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 /drivers/pci | |
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>
Diffstat (limited to 'drivers/pci')
-rw-r--r-- | drivers/pci/host/pci-rcar-gen2.c | 31 |
1 files changed, 29 insertions, 2 deletions
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 | }; |