Commit ad9f072c2e3b6b4b198f171cb1ba6c0e7fc3e06e
Committed by
Tom Rini
1 parent
890880583d
Exists in
master
and in
50 other branches
tricorder: add led support
Signed-off-by: Andreas Bießmann <andreas.biessmann@corscience.de>
Showing 5 changed files with 100 additions and 6 deletions Side-by-side Diff
board/corscience/tricorder/Makefile
board/corscience/tricorder/led.c
1 | +/* | |
2 | + * Copyright (c) 2013 Corscience GmbH & Co.KG | |
3 | + * Andreas Bießmann <andreas.biessmann@corscience.de> | |
4 | + * | |
5 | + * SPDX-License-Identifier: GPL-2.0+ | |
6 | + */ | |
7 | +#include <common.h> | |
8 | +#include <status_led.h> | |
9 | +#include <twl4030.h> | |
10 | +#include <asm/arch/cpu.h> | |
11 | +#include <asm/io.h> | |
12 | +#include <asm/arch/sys_proto.h> | |
13 | +#include <asm/gpio.h> | |
14 | + | |
15 | +#define TRICORDER_STATUS_LED_YELLOW 42 | |
16 | +#define TRICORDER_STATUS_LED_GREEN 43 | |
17 | + | |
18 | +void __led_init(led_id_t mask, int state) | |
19 | +{ | |
20 | + __led_set(mask, state); | |
21 | +} | |
22 | + | |
23 | +void __led_toggle(led_id_t mask) | |
24 | +{ | |
25 | + int toggle_gpio = 0; | |
26 | +#ifdef STATUS_LED_BIT | |
27 | + if (!toggle_gpio && STATUS_LED_BIT & mask) | |
28 | + toggle_gpio = TRICORDER_STATUS_LED_GREEN; | |
29 | +#endif | |
30 | +#ifdef STATUS_LED_BIT1 | |
31 | + if (!toggle_gpio && STATUS_LED_BIT1 & mask) | |
32 | + toggle_gpio = TRICORDER_STATUS_LED_YELLOW; | |
33 | +#endif | |
34 | +#ifdef STATUS_LED_BIT2 | |
35 | + if (!toggle_gpio && STATUS_LED_BIT2 & mask) { | |
36 | + uint8_t val; | |
37 | + twl4030_i2c_read_u8(TWL4030_CHIP_LED, TWL4030_LED_LEDEN, | |
38 | + &val); | |
39 | + val ^= (TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDAPWM); | |
40 | + twl4030_i2c_write_u8(TWL4030_CHIP_LED, TWL4030_LED_LEDEN, | |
41 | + val); | |
42 | + } | |
43 | +#endif | |
44 | + if (toggle_gpio) { | |
45 | + int state; | |
46 | + gpio_request(toggle_gpio, ""); | |
47 | + state = gpio_get_value(toggle_gpio); | |
48 | + gpio_set_value(toggle_gpio, !state); | |
49 | + } | |
50 | +} | |
51 | + | |
52 | +void __led_set(led_id_t mask, int state) | |
53 | +{ | |
54 | +#ifdef STATUS_LED_BIT | |
55 | + if (STATUS_LED_BIT & mask) { | |
56 | + gpio_request(TRICORDER_STATUS_LED_GREEN, ""); | |
57 | + gpio_direction_output(TRICORDER_STATUS_LED_GREEN, 0); | |
58 | + gpio_set_value(TRICORDER_STATUS_LED_GREEN, state); | |
59 | + } | |
60 | +#endif | |
61 | +#ifdef STATUS_LED_BIT1 | |
62 | + if (STATUS_LED_BIT1 & mask) { | |
63 | + gpio_request(TRICORDER_STATUS_LED_YELLOW, ""); | |
64 | + gpio_direction_output(TRICORDER_STATUS_LED_YELLOW, 0); | |
65 | + gpio_set_value(TRICORDER_STATUS_LED_YELLOW, state); | |
66 | + } | |
67 | +#endif | |
68 | +#ifdef STATUS_LED_BIT2 | |
69 | + if (STATUS_LED_BIT2 & mask) { | |
70 | + if (STATUS_LED_OFF == state) | |
71 | + twl4030_i2c_write_u8(TWL4030_CHIP_LED, | |
72 | + TWL4030_LED_LEDEN, 0); | |
73 | + else | |
74 | + twl4030_i2c_write_u8(TWL4030_CHIP_LED, | |
75 | + TWL4030_LED_LEDEN, | |
76 | + (TWL4030_LED_LEDEN_LEDAON | | |
77 | + TWL4030_LED_LEDEN_LEDAPWM)); | |
78 | + } | |
79 | +#endif | |
80 | +} |
board/corscience/tricorder/tricorder.c
... | ... | @@ -118,9 +118,9 @@ |
118 | 118 | print_hwversion(&eeprom); |
119 | 119 | |
120 | 120 | twl4030_power_init(); |
121 | -#ifdef CONFIG_TWL4030_LED | |
122 | - twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON); | |
123 | -#endif | |
121 | + status_led_set(0, STATUS_LED_ON); | |
122 | + status_led_set(1, STATUS_LED_ON); | |
123 | + status_led_set(2, STATUS_LED_ON); | |
124 | 124 | |
125 | 125 | dieid_num_r(); |
126 | 126 |
board/corscience/tricorder/tricorder.h
... | ... | @@ -75,8 +75,8 @@ |
75 | 75 | MUX_VAL(CP(GPMC_A6), (IDIS | PTD | DIS | M0)) /*GPMC_A6*/\ |
76 | 76 | MUX_VAL(CP(GPMC_A7), (IDIS | PTD | DIS | M0)) /*GPMC_A7*/\ |
77 | 77 | MUX_VAL(CP(GPMC_A8), (IDIS | PTD | DIS | M0)) /*GPMC_A8*/\ |
78 | - MUX_VAL(CP(GPMC_A9), (IDIS | PTD | DIS | M0)) /*GPMC_A9*/\ | |
79 | - MUX_VAL(CP(GPMC_A10), (IDIS | PTD | DIS | M0)) /*GPMC_A10*/\ | |
78 | + MUX_VAL(CP(GPMC_A9), (IDIS | PTU | EN | M4)) /*GPIO 42*/\ | |
79 | + MUX_VAL(CP(GPMC_A10), (IDIS | PTU | EN | M4)) /*GPIO 43*/\ | |
80 | 80 | MUX_VAL(CP(GPMC_D0), (IEN | PTD | DIS | M0)) /*GPMC_D0*/\ |
81 | 81 | MUX_VAL(CP(GPMC_D1), (IEN | PTD | DIS | M0)) /*GPMC_D1*/\ |
82 | 82 | MUX_VAL(CP(GPMC_D2), (IEN | PTD | DIS | M0)) /*GPMC_D2*/\ |
include/configs/tricorder.h
... | ... | @@ -60,6 +60,20 @@ |
60 | 60 | /* GPIO support */ |
61 | 61 | #define CONFIG_OMAP_GPIO |
62 | 62 | |
63 | +/* LED support */ | |
64 | +#define CONFIG_STATUS_LED | |
65 | +#define CONFIG_BOARD_SPECIFIC_LED | |
66 | +#define CONFIG_CMD_LED /* LED command */ | |
67 | +#define STATUS_LED_BIT (1 << 0) | |
68 | +#define STATUS_LED_STATE STATUS_LED_ON | |
69 | +#define STATUS_LED_PERIOD (CONFIG_SYS_HZ / 2) | |
70 | +#define STATUS_LED_BIT1 (1 << 1) | |
71 | +#define STATUS_LED_STATE1 STATUS_LED_ON | |
72 | +#define STATUS_LED_PERIOD1 (CONFIG_SYS_HZ / 2) | |
73 | +#define STATUS_LED_BIT2 (1 << 2) | |
74 | +#define STATUS_LED_STATE2 STATUS_LED_ON | |
75 | +#define STATUS_LED_PERIOD2 (CONFIG_SYS_HZ / 2) | |
76 | + | |
63 | 77 | /* NS16550 Configuration */ |
64 | 78 | #define CONFIG_SYS_NS16550 |
65 | 79 | #define CONFIG_SYS_NS16550_SERIAL |