aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/mach-omap1/board-osk.c108
-rw-r--r--arch/arm/mach-omap1/leds-osk.c80
-rw-r--r--include/asm-arm/arch-omap/board-osk.h11
3 files changed, 82 insertions, 117 deletions
diff --git a/arch/arm/mach-omap1/board-osk.c b/arch/arm/mach-omap1/board-osk.c
index dd9ece8f409f..4f9baba7d893 100644
--- a/arch/arm/mach-omap1/board-osk.c
+++ b/arch/arm/mach-omap1/board-osk.c
@@ -32,6 +32,7 @@
32#include <linux/interrupt.h> 32#include <linux/interrupt.h>
33#include <linux/irq.h> 33#include <linux/irq.h>
34#include <linux/i2c.h> 34#include <linux/i2c.h>
35#include <linux/leds.h>
35 36
36#include <linux/mtd/mtd.h> 37#include <linux/mtd/mtd.h>
37#include <linux/mtd/partitions.h> 38#include <linux/mtd/partitions.h>
@@ -183,11 +184,80 @@ static struct platform_device *osk5912_devices[] __initdata = {
183 &osk5912_mcbsp1_device, 184 &osk5912_mcbsp1_device,
184}; 185};
185 186
187static struct gpio_led tps_leds[] = {
188 /* NOTE: D9 and D2 have hardware blink support.
189 * Also, D9 requires non-battery power.
190 */
191 { .gpio = OSK_TPS_GPIO_LED_D9, .name = "d9", },
192 { .gpio = OSK_TPS_GPIO_LED_D2, .name = "d2", },
193 { .gpio = OSK_TPS_GPIO_LED_D3, .name = "d3", .active_low = 1,
194 .default_trigger = "heartbeat", },
195};
196
197static struct gpio_led_platform_data tps_leds_data = {
198 .num_leds = 3,
199 .leds = tps_leds,
200};
201
202static struct platform_device osk5912_tps_leds = {
203 .name = "leds-gpio",
204 .id = 0,
205 .dev.platform_data = &tps_leds_data,
206};
207
208static int osk_tps_setup(struct i2c_client *client, void *context)
209{
210 /* Set GPIO 1 HIGH to disable VBUS power supply;
211 * OHCI driver powers it up/down as needed.
212 */
213 gpio_request(OSK_TPS_GPIO_USB_PWR_EN, "n_vbus_en");
214 gpio_direction_output(OSK_TPS_GPIO_USB_PWR_EN, 1);
215
216 /* Set GPIO 2 high so LED D3 is off by default */
217 tps65010_set_gpio_out_value(GPIO2, HIGH);
218
219 /* Set GPIO 3 low to take ethernet out of reset */
220 gpio_request(OSK_TPS_GPIO_LAN_RESET, "smc_reset");
221 gpio_direction_output(OSK_TPS_GPIO_LAN_RESET, 0);
222
223 /* GPIO4 is VDD_DSP */
224 gpio_request(OSK_TPS_GPIO_DSP_PWR_EN, "dsp_power");
225 gpio_direction_output(OSK_TPS_GPIO_DSP_PWR_EN, 1);
226 /* REVISIT if DSP support isn't configured, power it off ... */
227
228 /* Let LED1 (D9) blink; leds-gpio may override it */
229 tps65010_set_led(LED1, BLINK);
230
231 /* Set LED2 off by default */
232 tps65010_set_led(LED2, OFF);
233
234 /* Enable LOW_PWR handshake */
235 tps65010_set_low_pwr(ON);
236
237 /* Switch VLDO2 to 3.0V for AIC23 */
238 tps65010_config_vregs1(TPS_LDO2_ENABLE | TPS_VLDO2_3_0V
239 | TPS_LDO1_ENABLE);
240
241 /* register these three LEDs */
242 osk5912_tps_leds.dev.parent = &client->dev;
243 platform_device_register(&osk5912_tps_leds);
244
245 return 0;
246}
247
248static struct tps65010_board tps_board = {
249 .base = OSK_TPS_GPIO_BASE,
250 .outmask = 0x0f,
251 .setup = osk_tps_setup,
252};
253
186static struct i2c_board_info __initdata osk_i2c_board_info[] = { 254static struct i2c_board_info __initdata osk_i2c_board_info[] = {
187 { 255 {
188 I2C_BOARD_INFO("tps65010", 0x48), 256 I2C_BOARD_INFO("tps65010", 0x48),
189 .type = "tps65010", 257 .type = "tps65010",
190 .irq = OMAP_GPIO_IRQ(OMAP_MPUIO(1)), 258 .irq = OMAP_GPIO_IRQ(OMAP_MPUIO(1)),
259 .platform_data = &tps_board,
260
191 }, 261 },
192 /* TODO when driver support is ready: 262 /* TODO when driver support is ready:
193 * - aic23 audio chip at 0x1a 263 * - aic23 audio chip at 0x1a
@@ -488,44 +558,6 @@ static void __init osk_map_io(void)
488 omap1_map_common_io(); 558 omap1_map_common_io();
489} 559}
490 560
491#ifdef CONFIG_TPS65010
492static int __init osk_tps_init(void)
493{
494 if (!machine_is_omap_osk())
495 return 0;
496
497 /* Let LED1 (D9) blink */
498 tps65010_set_led(LED1, BLINK);
499
500 /* Disable LED 2 (D2) */
501 tps65010_set_led(LED2, OFF);
502
503 /* Set GPIO 1 HIGH to disable VBUS power supply;
504 * OHCI driver powers it up/down as needed.
505 */
506 tps65010_set_gpio_out_value(GPIO1, HIGH);
507
508 /* Set GPIO 2 low to turn on LED D3 */
509 tps65010_set_gpio_out_value(GPIO2, HIGH);
510
511 /* Set GPIO 3 low to take ethernet out of reset */
512 tps65010_set_gpio_out_value(GPIO3, LOW);
513
514 /* gpio4 for VDD_DSP */
515 /* FIXME send power to DSP iff it's configured */
516
517 /* Enable LOW_PWR */
518 tps65010_set_low_pwr(ON);
519
520 /* Switch VLDO2 to 3.0V for AIC23 */
521 tps65010_config_vregs1(TPS_LDO2_ENABLE | TPS_VLDO2_3_0V
522 | TPS_LDO1_ENABLE);
523
524 return 0;
525}
526fs_initcall(osk_tps_init);
527#endif
528
529MACHINE_START(OMAP_OSK, "TI-OSK") 561MACHINE_START(OMAP_OSK, "TI-OSK")
530 /* Maintainer: Dirk Behme <dirk.behme@de.bosch.com> */ 562 /* Maintainer: Dirk Behme <dirk.behme@de.bosch.com> */
531 .phys_io = 0xfff00000, 563 .phys_io = 0xfff00000,
diff --git a/arch/arm/mach-omap1/leds-osk.c b/arch/arm/mach-omap1/leds-osk.c
index 026685ed461a..754383dde807 100644
--- a/arch/arm/mach-omap1/leds-osk.c
+++ b/arch/arm/mach-omap1/leds-osk.c
@@ -1,11 +1,9 @@
1/* 1/*
2 * linux/arch/arm/mach-omap1/leds-osk.c 2 * linux/arch/arm/mach-omap1/leds-osk.c
3 * 3 *
4 * LED driver for OSK, and optionally Mistral QVGA, boards 4 * LED driver for OSK with optional Mistral QVGA board
5 */ 5 */
6#include <linux/init.h> 6#include <linux/init.h>
7#include <linux/workqueue.h>
8#include <linux/i2c/tps65010.h>
9 7
10#include <asm/hardware.h> 8#include <asm/hardware.h>
11#include <asm/leds.h> 9#include <asm/leds.h>
@@ -20,49 +18,11 @@
20#define LED_STATE_CLAIMED (1 << 1) 18#define LED_STATE_CLAIMED (1 << 1)
21static u8 led_state; 19static u8 led_state;
22 20
23#define GREEN_LED (1 << 0) /* TPS65010 LED1 */
24#define AMBER_LED (1 << 1) /* TPS65010 LED2 */
25#define RED_LED (1 << 2) /* TPS65010 GPIO2 */
26#define TIMER_LED (1 << 3) /* Mistral board */ 21#define TIMER_LED (1 << 3) /* Mistral board */
27#define IDLE_LED (1 << 4) /* Mistral board */ 22#define IDLE_LED (1 << 4) /* Mistral board */
28static u8 hw_led_state; 23static u8 hw_led_state;
29 24
30 25
31/* TPS65010 leds are changed using i2c -- from a task context.
32 * Using one of these for the "idle" LED would be impractical...
33 */
34#define TPS_LEDS (GREEN_LED | RED_LED | AMBER_LED)
35
36static u8 tps_leds_change;
37
38static void tps_work(struct work_struct *unused)
39{
40 for (;;) {
41 u8 leds;
42
43 local_irq_disable();
44 leds = tps_leds_change;
45 tps_leds_change = 0;
46 local_irq_enable();
47
48 if (!leds)
49 break;
50
51 /* careful: the set_led() value is on/off/blink */
52 if (leds & GREEN_LED)
53 tps65010_set_led(LED1, !!(hw_led_state & GREEN_LED));
54 if (leds & AMBER_LED)
55 tps65010_set_led(LED2, !!(hw_led_state & AMBER_LED));
56
57 /* the gpio led doesn't have that issue */
58 if (leds & RED_LED)
59 tps65010_set_gpio_out_value(GPIO2,
60 !(hw_led_state & RED_LED));
61 }
62}
63
64static DECLARE_WORK(work, tps_work);
65
66#ifdef CONFIG_OMAP_OSK_MISTRAL 26#ifdef CONFIG_OMAP_OSK_MISTRAL
67 27
68/* For now, all system indicators require the Mistral board, since that 28/* For now, all system indicators require the Mistral board, since that
@@ -112,7 +72,6 @@ void osk_leds_event(led_event_t evt)
112 case led_stop: 72 case led_stop:
113 led_state &= ~LED_STATE_ENABLED; 73 led_state &= ~LED_STATE_ENABLED;
114 hw_led_state = 0; 74 hw_led_state = 0;
115 /* NOTE: work may still be pending!! */
116 break; 75 break;
117 76
118 case led_claim: 77 case led_claim:
@@ -145,48 +104,11 @@ void osk_leds_event(led_event_t evt)
145 104
146#endif /* CONFIG_OMAP_OSK_MISTRAL */ 105#endif /* CONFIG_OMAP_OSK_MISTRAL */
147 106
148 /* "green" == tps LED1 (leftmost, normally power-good)
149 * works only with DC adapter, not on battery power!
150 */
151 case led_green_on:
152 if (led_state & LED_STATE_CLAIMED)
153 hw_led_state |= GREEN_LED;
154 break;
155 case led_green_off:
156 if (led_state & LED_STATE_CLAIMED)
157 hw_led_state &= ~GREEN_LED;
158 break;
159
160 /* "amber" == tps LED2 (middle) */
161 case led_amber_on:
162 if (led_state & LED_STATE_CLAIMED)
163 hw_led_state |= AMBER_LED;
164 break;
165 case led_amber_off:
166 if (led_state & LED_STATE_CLAIMED)
167 hw_led_state &= ~AMBER_LED;
168 break;
169
170 /* "red" == LED on tps gpio3 (rightmost) */
171 case led_red_on:
172 if (led_state & LED_STATE_CLAIMED)
173 hw_led_state |= RED_LED;
174 break;
175 case led_red_off:
176 if (led_state & LED_STATE_CLAIMED)
177 hw_led_state &= ~RED_LED;
178 break;
179
180 default: 107 default:
181 break; 108 break;
182 } 109 }
183 110
184 leds ^= hw_led_state; 111 leds ^= hw_led_state;
185 leds &= TPS_LEDS;
186 if (leds && (led_state & LED_STATE_CLAIMED)) {
187 tps_leds_change |= leds;
188 schedule_work(&work);
189 }
190 112
191done: 113done:
192 local_irq_restore(flags); 114 local_irq_restore(flags);
diff --git a/include/asm-arm/arch-omap/board-osk.h b/include/asm-arm/arch-omap/board-osk.h
index 2b1a8a4fe44e..94926090e475 100644
--- a/include/asm-arm/arch-omap/board-osk.h
+++ b/include/asm-arm/arch-omap/board-osk.h
@@ -32,5 +32,16 @@
32/* At OMAP5912 OSK the Ethernet is directly connected to CS1 */ 32/* At OMAP5912 OSK the Ethernet is directly connected to CS1 */
33#define OMAP_OSK_ETHR_START 0x04800300 33#define OMAP_OSK_ETHR_START 0x04800300
34 34
35/* TPS65010 has four GPIOs. nPG and LED2 can be treated like GPIOs with
36 * alternate pin configurations for hardware-controlled blinking.
37 */
38#define OSK_TPS_GPIO_BASE (OMAP_MAX_GPIO_LINES + 16 /* MPUIO */)
39# define OSK_TPS_GPIO_USB_PWR_EN (OSK_TPS_GPIO_BASE + 0)
40# define OSK_TPS_GPIO_LED_D3 (OSK_TPS_GPIO_BASE + 1)
41# define OSK_TPS_GPIO_LAN_RESET (OSK_TPS_GPIO_BASE + 2)
42# define OSK_TPS_GPIO_DSP_PWR_EN (OSK_TPS_GPIO_BASE + 3)
43# define OSK_TPS_GPIO_LED_D9 (OSK_TPS_GPIO_BASE + 4)
44# define OSK_TPS_GPIO_LED_D2 (OSK_TPS_GPIO_BASE + 5)
45
35#endif /* __ASM_ARCH_OMAP_OSK_H */ 46#endif /* __ASM_ARCH_OMAP_OSK_H */
36 47