aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/mach-nomadik/board-nhk8815.c3
-rw-r--r--arch/arm/mach-nomadik/cpu-8815.c2
-rw-r--r--arch/arm/mach-nomadik/i2c-8815nhk.c3
-rw-r--r--arch/arm/mach-ux500/board-mop500-audio.c3
-rw-r--r--arch/arm/mach-ux500/board-mop500-pins.c3
-rw-r--r--arch/arm/mach-ux500/board-mop500.c2
-rw-r--r--arch/arm/mach-ux500/cpu-db8500.c6
-rw-r--r--arch/arm/mach-ux500/devices-common.c3
-rw-r--r--arch/arm/mach-ux500/devices-common.h8
-rw-r--r--arch/arm/plat-nomadik/include/plat/gpio-nomadik.h102
-rw-r--r--drivers/pinctrl/pinctrl-nomadik-db8500.c104
-rw-r--r--drivers/pinctrl/pinctrl-nomadik-db8540.c1
-rw-r--r--drivers/pinctrl/pinctrl-nomadik.c115
-rw-r--r--drivers/pinctrl/pinctrl-nomadik.h2
-rw-r--r--include/linux/platform_data/pinctrl-nomadik.h (renamed from arch/arm/plat-nomadik/include/plat/pincfg.h)111
15 files changed, 303 insertions, 165 deletions
diff --git a/arch/arm/mach-nomadik/board-nhk8815.c b/arch/arm/mach-nomadik/board-nhk8815.c
index bfa1eab91f41..22ef8a1abe08 100644
--- a/arch/arm/mach-nomadik/board-nhk8815.c
+++ b/arch/arm/mach-nomadik/board-nhk8815.c
@@ -24,6 +24,7 @@
24#include <linux/i2c.h> 24#include <linux/i2c.h>
25#include <linux/io.h> 25#include <linux/io.h>
26#include <linux/pinctrl/machine.h> 26#include <linux/pinctrl/machine.h>
27#include <linux/platform_data/pinctrl-nomadik.h>
27#include <asm/hardware/vic.h> 28#include <asm/hardware/vic.h>
28#include <asm/sizes.h> 29#include <asm/sizes.h>
29#include <asm/mach-types.h> 30#include <asm/mach-types.h>
@@ -32,9 +33,7 @@
32#include <asm/mach/flash.h> 33#include <asm/mach/flash.h>
33#include <asm/mach/time.h> 34#include <asm/mach/time.h>
34 35
35#include <plat/gpio-nomadik.h>
36#include <plat/mtu.h> 36#include <plat/mtu.h>
37#include <plat/pincfg.h>
38 37
39#include <linux/platform_data/mtd-nomadik-nand.h> 38#include <linux/platform_data/mtd-nomadik-nand.h>
40#include <mach/fsmc.h> 39#include <mach/fsmc.h>
diff --git a/arch/arm/mach-nomadik/cpu-8815.c b/arch/arm/mach-nomadik/cpu-8815.c
index b617eaed0ce5..1273931303fb 100644
--- a/arch/arm/mach-nomadik/cpu-8815.c
+++ b/arch/arm/mach-nomadik/cpu-8815.c
@@ -26,8 +26,8 @@
26#include <linux/irq.h> 26#include <linux/irq.h>
27#include <linux/dma-mapping.h> 27#include <linux/dma-mapping.h>
28#include <linux/platform_data/clk-nomadik.h> 28#include <linux/platform_data/clk-nomadik.h>
29#include <linux/platform_data/pinctrl-nomadik.h>
29 30
30#include <plat/gpio-nomadik.h>
31#include <mach/hardware.h> 31#include <mach/hardware.h>
32#include <mach/irqs.h> 32#include <mach/irqs.h>
33#include <asm/mach/map.h> 33#include <asm/mach/map.h>
diff --git a/arch/arm/mach-nomadik/i2c-8815nhk.c b/arch/arm/mach-nomadik/i2c-8815nhk.c
index 6d14454d4609..0c2f6628299a 100644
--- a/arch/arm/mach-nomadik/i2c-8815nhk.c
+++ b/arch/arm/mach-nomadik/i2c-8815nhk.c
@@ -4,8 +4,7 @@
4#include <linux/i2c-algo-bit.h> 4#include <linux/i2c-algo-bit.h>
5#include <linux/i2c-gpio.h> 5#include <linux/i2c-gpio.h>
6#include <linux/platform_device.h> 6#include <linux/platform_device.h>
7#include <plat/gpio-nomadik.h> 7#include <linux/platform_data/pinctrl-nomadik.h>
8#include <plat/pincfg.h>
9 8
10/* 9/*
11 * There are two busses in the 8815NHK. 10 * There are two busses in the 8815NHK.
diff --git a/arch/arm/mach-ux500/board-mop500-audio.c b/arch/arm/mach-ux500/board-mop500-audio.c
index 070629a95625..33631c9f1218 100644
--- a/arch/arm/mach-ux500/board-mop500-audio.c
+++ b/arch/arm/mach-ux500/board-mop500-audio.c
@@ -7,9 +7,8 @@
7#include <linux/platform_device.h> 7#include <linux/platform_device.h>
8#include <linux/init.h> 8#include <linux/init.h>
9#include <linux/gpio.h> 9#include <linux/gpio.h>
10#include <linux/platform_data/pinctrl-nomadik.h>
10 11
11#include <plat/gpio-nomadik.h>
12#include <plat/pincfg.h>
13#include <plat/ste_dma40.h> 12#include <plat/ste_dma40.h>
14 13
15#include <mach/devices.h> 14#include <mach/devices.h>
diff --git a/arch/arm/mach-ux500/board-mop500-pins.c b/arch/arm/mach-ux500/board-mop500-pins.c
index a267c6d30e37..c34d4efd0d5c 100644
--- a/arch/arm/mach-ux500/board-mop500-pins.c
+++ b/arch/arm/mach-ux500/board-mop500-pins.c
@@ -9,10 +9,9 @@
9#include <linux/bug.h> 9#include <linux/bug.h>
10#include <linux/string.h> 10#include <linux/string.h>
11#include <linux/pinctrl/machine.h> 11#include <linux/pinctrl/machine.h>
12#include <linux/platform_data/pinctrl-nomadik.h>
12 13
13#include <asm/mach-types.h> 14#include <asm/mach-types.h>
14#include <plat/pincfg.h>
15#include <plat/gpio-nomadik.h>
16 15
17#include <mach/hardware.h> 16#include <mach/hardware.h>
18 17
diff --git a/arch/arm/mach-ux500/board-mop500.c b/arch/arm/mach-ux500/board-mop500.c
index 416d436111f2..0a3dd601a400 100644
--- a/arch/arm/mach-ux500/board-mop500.c
+++ b/arch/arm/mach-ux500/board-mop500.c
@@ -37,13 +37,13 @@
37#include <linux/of_platform.h> 37#include <linux/of_platform.h>
38#include <linux/leds.h> 38#include <linux/leds.h>
39#include <linux/pinctrl/consumer.h> 39#include <linux/pinctrl/consumer.h>
40#include <linux/platform_data/pinctrl-nomadik.h>
40 41
41#include <asm/mach-types.h> 42#include <asm/mach-types.h>
42#include <asm/mach/arch.h> 43#include <asm/mach/arch.h>
43#include <asm/hardware/gic.h> 44#include <asm/hardware/gic.h>
44 45
45#include <plat/ste_dma40.h> 46#include <plat/ste_dma40.h>
46#include <plat/gpio-nomadik.h>
47 47
48#include <mach/hardware.h> 48#include <mach/hardware.h>
49#include <mach/setup.h> 49#include <mach/setup.h>
diff --git a/arch/arm/mach-ux500/cpu-db8500.c b/arch/arm/mach-ux500/cpu-db8500.c
index bcdfe6b1d453..113d9c47a842 100644
--- a/arch/arm/mach-ux500/cpu-db8500.c
+++ b/arch/arm/mach-ux500/cpu-db8500.c
@@ -17,14 +17,14 @@
17#include <linux/platform_device.h> 17#include <linux/platform_device.h>
18#include <linux/io.h> 18#include <linux/io.h>
19#include <linux/mfd/abx500/ab8500.h> 19#include <linux/mfd/abx500/ab8500.h>
20#include <linux/platform_data/usb-musb-ux500.h>
21#include <linux/platform_data/pinctrl-nomadik.h>
20 22
21#include <asm/pmu.h> 23#include <asm/pmu.h>
22#include <asm/mach/map.h> 24#include <asm/mach/map.h>
23#include <plat/gpio-nomadik.h>
24#include <mach/hardware.h> 25#include <mach/hardware.h>
25#include <mach/setup.h> 26#include <mach/setup.h>
26#include <mach/devices.h> 27#include <mach/devices.h>
27#include <linux/platform_data/usb-musb-ux500.h>
28#include <mach/db8500-regs.h> 28#include <mach/db8500-regs.h>
29 29
30#include "devices-db8500.h" 30#include "devices-db8500.h"
@@ -158,7 +158,7 @@ static void __init db8500_add_gpios(struct device *parent)
158 158
159 dbx500_add_gpios(parent, ARRAY_AND_SIZE(db8500_gpio_base), 159 dbx500_add_gpios(parent, ARRAY_AND_SIZE(db8500_gpio_base),
160 IRQ_DB8500_GPIO0, &pdata); 160 IRQ_DB8500_GPIO0, &pdata);
161 dbx500_add_pinctrl(parent, "pinctrl-db8500"); 161 dbx500_add_pinctrl(parent, "pinctrl-db8500", U8500_PRCMU_BASE);
162} 162}
163 163
164static int usb_db8500_rx_dma_cfg[] = { 164static int usb_db8500_rx_dma_cfg[] = {
diff --git a/arch/arm/mach-ux500/devices-common.c b/arch/arm/mach-ux500/devices-common.c
index dfdd4a54668d..692a77a1c153 100644
--- a/arch/arm/mach-ux500/devices-common.c
+++ b/arch/arm/mach-ux500/devices-common.c
@@ -11,8 +11,7 @@
11#include <linux/irq.h> 11#include <linux/irq.h>
12#include <linux/slab.h> 12#include <linux/slab.h>
13#include <linux/platform_device.h> 13#include <linux/platform_device.h>
14 14#include <linux/platform_data/pinctrl-nomadik.h>
15#include <plat/gpio-nomadik.h>
16 15
17#include <mach/hardware.h> 16#include <mach/hardware.h>
18 17
diff --git a/arch/arm/mach-ux500/devices-common.h b/arch/arm/mach-ux500/devices-common.h
index 7fbf0ba336e1..96fa4ac89e2e 100644
--- a/arch/arm/mach-ux500/devices-common.h
+++ b/arch/arm/mach-ux500/devices-common.h
@@ -129,12 +129,18 @@ void dbx500_add_gpios(struct device *parent, resource_size_t *base, int num,
129 int irq, struct nmk_gpio_platform_data *pdata); 129 int irq, struct nmk_gpio_platform_data *pdata);
130 130
131static inline void 131static inline void
132dbx500_add_pinctrl(struct device *parent, const char *name) 132dbx500_add_pinctrl(struct device *parent, const char *name,
133 resource_size_t base)
133{ 134{
135 struct resource res[] = {
136 DEFINE_RES_MEM(base, SZ_8K),
137 };
134 struct platform_device_info pdevinfo = { 138 struct platform_device_info pdevinfo = {
135 .parent = parent, 139 .parent = parent,
136 .name = name, 140 .name = name,
137 .id = -1, 141 .id = -1,
142 .res = res,
143 .num_res = ARRAY_SIZE(res),
138 }; 144 };
139 145
140 platform_device_register_full(&pdevinfo); 146 platform_device_register_full(&pdevinfo);
diff --git a/arch/arm/plat-nomadik/include/plat/gpio-nomadik.h b/arch/arm/plat-nomadik/include/plat/gpio-nomadik.h
deleted file mode 100644
index c08a54d9d889..000000000000
--- a/arch/arm/plat-nomadik/include/plat/gpio-nomadik.h
+++ /dev/null
@@ -1,102 +0,0 @@
1/*
2 * Structures and registers for GPIO access in the Nomadik SoC
3 *
4 * Copyright (C) 2008 STMicroelectronics
5 * Author: Prafulla WADASKAR <prafulla.wadaskar@st.com>
6 * Copyright (C) 2009 Alessandro Rubini <rubini@unipv.it>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12
13#ifndef __PLAT_NOMADIK_GPIO
14#define __PLAT_NOMADIK_GPIO
15
16/*
17 * "nmk_gpio" and "NMK_GPIO" stand for "Nomadik GPIO", leaving
18 * the "gpio" namespace for generic and cross-machine functions
19 */
20
21/* Register in the logic block */
22#define NMK_GPIO_DAT 0x00
23#define NMK_GPIO_DATS 0x04
24#define NMK_GPIO_DATC 0x08
25#define NMK_GPIO_PDIS 0x0c
26#define NMK_GPIO_DIR 0x10
27#define NMK_GPIO_DIRS 0x14
28#define NMK_GPIO_DIRC 0x18
29#define NMK_GPIO_SLPC 0x1c
30#define NMK_GPIO_AFSLA 0x20
31#define NMK_GPIO_AFSLB 0x24
32#define NMK_GPIO_LOWEMI 0x28
33
34#define NMK_GPIO_RIMSC 0x40
35#define NMK_GPIO_FIMSC 0x44
36#define NMK_GPIO_IS 0x48
37#define NMK_GPIO_IC 0x4c
38#define NMK_GPIO_RWIMSC 0x50
39#define NMK_GPIO_FWIMSC 0x54
40#define NMK_GPIO_WKS 0x58
41
42/* Alternate functions: function C is set in hw by setting both A and B */
43#define NMK_GPIO_ALT_GPIO 0
44#define NMK_GPIO_ALT_A 1
45#define NMK_GPIO_ALT_B 2
46#define NMK_GPIO_ALT_C (NMK_GPIO_ALT_A | NMK_GPIO_ALT_B)
47
48#define NMK_GPIO_ALT_CX_SHIFT 2
49#define NMK_GPIO_ALT_C1 ((1<<NMK_GPIO_ALT_CX_SHIFT) | NMK_GPIO_ALT_C)
50#define NMK_GPIO_ALT_C2 ((2<<NMK_GPIO_ALT_CX_SHIFT) | NMK_GPIO_ALT_C)
51#define NMK_GPIO_ALT_C3 ((3<<NMK_GPIO_ALT_CX_SHIFT) | NMK_GPIO_ALT_C)
52#define NMK_GPIO_ALT_C4 ((4<<NMK_GPIO_ALT_CX_SHIFT) | NMK_GPIO_ALT_C)
53
54/* Pull up/down values */
55enum nmk_gpio_pull {
56 NMK_GPIO_PULL_NONE,
57 NMK_GPIO_PULL_UP,
58 NMK_GPIO_PULL_DOWN,
59};
60
61/* Sleep mode */
62enum nmk_gpio_slpm {
63 NMK_GPIO_SLPM_INPUT,
64 NMK_GPIO_SLPM_WAKEUP_ENABLE = NMK_GPIO_SLPM_INPUT,
65 NMK_GPIO_SLPM_NOCHANGE,
66 NMK_GPIO_SLPM_WAKEUP_DISABLE = NMK_GPIO_SLPM_NOCHANGE,
67};
68
69extern int nmk_gpio_set_slpm(int gpio, enum nmk_gpio_slpm mode);
70extern int nmk_gpio_set_pull(int gpio, enum nmk_gpio_pull pull);
71#ifdef CONFIG_PINCTRL_NOMADIK
72extern int nmk_gpio_set_mode(int gpio, int gpio_mode);
73#else
74static inline int nmk_gpio_set_mode(int gpio, int gpio_mode)
75{
76 return -ENODEV;
77}
78#endif
79extern int nmk_gpio_get_mode(int gpio);
80
81extern void nmk_gpio_wakeups_suspend(void);
82extern void nmk_gpio_wakeups_resume(void);
83
84extern void nmk_gpio_clocks_enable(void);
85extern void nmk_gpio_clocks_disable(void);
86
87extern void nmk_gpio_read_pull(int gpio_bank, u32 *pull_up);
88
89/*
90 * Platform data to register a block: only the initial gpio/irq number.
91 */
92struct nmk_gpio_platform_data {
93 char *name;
94 int first_gpio;
95 int first_irq;
96 int num_gpio;
97 u32 (*get_secondary_status)(unsigned int bank);
98 void (*set_ioforce)(bool enable);
99 bool supports_sleepmode;
100};
101
102#endif /* __PLAT_NOMADIK_GPIO */
diff --git a/drivers/pinctrl/pinctrl-nomadik-db8500.c b/drivers/pinctrl/pinctrl-nomadik-db8500.c
index debaa75b0552..6de52e7c57f0 100644
--- a/drivers/pinctrl/pinctrl-nomadik-db8500.c
+++ b/drivers/pinctrl/pinctrl-nomadik-db8500.c
@@ -600,14 +600,66 @@ static const unsigned usbsim_c_2_pins[] = { DB8500_PIN_AF8 };
600static const unsigned i2c3_c_2_pins[] = { DB8500_PIN_AG7, DB8500_PIN_AF7 }; 600static const unsigned i2c3_c_2_pins[] = { DB8500_PIN_AG7, DB8500_PIN_AF7 };
601 601
602/* Other C1 column */ 602/* Other C1 column */
603static const unsigned u2rx_oc1_1_pins[] = { DB8500_PIN_AB2 };
604static const unsigned stmape_oc1_1_pins[] = { DB8500_PIN_AA4, DB8500_PIN_Y4,
605 DB8500_PIN_Y2, DB8500_PIN_AA2, DB8500_PIN_AA1 };
606static const unsigned remap0_oc1_1_pins[] = { DB8500_PIN_E1 };
607static const unsigned remap1_oc1_1_pins[] = { DB8500_PIN_E2 };
608static const unsigned ptma9_oc1_1_pins[] = { DB8500_PIN_G5, DB8500_PIN_G4,
609 DB8500_PIN_H4, DB8500_PIN_H3, DB8500_PIN_J3, DB8500_PIN_H2,
610 DB8500_PIN_J2, DB8500_PIN_H1 };
603static const unsigned kp_oc1_1_pins[] = { DB8500_PIN_C6, DB8500_PIN_B3, 611static const unsigned kp_oc1_1_pins[] = { DB8500_PIN_C6, DB8500_PIN_B3,
604 DB8500_PIN_C4, DB8500_PIN_E6, DB8500_PIN_A3, DB8500_PIN_B6, 612 DB8500_PIN_C4, DB8500_PIN_E6, DB8500_PIN_A3, DB8500_PIN_B6,
605 DB8500_PIN_D6, DB8500_PIN_B7 }; 613 DB8500_PIN_D6, DB8500_PIN_B7 };
614static const unsigned rf_oc1_1_pins[] = { DB8500_PIN_D8, DB8500_PIN_D9 };
615static const unsigned hxclk_oc1_1_pins[] = { DB8500_PIN_D16 };
616static const unsigned uartmodrx_oc1_1_pins[] = { DB8500_PIN_B17 };
617static const unsigned uartmodtx_oc1_1_pins[] = { DB8500_PIN_C16 };
618static const unsigned stmmod_oc1_1_pins[] = { DB8500_PIN_C19, DB8500_PIN_C17,
619 DB8500_PIN_A18, DB8500_PIN_C18, DB8500_PIN_B19 };
620static const unsigned hxgpio_oc1_1_pins[] = { DB8500_PIN_D21, DB8500_PIN_D20,
621 DB8500_PIN_C20, DB8500_PIN_B21, DB8500_PIN_C21, DB8500_PIN_A22,
622 DB8500_PIN_B24, DB8500_PIN_C22 };
623static const unsigned rf_oc1_2_pins[] = { DB8500_PIN_C23, DB8500_PIN_D23 };
606static const unsigned spi2_oc1_1_pins[] = { DB8500_PIN_AH13, DB8500_PIN_AG12, 624static const unsigned spi2_oc1_1_pins[] = { DB8500_PIN_AH13, DB8500_PIN_AG12,
607 DB8500_PIN_AH12, DB8500_PIN_AH11 }; 625 DB8500_PIN_AH12, DB8500_PIN_AH11 };
608static const unsigned spi2_oc1_2_pins[] = { DB8500_PIN_AH13, DB8500_PIN_AH12, 626static const unsigned spi2_oc1_2_pins[] = { DB8500_PIN_AH13, DB8500_PIN_AH12,
609 DB8500_PIN_AH11 }; 627 DB8500_PIN_AH11 };
610 628
629/* Other C2 column */
630static const unsigned sbag_oc2_1_pins[] = { DB8500_PIN_AA4, DB8500_PIN_AB2,
631 DB8500_PIN_Y4, DB8500_PIN_Y2, DB8500_PIN_AA2, DB8500_PIN_AA1 };
632static const unsigned etmr4_oc2_1_pins[] = { DB8500_PIN_G5, DB8500_PIN_G4,
633 DB8500_PIN_H4, DB8500_PIN_H3, DB8500_PIN_J3, DB8500_PIN_H2,
634 DB8500_PIN_J2, DB8500_PIN_H1 };
635static const unsigned ptma9_oc2_1_pins[] = { DB8500_PIN_D17, DB8500_PIN_D16,
636 DB8500_PIN_B17, DB8500_PIN_C16, DB8500_PIN_C19, DB8500_PIN_C17,
637 DB8500_PIN_A18, DB8500_PIN_C18, DB8500_PIN_B19, DB8500_PIN_B20,
638 DB8500_PIN_D21, DB8500_PIN_D20, DB8500_PIN_C20, DB8500_PIN_B21,
639 DB8500_PIN_C21, DB8500_PIN_A22, DB8500_PIN_B24, DB8500_PIN_C22 };
640
641/* Other C3 column */
642static const unsigned stmmod_oc3_1_pins[] = { DB8500_PIN_AB2, DB8500_PIN_W2,
643 DB8500_PIN_W3, DB8500_PIN_V3, DB8500_PIN_V2 };
644static const unsigned stmmod_oc3_2_pins[] = { DB8500_PIN_G5, DB8500_PIN_G4,
645 DB8500_PIN_H4, DB8500_PIN_H3, DB8500_PIN_J3 };
646static const unsigned uartmodrx_oc3_1_pins[] = { DB8500_PIN_H2 };
647static const unsigned uartmodtx_oc3_1_pins[] = { DB8500_PIN_J2 };
648static const unsigned etmr4_oc3_1_pins[] = { DB8500_PIN_D17, DB8500_PIN_D16,
649 DB8500_PIN_B17, DB8500_PIN_C16, DB8500_PIN_C19, DB8500_PIN_C17,
650 DB8500_PIN_A18, DB8500_PIN_C18, DB8500_PIN_B19, DB8500_PIN_B20,
651 DB8500_PIN_D21, DB8500_PIN_D20, DB8500_PIN_C20, DB8500_PIN_B21,
652 DB8500_PIN_C21, DB8500_PIN_A22, DB8500_PIN_B24, DB8500_PIN_C22 };
653
654/* Other C4 column */
655static const unsigned sbag_oc4_1_pins[] = { DB8500_PIN_G5, DB8500_PIN_G4,
656 DB8500_PIN_H4, DB8500_PIN_H3, DB8500_PIN_J3, DB8500_PIN_H1 };
657static const unsigned hwobs_oc4_1_pins[] = { DB8500_PIN_D17, DB8500_PIN_D16,
658 DB8500_PIN_B17, DB8500_PIN_C16, DB8500_PIN_C19, DB8500_PIN_C17,
659 DB8500_PIN_A18, DB8500_PIN_C18, DB8500_PIN_B19, DB8500_PIN_B20,
660 DB8500_PIN_D21, DB8500_PIN_D20, DB8500_PIN_C20, DB8500_PIN_B21,
661 DB8500_PIN_C21, DB8500_PIN_A22, DB8500_PIN_B24, DB8500_PIN_C22 };
662
611#define DB8500_PIN_GROUP(a,b) { .name = #a, .pins = a##_pins, \ 663#define DB8500_PIN_GROUP(a,b) { .name = #a, .pins = a##_pins, \
612 .npins = ARRAY_SIZE(a##_pins), .altsetting = b } 664 .npins = ARRAY_SIZE(a##_pins), .altsetting = b }
613 665
@@ -639,6 +691,7 @@ static const struct nmk_pingroup nmk_db8500_groups[] = {
639 DB8500_PIN_GROUP(i2c0_a_1, NMK_GPIO_ALT_A), 691 DB8500_PIN_GROUP(i2c0_a_1, NMK_GPIO_ALT_A),
640 DB8500_PIN_GROUP(ipgpio0_a_1, NMK_GPIO_ALT_A), 692 DB8500_PIN_GROUP(ipgpio0_a_1, NMK_GPIO_ALT_A),
641 DB8500_PIN_GROUP(ipgpio1_a_1, NMK_GPIO_ALT_A), 693 DB8500_PIN_GROUP(ipgpio1_a_1, NMK_GPIO_ALT_A),
694 DB8500_PIN_GROUP(kp_a_2, NMK_GPIO_ALT_A),
642 DB8500_PIN_GROUP(msp2sck_a_1, NMK_GPIO_ALT_A), 695 DB8500_PIN_GROUP(msp2sck_a_1, NMK_GPIO_ALT_A),
643 DB8500_PIN_GROUP(msp2_a_1, NMK_GPIO_ALT_A), 696 DB8500_PIN_GROUP(msp2_a_1, NMK_GPIO_ALT_A),
644 DB8500_PIN_GROUP(mc4_a_1, NMK_GPIO_ALT_A), 697 DB8500_PIN_GROUP(mc4_a_1, NMK_GPIO_ALT_A),
@@ -726,9 +779,34 @@ static const struct nmk_pingroup nmk_db8500_groups[] = {
726 DB8500_PIN_GROUP(usbsim_c_2, NMK_GPIO_ALT_C), 779 DB8500_PIN_GROUP(usbsim_c_2, NMK_GPIO_ALT_C),
727 DB8500_PIN_GROUP(i2c3_c_2, NMK_GPIO_ALT_C), 780 DB8500_PIN_GROUP(i2c3_c_2, NMK_GPIO_ALT_C),
728 /* Other alt C1 column */ 781 /* Other alt C1 column */
782 DB8500_PIN_GROUP(u2rx_oc1_1, NMK_GPIO_ALT_C1),
783 DB8500_PIN_GROUP(stmape_oc1_1, NMK_GPIO_ALT_C1),
784 DB8500_PIN_GROUP(remap0_oc1_1, NMK_GPIO_ALT_C1),
785 DB8500_PIN_GROUP(remap1_oc1_1, NMK_GPIO_ALT_C1),
786 DB8500_PIN_GROUP(ptma9_oc1_1, NMK_GPIO_ALT_C1),
729 DB8500_PIN_GROUP(kp_oc1_1, NMK_GPIO_ALT_C1), 787 DB8500_PIN_GROUP(kp_oc1_1, NMK_GPIO_ALT_C1),
788 DB8500_PIN_GROUP(rf_oc1_1, NMK_GPIO_ALT_C1),
789 DB8500_PIN_GROUP(hxclk_oc1_1, NMK_GPIO_ALT_C1),
790 DB8500_PIN_GROUP(uartmodrx_oc1_1, NMK_GPIO_ALT_C1),
791 DB8500_PIN_GROUP(uartmodtx_oc1_1, NMK_GPIO_ALT_C1),
792 DB8500_PIN_GROUP(stmmod_oc1_1, NMK_GPIO_ALT_C1),
793 DB8500_PIN_GROUP(hxgpio_oc1_1, NMK_GPIO_ALT_C1),
794 DB8500_PIN_GROUP(rf_oc1_2, NMK_GPIO_ALT_C1),
730 DB8500_PIN_GROUP(spi2_oc1_1, NMK_GPIO_ALT_C1), 795 DB8500_PIN_GROUP(spi2_oc1_1, NMK_GPIO_ALT_C1),
731 DB8500_PIN_GROUP(spi2_oc1_2, NMK_GPIO_ALT_C1), 796 DB8500_PIN_GROUP(spi2_oc1_2, NMK_GPIO_ALT_C1),
797 /* Other alt C2 column */
798 DB8500_PIN_GROUP(sbag_oc2_1, NMK_GPIO_ALT_C2),
799 DB8500_PIN_GROUP(etmr4_oc2_1, NMK_GPIO_ALT_C2),
800 DB8500_PIN_GROUP(ptma9_oc2_1, NMK_GPIO_ALT_C2),
801 /* Other alt C3 column */
802 DB8500_PIN_GROUP(stmmod_oc3_1, NMK_GPIO_ALT_C3),
803 DB8500_PIN_GROUP(stmmod_oc3_2, NMK_GPIO_ALT_C3),
804 DB8500_PIN_GROUP(uartmodrx_oc3_1, NMK_GPIO_ALT_C3),
805 DB8500_PIN_GROUP(uartmodtx_oc3_1, NMK_GPIO_ALT_C3),
806 DB8500_PIN_GROUP(etmr4_oc3_1, NMK_GPIO_ALT_C3),
807 /* Other alt C4 column */
808 DB8500_PIN_GROUP(sbag_oc4_1, NMK_GPIO_ALT_C4),
809 DB8500_PIN_GROUP(hwobs_oc4_1, NMK_GPIO_ALT_C4),
732}; 810};
733 811
734/* We use this macro to define the groups applicable to a function */ 812/* We use this macro to define the groups applicable to a function */
@@ -742,7 +820,7 @@ DB8500_FUNC_GROUPS(u1, "u1rxtx_a_1", "u1ctsrts_a_1");
742 * only available on two pins in alternative function C 820 * only available on two pins in alternative function C
743 */ 821 */
744DB8500_FUNC_GROUPS(u2, "u2rxtx_b_1", "u2rxtx_c_1", "u2ctsrts_c_1", 822DB8500_FUNC_GROUPS(u2, "u2rxtx_b_1", "u2rxtx_c_1", "u2ctsrts_c_1",
745 "u2rxtx_c_2", "u2rxtx_c_3"); 823 "u2rxtx_c_2", "u2rxtx_c_3", "u2rx_oc1_1");
746DB8500_FUNC_GROUPS(ipi2c, "ipi2c_a_1", "ipi2c_a_2"); 824DB8500_FUNC_GROUPS(ipi2c, "ipi2c_a_1", "ipi2c_a_2");
747/* 825/*
748 * MSP0 can only be on a certain set of pins, but the TX/RX pins can be 826 * MSP0 can only be on a certain set of pins, but the TX/RX pins can be
@@ -757,7 +835,7 @@ DB8500_FUNC_GROUPS(msp1, "msp1txrx_a_1", "msp1_a_1", "msp1txrx_b_1");
757DB8500_FUNC_GROUPS(lcdb, "lcdb_a_1"); 835DB8500_FUNC_GROUPS(lcdb, "lcdb_a_1");
758DB8500_FUNC_GROUPS(lcd, "lcdvsi0_a_1", "lcdvsi1_a_1", "lcd_d0_d7_a_1", 836DB8500_FUNC_GROUPS(lcd, "lcdvsi0_a_1", "lcdvsi1_a_1", "lcd_d0_d7_a_1",
759 "lcd_d8_d11_a_1", "lcd_d12_d23_a_1", "lcd_b_1"); 837 "lcd_d8_d11_a_1", "lcd_d12_d23_a_1", "lcd_b_1");
760DB8500_FUNC_GROUPS(kp, "kp_a_1", "kp_b_1", "kp_b_2", "kp_c_1", "kp_oc1_1"); 838DB8500_FUNC_GROUPS(kp, "kp_a_1", "kp_a_2", "kp_b_1", "kp_b_2", "kp_c_1", "kp_oc1_1");
761DB8500_FUNC_GROUPS(mc2, "mc2_a_1", "mc2rstn_c_1"); 839DB8500_FUNC_GROUPS(mc2, "mc2_a_1", "mc2rstn_c_1");
762DB8500_FUNC_GROUPS(ssp1, "ssp1_a_1"); 840DB8500_FUNC_GROUPS(ssp1, "ssp1_a_1");
763DB8500_FUNC_GROUPS(ssp0, "ssp0_a_1"); 841DB8500_FUNC_GROUPS(ssp0, "ssp0_a_1");
@@ -784,8 +862,10 @@ DB8500_FUNC_GROUPS(i2c2, "i2c2_b_1", "i2c2_b_2");
784 * so select one of each. 862 * so select one of each.
785 */ 863 */
786DB8500_FUNC_GROUPS(uartmod, "uartmodtx_b_1", "uartmodrx_b_1", "uartmodrx_b_2", 864DB8500_FUNC_GROUPS(uartmod, "uartmodtx_b_1", "uartmodrx_b_1", "uartmodrx_b_2",
787 "uartmodrx_c_1", "uartmod_tx_c_1"); 865 "uartmodrx_c_1", "uartmod_tx_c_1", "uartmodrx_oc1_1",
788DB8500_FUNC_GROUPS(stmmod, "stmmod_b_1", "stmmod_c_1"); 866 "uartmodtx_oc1_1", "uartmodrx_oc3_1", "uartmodtx_oc3_1");
867DB8500_FUNC_GROUPS(stmmod, "stmmod_b_1", "stmmod_c_1", "stmmod_oc1_1",
868 "stmmod_oc3_1", "stmmod_oc3_2");
789DB8500_FUNC_GROUPS(spi3, "spi3_b_1"); 869DB8500_FUNC_GROUPS(spi3, "spi3_b_1");
790/* Select between CS0 on alt B or PS1 on alt C */ 870/* Select between CS0 on alt B or PS1 on alt C */
791DB8500_FUNC_GROUPS(sm, "sm_b_1", "smcs0_b_1", "smcs1_b_1", "smcleale_c_1", 871DB8500_FUNC_GROUPS(sm, "sm_b_1", "smcs0_b_1", "smcs1_b_1", "smcleale_c_1",
@@ -799,13 +879,19 @@ DB8500_FUNC_GROUPS(ipjtag, "ipjtag_c_1");
799DB8500_FUNC_GROUPS(slim0, "slim0_c_1"); 879DB8500_FUNC_GROUPS(slim0, "slim0_c_1");
800DB8500_FUNC_GROUPS(ms, "ms_c_1"); 880DB8500_FUNC_GROUPS(ms, "ms_c_1");
801DB8500_FUNC_GROUPS(iptrigout, "iptrigout_c_1"); 881DB8500_FUNC_GROUPS(iptrigout, "iptrigout_c_1");
802DB8500_FUNC_GROUPS(stmape, "stmape_c_1", "stmape_c_2"); 882DB8500_FUNC_GROUPS(stmape, "stmape_c_1", "stmape_c_2", "stmape_oc1_1");
803DB8500_FUNC_GROUPS(mc5, "mc5_c_1"); 883DB8500_FUNC_GROUPS(mc5, "mc5_c_1");
804DB8500_FUNC_GROUPS(usbsim, "usbsim_c_1", "usbsim_c_2"); 884DB8500_FUNC_GROUPS(usbsim, "usbsim_c_1", "usbsim_c_2");
805DB8500_FUNC_GROUPS(i2c3, "i2c3_c_1", "i2c3_c_2"); 885DB8500_FUNC_GROUPS(i2c3, "i2c3_c_1", "i2c3_c_2");
806DB8500_FUNC_GROUPS(spi0, "spi0_c_1"); 886DB8500_FUNC_GROUPS(spi0, "spi0_c_1");
807DB8500_FUNC_GROUPS(spi2, "spi2_oc1_1", "spi2_oc1_2"); 887DB8500_FUNC_GROUPS(spi2, "spi2_oc1_1", "spi2_oc1_2");
808 888DB8500_FUNC_GROUPS(remap, "remap0_oc1_1", "remap1_oc1_1");
889DB8500_FUNC_GROUPS(sbag, "sbag_oc2_1", "sbag_oc4_1");
890DB8500_FUNC_GROUPS(ptm, "ptma9_oc1_1", "ptma9_oc2_1");
891DB8500_FUNC_GROUPS(rf, "rf_oc1_1", "rf_oc1_2");
892DB8500_FUNC_GROUPS(hx, "hxclk_oc1_1", "hxgpio_oc1_1");
893DB8500_FUNC_GROUPS(etm, "etmr4_oc2_1", "etmr4_oc3_1");
894DB8500_FUNC_GROUPS(hwobs, "hwobs_oc4_1");
809#define FUNCTION(fname) \ 895#define FUNCTION(fname) \
810 { \ 896 { \
811 .name = #fname, \ 897 .name = #fname, \
@@ -858,6 +944,12 @@ static const struct nmk_function nmk_db8500_functions[] = {
858 FUNCTION(i2c3), 944 FUNCTION(i2c3),
859 FUNCTION(spi0), 945 FUNCTION(spi0),
860 FUNCTION(spi2), 946 FUNCTION(spi2),
947 FUNCTION(remap),
948 FUNCTION(ptm),
949 FUNCTION(rf),
950 FUNCTION(hx),
951 FUNCTION(etm),
952 FUNCTION(hwobs),
861}; 953};
862 954
863static const struct prcm_gpiocr_altcx_pin_desc db8500_altcx_pins[] = { 955static const struct prcm_gpiocr_altcx_pin_desc db8500_altcx_pins[] = {
diff --git a/drivers/pinctrl/pinctrl-nomadik-db8540.c b/drivers/pinctrl/pinctrl-nomadik-db8540.c
index 52fc30181f7e..bce0583738ef 100644
--- a/drivers/pinctrl/pinctrl-nomadik-db8540.c
+++ b/drivers/pinctrl/pinctrl-nomadik-db8540.c
@@ -822,6 +822,7 @@ static const struct nmk_pingroup nmk_db8540_groups[] = {
822 DB8540_PIN_GROUP(modaccuarttxrx_oc4_1, NMK_GPIO_ALT_C4), 822 DB8540_PIN_GROUP(modaccuarttxrx_oc4_1, NMK_GPIO_ALT_C4),
823 DB8540_PIN_GROUP(modaccuartrtscts_oc4_1, NMK_GPIO_ALT_C4), 823 DB8540_PIN_GROUP(modaccuartrtscts_oc4_1, NMK_GPIO_ALT_C4),
824 DB8540_PIN_GROUP(stmmod_oc4_1, NMK_GPIO_ALT_C4), 824 DB8540_PIN_GROUP(stmmod_oc4_1, NMK_GPIO_ALT_C4),
825 DB8540_PIN_GROUP(moduartstmmux_oc4_1, NMK_GPIO_ALT_C4),
825 826
826}; 827};
827 828
diff --git a/drivers/pinctrl/pinctrl-nomadik.c b/drivers/pinctrl/pinctrl-nomadik.c
index cf82d9ce4dee..6a95d0438b6a 100644
--- a/drivers/pinctrl/pinctrl-nomadik.c
+++ b/drivers/pinctrl/pinctrl-nomadik.c
@@ -30,26 +30,10 @@
30#include <linux/pinctrl/pinconf.h> 30#include <linux/pinctrl/pinconf.h>
31/* Since we request GPIOs from ourself */ 31/* Since we request GPIOs from ourself */
32#include <linux/pinctrl/consumer.h> 32#include <linux/pinctrl/consumer.h>
33/* 33#include <linux/platform_data/pinctrl-nomadik.h>
34 * For the U8500 archs, use the PRCMU register interface, for the older
35 * Nomadik, provide some stubs. The functions using these will only be
36 * called on the U8500 series.
37 */
38#ifdef CONFIG_ARCH_U8500
39#include <linux/mfd/dbx500-prcmu.h>
40#else
41static inline u32 prcmu_read(unsigned int reg) {
42 return 0;
43}
44static inline void prcmu_write(unsigned int reg, u32 value) {}
45static inline void prcmu_write_masked(unsigned int reg, u32 mask, u32 value) {}
46#endif
47 34
48#include <asm/mach/irq.h> 35#include <asm/mach/irq.h>
49 36
50#include <plat/pincfg.h>
51#include <plat/gpio-nomadik.h>
52
53#include "pinctrl-nomadik.h" 37#include "pinctrl-nomadik.h"
54 38
55/* 39/*
@@ -60,8 +44,6 @@ static inline void prcmu_write_masked(unsigned int reg, u32 mask, u32 value) {}
60 * Symbols in this file are called "nmk_gpio" for "nomadik gpio" 44 * Symbols in this file are called "nmk_gpio" for "nomadik gpio"
61 */ 45 */
62 46
63#define NMK_GPIO_PER_CHIP 32
64
65struct nmk_gpio_chip { 47struct nmk_gpio_chip {
66 struct gpio_chip chip; 48 struct gpio_chip chip;
67 struct irq_domain *domain; 49 struct irq_domain *domain;
@@ -86,10 +68,18 @@ struct nmk_gpio_chip {
86 u32 lowemi; 68 u32 lowemi;
87}; 69};
88 70
71/**
72 * struct nmk_pinctrl - state container for the Nomadik pin controller
73 * @dev: containing device pointer
74 * @pctl: corresponding pin controller device
75 * @soc: SoC data for this specific chip
76 * @prcm_base: PRCM register range virtual base
77 */
89struct nmk_pinctrl { 78struct nmk_pinctrl {
90 struct device *dev; 79 struct device *dev;
91 struct pinctrl_dev *pctl; 80 struct pinctrl_dev *pctl;
92 const struct nmk_pinctrl_soc_data *soc; 81 const struct nmk_pinctrl_soc_data *soc;
82 void __iomem *prcm_base;
93}; 83};
94 84
95static struct nmk_gpio_chip * 85static struct nmk_gpio_chip *
@@ -251,6 +241,15 @@ nmk_gpio_disable_lazy_irq(struct nmk_gpio_chip *nmk_chip, unsigned offset)
251 dev_dbg(nmk_chip->chip.dev, "%d: clearing interrupt mask\n", gpio); 241 dev_dbg(nmk_chip->chip.dev, "%d: clearing interrupt mask\n", gpio);
252} 242}
253 243
244static void nmk_write_masked(void __iomem *reg, u32 mask, u32 value)
245{
246 u32 val;
247
248 val = readl(reg);
249 val = ((val & ~mask) | (value & mask));
250 writel(val, reg);
251}
252
254static void nmk_prcm_altcx_set_mode(struct nmk_pinctrl *npct, 253static void nmk_prcm_altcx_set_mode(struct nmk_pinctrl *npct,
255 unsigned offset, unsigned alt_num) 254 unsigned offset, unsigned alt_num)
256{ 255{
@@ -289,8 +288,8 @@ static void nmk_prcm_altcx_set_mode(struct nmk_pinctrl *npct,
289 if (pin_desc->altcx[i].used == true) { 288 if (pin_desc->altcx[i].used == true) {
290 reg = gpiocr_regs[pin_desc->altcx[i].reg_index]; 289 reg = gpiocr_regs[pin_desc->altcx[i].reg_index];
291 bit = pin_desc->altcx[i].control_bit; 290 bit = pin_desc->altcx[i].control_bit;
292 if (prcmu_read(reg) & BIT(bit)) { 291 if (readl(npct->prcm_base + reg) & BIT(bit)) {
293 prcmu_write_masked(reg, BIT(bit), 0); 292 nmk_write_masked(npct->prcm_base + reg, BIT(bit), 0);
294 dev_dbg(npct->dev, 293 dev_dbg(npct->dev,
295 "PRCM GPIOCR: pin %i: alternate-C%i has been disabled\n", 294 "PRCM GPIOCR: pin %i: alternate-C%i has been disabled\n",
296 offset, i+1); 295 offset, i+1);
@@ -318,8 +317,8 @@ static void nmk_prcm_altcx_set_mode(struct nmk_pinctrl *npct,
318 if (pin_desc->altcx[i].used == true) { 317 if (pin_desc->altcx[i].used == true) {
319 reg = gpiocr_regs[pin_desc->altcx[i].reg_index]; 318 reg = gpiocr_regs[pin_desc->altcx[i].reg_index];
320 bit = pin_desc->altcx[i].control_bit; 319 bit = pin_desc->altcx[i].control_bit;
321 if (prcmu_read(reg) & BIT(bit)) { 320 if (readl(npct->prcm_base + reg) & BIT(bit)) {
322 prcmu_write_masked(reg, BIT(bit), 0); 321 nmk_write_masked(npct->prcm_base + reg, BIT(bit), 0);
323 dev_dbg(npct->dev, 322 dev_dbg(npct->dev,
324 "PRCM GPIOCR: pin %i: alternate-C%i has been disabled\n", 323 "PRCM GPIOCR: pin %i: alternate-C%i has been disabled\n",
325 offset, i+1); 324 offset, i+1);
@@ -331,7 +330,7 @@ static void nmk_prcm_altcx_set_mode(struct nmk_pinctrl *npct,
331 bit = pin_desc->altcx[alt_index].control_bit; 330 bit = pin_desc->altcx[alt_index].control_bit;
332 dev_dbg(npct->dev, "PRCM GPIOCR: pin %i: alternate-C%i has been selected\n", 331 dev_dbg(npct->dev, "PRCM GPIOCR: pin %i: alternate-C%i has been selected\n",
333 offset, alt_index+1); 332 offset, alt_index+1);
334 prcmu_write_masked(reg, BIT(bit), BIT(bit)); 333 nmk_write_masked(npct->prcm_base + reg, BIT(bit), BIT(bit));
335} 334}
336 335
337static void __nmk_config_pin(struct nmk_gpio_chip *nmk_chip, unsigned offset, 336static void __nmk_config_pin(struct nmk_gpio_chip *nmk_chip, unsigned offset,
@@ -536,7 +535,7 @@ static int __nmk_config_pins(pin_cfg_t *cfgs, int num, bool sleep)
536 * and its sleep mode based on the specified configuration. The @cfg is 535 * and its sleep mode based on the specified configuration. The @cfg is
537 * usually one of the SoC specific macros defined in mach/<soc>-pins.h. These 536 * usually one of the SoC specific macros defined in mach/<soc>-pins.h. These
538 * are constructed using, and can be further enhanced with, the macros in 537 * are constructed using, and can be further enhanced with, the macros in
539 * plat/pincfg.h. 538 * <linux/platform_data/pinctrl-nomadik.h>
540 * 539 *
541 * If a pin's mode is set to GPIO, it is configured as an input to avoid 540 * If a pin's mode is set to GPIO, it is configured as an input to avoid
542 * side-effects. The gpio can be manipulated later using standard GPIO API 541 * side-effects. The gpio can be manipulated later using standard GPIO API
@@ -675,6 +674,35 @@ int nmk_gpio_set_mode(int gpio, int gpio_mode)
675} 674}
676EXPORT_SYMBOL(nmk_gpio_set_mode); 675EXPORT_SYMBOL(nmk_gpio_set_mode);
677 676
677static int nmk_prcm_gpiocr_get_mode(struct pinctrl_dev *pctldev, int gpio)
678{
679 int i;
680 u16 reg;
681 u8 bit;
682 struct nmk_pinctrl *npct = pinctrl_dev_get_drvdata(pctldev);
683 const struct prcm_gpiocr_altcx_pin_desc *pin_desc;
684 const u16 *gpiocr_regs;
685
686 for (i = 0; i < npct->soc->npins_altcx; i++) {
687 if (npct->soc->altcx_pins[i].pin == gpio)
688 break;
689 }
690 if (i == npct->soc->npins_altcx)
691 return NMK_GPIO_ALT_C;
692
693 pin_desc = npct->soc->altcx_pins + i;
694 gpiocr_regs = npct->soc->prcm_gpiocr_registers;
695 for (i = 0; i < PRCM_IDX_GPIOCR_ALTC_MAX; i++) {
696 if (pin_desc->altcx[i].used == true) {
697 reg = gpiocr_regs[pin_desc->altcx[i].reg_index];
698 bit = pin_desc->altcx[i].control_bit;
699 if (readl(npct->prcm_base + reg) & BIT(bit))
700 return NMK_GPIO_ALT_C+i+1;
701 }
702 }
703 return NMK_GPIO_ALT_C;
704}
705
678int nmk_gpio_get_mode(int gpio) 706int nmk_gpio_get_mode(int gpio)
679{ 707{
680 struct nmk_gpio_chip *nmk_chip; 708 struct nmk_gpio_chip *nmk_chip;
@@ -1063,8 +1091,9 @@ static int nmk_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
1063 1091
1064#include <linux/seq_file.h> 1092#include <linux/seq_file.h>
1065 1093
1066static void nmk_gpio_dbg_show_one(struct seq_file *s, struct gpio_chip *chip, 1094static void nmk_gpio_dbg_show_one(struct seq_file *s,
1067 unsigned offset, unsigned gpio) 1095 struct pinctrl_dev *pctldev, struct gpio_chip *chip,
1096 unsigned offset, unsigned gpio)
1068{ 1097{
1069 const char *label = gpiochip_is_requested(chip, offset); 1098 const char *label = gpiochip_is_requested(chip, offset);
1070 struct nmk_gpio_chip *nmk_chip = 1099 struct nmk_gpio_chip *nmk_chip =
@@ -1078,12 +1107,18 @@ static void nmk_gpio_dbg_show_one(struct seq_file *s, struct gpio_chip *chip,
1078 [NMK_GPIO_ALT_A] = "altA", 1107 [NMK_GPIO_ALT_A] = "altA",
1079 [NMK_GPIO_ALT_B] = "altB", 1108 [NMK_GPIO_ALT_B] = "altB",
1080 [NMK_GPIO_ALT_C] = "altC", 1109 [NMK_GPIO_ALT_C] = "altC",
1110 [NMK_GPIO_ALT_C+1] = "altC1",
1111 [NMK_GPIO_ALT_C+2] = "altC2",
1112 [NMK_GPIO_ALT_C+3] = "altC3",
1113 [NMK_GPIO_ALT_C+4] = "altC4",
1081 }; 1114 };
1082 1115
1083 clk_enable(nmk_chip->clk); 1116 clk_enable(nmk_chip->clk);
1084 is_out = !!(readl(nmk_chip->addr + NMK_GPIO_DIR) & bit); 1117 is_out = !!(readl(nmk_chip->addr + NMK_GPIO_DIR) & bit);
1085 pull = !(readl(nmk_chip->addr + NMK_GPIO_PDIS) & bit); 1118 pull = !(readl(nmk_chip->addr + NMK_GPIO_PDIS) & bit);
1086 mode = nmk_gpio_get_mode(gpio); 1119 mode = nmk_gpio_get_mode(gpio);
1120 if ((mode == NMK_GPIO_ALT_C) && pctldev)
1121 mode = nmk_prcm_gpiocr_get_mode(pctldev, gpio);
1087 1122
1088 seq_printf(s, " gpio-%-3d (%-20.20s) %s %s %s %s", 1123 seq_printf(s, " gpio-%-3d (%-20.20s) %s %s %s %s",
1089 gpio, label ?: "(none)", 1124 gpio, label ?: "(none)",
@@ -1127,13 +1162,14 @@ static void nmk_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
1127 unsigned gpio = chip->base; 1162 unsigned gpio = chip->base;
1128 1163
1129 for (i = 0; i < chip->ngpio; i++, gpio++) { 1164 for (i = 0; i < chip->ngpio; i++, gpio++) {
1130 nmk_gpio_dbg_show_one(s, chip, i, gpio); 1165 nmk_gpio_dbg_show_one(s, NULL, chip, i, gpio);
1131 seq_printf(s, "\n"); 1166 seq_printf(s, "\n");
1132 } 1167 }
1133} 1168}
1134 1169
1135#else 1170#else
1136static inline void nmk_gpio_dbg_show_one(struct seq_file *s, 1171static inline void nmk_gpio_dbg_show_one(struct seq_file *s,
1172 struct pinctrl_dev *pctldev,
1137 struct gpio_chip *chip, 1173 struct gpio_chip *chip,
1138 unsigned offset, unsigned gpio) 1174 unsigned offset, unsigned gpio)
1139{ 1175{
@@ -1464,7 +1500,7 @@ static void nmk_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s,
1464 return; 1500 return;
1465 } 1501 }
1466 chip = range->gc; 1502 chip = range->gc;
1467 nmk_gpio_dbg_show_one(s, chip, offset - chip->base, offset); 1503 nmk_gpio_dbg_show_one(s, pctldev, chip, offset - chip->base, offset);
1468} 1504}
1469 1505
1470static struct pinctrl_ops nmk_pinctrl_ops = { 1506static struct pinctrl_ops nmk_pinctrl_ops = {
@@ -1818,6 +1854,7 @@ static int __devinit nmk_pinctrl_probe(struct platform_device *pdev)
1818 const struct platform_device_id *platid = platform_get_device_id(pdev); 1854 const struct platform_device_id *platid = platform_get_device_id(pdev);
1819 struct device_node *np = pdev->dev.of_node; 1855 struct device_node *np = pdev->dev.of_node;
1820 struct nmk_pinctrl *npct; 1856 struct nmk_pinctrl *npct;
1857 struct resource *res;
1821 unsigned int version = 0; 1858 unsigned int version = 0;
1822 int i; 1859 int i;
1823 1860
@@ -1839,22 +1876,37 @@ static int __devinit nmk_pinctrl_probe(struct platform_device *pdev)
1839 if (version == PINCTRL_NMK_DB8540) 1876 if (version == PINCTRL_NMK_DB8540)
1840 nmk_pinctrl_db8540_init(&npct->soc); 1877 nmk_pinctrl_db8540_init(&npct->soc);
1841 1878
1879 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1880 if (res) {
1881 npct->prcm_base = devm_ioremap(&pdev->dev, res->start,
1882 resource_size(res));
1883 if (!npct->prcm_base) {
1884 dev_err(&pdev->dev,
1885 "failed to ioremap PRCM registers\n");
1886 return -ENOMEM;
1887 }
1888 } else {
1889 dev_info(&pdev->dev,
1890 "No PRCM base, assume no ALT-Cx control is available\n");
1891 }
1892
1842 /* 1893 /*
1843 * We need all the GPIO drivers to probe FIRST, or we will not be able 1894 * We need all the GPIO drivers to probe FIRST, or we will not be able
1844 * to obtain references to the struct gpio_chip * for them, and we 1895 * to obtain references to the struct gpio_chip * for them, and we
1845 * need this to proceed. 1896 * need this to proceed.
1846 */ 1897 */
1847 for (i = 0; i < npct->soc->gpio_num_ranges; i++) { 1898 for (i = 0; i < npct->soc->gpio_num_ranges; i++) {
1848 if (!nmk_gpio_chips[i]) { 1899 if (!nmk_gpio_chips[npct->soc->gpio_ranges[i].id]) {
1849 dev_warn(&pdev->dev, "GPIO chip %d not registered yet\n", i); 1900 dev_warn(&pdev->dev, "GPIO chip %d not registered yet\n", i);
1850 return -EPROBE_DEFER; 1901 return -EPROBE_DEFER;
1851 } 1902 }
1852 npct->soc->gpio_ranges[i].gc = &nmk_gpio_chips[i]->chip; 1903 npct->soc->gpio_ranges[i].gc = &nmk_gpio_chips[npct->soc->gpio_ranges[i].id]->chip;
1853 } 1904 }
1854 1905
1855 nmk_pinctrl_desc.pins = npct->soc->pins; 1906 nmk_pinctrl_desc.pins = npct->soc->pins;
1856 nmk_pinctrl_desc.npins = npct->soc->npins; 1907 nmk_pinctrl_desc.npins = npct->soc->npins;
1857 npct->dev = &pdev->dev; 1908 npct->dev = &pdev->dev;
1909
1858 npct->pctl = pinctrl_register(&nmk_pinctrl_desc, &pdev->dev, npct); 1910 npct->pctl = pinctrl_register(&nmk_pinctrl_desc, &pdev->dev, npct);
1859 if (!npct->pctl) { 1911 if (!npct->pctl) {
1860 dev_err(&pdev->dev, "could not register Nomadik pinctrl driver\n"); 1912 dev_err(&pdev->dev, "could not register Nomadik pinctrl driver\n");
@@ -1889,6 +1941,7 @@ static const struct platform_device_id nmk_pinctrl_id[] = {
1889 { "pinctrl-stn8815", PINCTRL_NMK_STN8815 }, 1941 { "pinctrl-stn8815", PINCTRL_NMK_STN8815 },
1890 { "pinctrl-db8500", PINCTRL_NMK_DB8500 }, 1942 { "pinctrl-db8500", PINCTRL_NMK_DB8500 },
1891 { "pinctrl-db8540", PINCTRL_NMK_DB8540 }, 1943 { "pinctrl-db8540", PINCTRL_NMK_DB8540 },
1944 { }
1892}; 1945};
1893 1946
1894static struct platform_driver nmk_pinctrl_driver = { 1947static struct platform_driver nmk_pinctrl_driver = {
diff --git a/drivers/pinctrl/pinctrl-nomadik.h b/drivers/pinctrl/pinctrl-nomadik.h
index eef316e979a0..bcd4191e10ea 100644
--- a/drivers/pinctrl/pinctrl-nomadik.h
+++ b/drivers/pinctrl/pinctrl-nomadik.h
@@ -1,7 +1,7 @@
1#ifndef PINCTRL_PINCTRL_NOMADIK_H 1#ifndef PINCTRL_PINCTRL_NOMADIK_H
2#define PINCTRL_PINCTRL_NOMADIK_H 2#define PINCTRL_PINCTRL_NOMADIK_H
3 3
4#include <plat/gpio-nomadik.h> 4#include <linux/platform_data/pinctrl-nomadik.h>
5 5
6/* Package definitions */ 6/* Package definitions */
7#define PINCTRL_NMK_STN8815 0 7#define PINCTRL_NMK_STN8815 0
diff --git a/arch/arm/plat-nomadik/include/plat/pincfg.h b/include/linux/platform_data/pinctrl-nomadik.h
index 3b8ec60af351..f73b2f0c55b7 100644
--- a/arch/arm/plat-nomadik/include/plat/pincfg.h
+++ b/include/linux/platform_data/pinctrl-nomadik.h
@@ -1,16 +1,17 @@
1/* 1/*
2 * Copyright (C) ST-Ericsson SA 2010 2 * Structures and registers for GPIO access in the Nomadik SoC
3 * 3 *
4 * License terms: GNU General Public License, version 2 4 * Copyright (C) 2008 STMicroelectronics
5 * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson 5 * Author: Prafulla WADASKAR <prafulla.wadaskar@st.com>
6 * Copyright (C) 2009 Alessandro Rubini <rubini@unipv.it>
6 * 7 *
7 * Based on arch/arm/mach-pxa/include/mach/mfp.h: 8 * This program is free software; you can redistribute it and/or modify
8 * Copyright (C) 2007 Marvell International Ltd. 9 * it under the terms of the GNU General Public License version 2 as
9 * eric miao <eric.miao@marvell.com> 10 * published by the Free Software Foundation.
10 */ 11 */
11 12
12#ifndef __PLAT_PINCFG_H 13#ifndef __PLAT_NOMADIK_GPIO
13#define __PLAT_PINCFG_H 14#define __PLAT_NOMADIK_GPIO
14 15
15/* 16/*
16 * pin configurations are represented by 32-bit integers: 17 * pin configurations are represented by 32-bit integers:
@@ -166,8 +167,100 @@ typedef unsigned long pin_cfg_t;
166 (PIN_CFG_DEFAULT |\ 167 (PIN_CFG_DEFAULT |\
167 (PIN_NUM(num) | PIN_##alt | PIN_OUTPUT_##val)) 168 (PIN_NUM(num) | PIN_##alt | PIN_OUTPUT_##val))
168 169
170/*
171 * "nmk_gpio" and "NMK_GPIO" stand for "Nomadik GPIO", leaving
172 * the "gpio" namespace for generic and cross-machine functions
173 */
174
175#define GPIO_BLOCK_SHIFT 5
176#define NMK_GPIO_PER_CHIP (1 << GPIO_BLOCK_SHIFT)
177
178/* Register in the logic block */
179#define NMK_GPIO_DAT 0x00
180#define NMK_GPIO_DATS 0x04
181#define NMK_GPIO_DATC 0x08
182#define NMK_GPIO_PDIS 0x0c
183#define NMK_GPIO_DIR 0x10
184#define NMK_GPIO_DIRS 0x14
185#define NMK_GPIO_DIRC 0x18
186#define NMK_GPIO_SLPC 0x1c
187#define NMK_GPIO_AFSLA 0x20
188#define NMK_GPIO_AFSLB 0x24
189#define NMK_GPIO_LOWEMI 0x28
190
191#define NMK_GPIO_RIMSC 0x40
192#define NMK_GPIO_FIMSC 0x44
193#define NMK_GPIO_IS 0x48
194#define NMK_GPIO_IC 0x4c
195#define NMK_GPIO_RWIMSC 0x50
196#define NMK_GPIO_FWIMSC 0x54
197#define NMK_GPIO_WKS 0x58
198/* These appear in DB8540 and later ASICs */
199#define NMK_GPIO_EDGELEVEL 0x5C
200#define NMK_GPIO_LEVEL 0x60
201
202/* Alternate functions: function C is set in hw by setting both A and B */
203#define NMK_GPIO_ALT_GPIO 0
204#define NMK_GPIO_ALT_A 1
205#define NMK_GPIO_ALT_B 2
206#define NMK_GPIO_ALT_C (NMK_GPIO_ALT_A | NMK_GPIO_ALT_B)
207
208#define NMK_GPIO_ALT_CX_SHIFT 2
209#define NMK_GPIO_ALT_C1 ((1<<NMK_GPIO_ALT_CX_SHIFT) | NMK_GPIO_ALT_C)
210#define NMK_GPIO_ALT_C2 ((2<<NMK_GPIO_ALT_CX_SHIFT) | NMK_GPIO_ALT_C)
211#define NMK_GPIO_ALT_C3 ((3<<NMK_GPIO_ALT_CX_SHIFT) | NMK_GPIO_ALT_C)
212#define NMK_GPIO_ALT_C4 ((4<<NMK_GPIO_ALT_CX_SHIFT) | NMK_GPIO_ALT_C)
213
214/* Pull up/down values */
215enum nmk_gpio_pull {
216 NMK_GPIO_PULL_NONE,
217 NMK_GPIO_PULL_UP,
218 NMK_GPIO_PULL_DOWN,
219};
220
221/* Sleep mode */
222enum nmk_gpio_slpm {
223 NMK_GPIO_SLPM_INPUT,
224 NMK_GPIO_SLPM_WAKEUP_ENABLE = NMK_GPIO_SLPM_INPUT,
225 NMK_GPIO_SLPM_NOCHANGE,
226 NMK_GPIO_SLPM_WAKEUP_DISABLE = NMK_GPIO_SLPM_NOCHANGE,
227};
228
229/* Older deprecated pin config API that should go away soon */
169extern int nmk_config_pin(pin_cfg_t cfg, bool sleep); 230extern int nmk_config_pin(pin_cfg_t cfg, bool sleep);
170extern int nmk_config_pins(pin_cfg_t *cfgs, int num); 231extern int nmk_config_pins(pin_cfg_t *cfgs, int num);
171extern int nmk_config_pins_sleep(pin_cfg_t *cfgs, int num); 232extern int nmk_config_pins_sleep(pin_cfg_t *cfgs, int num);
172 233extern int nmk_gpio_set_slpm(int gpio, enum nmk_gpio_slpm mode);
234extern int nmk_gpio_set_pull(int gpio, enum nmk_gpio_pull pull);
235#ifdef CONFIG_PINCTRL_NOMADIK
236extern int nmk_gpio_set_mode(int gpio, int gpio_mode);
237#else
238static inline int nmk_gpio_set_mode(int gpio, int gpio_mode)
239{
240 return -ENODEV;
241}
173#endif 242#endif
243extern int nmk_gpio_get_mode(int gpio);
244
245extern void nmk_gpio_wakeups_suspend(void);
246extern void nmk_gpio_wakeups_resume(void);
247
248extern void nmk_gpio_clocks_enable(void);
249extern void nmk_gpio_clocks_disable(void);
250
251extern void nmk_gpio_read_pull(int gpio_bank, u32 *pull_up);
252
253/*
254 * Platform data to register a block: only the initial gpio/irq number.
255 */
256struct nmk_gpio_platform_data {
257 char *name;
258 int first_gpio;
259 int first_irq;
260 int num_gpio;
261 u32 (*get_secondary_status)(unsigned int bank);
262 void (*set_ioforce)(bool enable);
263 bool supports_sleepmode;
264};
265
266#endif /* __PLAT_NOMADIK_GPIO */