linux-mips
[Top] [All Lists]

Re: [PATCH 02/14] MIPS: pci: parse memory ranges from devicetree

To: John Crispin <blogic@openwrt.org>
Subject: Re: [PATCH 02/14] MIPS: pci: parse memory ranges from devicetree
From: Geert Uytterhoeven <geert@linux-m68k.org>
Date: Thu, 3 May 2012 21:30:20 +0200
Cc: Ralf Baechle <ralf@linux-mips.org>, "linux-mips@linux-mips.org" <linux-mips@linux-mips.org>
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=l1DlFo0gltURw60q+cQHRq36KSU7X6VDNin+NMLqdcA=; b=fWH+5Yz2ykhSVzx1E9G5//L9eHEUHR7ecMvFNi+4fQrWPrfkj+bi5HkNkej//7AVaD UN07Veza9IaOzjVqqiti58dCDXoggrS9LyY1fVVu8sZ1l0/VlmKG6aJ5lHdHhsRailJF sLlSsN/r9983N5mB/Mepj1TKx9EuWBFPXlGNvdanBtDsSUfAJvjpP7rF1iKRVDTG3oC4 8b9f8NoqkIiya3ihe4n4r0hLTg9q3Z4kgfjVhe+qWHD7p4AXcUk2VWCWDrXBCIjGwK8+ fxAV18JBgCL7A6i3Rt5P21fmUVXfs1FwLbeUlYSnoYaN6B86qAAyyKJ0JQalcPZ++fEg rjtg==
In-reply-to: <1336066949-24546-1-git-send-email-blogic@openwrt.org>
References: <1336066949-24546-1-git-send-email-blogic@openwrt.org>
Sender: linux-mips-bounce@linux-mips.org
On Thu, May 3, 2012 at 7:42 PM, John Crispin <blogic@openwrt.org> wrote:
> Implement pci_load_of_ranges on MIPS. Due to lack of test hardware only 32bit
> bus width is supported. This function is based on the implementation found on
> powerpc.

There's no pci_load_of_ranges() in arch/powerpc/?

> +void __devinit pci_load_of_ranges(struct pci_controller *hose,
> +                               struct device_node *node)
> +{
> +       const __be32 *ranges;
> +       int rlen;
> +       int pna = of_n_addr_cells(node);
> +       int np = pna + 5;
> +
> +       pr_info("PCI host bridge %s ranges:\n", node->full_name);
> +       ranges = of_get_property(node, "ranges", &rlen);
> +       if (ranges == NULL)
> +               return;
> +       hose->of_node = node;
> +
> +       while ((rlen -= np * 4) >= 0) {
> +               u32 pci_space;
> +               struct resource *res = NULL;
> +               unsigned long long addr, size;

You better use u64, as that's what of_translate_address() and
of_read_number() return.

> +
> +               pci_space = ranges[0];

pci_space = be32_to_cpup(&ranges[0])

> +               addr = of_translate_address(node, ranges + 3);
> +               size = of_read_number(ranges + pna + 3, 2);

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

<Prev in Thread] Current Thread [Next in Thread>