aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap1
diff options
context:
space:
mode:
authorJanusz Krzysztofik <jkrzyszt@tis.icnet.pl>2011-12-19 21:24:21 -0500
committerTony Lindgren <tony@atomide.com>2011-12-22 11:59:49 -0500
commit937eb4bb00588571f223eade260f9b509bf223ab (patch)
treed8074b6a3126f556238ffbeac59a17431564b5e3 /arch/arm/mach-omap1
parentf7519d8c8290765a9408a52db4ba4a368ff72ca5 (diff)
ARM: OMAP1: ams-delta: convert latches to basic_mmio_gpio
Once ready, ams-delta specific device drivers currently calling custom ams_delta_latch[12]_write() functions can be updated to call generic gpio_set_value() instead, which will make them less platform dependent. Even more, some custom ams-delta only drivers can perhaps be dropped from the tree after converting selected ams-delta platform devices to follow generic GPIO based device models. The latch_gpios[] table is initially filled with all latch1 and latch2 GPIO pins in order to register and initialize them from the board file until those are handled by respective existing device drivers (leds, nand, lcd, serio, asoc, serial). That table will get almost empty after the transision process is completed, holding only pins not used by any drivers / connected to unused devices, in order to initialize them from the board file for power saving purposes. The new ams_delta_latch_write() function is a unified replacement for those removed ams_delta_latch[12]_write(), and serves as a temporary wrapper over gpio_set_value(), providing the old API for those not yet updated device drivers, and will be removed after all custom drivers are converted or replaced. Signed-off-by: Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> Signed-off-by: Tony Lindgren <tony@atomide.com>
Diffstat (limited to 'arch/arm/mach-omap1')
-rw-r--r--arch/arm/mach-omap1/Kconfig1
-rw-r--r--arch/arm/mach-omap1/board-ams-delta.c237
2 files changed, 208 insertions, 30 deletions
diff --git a/arch/arm/mach-omap1/Kconfig b/arch/arm/mach-omap1/Kconfig
index 4f8d66f044e7..e14532f236a0 100644
--- a/arch/arm/mach-omap1/Kconfig
+++ b/arch/arm/mach-omap1/Kconfig
@@ -155,6 +155,7 @@ config MACH_AMS_DELTA
155 bool "Amstrad E3 (Delta)" 155 bool "Amstrad E3 (Delta)"
156 depends on ARCH_OMAP1 && ARCH_OMAP15XX 156 depends on ARCH_OMAP1 && ARCH_OMAP15XX
157 select FIQ 157 select FIQ
158 select GPIO_GENERIC_PLATFORM
158 help 159 help
159 Support for the Amstrad E3 (codename Delta) videophone. Say Y here 160 Support for the Amstrad E3 (codename Delta) videophone. Say Y here
160 if you have such a device. 161 if you have such a device.
diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
index 50987c91690f..cff2711dc259 100644
--- a/arch/arm/mach-omap1/board-ams-delta.c
+++ b/arch/arm/mach-omap1/board-ams-delta.c
@@ -11,6 +11,7 @@
11 * it under the terms of the GNU General Public License version 2 as 11 * it under the terms of the GNU General Public License version 2 as
12 * published by the Free Software Foundation. 12 * published by the Free Software Foundation.
13 */ 13 */
14#include <linux/basic_mmio_gpio.h>
14#include <linux/gpio.h> 15#include <linux/gpio.h>
15#include <linux/kernel.h> 16#include <linux/kernel.h>
16#include <linux/init.h> 17#include <linux/init.h>
@@ -40,9 +41,6 @@
40 41
41#include <mach/ams-delta-fiq.h> 42#include <mach/ams-delta-fiq.h>
42 43
43static u8 ams_delta_latch1_reg;
44static u16 ams_delta_latch2_reg;
45
46static const unsigned int ams_delta_keymap[] = { 44static const unsigned int ams_delta_keymap[] = {
47 KEY(0, 0, KEY_F1), /* Advert */ 45 KEY(0, 0, KEY_F1), /* Advert */
48 46
@@ -121,39 +119,32 @@ static const unsigned int ams_delta_keymap[] = {
121 KEY(7, 3, KEY_LEFTCTRL), /* Vol down */ 119 KEY(7, 3, KEY_LEFTCTRL), /* Vol down */
122}; 120};
123 121
124void ams_delta_latch1_write(u8 mask, u8 value) 122#define LATCH1_PHYS 0x01000000
125{ 123#define LATCH1_VIRT 0xEA000000
126 ams_delta_latch1_reg &= ~mask; 124#define MODEM_PHYS 0x04000000
127 ams_delta_latch1_reg |= value; 125#define MODEM_VIRT 0xEB000000
128 *(volatile __u8 *) AMS_DELTA_LATCH1_VIRT = ams_delta_latch1_reg; 126#define LATCH2_PHYS 0x08000000
129} 127#define LATCH2_VIRT 0xEC000000
130
131void ams_delta_latch2_write(u16 mask, u16 value)
132{
133 ams_delta_latch2_reg &= ~mask;
134 ams_delta_latch2_reg |= value;
135 *(volatile __u16 *) AMS_DELTA_LATCH2_VIRT = ams_delta_latch2_reg;
136}
137 128
138static struct map_desc ams_delta_io_desc[] __initdata = { 129static struct map_desc ams_delta_io_desc[] __initdata = {
139 /* AMS_DELTA_LATCH1 */ 130 /* AMS_DELTA_LATCH1 */
140 { 131 {
141 .virtual = AMS_DELTA_LATCH1_VIRT, 132 .virtual = LATCH1_VIRT,
142 .pfn = __phys_to_pfn(AMS_DELTA_LATCH1_PHYS), 133 .pfn = __phys_to_pfn(LATCH1_PHYS),
143 .length = 0x01000000, 134 .length = 0x01000000,
144 .type = MT_DEVICE 135 .type = MT_DEVICE
145 }, 136 },
146 /* AMS_DELTA_LATCH2 */ 137 /* AMS_DELTA_LATCH2 */
147 { 138 {
148 .virtual = AMS_DELTA_LATCH2_VIRT, 139 .virtual = LATCH2_VIRT,
149 .pfn = __phys_to_pfn(AMS_DELTA_LATCH2_PHYS), 140 .pfn = __phys_to_pfn(LATCH2_PHYS),
150 .length = 0x01000000, 141 .length = 0x01000000,
151 .type = MT_DEVICE 142 .type = MT_DEVICE
152 }, 143 },
153 /* AMS_DELTA_MODEM */ 144 /* AMS_DELTA_MODEM */
154 { 145 {
155 .virtual = AMS_DELTA_MODEM_VIRT, 146 .virtual = MODEM_VIRT,
156 .pfn = __phys_to_pfn(AMS_DELTA_MODEM_PHYS), 147 .pfn = __phys_to_pfn(MODEM_PHYS),
157 .length = 0x01000000, 148 .length = 0x01000000,
158 .type = MT_DEVICE 149 .type = MT_DEVICE
159 } 150 }
@@ -173,6 +164,190 @@ static struct omap_board_config_kernel ams_delta_config[] __initdata = {
173 { OMAP_TAG_LCD, &ams_delta_lcd_config }, 164 { OMAP_TAG_LCD, &ams_delta_lcd_config },
174}; 165};
175 166
167static struct resource latch1_resources[] __initconst = {
168 [0] = {
169 .name = "dat",
170 .start = LATCH1_PHYS,
171 .end = LATCH1_PHYS + (AMS_DELTA_LATCH1_NGPIO - 1) / 8,
172 .flags = IORESOURCE_MEM,
173 },
174};
175
176static struct bgpio_pdata latch1_pdata __initconst = {
177 .base = AMS_DELTA_LATCH1_GPIO_BASE,
178 .ngpio = AMS_DELTA_LATCH1_NGPIO,
179};
180
181static struct platform_device latch1_gpio_device = {
182 .name = "basic-mmio-gpio",
183 .id = 0,
184 .resource = latch1_resources,
185 .num_resources = ARRAY_SIZE(latch1_resources),
186 .dev = {
187 .platform_data = &latch1_pdata,
188 },
189};
190
191static struct resource latch2_resources[] __initconst = {
192 [0] = {
193 .name = "dat",
194 .start = LATCH2_PHYS,
195 .end = LATCH2_PHYS + (AMS_DELTA_LATCH2_NGPIO - 1) / 8,
196 .flags = IORESOURCE_MEM,
197 },
198};
199
200static struct bgpio_pdata latch2_pdata __initconst = {
201 .base = AMS_DELTA_LATCH2_GPIO_BASE,
202 .ngpio = AMS_DELTA_LATCH2_NGPIO,
203};
204
205static struct platform_device latch2_gpio_device = {
206 .name = "basic-mmio-gpio",
207 .id = 1,
208 .resource = latch2_resources,
209 .num_resources = ARRAY_SIZE(latch2_resources),
210 .dev = {
211 .platform_data = &latch2_pdata,
212 },
213};
214
215static struct gpio latch_gpios[] __initconst = {
216 {
217 .gpio = AMS_DELTA_GPIO_PIN_LED_CAMERA,
218 .flags = GPIOF_OUT_INIT_LOW,
219 .label = "led_camera",
220 },
221 {
222 .gpio = AMS_DELTA_GPIO_PIN_LED_ADVERT,
223 .flags = GPIOF_OUT_INIT_LOW,
224 .label = "led_advert",
225 },
226 {
227 .gpio = AMS_DELTA_GPIO_PIN_LED_EMAIL,
228 .flags = GPIOF_OUT_INIT_LOW,
229 .label = "led_email",
230 },
231 {
232 .gpio = AMS_DELTA_GPIO_PIN_LED_HANDSFREE,
233 .flags = GPIOF_OUT_INIT_LOW,
234 .label = "led_handsfree",
235 },
236 {
237 .gpio = AMS_DELTA_GPIO_PIN_LED_VOICEMAIL,
238 .flags = GPIOF_OUT_INIT_LOW,
239 .label = "led_voicemail",
240 },
241 {
242 .gpio = AMS_DELTA_GPIO_PIN_LED_VOICE,
243 .flags = GPIOF_OUT_INIT_LOW,
244 .label = "led_voice",
245 },
246 {
247 .gpio = AMS_DELTA_LATCH1_GPIO_BASE + 6,
248 .flags = GPIOF_OUT_INIT_LOW,
249 .label = "dockit1",
250 },
251 {
252 .gpio = AMS_DELTA_LATCH1_GPIO_BASE + 7,
253 .flags = GPIOF_OUT_INIT_LOW,
254 .label = "dockit2",
255 },
256 {
257 .gpio = AMS_DELTA_GPIO_PIN_LCD_VBLEN,
258 .flags = GPIOF_OUT_INIT_LOW,
259 .label = "lcd_vblen",
260 },
261 {
262 .gpio = AMS_DELTA_GPIO_PIN_LCD_NDISP,
263 .flags = GPIOF_OUT_INIT_LOW,
264 .label = "lcd_ndisp",
265 },
266 {
267 .gpio = AMS_DELTA_GPIO_PIN_NAND_NCE,
268 .flags = GPIOF_OUT_INIT_LOW,
269 .label = "nand_nce",
270 },
271 {
272 .gpio = AMS_DELTA_GPIO_PIN_NAND_NRE,
273 .flags = GPIOF_OUT_INIT_LOW,
274 .label = "nand_nre",
275 },
276 {
277 .gpio = AMS_DELTA_GPIO_PIN_NAND_NWP,
278 .flags = GPIOF_OUT_INIT_LOW,
279 .label = "nand_nwp",
280 },
281 {
282 .gpio = AMS_DELTA_GPIO_PIN_NAND_NWE,
283 .flags = GPIOF_OUT_INIT_LOW,
284 .label = "nand_nwe",
285 },
286 {
287 .gpio = AMS_DELTA_GPIO_PIN_NAND_ALE,
288 .flags = GPIOF_OUT_INIT_LOW,
289 .label = "nand_ale",
290 },
291 {
292 .gpio = AMS_DELTA_GPIO_PIN_NAND_CLE,
293 .flags = GPIOF_OUT_INIT_LOW,
294 .label = "nand_cle",
295 },
296 {
297 .gpio = AMS_DELTA_GPIO_PIN_KEYBRD_PWR,
298 .flags = GPIOF_OUT_INIT_LOW,
299 .label = "keybrd_pwr",
300 },
301 {
302 .gpio = AMS_DELTA_GPIO_PIN_KEYBRD_DATAOUT,
303 .flags = GPIOF_OUT_INIT_LOW,
304 .label = "keybrd_dataout",
305 },
306 {
307 .gpio = AMS_DELTA_GPIO_PIN_SCARD_RSTIN,
308 .flags = GPIOF_OUT_INIT_LOW,
309 .label = "scard_rstin",
310 },
311 {
312 .gpio = AMS_DELTA_GPIO_PIN_SCARD_CMDVCC,
313 .flags = GPIOF_OUT_INIT_LOW,
314 .label = "scard_cmdvcc",
315 },
316 {
317 .gpio = AMS_DELTA_GPIO_PIN_MODEM_NRESET,
318 .flags = GPIOF_OUT_INIT_LOW,
319 .label = "modem_nreset",
320 },
321 {
322 .gpio = AMS_DELTA_GPIO_PIN_MODEM_CODEC,
323 .flags = GPIOF_OUT_INIT_LOW,
324 .label = "modem_codec",
325 },
326 {
327 .gpio = AMS_DELTA_LATCH2_GPIO_BASE + 14,
328 .flags = GPIOF_OUT_INIT_LOW,
329 .label = "hookflash1",
330 },
331 {
332 .gpio = AMS_DELTA_LATCH2_GPIO_BASE + 15,
333 .flags = GPIOF_OUT_INIT_LOW,
334 .label = "hookflash2",
335 },
336};
337
338void ams_delta_latch_write(int base, int ngpio, u16 mask, u16 value)
339{
340 int bit = 0;
341 u16 bitpos = 1 << bit;
342
343 for (; bit < ngpio; bit++, bitpos = bitpos << 1) {
344 if (!(mask & bitpos))
345 continue;
346 gpio_set_value(base + bit, (value & bitpos) != 0);
347 }
348}
349EXPORT_SYMBOL(ams_delta_latch_write);
350
176static struct resource ams_delta_nand_resources[] = { 351static struct resource ams_delta_nand_resources[] = {
177 [0] = { 352 [0] = {
178 .start = OMAP1_MPUIO_BASE, 353 .start = OMAP1_MPUIO_BASE,
@@ -275,11 +450,13 @@ static struct omap1_cam_platform_data ams_delta_camera_platform_data = {
275}; 450};
276 451
277static struct platform_device *ams_delta_devices[] __initdata = { 452static struct platform_device *ams_delta_devices[] __initdata = {
453 &latch1_gpio_device,
454 &latch2_gpio_device,
278 &ams_delta_kp_device, 455 &ams_delta_kp_device,
279 &ams_delta_camera_device, 456 &ams_delta_camera_device,
280}; 457};
281 458
282static struct platform_device *late_devices[] __initdata = { 459static struct platform_device *late_devices[] __initconst = {
283 &ams_delta_nand_device, 460 &ams_delta_nand_device,
284 &ams_delta_lcd_device, 461 &ams_delta_lcd_device,
285 &ams_delta_led_device, 462 &ams_delta_led_device,
@@ -325,8 +502,8 @@ static void __init ams_delta_init(void)
325 502
326static struct plat_serial8250_port ams_delta_modem_ports[] = { 503static struct plat_serial8250_port ams_delta_modem_ports[] = {
327 { 504 {
328 .membase = IOMEM(AMS_DELTA_MODEM_VIRT), 505 .membase = IOMEM(MODEM_VIRT),
329 .mapbase = AMS_DELTA_MODEM_PHYS, 506 .mapbase = MODEM_PHYS,
330 .irq = -EINVAL, /* changed later */ 507 .irq = -EINVAL, /* changed later */
331 .flags = UPF_BOOT_AUTOCONF, 508 .flags = UPF_BOOT_AUTOCONF,
332 .irqflags = IRQF_TRIGGER_RISING, 509 .irqflags = IRQF_TRIGGER_RISING,
@@ -352,8 +529,11 @@ static int __init late_init(void)
352 if (!machine_is_ams_delta()) 529 if (!machine_is_ams_delta())
353 return -ENODEV; 530 return -ENODEV;
354 531
355 /* Clear latch2 (NAND, LCD, modem enable) */ 532 err = gpio_request_array(latch_gpios, ARRAY_SIZE(latch_gpios));
356 ams_delta_latch2_write(~0, 0); 533 if (err) {
534 pr_err("Couldn't take over latch1/latch2 GPIO pins\n");
535 return err;
536 }
357 537
358 platform_add_devices(late_devices, ARRAY_SIZE(late_devices)); 538 platform_add_devices(late_devices, ARRAY_SIZE(late_devices));
359 539
@@ -399,6 +579,3 @@ MACHINE_START(AMS_DELTA, "Amstrad E3 (Delta)")
399 .init_machine = ams_delta_init, 579 .init_machine = ams_delta_init,
400 .timer = &omap1_timer, 580 .timer = &omap1_timer,
401MACHINE_END 581MACHINE_END
402
403EXPORT_SYMBOL(ams_delta_latch1_write);
404EXPORT_SYMBOL(ams_delta_latch2_write);