diff options
author | Olof Johansson <olof@lixom.net> | 2012-05-10 02:51:32 -0400 |
---|---|---|
committer | Olof Johansson <olof@lixom.net> | 2012-05-10 02:51:32 -0400 |
commit | bf98a6eaa9964fef49f186834713bfc57d16ede1 (patch) | |
tree | 46dc9e802c90fa7d6854f19f829945ea9bfb1bc8 /drivers | |
parent | d48b97b403d23f6df0b990cee652bdf9a52337a3 (diff) | |
parent | 22bfe102c0c39f0bac24950b875e7bfdeb329dd9 (diff) |
Merge branch 'for-3.5/dt' of git://git.kernel.org/pub/scm/linux/kernel/git/swarren/linux-tegra into next/dt2
By Stephen Warren (29) and others
via Stephen Warren
* 'for-3.5/dt' of git://git.kernel.org/pub/scm/linux/kernel/git/swarren/linux-tegra: (43 commits)
ARM: dt: tegra trimslice: add support for audio
ARM: dt: tegra trimslice: enable SDHCI1 controller
ARM: dt: tegra trimslice: add RTC I2C device
ARM: dt: tegra seaboard: add i2c devices
ARM: dt: tegra seaboard: configure I2C2 pinmux
ARM: dt: tegra seaboard: fix I2C2 SCL rate
ARM: dt: tegra: enable als and proximity sensor
+ pinctrl mergebase branch
The pinctrl mergebase branch merge conflicts in drivers/pinctrl/core.c
that were resolved.
Signed-off-by: Olof Johansson <olof@lixom.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpio/gpio-tegra.c | 39 | ||||
-rw-r--r-- | drivers/mmc/host/sdhci-tegra.c | 24 | ||||
-rw-r--r-- | drivers/of/base.c | 41 | ||||
-rw-r--r-- | drivers/pinctrl/Kconfig | 1 | ||||
-rw-r--r-- | drivers/pinctrl/Makefile | 3 | ||||
-rw-r--r-- | drivers/pinctrl/core.c | 175 | ||||
-rw-r--r-- | drivers/pinctrl/core.h | 12 | ||||
-rw-r--r-- | drivers/pinctrl/devicetree.c | 249 | ||||
-rw-r--r-- | drivers/pinctrl/devicetree.h | 35 | ||||
-rw-r--r-- | drivers/pinctrl/pinconf.c | 42 | ||||
-rw-r--r-- | drivers/pinctrl/pinconf.h | 17 | ||||
-rw-r--r-- | drivers/pinctrl/pinctrl-coh901.c | 4 | ||||
-rw-r--r-- | drivers/pinctrl/pinctrl-pxa3xx.c | 24 | ||||
-rw-r--r-- | drivers/pinctrl/pinctrl-sirf.c | 20 | ||||
-rw-r--r-- | drivers/pinctrl/pinctrl-tegra.c | 439 | ||||
-rw-r--r-- | drivers/pinctrl/pinctrl-tegra.h | 23 | ||||
-rw-r--r-- | drivers/pinctrl/pinctrl-tegra20.c | 40 | ||||
-rw-r--r-- | drivers/pinctrl/pinctrl-tegra30.c | 40 | ||||
-rw-r--r-- | drivers/pinctrl/pinctrl-u300.c | 20 | ||||
-rw-r--r-- | drivers/pinctrl/pinmux.c | 33 | ||||
-rw-r--r-- | drivers/pinctrl/pinmux.h | 18 | ||||
-rw-r--r-- | drivers/usb/host/ehci-tegra.c | 13 |
22 files changed, 1032 insertions, 280 deletions
diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c index 12f349b3830d..dc5184d57892 100644 --- a/drivers/gpio/gpio-tegra.c +++ b/drivers/gpio/gpio-tegra.c | |||
@@ -26,10 +26,10 @@ | |||
26 | #include <linux/platform_device.h> | 26 | #include <linux/platform_device.h> |
27 | #include <linux/module.h> | 27 | #include <linux/module.h> |
28 | #include <linux/irqdomain.h> | 28 | #include <linux/irqdomain.h> |
29 | #include <linux/pinctrl/consumer.h> | ||
29 | 30 | ||
30 | #include <asm/mach/irq.h> | 31 | #include <asm/mach/irq.h> |
31 | 32 | ||
32 | #include <mach/gpio-tegra.h> | ||
33 | #include <mach/iomap.h> | 33 | #include <mach/iomap.h> |
34 | #include <mach/suspend.h> | 34 | #include <mach/suspend.h> |
35 | 35 | ||
@@ -108,18 +108,29 @@ static void tegra_gpio_mask_write(u32 reg, int gpio, int value) | |||
108 | tegra_gpio_writel(val, reg); | 108 | tegra_gpio_writel(val, reg); |
109 | } | 109 | } |
110 | 110 | ||
111 | void tegra_gpio_enable(int gpio) | 111 | static void tegra_gpio_enable(int gpio) |
112 | { | 112 | { |
113 | tegra_gpio_mask_write(GPIO_MSK_CNF(gpio), gpio, 1); | 113 | tegra_gpio_mask_write(GPIO_MSK_CNF(gpio), gpio, 1); |
114 | } | 114 | } |
115 | EXPORT_SYMBOL_GPL(tegra_gpio_enable); | 115 | EXPORT_SYMBOL_GPL(tegra_gpio_enable); |
116 | 116 | ||
117 | void tegra_gpio_disable(int gpio) | 117 | static void tegra_gpio_disable(int gpio) |
118 | { | 118 | { |
119 | tegra_gpio_mask_write(GPIO_MSK_CNF(gpio), gpio, 0); | 119 | tegra_gpio_mask_write(GPIO_MSK_CNF(gpio), gpio, 0); |
120 | } | 120 | } |
121 | EXPORT_SYMBOL_GPL(tegra_gpio_disable); | 121 | EXPORT_SYMBOL_GPL(tegra_gpio_disable); |
122 | 122 | ||
123 | int tegra_gpio_request(struct gpio_chip *chip, unsigned offset) | ||
124 | { | ||
125 | return pinctrl_request_gpio(offset); | ||
126 | } | ||
127 | |||
128 | void tegra_gpio_free(struct gpio_chip *chip, unsigned offset) | ||
129 | { | ||
130 | pinctrl_free_gpio(offset); | ||
131 | tegra_gpio_disable(offset); | ||
132 | } | ||
133 | |||
123 | static void tegra_gpio_set(struct gpio_chip *chip, unsigned offset, int value) | 134 | static void tegra_gpio_set(struct gpio_chip *chip, unsigned offset, int value) |
124 | { | 135 | { |
125 | tegra_gpio_mask_write(GPIO_MSK_OUT(offset), offset, value); | 136 | tegra_gpio_mask_write(GPIO_MSK_OUT(offset), offset, value); |
@@ -133,6 +144,7 @@ static int tegra_gpio_get(struct gpio_chip *chip, unsigned offset) | |||
133 | static int tegra_gpio_direction_input(struct gpio_chip *chip, unsigned offset) | 144 | static int tegra_gpio_direction_input(struct gpio_chip *chip, unsigned offset) |
134 | { | 145 | { |
135 | tegra_gpio_mask_write(GPIO_MSK_OE(offset), offset, 0); | 146 | tegra_gpio_mask_write(GPIO_MSK_OE(offset), offset, 0); |
147 | tegra_gpio_enable(offset); | ||
136 | return 0; | 148 | return 0; |
137 | } | 149 | } |
138 | 150 | ||
@@ -141,6 +153,7 @@ static int tegra_gpio_direction_output(struct gpio_chip *chip, unsigned offset, | |||
141 | { | 153 | { |
142 | tegra_gpio_set(chip, offset, value); | 154 | tegra_gpio_set(chip, offset, value); |
143 | tegra_gpio_mask_write(GPIO_MSK_OE(offset), offset, 1); | 155 | tegra_gpio_mask_write(GPIO_MSK_OE(offset), offset, 1); |
156 | tegra_gpio_enable(offset); | ||
144 | return 0; | 157 | return 0; |
145 | } | 158 | } |
146 | 159 | ||
@@ -151,13 +164,14 @@ static int tegra_gpio_to_irq(struct gpio_chip *chip, unsigned offset) | |||
151 | 164 | ||
152 | static struct gpio_chip tegra_gpio_chip = { | 165 | static struct gpio_chip tegra_gpio_chip = { |
153 | .label = "tegra-gpio", | 166 | .label = "tegra-gpio", |
167 | .request = tegra_gpio_request, | ||
168 | .free = tegra_gpio_free, | ||
154 | .direction_input = tegra_gpio_direction_input, | 169 | .direction_input = tegra_gpio_direction_input, |
155 | .get = tegra_gpio_get, | 170 | .get = tegra_gpio_get, |
156 | .direction_output = tegra_gpio_direction_output, | 171 | .direction_output = tegra_gpio_direction_output, |
157 | .set = tegra_gpio_set, | 172 | .set = tegra_gpio_set, |
158 | .to_irq = tegra_gpio_to_irq, | 173 | .to_irq = tegra_gpio_to_irq, |
159 | .base = 0, | 174 | .base = 0, |
160 | .ngpio = TEGRA_NR_GPIOS, | ||
161 | }; | 175 | }; |
162 | 176 | ||
163 | static void tegra_gpio_irq_ack(struct irq_data *d) | 177 | static void tegra_gpio_irq_ack(struct irq_data *d) |
@@ -224,6 +238,9 @@ static int tegra_gpio_irq_set_type(struct irq_data *d, unsigned int type) | |||
224 | 238 | ||
225 | spin_unlock_irqrestore(&bank->lvl_lock[port], flags); | 239 | spin_unlock_irqrestore(&bank->lvl_lock[port], flags); |
226 | 240 | ||
241 | tegra_gpio_mask_write(GPIO_MSK_OE(gpio), gpio, 0); | ||
242 | tegra_gpio_enable(gpio); | ||
243 | |||
227 | if (type & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH)) | 244 | if (type & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH)) |
228 | __irq_set_handler_locked(d->irq, handle_level_irq); | 245 | __irq_set_handler_locked(d->irq, handle_level_irq); |
229 | else if (type & (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING)) | 246 | else if (type & (IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING)) |
@@ -490,20 +507,6 @@ static int __init tegra_gpio_init(void) | |||
490 | } | 507 | } |
491 | postcore_initcall(tegra_gpio_init); | 508 | postcore_initcall(tegra_gpio_init); |
492 | 509 | ||
493 | void tegra_gpio_config(struct tegra_gpio_table *table, int num) | ||
494 | { | ||
495 | int i; | ||
496 | |||
497 | for (i = 0; i < num; i++) { | ||
498 | int gpio = table[i].gpio; | ||
499 | |||
500 | if (table[i].enable) | ||
501 | tegra_gpio_enable(gpio); | ||
502 | else | ||
503 | tegra_gpio_disable(gpio); | ||
504 | } | ||
505 | } | ||
506 | |||
507 | #ifdef CONFIG_DEBUG_FS | 510 | #ifdef CONFIG_DEBUG_FS |
508 | 511 | ||
509 | #include <linux/debugfs.h> | 512 | #include <linux/debugfs.h> |
diff --git a/drivers/mmc/host/sdhci-tegra.c b/drivers/mmc/host/sdhci-tegra.c index 53b26502f6e2..ff5a16991939 100644 --- a/drivers/mmc/host/sdhci-tegra.c +++ b/drivers/mmc/host/sdhci-tegra.c | |||
@@ -269,7 +269,6 @@ static int __devinit sdhci_tegra_probe(struct platform_device *pdev) | |||
269 | "failed to allocate power gpio\n"); | 269 | "failed to allocate power gpio\n"); |
270 | goto err_power_req; | 270 | goto err_power_req; |
271 | } | 271 | } |
272 | tegra_gpio_enable(plat->power_gpio); | ||
273 | gpio_direction_output(plat->power_gpio, 1); | 272 | gpio_direction_output(plat->power_gpio, 1); |
274 | } | 273 | } |
275 | 274 | ||
@@ -280,7 +279,6 @@ static int __devinit sdhci_tegra_probe(struct platform_device *pdev) | |||
280 | "failed to allocate cd gpio\n"); | 279 | "failed to allocate cd gpio\n"); |
281 | goto err_cd_req; | 280 | goto err_cd_req; |
282 | } | 281 | } |
283 | tegra_gpio_enable(plat->cd_gpio); | ||
284 | gpio_direction_input(plat->cd_gpio); | 282 | gpio_direction_input(plat->cd_gpio); |
285 | 283 | ||
286 | rc = request_irq(gpio_to_irq(plat->cd_gpio), carddetect_irq, | 284 | rc = request_irq(gpio_to_irq(plat->cd_gpio), carddetect_irq, |
@@ -301,7 +299,6 @@ static int __devinit sdhci_tegra_probe(struct platform_device *pdev) | |||
301 | "failed to allocate wp gpio\n"); | 299 | "failed to allocate wp gpio\n"); |
302 | goto err_wp_req; | 300 | goto err_wp_req; |
303 | } | 301 | } |
304 | tegra_gpio_enable(plat->wp_gpio); | ||
305 | gpio_direction_input(plat->wp_gpio); | 302 | gpio_direction_input(plat->wp_gpio); |
306 | } | 303 | } |
307 | 304 | ||
@@ -329,23 +326,17 @@ err_add_host: | |||
329 | clk_disable(pltfm_host->clk); | 326 | clk_disable(pltfm_host->clk); |
330 | clk_put(pltfm_host->clk); | 327 | clk_put(pltfm_host->clk); |
331 | err_clk_get: | 328 | err_clk_get: |
332 | if (gpio_is_valid(plat->wp_gpio)) { | 329 | if (gpio_is_valid(plat->wp_gpio)) |
333 | tegra_gpio_disable(plat->wp_gpio); | ||
334 | gpio_free(plat->wp_gpio); | 330 | gpio_free(plat->wp_gpio); |
335 | } | ||
336 | err_wp_req: | 331 | err_wp_req: |
337 | if (gpio_is_valid(plat->cd_gpio)) | 332 | if (gpio_is_valid(plat->cd_gpio)) |
338 | free_irq(gpio_to_irq(plat->cd_gpio), host); | 333 | free_irq(gpio_to_irq(plat->cd_gpio), host); |
339 | err_cd_irq_req: | 334 | err_cd_irq_req: |
340 | if (gpio_is_valid(plat->cd_gpio)) { | 335 | if (gpio_is_valid(plat->cd_gpio)) |
341 | tegra_gpio_disable(plat->cd_gpio); | ||
342 | gpio_free(plat->cd_gpio); | 336 | gpio_free(plat->cd_gpio); |
343 | } | ||
344 | err_cd_req: | 337 | err_cd_req: |
345 | if (gpio_is_valid(plat->power_gpio)) { | 338 | if (gpio_is_valid(plat->power_gpio)) |
346 | tegra_gpio_disable(plat->power_gpio); | ||
347 | gpio_free(plat->power_gpio); | 339 | gpio_free(plat->power_gpio); |
348 | } | ||
349 | err_power_req: | 340 | err_power_req: |
350 | err_no_plat: | 341 | err_no_plat: |
351 | sdhci_pltfm_free(pdev); | 342 | sdhci_pltfm_free(pdev); |
@@ -362,21 +353,16 @@ static int __devexit sdhci_tegra_remove(struct platform_device *pdev) | |||
362 | 353 | ||
363 | sdhci_remove_host(host, dead); | 354 | sdhci_remove_host(host, dead); |
364 | 355 | ||
365 | if (gpio_is_valid(plat->wp_gpio)) { | 356 | if (gpio_is_valid(plat->wp_gpio)) |
366 | tegra_gpio_disable(plat->wp_gpio); | ||
367 | gpio_free(plat->wp_gpio); | 357 | gpio_free(plat->wp_gpio); |
368 | } | ||
369 | 358 | ||
370 | if (gpio_is_valid(plat->cd_gpio)) { | 359 | if (gpio_is_valid(plat->cd_gpio)) { |
371 | free_irq(gpio_to_irq(plat->cd_gpio), host); | 360 | free_irq(gpio_to_irq(plat->cd_gpio), host); |
372 | tegra_gpio_disable(plat->cd_gpio); | ||
373 | gpio_free(plat->cd_gpio); | 361 | gpio_free(plat->cd_gpio); |
374 | } | 362 | } |
375 | 363 | ||
376 | if (gpio_is_valid(plat->power_gpio)) { | 364 | if (gpio_is_valid(plat->power_gpio)) |
377 | tegra_gpio_disable(plat->power_gpio); | ||
378 | gpio_free(plat->power_gpio); | 365 | gpio_free(plat->power_gpio); |
379 | } | ||
380 | 366 | ||
381 | clk_disable(pltfm_host->clk); | 367 | clk_disable(pltfm_host->clk); |
382 | clk_put(pltfm_host->clk); | 368 | clk_put(pltfm_host->clk); |
diff --git a/drivers/of/base.c b/drivers/of/base.c index 580644986945..d9bfd49b1935 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c | |||
@@ -1260,3 +1260,44 @@ int of_alias_get_id(struct device_node *np, const char *stem) | |||
1260 | return id; | 1260 | return id; |
1261 | } | 1261 | } |
1262 | EXPORT_SYMBOL_GPL(of_alias_get_id); | 1262 | EXPORT_SYMBOL_GPL(of_alias_get_id); |
1263 | |||
1264 | const __be32 *of_prop_next_u32(struct property *prop, const __be32 *cur, | ||
1265 | u32 *pu) | ||
1266 | { | ||
1267 | const void *curv = cur; | ||
1268 | |||
1269 | if (!prop) | ||
1270 | return NULL; | ||
1271 | |||
1272 | if (!cur) { | ||
1273 | curv = prop->value; | ||
1274 | goto out_val; | ||
1275 | } | ||
1276 | |||
1277 | curv += sizeof(*cur); | ||
1278 | if (curv >= prop->value + prop->length) | ||
1279 | return NULL; | ||
1280 | |||
1281 | out_val: | ||
1282 | *pu = be32_to_cpup(curv); | ||
1283 | return curv; | ||
1284 | } | ||
1285 | EXPORT_SYMBOL_GPL(of_prop_next_u32); | ||
1286 | |||
1287 | const char *of_prop_next_string(struct property *prop, const char *cur) | ||
1288 | { | ||
1289 | const void *curv = cur; | ||
1290 | |||
1291 | if (!prop) | ||
1292 | return NULL; | ||
1293 | |||
1294 | if (!cur) | ||
1295 | return prop->value; | ||
1296 | |||
1297 | curv += strlen(cur) + 1; | ||
1298 | if (curv >= prop->value + prop->length) | ||
1299 | return NULL; | ||
1300 | |||
1301 | return curv; | ||
1302 | } | ||
1303 | EXPORT_SYMBOL_GPL(of_prop_next_string); | ||
diff --git a/drivers/pinctrl/Kconfig b/drivers/pinctrl/Kconfig index abfb96408779..f73a5ea89754 100644 --- a/drivers/pinctrl/Kconfig +++ b/drivers/pinctrl/Kconfig | |||
@@ -4,7 +4,6 @@ | |||
4 | 4 | ||
5 | config PINCTRL | 5 | config PINCTRL |
6 | bool | 6 | bool |
7 | depends on EXPERIMENTAL | ||
8 | 7 | ||
9 | if PINCTRL | 8 | if PINCTRL |
10 | 9 | ||
diff --git a/drivers/pinctrl/Makefile b/drivers/pinctrl/Makefile index 6d4150b4eced..8e3c95a02fbd 100644 --- a/drivers/pinctrl/Makefile +++ b/drivers/pinctrl/Makefile | |||
@@ -5,6 +5,9 @@ ccflags-$(CONFIG_DEBUG_PINCTRL) += -DDEBUG | |||
5 | obj-$(CONFIG_PINCTRL) += core.o | 5 | obj-$(CONFIG_PINCTRL) += core.o |
6 | obj-$(CONFIG_PINMUX) += pinmux.o | 6 | obj-$(CONFIG_PINMUX) += pinmux.o |
7 | obj-$(CONFIG_PINCONF) += pinconf.o | 7 | obj-$(CONFIG_PINCONF) += pinconf.o |
8 | ifeq ($(CONFIG_OF),y) | ||
9 | obj-$(CONFIG_PINCTRL) += devicetree.o | ||
10 | endif | ||
8 | obj-$(CONFIG_GENERIC_PINCONF) += pinconf-generic.o | 11 | obj-$(CONFIG_GENERIC_PINCONF) += pinconf-generic.o |
9 | obj-$(CONFIG_PINCTRL_PXA3xx) += pinctrl-pxa3xx.o | 12 | obj-$(CONFIG_PINCTRL_PXA3xx) += pinctrl-pxa3xx.o |
10 | obj-$(CONFIG_PINCTRL_MMP2) += pinctrl-mmp2.o | 13 | obj-$(CONFIG_PINCTRL_MMP2) += pinctrl-mmp2.o |
diff --git a/drivers/pinctrl/core.c b/drivers/pinctrl/core.c index df6296c5f47b..5cd5a5a3a403 100644 --- a/drivers/pinctrl/core.c +++ b/drivers/pinctrl/core.c | |||
@@ -23,9 +23,11 @@ | |||
23 | #include <linux/sysfs.h> | 23 | #include <linux/sysfs.h> |
24 | #include <linux/debugfs.h> | 24 | #include <linux/debugfs.h> |
25 | #include <linux/seq_file.h> | 25 | #include <linux/seq_file.h> |
26 | #include <linux/pinctrl/consumer.h> | ||
26 | #include <linux/pinctrl/pinctrl.h> | 27 | #include <linux/pinctrl/pinctrl.h> |
27 | #include <linux/pinctrl/machine.h> | 28 | #include <linux/pinctrl/machine.h> |
28 | #include "core.h" | 29 | #include "core.h" |
30 | #include "devicetree.h" | ||
29 | #include "pinmux.h" | 31 | #include "pinmux.h" |
30 | #include "pinconf.h" | 32 | #include "pinconf.h" |
31 | 33 | ||
@@ -45,7 +47,7 @@ struct pinctrl_maps { | |||
45 | DEFINE_MUTEX(pinctrl_mutex); | 47 | DEFINE_MUTEX(pinctrl_mutex); |
46 | 48 | ||
47 | /* Global list of pin control devices (struct pinctrl_dev) */ | 49 | /* Global list of pin control devices (struct pinctrl_dev) */ |
48 | static LIST_HEAD(pinctrldev_list); | 50 | LIST_HEAD(pinctrldev_list); |
49 | 51 | ||
50 | /* List of pin controller handles (struct pinctrl) */ | 52 | /* List of pin controller handles (struct pinctrl) */ |
51 | static LIST_HEAD(pinctrl_list); | 53 | static LIST_HEAD(pinctrl_list); |
@@ -124,6 +126,25 @@ int pin_get_from_name(struct pinctrl_dev *pctldev, const char *name) | |||
124 | } | 126 | } |
125 | 127 | ||
126 | /** | 128 | /** |
129 | * pin_get_name_from_id() - look up a pin name from a pin id | ||
130 | * @pctldev: the pin control device to lookup the pin on | ||
131 | * @name: the name of the pin to look up | ||
132 | */ | ||
133 | const char *pin_get_name(struct pinctrl_dev *pctldev, const unsigned pin) | ||
134 | { | ||
135 | const struct pin_desc *desc; | ||
136 | |||
137 | desc = pin_desc_get(pctldev, pin); | ||
138 | if (desc == NULL) { | ||
139 | dev_err(pctldev->dev, "failed to get pin(%d) name\n", | ||
140 | pin); | ||
141 | return NULL; | ||
142 | } | ||
143 | |||
144 | return desc->name; | ||
145 | } | ||
146 | |||
147 | /** | ||
127 | * pin_is_valid() - check if pin exists on controller | 148 | * pin_is_valid() - check if pin exists on controller |
128 | * @pctldev: the pin control device to check the pin on | 149 | * @pctldev: the pin control device to check the pin on |
129 | * @pin: pin to check, use the local pin controller index number | 150 | * @pin: pin to check, use the local pin controller index number |
@@ -318,9 +339,10 @@ int pinctrl_get_group_selector(struct pinctrl_dev *pctldev, | |||
318 | const char *pin_group) | 339 | const char *pin_group) |
319 | { | 340 | { |
320 | const struct pinctrl_ops *pctlops = pctldev->desc->pctlops; | 341 | const struct pinctrl_ops *pctlops = pctldev->desc->pctlops; |
342 | unsigned ngroups = pctlops->get_groups_count(pctldev); | ||
321 | unsigned group_selector = 0; | 343 | unsigned group_selector = 0; |
322 | 344 | ||
323 | while (pctlops->list_groups(pctldev, group_selector) >= 0) { | 345 | while (group_selector < ngroups) { |
324 | const char *gname = pctlops->get_group_name(pctldev, | 346 | const char *gname = pctlops->get_group_name(pctldev, |
325 | group_selector); | 347 | group_selector); |
326 | if (!strcmp(gname, pin_group)) { | 348 | if (!strcmp(gname, pin_group)) { |
@@ -516,11 +538,14 @@ static int add_setting(struct pinctrl *p, struct pinctrl_map const *map) | |||
516 | 538 | ||
517 | setting->pctldev = get_pinctrl_dev_from_devname(map->ctrl_dev_name); | 539 | setting->pctldev = get_pinctrl_dev_from_devname(map->ctrl_dev_name); |
518 | if (setting->pctldev == NULL) { | 540 | if (setting->pctldev == NULL) { |
519 | dev_err(p->dev, "unknown pinctrl device %s in map entry", | 541 | dev_info(p->dev, "unknown pinctrl device %s in map entry, deferring probe", |
520 | map->ctrl_dev_name); | 542 | map->ctrl_dev_name); |
521 | kfree(setting); | 543 | kfree(setting); |
522 | /* Eventually, this should trigger deferred probe */ | 544 | /* |
523 | return -ENODEV; | 545 | * OK let us guess that the driver is not there yet, and |
546 | * let's defer obtaining this pinctrl handle to later... | ||
547 | */ | ||
548 | return -EPROBE_DEFER; | ||
524 | } | 549 | } |
525 | 550 | ||
526 | switch (map->type) { | 551 | switch (map->type) { |
@@ -579,6 +604,13 @@ static struct pinctrl *create_pinctrl(struct device *dev) | |||
579 | } | 604 | } |
580 | p->dev = dev; | 605 | p->dev = dev; |
581 | INIT_LIST_HEAD(&p->states); | 606 | INIT_LIST_HEAD(&p->states); |
607 | INIT_LIST_HEAD(&p->dt_maps); | ||
608 | |||
609 | ret = pinctrl_dt_to_map(p); | ||
610 | if (ret < 0) { | ||
611 | kfree(p); | ||
612 | return ERR_PTR(ret); | ||
613 | } | ||
582 | 614 | ||
583 | devname = dev_name(dev); | 615 | devname = dev_name(dev); |
584 | 616 | ||
@@ -662,6 +694,8 @@ static void pinctrl_put_locked(struct pinctrl *p, bool inlist) | |||
662 | kfree(state); | 694 | kfree(state); |
663 | } | 695 | } |
664 | 696 | ||
697 | pinctrl_dt_free_maps(p); | ||
698 | |||
665 | if (inlist) | 699 | if (inlist) |
666 | list_del(&p->node); | 700 | list_del(&p->node); |
667 | kfree(p); | 701 | kfree(p); |
@@ -787,15 +821,63 @@ int pinctrl_select_state(struct pinctrl *p, struct pinctrl_state *state) | |||
787 | } | 821 | } |
788 | EXPORT_SYMBOL_GPL(pinctrl_select_state); | 822 | EXPORT_SYMBOL_GPL(pinctrl_select_state); |
789 | 823 | ||
824 | static void devm_pinctrl_release(struct device *dev, void *res) | ||
825 | { | ||
826 | pinctrl_put(*(struct pinctrl **)res); | ||
827 | } | ||
828 | |||
790 | /** | 829 | /** |
791 | * pinctrl_register_mappings() - register a set of pin controller mappings | 830 | * struct devm_pinctrl_get() - Resource managed pinctrl_get() |
792 | * @maps: the pincontrol mappings table to register. This should probably be | 831 | * @dev: the device to obtain the handle for |
793 | * marked with __initdata so it can be discarded after boot. This | 832 | * |
794 | * function will perform a shallow copy for the mapping entries. | 833 | * If there is a need to explicitly destroy the returned struct pinctrl, |
795 | * @num_maps: the number of maps in the mapping table | 834 | * devm_pinctrl_put() should be used, rather than plain pinctrl_put(). |
796 | */ | 835 | */ |
797 | int pinctrl_register_mappings(struct pinctrl_map const *maps, | 836 | struct pinctrl *devm_pinctrl_get(struct device *dev) |
798 | unsigned num_maps) | 837 | { |
838 | struct pinctrl **ptr, *p; | ||
839 | |||
840 | ptr = devres_alloc(devm_pinctrl_release, sizeof(*ptr), GFP_KERNEL); | ||
841 | if (!ptr) | ||
842 | return ERR_PTR(-ENOMEM); | ||
843 | |||
844 | p = pinctrl_get(dev); | ||
845 | if (!IS_ERR(p)) { | ||
846 | *ptr = p; | ||
847 | devres_add(dev, ptr); | ||
848 | } else { | ||
849 | devres_free(ptr); | ||
850 | } | ||
851 | |||
852 | return p; | ||
853 | } | ||
854 | EXPORT_SYMBOL_GPL(devm_pinctrl_get); | ||
855 | |||
856 | static int devm_pinctrl_match(struct device *dev, void *res, void *data) | ||
857 | { | ||
858 | struct pinctrl **p = res; | ||
859 | |||
860 | return *p == data; | ||
861 | } | ||
862 | |||
863 | /** | ||
864 | * devm_pinctrl_put() - Resource managed pinctrl_put() | ||
865 | * @p: the pinctrl handle to release | ||
866 | * | ||
867 | * Deallocate a struct pinctrl obtained via devm_pinctrl_get(). Normally | ||
868 | * this function will not need to be called and the resource management | ||
869 | * code will ensure that the resource is freed. | ||
870 | */ | ||
871 | void devm_pinctrl_put(struct pinctrl *p) | ||
872 | { | ||
873 | WARN_ON(devres_destroy(p->dev, devm_pinctrl_release, | ||
874 | devm_pinctrl_match, p)); | ||
875 | pinctrl_put(p); | ||
876 | } | ||
877 | EXPORT_SYMBOL_GPL(devm_pinctrl_put); | ||
878 | |||
879 | int pinctrl_register_map(struct pinctrl_map const *maps, unsigned num_maps, | ||
880 | bool dup, bool locked) | ||
799 | { | 881 | { |
800 | int i, ret; | 882 | int i, ret; |
801 | struct pinctrl_maps *maps_node; | 883 | struct pinctrl_maps *maps_node; |
@@ -851,20 +933,52 @@ int pinctrl_register_mappings(struct pinctrl_map const *maps, | |||
851 | } | 933 | } |
852 | 934 | ||
853 | maps_node->num_maps = num_maps; | 935 | maps_node->num_maps = num_maps; |
854 | maps_node->maps = kmemdup(maps, sizeof(*maps) * num_maps, GFP_KERNEL); | 936 | if (dup) { |
855 | if (!maps_node->maps) { | 937 | maps_node->maps = kmemdup(maps, sizeof(*maps) * num_maps, |
856 | pr_err("failed to duplicate mapping table\n"); | 938 | GFP_KERNEL); |
857 | kfree(maps_node); | 939 | if (!maps_node->maps) { |
858 | return -ENOMEM; | 940 | pr_err("failed to duplicate mapping table\n"); |
941 | kfree(maps_node); | ||
942 | return -ENOMEM; | ||
943 | } | ||
944 | } else { | ||
945 | maps_node->maps = maps; | ||
859 | } | 946 | } |
860 | 947 | ||
861 | mutex_lock(&pinctrl_mutex); | 948 | if (!locked) |
949 | mutex_lock(&pinctrl_mutex); | ||
862 | list_add_tail(&maps_node->node, &pinctrl_maps); | 950 | list_add_tail(&maps_node->node, &pinctrl_maps); |
863 | mutex_unlock(&pinctrl_mutex); | 951 | if (!locked) |
952 | mutex_unlock(&pinctrl_mutex); | ||
864 | 953 | ||
865 | return 0; | 954 | return 0; |
866 | } | 955 | } |
867 | 956 | ||
957 | /** | ||
958 | * pinctrl_register_mappings() - register a set of pin controller mappings | ||
959 | * @maps: the pincontrol mappings table to register. This should probably be | ||
960 | * marked with __initdata so it can be discarded after boot. This | ||
961 | * function will perform a shallow copy for the mapping entries. | ||
962 | * @num_maps: the number of maps in the mapping table | ||
963 | */ | ||
964 | int pinctrl_register_mappings(struct pinctrl_map const *maps, | ||
965 | unsigned num_maps) | ||
966 | { | ||
967 | return pinctrl_register_map(maps, num_maps, true, false); | ||
968 | } | ||
969 | |||
970 | void pinctrl_unregister_map(struct pinctrl_map const *map) | ||
971 | { | ||
972 | struct pinctrl_maps *maps_node; | ||
973 | |||
974 | list_for_each_entry(maps_node, &pinctrl_maps, node) { | ||
975 | if (maps_node->maps == map) { | ||
976 | list_del(&maps_node->node); | ||
977 | return; | ||
978 | } | ||
979 | } | ||
980 | } | ||
981 | |||
868 | #ifdef CONFIG_DEBUG_FS | 982 | #ifdef CONFIG_DEBUG_FS |
869 | 983 | ||
870 | static int pinctrl_pins_show(struct seq_file *s, void *what) | 984 | static int pinctrl_pins_show(struct seq_file *s, void *what) |
@@ -906,15 +1020,17 @@ static int pinctrl_groups_show(struct seq_file *s, void *what) | |||
906 | { | 1020 | { |
907 | struct pinctrl_dev *pctldev = s->private; | 1021 | struct pinctrl_dev *pctldev = s->private; |
908 | const struct pinctrl_ops *ops = pctldev->desc->pctlops; | 1022 | const struct pinctrl_ops *ops = pctldev->desc->pctlops; |
909 | unsigned selector = 0; | 1023 | unsigned ngroups, selector = 0; |
910 | 1024 | ||
1025 | ngroups = ops->get_groups_count(pctldev); | ||
911 | mutex_lock(&pinctrl_mutex); | 1026 | mutex_lock(&pinctrl_mutex); |
912 | 1027 | ||
913 | seq_puts(s, "registered pin groups:\n"); | 1028 | seq_puts(s, "registered pin groups:\n"); |
914 | while (ops->list_groups(pctldev, selector) >= 0) { | 1029 | while (selector < ngroups) { |
915 | const unsigned *pins; | 1030 | const unsigned *pins; |
916 | unsigned num_pins; | 1031 | unsigned num_pins; |
917 | const char *gname = ops->get_group_name(pctldev, selector); | 1032 | const char *gname = ops->get_group_name(pctldev, selector); |
1033 | const char *pname; | ||
918 | int ret; | 1034 | int ret; |
919 | int i; | 1035 | int i; |
920 | 1036 | ||
@@ -924,10 +1040,14 @@ static int pinctrl_groups_show(struct seq_file *s, void *what) | |||
924 | seq_printf(s, "%s [ERROR GETTING PINS]\n", | 1040 | seq_printf(s, "%s [ERROR GETTING PINS]\n", |
925 | gname); | 1041 | gname); |
926 | else { | 1042 | else { |
927 | seq_printf(s, "group: %s, pins = [ ", gname); | 1043 | seq_printf(s, "group: %s\n", gname); |
928 | for (i = 0; i < num_pins; i++) | 1044 | for (i = 0; i < num_pins; i++) { |
929 | seq_printf(s, "%d ", pins[i]); | 1045 | pname = pin_get_name(pctldev, pins[i]); |
930 | seq_puts(s, "]\n"); | 1046 | if (WARN_ON(!pname)) |
1047 | return -EINVAL; | ||
1048 | seq_printf(s, "pin %d (%s)\n", pins[i], pname); | ||
1049 | } | ||
1050 | seq_puts(s, "\n"); | ||
931 | } | 1051 | } |
932 | selector++; | 1052 | selector++; |
933 | } | 1053 | } |
@@ -1226,11 +1346,14 @@ static int pinctrl_check_ops(struct pinctrl_dev *pctldev) | |||
1226 | const struct pinctrl_ops *ops = pctldev->desc->pctlops; | 1346 | const struct pinctrl_ops *ops = pctldev->desc->pctlops; |
1227 | 1347 | ||
1228 | if (!ops || | 1348 | if (!ops || |
1229 | !ops->list_groups || | 1349 | !ops->get_groups_count || |
1230 | !ops->get_group_name || | 1350 | !ops->get_group_name || |
1231 | !ops->get_group_pins) | 1351 | !ops->get_group_pins) |
1232 | return -EINVAL; | 1352 | return -EINVAL; |
1233 | 1353 | ||
1354 | if (ops->dt_node_to_map && !ops->dt_free_map) | ||
1355 | return -EINVAL; | ||
1356 | |||
1234 | return 0; | 1357 | return 0; |
1235 | } | 1358 | } |
1236 | 1359 | ||
diff --git a/drivers/pinctrl/core.h b/drivers/pinctrl/core.h index 17ecf651b123..1f40ff68a8c4 100644 --- a/drivers/pinctrl/core.h +++ b/drivers/pinctrl/core.h | |||
@@ -52,12 +52,15 @@ struct pinctrl_dev { | |||
52 | * @dev: the device using this pin control handle | 52 | * @dev: the device using this pin control handle |
53 | * @states: a list of states for this device | 53 | * @states: a list of states for this device |
54 | * @state: the current state | 54 | * @state: the current state |
55 | * @dt_maps: the mapping table chunks dynamically parsed from device tree for | ||
56 | * this device, if any | ||
55 | */ | 57 | */ |
56 | struct pinctrl { | 58 | struct pinctrl { |
57 | struct list_head node; | 59 | struct list_head node; |
58 | struct device *dev; | 60 | struct device *dev; |
59 | struct list_head states; | 61 | struct list_head states; |
60 | struct pinctrl_state *state; | 62 | struct pinctrl_state *state; |
63 | struct list_head dt_maps; | ||
61 | }; | 64 | }; |
62 | 65 | ||
63 | /** | 66 | /** |
@@ -100,7 +103,8 @@ struct pinctrl_setting_configs { | |||
100 | * struct pinctrl_setting - an individual mux or config setting | 103 | * struct pinctrl_setting - an individual mux or config setting |
101 | * @node: list node for struct pinctrl_settings's @settings field | 104 | * @node: list node for struct pinctrl_settings's @settings field |
102 | * @type: the type of setting | 105 | * @type: the type of setting |
103 | * @pctldev: pin control device handling to be programmed | 106 | * @pctldev: pin control device handling to be programmed. Not used for |
107 | * PIN_MAP_TYPE_DUMMY_STATE. | ||
104 | * @data: Data specific to the setting type | 108 | * @data: Data specific to the setting type |
105 | */ | 109 | */ |
106 | struct pinctrl_setting { | 110 | struct pinctrl_setting { |
@@ -144,6 +148,7 @@ struct pin_desc { | |||
144 | 148 | ||
145 | struct pinctrl_dev *get_pinctrl_dev_from_devname(const char *dev_name); | 149 | struct pinctrl_dev *get_pinctrl_dev_from_devname(const char *dev_name); |
146 | int pin_get_from_name(struct pinctrl_dev *pctldev, const char *name); | 150 | int pin_get_from_name(struct pinctrl_dev *pctldev, const char *name); |
151 | const char *pin_get_name(struct pinctrl_dev *pctldev, const unsigned pin); | ||
147 | int pinctrl_get_group_selector(struct pinctrl_dev *pctldev, | 152 | int pinctrl_get_group_selector(struct pinctrl_dev *pctldev, |
148 | const char *pin_group); | 153 | const char *pin_group); |
149 | 154 | ||
@@ -153,4 +158,9 @@ static inline struct pin_desc *pin_desc_get(struct pinctrl_dev *pctldev, | |||
153 | return radix_tree_lookup(&pctldev->pin_desc_tree, pin); | 158 | return radix_tree_lookup(&pctldev->pin_desc_tree, pin); |
154 | } | 159 | } |
155 | 160 | ||
161 | int pinctrl_register_map(struct pinctrl_map const *maps, unsigned num_maps, | ||
162 | bool dup, bool locked); | ||
163 | void pinctrl_unregister_map(struct pinctrl_map const *map); | ||
164 | |||
156 | extern struct mutex pinctrl_mutex; | 165 | extern struct mutex pinctrl_mutex; |
166 | extern struct list_head pinctrldev_list; | ||
diff --git a/drivers/pinctrl/devicetree.c b/drivers/pinctrl/devicetree.c new file mode 100644 index 000000000000..fcb1de45473c --- /dev/null +++ b/drivers/pinctrl/devicetree.c | |||
@@ -0,0 +1,249 @@ | |||
1 | /* | ||
2 | * Device tree integration for the pin control subsystem | ||
3 | * | ||
4 | * Copyright (C) 2012 NVIDIA CORPORATION. All rights reserved. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms and conditions of the GNU General Public License, | ||
8 | * version 2, as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
13 | * more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | |||
19 | #include <linux/device.h> | ||
20 | #include <linux/of.h> | ||
21 | #include <linux/pinctrl/pinctrl.h> | ||
22 | #include <linux/slab.h> | ||
23 | |||
24 | #include "core.h" | ||
25 | #include "devicetree.h" | ||
26 | |||
27 | /** | ||
28 | * struct pinctrl_dt_map - mapping table chunk parsed from device tree | ||
29 | * @node: list node for struct pinctrl's @dt_maps field | ||
30 | * @pctldev: the pin controller that allocated this struct, and will free it | ||
31 | * @maps: the mapping table entries | ||
32 | */ | ||
33 | struct pinctrl_dt_map { | ||
34 | struct list_head node; | ||
35 | struct pinctrl_dev *pctldev; | ||
36 | struct pinctrl_map *map; | ||
37 | unsigned num_maps; | ||
38 | }; | ||
39 | |||
40 | static void dt_free_map(struct pinctrl_dev *pctldev, | ||
41 | struct pinctrl_map *map, unsigned num_maps) | ||
42 | { | ||
43 | if (pctldev) { | ||
44 | struct pinctrl_ops *ops = pctldev->desc->pctlops; | ||
45 | ops->dt_free_map(pctldev, map, num_maps); | ||
46 | } else { | ||
47 | /* There is no pctldev for PIN_MAP_TYPE_DUMMY_STATE */ | ||
48 | kfree(map); | ||
49 | } | ||
50 | } | ||
51 | |||
52 | void pinctrl_dt_free_maps(struct pinctrl *p) | ||
53 | { | ||
54 | struct pinctrl_dt_map *dt_map, *n1; | ||
55 | |||
56 | list_for_each_entry_safe(dt_map, n1, &p->dt_maps, node) { | ||
57 | pinctrl_unregister_map(dt_map->map); | ||
58 | list_del(&dt_map->node); | ||
59 | dt_free_map(dt_map->pctldev, dt_map->map, | ||
60 | dt_map->num_maps); | ||
61 | kfree(dt_map); | ||
62 | } | ||
63 | |||
64 | of_node_put(p->dev->of_node); | ||
65 | } | ||
66 | |||
67 | static int dt_remember_or_free_map(struct pinctrl *p, const char *statename, | ||
68 | struct pinctrl_dev *pctldev, | ||
69 | struct pinctrl_map *map, unsigned num_maps) | ||
70 | { | ||
71 | int i; | ||
72 | struct pinctrl_dt_map *dt_map; | ||
73 | |||
74 | /* Initialize common mapping table entry fields */ | ||
75 | for (i = 0; i < num_maps; i++) { | ||
76 | map[i].dev_name = dev_name(p->dev); | ||
77 | map[i].name = statename; | ||
78 | if (pctldev) | ||
79 | map[i].ctrl_dev_name = dev_name(pctldev->dev); | ||
80 | } | ||
81 | |||
82 | /* Remember the converted mapping table entries */ | ||
83 | dt_map = kzalloc(sizeof(*dt_map), GFP_KERNEL); | ||
84 | if (!dt_map) { | ||
85 | dev_err(p->dev, "failed to alloc struct pinctrl_dt_map\n"); | ||
86 | dt_free_map(pctldev, map, num_maps); | ||
87 | return -ENOMEM; | ||
88 | } | ||
89 | |||
90 | dt_map->pctldev = pctldev; | ||
91 | dt_map->map = map; | ||
92 | dt_map->num_maps = num_maps; | ||
93 | list_add_tail(&dt_map->node, &p->dt_maps); | ||
94 | |||
95 | return pinctrl_register_map(map, num_maps, false, true); | ||
96 | } | ||
97 | |||
98 | static struct pinctrl_dev *find_pinctrl_by_of_node(struct device_node *np) | ||
99 | { | ||
100 | struct pinctrl_dev *pctldev; | ||
101 | |||
102 | list_for_each_entry(pctldev, &pinctrldev_list, node) | ||
103 | if (pctldev->dev->of_node == np) | ||
104 | return pctldev; | ||
105 | |||
106 | return NULL; | ||
107 | } | ||
108 | |||
109 | static int dt_to_map_one_config(struct pinctrl *p, const char *statename, | ||
110 | struct device_node *np_config) | ||
111 | { | ||
112 | struct device_node *np_pctldev; | ||
113 | struct pinctrl_dev *pctldev; | ||
114 | struct pinctrl_ops *ops; | ||
115 | int ret; | ||
116 | struct pinctrl_map *map; | ||
117 | unsigned num_maps; | ||
118 | |||
119 | /* Find the pin controller containing np_config */ | ||
120 | np_pctldev = of_node_get(np_config); | ||
121 | for (;;) { | ||
122 | np_pctldev = of_get_next_parent(np_pctldev); | ||
123 | if (!np_pctldev || of_node_is_root(np_pctldev)) { | ||
124 | dev_info(p->dev, "could not find pctldev for node %s, deferring probe\n", | ||
125 | np_config->full_name); | ||
126 | of_node_put(np_pctldev); | ||
127 | /* OK let's just assume this will appear later then */ | ||
128 | return -EPROBE_DEFER; | ||
129 | } | ||
130 | pctldev = find_pinctrl_by_of_node(np_pctldev); | ||
131 | if (pctldev) | ||
132 | break; | ||
133 | } | ||
134 | of_node_put(np_pctldev); | ||
135 | |||
136 | /* | ||
137 | * Call pinctrl driver to parse device tree node, and | ||
138 | * generate mapping table entries | ||
139 | */ | ||
140 | ops = pctldev->desc->pctlops; | ||
141 | if (!ops->dt_node_to_map) { | ||
142 | dev_err(p->dev, "pctldev %s doesn't support DT\n", | ||
143 | dev_name(pctldev->dev)); | ||
144 | return -ENODEV; | ||
145 | } | ||
146 | ret = ops->dt_node_to_map(pctldev, np_config, &map, &num_maps); | ||
147 | if (ret < 0) | ||
148 | return ret; | ||
149 | |||
150 | /* Stash the mapping table chunk away for later use */ | ||
151 | return dt_remember_or_free_map(p, statename, pctldev, map, num_maps); | ||
152 | } | ||
153 | |||
154 | static int dt_remember_dummy_state(struct pinctrl *p, const char *statename) | ||
155 | { | ||
156 | struct pinctrl_map *map; | ||
157 | |||
158 | map = kzalloc(sizeof(*map), GFP_KERNEL); | ||
159 | if (!map) { | ||
160 | dev_err(p->dev, "failed to alloc struct pinctrl_map\n"); | ||
161 | return -ENOMEM; | ||
162 | } | ||
163 | |||
164 | /* There is no pctldev for PIN_MAP_TYPE_DUMMY_STATE */ | ||
165 | map->type = PIN_MAP_TYPE_DUMMY_STATE; | ||
166 | |||
167 | return dt_remember_or_free_map(p, statename, NULL, map, 1); | ||
168 | } | ||
169 | |||
170 | int pinctrl_dt_to_map(struct pinctrl *p) | ||
171 | { | ||
172 | struct device_node *np = p->dev->of_node; | ||
173 | int state, ret; | ||
174 | char *propname; | ||
175 | struct property *prop; | ||
176 | const char *statename; | ||
177 | const __be32 *list; | ||
178 | int size, config; | ||
179 | phandle phandle; | ||
180 | struct device_node *np_config; | ||
181 | |||
182 | /* CONFIG_OF enabled, p->dev not instantiated from DT */ | ||
183 | if (!np) { | ||
184 | dev_dbg(p->dev, "no of_node; not parsing pinctrl DT\n"); | ||
185 | return 0; | ||
186 | } | ||
187 | |||
188 | /* We may store pointers to property names within the node */ | ||
189 | of_node_get(np); | ||
190 | |||
191 | /* For each defined state ID */ | ||
192 | for (state = 0; ; state++) { | ||
193 | /* Retrieve the pinctrl-* property */ | ||
194 | propname = kasprintf(GFP_KERNEL, "pinctrl-%d", state); | ||
195 | prop = of_find_property(np, propname, &size); | ||
196 | kfree(propname); | ||
197 | if (!prop) | ||
198 | break; | ||
199 | list = prop->value; | ||
200 | size /= sizeof(*list); | ||
201 | |||
202 | /* Determine whether pinctrl-names property names the state */ | ||
203 | ret = of_property_read_string_index(np, "pinctrl-names", | ||
204 | state, &statename); | ||
205 | /* | ||
206 | * If not, statename is just the integer state ID. But rather | ||
207 | * than dynamically allocate it and have to free it later, | ||
208 | * just point part way into the property name for the string. | ||
209 | */ | ||
210 | if (ret < 0) { | ||
211 | /* strlen("pinctrl-") == 8 */ | ||
212 | statename = prop->name + 8; | ||
213 | } | ||
214 | |||
215 | /* For every referenced pin configuration node in it */ | ||
216 | for (config = 0; config < size; config++) { | ||
217 | phandle = be32_to_cpup(list++); | ||
218 | |||
219 | /* Look up the pin configuration node */ | ||
220 | np_config = of_find_node_by_phandle(phandle); | ||
221 | if (!np_config) { | ||
222 | dev_err(p->dev, | ||
223 | "prop %s index %i invalid phandle\n", | ||
224 | prop->name, config); | ||
225 | ret = -EINVAL; | ||
226 | goto err; | ||
227 | } | ||
228 | |||
229 | /* Parse the node */ | ||
230 | ret = dt_to_map_one_config(p, statename, np_config); | ||
231 | of_node_put(np_config); | ||
232 | if (ret < 0) | ||
233 | goto err; | ||
234 | } | ||
235 | |||
236 | /* No entries in DT? Generate a dummy state table entry */ | ||
237 | if (!size) { | ||
238 | ret = dt_remember_dummy_state(p, statename); | ||
239 | if (ret < 0) | ||
240 | goto err; | ||
241 | } | ||
242 | } | ||
243 | |||
244 | return 0; | ||
245 | |||
246 | err: | ||
247 | pinctrl_dt_free_maps(p); | ||
248 | return ret; | ||
249 | } | ||
diff --git a/drivers/pinctrl/devicetree.h b/drivers/pinctrl/devicetree.h new file mode 100644 index 000000000000..760bc4960f58 --- /dev/null +++ b/drivers/pinctrl/devicetree.h | |||
@@ -0,0 +1,35 @@ | |||
1 | /* | ||
2 | * Internal interface to pinctrl device tree integration | ||
3 | * | ||
4 | * Copyright (C) 2012 NVIDIA CORPORATION. All rights reserved. | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms and conditions of the GNU General Public License, | ||
8 | * version 2, as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
13 | * more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | |||
19 | #ifdef CONFIG_OF | ||
20 | |||
21 | void pinctrl_dt_free_maps(struct pinctrl *p); | ||
22 | int pinctrl_dt_to_map(struct pinctrl *p); | ||
23 | |||
24 | #else | ||
25 | |||
26 | static inline int pinctrl_dt_to_map(struct pinctrl *p) | ||
27 | { | ||
28 | return 0; | ||
29 | } | ||
30 | |||
31 | static inline void pinctrl_dt_free_maps(struct pinctrl *p) | ||
32 | { | ||
33 | } | ||
34 | |||
35 | #endif | ||
diff --git a/drivers/pinctrl/pinconf.c b/drivers/pinctrl/pinconf.c index 7321e8601294..14f48c96b20d 100644 --- a/drivers/pinctrl/pinconf.c +++ b/drivers/pinctrl/pinconf.c | |||
@@ -379,8 +379,16 @@ int pinconf_apply_setting(struct pinctrl_setting const *setting) | |||
379 | 379 | ||
380 | void pinconf_show_map(struct seq_file *s, struct pinctrl_map const *map) | 380 | void pinconf_show_map(struct seq_file *s, struct pinctrl_map const *map) |
381 | { | 381 | { |
382 | struct pinctrl_dev *pctldev; | ||
383 | const struct pinconf_ops *confops; | ||
382 | int i; | 384 | int i; |
383 | 385 | ||
386 | pctldev = get_pinctrl_dev_from_devname(map->ctrl_dev_name); | ||
387 | if (pctldev) | ||
388 | confops = pctldev->desc->confops; | ||
389 | else | ||
390 | confops = NULL; | ||
391 | |||
384 | switch (map->type) { | 392 | switch (map->type) { |
385 | case PIN_MAP_TYPE_CONFIGS_PIN: | 393 | case PIN_MAP_TYPE_CONFIGS_PIN: |
386 | seq_printf(s, "pin "); | 394 | seq_printf(s, "pin "); |
@@ -394,8 +402,15 @@ void pinconf_show_map(struct seq_file *s, struct pinctrl_map const *map) | |||
394 | 402 | ||
395 | seq_printf(s, "%s\n", map->data.configs.group_or_pin); | 403 | seq_printf(s, "%s\n", map->data.configs.group_or_pin); |
396 | 404 | ||
397 | for (i = 0; i < map->data.configs.num_configs; i++) | 405 | for (i = 0; i < map->data.configs.num_configs; i++) { |
398 | seq_printf(s, "config %08lx\n", map->data.configs.configs[i]); | 406 | seq_printf(s, "config "); |
407 | if (confops && confops->pin_config_config_dbg_show) | ||
408 | confops->pin_config_config_dbg_show(pctldev, s, | ||
409 | map->data.configs.configs[i]); | ||
410 | else | ||
411 | seq_printf(s, "%08lx", map->data.configs.configs[i]); | ||
412 | seq_printf(s, "\n"); | ||
413 | } | ||
399 | } | 414 | } |
400 | 415 | ||
401 | void pinconf_show_setting(struct seq_file *s, | 416 | void pinconf_show_setting(struct seq_file *s, |
@@ -403,6 +418,7 @@ void pinconf_show_setting(struct seq_file *s, | |||
403 | { | 418 | { |
404 | struct pinctrl_dev *pctldev = setting->pctldev; | 419 | struct pinctrl_dev *pctldev = setting->pctldev; |
405 | const struct pinctrl_ops *pctlops = pctldev->desc->pctlops; | 420 | const struct pinctrl_ops *pctlops = pctldev->desc->pctlops; |
421 | const struct pinconf_ops *confops = pctldev->desc->confops; | ||
406 | struct pin_desc *desc; | 422 | struct pin_desc *desc; |
407 | int i; | 423 | int i; |
408 | 424 | ||
@@ -428,8 +444,15 @@ void pinconf_show_setting(struct seq_file *s, | |||
428 | * FIXME: We should really get the pin controler to dump the config | 444 | * FIXME: We should really get the pin controler to dump the config |
429 | * values, so they can be decoded to something meaningful. | 445 | * values, so they can be decoded to something meaningful. |
430 | */ | 446 | */ |
431 | for (i = 0; i < setting->data.configs.num_configs; i++) | 447 | for (i = 0; i < setting->data.configs.num_configs; i++) { |
432 | seq_printf(s, " %08lx", setting->data.configs.configs[i]); | 448 | seq_printf(s, " "); |
449 | if (confops && confops->pin_config_config_dbg_show) | ||
450 | confops->pin_config_config_dbg_show(pctldev, s, | ||
451 | setting->data.configs.configs[i]); | ||
452 | else | ||
453 | seq_printf(s, "%08lx", | ||
454 | setting->data.configs.configs[i]); | ||
455 | } | ||
433 | 456 | ||
434 | seq_printf(s, "\n"); | 457 | seq_printf(s, "\n"); |
435 | } | 458 | } |
@@ -448,10 +471,14 @@ static void pinconf_dump_pin(struct pinctrl_dev *pctldev, | |||
448 | static int pinconf_pins_show(struct seq_file *s, void *what) | 471 | static int pinconf_pins_show(struct seq_file *s, void *what) |
449 | { | 472 | { |
450 | struct pinctrl_dev *pctldev = s->private; | 473 | struct pinctrl_dev *pctldev = s->private; |
474 | const struct pinconf_ops *ops = pctldev->desc->confops; | ||
451 | unsigned i, pin; | 475 | unsigned i, pin; |
452 | 476 | ||
477 | if (!ops || !ops->pin_config_get) | ||
478 | return 0; | ||
479 | |||
453 | seq_puts(s, "Pin config settings per pin\n"); | 480 | seq_puts(s, "Pin config settings per pin\n"); |
454 | seq_puts(s, "Format: pin (name): pinmux setting array\n"); | 481 | seq_puts(s, "Format: pin (name): configs\n"); |
455 | 482 | ||
456 | mutex_lock(&pinctrl_mutex); | 483 | mutex_lock(&pinctrl_mutex); |
457 | 484 | ||
@@ -495,17 +522,18 @@ static int pinconf_groups_show(struct seq_file *s, void *what) | |||
495 | struct pinctrl_dev *pctldev = s->private; | 522 | struct pinctrl_dev *pctldev = s->private; |
496 | const struct pinctrl_ops *pctlops = pctldev->desc->pctlops; | 523 | const struct pinctrl_ops *pctlops = pctldev->desc->pctlops; |
497 | const struct pinconf_ops *ops = pctldev->desc->confops; | 524 | const struct pinconf_ops *ops = pctldev->desc->confops; |
525 | unsigned ngroups = pctlops->get_groups_count(pctldev); | ||
498 | unsigned selector = 0; | 526 | unsigned selector = 0; |
499 | 527 | ||
500 | if (!ops || !ops->pin_config_group_get) | 528 | if (!ops || !ops->pin_config_group_get) |
501 | return 0; | 529 | return 0; |
502 | 530 | ||
503 | seq_puts(s, "Pin config settings per pin group\n"); | 531 | seq_puts(s, "Pin config settings per pin group\n"); |
504 | seq_puts(s, "Format: group (name): pinmux setting array\n"); | 532 | seq_puts(s, "Format: group (name): configs\n"); |
505 | 533 | ||
506 | mutex_lock(&pinctrl_mutex); | 534 | mutex_lock(&pinctrl_mutex); |
507 | 535 | ||
508 | while (pctlops->list_groups(pctldev, selector) >= 0) { | 536 | while (selector < ngroups) { |
509 | const char *gname = pctlops->get_group_name(pctldev, selector); | 537 | const char *gname = pctlops->get_group_name(pctldev, selector); |
510 | 538 | ||
511 | seq_printf(s, "%u (%s):", selector, gname); | 539 | seq_printf(s, "%u (%s):", selector, gname); |
diff --git a/drivers/pinctrl/pinconf.h b/drivers/pinctrl/pinconf.h index 54510de5e8c6..e3ed8cb072a5 100644 --- a/drivers/pinctrl/pinconf.h +++ b/drivers/pinctrl/pinconf.h | |||
@@ -19,11 +19,6 @@ int pinconf_map_to_setting(struct pinctrl_map const *map, | |||
19 | struct pinctrl_setting *setting); | 19 | struct pinctrl_setting *setting); |
20 | void pinconf_free_setting(struct pinctrl_setting const *setting); | 20 | void pinconf_free_setting(struct pinctrl_setting const *setting); |
21 | int pinconf_apply_setting(struct pinctrl_setting const *setting); | 21 | int pinconf_apply_setting(struct pinctrl_setting const *setting); |
22 | void pinconf_show_map(struct seq_file *s, struct pinctrl_map const *map); | ||
23 | void pinconf_show_setting(struct seq_file *s, | ||
24 | struct pinctrl_setting const *setting); | ||
25 | void pinconf_init_device_debugfs(struct dentry *devroot, | ||
26 | struct pinctrl_dev *pctldev); | ||
27 | 22 | ||
28 | /* | 23 | /* |
29 | * You will only be interested in these if you're using PINCONF | 24 | * You will only be interested in these if you're using PINCONF |
@@ -61,6 +56,18 @@ static inline int pinconf_apply_setting(struct pinctrl_setting const *setting) | |||
61 | return 0; | 56 | return 0; |
62 | } | 57 | } |
63 | 58 | ||
59 | #endif | ||
60 | |||
61 | #if defined(CONFIG_PINCONF) && defined(CONFIG_DEBUG_FS) | ||
62 | |||
63 | void pinconf_show_map(struct seq_file *s, struct pinctrl_map const *map); | ||
64 | void pinconf_show_setting(struct seq_file *s, | ||
65 | struct pinctrl_setting const *setting); | ||
66 | void pinconf_init_device_debugfs(struct dentry *devroot, | ||
67 | struct pinctrl_dev *pctldev); | ||
68 | |||
69 | #else | ||
70 | |||
64 | static inline void pinconf_show_map(struct seq_file *s, | 71 | static inline void pinconf_show_map(struct seq_file *s, |
65 | struct pinctrl_map const *map) | 72 | struct pinctrl_map const *map) |
66 | { | 73 | { |
diff --git a/drivers/pinctrl/pinctrl-coh901.c b/drivers/pinctrl/pinctrl-coh901.c index 0797eba3e33a..55697a5d7482 100644 --- a/drivers/pinctrl/pinctrl-coh901.c +++ b/drivers/pinctrl/pinctrl-coh901.c | |||
@@ -174,7 +174,7 @@ struct u300_gpio_confdata { | |||
174 | 174 | ||
175 | 175 | ||
176 | /* Initial configuration */ | 176 | /* Initial configuration */ |
177 | static const struct __initdata u300_gpio_confdata | 177 | static const struct __initconst u300_gpio_confdata |
178 | bs335_gpio_config[BS335_GPIO_NUM_PORTS][U300_GPIO_PINS_PER_PORT] = { | 178 | bs335_gpio_config[BS335_GPIO_NUM_PORTS][U300_GPIO_PINS_PER_PORT] = { |
179 | /* Port 0, pins 0-7 */ | 179 | /* Port 0, pins 0-7 */ |
180 | { | 180 | { |
@@ -255,7 +255,7 @@ bs335_gpio_config[BS335_GPIO_NUM_PORTS][U300_GPIO_PINS_PER_PORT] = { | |||
255 | } | 255 | } |
256 | }; | 256 | }; |
257 | 257 | ||
258 | static const struct __initdata u300_gpio_confdata | 258 | static const struct __initconst u300_gpio_confdata |
259 | bs365_gpio_config[BS365_GPIO_NUM_PORTS][U300_GPIO_PINS_PER_PORT] = { | 259 | bs365_gpio_config[BS365_GPIO_NUM_PORTS][U300_GPIO_PINS_PER_PORT] = { |
260 | /* Port 0, pins 0-7 */ | 260 | /* Port 0, pins 0-7 */ |
261 | { | 261 | { |
diff --git a/drivers/pinctrl/pinctrl-pxa3xx.c b/drivers/pinctrl/pinctrl-pxa3xx.c index 079dce0e93e9..7644e42ac211 100644 --- a/drivers/pinctrl/pinctrl-pxa3xx.c +++ b/drivers/pinctrl/pinctrl-pxa3xx.c | |||
@@ -25,20 +25,18 @@ static struct pinctrl_gpio_range pxa3xx_pinctrl_gpio_range = { | |||
25 | .pin_base = 0, | 25 | .pin_base = 0, |
26 | }; | 26 | }; |
27 | 27 | ||
28 | static int pxa3xx_list_groups(struct pinctrl_dev *pctrldev, unsigned selector) | 28 | static int pxa3xx_get_groups_count(struct pinctrl_dev *pctrldev) |
29 | { | 29 | { |
30 | struct pxa3xx_pinmux_info *info = pinctrl_dev_get_drvdata(pctrldev); | 30 | struct pxa3xx_pinmux_info *info = pinctrl_dev_get_drvdata(pctrldev); |
31 | if (selector >= info->num_grps) | 31 | |
32 | return -EINVAL; | 32 | return info->num_grps; |
33 | return 0; | ||
34 | } | 33 | } |
35 | 34 | ||
36 | static const char *pxa3xx_get_group_name(struct pinctrl_dev *pctrldev, | 35 | static const char *pxa3xx_get_group_name(struct pinctrl_dev *pctrldev, |
37 | unsigned selector) | 36 | unsigned selector) |
38 | { | 37 | { |
39 | struct pxa3xx_pinmux_info *info = pinctrl_dev_get_drvdata(pctrldev); | 38 | struct pxa3xx_pinmux_info *info = pinctrl_dev_get_drvdata(pctrldev); |
40 | if (selector >= info->num_grps) | 39 | |
41 | return NULL; | ||
42 | return info->grps[selector].name; | 40 | return info->grps[selector].name; |
43 | } | 41 | } |
44 | 42 | ||
@@ -48,25 +46,23 @@ static int pxa3xx_get_group_pins(struct pinctrl_dev *pctrldev, | |||
48 | unsigned *num_pins) | 46 | unsigned *num_pins) |
49 | { | 47 | { |
50 | struct pxa3xx_pinmux_info *info = pinctrl_dev_get_drvdata(pctrldev); | 48 | struct pxa3xx_pinmux_info *info = pinctrl_dev_get_drvdata(pctrldev); |
51 | if (selector >= info->num_grps) | 49 | |
52 | return -EINVAL; | ||
53 | *pins = info->grps[selector].pins; | 50 | *pins = info->grps[selector].pins; |
54 | *num_pins = info->grps[selector].npins; | 51 | *num_pins = info->grps[selector].npins; |
55 | return 0; | 52 | return 0; |
56 | } | 53 | } |
57 | 54 | ||
58 | static struct pinctrl_ops pxa3xx_pctrl_ops = { | 55 | static struct pinctrl_ops pxa3xx_pctrl_ops = { |
59 | .list_groups = pxa3xx_list_groups, | 56 | .get_groups_count = pxa3xx_get_groups_count, |
60 | .get_group_name = pxa3xx_get_group_name, | 57 | .get_group_name = pxa3xx_get_group_name, |
61 | .get_group_pins = pxa3xx_get_group_pins, | 58 | .get_group_pins = pxa3xx_get_group_pins, |
62 | }; | 59 | }; |
63 | 60 | ||
64 | static int pxa3xx_pmx_list_func(struct pinctrl_dev *pctrldev, unsigned func) | 61 | static int pxa3xx_pmx_get_funcs_count(struct pinctrl_dev *pctrldev) |
65 | { | 62 | { |
66 | struct pxa3xx_pinmux_info *info = pinctrl_dev_get_drvdata(pctrldev); | 63 | struct pxa3xx_pinmux_info *info = pinctrl_dev_get_drvdata(pctrldev); |
67 | if (func >= info->num_funcs) | 64 | |
68 | return -EINVAL; | 65 | return info->num_funcs; |
69 | return 0; | ||
70 | } | 66 | } |
71 | 67 | ||
72 | static const char *pxa3xx_pmx_get_func_name(struct pinctrl_dev *pctrldev, | 68 | static const char *pxa3xx_pmx_get_func_name(struct pinctrl_dev *pctrldev, |
@@ -170,7 +166,7 @@ static int pxa3xx_pmx_request_gpio(struct pinctrl_dev *pctrldev, | |||
170 | } | 166 | } |
171 | 167 | ||
172 | static struct pinmux_ops pxa3xx_pmx_ops = { | 168 | static struct pinmux_ops pxa3xx_pmx_ops = { |
173 | .list_functions = pxa3xx_pmx_list_func, | 169 | .get_functions_count = pxa3xx_pmx_get_funcs_count, |
174 | .get_function_name = pxa3xx_pmx_get_func_name, | 170 | .get_function_name = pxa3xx_pmx_get_func_name, |
175 | .get_function_groups = pxa3xx_pmx_get_groups, | 171 | .get_function_groups = pxa3xx_pmx_get_groups, |
176 | .enable = pxa3xx_pmx_enable, | 172 | .enable = pxa3xx_pmx_enable, |
diff --git a/drivers/pinctrl/pinctrl-sirf.c b/drivers/pinctrl/pinctrl-sirf.c index 6b3534cc051a..ba15b1a29e52 100644 --- a/drivers/pinctrl/pinctrl-sirf.c +++ b/drivers/pinctrl/pinctrl-sirf.c | |||
@@ -853,18 +853,14 @@ static const struct sirfsoc_pin_group sirfsoc_pin_groups[] = { | |||
853 | SIRFSOC_PIN_GROUP("gpsgrp", gps_pins), | 853 | SIRFSOC_PIN_GROUP("gpsgrp", gps_pins), |
854 | }; | 854 | }; |
855 | 855 | ||
856 | static int sirfsoc_list_groups(struct pinctrl_dev *pctldev, unsigned selector) | 856 | static int sirfsoc_get_groups_count(struct pinctrl_dev *pctldev) |
857 | { | 857 | { |
858 | if (selector >= ARRAY_SIZE(sirfsoc_pin_groups)) | 858 | return ARRAY_SIZE(sirfsoc_pin_groups); |
859 | return -EINVAL; | ||
860 | return 0; | ||
861 | } | 859 | } |
862 | 860 | ||
863 | static const char *sirfsoc_get_group_name(struct pinctrl_dev *pctldev, | 861 | static const char *sirfsoc_get_group_name(struct pinctrl_dev *pctldev, |
864 | unsigned selector) | 862 | unsigned selector) |
865 | { | 863 | { |
866 | if (selector >= ARRAY_SIZE(sirfsoc_pin_groups)) | ||
867 | return NULL; | ||
868 | return sirfsoc_pin_groups[selector].name; | 864 | return sirfsoc_pin_groups[selector].name; |
869 | } | 865 | } |
870 | 866 | ||
@@ -872,8 +868,6 @@ static int sirfsoc_get_group_pins(struct pinctrl_dev *pctldev, unsigned selector | |||
872 | const unsigned **pins, | 868 | const unsigned **pins, |
873 | unsigned *num_pins) | 869 | unsigned *num_pins) |
874 | { | 870 | { |
875 | if (selector >= ARRAY_SIZE(sirfsoc_pin_groups)) | ||
876 | return -EINVAL; | ||
877 | *pins = sirfsoc_pin_groups[selector].pins; | 871 | *pins = sirfsoc_pin_groups[selector].pins; |
878 | *num_pins = sirfsoc_pin_groups[selector].num_pins; | 872 | *num_pins = sirfsoc_pin_groups[selector].num_pins; |
879 | return 0; | 873 | return 0; |
@@ -886,7 +880,7 @@ static void sirfsoc_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s | |||
886 | } | 880 | } |
887 | 881 | ||
888 | static struct pinctrl_ops sirfsoc_pctrl_ops = { | 882 | static struct pinctrl_ops sirfsoc_pctrl_ops = { |
889 | .list_groups = sirfsoc_list_groups, | 883 | .get_groups_count = sirfsoc_get_groups_count, |
890 | .get_group_name = sirfsoc_get_group_name, | 884 | .get_group_name = sirfsoc_get_group_name, |
891 | .get_group_pins = sirfsoc_get_group_pins, | 885 | .get_group_pins = sirfsoc_get_group_pins, |
892 | .pin_dbg_show = sirfsoc_pin_dbg_show, | 886 | .pin_dbg_show = sirfsoc_pin_dbg_show, |
@@ -1033,11 +1027,9 @@ static void sirfsoc_pinmux_disable(struct pinctrl_dev *pmxdev, unsigned selector | |||
1033 | sirfsoc_pinmux_endisable(spmx, selector, false); | 1027 | sirfsoc_pinmux_endisable(spmx, selector, false); |
1034 | } | 1028 | } |
1035 | 1029 | ||
1036 | static int sirfsoc_pinmux_list_funcs(struct pinctrl_dev *pmxdev, unsigned selector) | 1030 | static int sirfsoc_pinmux_get_funcs_count(struct pinctrl_dev *pmxdev) |
1037 | { | 1031 | { |
1038 | if (selector >= ARRAY_SIZE(sirfsoc_pmx_functions)) | 1032 | return ARRAY_SIZE(sirfsoc_pmx_functions); |
1039 | return -EINVAL; | ||
1040 | return 0; | ||
1041 | } | 1033 | } |
1042 | 1034 | ||
1043 | static const char *sirfsoc_pinmux_get_func_name(struct pinctrl_dev *pctldev, | 1035 | static const char *sirfsoc_pinmux_get_func_name(struct pinctrl_dev *pctldev, |
@@ -1074,9 +1066,9 @@ static int sirfsoc_pinmux_request_gpio(struct pinctrl_dev *pmxdev, | |||
1074 | } | 1066 | } |
1075 | 1067 | ||
1076 | static struct pinmux_ops sirfsoc_pinmux_ops = { | 1068 | static struct pinmux_ops sirfsoc_pinmux_ops = { |
1077 | .list_functions = sirfsoc_pinmux_list_funcs, | ||
1078 | .enable = sirfsoc_pinmux_enable, | 1069 | .enable = sirfsoc_pinmux_enable, |
1079 | .disable = sirfsoc_pinmux_disable, | 1070 | .disable = sirfsoc_pinmux_disable, |
1071 | .get_functions_count = sirfsoc_pinmux_get_funcs_count, | ||
1080 | .get_function_name = sirfsoc_pinmux_get_func_name, | 1072 | .get_function_name = sirfsoc_pinmux_get_func_name, |
1081 | .get_function_groups = sirfsoc_pinmux_get_groups, | 1073 | .get_function_groups = sirfsoc_pinmux_get_groups, |
1082 | .gpio_request_enable = sirfsoc_pinmux_request_gpio, | 1074 | .gpio_request_enable = sirfsoc_pinmux_request_gpio, |
diff --git a/drivers/pinctrl/pinctrl-tegra.c b/drivers/pinctrl/pinctrl-tegra.c index 9b329688120c..b6934867d8d3 100644 --- a/drivers/pinctrl/pinctrl-tegra.c +++ b/drivers/pinctrl/pinctrl-tegra.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Driver for the NVIDIA Tegra pinmux | 2 | * Driver for the NVIDIA Tegra pinmux |
3 | * | 3 | * |
4 | * Copyright (c) 2011, NVIDIA CORPORATION. All rights reserved. | 4 | * Copyright (c) 2011-2012, NVIDIA CORPORATION. All rights reserved. |
5 | * | 5 | * |
6 | * Derived from code: | 6 | * Derived from code: |
7 | * Copyright (C) 2010 Google, Inc. | 7 | * Copyright (C) 2010 Google, Inc. |
@@ -22,17 +22,19 @@ | |||
22 | #include <linux/init.h> | 22 | #include <linux/init.h> |
23 | #include <linux/io.h> | 23 | #include <linux/io.h> |
24 | #include <linux/module.h> | 24 | #include <linux/module.h> |
25 | #include <linux/of_device.h> | 25 | #include <linux/of.h> |
26 | #include <linux/platform_device.h> | ||
27 | #include <linux/pinctrl/machine.h> | ||
26 | #include <linux/pinctrl/pinctrl.h> | 28 | #include <linux/pinctrl/pinctrl.h> |
27 | #include <linux/pinctrl/pinmux.h> | 29 | #include <linux/pinctrl/pinmux.h> |
28 | #include <linux/pinctrl/pinconf.h> | 30 | #include <linux/pinctrl/pinconf.h> |
31 | #include <linux/slab.h> | ||
29 | 32 | ||
30 | #include <mach/pinconf-tegra.h> | 33 | #include <mach/pinconf-tegra.h> |
31 | 34 | ||
35 | #include "core.h" | ||
32 | #include "pinctrl-tegra.h" | 36 | #include "pinctrl-tegra.h" |
33 | 37 | ||
34 | #define DRIVER_NAME "tegra-pinmux-disabled" | ||
35 | |||
36 | struct tegra_pmx { | 38 | struct tegra_pmx { |
37 | struct device *dev; | 39 | struct device *dev; |
38 | struct pinctrl_dev *pctl; | 40 | struct pinctrl_dev *pctl; |
@@ -53,15 +55,11 @@ static inline void pmx_writel(struct tegra_pmx *pmx, u32 val, u32 bank, u32 reg) | |||
53 | writel(val, pmx->regs[bank] + reg); | 55 | writel(val, pmx->regs[bank] + reg); |
54 | } | 56 | } |
55 | 57 | ||
56 | static int tegra_pinctrl_list_groups(struct pinctrl_dev *pctldev, | 58 | static int tegra_pinctrl_get_groups_count(struct pinctrl_dev *pctldev) |
57 | unsigned group) | ||
58 | { | 59 | { |
59 | struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); | 60 | struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); |
60 | 61 | ||
61 | if (group >= pmx->soc->ngroups) | 62 | return pmx->soc->ngroups; |
62 | return -EINVAL; | ||
63 | |||
64 | return 0; | ||
65 | } | 63 | } |
66 | 64 | ||
67 | static const char *tegra_pinctrl_get_group_name(struct pinctrl_dev *pctldev, | 65 | static const char *tegra_pinctrl_get_group_name(struct pinctrl_dev *pctldev, |
@@ -69,9 +67,6 @@ static const char *tegra_pinctrl_get_group_name(struct pinctrl_dev *pctldev, | |||
69 | { | 67 | { |
70 | struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); | 68 | struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); |
71 | 69 | ||
72 | if (group >= pmx->soc->ngroups) | ||
73 | return NULL; | ||
74 | |||
75 | return pmx->soc->groups[group].name; | 70 | return pmx->soc->groups[group].name; |
76 | } | 71 | } |
77 | 72 | ||
@@ -82,38 +77,259 @@ static int tegra_pinctrl_get_group_pins(struct pinctrl_dev *pctldev, | |||
82 | { | 77 | { |
83 | struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); | 78 | struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); |
84 | 79 | ||
85 | if (group >= pmx->soc->ngroups) | ||
86 | return -EINVAL; | ||
87 | |||
88 | *pins = pmx->soc->groups[group].pins; | 80 | *pins = pmx->soc->groups[group].pins; |
89 | *num_pins = pmx->soc->groups[group].npins; | 81 | *num_pins = pmx->soc->groups[group].npins; |
90 | 82 | ||
91 | return 0; | 83 | return 0; |
92 | } | 84 | } |
93 | 85 | ||
86 | #ifdef CONFIG_DEBUG_FS | ||
94 | static void tegra_pinctrl_pin_dbg_show(struct pinctrl_dev *pctldev, | 87 | static void tegra_pinctrl_pin_dbg_show(struct pinctrl_dev *pctldev, |
95 | struct seq_file *s, | 88 | struct seq_file *s, |
96 | unsigned offset) | 89 | unsigned offset) |
97 | { | 90 | { |
98 | seq_printf(s, " " DRIVER_NAME); | 91 | seq_printf(s, " %s", dev_name(pctldev->dev)); |
92 | } | ||
93 | #endif | ||
94 | |||
95 | static int reserve_map(struct device *dev, struct pinctrl_map **map, | ||
96 | unsigned *reserved_maps, unsigned *num_maps, | ||
97 | unsigned reserve) | ||
98 | { | ||
99 | unsigned old_num = *reserved_maps; | ||
100 | unsigned new_num = *num_maps + reserve; | ||
101 | struct pinctrl_map *new_map; | ||
102 | |||
103 | if (old_num >= new_num) | ||
104 | return 0; | ||
105 | |||
106 | new_map = krealloc(*map, sizeof(*new_map) * new_num, GFP_KERNEL); | ||
107 | if (!new_map) { | ||
108 | dev_err(dev, "krealloc(map) failed\n"); | ||
109 | return -ENOMEM; | ||
110 | } | ||
111 | |||
112 | memset(new_map + old_num, 0, (new_num - old_num) * sizeof(*new_map)); | ||
113 | |||
114 | *map = new_map; | ||
115 | *reserved_maps = new_num; | ||
116 | |||
117 | return 0; | ||
118 | } | ||
119 | |||
120 | static int add_map_mux(struct pinctrl_map **map, unsigned *reserved_maps, | ||
121 | unsigned *num_maps, const char *group, | ||
122 | const char *function) | ||
123 | { | ||
124 | if (WARN_ON(*num_maps == *reserved_maps)) | ||
125 | return -ENOSPC; | ||
126 | |||
127 | (*map)[*num_maps].type = PIN_MAP_TYPE_MUX_GROUP; | ||
128 | (*map)[*num_maps].data.mux.group = group; | ||
129 | (*map)[*num_maps].data.mux.function = function; | ||
130 | (*num_maps)++; | ||
131 | |||
132 | return 0; | ||
133 | } | ||
134 | |||
135 | static int add_map_configs(struct device *dev, struct pinctrl_map **map, | ||
136 | unsigned *reserved_maps, unsigned *num_maps, | ||
137 | const char *group, unsigned long *configs, | ||
138 | unsigned num_configs) | ||
139 | { | ||
140 | unsigned long *dup_configs; | ||
141 | |||
142 | if (WARN_ON(*num_maps == *reserved_maps)) | ||
143 | return -ENOSPC; | ||
144 | |||
145 | dup_configs = kmemdup(configs, num_configs * sizeof(*dup_configs), | ||
146 | GFP_KERNEL); | ||
147 | if (!dup_configs) { | ||
148 | dev_err(dev, "kmemdup(configs) failed\n"); | ||
149 | return -ENOMEM; | ||
150 | } | ||
151 | |||
152 | (*map)[*num_maps].type = PIN_MAP_TYPE_CONFIGS_GROUP; | ||
153 | (*map)[*num_maps].data.configs.group_or_pin = group; | ||
154 | (*map)[*num_maps].data.configs.configs = dup_configs; | ||
155 | (*map)[*num_maps].data.configs.num_configs = num_configs; | ||
156 | (*num_maps)++; | ||
157 | |||
158 | return 0; | ||
159 | } | ||
160 | |||
161 | static int add_config(struct device *dev, unsigned long **configs, | ||
162 | unsigned *num_configs, unsigned long config) | ||
163 | { | ||
164 | unsigned old_num = *num_configs; | ||
165 | unsigned new_num = old_num + 1; | ||
166 | unsigned long *new_configs; | ||
167 | |||
168 | new_configs = krealloc(*configs, sizeof(*new_configs) * new_num, | ||
169 | GFP_KERNEL); | ||
170 | if (!new_configs) { | ||
171 | dev_err(dev, "krealloc(configs) failed\n"); | ||
172 | return -ENOMEM; | ||
173 | } | ||
174 | |||
175 | new_configs[old_num] = config; | ||
176 | |||
177 | *configs = new_configs; | ||
178 | *num_configs = new_num; | ||
179 | |||
180 | return 0; | ||
181 | } | ||
182 | |||
183 | void tegra_pinctrl_dt_free_map(struct pinctrl_dev *pctldev, | ||
184 | struct pinctrl_map *map, unsigned num_maps) | ||
185 | { | ||
186 | int i; | ||
187 | |||
188 | for (i = 0; i < num_maps; i++) | ||
189 | if (map[i].type == PIN_MAP_TYPE_CONFIGS_GROUP) | ||
190 | kfree(map[i].data.configs.configs); | ||
191 | |||
192 | kfree(map); | ||
193 | } | ||
194 | |||
195 | static const struct cfg_param { | ||
196 | const char *property; | ||
197 | enum tegra_pinconf_param param; | ||
198 | } cfg_params[] = { | ||
199 | {"nvidia,pull", TEGRA_PINCONF_PARAM_PULL}, | ||
200 | {"nvidia,tristate", TEGRA_PINCONF_PARAM_TRISTATE}, | ||
201 | {"nvidia,enable-input", TEGRA_PINCONF_PARAM_ENABLE_INPUT}, | ||
202 | {"nvidia,open-drain", TEGRA_PINCONF_PARAM_OPEN_DRAIN}, | ||
203 | {"nvidia,lock", TEGRA_PINCONF_PARAM_LOCK}, | ||
204 | {"nvidia,io-reset", TEGRA_PINCONF_PARAM_IORESET}, | ||
205 | {"nvidia,high-speed-mode", TEGRA_PINCONF_PARAM_HIGH_SPEED_MODE}, | ||
206 | {"nvidia,schmitt", TEGRA_PINCONF_PARAM_SCHMITT}, | ||
207 | {"nvidia,low-power-mode", TEGRA_PINCONF_PARAM_LOW_POWER_MODE}, | ||
208 | {"nvidia,pull-down-strength", TEGRA_PINCONF_PARAM_DRIVE_DOWN_STRENGTH}, | ||
209 | {"nvidia,pull-up-strength", TEGRA_PINCONF_PARAM_DRIVE_UP_STRENGTH}, | ||
210 | {"nvidia,slew-rate-falling", TEGRA_PINCONF_PARAM_SLEW_RATE_FALLING}, | ||
211 | {"nvidia,slew-rate-rising", TEGRA_PINCONF_PARAM_SLEW_RATE_RISING}, | ||
212 | }; | ||
213 | |||
214 | int tegra_pinctrl_dt_subnode_to_map(struct device *dev, | ||
215 | struct device_node *np, | ||
216 | struct pinctrl_map **map, | ||
217 | unsigned *reserved_maps, | ||
218 | unsigned *num_maps) | ||
219 | { | ||
220 | int ret, i; | ||
221 | const char *function; | ||
222 | u32 val; | ||
223 | unsigned long config; | ||
224 | unsigned long *configs = NULL; | ||
225 | unsigned num_configs = 0; | ||
226 | unsigned reserve; | ||
227 | struct property *prop; | ||
228 | const char *group; | ||
229 | |||
230 | ret = of_property_read_string(np, "nvidia,function", &function); | ||
231 | if (ret < 0) { | ||
232 | /* EINVAL=missing, which is fine since it's optional */ | ||
233 | if (ret != -EINVAL) | ||
234 | dev_err(dev, | ||
235 | "could not parse property nvidia,function\n"); | ||
236 | function = NULL; | ||
237 | } | ||
238 | |||
239 | for (i = 0; i < ARRAY_SIZE(cfg_params); i++) { | ||
240 | ret = of_property_read_u32(np, cfg_params[i].property, &val); | ||
241 | if (!ret) { | ||
242 | config = TEGRA_PINCONF_PACK(cfg_params[i].param, val); | ||
243 | ret = add_config(dev, &configs, &num_configs, config); | ||
244 | if (ret < 0) | ||
245 | goto exit; | ||
246 | /* EINVAL=missing, which is fine since it's optional */ | ||
247 | } else if (ret != -EINVAL) { | ||
248 | dev_err(dev, "could not parse property %s\n", | ||
249 | cfg_params[i].property); | ||
250 | } | ||
251 | } | ||
252 | |||
253 | reserve = 0; | ||
254 | if (function != NULL) | ||
255 | reserve++; | ||
256 | if (num_configs) | ||
257 | reserve++; | ||
258 | ret = of_property_count_strings(np, "nvidia,pins"); | ||
259 | if (ret < 0) { | ||
260 | dev_err(dev, "could not parse property nvidia,pins\n"); | ||
261 | goto exit; | ||
262 | } | ||
263 | reserve *= ret; | ||
264 | |||
265 | ret = reserve_map(dev, map, reserved_maps, num_maps, reserve); | ||
266 | if (ret < 0) | ||
267 | goto exit; | ||
268 | |||
269 | of_property_for_each_string(np, "nvidia,pins", prop, group) { | ||
270 | if (function) { | ||
271 | ret = add_map_mux(map, reserved_maps, num_maps, | ||
272 | group, function); | ||
273 | if (ret < 0) | ||
274 | goto exit; | ||
275 | } | ||
276 | |||
277 | if (num_configs) { | ||
278 | ret = add_map_configs(dev, map, reserved_maps, | ||
279 | num_maps, group, configs, | ||
280 | num_configs); | ||
281 | if (ret < 0) | ||
282 | goto exit; | ||
283 | } | ||
284 | } | ||
285 | |||
286 | ret = 0; | ||
287 | |||
288 | exit: | ||
289 | kfree(configs); | ||
290 | return ret; | ||
291 | } | ||
292 | |||
293 | int tegra_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev, | ||
294 | struct device_node *np_config, | ||
295 | struct pinctrl_map **map, unsigned *num_maps) | ||
296 | { | ||
297 | unsigned reserved_maps; | ||
298 | struct device_node *np; | ||
299 | int ret; | ||
300 | |||
301 | reserved_maps = 0; | ||
302 | *map = NULL; | ||
303 | *num_maps = 0; | ||
304 | |||
305 | for_each_child_of_node(np_config, np) { | ||
306 | ret = tegra_pinctrl_dt_subnode_to_map(pctldev->dev, np, map, | ||
307 | &reserved_maps, num_maps); | ||
308 | if (ret < 0) { | ||
309 | tegra_pinctrl_dt_free_map(pctldev, *map, *num_maps); | ||
310 | return ret; | ||
311 | } | ||
312 | } | ||
313 | |||
314 | return 0; | ||
99 | } | 315 | } |
100 | 316 | ||
101 | static struct pinctrl_ops tegra_pinctrl_ops = { | 317 | static struct pinctrl_ops tegra_pinctrl_ops = { |
102 | .list_groups = tegra_pinctrl_list_groups, | 318 | .get_groups_count = tegra_pinctrl_get_groups_count, |
103 | .get_group_name = tegra_pinctrl_get_group_name, | 319 | .get_group_name = tegra_pinctrl_get_group_name, |
104 | .get_group_pins = tegra_pinctrl_get_group_pins, | 320 | .get_group_pins = tegra_pinctrl_get_group_pins, |
321 | #ifdef CONFIG_DEBUG_FS | ||
105 | .pin_dbg_show = tegra_pinctrl_pin_dbg_show, | 322 | .pin_dbg_show = tegra_pinctrl_pin_dbg_show, |
323 | #endif | ||
324 | .dt_node_to_map = tegra_pinctrl_dt_node_to_map, | ||
325 | .dt_free_map = tegra_pinctrl_dt_free_map, | ||
106 | }; | 326 | }; |
107 | 327 | ||
108 | static int tegra_pinctrl_list_funcs(struct pinctrl_dev *pctldev, | 328 | static int tegra_pinctrl_get_funcs_count(struct pinctrl_dev *pctldev) |
109 | unsigned function) | ||
110 | { | 329 | { |
111 | struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); | 330 | struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); |
112 | 331 | ||
113 | if (function >= pmx->soc->nfunctions) | 332 | return pmx->soc->nfunctions; |
114 | return -EINVAL; | ||
115 | |||
116 | return 0; | ||
117 | } | 333 | } |
118 | 334 | ||
119 | static const char *tegra_pinctrl_get_func_name(struct pinctrl_dev *pctldev, | 335 | static const char *tegra_pinctrl_get_func_name(struct pinctrl_dev *pctldev, |
@@ -121,9 +337,6 @@ static const char *tegra_pinctrl_get_func_name(struct pinctrl_dev *pctldev, | |||
121 | { | 337 | { |
122 | struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); | 338 | struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); |
123 | 339 | ||
124 | if (function >= pmx->soc->nfunctions) | ||
125 | return NULL; | ||
126 | |||
127 | return pmx->soc->functions[function].name; | 340 | return pmx->soc->functions[function].name; |
128 | } | 341 | } |
129 | 342 | ||
@@ -134,9 +347,6 @@ static int tegra_pinctrl_get_func_groups(struct pinctrl_dev *pctldev, | |||
134 | { | 347 | { |
135 | struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); | 348 | struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); |
136 | 349 | ||
137 | if (function >= pmx->soc->nfunctions) | ||
138 | return -EINVAL; | ||
139 | |||
140 | *groups = pmx->soc->functions[function].groups; | 350 | *groups = pmx->soc->functions[function].groups; |
141 | *num_groups = pmx->soc->functions[function].ngroups; | 351 | *num_groups = pmx->soc->functions[function].ngroups; |
142 | 352 | ||
@@ -151,18 +361,16 @@ static int tegra_pinctrl_enable(struct pinctrl_dev *pctldev, unsigned function, | |||
151 | int i; | 361 | int i; |
152 | u32 val; | 362 | u32 val; |
153 | 363 | ||
154 | if (group >= pmx->soc->ngroups) | ||
155 | return -EINVAL; | ||
156 | g = &pmx->soc->groups[group]; | 364 | g = &pmx->soc->groups[group]; |
157 | 365 | ||
158 | if (g->mux_reg < 0) | 366 | if (WARN_ON(g->mux_reg < 0)) |
159 | return -EINVAL; | 367 | return -EINVAL; |
160 | 368 | ||
161 | for (i = 0; i < ARRAY_SIZE(g->funcs); i++) { | 369 | for (i = 0; i < ARRAY_SIZE(g->funcs); i++) { |
162 | if (g->funcs[i] == function) | 370 | if (g->funcs[i] == function) |
163 | break; | 371 | break; |
164 | } | 372 | } |
165 | if (i == ARRAY_SIZE(g->funcs)) | 373 | if (WARN_ON(i == ARRAY_SIZE(g->funcs))) |
166 | return -EINVAL; | 374 | return -EINVAL; |
167 | 375 | ||
168 | val = pmx_readl(pmx, g->mux_bank, g->mux_reg); | 376 | val = pmx_readl(pmx, g->mux_bank, g->mux_reg); |
@@ -180,11 +388,9 @@ static void tegra_pinctrl_disable(struct pinctrl_dev *pctldev, | |||
180 | const struct tegra_pingroup *g; | 388 | const struct tegra_pingroup *g; |
181 | u32 val; | 389 | u32 val; |
182 | 390 | ||
183 | if (group >= pmx->soc->ngroups) | ||
184 | return; | ||
185 | g = &pmx->soc->groups[group]; | 391 | g = &pmx->soc->groups[group]; |
186 | 392 | ||
187 | if (g->mux_reg < 0) | 393 | if (WARN_ON(g->mux_reg < 0)) |
188 | return; | 394 | return; |
189 | 395 | ||
190 | val = pmx_readl(pmx, g->mux_bank, g->mux_reg); | 396 | val = pmx_readl(pmx, g->mux_bank, g->mux_reg); |
@@ -194,7 +400,7 @@ static void tegra_pinctrl_disable(struct pinctrl_dev *pctldev, | |||
194 | } | 400 | } |
195 | 401 | ||
196 | static struct pinmux_ops tegra_pinmux_ops = { | 402 | static struct pinmux_ops tegra_pinmux_ops = { |
197 | .list_functions = tegra_pinctrl_list_funcs, | 403 | .get_functions_count = tegra_pinctrl_get_funcs_count, |
198 | .get_function_name = tegra_pinctrl_get_func_name, | 404 | .get_function_name = tegra_pinctrl_get_func_name, |
199 | .get_function_groups = tegra_pinctrl_get_func_groups, | 405 | .get_function_groups = tegra_pinctrl_get_func_groups, |
200 | .enable = tegra_pinctrl_enable, | 406 | .enable = tegra_pinctrl_enable, |
@@ -204,6 +410,7 @@ static struct pinmux_ops tegra_pinmux_ops = { | |||
204 | static int tegra_pinconf_reg(struct tegra_pmx *pmx, | 410 | static int tegra_pinconf_reg(struct tegra_pmx *pmx, |
205 | const struct tegra_pingroup *g, | 411 | const struct tegra_pingroup *g, |
206 | enum tegra_pinconf_param param, | 412 | enum tegra_pinconf_param param, |
413 | bool report_err, | ||
207 | s8 *bank, s16 *reg, s8 *bit, s8 *width) | 414 | s8 *bank, s16 *reg, s8 *bit, s8 *width) |
208 | { | 415 | { |
209 | switch (param) { | 416 | switch (param) { |
@@ -291,9 +498,10 @@ static int tegra_pinconf_reg(struct tegra_pmx *pmx, | |||
291 | } | 498 | } |
292 | 499 | ||
293 | if (*reg < 0) { | 500 | if (*reg < 0) { |
294 | dev_err(pmx->dev, | 501 | if (report_err) |
295 | "Config param %04x not supported on group %s\n", | 502 | dev_err(pmx->dev, |
296 | param, g->name); | 503 | "Config param %04x not supported on group %s\n", |
504 | param, g->name); | ||
297 | return -ENOTSUPP; | 505 | return -ENOTSUPP; |
298 | } | 506 | } |
299 | 507 | ||
@@ -303,12 +511,14 @@ static int tegra_pinconf_reg(struct tegra_pmx *pmx, | |||
303 | static int tegra_pinconf_get(struct pinctrl_dev *pctldev, | 511 | static int tegra_pinconf_get(struct pinctrl_dev *pctldev, |
304 | unsigned pin, unsigned long *config) | 512 | unsigned pin, unsigned long *config) |
305 | { | 513 | { |
514 | dev_err(pctldev->dev, "pin_config_get op not supported\n"); | ||
306 | return -ENOTSUPP; | 515 | return -ENOTSUPP; |
307 | } | 516 | } |
308 | 517 | ||
309 | static int tegra_pinconf_set(struct pinctrl_dev *pctldev, | 518 | static int tegra_pinconf_set(struct pinctrl_dev *pctldev, |
310 | unsigned pin, unsigned long config) | 519 | unsigned pin, unsigned long config) |
311 | { | 520 | { |
521 | dev_err(pctldev->dev, "pin_config_set op not supported\n"); | ||
312 | return -ENOTSUPP; | 522 | return -ENOTSUPP; |
313 | } | 523 | } |
314 | 524 | ||
@@ -324,11 +534,10 @@ static int tegra_pinconf_group_get(struct pinctrl_dev *pctldev, | |||
324 | s16 reg; | 534 | s16 reg; |
325 | u32 val, mask; | 535 | u32 val, mask; |
326 | 536 | ||
327 | if (group >= pmx->soc->ngroups) | ||
328 | return -EINVAL; | ||
329 | g = &pmx->soc->groups[group]; | 537 | g = &pmx->soc->groups[group]; |
330 | 538 | ||
331 | ret = tegra_pinconf_reg(pmx, g, param, &bank, ®, &bit, &width); | 539 | ret = tegra_pinconf_reg(pmx, g, param, true, &bank, ®, &bit, |
540 | &width); | ||
332 | if (ret < 0) | 541 | if (ret < 0) |
333 | return ret; | 542 | return ret; |
334 | 543 | ||
@@ -353,11 +562,10 @@ static int tegra_pinconf_group_set(struct pinctrl_dev *pctldev, | |||
353 | s16 reg; | 562 | s16 reg; |
354 | u32 val, mask; | 563 | u32 val, mask; |
355 | 564 | ||
356 | if (group >= pmx->soc->ngroups) | ||
357 | return -EINVAL; | ||
358 | g = &pmx->soc->groups[group]; | 565 | g = &pmx->soc->groups[group]; |
359 | 566 | ||
360 | ret = tegra_pinconf_reg(pmx, g, param, &bank, ®, &bit, &width); | 567 | ret = tegra_pinconf_reg(pmx, g, param, true, &bank, ®, &bit, |
568 | &width); | ||
361 | if (ret < 0) | 569 | if (ret < 0) |
362 | return ret; | 570 | return ret; |
363 | 571 | ||
@@ -365,8 +573,10 @@ static int tegra_pinconf_group_set(struct pinctrl_dev *pctldev, | |||
365 | 573 | ||
366 | /* LOCK can't be cleared */ | 574 | /* LOCK can't be cleared */ |
367 | if (param == TEGRA_PINCONF_PARAM_LOCK) { | 575 | if (param == TEGRA_PINCONF_PARAM_LOCK) { |
368 | if ((val & BIT(bit)) && !arg) | 576 | if ((val & BIT(bit)) && !arg) { |
577 | dev_err(pctldev->dev, "LOCK bit cannot be cleared\n"); | ||
369 | return -EINVAL; | 578 | return -EINVAL; |
579 | } | ||
370 | } | 580 | } |
371 | 581 | ||
372 | /* Special-case Boolean values; allow any non-zero as true */ | 582 | /* Special-case Boolean values; allow any non-zero as true */ |
@@ -375,8 +585,12 @@ static int tegra_pinconf_group_set(struct pinctrl_dev *pctldev, | |||
375 | 585 | ||
376 | /* Range-check user-supplied value */ | 586 | /* Range-check user-supplied value */ |
377 | mask = (1 << width) - 1; | 587 | mask = (1 << width) - 1; |
378 | if (arg & ~mask) | 588 | if (arg & ~mask) { |
589 | dev_err(pctldev->dev, | ||
590 | "config %lx: %x too big for %d bit register\n", | ||
591 | config, arg, width); | ||
379 | return -EINVAL; | 592 | return -EINVAL; |
593 | } | ||
380 | 594 | ||
381 | /* Update register */ | 595 | /* Update register */ |
382 | val &= ~(mask << bit); | 596 | val &= ~(mask << bit); |
@@ -386,23 +600,78 @@ static int tegra_pinconf_group_set(struct pinctrl_dev *pctldev, | |||
386 | return 0; | 600 | return 0; |
387 | } | 601 | } |
388 | 602 | ||
603 | #ifdef CONFIG_DEBUG_FS | ||
389 | static void tegra_pinconf_dbg_show(struct pinctrl_dev *pctldev, | 604 | static void tegra_pinconf_dbg_show(struct pinctrl_dev *pctldev, |
390 | struct seq_file *s, unsigned offset) | 605 | struct seq_file *s, unsigned offset) |
391 | { | 606 | { |
392 | } | 607 | } |
393 | 608 | ||
609 | static const char *strip_prefix(const char *s) | ||
610 | { | ||
611 | const char *comma = strchr(s, ','); | ||
612 | if (!comma) | ||
613 | return s; | ||
614 | |||
615 | return comma + 1; | ||
616 | } | ||
617 | |||
394 | static void tegra_pinconf_group_dbg_show(struct pinctrl_dev *pctldev, | 618 | static void tegra_pinconf_group_dbg_show(struct pinctrl_dev *pctldev, |
395 | struct seq_file *s, unsigned selector) | 619 | struct seq_file *s, unsigned group) |
396 | { | 620 | { |
621 | struct tegra_pmx *pmx = pinctrl_dev_get_drvdata(pctldev); | ||
622 | const struct tegra_pingroup *g; | ||
623 | int i, ret; | ||
624 | s8 bank, bit, width; | ||
625 | s16 reg; | ||
626 | u32 val; | ||
627 | |||
628 | g = &pmx->soc->groups[group]; | ||
629 | |||
630 | for (i = 0; i < ARRAY_SIZE(cfg_params); i++) { | ||
631 | ret = tegra_pinconf_reg(pmx, g, cfg_params[i].param, false, | ||
632 | &bank, ®, &bit, &width); | ||
633 | if (ret < 0) | ||
634 | continue; | ||
635 | |||
636 | val = pmx_readl(pmx, bank, reg); | ||
637 | val >>= bit; | ||
638 | val &= (1 << width) - 1; | ||
639 | |||
640 | seq_printf(s, "\n\t%s=%u", | ||
641 | strip_prefix(cfg_params[i].property), val); | ||
642 | } | ||
397 | } | 643 | } |
398 | 644 | ||
645 | static void tegra_pinconf_config_dbg_show(struct pinctrl_dev *pctldev, | ||
646 | struct seq_file *s, | ||
647 | unsigned long config) | ||
648 | { | ||
649 | enum tegra_pinconf_param param = TEGRA_PINCONF_UNPACK_PARAM(config); | ||
650 | u16 arg = TEGRA_PINCONF_UNPACK_ARG(config); | ||
651 | const char *pname = "unknown"; | ||
652 | int i; | ||
653 | |||
654 | for (i = 0; i < ARRAY_SIZE(cfg_params); i++) { | ||
655 | if (cfg_params[i].param == param) { | ||
656 | pname = cfg_params[i].property; | ||
657 | break; | ||
658 | } | ||
659 | } | ||
660 | |||
661 | seq_printf(s, "%s=%d", strip_prefix(pname), arg); | ||
662 | } | ||
663 | #endif | ||
664 | |||
399 | struct pinconf_ops tegra_pinconf_ops = { | 665 | struct pinconf_ops tegra_pinconf_ops = { |
400 | .pin_config_get = tegra_pinconf_get, | 666 | .pin_config_get = tegra_pinconf_get, |
401 | .pin_config_set = tegra_pinconf_set, | 667 | .pin_config_set = tegra_pinconf_set, |
402 | .pin_config_group_get = tegra_pinconf_group_get, | 668 | .pin_config_group_get = tegra_pinconf_group_get, |
403 | .pin_config_group_set = tegra_pinconf_group_set, | 669 | .pin_config_group_set = tegra_pinconf_group_set, |
670 | #ifdef CONFIG_DEBUG_FS | ||
404 | .pin_config_dbg_show = tegra_pinconf_dbg_show, | 671 | .pin_config_dbg_show = tegra_pinconf_dbg_show, |
405 | .pin_config_group_dbg_show = tegra_pinconf_group_dbg_show, | 672 | .pin_config_group_dbg_show = tegra_pinconf_group_dbg_show, |
673 | .pin_config_config_dbg_show = tegra_pinconf_config_dbg_show, | ||
674 | #endif | ||
406 | }; | 675 | }; |
407 | 676 | ||
408 | static struct pinctrl_gpio_range tegra_pinctrl_gpio_range = { | 677 | static struct pinctrl_gpio_range tegra_pinctrl_gpio_range = { |
@@ -412,60 +681,29 @@ static struct pinctrl_gpio_range tegra_pinctrl_gpio_range = { | |||
412 | }; | 681 | }; |
413 | 682 | ||
414 | static struct pinctrl_desc tegra_pinctrl_desc = { | 683 | static struct pinctrl_desc tegra_pinctrl_desc = { |
415 | .name = DRIVER_NAME, | ||
416 | .pctlops = &tegra_pinctrl_ops, | 684 | .pctlops = &tegra_pinctrl_ops, |
417 | .pmxops = &tegra_pinmux_ops, | 685 | .pmxops = &tegra_pinmux_ops, |
418 | .confops = &tegra_pinconf_ops, | 686 | .confops = &tegra_pinconf_ops, |
419 | .owner = THIS_MODULE, | 687 | .owner = THIS_MODULE, |
420 | }; | 688 | }; |
421 | 689 | ||
422 | static struct of_device_id tegra_pinctrl_of_match[] __devinitdata = { | 690 | int __devinit tegra_pinctrl_probe(struct platform_device *pdev, |
423 | #ifdef CONFIG_PINCTRL_TEGRA20 | 691 | const struct tegra_pinctrl_soc_data *soc_data) |
424 | { | ||
425 | .compatible = "nvidia,tegra20-pinmux-disabled", | ||
426 | .data = tegra20_pinctrl_init, | ||
427 | }, | ||
428 | #endif | ||
429 | #ifdef CONFIG_PINCTRL_TEGRA30 | ||
430 | { | ||
431 | .compatible = "nvidia,tegra30-pinmux-disabled", | ||
432 | .data = tegra30_pinctrl_init, | ||
433 | }, | ||
434 | #endif | ||
435 | {}, | ||
436 | }; | ||
437 | |||
438 | static int __devinit tegra_pinctrl_probe(struct platform_device *pdev) | ||
439 | { | 692 | { |
440 | const struct of_device_id *match; | ||
441 | tegra_pinctrl_soc_initf initf = NULL; | ||
442 | struct tegra_pmx *pmx; | 693 | struct tegra_pmx *pmx; |
443 | struct resource *res; | 694 | struct resource *res; |
444 | int i; | 695 | int i; |
445 | 696 | ||
446 | match = of_match_device(tegra_pinctrl_of_match, &pdev->dev); | ||
447 | if (match) | ||
448 | initf = (tegra_pinctrl_soc_initf)match->data; | ||
449 | #ifdef CONFIG_PINCTRL_TEGRA20 | ||
450 | if (!initf) | ||
451 | initf = tegra20_pinctrl_init; | ||
452 | #endif | ||
453 | if (!initf) { | ||
454 | dev_err(&pdev->dev, | ||
455 | "Could not determine SoC-specific init func\n"); | ||
456 | return -EINVAL; | ||
457 | } | ||
458 | |||
459 | pmx = devm_kzalloc(&pdev->dev, sizeof(*pmx), GFP_KERNEL); | 697 | pmx = devm_kzalloc(&pdev->dev, sizeof(*pmx), GFP_KERNEL); |
460 | if (!pmx) { | 698 | if (!pmx) { |
461 | dev_err(&pdev->dev, "Can't alloc tegra_pmx\n"); | 699 | dev_err(&pdev->dev, "Can't alloc tegra_pmx\n"); |
462 | return -ENOMEM; | 700 | return -ENOMEM; |
463 | } | 701 | } |
464 | pmx->dev = &pdev->dev; | 702 | pmx->dev = &pdev->dev; |
465 | 703 | pmx->soc = soc_data; | |
466 | (*initf)(&pmx->soc); | ||
467 | 704 | ||
468 | tegra_pinctrl_gpio_range.npins = pmx->soc->ngpios; | 705 | tegra_pinctrl_gpio_range.npins = pmx->soc->ngpios; |
706 | tegra_pinctrl_desc.name = dev_name(&pdev->dev); | ||
469 | tegra_pinctrl_desc.pins = pmx->soc->pins; | 707 | tegra_pinctrl_desc.pins = pmx->soc->pins; |
470 | tegra_pinctrl_desc.npins = pmx->soc->npins; | 708 | tegra_pinctrl_desc.npins = pmx->soc->npins; |
471 | 709 | ||
@@ -520,8 +758,9 @@ static int __devinit tegra_pinctrl_probe(struct platform_device *pdev) | |||
520 | 758 | ||
521 | return 0; | 759 | return 0; |
522 | } | 760 | } |
761 | EXPORT_SYMBOL_GPL(tegra_pinctrl_probe); | ||
523 | 762 | ||
524 | static int __devexit tegra_pinctrl_remove(struct platform_device *pdev) | 763 | int __devexit tegra_pinctrl_remove(struct platform_device *pdev) |
525 | { | 764 | { |
526 | struct tegra_pmx *pmx = platform_get_drvdata(pdev); | 765 | struct tegra_pmx *pmx = platform_get_drvdata(pdev); |
527 | 766 | ||
@@ -530,30 +769,4 @@ static int __devexit tegra_pinctrl_remove(struct platform_device *pdev) | |||
530 | 769 | ||
531 | return 0; | 770 | return 0; |
532 | } | 771 | } |
533 | 772 | EXPORT_SYMBOL_GPL(tegra_pinctrl_remove); | |
534 | static struct platform_driver tegra_pinctrl_driver = { | ||
535 | .driver = { | ||
536 | .name = DRIVER_NAME, | ||
537 | .owner = THIS_MODULE, | ||
538 | .of_match_table = tegra_pinctrl_of_match, | ||
539 | }, | ||
540 | .probe = tegra_pinctrl_probe, | ||
541 | .remove = __devexit_p(tegra_pinctrl_remove), | ||
542 | }; | ||
543 | |||
544 | static int __init tegra_pinctrl_init(void) | ||
545 | { | ||
546 | return platform_driver_register(&tegra_pinctrl_driver); | ||
547 | } | ||
548 | arch_initcall(tegra_pinctrl_init); | ||
549 | |||
550 | static void __exit tegra_pinctrl_exit(void) | ||
551 | { | ||
552 | platform_driver_unregister(&tegra_pinctrl_driver); | ||
553 | } | ||
554 | module_exit(tegra_pinctrl_exit); | ||
555 | |||
556 | MODULE_AUTHOR("Stephen Warren <swarren@nvidia.com>"); | ||
557 | MODULE_DESCRIPTION("NVIDIA Tegra pinctrl driver"); | ||
558 | MODULE_LICENSE("GPL v2"); | ||
559 | MODULE_DEVICE_TABLE(of, tegra_pinctrl_of_match); | ||
diff --git a/drivers/pinctrl/pinctrl-tegra.h b/drivers/pinctrl/pinctrl-tegra.h index 782c795326ef..705c007a38cc 100644 --- a/drivers/pinctrl/pinctrl-tegra.h +++ b/drivers/pinctrl/pinctrl-tegra.h | |||
@@ -139,25 +139,8 @@ struct tegra_pinctrl_soc_data { | |||
139 | unsigned ngroups; | 139 | unsigned ngroups; |
140 | }; | 140 | }; |
141 | 141 | ||
142 | /** | 142 | int tegra_pinctrl_probe(struct platform_device *pdev, |
143 | * tegra_pinctrl_soc_initf() - Retrieve pin controller details for a SoC. | 143 | const struct tegra_pinctrl_soc_data *soc_data); |
144 | * @soc_data: This pointer must be updated to point at a struct containing | 144 | int tegra_pinctrl_remove(struct platform_device *pdev); |
145 | * details of the SoC. | ||
146 | */ | ||
147 | typedef void (*tegra_pinctrl_soc_initf)( | ||
148 | const struct tegra_pinctrl_soc_data **soc_data); | ||
149 | |||
150 | /** | ||
151 | * tegra20_pinctrl_init() - Retrieve pin controller details for Tegra20 | ||
152 | * @soc_data: This pointer will be updated to point at a struct containing | ||
153 | * details of Tegra20's pin controller. | ||
154 | */ | ||
155 | void tegra20_pinctrl_init(const struct tegra_pinctrl_soc_data **soc_data); | ||
156 | /** | ||
157 | * tegra30_pinctrl_init() - Retrieve pin controller details for Tegra20 | ||
158 | * @soc_data: This pointer will be updated to point at a struct containing | ||
159 | * details of Tegra30's pin controller. | ||
160 | */ | ||
161 | void tegra30_pinctrl_init(const struct tegra_pinctrl_soc_data **soc_data); | ||
162 | 145 | ||
163 | #endif | 146 | #endif |
diff --git a/drivers/pinctrl/pinctrl-tegra20.c b/drivers/pinctrl/pinctrl-tegra20.c index f69ff96aa292..a74f9a568536 100644 --- a/drivers/pinctrl/pinctrl-tegra20.c +++ b/drivers/pinctrl/pinctrl-tegra20.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Pinctrl data for the NVIDIA Tegra20 pinmux | 2 | * Pinctrl data for the NVIDIA Tegra20 pinmux |
3 | * | 3 | * |
4 | * Copyright (c) 2011, NVIDIA CORPORATION. All rights reserved. | 4 | * Copyright (c) 2011-2012, NVIDIA CORPORATION. All rights reserved. |
5 | * | 5 | * |
6 | * Derived from code: | 6 | * Derived from code: |
7 | * Copyright (C) 2010 Google, Inc. | 7 | * Copyright (C) 2010 Google, Inc. |
@@ -17,6 +17,8 @@ | |||
17 | * more details. | 17 | * more details. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #include <linux/module.h> | ||
21 | #include <linux/of.h> | ||
20 | #include <linux/platform_device.h> | 22 | #include <linux/platform_device.h> |
21 | #include <linux/pinctrl/pinctrl.h> | 23 | #include <linux/pinctrl/pinctrl.h> |
22 | #include <linux/pinctrl/pinmux.h> | 24 | #include <linux/pinctrl/pinmux.h> |
@@ -2854,7 +2856,39 @@ static const struct tegra_pinctrl_soc_data tegra20_pinctrl = { | |||
2854 | .ngroups = ARRAY_SIZE(tegra20_groups), | 2856 | .ngroups = ARRAY_SIZE(tegra20_groups), |
2855 | }; | 2857 | }; |
2856 | 2858 | ||
2857 | void __devinit tegra20_pinctrl_init(const struct tegra_pinctrl_soc_data **soc) | 2859 | static int __devinit tegra20_pinctrl_probe(struct platform_device *pdev) |
2858 | { | 2860 | { |
2859 | *soc = &tegra20_pinctrl; | 2861 | return tegra_pinctrl_probe(pdev, &tegra20_pinctrl); |
2860 | } | 2862 | } |
2863 | |||
2864 | static struct of_device_id tegra20_pinctrl_of_match[] __devinitdata = { | ||
2865 | { .compatible = "nvidia,tegra20-pinmux", }, | ||
2866 | { }, | ||
2867 | }; | ||
2868 | |||
2869 | static struct platform_driver tegra20_pinctrl_driver = { | ||
2870 | .driver = { | ||
2871 | .name = "tegra20-pinctrl", | ||
2872 | .owner = THIS_MODULE, | ||
2873 | .of_match_table = tegra20_pinctrl_of_match, | ||
2874 | }, | ||
2875 | .probe = tegra20_pinctrl_probe, | ||
2876 | .remove = __devexit_p(tegra_pinctrl_remove), | ||
2877 | }; | ||
2878 | |||
2879 | static int __init tegra20_pinctrl_init(void) | ||
2880 | { | ||
2881 | return platform_driver_register(&tegra20_pinctrl_driver); | ||
2882 | } | ||
2883 | arch_initcall(tegra20_pinctrl_init); | ||
2884 | |||
2885 | static void __exit tegra20_pinctrl_exit(void) | ||
2886 | { | ||
2887 | platform_driver_unregister(&tegra20_pinctrl_driver); | ||
2888 | } | ||
2889 | module_exit(tegra20_pinctrl_exit); | ||
2890 | |||
2891 | MODULE_AUTHOR("Stephen Warren <swarren@nvidia.com>"); | ||
2892 | MODULE_DESCRIPTION("NVIDIA Tegra20 pinctrl driver"); | ||
2893 | MODULE_LICENSE("GPL v2"); | ||
2894 | MODULE_DEVICE_TABLE(of, tegra20_pinctrl_of_match); | ||
diff --git a/drivers/pinctrl/pinctrl-tegra30.c b/drivers/pinctrl/pinctrl-tegra30.c index 4d7571d4a431..0386fdf0da16 100644 --- a/drivers/pinctrl/pinctrl-tegra30.c +++ b/drivers/pinctrl/pinctrl-tegra30.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Pinctrl data for the NVIDIA Tegra30 pinmux | 2 | * Pinctrl data for the NVIDIA Tegra30 pinmux |
3 | * | 3 | * |
4 | * Copyright (c) 2011, NVIDIA CORPORATION. All rights reserved. | 4 | * Copyright (c) 2011-2012, NVIDIA CORPORATION. All rights reserved. |
5 | * | 5 | * |
6 | * This program is free software; you can redistribute it and/or modify it | 6 | * This program is free software; you can redistribute it and/or modify it |
7 | * under the terms and conditions of the GNU General Public License, | 7 | * under the terms and conditions of the GNU General Public License, |
@@ -13,6 +13,8 @@ | |||
13 | * more details. | 13 | * more details. |
14 | */ | 14 | */ |
15 | 15 | ||
16 | #include <linux/module.h> | ||
17 | #include <linux/of.h> | ||
16 | #include <linux/platform_device.h> | 18 | #include <linux/platform_device.h> |
17 | #include <linux/pinctrl/pinctrl.h> | 19 | #include <linux/pinctrl/pinctrl.h> |
18 | #include <linux/pinctrl/pinmux.h> | 20 | #include <linux/pinctrl/pinmux.h> |
@@ -3720,7 +3722,39 @@ static const struct tegra_pinctrl_soc_data tegra30_pinctrl = { | |||
3720 | .ngroups = ARRAY_SIZE(tegra30_groups), | 3722 | .ngroups = ARRAY_SIZE(tegra30_groups), |
3721 | }; | 3723 | }; |
3722 | 3724 | ||
3723 | void __devinit tegra30_pinctrl_init(const struct tegra_pinctrl_soc_data **soc) | 3725 | static int __devinit tegra30_pinctrl_probe(struct platform_device *pdev) |
3724 | { | 3726 | { |
3725 | *soc = &tegra30_pinctrl; | 3727 | return tegra_pinctrl_probe(pdev, &tegra30_pinctrl); |
3726 | } | 3728 | } |
3729 | |||
3730 | static struct of_device_id tegra30_pinctrl_of_match[] __devinitdata = { | ||
3731 | { .compatible = "nvidia,tegra30-pinmux", }, | ||
3732 | { }, | ||
3733 | }; | ||
3734 | |||
3735 | static struct platform_driver tegra30_pinctrl_driver = { | ||
3736 | .driver = { | ||
3737 | .name = "tegra30-pinctrl", | ||
3738 | .owner = THIS_MODULE, | ||
3739 | .of_match_table = tegra30_pinctrl_of_match, | ||
3740 | }, | ||
3741 | .probe = tegra30_pinctrl_probe, | ||
3742 | .remove = __devexit_p(tegra_pinctrl_remove), | ||
3743 | }; | ||
3744 | |||
3745 | static int __init tegra30_pinctrl_init(void) | ||
3746 | { | ||
3747 | return platform_driver_register(&tegra30_pinctrl_driver); | ||
3748 | } | ||
3749 | arch_initcall(tegra30_pinctrl_init); | ||
3750 | |||
3751 | static void __exit tegra30_pinctrl_exit(void) | ||
3752 | { | ||
3753 | platform_driver_unregister(&tegra30_pinctrl_driver); | ||
3754 | } | ||
3755 | module_exit(tegra30_pinctrl_exit); | ||
3756 | |||
3757 | MODULE_AUTHOR("Stephen Warren <swarren@nvidia.com>"); | ||
3758 | MODULE_DESCRIPTION("NVIDIA Tegra30 pinctrl driver"); | ||
3759 | MODULE_LICENSE("GPL v2"); | ||
3760 | MODULE_DEVICE_TABLE(of, tegra30_pinctrl_of_match); | ||
diff --git a/drivers/pinctrl/pinctrl-u300.c b/drivers/pinctrl/pinctrl-u300.c index 26eb8ccd72d5..05d029911be6 100644 --- a/drivers/pinctrl/pinctrl-u300.c +++ b/drivers/pinctrl/pinctrl-u300.c | |||
@@ -836,18 +836,14 @@ static const struct u300_pin_group u300_pin_groups[] = { | |||
836 | }, | 836 | }, |
837 | }; | 837 | }; |
838 | 838 | ||
839 | static int u300_list_groups(struct pinctrl_dev *pctldev, unsigned selector) | 839 | static int u300_get_groups_count(struct pinctrl_dev *pctldev) |
840 | { | 840 | { |
841 | if (selector >= ARRAY_SIZE(u300_pin_groups)) | 841 | return ARRAY_SIZE(u300_pin_groups); |
842 | return -EINVAL; | ||
843 | return 0; | ||
844 | } | 842 | } |
845 | 843 | ||
846 | static const char *u300_get_group_name(struct pinctrl_dev *pctldev, | 844 | static const char *u300_get_group_name(struct pinctrl_dev *pctldev, |
847 | unsigned selector) | 845 | unsigned selector) |
848 | { | 846 | { |
849 | if (selector >= ARRAY_SIZE(u300_pin_groups)) | ||
850 | return NULL; | ||
851 | return u300_pin_groups[selector].name; | 847 | return u300_pin_groups[selector].name; |
852 | } | 848 | } |
853 | 849 | ||
@@ -855,8 +851,6 @@ static int u300_get_group_pins(struct pinctrl_dev *pctldev, unsigned selector, | |||
855 | const unsigned **pins, | 851 | const unsigned **pins, |
856 | unsigned *num_pins) | 852 | unsigned *num_pins) |
857 | { | 853 | { |
858 | if (selector >= ARRAY_SIZE(u300_pin_groups)) | ||
859 | return -EINVAL; | ||
860 | *pins = u300_pin_groups[selector].pins; | 854 | *pins = u300_pin_groups[selector].pins; |
861 | *num_pins = u300_pin_groups[selector].num_pins; | 855 | *num_pins = u300_pin_groups[selector].num_pins; |
862 | return 0; | 856 | return 0; |
@@ -869,7 +863,7 @@ static void u300_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s, | |||
869 | } | 863 | } |
870 | 864 | ||
871 | static struct pinctrl_ops u300_pctrl_ops = { | 865 | static struct pinctrl_ops u300_pctrl_ops = { |
872 | .list_groups = u300_list_groups, | 866 | .get_groups_count = u300_get_groups_count, |
873 | .get_group_name = u300_get_group_name, | 867 | .get_group_name = u300_get_group_name, |
874 | .get_group_pins = u300_get_group_pins, | 868 | .get_group_pins = u300_get_group_pins, |
875 | .pin_dbg_show = u300_pin_dbg_show, | 869 | .pin_dbg_show = u300_pin_dbg_show, |
@@ -991,11 +985,9 @@ static void u300_pmx_disable(struct pinctrl_dev *pctldev, unsigned selector, | |||
991 | u300_pmx_endisable(upmx, selector, false); | 985 | u300_pmx_endisable(upmx, selector, false); |
992 | } | 986 | } |
993 | 987 | ||
994 | static int u300_pmx_list_funcs(struct pinctrl_dev *pctldev, unsigned selector) | 988 | static int u300_pmx_get_funcs_count(struct pinctrl_dev *pctldev) |
995 | { | 989 | { |
996 | if (selector >= ARRAY_SIZE(u300_pmx_functions)) | 990 | return ARRAY_SIZE(u300_pmx_functions); |
997 | return -EINVAL; | ||
998 | return 0; | ||
999 | } | 991 | } |
1000 | 992 | ||
1001 | static const char *u300_pmx_get_func_name(struct pinctrl_dev *pctldev, | 993 | static const char *u300_pmx_get_func_name(struct pinctrl_dev *pctldev, |
@@ -1014,7 +1006,7 @@ static int u300_pmx_get_groups(struct pinctrl_dev *pctldev, unsigned selector, | |||
1014 | } | 1006 | } |
1015 | 1007 | ||
1016 | static struct pinmux_ops u300_pmx_ops = { | 1008 | static struct pinmux_ops u300_pmx_ops = { |
1017 | .list_functions = u300_pmx_list_funcs, | 1009 | .get_functions_count = u300_pmx_get_funcs_count, |
1018 | .get_function_name = u300_pmx_get_func_name, | 1010 | .get_function_name = u300_pmx_get_func_name, |
1019 | .get_function_groups = u300_pmx_get_groups, | 1011 | .get_function_groups = u300_pmx_get_groups, |
1020 | .enable = u300_pmx_enable, | 1012 | .enable = u300_pmx_enable, |
diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c index 4e62783a573a..fa0357bd88ff 100644 --- a/drivers/pinctrl/pinmux.c +++ b/drivers/pinctrl/pinmux.c | |||
@@ -33,10 +33,12 @@ | |||
33 | int pinmux_check_ops(struct pinctrl_dev *pctldev) | 33 | int pinmux_check_ops(struct pinctrl_dev *pctldev) |
34 | { | 34 | { |
35 | const struct pinmux_ops *ops = pctldev->desc->pmxops; | 35 | const struct pinmux_ops *ops = pctldev->desc->pmxops; |
36 | unsigned nfuncs; | ||
36 | unsigned selector = 0; | 37 | unsigned selector = 0; |
37 | 38 | ||
38 | /* Check that we implement required operations */ | 39 | /* Check that we implement required operations */ |
39 | if (!ops->list_functions || | 40 | if (!ops || |
41 | !ops->get_functions_count || | ||
40 | !ops->get_function_name || | 42 | !ops->get_function_name || |
41 | !ops->get_function_groups || | 43 | !ops->get_function_groups || |
42 | !ops->enable || | 44 | !ops->enable || |
@@ -44,11 +46,12 @@ int pinmux_check_ops(struct pinctrl_dev *pctldev) | |||
44 | return -EINVAL; | 46 | return -EINVAL; |
45 | 47 | ||
46 | /* Check that all functions registered have names */ | 48 | /* Check that all functions registered have names */ |
47 | while (ops->list_functions(pctldev, selector) >= 0) { | 49 | nfuncs = ops->get_functions_count(pctldev); |
50 | while (selector < nfuncs) { | ||
48 | const char *fname = ops->get_function_name(pctldev, | 51 | const char *fname = ops->get_function_name(pctldev, |
49 | selector); | 52 | selector); |
50 | if (!fname) { | 53 | if (!fname) { |
51 | pr_err("pinmux ops has no name for function%u\n", | 54 | dev_err(pctldev->dev, "pinmux ops has no name for function%u\n", |
52 | selector); | 55 | selector); |
53 | return -EINVAL; | 56 | return -EINVAL; |
54 | } | 57 | } |
@@ -85,8 +88,6 @@ static int pin_request(struct pinctrl_dev *pctldev, | |||
85 | const struct pinmux_ops *ops = pctldev->desc->pmxops; | 88 | const struct pinmux_ops *ops = pctldev->desc->pmxops; |
86 | int status = -EINVAL; | 89 | int status = -EINVAL; |
87 | 90 | ||
88 | dev_dbg(pctldev->dev, "request pin %d for %s\n", pin, owner); | ||
89 | |||
90 | desc = pin_desc_get(pctldev, pin); | 91 | desc = pin_desc_get(pctldev, pin); |
91 | if (desc == NULL) { | 92 | if (desc == NULL) { |
92 | dev_err(pctldev->dev, | 93 | dev_err(pctldev->dev, |
@@ -94,6 +95,9 @@ static int pin_request(struct pinctrl_dev *pctldev, | |||
94 | goto out; | 95 | goto out; |
95 | } | 96 | } |
96 | 97 | ||
98 | dev_dbg(pctldev->dev, "request pin %d (%s) for %s\n", | ||
99 | pin, desc->name, owner); | ||
100 | |||
97 | if (gpio_range) { | 101 | if (gpio_range) { |
98 | /* There's no need to support multiple GPIO requests */ | 102 | /* There's no need to support multiple GPIO requests */ |
99 | if (desc->gpio_owner) { | 103 | if (desc->gpio_owner) { |
@@ -287,10 +291,11 @@ static int pinmux_func_name_to_selector(struct pinctrl_dev *pctldev, | |||
287 | const char *function) | 291 | const char *function) |
288 | { | 292 | { |
289 | const struct pinmux_ops *ops = pctldev->desc->pmxops; | 293 | const struct pinmux_ops *ops = pctldev->desc->pmxops; |
294 | unsigned nfuncs = ops->get_functions_count(pctldev); | ||
290 | unsigned selector = 0; | 295 | unsigned selector = 0; |
291 | 296 | ||
292 | /* See if this pctldev has this function */ | 297 | /* See if this pctldev has this function */ |
293 | while (ops->list_functions(pctldev, selector) >= 0) { | 298 | while (selector < nfuncs) { |
294 | const char *fname = ops->get_function_name(pctldev, | 299 | const char *fname = ops->get_function_name(pctldev, |
295 | selector); | 300 | selector); |
296 | 301 | ||
@@ -319,6 +324,11 @@ int pinmux_map_to_setting(struct pinctrl_map const *map, | |||
319 | const unsigned *pins; | 324 | const unsigned *pins; |
320 | unsigned num_pins; | 325 | unsigned num_pins; |
321 | 326 | ||
327 | if (!pmxops) { | ||
328 | dev_err(pctldev->dev, "does not support mux function\n"); | ||
329 | return -EINVAL; | ||
330 | } | ||
331 | |||
322 | setting->data.mux.func = | 332 | setting->data.mux.func = |
323 | pinmux_func_name_to_selector(pctldev, map->data.mux.function); | 333 | pinmux_func_name_to_selector(pctldev, map->data.mux.function); |
324 | if (setting->data.mux.func < 0) | 334 | if (setting->data.mux.func < 0) |
@@ -477,11 +487,15 @@ static int pinmux_functions_show(struct seq_file *s, void *what) | |||
477 | { | 487 | { |
478 | struct pinctrl_dev *pctldev = s->private; | 488 | struct pinctrl_dev *pctldev = s->private; |
479 | const struct pinmux_ops *pmxops = pctldev->desc->pmxops; | 489 | const struct pinmux_ops *pmxops = pctldev->desc->pmxops; |
490 | unsigned nfuncs; | ||
480 | unsigned func_selector = 0; | 491 | unsigned func_selector = 0; |
481 | 492 | ||
482 | mutex_lock(&pinctrl_mutex); | 493 | if (!pmxops) |
494 | return 0; | ||
483 | 495 | ||
484 | while (pmxops->list_functions(pctldev, func_selector) >= 0) { | 496 | mutex_lock(&pinctrl_mutex); |
497 | nfuncs = pmxops->get_functions_count(pctldev); | ||
498 | while (func_selector < nfuncs) { | ||
485 | const char *func = pmxops->get_function_name(pctldev, | 499 | const char *func = pmxops->get_function_name(pctldev, |
486 | func_selector); | 500 | func_selector); |
487 | const char * const *groups; | 501 | const char * const *groups; |
@@ -515,6 +529,9 @@ static int pinmux_pins_show(struct seq_file *s, void *what) | |||
515 | const struct pinmux_ops *pmxops = pctldev->desc->pmxops; | 529 | const struct pinmux_ops *pmxops = pctldev->desc->pmxops; |
516 | unsigned i, pin; | 530 | unsigned i, pin; |
517 | 531 | ||
532 | if (!pmxops) | ||
533 | return 0; | ||
534 | |||
518 | seq_puts(s, "Pinmux settings per pin\n"); | 535 | seq_puts(s, "Pinmux settings per pin\n"); |
519 | seq_puts(s, "Format: pin (name): mux_owner gpio_owner hog?\n"); | 536 | seq_puts(s, "Format: pin (name): mux_owner gpio_owner hog?\n"); |
520 | 537 | ||
diff --git a/drivers/pinctrl/pinmux.h b/drivers/pinctrl/pinmux.h index 6fc47003e95d..d1a98b1c9fce 100644 --- a/drivers/pinctrl/pinmux.h +++ b/drivers/pinctrl/pinmux.h | |||
@@ -31,12 +31,6 @@ void pinmux_free_setting(struct pinctrl_setting const *setting); | |||
31 | int pinmux_enable_setting(struct pinctrl_setting const *setting); | 31 | int pinmux_enable_setting(struct pinctrl_setting const *setting); |
32 | void pinmux_disable_setting(struct pinctrl_setting const *setting); | 32 | void pinmux_disable_setting(struct pinctrl_setting const *setting); |
33 | 33 | ||
34 | void pinmux_show_map(struct seq_file *s, struct pinctrl_map const *map); | ||
35 | void pinmux_show_setting(struct seq_file *s, | ||
36 | struct pinctrl_setting const *setting); | ||
37 | void pinmux_init_device_debugfs(struct dentry *devroot, | ||
38 | struct pinctrl_dev *pctldev); | ||
39 | |||
40 | #else | 34 | #else |
41 | 35 | ||
42 | static inline int pinmux_check_ops(struct pinctrl_dev *pctldev) | 36 | static inline int pinmux_check_ops(struct pinctrl_dev *pctldev) |
@@ -89,6 +83,18 @@ static inline void pinmux_disable_setting( | |||
89 | { | 83 | { |
90 | } | 84 | } |
91 | 85 | ||
86 | #endif | ||
87 | |||
88 | #if defined(CONFIG_PINMUX) && defined(CONFIG_DEBUG_FS) | ||
89 | |||
90 | void pinmux_show_map(struct seq_file *s, struct pinctrl_map const *map); | ||
91 | void pinmux_show_setting(struct seq_file *s, | ||
92 | struct pinctrl_setting const *setting); | ||
93 | void pinmux_init_device_debugfs(struct dentry *devroot, | ||
94 | struct pinctrl_dev *pctldev); | ||
95 | |||
96 | #else | ||
97 | |||
92 | static inline void pinmux_show_map(struct seq_file *s, | 98 | static inline void pinmux_show_map(struct seq_file *s, |
93 | struct pinctrl_map const *map) | 99 | struct pinctrl_map const *map) |
94 | { | 100 | { |
diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c index f214a80cdee2..87e271b9c157 100644 --- a/drivers/usb/host/ehci-tegra.c +++ b/drivers/usb/host/ehci-tegra.c | |||
@@ -436,15 +436,16 @@ static const struct hc_driver tegra_ehci_hc_driver = { | |||
436 | .port_handed_over = ehci_port_handed_over, | 436 | .port_handed_over = ehci_port_handed_over, |
437 | }; | 437 | }; |
438 | 438 | ||
439 | static int setup_vbus_gpio(struct platform_device *pdev) | 439 | static int setup_vbus_gpio(struct platform_device *pdev, |
440 | struct tegra_ehci_platform_data *pdata) | ||
440 | { | 441 | { |
441 | int err = 0; | 442 | int err = 0; |
442 | int gpio; | 443 | int gpio; |
443 | 444 | ||
444 | if (!pdev->dev.of_node) | 445 | gpio = pdata->vbus_gpio; |
445 | return 0; | 446 | if (!gpio_is_valid(gpio)) |
446 | 447 | gpio = of_get_named_gpio(pdev->dev.of_node, | |
447 | gpio = of_get_named_gpio(pdev->dev.of_node, "nvidia,vbus-gpio", 0); | 448 | "nvidia,vbus-gpio", 0); |
448 | if (!gpio_is_valid(gpio)) | 449 | if (!gpio_is_valid(gpio)) |
449 | return 0; | 450 | return 0; |
450 | 451 | ||
@@ -664,7 +665,7 @@ static int tegra_ehci_probe(struct platform_device *pdev) | |||
664 | if (!pdev->dev.dma_mask) | 665 | if (!pdev->dev.dma_mask) |
665 | pdev->dev.dma_mask = &tegra_ehci_dma_mask; | 666 | pdev->dev.dma_mask = &tegra_ehci_dma_mask; |
666 | 667 | ||
667 | setup_vbus_gpio(pdev); | 668 | setup_vbus_gpio(pdev, pdata); |
668 | 669 | ||
669 | tegra = kzalloc(sizeof(struct tegra_ehci_hcd), GFP_KERNEL); | 670 | tegra = kzalloc(sizeof(struct tegra_ehci_hcd), GFP_KERNEL); |
670 | if (!tegra) | 671 | if (!tegra) |