diff options
author | Kevin Hilman <khilman@ti.com> | 2011-04-20 19:31:23 -0400 |
---|---|---|
committer | Kevin Hilman <khilman@ti.com> | 2011-06-16 14:13:42 -0400 |
commit | fa87931acb8203a1f40a3c637863ad238f70cd40 (patch) | |
tree | fd79e56fb9819bbb1096c9d3904f0ba04bec832a /arch | |
parent | a8be8dafd00e3ccf4f85e2f30babf42be5076324 (diff) |
gpio/omap: consolidate direction, input, output, remove #ifdefs
Add register offset fields to GPIO platform_data for registers.
This patch adds registers that control direction, input and output
data. Using these register offsets in the common driver allows
removal of #ifdefs and greatly improves readability.
Also create dedicated data out functions: one for banks with dedicated
set/clear registers, and another for banks with a single mask
register.
Signed-off-by: Kevin Hilman <khilman@ti.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/arm/mach-omap1/gpio15xx.c | 14 | ||||
-rw-r--r-- | arch/arm/mach-omap1/gpio16xx.c | 19 | ||||
-rw-r--r-- | arch/arm/mach-omap1/gpio7xx.c | 19 | ||||
-rw-r--r-- | arch/arm/mach-omap2/gpio.c | 16 | ||||
-rw-r--r-- | arch/arm/plat-omap/include/plat/gpio.h | 10 |
5 files changed, 78 insertions, 0 deletions
diff --git a/arch/arm/mach-omap1/gpio15xx.c b/arch/arm/mach-omap1/gpio15xx.c index 04c4b04cf54e..a622d567b53e 100644 --- a/arch/arm/mach-omap1/gpio15xx.c +++ b/arch/arm/mach-omap1/gpio15xx.c | |||
@@ -34,11 +34,18 @@ static struct __initdata resource omap15xx_mpu_gpio_resources[] = { | |||
34 | }, | 34 | }, |
35 | }; | 35 | }; |
36 | 36 | ||
37 | static struct omap_gpio_reg_offs omap15xx_mpuio_regs = { | ||
38 | .direction = OMAP_MPUIO_IO_CNTL, | ||
39 | .datain = OMAP_MPUIO_INPUT_LATCH, | ||
40 | .dataout = OMAP_MPUIO_OUTPUT, | ||
41 | }; | ||
42 | |||
37 | static struct __initdata omap_gpio_platform_data omap15xx_mpu_gpio_config = { | 43 | static struct __initdata omap_gpio_platform_data omap15xx_mpu_gpio_config = { |
38 | .virtual_irq_start = IH_MPUIO_BASE, | 44 | .virtual_irq_start = IH_MPUIO_BASE, |
39 | .bank_type = METHOD_MPUIO, | 45 | .bank_type = METHOD_MPUIO, |
40 | .bank_width = 16, | 46 | .bank_width = 16, |
41 | .bank_stride = 1, | 47 | .bank_stride = 1, |
48 | .regs = &omap15xx_mpuio_regs, | ||
42 | }; | 49 | }; |
43 | 50 | ||
44 | static struct __initdata platform_device omap15xx_mpu_gpio = { | 51 | static struct __initdata platform_device omap15xx_mpu_gpio = { |
@@ -64,10 +71,17 @@ static struct __initdata resource omap15xx_gpio_resources[] = { | |||
64 | }, | 71 | }, |
65 | }; | 72 | }; |
66 | 73 | ||
74 | static struct omap_gpio_reg_offs omap15xx_gpio_regs = { | ||
75 | .direction = OMAP1510_GPIO_DIR_CONTROL, | ||
76 | .datain = OMAP1510_GPIO_DATA_INPUT, | ||
77 | .dataout = OMAP1510_GPIO_DATA_OUTPUT, | ||
78 | }; | ||
79 | |||
67 | static struct __initdata omap_gpio_platform_data omap15xx_gpio_config = { | 80 | static struct __initdata omap_gpio_platform_data omap15xx_gpio_config = { |
68 | .virtual_irq_start = IH_GPIO_BASE, | 81 | .virtual_irq_start = IH_GPIO_BASE, |
69 | .bank_type = METHOD_GPIO_1510, | 82 | .bank_type = METHOD_GPIO_1510, |
70 | .bank_width = 16, | 83 | .bank_width = 16, |
84 | .regs = &omap15xx_gpio_regs, | ||
71 | }; | 85 | }; |
72 | 86 | ||
73 | static struct __initdata platform_device omap15xx_gpio = { | 87 | static struct __initdata platform_device omap15xx_gpio = { |
diff --git a/arch/arm/mach-omap1/gpio16xx.c b/arch/arm/mach-omap1/gpio16xx.c index 5dd0d4c82b24..4ff6ff36ab73 100644 --- a/arch/arm/mach-omap1/gpio16xx.c +++ b/arch/arm/mach-omap1/gpio16xx.c | |||
@@ -37,11 +37,18 @@ static struct __initdata resource omap16xx_mpu_gpio_resources[] = { | |||
37 | }, | 37 | }, |
38 | }; | 38 | }; |
39 | 39 | ||
40 | static struct omap_gpio_reg_offs omap16xx_mpuio_regs = { | ||
41 | .direction = OMAP_MPUIO_IO_CNTL, | ||
42 | .datain = OMAP_MPUIO_INPUT_LATCH, | ||
43 | .dataout = OMAP_MPUIO_OUTPUT, | ||
44 | }; | ||
45 | |||
40 | static struct __initdata omap_gpio_platform_data omap16xx_mpu_gpio_config = { | 46 | static struct __initdata omap_gpio_platform_data omap16xx_mpu_gpio_config = { |
41 | .virtual_irq_start = IH_MPUIO_BASE, | 47 | .virtual_irq_start = IH_MPUIO_BASE, |
42 | .bank_type = METHOD_MPUIO, | 48 | .bank_type = METHOD_MPUIO, |
43 | .bank_width = 16, | 49 | .bank_width = 16, |
44 | .bank_stride = 1, | 50 | .bank_stride = 1, |
51 | .regs = &omap16xx_mpuio_regs, | ||
45 | }; | 52 | }; |
46 | 53 | ||
47 | static struct __initdata platform_device omap16xx_mpu_gpio = { | 54 | static struct __initdata platform_device omap16xx_mpu_gpio = { |
@@ -67,10 +74,19 @@ static struct __initdata resource omap16xx_gpio1_resources[] = { | |||
67 | }, | 74 | }, |
68 | }; | 75 | }; |
69 | 76 | ||
77 | static struct omap_gpio_reg_offs omap16xx_gpio_regs = { | ||
78 | .direction = OMAP1610_GPIO_DIRECTION, | ||
79 | .set_dataout = OMAP1610_GPIO_SET_DATAOUT, | ||
80 | .clr_dataout = OMAP1610_GPIO_CLEAR_DATAOUT, | ||
81 | .datain = OMAP1610_GPIO_DATAIN, | ||
82 | .dataout = OMAP1610_GPIO_DATAOUT, | ||
83 | }; | ||
84 | |||
70 | static struct __initdata omap_gpio_platform_data omap16xx_gpio1_config = { | 85 | static struct __initdata omap_gpio_platform_data omap16xx_gpio1_config = { |
71 | .virtual_irq_start = IH_GPIO_BASE, | 86 | .virtual_irq_start = IH_GPIO_BASE, |
72 | .bank_type = METHOD_GPIO_1610, | 87 | .bank_type = METHOD_GPIO_1610, |
73 | .bank_width = 16, | 88 | .bank_width = 16, |
89 | .regs = &omap16xx_gpio_regs, | ||
74 | }; | 90 | }; |
75 | 91 | ||
76 | static struct __initdata platform_device omap16xx_gpio1 = { | 92 | static struct __initdata platform_device omap16xx_gpio1 = { |
@@ -100,6 +116,7 @@ static struct __initdata omap_gpio_platform_data omap16xx_gpio2_config = { | |||
100 | .virtual_irq_start = IH_GPIO_BASE + 16, | 116 | .virtual_irq_start = IH_GPIO_BASE + 16, |
101 | .bank_type = METHOD_GPIO_1610, | 117 | .bank_type = METHOD_GPIO_1610, |
102 | .bank_width = 16, | 118 | .bank_width = 16, |
119 | .regs = &omap16xx_gpio_regs, | ||
103 | }; | 120 | }; |
104 | 121 | ||
105 | static struct __initdata platform_device omap16xx_gpio2 = { | 122 | static struct __initdata platform_device omap16xx_gpio2 = { |
@@ -129,6 +146,7 @@ static struct __initdata omap_gpio_platform_data omap16xx_gpio3_config = { | |||
129 | .virtual_irq_start = IH_GPIO_BASE + 32, | 146 | .virtual_irq_start = IH_GPIO_BASE + 32, |
130 | .bank_type = METHOD_GPIO_1610, | 147 | .bank_type = METHOD_GPIO_1610, |
131 | .bank_width = 16, | 148 | .bank_width = 16, |
149 | .regs = &omap16xx_gpio_regs, | ||
132 | }; | 150 | }; |
133 | 151 | ||
134 | static struct __initdata platform_device omap16xx_gpio3 = { | 152 | static struct __initdata platform_device omap16xx_gpio3 = { |
@@ -158,6 +176,7 @@ static struct __initdata omap_gpio_platform_data omap16xx_gpio4_config = { | |||
158 | .virtual_irq_start = IH_GPIO_BASE + 48, | 176 | .virtual_irq_start = IH_GPIO_BASE + 48, |
159 | .bank_type = METHOD_GPIO_1610, | 177 | .bank_type = METHOD_GPIO_1610, |
160 | .bank_width = 16, | 178 | .bank_width = 16, |
179 | .regs = &omap16xx_gpio_regs, | ||
161 | }; | 180 | }; |
162 | 181 | ||
163 | static struct __initdata platform_device omap16xx_gpio4 = { | 182 | static struct __initdata platform_device omap16xx_gpio4 = { |
diff --git a/arch/arm/mach-omap1/gpio7xx.c b/arch/arm/mach-omap1/gpio7xx.c index 1204c8b871af..efe4dccaa4f2 100644 --- a/arch/arm/mach-omap1/gpio7xx.c +++ b/arch/arm/mach-omap1/gpio7xx.c | |||
@@ -39,11 +39,18 @@ static struct __initdata resource omap7xx_mpu_gpio_resources[] = { | |||
39 | }, | 39 | }, |
40 | }; | 40 | }; |
41 | 41 | ||
42 | static struct omap_gpio_reg_offs omap7xx_mpuio_regs = { | ||
43 | .direction = OMAP_MPUIO_IO_CNTL / 2, | ||
44 | .datain = OMAP_MPUIO_INPUT_LATCH / 2, | ||
45 | .dataout = OMAP_MPUIO_OUTPUT / 2, | ||
46 | }; | ||
47 | |||
42 | static struct __initdata omap_gpio_platform_data omap7xx_mpu_gpio_config = { | 48 | static struct __initdata omap_gpio_platform_data omap7xx_mpu_gpio_config = { |
43 | .virtual_irq_start = IH_MPUIO_BASE, | 49 | .virtual_irq_start = IH_MPUIO_BASE, |
44 | .bank_type = METHOD_MPUIO, | 50 | .bank_type = METHOD_MPUIO, |
45 | .bank_width = 32, | 51 | .bank_width = 32, |
46 | .bank_stride = 2, | 52 | .bank_stride = 2, |
53 | .regs = &omap7xx_mpuio_regs, | ||
47 | }; | 54 | }; |
48 | 55 | ||
49 | static struct __initdata platform_device omap7xx_mpu_gpio = { | 56 | static struct __initdata platform_device omap7xx_mpu_gpio = { |
@@ -69,10 +76,17 @@ static struct __initdata resource omap7xx_gpio1_resources[] = { | |||
69 | }, | 76 | }, |
70 | }; | 77 | }; |
71 | 78 | ||
79 | static struct omap_gpio_reg_offs omap7xx_gpio_regs = { | ||
80 | .direction = OMAP7XX_GPIO_DIR_CONTROL, | ||
81 | .datain = OMAP7XX_GPIO_DATA_INPUT, | ||
82 | .dataout = OMAP7XX_GPIO_DATA_OUTPUT, | ||
83 | }; | ||
84 | |||
72 | static struct __initdata omap_gpio_platform_data omap7xx_gpio1_config = { | 85 | static struct __initdata omap_gpio_platform_data omap7xx_gpio1_config = { |
73 | .virtual_irq_start = IH_GPIO_BASE, | 86 | .virtual_irq_start = IH_GPIO_BASE, |
74 | .bank_type = METHOD_GPIO_7XX, | 87 | .bank_type = METHOD_GPIO_7XX, |
75 | .bank_width = 32, | 88 | .bank_width = 32, |
89 | .regs = &omap7xx_gpio_regs, | ||
76 | }; | 90 | }; |
77 | 91 | ||
78 | static struct __initdata platform_device omap7xx_gpio1 = { | 92 | static struct __initdata platform_device omap7xx_gpio1 = { |
@@ -102,6 +116,7 @@ static struct __initdata omap_gpio_platform_data omap7xx_gpio2_config = { | |||
102 | .virtual_irq_start = IH_GPIO_BASE + 32, | 116 | .virtual_irq_start = IH_GPIO_BASE + 32, |
103 | .bank_type = METHOD_GPIO_7XX, | 117 | .bank_type = METHOD_GPIO_7XX, |
104 | .bank_width = 32, | 118 | .bank_width = 32, |
119 | .regs = &omap7xx_gpio_regs, | ||
105 | }; | 120 | }; |
106 | 121 | ||
107 | static struct __initdata platform_device omap7xx_gpio2 = { | 122 | static struct __initdata platform_device omap7xx_gpio2 = { |
@@ -131,6 +146,7 @@ static struct __initdata omap_gpio_platform_data omap7xx_gpio3_config = { | |||
131 | .virtual_irq_start = IH_GPIO_BASE + 64, | 146 | .virtual_irq_start = IH_GPIO_BASE + 64, |
132 | .bank_type = METHOD_GPIO_7XX, | 147 | .bank_type = METHOD_GPIO_7XX, |
133 | .bank_width = 32, | 148 | .bank_width = 32, |
149 | .regs = &omap7xx_gpio_regs, | ||
134 | }; | 150 | }; |
135 | 151 | ||
136 | static struct __initdata platform_device omap7xx_gpio3 = { | 152 | static struct __initdata platform_device omap7xx_gpio3 = { |
@@ -160,6 +176,7 @@ static struct __initdata omap_gpio_platform_data omap7xx_gpio4_config = { | |||
160 | .virtual_irq_start = IH_GPIO_BASE + 96, | 176 | .virtual_irq_start = IH_GPIO_BASE + 96, |
161 | .bank_type = METHOD_GPIO_7XX, | 177 | .bank_type = METHOD_GPIO_7XX, |
162 | .bank_width = 32, | 178 | .bank_width = 32, |
179 | .regs = &omap7xx_gpio_regs, | ||
163 | }; | 180 | }; |
164 | 181 | ||
165 | static struct __initdata platform_device omap7xx_gpio4 = { | 182 | static struct __initdata platform_device omap7xx_gpio4 = { |
@@ -189,6 +206,7 @@ static struct __initdata omap_gpio_platform_data omap7xx_gpio5_config = { | |||
189 | .virtual_irq_start = IH_GPIO_BASE + 128, | 206 | .virtual_irq_start = IH_GPIO_BASE + 128, |
190 | .bank_type = METHOD_GPIO_7XX, | 207 | .bank_type = METHOD_GPIO_7XX, |
191 | .bank_width = 32, | 208 | .bank_width = 32, |
209 | .regs = &omap7xx_gpio_regs, | ||
192 | }; | 210 | }; |
193 | 211 | ||
194 | static struct __initdata platform_device omap7xx_gpio5 = { | 212 | static struct __initdata platform_device omap7xx_gpio5 = { |
@@ -218,6 +236,7 @@ static struct __initdata omap_gpio_platform_data omap7xx_gpio6_config = { | |||
218 | .virtual_irq_start = IH_GPIO_BASE + 160, | 236 | .virtual_irq_start = IH_GPIO_BASE + 160, |
219 | .bank_type = METHOD_GPIO_7XX, | 237 | .bank_type = METHOD_GPIO_7XX, |
220 | .bank_width = 32, | 238 | .bank_width = 32, |
239 | .regs = &omap7xx_gpio_regs, | ||
221 | }; | 240 | }; |
222 | 241 | ||
223 | static struct __initdata platform_device omap7xx_gpio6 = { | 242 | static struct __initdata platform_device omap7xx_gpio6 = { |
diff --git a/arch/arm/mach-omap2/gpio.c b/arch/arm/mach-omap2/gpio.c index 9529842ae054..357e06956b0c 100644 --- a/arch/arm/mach-omap2/gpio.c +++ b/arch/arm/mach-omap2/gpio.c | |||
@@ -61,13 +61,29 @@ static int omap2_gpio_dev_init(struct omap_hwmod *oh, void *unused) | |||
61 | pdata->dbck_flag = dev_attr->dbck_flag; | 61 | pdata->dbck_flag = dev_attr->dbck_flag; |
62 | pdata->virtual_irq_start = IH_GPIO_BASE + 32 * (id - 1); | 62 | pdata->virtual_irq_start = IH_GPIO_BASE + 32 * (id - 1); |
63 | 63 | ||
64 | pdata->regs = kzalloc(sizeof(struct omap_gpio_reg_offs), GFP_KERNEL); | ||
65 | if (!pdata) { | ||
66 | pr_err("gpio%d: Memory allocation failed\n", id); | ||
67 | return -ENOMEM; | ||
68 | } | ||
69 | |||
64 | switch (oh->class->rev) { | 70 | switch (oh->class->rev) { |
65 | case 0: | 71 | case 0: |
66 | case 1: | 72 | case 1: |
67 | pdata->bank_type = METHOD_GPIO_24XX; | 73 | pdata->bank_type = METHOD_GPIO_24XX; |
74 | pdata->regs->direction = OMAP24XX_GPIO_OE; | ||
75 | pdata->regs->datain = OMAP24XX_GPIO_DATAIN; | ||
76 | pdata->regs->dataout = OMAP24XX_GPIO_DATAOUT; | ||
77 | pdata->regs->set_dataout = OMAP24XX_GPIO_SETDATAOUT; | ||
78 | pdata->regs->clr_dataout = OMAP24XX_GPIO_CLEARDATAOUT; | ||
68 | break; | 79 | break; |
69 | case 2: | 80 | case 2: |
70 | pdata->bank_type = METHOD_GPIO_44XX; | 81 | pdata->bank_type = METHOD_GPIO_44XX; |
82 | pdata->regs->direction = OMAP4_GPIO_OE; | ||
83 | pdata->regs->datain = OMAP4_GPIO_DATAIN; | ||
84 | pdata->regs->dataout = OMAP4_GPIO_DATAOUT; | ||
85 | pdata->regs->set_dataout = OMAP4_GPIO_SETDATAOUT; | ||
86 | pdata->regs->clr_dataout = OMAP4_GPIO_CLEARDATAOUT; | ||
71 | break; | 87 | break; |
72 | default: | 88 | default: |
73 | WARN(1, "Invalid gpio bank_type\n"); | 89 | WARN(1, "Invalid gpio bank_type\n"); |
diff --git a/arch/arm/plat-omap/include/plat/gpio.h b/arch/arm/plat-omap/include/plat/gpio.h index ec97e00cb581..268bccd0f7f6 100644 --- a/arch/arm/plat-omap/include/plat/gpio.h +++ b/arch/arm/plat-omap/include/plat/gpio.h | |||
@@ -174,12 +174,22 @@ struct omap_gpio_dev_attr { | |||
174 | bool dbck_flag; /* dbck required or not - True for OMAP3&4 */ | 174 | bool dbck_flag; /* dbck required or not - True for OMAP3&4 */ |
175 | }; | 175 | }; |
176 | 176 | ||
177 | struct omap_gpio_reg_offs { | ||
178 | u16 direction; | ||
179 | u16 datain; | ||
180 | u16 dataout; | ||
181 | u16 set_dataout; | ||
182 | u16 clr_dataout; | ||
183 | }; | ||
184 | |||
177 | struct omap_gpio_platform_data { | 185 | struct omap_gpio_platform_data { |
178 | u16 virtual_irq_start; | 186 | u16 virtual_irq_start; |
179 | int bank_type; | 187 | int bank_type; |
180 | int bank_width; /* GPIO bank width */ | 188 | int bank_width; /* GPIO bank width */ |
181 | int bank_stride; /* Only needed for omap1 MPUIO */ | 189 | int bank_stride; /* Only needed for omap1 MPUIO */ |
182 | bool dbck_flag; /* dbck required or not - True for OMAP3&4 */ | 190 | bool dbck_flag; /* dbck required or not - True for OMAP3&4 */ |
191 | |||
192 | struct omap_gpio_reg_offs *regs; | ||
183 | }; | 193 | }; |
184 | 194 | ||
185 | /* TODO: Analyze removing gpio_bank_count usage from driver code */ | 195 | /* TODO: Analyze removing gpio_bank_count usage from driver code */ |