aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/sh
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>2012-12-15 17:50:55 -0500
committerSimon Horman <horms+renesas@verge.net.au>2013-01-24 19:24:22 -0500
commit973931ae0a2dad57e23ce0ca2fab5abed9cf0d9a (patch)
tree57775891c71f319afbf0dd6ad9f6fc478d4853a1 /drivers/sh
parent40ee6fce7a0d3a2b2a1f2a14900af98a49a9ff40 (diff)
sh-pfc: Support passing resources through platform device
Resources should be passed through the platform device, not through platform data. Default to platform device resources and fall back to platform data resources if not available. Support for platform data resources will be removed when arch code will be converted. Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> Acked-by: Paul Mundt <lethal@linux-sh.org> Acked-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Simon Horman <horms+renesas@verge.net.au>
Diffstat (limited to 'drivers/sh')
-rw-r--r--drivers/sh/pfc/core.c26
-rw-r--r--drivers/sh/pfc/core.h2
2 files changed, 21 insertions, 7 deletions
diff --git a/drivers/sh/pfc/core.c b/drivers/sh/pfc/core.c
index cd8f09dcea95..b2e121d927a0 100644
--- a/drivers/sh/pfc/core.c
+++ b/drivers/sh/pfc/core.c
@@ -26,21 +26,33 @@
26 26
27#include "core.h" 27#include "core.h"
28 28
29static int sh_pfc_ioremap(struct sh_pfc *pfc) 29static int sh_pfc_ioremap(struct sh_pfc *pfc, struct platform_device *pdev)
30{ 30{
31 unsigned int num_resources;
31 struct resource *res; 32 struct resource *res;
32 int k; 33 int k;
33 34
34 if (!pfc->pdata->num_resources) 35 if (pdev->num_resources) {
36 num_resources = pdev->num_resources;
37 res = pdev->resource;
38 } else {
39 num_resources = pfc->pdata->num_resources;
40 res = pfc->pdata->resource;
41 }
42
43 if (num_resources == 0) {
44 pfc->num_windows = 0;
35 return 0; 45 return 0;
46 }
36 47
37 pfc->window = devm_kzalloc(pfc->dev, pfc->pdata->num_resources * 48 pfc->window = devm_kzalloc(pfc->dev, num_resources *
38 sizeof(*pfc->window), GFP_NOWAIT); 49 sizeof(*pfc->window), GFP_NOWAIT);
39 if (!pfc->window) 50 if (!pfc->window)
40 return -ENOMEM; 51 return -ENOMEM;
41 52
42 for (k = 0; k < pfc->pdata->num_resources; k++) { 53 pfc->num_windows = num_resources;
43 res = pfc->pdata->resource + k; 54
55 for (k = 0; k < num_resources; k++, res++) {
44 WARN_ON(resource_type(res) != IORESOURCE_MEM); 56 WARN_ON(resource_type(res) != IORESOURCE_MEM);
45 pfc->window[k].phys = res->start; 57 pfc->window[k].phys = res->start;
46 pfc->window[k].size = resource_size(res); 58 pfc->window[k].size = resource_size(res);
@@ -60,7 +72,7 @@ static void __iomem *sh_pfc_phys_to_virt(struct sh_pfc *pfc,
60 int k; 72 int k;
61 73
62 /* scan through physical windows and convert address */ 74 /* scan through physical windows and convert address */
63 for (k = 0; k < pfc->pdata->num_resources; k++) { 75 for (k = 0; k < pfc->num_windows; k++) {
64 window = pfc->window + k; 76 window = pfc->window + k;
65 77
66 if (address < window->phys) 78 if (address < window->phys)
@@ -498,7 +510,7 @@ static int sh_pfc_probe(struct platform_device *pdev)
498 pfc->pdata = pdata; 510 pfc->pdata = pdata;
499 pfc->dev = &pdev->dev; 511 pfc->dev = &pdev->dev;
500 512
501 ret = sh_pfc_ioremap(pfc); 513 ret = sh_pfc_ioremap(pfc, pdev);
502 if (unlikely(ret < 0)) 514 if (unlikely(ret < 0))
503 return ret; 515 return ret;
504 516
diff --git a/drivers/sh/pfc/core.h b/drivers/sh/pfc/core.h
index d6a40bc592ff..87ae5fd2a201 100644
--- a/drivers/sh/pfc/core.h
+++ b/drivers/sh/pfc/core.h
@@ -28,7 +28,9 @@ struct sh_pfc {
28 struct sh_pfc_platform_data *pdata; 28 struct sh_pfc_platform_data *pdata;
29 spinlock_t lock; 29 spinlock_t lock;
30 30
31 unsigned int num_windows;
31 struct sh_pfc_window *window; 32 struct sh_pfc_window *window;
33
32 struct sh_pfc_chip *gpio; 34 struct sh_pfc_chip *gpio;
33 struct sh_pfc_pinctrl *pinctrl; 35 struct sh_pfc_pinctrl *pinctrl;
34}; 36};