mirror of
https://xff.cz/git/u-boot/
synced 2025-09-01 08:42:12 +02:00
tricorder: add led support
Signed-off-by: Andreas Bießmann <andreas.biessmann@corscience.de>
This commit is contained in:
committed by
Tom Rini
parent
890880583d
commit
ad9f072c2e
@@ -12,7 +12,7 @@ include $(TOPDIR)/config.mk
|
|||||||
|
|
||||||
LIB = $(obj)lib$(BOARD).o
|
LIB = $(obj)lib$(BOARD).o
|
||||||
|
|
||||||
COBJS := tricorder.o tricorder-eeprom.o
|
COBJS := tricorder.o tricorder-eeprom.o led.o
|
||||||
|
|
||||||
SRCS := $(COBJS:.o=.c)
|
SRCS := $(COBJS:.o=.c)
|
||||||
OBJS := $(addprefix $(obj),$(COBJS))
|
OBJS := $(addprefix $(obj),$(COBJS))
|
||||||
|
80
board/corscience/tricorder/led.c
Normal file
80
board/corscience/tricorder/led.c
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2013 Corscience GmbH & Co.KG
|
||||||
|
* Andreas Bießmann <andreas.biessmann@corscience.de>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: GPL-2.0+
|
||||||
|
*/
|
||||||
|
#include <common.h>
|
||||||
|
#include <status_led.h>
|
||||||
|
#include <twl4030.h>
|
||||||
|
#include <asm/arch/cpu.h>
|
||||||
|
#include <asm/io.h>
|
||||||
|
#include <asm/arch/sys_proto.h>
|
||||||
|
#include <asm/gpio.h>
|
||||||
|
|
||||||
|
#define TRICORDER_STATUS_LED_YELLOW 42
|
||||||
|
#define TRICORDER_STATUS_LED_GREEN 43
|
||||||
|
|
||||||
|
void __led_init(led_id_t mask, int state)
|
||||||
|
{
|
||||||
|
__led_set(mask, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
void __led_toggle(led_id_t mask)
|
||||||
|
{
|
||||||
|
int toggle_gpio = 0;
|
||||||
|
#ifdef STATUS_LED_BIT
|
||||||
|
if (!toggle_gpio && STATUS_LED_BIT & mask)
|
||||||
|
toggle_gpio = TRICORDER_STATUS_LED_GREEN;
|
||||||
|
#endif
|
||||||
|
#ifdef STATUS_LED_BIT1
|
||||||
|
if (!toggle_gpio && STATUS_LED_BIT1 & mask)
|
||||||
|
toggle_gpio = TRICORDER_STATUS_LED_YELLOW;
|
||||||
|
#endif
|
||||||
|
#ifdef STATUS_LED_BIT2
|
||||||
|
if (!toggle_gpio && STATUS_LED_BIT2 & mask) {
|
||||||
|
uint8_t val;
|
||||||
|
twl4030_i2c_read_u8(TWL4030_CHIP_LED, TWL4030_LED_LEDEN,
|
||||||
|
&val);
|
||||||
|
val ^= (TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDAPWM);
|
||||||
|
twl4030_i2c_write_u8(TWL4030_CHIP_LED, TWL4030_LED_LEDEN,
|
||||||
|
val);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (toggle_gpio) {
|
||||||
|
int state;
|
||||||
|
gpio_request(toggle_gpio, "");
|
||||||
|
state = gpio_get_value(toggle_gpio);
|
||||||
|
gpio_set_value(toggle_gpio, !state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void __led_set(led_id_t mask, int state)
|
||||||
|
{
|
||||||
|
#ifdef STATUS_LED_BIT
|
||||||
|
if (STATUS_LED_BIT & mask) {
|
||||||
|
gpio_request(TRICORDER_STATUS_LED_GREEN, "");
|
||||||
|
gpio_direction_output(TRICORDER_STATUS_LED_GREEN, 0);
|
||||||
|
gpio_set_value(TRICORDER_STATUS_LED_GREEN, state);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef STATUS_LED_BIT1
|
||||||
|
if (STATUS_LED_BIT1 & mask) {
|
||||||
|
gpio_request(TRICORDER_STATUS_LED_YELLOW, "");
|
||||||
|
gpio_direction_output(TRICORDER_STATUS_LED_YELLOW, 0);
|
||||||
|
gpio_set_value(TRICORDER_STATUS_LED_YELLOW, state);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef STATUS_LED_BIT2
|
||||||
|
if (STATUS_LED_BIT2 & mask) {
|
||||||
|
if (STATUS_LED_OFF == state)
|
||||||
|
twl4030_i2c_write_u8(TWL4030_CHIP_LED,
|
||||||
|
TWL4030_LED_LEDEN, 0);
|
||||||
|
else
|
||||||
|
twl4030_i2c_write_u8(TWL4030_CHIP_LED,
|
||||||
|
TWL4030_LED_LEDEN,
|
||||||
|
(TWL4030_LED_LEDEN_LEDAON |
|
||||||
|
TWL4030_LED_LEDEN_LEDAPWM));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
@@ -118,9 +118,9 @@ int misc_init_r(void)
|
|||||||
print_hwversion(&eeprom);
|
print_hwversion(&eeprom);
|
||||||
|
|
||||||
twl4030_power_init();
|
twl4030_power_init();
|
||||||
#ifdef CONFIG_TWL4030_LED
|
status_led_set(0, STATUS_LED_ON);
|
||||||
twl4030_led_init(TWL4030_LED_LEDEN_LEDAON | TWL4030_LED_LEDEN_LEDBON);
|
status_led_set(1, STATUS_LED_ON);
|
||||||
#endif
|
status_led_set(2, STATUS_LED_ON);
|
||||||
|
|
||||||
dieid_num_r();
|
dieid_num_r();
|
||||||
|
|
||||||
|
@@ -75,8 +75,8 @@ const omap3_sysinfo sysinfo = {
|
|||||||
MUX_VAL(CP(GPMC_A6), (IDIS | PTD | DIS | M0)) /*GPMC_A6*/\
|
MUX_VAL(CP(GPMC_A6), (IDIS | PTD | DIS | M0)) /*GPMC_A6*/\
|
||||||
MUX_VAL(CP(GPMC_A7), (IDIS | PTD | DIS | M0)) /*GPMC_A7*/\
|
MUX_VAL(CP(GPMC_A7), (IDIS | PTD | DIS | M0)) /*GPMC_A7*/\
|
||||||
MUX_VAL(CP(GPMC_A8), (IDIS | PTD | DIS | M0)) /*GPMC_A8*/\
|
MUX_VAL(CP(GPMC_A8), (IDIS | PTD | DIS | M0)) /*GPMC_A8*/\
|
||||||
MUX_VAL(CP(GPMC_A9), (IDIS | PTD | DIS | M0)) /*GPMC_A9*/\
|
MUX_VAL(CP(GPMC_A9), (IDIS | PTU | EN | M4)) /*GPIO 42*/\
|
||||||
MUX_VAL(CP(GPMC_A10), (IDIS | PTD | DIS | M0)) /*GPMC_A10*/\
|
MUX_VAL(CP(GPMC_A10), (IDIS | PTU | EN | M4)) /*GPIO 43*/\
|
||||||
MUX_VAL(CP(GPMC_D0), (IEN | PTD | DIS | M0)) /*GPMC_D0*/\
|
MUX_VAL(CP(GPMC_D0), (IEN | PTD | DIS | M0)) /*GPMC_D0*/\
|
||||||
MUX_VAL(CP(GPMC_D1), (IEN | PTD | DIS | M0)) /*GPMC_D1*/\
|
MUX_VAL(CP(GPMC_D1), (IEN | PTD | DIS | M0)) /*GPMC_D1*/\
|
||||||
MUX_VAL(CP(GPMC_D2), (IEN | PTD | DIS | M0)) /*GPMC_D2*/\
|
MUX_VAL(CP(GPMC_D2), (IEN | PTD | DIS | M0)) /*GPMC_D2*/\
|
||||||
|
@@ -60,6 +60,20 @@
|
|||||||
/* GPIO support */
|
/* GPIO support */
|
||||||
#define CONFIG_OMAP_GPIO
|
#define CONFIG_OMAP_GPIO
|
||||||
|
|
||||||
|
/* LED support */
|
||||||
|
#define CONFIG_STATUS_LED
|
||||||
|
#define CONFIG_BOARD_SPECIFIC_LED
|
||||||
|
#define CONFIG_CMD_LED /* LED command */
|
||||||
|
#define STATUS_LED_BIT (1 << 0)
|
||||||
|
#define STATUS_LED_STATE STATUS_LED_ON
|
||||||
|
#define STATUS_LED_PERIOD (CONFIG_SYS_HZ / 2)
|
||||||
|
#define STATUS_LED_BIT1 (1 << 1)
|
||||||
|
#define STATUS_LED_STATE1 STATUS_LED_ON
|
||||||
|
#define STATUS_LED_PERIOD1 (CONFIG_SYS_HZ / 2)
|
||||||
|
#define STATUS_LED_BIT2 (1 << 2)
|
||||||
|
#define STATUS_LED_STATE2 STATUS_LED_ON
|
||||||
|
#define STATUS_LED_PERIOD2 (CONFIG_SYS_HZ / 2)
|
||||||
|
|
||||||
/* NS16550 Configuration */
|
/* NS16550 Configuration */
|
||||||
#define CONFIG_SYS_NS16550
|
#define CONFIG_SYS_NS16550
|
||||||
#define CONFIG_SYS_NS16550_SERIAL
|
#define CONFIG_SYS_NS16550_SERIAL
|
||||||
|
Reference in New Issue
Block a user