Commit 973931ae authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Simon Horman

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: default avatarLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Acked-by: default avatarPaul Mundt <lethal@linux-sh.org>
Acked-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarSimon Horman <horms+renesas@verge.net.au>
parent 40ee6fce
...@@ -26,21 +26,33 @@ ...@@ -26,21 +26,33 @@
#include "core.h" #include "core.h"
static int sh_pfc_ioremap(struct sh_pfc *pfc) static int sh_pfc_ioremap(struct sh_pfc *pfc, struct platform_device *pdev)
{ {
unsigned int num_resources;
struct resource *res; struct resource *res;
int k; int k;
if (!pfc->pdata->num_resources) if (pdev->num_resources) {
num_resources = pdev->num_resources;
res = pdev->resource;
} else {
num_resources = pfc->pdata->num_resources;
res = pfc->pdata->resource;
}
if (num_resources == 0) {
pfc->num_windows = 0;
return 0; return 0;
}
pfc->window = devm_kzalloc(pfc->dev, pfc->pdata->num_resources * pfc->window = devm_kzalloc(pfc->dev, num_resources *
sizeof(*pfc->window), GFP_NOWAIT); sizeof(*pfc->window), GFP_NOWAIT);
if (!pfc->window) if (!pfc->window)
return -ENOMEM; return -ENOMEM;
for (k = 0; k < pfc->pdata->num_resources; k++) { pfc->num_windows = num_resources;
res = pfc->pdata->resource + k;
for (k = 0; k < num_resources; k++, res++) {
WARN_ON(resource_type(res) != IORESOURCE_MEM); WARN_ON(resource_type(res) != IORESOURCE_MEM);
pfc->window[k].phys = res->start; pfc->window[k].phys = res->start;
pfc->window[k].size = resource_size(res); pfc->window[k].size = resource_size(res);
...@@ -60,7 +72,7 @@ static void __iomem *sh_pfc_phys_to_virt(struct sh_pfc *pfc, ...@@ -60,7 +72,7 @@ static void __iomem *sh_pfc_phys_to_virt(struct sh_pfc *pfc,
int k; int k;
/* scan through physical windows and convert address */ /* scan through physical windows and convert address */
for (k = 0; k < pfc->pdata->num_resources; k++) { for (k = 0; k < pfc->num_windows; k++) {
window = pfc->window + k; window = pfc->window + k;
if (address < window->phys) if (address < window->phys)
...@@ -498,7 +510,7 @@ static int sh_pfc_probe(struct platform_device *pdev) ...@@ -498,7 +510,7 @@ static int sh_pfc_probe(struct platform_device *pdev)
pfc->pdata = pdata; pfc->pdata = pdata;
pfc->dev = &pdev->dev; pfc->dev = &pdev->dev;
ret = sh_pfc_ioremap(pfc); ret = sh_pfc_ioremap(pfc, pdev);
if (unlikely(ret < 0)) if (unlikely(ret < 0))
return ret; return ret;
......
...@@ -28,7 +28,9 @@ struct sh_pfc { ...@@ -28,7 +28,9 @@ struct sh_pfc {
struct sh_pfc_platform_data *pdata; struct sh_pfc_platform_data *pdata;
spinlock_t lock; spinlock_t lock;
unsigned int num_windows;
struct sh_pfc_window *window; struct sh_pfc_window *window;
struct sh_pfc_chip *gpio; struct sh_pfc_chip *gpio;
struct sh_pfc_pinctrl *pinctrl; struct sh_pfc_pinctrl *pinctrl;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment