diff options
author | Lee Jones <lee.jones@linaro.org> | 2013-01-31 06:07:40 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2013-02-06 16:38:48 -0500 |
commit | f30a3839b33c560b374c69be9ba2621d3d6a3d10 (patch) | |
tree | 97cb517942efbf5a3dd611824c7ad3809d39b2b4 | |
parent | b9fab6e45d2d41de5495f7d40808e9e131652f92 (diff) |
pinctrl/abx500: add Device Tree support
This patch will allow the ABX500 Pinctrl driver to be probed when
Device Tree is enabled with an appropriate node contained.
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
-rw-r--r-- | drivers/pinctrl/pinctrl-abx500.c | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/drivers/pinctrl/pinctrl-abx500.c b/drivers/pinctrl/pinctrl-abx500.c index a9e720ffabfb..17508b5820f5 100644 --- a/drivers/pinctrl/pinctrl-abx500.c +++ b/drivers/pinctrl/pinctrl-abx500.c | |||
@@ -14,6 +14,8 @@ | |||
14 | #include <linux/init.h> | 14 | #include <linux/init.h> |
15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
16 | #include <linux/err.h> | 16 | #include <linux/err.h> |
17 | #include <linux/of.h> | ||
18 | #include <linux/of_device.h> | ||
17 | #include <linux/platform_device.h> | 19 | #include <linux/platform_device.h> |
18 | #include <linux/gpio.h> | 20 | #include <linux/gpio.h> |
19 | #include <linux/irq.h> | 21 | #include <linux/irq.h> |
@@ -1106,22 +1108,44 @@ static int abx500_get_gpio_num(struct abx500_pinctrl_soc_data *soc) | |||
1106 | return npins; | 1108 | return npins; |
1107 | } | 1109 | } |
1108 | 1110 | ||
1111 | static const struct of_device_id abx500_gpio_match[] = { | ||
1112 | { .compatible = "stericsson,ab8500-gpio", .data = (void *)PINCTRL_AB8500, }, | ||
1113 | { .compatible = "stericsson,ab8505-gpio", .data = (void *)PINCTRL_AB8505, }, | ||
1114 | { .compatible = "stericsson,ab8540-gpio", .data = (void *)PINCTRL_AB8540, }, | ||
1115 | { .compatible = "stericsson,ab9540-gpio", .data = (void *)PINCTRL_AB9540, }, | ||
1116 | }; | ||
1117 | |||
1109 | static int abx500_gpio_probe(struct platform_device *pdev) | 1118 | static int abx500_gpio_probe(struct platform_device *pdev) |
1110 | { | 1119 | { |
1111 | struct ab8500_platform_data *abx500_pdata = | 1120 | struct ab8500_platform_data *abx500_pdata = |
1112 | dev_get_platdata(pdev->dev.parent); | 1121 | dev_get_platdata(pdev->dev.parent); |
1113 | struct abx500_gpio_platform_data *pdata; | 1122 | struct abx500_gpio_platform_data *pdata = NULL; |
1123 | struct device_node *np = pdev->dev.of_node; | ||
1114 | struct abx500_pinctrl *pct; | 1124 | struct abx500_pinctrl *pct; |
1115 | const struct platform_device_id *platid = platform_get_device_id(pdev); | 1125 | const struct platform_device_id *platid = platform_get_device_id(pdev); |
1126 | unsigned int id = -1; | ||
1116 | int ret, err; | 1127 | int ret, err; |
1117 | int i; | 1128 | int i; |
1118 | 1129 | ||
1119 | pdata = abx500_pdata->gpio; | 1130 | if (abx500_pdata) |
1131 | pdata = abx500_pdata->gpio; | ||
1120 | if (!pdata) { | 1132 | if (!pdata) { |
1121 | dev_err(&pdev->dev, "gpio platform data missing\n"); | 1133 | if (np) { |
1122 | return -ENODEV; | 1134 | const struct of_device_id *match; |
1135 | |||
1136 | match = of_match_device(abx500_gpio_match, &pdev->dev); | ||
1137 | if (!match) | ||
1138 | return -ENODEV; | ||
1139 | id = (unsigned long)match->data; | ||
1140 | } else { | ||
1141 | dev_err(&pdev->dev, "gpio dt and platform data missing\n"); | ||
1142 | return -ENODEV; | ||
1143 | } | ||
1123 | } | 1144 | } |
1124 | 1145 | ||
1146 | if (platid) | ||
1147 | id = platid->driver_data; | ||
1148 | |||
1125 | pct = devm_kzalloc(&pdev->dev, sizeof(struct abx500_pinctrl), | 1149 | pct = devm_kzalloc(&pdev->dev, sizeof(struct abx500_pinctrl), |
1126 | GFP_KERNEL); | 1150 | GFP_KERNEL); |
1127 | if (pct == NULL) { | 1151 | if (pct == NULL) { |
@@ -1136,12 +1160,13 @@ static int abx500_gpio_probe(struct platform_device *pdev) | |||
1136 | pct->chip.dev = &pdev->dev; | 1160 | pct->chip.dev = &pdev->dev; |
1137 | pct->chip.base = pdata->gpio_base; | 1161 | pct->chip.base = pdata->gpio_base; |
1138 | pct->irq_base = pdata->irq_base; | 1162 | pct->irq_base = pdata->irq_base; |
1163 | pct->chip.base = (np) ? -1 : pdata->gpio_base; | ||
1139 | 1164 | ||
1140 | /* initialize the lock */ | 1165 | /* initialize the lock */ |
1141 | mutex_init(&pct->lock); | 1166 | mutex_init(&pct->lock); |
1142 | 1167 | ||
1143 | /* Poke in other ASIC variants here */ | 1168 | /* Poke in other ASIC variants here */ |
1144 | switch (platid->driver_data) { | 1169 | switch (id) { |
1145 | case PINCTRL_AB8500: | 1170 | case PINCTRL_AB8500: |
1146 | abx500_pinctrl_ab8500_init(&pct->soc); | 1171 | abx500_pinctrl_ab8500_init(&pct->soc); |
1147 | break; | 1172 | break; |
@@ -1256,6 +1281,7 @@ static struct platform_driver abx500_gpio_driver = { | |||
1256 | .driver = { | 1281 | .driver = { |
1257 | .name = "abx500-gpio", | 1282 | .name = "abx500-gpio", |
1258 | .owner = THIS_MODULE, | 1283 | .owner = THIS_MODULE, |
1284 | .of_match_table = abx500_gpio_match, | ||
1259 | }, | 1285 | }, |
1260 | .probe = abx500_gpio_probe, | 1286 | .probe = abx500_gpio_probe, |
1261 | .remove = abx500_gpio_remove, | 1287 | .remove = abx500_gpio_remove, |