aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap1/board-ams-delta.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/mach-omap1/board-ams-delta.c')
-rw-r--r--arch/arm/mach-omap1/board-ams-delta.c322
1 files changed, 274 insertions, 48 deletions
diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
index e0e8245f3c9f..c1b681ef4cba 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>
@@ -18,31 +19,33 @@
18#include <linux/interrupt.h> 19#include <linux/interrupt.h>
19#include <linux/leds.h> 20#include <linux/leds.h>
20#include <linux/platform_device.h> 21#include <linux/platform_device.h>
22#include <linux/regulator/consumer.h>
23#include <linux/regulator/fixed.h>
24#include <linux/regulator/machine.h>
21#include <linux/serial_8250.h> 25#include <linux/serial_8250.h>
22#include <linux/export.h> 26#include <linux/export.h>
23#include <linux/omapfb.h> 27#include <linux/omapfb.h>
28#include <linux/io.h>
24 29
25#include <media/soc_camera.h> 30#include <media/soc_camera.h>
26 31
27#include <asm/serial.h> 32#include <asm/serial.h>
28#include <mach/hardware.h>
29#include <asm/mach-types.h> 33#include <asm/mach-types.h>
30#include <asm/mach/arch.h> 34#include <asm/mach/arch.h>
31#include <asm/mach/map.h> 35#include <asm/mach/map.h>
32 36
33#include <plat/io.h>
34#include <plat/board-ams-delta.h> 37#include <plat/board-ams-delta.h>
35#include <plat/keypad.h> 38#include <plat/keypad.h>
36#include <plat/mux.h> 39#include <plat/mux.h>
37#include <plat/usb.h> 40#include <plat/usb.h>
38#include <plat/board.h> 41#include <plat/board.h>
39#include "common.h"
40#include <mach/camera.h>
41 42
43#include <mach/hardware.h>
42#include <mach/ams-delta-fiq.h> 44#include <mach/ams-delta-fiq.h>
45#include <mach/camera.h>
43 46
44static u8 ams_delta_latch1_reg; 47#include "iomap.h"
45static u16 ams_delta_latch2_reg; 48#include "common.h"
46 49
47static const unsigned int ams_delta_keymap[] = { 50static const unsigned int ams_delta_keymap[] = {
48 KEY(0, 0, KEY_F1), /* Advert */ 51 KEY(0, 0, KEY_F1), /* Advert */
@@ -122,54 +125,188 @@ static const unsigned int ams_delta_keymap[] = {
122 KEY(7, 3, KEY_LEFTCTRL), /* Vol down */ 125 KEY(7, 3, KEY_LEFTCTRL), /* Vol down */
123}; 126};
124 127
125void ams_delta_latch1_write(u8 mask, u8 value) 128#define LATCH1_PHYS 0x01000000
126{ 129#define LATCH1_VIRT 0xEA000000
127 ams_delta_latch1_reg &= ~mask; 130#define MODEM_PHYS 0x04000000
128 ams_delta_latch1_reg |= value; 131#define MODEM_VIRT 0xEB000000
129 *(volatile __u8 *) AMS_DELTA_LATCH1_VIRT = ams_delta_latch1_reg; 132#define LATCH2_PHYS 0x08000000
130} 133#define LATCH2_VIRT 0xEC000000
131
132void ams_delta_latch2_write(u16 mask, u16 value)
133{
134 ams_delta_latch2_reg &= ~mask;
135 ams_delta_latch2_reg |= value;
136 *(volatile __u16 *) AMS_DELTA_LATCH2_VIRT = ams_delta_latch2_reg;
137}
138 134
139static struct map_desc ams_delta_io_desc[] __initdata = { 135static struct map_desc ams_delta_io_desc[] __initdata = {
140 /* AMS_DELTA_LATCH1 */ 136 /* AMS_DELTA_LATCH1 */
141 { 137 {
142 .virtual = AMS_DELTA_LATCH1_VIRT, 138 .virtual = LATCH1_VIRT,
143 .pfn = __phys_to_pfn(AMS_DELTA_LATCH1_PHYS), 139 .pfn = __phys_to_pfn(LATCH1_PHYS),
144 .length = 0x01000000, 140 .length = 0x01000000,
145 .type = MT_DEVICE 141 .type = MT_DEVICE
146 }, 142 },
147 /* AMS_DELTA_LATCH2 */ 143 /* AMS_DELTA_LATCH2 */
148 { 144 {
149 .virtual = AMS_DELTA_LATCH2_VIRT, 145 .virtual = LATCH2_VIRT,
150 .pfn = __phys_to_pfn(AMS_DELTA_LATCH2_PHYS), 146 .pfn = __phys_to_pfn(LATCH2_PHYS),
151 .length = 0x01000000, 147 .length = 0x01000000,
152 .type = MT_DEVICE 148 .type = MT_DEVICE
153 }, 149 },
154 /* AMS_DELTA_MODEM */ 150 /* AMS_DELTA_MODEM */
155 { 151 {
156 .virtual = AMS_DELTA_MODEM_VIRT, 152 .virtual = MODEM_VIRT,
157 .pfn = __phys_to_pfn(AMS_DELTA_MODEM_PHYS), 153 .pfn = __phys_to_pfn(MODEM_PHYS),
158 .length = 0x01000000, 154 .length = 0x01000000,
159 .type = MT_DEVICE 155 .type = MT_DEVICE
160 } 156 }
161}; 157};
162 158
163static struct omap_lcd_config ams_delta_lcd_config = { 159static struct omap_lcd_config ams_delta_lcd_config __initdata = {
164 .ctrl_name = "internal", 160 .ctrl_name = "internal",
165}; 161};
166 162
167static struct omap_usb_config ams_delta_usb_config __initdata = { 163static struct omap_usb_config ams_delta_usb_config = {
168 .register_host = 1, 164 .register_host = 1,
169 .hmc_mode = 16, 165 .hmc_mode = 16,
170 .pins[0] = 2, 166 .pins[0] = 2,
171}; 167};
172 168
169#define LATCH1_GPIO_BASE 232
170#define LATCH1_NGPIO 8
171
172static struct resource latch1_resources[] = {
173 [0] = {
174 .name = "dat",
175 .start = LATCH1_PHYS,
176 .end = LATCH1_PHYS + (LATCH1_NGPIO - 1) / 8,
177 .flags = IORESOURCE_MEM,
178 },
179};
180
181static struct bgpio_pdata latch1_pdata = {
182 .base = LATCH1_GPIO_BASE,
183 .ngpio = LATCH1_NGPIO,
184};
185
186static struct platform_device latch1_gpio_device = {
187 .name = "basic-mmio-gpio",
188 .id = 0,
189 .resource = latch1_resources,
190 .num_resources = ARRAY_SIZE(latch1_resources),
191 .dev = {
192 .platform_data = &latch1_pdata,
193 },
194};
195
196static struct resource latch2_resources[] = {
197 [0] = {
198 .name = "dat",
199 .start = LATCH2_PHYS,
200 .end = LATCH2_PHYS + (AMS_DELTA_LATCH2_NGPIO - 1) / 8,
201 .flags = IORESOURCE_MEM,
202 },
203};
204
205static struct bgpio_pdata latch2_pdata = {
206 .base = AMS_DELTA_LATCH2_GPIO_BASE,
207 .ngpio = AMS_DELTA_LATCH2_NGPIO,
208};
209
210static struct platform_device latch2_gpio_device = {
211 .name = "basic-mmio-gpio",
212 .id = 1,
213 .resource = latch2_resources,
214 .num_resources = ARRAY_SIZE(latch2_resources),
215 .dev = {
216 .platform_data = &latch2_pdata,
217 },
218};
219
220static const struct gpio latch_gpios[] __initconst = {
221 {
222 .gpio = LATCH1_GPIO_BASE + 6,
223 .flags = GPIOF_OUT_INIT_LOW,
224 .label = "dockit1",
225 },
226 {
227 .gpio = LATCH1_GPIO_BASE + 7,
228 .flags = GPIOF_OUT_INIT_LOW,
229 .label = "dockit2",
230 },
231 {
232 .gpio = AMS_DELTA_GPIO_PIN_SCARD_RSTIN,
233 .flags = GPIOF_OUT_INIT_LOW,
234 .label = "scard_rstin",
235 },
236 {
237 .gpio = AMS_DELTA_GPIO_PIN_SCARD_CMDVCC,
238 .flags = GPIOF_OUT_INIT_LOW,
239 .label = "scard_cmdvcc",
240 },
241 {
242 .gpio = AMS_DELTA_GPIO_PIN_MODEM_CODEC,
243 .flags = GPIOF_OUT_INIT_LOW,
244 .label = "modem_codec",
245 },
246 {
247 .gpio = AMS_DELTA_LATCH2_GPIO_BASE + 14,
248 .flags = GPIOF_OUT_INIT_LOW,
249 .label = "hookflash1",
250 },
251 {
252 .gpio = AMS_DELTA_LATCH2_GPIO_BASE + 15,
253 .flags = GPIOF_OUT_INIT_LOW,
254 .label = "hookflash2",
255 },
256};
257
258static struct regulator_consumer_supply modem_nreset_consumers[] = {
259 REGULATOR_SUPPLY("RESET#", "serial8250.1"),
260 REGULATOR_SUPPLY("POR", "cx20442-codec"),
261};
262
263static struct regulator_init_data modem_nreset_data = {
264 .constraints = {
265 .valid_ops_mask = REGULATOR_CHANGE_STATUS,
266 .boot_on = 1,
267 },
268 .num_consumer_supplies = ARRAY_SIZE(modem_nreset_consumers),
269 .consumer_supplies = modem_nreset_consumers,
270};
271
272static struct fixed_voltage_config modem_nreset_config = {
273 .supply_name = "modem_nreset",
274 .microvolts = 3300000,
275 .gpio = AMS_DELTA_GPIO_PIN_MODEM_NRESET,
276 .startup_delay = 25000,
277 .enable_high = 1,
278 .enabled_at_boot = 1,
279 .init_data = &modem_nreset_data,
280};
281
282static struct platform_device modem_nreset_device = {
283 .name = "reg-fixed-voltage",
284 .id = -1,
285 .dev = {
286 .platform_data = &modem_nreset_config,
287 },
288};
289
290struct modem_private_data {
291 struct regulator *regulator;
292};
293
294static struct modem_private_data modem_priv;
295
296void ams_delta_latch_write(int base, int ngpio, u16 mask, u16 value)
297{
298 int bit = 0;
299 u16 bitpos = 1 << bit;
300
301 for (; bit < ngpio; bit++, bitpos = bitpos << 1) {
302 if (!(mask & bitpos))
303 continue;
304 else
305 gpio_set_value(base + bit, (value & bitpos) != 0);
306 }
307}
308EXPORT_SYMBOL(ams_delta_latch_write);
309
173static struct resource ams_delta_nand_resources[] = { 310static struct resource ams_delta_nand_resources[] = {
174 [0] = { 311 [0] = {
175 .start = OMAP1_MPUIO_BASE, 312 .start = OMAP1_MPUIO_BASE,
@@ -199,7 +336,7 @@ static const struct matrix_keymap_data ams_delta_keymap_data = {
199 .keymap_size = ARRAY_SIZE(ams_delta_keymap), 336 .keymap_size = ARRAY_SIZE(ams_delta_keymap),
200}; 337};
201 338
202static struct omap_kp_platform_data ams_delta_kp_data __initdata = { 339static struct omap_kp_platform_data ams_delta_kp_data = {
203 .rows = 8, 340 .rows = 8,
204 .cols = 8, 341 .cols = 8,
205 .keymap_data = &ams_delta_keymap_data, 342 .keymap_data = &ams_delta_keymap_data,
@@ -221,9 +358,45 @@ static struct platform_device ams_delta_lcd_device = {
221 .id = -1, 358 .id = -1,
222}; 359};
223 360
224static struct platform_device ams_delta_led_device = { 361static const struct gpio_led gpio_leds[] __initconst = {
225 .name = "ams-delta-led", 362 {
226 .id = -1 363 .name = "camera",
364 .gpio = LATCH1_GPIO_BASE + 0,
365 .default_state = LEDS_GPIO_DEFSTATE_OFF,
366#ifdef CONFIG_LEDS_TRIGGERS
367 .default_trigger = "ams_delta_camera",
368#endif
369 },
370 {
371 .name = "advert",
372 .gpio = LATCH1_GPIO_BASE + 1,
373 .default_state = LEDS_GPIO_DEFSTATE_OFF,
374 },
375 {
376 .name = "email",
377 .gpio = LATCH1_GPIO_BASE + 2,
378 .default_state = LEDS_GPIO_DEFSTATE_OFF,
379 },
380 {
381 .name = "handsfree",
382 .gpio = LATCH1_GPIO_BASE + 3,
383 .default_state = LEDS_GPIO_DEFSTATE_OFF,
384 },
385 {
386 .name = "voicemail",
387 .gpio = LATCH1_GPIO_BASE + 4,
388 .default_state = LEDS_GPIO_DEFSTATE_OFF,
389 },
390 {
391 .name = "voice",
392 .gpio = LATCH1_GPIO_BASE + 5,
393 .default_state = LEDS_GPIO_DEFSTATE_OFF,
394 },
395};
396
397static const struct gpio_led_platform_data leds_pdata __initconst = {
398 .leds = gpio_leds,
399 .num_leds = ARRAY_SIZE(gpio_leds),
227}; 400};
228 401
229static struct i2c_board_info ams_delta_camera_board_info[] = { 402static struct i2c_board_info ams_delta_camera_board_info[] = {
@@ -272,13 +445,17 @@ static struct omap1_cam_platform_data ams_delta_camera_platform_data = {
272}; 445};
273 446
274static struct platform_device *ams_delta_devices[] __initdata = { 447static struct platform_device *ams_delta_devices[] __initdata = {
275 &ams_delta_nand_device, 448 &latch1_gpio_device,
449 &latch2_gpio_device,
276 &ams_delta_kp_device, 450 &ams_delta_kp_device,
277 &ams_delta_lcd_device,
278 &ams_delta_led_device,
279 &ams_delta_camera_device, 451 &ams_delta_camera_device,
280}; 452};
281 453
454static struct platform_device *late_devices[] __initdata = {
455 &ams_delta_nand_device,
456 &ams_delta_lcd_device,
457};
458
282static void __init ams_delta_init(void) 459static void __init ams_delta_init(void)
283{ 460{
284 /* mux pins for uarts */ 461 /* mux pins for uarts */
@@ -302,15 +479,13 @@ static void __init ams_delta_init(void)
302 omap_serial_init(); 479 omap_serial_init();
303 omap_register_i2c_bus(1, 100, NULL, 0); 480 omap_register_i2c_bus(1, 100, NULL, 0);
304 481
305 /* Clear latch2 (NAND, LCD, modem enable) */
306 ams_delta_latch2_write(~0, 0);
307
308 omap1_usb_init(&ams_delta_usb_config); 482 omap1_usb_init(&ams_delta_usb_config);
309 omap1_set_camera_info(&ams_delta_camera_platform_data); 483 omap1_set_camera_info(&ams_delta_camera_platform_data);
310#ifdef CONFIG_LEDS_TRIGGERS 484#ifdef CONFIG_LEDS_TRIGGERS
311 led_trigger_register_simple("ams_delta_camera", 485 led_trigger_register_simple("ams_delta_camera",
312 &ams_delta_camera_led_trigger); 486 &ams_delta_camera_led_trigger);
313#endif 487#endif
488 gpio_led_register_device(-1, &leds_pdata);
314 platform_add_devices(ams_delta_devices, ARRAY_SIZE(ams_delta_devices)); 489 platform_add_devices(ams_delta_devices, ARRAY_SIZE(ams_delta_devices));
315 490
316 ams_delta_init_fiq(); 491 ams_delta_init_fiq();
@@ -320,16 +495,34 @@ static void __init ams_delta_init(void)
320 omapfb_set_lcd_config(&ams_delta_lcd_config); 495 omapfb_set_lcd_config(&ams_delta_lcd_config);
321} 496}
322 497
498static void modem_pm(struct uart_port *port, unsigned int state, unsigned old)
499{
500 struct modem_private_data *priv = port->private_data;
501
502 if (IS_ERR(priv->regulator))
503 return;
504
505 if (state == old)
506 return;
507
508 if (state == 0)
509 regulator_enable(priv->regulator);
510 else if (old == 0)
511 regulator_disable(priv->regulator);
512}
513
323static struct plat_serial8250_port ams_delta_modem_ports[] = { 514static struct plat_serial8250_port ams_delta_modem_ports[] = {
324 { 515 {
325 .membase = IOMEM(AMS_DELTA_MODEM_VIRT), 516 .membase = IOMEM(MODEM_VIRT),
326 .mapbase = AMS_DELTA_MODEM_PHYS, 517 .mapbase = MODEM_PHYS,
327 .irq = -EINVAL, /* changed later */ 518 .irq = -EINVAL, /* changed later */
328 .flags = UPF_BOOT_AUTOCONF, 519 .flags = UPF_BOOT_AUTOCONF,
329 .irqflags = IRQF_TRIGGER_RISING, 520 .irqflags = IRQF_TRIGGER_RISING,
330 .iotype = UPIO_MEM, 521 .iotype = UPIO_MEM,
331 .regshift = 1, 522 .regshift = 1,
332 .uartclk = BASE_BAUD * 16, 523 .uartclk = BASE_BAUD * 16,
524 .pm = modem_pm,
525 .private_data = &modem_priv,
333 }, 526 },
334 { }, 527 { },
335}; 528};
@@ -342,13 +535,27 @@ static struct platform_device ams_delta_modem_device = {
342 }, 535 },
343}; 536};
344 537
345static int __init ams_delta_modem_init(void) 538static int __init late_init(void)
346{ 539{
347 int err; 540 int err;
348 541
349 if (!machine_is_ams_delta()) 542 if (!machine_is_ams_delta())
350 return -ENODEV; 543 return -ENODEV;
351 544
545 err = gpio_request_array(latch_gpios, ARRAY_SIZE(latch_gpios));
546 if (err) {
547 pr_err("Couldn't take over latch1/latch2 GPIO pins\n");
548 return err;
549 }
550
551 platform_add_devices(late_devices, ARRAY_SIZE(late_devices));
552
553 err = platform_device_register(&modem_nreset_device);
554 if (err) {
555 pr_err("Couldn't register the modem regulator device\n");
556 return err;
557 }
558
352 omap_cfg_reg(M14_1510_GPIO2); 559 omap_cfg_reg(M14_1510_GPIO2);
353 ams_delta_modem_ports[0].irq = 560 ams_delta_modem_ports[0].irq =
354 gpio_to_irq(AMS_DELTA_GPIO_PIN_MODEM_IRQ); 561 gpio_to_irq(AMS_DELTA_GPIO_PIN_MODEM_IRQ);
@@ -360,13 +567,35 @@ static int __init ams_delta_modem_init(void)
360 } 567 }
361 gpio_direction_input(AMS_DELTA_GPIO_PIN_MODEM_IRQ); 568 gpio_direction_input(AMS_DELTA_GPIO_PIN_MODEM_IRQ);
362 569
363 ams_delta_latch2_write( 570 /* Initialize the modem_nreset regulator consumer before use */
364 AMS_DELTA_LATCH2_MODEM_NRESET | AMS_DELTA_LATCH2_MODEM_CODEC, 571 modem_priv.regulator = ERR_PTR(-ENODEV);
365 AMS_DELTA_LATCH2_MODEM_NRESET | AMS_DELTA_LATCH2_MODEM_CODEC); 572
573 ams_delta_latch2_write(AMS_DELTA_LATCH2_MODEM_CODEC,
574 AMS_DELTA_LATCH2_MODEM_CODEC);
366 575
367 return platform_device_register(&ams_delta_modem_device); 576 err = platform_device_register(&ams_delta_modem_device);
577 if (err)
578 goto gpio_free;
579
580 /*
581 * Once the modem device is registered, the modem_nreset
582 * regulator can be requested on behalf of that device.
583 */
584 modem_priv.regulator = regulator_get(&ams_delta_modem_device.dev,
585 "RESET#");
586 if (IS_ERR(modem_priv.regulator)) {
587 err = PTR_ERR(modem_priv.regulator);
588 goto unregister;
589 }
590 return 0;
591
592unregister:
593 platform_device_unregister(&ams_delta_modem_device);
594gpio_free:
595 gpio_free(AMS_DELTA_GPIO_PIN_MODEM_IRQ);
596 return err;
368} 597}
369arch_initcall(ams_delta_modem_init); 598late_initcall(late_init);
370 599
371static void __init ams_delta_map_io(void) 600static void __init ams_delta_map_io(void)
372{ 601{
@@ -385,6 +614,3 @@ MACHINE_START(AMS_DELTA, "Amstrad E3 (Delta)")
385 .timer = &omap1_timer, 614 .timer = &omap1_timer,
386 .restart = omap1_restart, 615 .restart = omap1_restart,
387MACHINE_END 616MACHINE_END
388
389EXPORT_SYMBOL(ams_delta_latch1_write);
390EXPORT_SYMBOL(ams_delta_latch2_write);