diff options
author | Ben Dooks <ben.dooks@codethink.co.uk> | 2014-05-19 17:10:20 -0400 |
---|---|---|
committer | Bjorn Helgaas <bhelgaas@google.com> | 2014-05-28 09:47:55 -0400 |
commit | d47b62f4b1c0374517ccbdf3ee4a7cceead58905 (patch) | |
tree | 1aa8da898e7f309ca489867dbc958e5bf127e08b | |
parent | 7869fc6e295cbb1f80e30555bebbc795abb5b9a7 (diff) |
PCI: rcar: Add gen2 device tree support
Add device tree probing support to the 'pci-rcar-gen2' driver.
[Sergei: numerous fixes/cleanups/additions]
[bhelgaas: whitespace fix]
Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Simon Horman <horms+renesas@verge.net.au>
Acked-by: Arnd Bergmann <arnd@arndb.de>
-rw-r--r-- | Documentation/devicetree/bindings/pci/pci-rcar-gen2.txt | 66 | ||||
-rw-r--r-- | drivers/pci/host/pci-rcar-gen2.c | 31 |
2 files changed, 95 insertions, 2 deletions
diff --git a/Documentation/devicetree/bindings/pci/pci-rcar-gen2.txt b/Documentation/devicetree/bindings/pci/pci-rcar-gen2.txt new file mode 100644 index 000000000000..d8ef5bf50f11 --- /dev/null +++ b/Documentation/devicetree/bindings/pci/pci-rcar-gen2.txt | |||
@@ -0,0 +1,66 @@ | |||
1 | Renesas AHB to PCI bridge | ||
2 | ------------------------- | ||
3 | |||
4 | This is the bridge used internally to connect the USB controllers to the | ||
5 | AHB. There is one bridge instance per USB port connected to the internal | ||
6 | OHCI and EHCI controllers. | ||
7 | |||
8 | Required properties: | ||
9 | - compatible: "renesas,pci-r8a7790" for the R8A7790 SoC; | ||
10 | "renesas,pci-r8a7791" for the R8A7791 SoC. | ||
11 | - reg: A list of physical regions to access the device: the first is | ||
12 | the operational registers for the OHCI/EHCI controllers and the | ||
13 | second is for the bridge configuration and control registers. | ||
14 | - interrupts: interrupt for the device. | ||
15 | - clocks: The reference to the device clock. | ||
16 | - bus-range: The PCI bus number range; as this is a single bus, the range | ||
17 | should be specified as the same value twice. | ||
18 | - #address-cells: must be 3. | ||
19 | - #size-cells: must be 2. | ||
20 | - #interrupt-cells: must be 1. | ||
21 | - interrupt-map: standard property used to define the mapping of the PCI | ||
22 | interrupts to the GIC interrupts. | ||
23 | - interrupt-map-mask: standard property that helps to define the interrupt | ||
24 | mapping. | ||
25 | |||
26 | Example SoC configuration: | ||
27 | |||
28 | pci0: pci@ee090000 { | ||
29 | compatible = "renesas,pci-r8a7790"; | ||
30 | clocks = <&mstp7_clks R8A7790_CLK_EHCI>; | ||
31 | reg = <0x0 0xee090000 0x0 0xc00>, | ||
32 | <0x0 0xee080000 0x0 0x1100>; | ||
33 | interrupts = <0 108 IRQ_TYPE_LEVEL_HIGH>; | ||
34 | status = "disabled"; | ||
35 | |||
36 | bus-range = <0 0>; | ||
37 | #address-cells = <3>; | ||
38 | #size-cells = <2>; | ||
39 | #interrupt-cells = <1>; | ||
40 | interrupt-map-mask = <0xff00 0 0 0x7>; | ||
41 | interrupt-map = <0x0000 0 0 1 &gic 0 108 IRQ_TYPE_LEVEL_HIGH | ||
42 | 0x0800 0 0 1 &gic 0 108 IRQ_TYPE_LEVEL_HIGH | ||
43 | 0x1000 0 0 2 &gic 0 108 IRQ_TYPE_LEVEL_HIGH>; | ||
44 | |||
45 | pci@0,1 { | ||
46 | reg = <0x800 0 0 0 0>; | ||
47 | device_type = "pci"; | ||
48 | phys = <&usbphy 0 0>; | ||
49 | phy-names = "usb"; | ||
50 | }; | ||
51 | |||
52 | pci@0,2 { | ||
53 | reg = <0x1000 0 0 0 0>; | ||
54 | device_type = "pci"; | ||
55 | phys = <&usbphy 0 0>; | ||
56 | phy-names = "usb"; | ||
57 | }; | ||
58 | }; | ||
59 | |||
60 | Example board setup: | ||
61 | |||
62 | &pci0 { | ||
63 | status = "okay"; | ||
64 | pinctrl-0 = <&usb0_pins>; | ||
65 | pinctrl-names = "default"; | ||
66 | }; | ||
diff --git a/drivers/pci/host/pci-rcar-gen2.c b/drivers/pci/host/pci-rcar-gen2.c index 4fe349dcaf59..3ef854f5a5b5 100644 --- a/drivers/pci/host/pci-rcar-gen2.c +++ b/drivers/pci/host/pci-rcar-gen2.c | |||
@@ -99,6 +99,7 @@ struct rcar_pci_priv { | |||
99 | struct resource io_res; | 99 | struct resource io_res; |
100 | struct resource mem_res; | 100 | struct resource mem_res; |
101 | struct resource *cfg_res; | 101 | struct resource *cfg_res; |
102 | unsigned busnr; | ||
102 | int irq; | 103 | int irq; |
103 | unsigned long window_size; | 104 | unsigned long window_size; |
104 | }; | 105 | }; |
@@ -318,8 +319,8 @@ static int rcar_pci_setup(int nr, struct pci_sys_data *sys) | |||
318 | pci_add_resource(&sys->resources, &priv->io_res); | 319 | pci_add_resource(&sys->resources, &priv->io_res); |
319 | pci_add_resource(&sys->resources, &priv->mem_res); | 320 | pci_add_resource(&sys->resources, &priv->mem_res); |
320 | 321 | ||
321 | /* Setup bus number based on platform device id */ | 322 | /* Setup bus number based on platform device id / of bus-range */ |
322 | sys->busnr = to_platform_device(priv->dev)->id; | 323 | sys->busnr = priv->busnr; |
323 | return 1; | 324 | return 1; |
324 | } | 325 | } |
325 | 326 | ||
@@ -372,6 +373,23 @@ static int rcar_pci_probe(struct platform_device *pdev) | |||
372 | 373 | ||
373 | priv->window_size = SZ_1G; | 374 | priv->window_size = SZ_1G; |
374 | 375 | ||
376 | if (pdev->dev.of_node) { | ||
377 | struct resource busnr; | ||
378 | int ret; | ||
379 | |||
380 | ret = of_pci_parse_bus_range(pdev->dev.of_node, &busnr); | ||
381 | if (ret < 0) { | ||
382 | dev_err(&pdev->dev, "failed to parse bus-range\n"); | ||
383 | return ret; | ||
384 | } | ||
385 | |||
386 | priv->busnr = busnr.start; | ||
387 | if (busnr.end != busnr.start) | ||
388 | dev_warn(&pdev->dev, "only one bus number supported\n"); | ||
389 | } else { | ||
390 | priv->busnr = pdev->id; | ||
391 | } | ||
392 | |||
375 | hw_private[0] = priv; | 393 | hw_private[0] = priv; |
376 | memset(&hw, 0, sizeof(hw)); | 394 | memset(&hw, 0, sizeof(hw)); |
377 | hw.nr_controllers = ARRAY_SIZE(hw_private); | 395 | hw.nr_controllers = ARRAY_SIZE(hw_private); |
@@ -383,11 +401,20 @@ static int rcar_pci_probe(struct platform_device *pdev) | |||
383 | return 0; | 401 | return 0; |
384 | } | 402 | } |
385 | 403 | ||
404 | static struct of_device_id rcar_pci_of_match[] = { | ||
405 | { .compatible = "renesas,pci-r8a7790", }, | ||
406 | { .compatible = "renesas,pci-r8a7791", }, | ||
407 | { }, | ||
408 | }; | ||
409 | |||
410 | MODULE_DEVICE_TABLE(of, rcar_pci_of_match); | ||
411 | |||
386 | static struct platform_driver rcar_pci_driver = { | 412 | static struct platform_driver rcar_pci_driver = { |
387 | .driver = { | 413 | .driver = { |
388 | .name = "pci-rcar-gen2", | 414 | .name = "pci-rcar-gen2", |
389 | .owner = THIS_MODULE, | 415 | .owner = THIS_MODULE, |
390 | .suppress_bind_attrs = true, | 416 | .suppress_bind_attrs = true, |
417 | .of_match_table = rcar_pci_of_match, | ||
391 | }, | 418 | }, |
392 | .probe = rcar_pci_probe, | 419 | .probe = rcar_pci_probe, |
393 | }; | 420 | }; |