aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap1/board-ams-delta.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-03-27 19:27:28 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-03-27 19:27:28 -0400
commit1bfecd935849a45b6b47d9f011e1c278ff880512 (patch)
tree23c08a9c103c92e5a4a4cd3311823426c9d2bdf9 /arch/arm/mach-omap1/board-ams-delta.c
parent281b05392fc2cb26209b4d85abaf4889ab1991f3 (diff)
parenta754a87ce8b17024358c1be8ee0232ef09a7055f (diff)
Merge tag 'boards' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc
Pull "ARM: board specific updates" from Arnd Bergmann/Olof Johansson: "These changes are all specific to one board only. We're trying to keep the number of board files low, but generally board level updates are ok on platforms that are working on moving towards DT based probing, which will eventually lead to removing them. The board-ams-delta.c board file gets a conflict between the removal of ams_delta_config and the addition of a lot of other data. The Kconfig file has two changes in the same line, and in exynos, the power domain cleanup conflicts with the addition of the image sensor device. Signed-off-by: Arnd Bergmann <arnd@arndb.de> [olof: Amended a fix for a mismerge to board-omap4panda.c] Signed-off-by: Olof Johansson <olof@lixom.net>" Fixed up some fairly trivial conflicts manually. * tag 'boards' of git://git.kernel.org/pub/scm/linux/kernel/git/arm/arm-soc: (82 commits) i.MX35-PDK: Add Camera support ARM : mx35: 3ds-board: add framebuffer device pxa/hx4700: Remove pcmcia platform_device structure ARM: pxa/hx4700: Reduce sleep mode battery discharge by 35% ARM: pxa/hx4700: Remove unwanted request for GPIO105 ARM: EXYNOS: support Exynos4210-bus Devfreq driver on Nuri board ARM: EXYNOS: Register JPEG on nuri ARM: EXYNOS: Register JPEG on universal_c210 ARM: S5PV210: Enable JPEG on SMDKV210 ARM: S5PV210: Add JPEG board definition ARM: EXYNOS: Enable JPEG on Origen ARM: EXYNOS: Enable JPEG on SMDKV310 ARM: EXYNOS: Add __init attribute to universal_camera_init() ARM: EXYNOS: Add __init attribute to nuri_camera_init() ARM: S5PV210: Enable FIMC on SMDKC110 ARM: S5PV210: Enable FIMC on SMDKV210 ARM: S5PV210: Enable MFC on SMDKC110 ARM: S5PV210: Enable MFC on SMDKV210 ARM: EXYNOS: Enable G2D on SMDKV310 ARM: tegra: update defconfig ...
Diffstat (limited to 'arch/arm/mach-omap1/board-ams-delta.c')
-rw-r--r--arch/arm/mach-omap1/board-ams-delta.c314
1 files changed, 269 insertions, 45 deletions
diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
index 83eac744ddb9..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,6 +19,9 @@
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>
@@ -43,9 +47,6 @@
43#include "iomap.h" 47#include "iomap.h"
44#include "common.h" 48#include "common.h"
45 49
46static u8 ams_delta_latch1_reg;
47static u16 ams_delta_latch2_reg;
48
49static const unsigned int ams_delta_keymap[] = { 50static const unsigned int ams_delta_keymap[] = {
50 KEY(0, 0, KEY_F1), /* Advert */ 51 KEY(0, 0, KEY_F1), /* Advert */
51 52
@@ -124,54 +125,188 @@ static const unsigned int ams_delta_keymap[] = {
124 KEY(7, 3, KEY_LEFTCTRL), /* Vol down */ 125 KEY(7, 3, KEY_LEFTCTRL), /* Vol down */
125}; 126};
126 127
127void ams_delta_latch1_write(u8 mask, u8 value) 128#define LATCH1_PHYS 0x01000000
128{ 129#define LATCH1_VIRT 0xEA000000
129 ams_delta_latch1_reg &= ~mask; 130#define MODEM_PHYS 0x04000000
130 ams_delta_latch1_reg |= value; 131#define MODEM_VIRT 0xEB000000
131 *(volatile __u8 *) AMS_DELTA_LATCH1_VIRT = ams_delta_latch1_reg; 132#define LATCH2_PHYS 0x08000000
132} 133#define LATCH2_VIRT 0xEC000000
133
134void ams_delta_latch2_write(u16 mask, u16 value)
135{
136 ams_delta_latch2_reg &= ~mask;
137 ams_delta_latch2_reg |= value;
138 *(volatile __u16 *) AMS_DELTA_LATCH2_VIRT = ams_delta_latch2_reg;
139}
140 134
141static struct map_desc ams_delta_io_desc[] __initdata = { 135static struct map_desc ams_delta_io_desc[] __initdata = {
142 /* AMS_DELTA_LATCH1 */ 136 /* AMS_DELTA_LATCH1 */
143 { 137 {
144 .virtual = AMS_DELTA_LATCH1_VIRT, 138 .virtual = LATCH1_VIRT,
145 .pfn = __phys_to_pfn(AMS_DELTA_LATCH1_PHYS), 139 .pfn = __phys_to_pfn(LATCH1_PHYS),
146 .length = 0x01000000, 140 .length = 0x01000000,
147 .type = MT_DEVICE 141 .type = MT_DEVICE
148 }, 142 },
149 /* AMS_DELTA_LATCH2 */ 143 /* AMS_DELTA_LATCH2 */
150 { 144 {
151 .virtual = AMS_DELTA_LATCH2_VIRT, 145 .virtual = LATCH2_VIRT,
152 .pfn = __phys_to_pfn(AMS_DELTA_LATCH2_PHYS), 146 .pfn = __phys_to_pfn(LATCH2_PHYS),
153 .length = 0x01000000, 147 .length = 0x01000000,
154 .type = MT_DEVICE 148 .type = MT_DEVICE
155 }, 149 },
156 /* AMS_DELTA_MODEM */ 150 /* AMS_DELTA_MODEM */
157 { 151 {
158 .virtual = AMS_DELTA_MODEM_VIRT, 152 .virtual = MODEM_VIRT,
159 .pfn = __phys_to_pfn(AMS_DELTA_MODEM_PHYS), 153 .pfn = __phys_to_pfn(MODEM_PHYS),
160 .length = 0x01000000, 154 .length = 0x01000000,
161 .type = MT_DEVICE 155 .type = MT_DEVICE
162 } 156 }
163}; 157};
164 158
165static struct omap_lcd_config ams_delta_lcd_config = { 159static struct omap_lcd_config ams_delta_lcd_config __initdata = {
166 .ctrl_name = "internal", 160 .ctrl_name = "internal",
167}; 161};
168 162
169static struct omap_usb_config ams_delta_usb_config __initdata = { 163static struct omap_usb_config ams_delta_usb_config = {
170 .register_host = 1, 164 .register_host = 1,
171 .hmc_mode = 16, 165 .hmc_mode = 16,
172 .pins[0] = 2, 166 .pins[0] = 2,
173}; 167};
174 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
175static struct resource ams_delta_nand_resources[] = { 310static struct resource ams_delta_nand_resources[] = {
176 [0] = { 311 [0] = {
177 .start = OMAP1_MPUIO_BASE, 312 .start = OMAP1_MPUIO_BASE,
@@ -201,7 +336,7 @@ static const struct matrix_keymap_data ams_delta_keymap_data = {
201 .keymap_size = ARRAY_SIZE(ams_delta_keymap), 336 .keymap_size = ARRAY_SIZE(ams_delta_keymap),
202}; 337};
203 338
204static struct omap_kp_platform_data ams_delta_kp_data __initdata = { 339static struct omap_kp_platform_data ams_delta_kp_data = {
205 .rows = 8, 340 .rows = 8,
206 .cols = 8, 341 .cols = 8,
207 .keymap_data = &ams_delta_keymap_data, 342 .keymap_data = &ams_delta_keymap_data,
@@ -223,9 +358,45 @@ static struct platform_device ams_delta_lcd_device = {
223 .id = -1, 358 .id = -1,
224}; 359};
225 360
226static struct platform_device ams_delta_led_device = { 361static const struct gpio_led gpio_leds[] __initconst = {
227 .name = "ams-delta-led", 362 {
228 .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),
229}; 400};
230 401
231static struct i2c_board_info ams_delta_camera_board_info[] = { 402static struct i2c_board_info ams_delta_camera_board_info[] = {
@@ -274,13 +445,17 @@ static struct omap1_cam_platform_data ams_delta_camera_platform_data = {
274}; 445};
275 446
276static struct platform_device *ams_delta_devices[] __initdata = { 447static struct platform_device *ams_delta_devices[] __initdata = {
277 &ams_delta_nand_device, 448 &latch1_gpio_device,
449 &latch2_gpio_device,
278 &ams_delta_kp_device, 450 &ams_delta_kp_device,
279 &ams_delta_lcd_device,
280 &ams_delta_led_device,
281 &ams_delta_camera_device, 451 &ams_delta_camera_device,
282}; 452};
283 453
454static struct platform_device *late_devices[] __initdata = {
455 &ams_delta_nand_device,
456 &ams_delta_lcd_device,
457};
458
284static void __init ams_delta_init(void) 459static void __init ams_delta_init(void)
285{ 460{
286 /* mux pins for uarts */ 461 /* mux pins for uarts */
@@ -304,15 +479,13 @@ static void __init ams_delta_init(void)
304 omap_serial_init(); 479 omap_serial_init();
305 omap_register_i2c_bus(1, 100, NULL, 0); 480 omap_register_i2c_bus(1, 100, NULL, 0);
306 481
307 /* Clear latch2 (NAND, LCD, modem enable) */
308 ams_delta_latch2_write(~0, 0);
309
310 omap1_usb_init(&ams_delta_usb_config); 482 omap1_usb_init(&ams_delta_usb_config);
311 omap1_set_camera_info(&ams_delta_camera_platform_data); 483 omap1_set_camera_info(&ams_delta_camera_platform_data);
312#ifdef CONFIG_LEDS_TRIGGERS 484#ifdef CONFIG_LEDS_TRIGGERS
313 led_trigger_register_simple("ams_delta_camera", 485 led_trigger_register_simple("ams_delta_camera",
314 &ams_delta_camera_led_trigger); 486 &ams_delta_camera_led_trigger);
315#endif 487#endif
488 gpio_led_register_device(-1, &leds_pdata);
316 platform_add_devices(ams_delta_devices, ARRAY_SIZE(ams_delta_devices)); 489 platform_add_devices(ams_delta_devices, ARRAY_SIZE(ams_delta_devices));
317 490
318 ams_delta_init_fiq(); 491 ams_delta_init_fiq();
@@ -322,16 +495,34 @@ static void __init ams_delta_init(void)
322 omapfb_set_lcd_config(&ams_delta_lcd_config); 495 omapfb_set_lcd_config(&ams_delta_lcd_config);
323} 496}
324 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
325static struct plat_serial8250_port ams_delta_modem_ports[] = { 514static struct plat_serial8250_port ams_delta_modem_ports[] = {
326 { 515 {
327 .membase = IOMEM(AMS_DELTA_MODEM_VIRT), 516 .membase = IOMEM(MODEM_VIRT),
328 .mapbase = AMS_DELTA_MODEM_PHYS, 517 .mapbase = MODEM_PHYS,
329 .irq = -EINVAL, /* changed later */ 518 .irq = -EINVAL, /* changed later */
330 .flags = UPF_BOOT_AUTOCONF, 519 .flags = UPF_BOOT_AUTOCONF,
331 .irqflags = IRQF_TRIGGER_RISING, 520 .irqflags = IRQF_TRIGGER_RISING,
332 .iotype = UPIO_MEM, 521 .iotype = UPIO_MEM,
333 .regshift = 1, 522 .regshift = 1,
334 .uartclk = BASE_BAUD * 16, 523 .uartclk = BASE_BAUD * 16,
524 .pm = modem_pm,
525 .private_data = &modem_priv,
335 }, 526 },
336 { }, 527 { },
337}; 528};
@@ -344,13 +535,27 @@ static struct platform_device ams_delta_modem_device = {
344 }, 535 },
345}; 536};
346 537
347static int __init ams_delta_modem_init(void) 538static int __init late_init(void)
348{ 539{
349 int err; 540 int err;
350 541
351 if (!machine_is_ams_delta()) 542 if (!machine_is_ams_delta())
352 return -ENODEV; 543 return -ENODEV;
353 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
354 omap_cfg_reg(M14_1510_GPIO2); 559 omap_cfg_reg(M14_1510_GPIO2);
355 ams_delta_modem_ports[0].irq = 560 ams_delta_modem_ports[0].irq =
356 gpio_to_irq(AMS_DELTA_GPIO_PIN_MODEM_IRQ); 561 gpio_to_irq(AMS_DELTA_GPIO_PIN_MODEM_IRQ);
@@ -362,13 +567,35 @@ static int __init ams_delta_modem_init(void)
362 } 567 }
363 gpio_direction_input(AMS_DELTA_GPIO_PIN_MODEM_IRQ); 568 gpio_direction_input(AMS_DELTA_GPIO_PIN_MODEM_IRQ);
364 569
365 ams_delta_latch2_write( 570 /* Initialize the modem_nreset regulator consumer before use */
366 AMS_DELTA_LATCH2_MODEM_NRESET | AMS_DELTA_LATCH2_MODEM_CODEC, 571 modem_priv.regulator = ERR_PTR(-ENODEV);
367 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);
575
576 err = platform_device_register(&ams_delta_modem_device);
577 if (err)
578 goto gpio_free;
368 579
369 return platform_device_register(&ams_delta_modem_device); 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;
370} 597}
371arch_initcall(ams_delta_modem_init); 598late_initcall(late_init);
372 599
373static void __init ams_delta_map_io(void) 600static void __init ams_delta_map_io(void)
374{ 601{
@@ -387,6 +614,3 @@ MACHINE_START(AMS_DELTA, "Amstrad E3 (Delta)")
387 .timer = &omap1_timer, 614 .timer = &omap1_timer,
388 .restart = omap1_restart, 615 .restart = omap1_restart,
389MACHINE_END 616MACHINE_END
390
391EXPORT_SYMBOL(ams_delta_latch1_write);
392EXPORT_SYMBOL(ams_delta_latch2_write);