diff options
Diffstat (limited to 'drivers/pinctrl/pinctrl-nomadik.c')
-rw-r--r-- | drivers/pinctrl/pinctrl-nomadik.c | 296 |
1 files changed, 237 insertions, 59 deletions
diff --git a/drivers/pinctrl/pinctrl-nomadik.c b/drivers/pinctrl/pinctrl-nomadik.c index 7111c3b59130..983662e846a4 100644 --- a/drivers/pinctrl/pinctrl-nomadik.c +++ b/drivers/pinctrl/pinctrl-nomadik.c | |||
@@ -4,7 +4,7 @@ | |||
4 | * Copyright (C) 2008,2009 STMicroelectronics | 4 | * Copyright (C) 2008,2009 STMicroelectronics |
5 | * Copyright (C) 2009 Alessandro Rubini <rubini@unipv.it> | 5 | * Copyright (C) 2009 Alessandro Rubini <rubini@unipv.it> |
6 | * Rewritten based on work by Prafulla WADASKAR <prafulla.wadaskar@st.com> | 6 | * Rewritten based on work by Prafulla WADASKAR <prafulla.wadaskar@st.com> |
7 | * Copyright (C) 2011 Linus Walleij <linus.walleij@linaro.org> | 7 | * Copyright (C) 2011-2013 Linus Walleij <linus.walleij@linaro.org> |
8 | * | 8 | * |
9 | * This program is free software; you can redistribute it and/or modify | 9 | * This program is free software; you can redistribute it and/or modify |
10 | * it under the terms of the GNU General Public License version 2 as | 10 | * it under the terms of the GNU General Public License version 2 as |
@@ -33,7 +33,6 @@ | |||
33 | #include <linux/pinctrl/pinconf.h> | 33 | #include <linux/pinctrl/pinconf.h> |
34 | /* Since we request GPIOs from ourself */ | 34 | /* Since we request GPIOs from ourself */ |
35 | #include <linux/pinctrl/consumer.h> | 35 | #include <linux/pinctrl/consumer.h> |
36 | #include <linux/platform_data/pinctrl-nomadik.h> | ||
37 | #include "pinctrl-nomadik.h" | 36 | #include "pinctrl-nomadik.h" |
38 | #include "core.h" | 37 | #include "core.h" |
39 | 38 | ||
@@ -45,6 +44,221 @@ | |||
45 | * Symbols in this file are called "nmk_gpio" for "nomadik gpio" | 44 | * Symbols in this file are called "nmk_gpio" for "nomadik gpio" |
46 | */ | 45 | */ |
47 | 46 | ||
47 | /* | ||
48 | * pin configurations are represented by 32-bit integers: | ||
49 | * | ||
50 | * bit 0.. 8 - Pin Number (512 Pins Maximum) | ||
51 | * bit 9..10 - Alternate Function Selection | ||
52 | * bit 11..12 - Pull up/down state | ||
53 | * bit 13 - Sleep mode behaviour | ||
54 | * bit 14 - Direction | ||
55 | * bit 15 - Value (if output) | ||
56 | * bit 16..18 - SLPM pull up/down state | ||
57 | * bit 19..20 - SLPM direction | ||
58 | * bit 21..22 - SLPM Value (if output) | ||
59 | * bit 23..25 - PDIS value (if input) | ||
60 | * bit 26 - Gpio mode | ||
61 | * bit 27 - Sleep mode | ||
62 | * | ||
63 | * to facilitate the definition, the following macros are provided | ||
64 | * | ||
65 | * PIN_CFG_DEFAULT - default config (0): | ||
66 | * pull up/down = disabled | ||
67 | * sleep mode = input/wakeup | ||
68 | * direction = input | ||
69 | * value = low | ||
70 | * SLPM direction = same as normal | ||
71 | * SLPM pull = same as normal | ||
72 | * SLPM value = same as normal | ||
73 | * | ||
74 | * PIN_CFG - default config with alternate function | ||
75 | */ | ||
76 | |||
77 | typedef unsigned long pin_cfg_t; | ||
78 | |||
79 | #define PIN_NUM_MASK 0x1ff | ||
80 | #define PIN_NUM(x) ((x) & PIN_NUM_MASK) | ||
81 | |||
82 | #define PIN_ALT_SHIFT 9 | ||
83 | #define PIN_ALT_MASK (0x3 << PIN_ALT_SHIFT) | ||
84 | #define PIN_ALT(x) (((x) & PIN_ALT_MASK) >> PIN_ALT_SHIFT) | ||
85 | #define PIN_GPIO (NMK_GPIO_ALT_GPIO << PIN_ALT_SHIFT) | ||
86 | #define PIN_ALT_A (NMK_GPIO_ALT_A << PIN_ALT_SHIFT) | ||
87 | #define PIN_ALT_B (NMK_GPIO_ALT_B << PIN_ALT_SHIFT) | ||
88 | #define PIN_ALT_C (NMK_GPIO_ALT_C << PIN_ALT_SHIFT) | ||
89 | |||
90 | #define PIN_PULL_SHIFT 11 | ||
91 | #define PIN_PULL_MASK (0x3 << PIN_PULL_SHIFT) | ||
92 | #define PIN_PULL(x) (((x) & PIN_PULL_MASK) >> PIN_PULL_SHIFT) | ||
93 | #define PIN_PULL_NONE (NMK_GPIO_PULL_NONE << PIN_PULL_SHIFT) | ||
94 | #define PIN_PULL_UP (NMK_GPIO_PULL_UP << PIN_PULL_SHIFT) | ||
95 | #define PIN_PULL_DOWN (NMK_GPIO_PULL_DOWN << PIN_PULL_SHIFT) | ||
96 | |||
97 | #define PIN_SLPM_SHIFT 13 | ||
98 | #define PIN_SLPM_MASK (0x1 << PIN_SLPM_SHIFT) | ||
99 | #define PIN_SLPM(x) (((x) & PIN_SLPM_MASK) >> PIN_SLPM_SHIFT) | ||
100 | #define PIN_SLPM_MAKE_INPUT (NMK_GPIO_SLPM_INPUT << PIN_SLPM_SHIFT) | ||
101 | #define PIN_SLPM_NOCHANGE (NMK_GPIO_SLPM_NOCHANGE << PIN_SLPM_SHIFT) | ||
102 | /* These two replace the above in DB8500v2+ */ | ||
103 | #define PIN_SLPM_WAKEUP_ENABLE (NMK_GPIO_SLPM_WAKEUP_ENABLE << PIN_SLPM_SHIFT) | ||
104 | #define PIN_SLPM_WAKEUP_DISABLE (NMK_GPIO_SLPM_WAKEUP_DISABLE << PIN_SLPM_SHIFT) | ||
105 | #define PIN_SLPM_USE_MUX_SETTINGS_IN_SLEEP PIN_SLPM_WAKEUP_DISABLE | ||
106 | |||
107 | #define PIN_SLPM_GPIO PIN_SLPM_WAKEUP_ENABLE /* In SLPM, pin is a gpio */ | ||
108 | #define PIN_SLPM_ALTFUNC PIN_SLPM_WAKEUP_DISABLE /* In SLPM, pin is altfunc */ | ||
109 | |||
110 | #define PIN_DIR_SHIFT 14 | ||
111 | #define PIN_DIR_MASK (0x1 << PIN_DIR_SHIFT) | ||
112 | #define PIN_DIR(x) (((x) & PIN_DIR_MASK) >> PIN_DIR_SHIFT) | ||
113 | #define PIN_DIR_INPUT (0 << PIN_DIR_SHIFT) | ||
114 | #define PIN_DIR_OUTPUT (1 << PIN_DIR_SHIFT) | ||
115 | |||
116 | #define PIN_VAL_SHIFT 15 | ||
117 | #define PIN_VAL_MASK (0x1 << PIN_VAL_SHIFT) | ||
118 | #define PIN_VAL(x) (((x) & PIN_VAL_MASK) >> PIN_VAL_SHIFT) | ||
119 | #define PIN_VAL_LOW (0 << PIN_VAL_SHIFT) | ||
120 | #define PIN_VAL_HIGH (1 << PIN_VAL_SHIFT) | ||
121 | |||
122 | #define PIN_SLPM_PULL_SHIFT 16 | ||
123 | #define PIN_SLPM_PULL_MASK (0x7 << PIN_SLPM_PULL_SHIFT) | ||
124 | #define PIN_SLPM_PULL(x) \ | ||
125 | (((x) & PIN_SLPM_PULL_MASK) >> PIN_SLPM_PULL_SHIFT) | ||
126 | #define PIN_SLPM_PULL_NONE \ | ||
127 | ((1 + NMK_GPIO_PULL_NONE) << PIN_SLPM_PULL_SHIFT) | ||
128 | #define PIN_SLPM_PULL_UP \ | ||
129 | ((1 + NMK_GPIO_PULL_UP) << PIN_SLPM_PULL_SHIFT) | ||
130 | #define PIN_SLPM_PULL_DOWN \ | ||
131 | ((1 + NMK_GPIO_PULL_DOWN) << PIN_SLPM_PULL_SHIFT) | ||
132 | |||
133 | #define PIN_SLPM_DIR_SHIFT 19 | ||
134 | #define PIN_SLPM_DIR_MASK (0x3 << PIN_SLPM_DIR_SHIFT) | ||
135 | #define PIN_SLPM_DIR(x) \ | ||
136 | (((x) & PIN_SLPM_DIR_MASK) >> PIN_SLPM_DIR_SHIFT) | ||
137 | #define PIN_SLPM_DIR_INPUT ((1 + 0) << PIN_SLPM_DIR_SHIFT) | ||
138 | #define PIN_SLPM_DIR_OUTPUT ((1 + 1) << PIN_SLPM_DIR_SHIFT) | ||
139 | |||
140 | #define PIN_SLPM_VAL_SHIFT 21 | ||
141 | #define PIN_SLPM_VAL_MASK (0x3 << PIN_SLPM_VAL_SHIFT) | ||
142 | #define PIN_SLPM_VAL(x) \ | ||
143 | (((x) & PIN_SLPM_VAL_MASK) >> PIN_SLPM_VAL_SHIFT) | ||
144 | #define PIN_SLPM_VAL_LOW ((1 + 0) << PIN_SLPM_VAL_SHIFT) | ||
145 | #define PIN_SLPM_VAL_HIGH ((1 + 1) << PIN_SLPM_VAL_SHIFT) | ||
146 | |||
147 | #define PIN_SLPM_PDIS_SHIFT 23 | ||
148 | #define PIN_SLPM_PDIS_MASK (0x3 << PIN_SLPM_PDIS_SHIFT) | ||
149 | #define PIN_SLPM_PDIS(x) \ | ||
150 | (((x) & PIN_SLPM_PDIS_MASK) >> PIN_SLPM_PDIS_SHIFT) | ||
151 | #define PIN_SLPM_PDIS_NO_CHANGE (0 << PIN_SLPM_PDIS_SHIFT) | ||
152 | #define PIN_SLPM_PDIS_DISABLED (1 << PIN_SLPM_PDIS_SHIFT) | ||
153 | #define PIN_SLPM_PDIS_ENABLED (2 << PIN_SLPM_PDIS_SHIFT) | ||
154 | |||
155 | #define PIN_LOWEMI_SHIFT 25 | ||
156 | #define PIN_LOWEMI_MASK (0x1 << PIN_LOWEMI_SHIFT) | ||
157 | #define PIN_LOWEMI(x) (((x) & PIN_LOWEMI_MASK) >> PIN_LOWEMI_SHIFT) | ||
158 | #define PIN_LOWEMI_DISABLED (0 << PIN_LOWEMI_SHIFT) | ||
159 | #define PIN_LOWEMI_ENABLED (1 << PIN_LOWEMI_SHIFT) | ||
160 | |||
161 | #define PIN_GPIOMODE_SHIFT 26 | ||
162 | #define PIN_GPIOMODE_MASK (0x1 << PIN_GPIOMODE_SHIFT) | ||
163 | #define PIN_GPIOMODE(x) (((x) & PIN_GPIOMODE_MASK) >> PIN_GPIOMODE_SHIFT) | ||
164 | #define PIN_GPIOMODE_DISABLED (0 << PIN_GPIOMODE_SHIFT) | ||
165 | #define PIN_GPIOMODE_ENABLED (1 << PIN_GPIOMODE_SHIFT) | ||
166 | |||
167 | #define PIN_SLEEPMODE_SHIFT 27 | ||
168 | #define PIN_SLEEPMODE_MASK (0x1 << PIN_SLEEPMODE_SHIFT) | ||
169 | #define PIN_SLEEPMODE(x) (((x) & PIN_SLEEPMODE_MASK) >> PIN_SLEEPMODE_SHIFT) | ||
170 | #define PIN_SLEEPMODE_DISABLED (0 << PIN_SLEEPMODE_SHIFT) | ||
171 | #define PIN_SLEEPMODE_ENABLED (1 << PIN_SLEEPMODE_SHIFT) | ||
172 | |||
173 | |||
174 | /* Shortcuts. Use these instead of separate DIR, PULL, and VAL. */ | ||
175 | #define PIN_INPUT_PULLDOWN (PIN_DIR_INPUT | PIN_PULL_DOWN) | ||
176 | #define PIN_INPUT_PULLUP (PIN_DIR_INPUT | PIN_PULL_UP) | ||
177 | #define PIN_INPUT_NOPULL (PIN_DIR_INPUT | PIN_PULL_NONE) | ||
178 | #define PIN_OUTPUT_LOW (PIN_DIR_OUTPUT | PIN_VAL_LOW) | ||
179 | #define PIN_OUTPUT_HIGH (PIN_DIR_OUTPUT | PIN_VAL_HIGH) | ||
180 | |||
181 | #define PIN_SLPM_INPUT_PULLDOWN (PIN_SLPM_DIR_INPUT | PIN_SLPM_PULL_DOWN) | ||
182 | #define PIN_SLPM_INPUT_PULLUP (PIN_SLPM_DIR_INPUT | PIN_SLPM_PULL_UP) | ||
183 | #define PIN_SLPM_INPUT_NOPULL (PIN_SLPM_DIR_INPUT | PIN_SLPM_PULL_NONE) | ||
184 | #define PIN_SLPM_OUTPUT_LOW (PIN_SLPM_DIR_OUTPUT | PIN_SLPM_VAL_LOW) | ||
185 | #define PIN_SLPM_OUTPUT_HIGH (PIN_SLPM_DIR_OUTPUT | PIN_SLPM_VAL_HIGH) | ||
186 | |||
187 | #define PIN_CFG_DEFAULT (0) | ||
188 | |||
189 | #define PIN_CFG(num, alt) \ | ||
190 | (PIN_CFG_DEFAULT |\ | ||
191 | (PIN_NUM(num) | PIN_##alt)) | ||
192 | |||
193 | #define PIN_CFG_INPUT(num, alt, pull) \ | ||
194 | (PIN_CFG_DEFAULT |\ | ||
195 | (PIN_NUM(num) | PIN_##alt | PIN_INPUT_##pull)) | ||
196 | |||
197 | #define PIN_CFG_OUTPUT(num, alt, val) \ | ||
198 | (PIN_CFG_DEFAULT |\ | ||
199 | (PIN_NUM(num) | PIN_##alt | PIN_OUTPUT_##val)) | ||
200 | |||
201 | /* | ||
202 | * "nmk_gpio" and "NMK_GPIO" stand for "Nomadik GPIO", leaving | ||
203 | * the "gpio" namespace for generic and cross-machine functions | ||
204 | */ | ||
205 | |||
206 | #define GPIO_BLOCK_SHIFT 5 | ||
207 | #define NMK_GPIO_PER_CHIP (1 << GPIO_BLOCK_SHIFT) | ||
208 | |||
209 | /* Register in the logic block */ | ||
210 | #define NMK_GPIO_DAT 0x00 | ||
211 | #define NMK_GPIO_DATS 0x04 | ||
212 | #define NMK_GPIO_DATC 0x08 | ||
213 | #define NMK_GPIO_PDIS 0x0c | ||
214 | #define NMK_GPIO_DIR 0x10 | ||
215 | #define NMK_GPIO_DIRS 0x14 | ||
216 | #define NMK_GPIO_DIRC 0x18 | ||
217 | #define NMK_GPIO_SLPC 0x1c | ||
218 | #define NMK_GPIO_AFSLA 0x20 | ||
219 | #define NMK_GPIO_AFSLB 0x24 | ||
220 | #define NMK_GPIO_LOWEMI 0x28 | ||
221 | |||
222 | #define NMK_GPIO_RIMSC 0x40 | ||
223 | #define NMK_GPIO_FIMSC 0x44 | ||
224 | #define NMK_GPIO_IS 0x48 | ||
225 | #define NMK_GPIO_IC 0x4c | ||
226 | #define NMK_GPIO_RWIMSC 0x50 | ||
227 | #define NMK_GPIO_FWIMSC 0x54 | ||
228 | #define NMK_GPIO_WKS 0x58 | ||
229 | /* These appear in DB8540 and later ASICs */ | ||
230 | #define NMK_GPIO_EDGELEVEL 0x5C | ||
231 | #define NMK_GPIO_LEVEL 0x60 | ||
232 | |||
233 | |||
234 | /* Pull up/down values */ | ||
235 | enum nmk_gpio_pull { | ||
236 | NMK_GPIO_PULL_NONE, | ||
237 | NMK_GPIO_PULL_UP, | ||
238 | NMK_GPIO_PULL_DOWN, | ||
239 | }; | ||
240 | |||
241 | /* Sleep mode */ | ||
242 | enum nmk_gpio_slpm { | ||
243 | NMK_GPIO_SLPM_INPUT, | ||
244 | NMK_GPIO_SLPM_WAKEUP_ENABLE = NMK_GPIO_SLPM_INPUT, | ||
245 | NMK_GPIO_SLPM_NOCHANGE, | ||
246 | NMK_GPIO_SLPM_WAKEUP_DISABLE = NMK_GPIO_SLPM_NOCHANGE, | ||
247 | }; | ||
248 | |||
249 | /* | ||
250 | * Platform data to register a block: only the initial gpio/irq number. | ||
251 | */ | ||
252 | struct nmk_gpio_platform_data { | ||
253 | char *name; | ||
254 | int first_gpio; | ||
255 | int first_irq; | ||
256 | int num_gpio; | ||
257 | u32 (*get_secondary_status)(unsigned int bank); | ||
258 | void (*set_ioforce)(bool enable); | ||
259 | bool supports_sleepmode; | ||
260 | }; | ||
261 | |||
48 | struct nmk_gpio_chip { | 262 | struct nmk_gpio_chip { |
49 | struct gpio_chip chip; | 263 | struct gpio_chip chip; |
50 | struct irq_domain *domain; | 264 | struct irq_domain *domain; |
@@ -1026,7 +1240,7 @@ static const struct irq_domain_ops nmk_gpio_irq_simple_ops = { | |||
1026 | 1240 | ||
1027 | static int nmk_gpio_probe(struct platform_device *dev) | 1241 | static int nmk_gpio_probe(struct platform_device *dev) |
1028 | { | 1242 | { |
1029 | struct nmk_gpio_platform_data *pdata = dev->dev.platform_data; | 1243 | struct nmk_gpio_platform_data *pdata; |
1030 | struct device_node *np = dev->dev.of_node; | 1244 | struct device_node *np = dev->dev.of_node; |
1031 | struct nmk_gpio_chip *nmk_chip; | 1245 | struct nmk_gpio_chip *nmk_chip; |
1032 | struct gpio_chip *chip; | 1246 | struct gpio_chip *chip; |
@@ -1034,32 +1248,24 @@ static int nmk_gpio_probe(struct platform_device *dev) | |||
1034 | struct clk *clk; | 1248 | struct clk *clk; |
1035 | int secondary_irq; | 1249 | int secondary_irq; |
1036 | void __iomem *base; | 1250 | void __iomem *base; |
1037 | int irq_start = 0; | ||
1038 | int irq; | 1251 | int irq; |
1039 | int ret; | 1252 | int ret; |
1040 | 1253 | ||
1041 | if (!pdata && !np) { | 1254 | pdata = devm_kzalloc(&dev->dev, sizeof(*pdata), GFP_KERNEL); |
1042 | dev_err(&dev->dev, "No platform data or device tree found\n"); | 1255 | if (!pdata) |
1043 | return -ENODEV; | 1256 | return -ENOMEM; |
1044 | } | ||
1045 | |||
1046 | if (np) { | ||
1047 | pdata = devm_kzalloc(&dev->dev, sizeof(*pdata), GFP_KERNEL); | ||
1048 | if (!pdata) | ||
1049 | return -ENOMEM; | ||
1050 | |||
1051 | if (of_get_property(np, "st,supports-sleepmode", NULL)) | ||
1052 | pdata->supports_sleepmode = true; | ||
1053 | 1257 | ||
1054 | if (of_property_read_u32(np, "gpio-bank", &dev->id)) { | 1258 | if (of_get_property(np, "st,supports-sleepmode", NULL)) |
1055 | dev_err(&dev->dev, "gpio-bank property not found\n"); | 1259 | pdata->supports_sleepmode = true; |
1056 | return -EINVAL; | ||
1057 | } | ||
1058 | 1260 | ||
1059 | pdata->first_gpio = dev->id * NMK_GPIO_PER_CHIP; | 1261 | if (of_property_read_u32(np, "gpio-bank", &dev->id)) { |
1060 | pdata->num_gpio = NMK_GPIO_PER_CHIP; | 1262 | dev_err(&dev->dev, "gpio-bank property not found\n"); |
1263 | return -EINVAL; | ||
1061 | } | 1264 | } |
1062 | 1265 | ||
1266 | pdata->first_gpio = dev->id * NMK_GPIO_PER_CHIP; | ||
1267 | pdata->num_gpio = NMK_GPIO_PER_CHIP; | ||
1268 | |||
1063 | irq = platform_get_irq(dev, 0); | 1269 | irq = platform_get_irq(dev, 0); |
1064 | if (irq < 0) | 1270 | if (irq < 0) |
1065 | return irq; | 1271 | return irq; |
@@ -1107,10 +1313,7 @@ static int nmk_gpio_probe(struct platform_device *dev) | |||
1107 | clk_enable(nmk_chip->clk); | 1313 | clk_enable(nmk_chip->clk); |
1108 | nmk_chip->lowemi = readl_relaxed(nmk_chip->addr + NMK_GPIO_LOWEMI); | 1314 | nmk_chip->lowemi = readl_relaxed(nmk_chip->addr + NMK_GPIO_LOWEMI); |
1109 | clk_disable(nmk_chip->clk); | 1315 | clk_disable(nmk_chip->clk); |
1110 | |||
1111 | #ifdef CONFIG_OF_GPIO | ||
1112 | chip->of_node = np; | 1316 | chip->of_node = np; |
1113 | #endif | ||
1114 | 1317 | ||
1115 | ret = gpiochip_add(&nmk_chip->chip); | 1318 | ret = gpiochip_add(&nmk_chip->chip); |
1116 | if (ret) | 1319 | if (ret) |
@@ -1122,10 +1325,8 @@ static int nmk_gpio_probe(struct platform_device *dev) | |||
1122 | 1325 | ||
1123 | platform_set_drvdata(dev, nmk_chip); | 1326 | platform_set_drvdata(dev, nmk_chip); |
1124 | 1327 | ||
1125 | if (!np) | ||
1126 | irq_start = pdata->first_irq; | ||
1127 | nmk_chip->domain = irq_domain_add_simple(np, | 1328 | nmk_chip->domain = irq_domain_add_simple(np, |
1128 | NMK_GPIO_PER_CHIP, irq_start, | 1329 | NMK_GPIO_PER_CHIP, 0, |
1129 | &nmk_gpio_irq_simple_ops, nmk_chip); | 1330 | &nmk_gpio_irq_simple_ops, nmk_chip); |
1130 | if (!nmk_chip->domain) { | 1331 | if (!nmk_chip->domain) { |
1131 | dev_err(&dev->dev, "failed to create irqdomain\n"); | 1332 | dev_err(&dev->dev, "failed to create irqdomain\n"); |
@@ -1858,11 +2059,10 @@ static int nmk_pinctrl_resume(struct platform_device *pdev) | |||
1858 | 2059 | ||
1859 | static int nmk_pinctrl_probe(struct platform_device *pdev) | 2060 | static int nmk_pinctrl_probe(struct platform_device *pdev) |
1860 | { | 2061 | { |
1861 | const struct platform_device_id *platid = platform_get_device_id(pdev); | 2062 | const struct of_device_id *match; |
1862 | struct device_node *np = pdev->dev.of_node; | 2063 | struct device_node *np = pdev->dev.of_node; |
1863 | struct device_node *prcm_np; | 2064 | struct device_node *prcm_np; |
1864 | struct nmk_pinctrl *npct; | 2065 | struct nmk_pinctrl *npct; |
1865 | struct resource *res; | ||
1866 | unsigned int version = 0; | 2066 | unsigned int version = 0; |
1867 | int i; | 2067 | int i; |
1868 | 2068 | ||
@@ -1870,16 +2070,10 @@ static int nmk_pinctrl_probe(struct platform_device *pdev) | |||
1870 | if (!npct) | 2070 | if (!npct) |
1871 | return -ENOMEM; | 2071 | return -ENOMEM; |
1872 | 2072 | ||
1873 | if (platid) | 2073 | match = of_match_device(nmk_pinctrl_match, &pdev->dev); |
1874 | version = platid->driver_data; | 2074 | if (!match) |
1875 | else if (np) { | 2075 | return -ENODEV; |
1876 | const struct of_device_id *match; | 2076 | version = (unsigned int) match->data; |
1877 | |||
1878 | match = of_match_device(nmk_pinctrl_match, &pdev->dev); | ||
1879 | if (!match) | ||
1880 | return -ENODEV; | ||
1881 | version = (unsigned int) match->data; | ||
1882 | } | ||
1883 | 2077 | ||
1884 | /* Poke in other ASIC variants here */ | 2078 | /* Poke in other ASIC variants here */ |
1885 | if (version == PINCTRL_NMK_STN8815) | 2079 | if (version == PINCTRL_NMK_STN8815) |
@@ -1889,17 +2083,9 @@ static int nmk_pinctrl_probe(struct platform_device *pdev) | |||
1889 | if (version == PINCTRL_NMK_DB8540) | 2083 | if (version == PINCTRL_NMK_DB8540) |
1890 | nmk_pinctrl_db8540_init(&npct->soc); | 2084 | nmk_pinctrl_db8540_init(&npct->soc); |
1891 | 2085 | ||
1892 | if (np) { | 2086 | prcm_np = of_parse_phandle(np, "prcm", 0); |
1893 | prcm_np = of_parse_phandle(np, "prcm", 0); | 2087 | if (prcm_np) |
1894 | if (prcm_np) | 2088 | npct->prcm_base = of_iomap(prcm_np, 0); |
1895 | npct->prcm_base = of_iomap(prcm_np, 0); | ||
1896 | } | ||
1897 | |||
1898 | /* Allow platform passed information to over-write DT. */ | ||
1899 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
1900 | if (res) | ||
1901 | npct->prcm_base = devm_ioremap(&pdev->dev, res->start, | ||
1902 | resource_size(res)); | ||
1903 | if (!npct->prcm_base) { | 2089 | if (!npct->prcm_base) { |
1904 | if (version == PINCTRL_NMK_STN8815) { | 2090 | if (version == PINCTRL_NMK_STN8815) { |
1905 | dev_info(&pdev->dev, | 2091 | dev_info(&pdev->dev, |
@@ -1958,13 +2144,6 @@ static struct platform_driver nmk_gpio_driver = { | |||
1958 | .probe = nmk_gpio_probe, | 2144 | .probe = nmk_gpio_probe, |
1959 | }; | 2145 | }; |
1960 | 2146 | ||
1961 | static const struct platform_device_id nmk_pinctrl_id[] = { | ||
1962 | { "pinctrl-stn8815", PINCTRL_NMK_STN8815 }, | ||
1963 | { "pinctrl-db8500", PINCTRL_NMK_DB8500 }, | ||
1964 | { "pinctrl-db8540", PINCTRL_NMK_DB8540 }, | ||
1965 | { } | ||
1966 | }; | ||
1967 | |||
1968 | static struct platform_driver nmk_pinctrl_driver = { | 2147 | static struct platform_driver nmk_pinctrl_driver = { |
1969 | .driver = { | 2148 | .driver = { |
1970 | .owner = THIS_MODULE, | 2149 | .owner = THIS_MODULE, |
@@ -1972,7 +2151,6 @@ static struct platform_driver nmk_pinctrl_driver = { | |||
1972 | .of_match_table = nmk_pinctrl_match, | 2151 | .of_match_table = nmk_pinctrl_match, |
1973 | }, | 2152 | }, |
1974 | .probe = nmk_pinctrl_probe, | 2153 | .probe = nmk_pinctrl_probe, |
1975 | .id_table = nmk_pinctrl_id, | ||
1976 | #ifdef CONFIG_PM | 2154 | #ifdef CONFIG_PM |
1977 | .suspend = nmk_pinctrl_suspend, | 2155 | .suspend = nmk_pinctrl_suspend, |
1978 | .resume = nmk_pinctrl_resume, | 2156 | .resume = nmk_pinctrl_resume, |