nrhw20: added LED control
This commit is contained in:
parent
d4d8afa3f0
commit
667be0ea8e
|
|
@ -121,6 +121,7 @@ static int _bd_init(void)
|
|||
{
|
||||
int old_bus;
|
||||
|
||||
/* TODO: Use a define for bus number */
|
||||
old_bus = i2c_get_bus_num();
|
||||
i2c_set_bus_num(2);
|
||||
|
||||
|
|
@ -265,12 +266,9 @@ const struct dpll_params *get_dpll_ddr_params(void)
|
|||
|
||||
void set_uart_mux_conf(void)
|
||||
{
|
||||
#ifdef NRHW20_ON_HW16_MODE
|
||||
enable_uart0_disabled_pin_mux();
|
||||
#else
|
||||
disable_uart0_pin_mux();
|
||||
#endif
|
||||
enable_uart1_pin_mux();
|
||||
enable_uart0_pin_mux();
|
||||
/* disable_uart0_pin_mux(); */
|
||||
/* enable_uart1_pin_mux(); */
|
||||
}
|
||||
|
||||
void set_mux_conf_regs(void)
|
||||
|
|
@ -490,6 +488,56 @@ static void enable_ext_usb(void)
|
|||
}
|
||||
|
||||
|
||||
/* TODO: Create DA9063 Accessor Module */
|
||||
#define CONFIG_PMIC_I2C_BUS 0
|
||||
#define CONFIG_PMIC_I2C_ADDR 0x58 /* Pages 0 and 1, Pages 2 and 3 -> 0x59 */
|
||||
#define PMIC_REG_GPIO_MODE8_15 0x1E /* Control register for GPIOs 8..15 */
|
||||
|
||||
static int da9063_i2c_bus = 0;
|
||||
|
||||
void da9063_init(int i2c_bus)
|
||||
{
|
||||
printf("da9063_init %d\n", i2c_bus);
|
||||
da9063_i2c_bus = i2c_bus;
|
||||
}
|
||||
|
||||
int da9093_get_reg(int reg, u8* val)
|
||||
{
|
||||
int ret;
|
||||
int old_bus;
|
||||
u8 temp;
|
||||
|
||||
/* TODO: Check whether swiching is required */
|
||||
old_bus = i2c_get_bus_num();
|
||||
i2c_set_bus_num(da9063_i2c_bus);
|
||||
|
||||
*val = 0;
|
||||
ret = i2c_read(CONFIG_PMIC_I2C_ADDR, reg, 1, &temp, 1);
|
||||
if (ret == 0)
|
||||
*val = temp;
|
||||
|
||||
i2c_set_bus_num(old_bus);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int da9093_set_reg(int reg, u8 val)
|
||||
{
|
||||
int ret;
|
||||
int old_bus;
|
||||
|
||||
old_bus = i2c_get_bus_num();
|
||||
i2c_set_bus_num(da9063_i2c_bus);
|
||||
|
||||
ret = i2c_write(CONFIG_PMIC_I2C_ADDR, reg, 1, &val, 1);
|
||||
if (ret != 0)
|
||||
puts("da9063 write error\n");
|
||||
|
||||
i2c_set_bus_num(old_bus);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Bus 0: PMIC
|
||||
* Bus 2: System
|
||||
|
|
@ -497,36 +545,52 @@ static void enable_ext_usb(void)
|
|||
|
||||
static void set_status_led(int red, int green)
|
||||
{
|
||||
#define PMIC_I2C_ADDR 0x58 /* Pages 0 and 1, Pages 2 and 3 -> 0x59 */
|
||||
#define PMIC_REG_GPIO_MODE8_15 0x1E /* Control register for GPIOs 8..15 */
|
||||
|
||||
#define LED_REG PMIC_REG_GPIO_MODE8_15
|
||||
#define RED_MASK (1U << (10-8))
|
||||
#define GREEN_MASK (1U << (11-8))
|
||||
|
||||
int old_bus;
|
||||
int ret;
|
||||
uint8_t reg = 0x00;
|
||||
u8 reg = 0x00;
|
||||
|
||||
old_bus = i2c_get_bus_num();
|
||||
i2c_set_bus_num(0);
|
||||
|
||||
/* TODO: Do only once in board_init */
|
||||
i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
|
||||
|
||||
ret = i2c_read(PMIC_I2C_ADDR, PMIC_REG_GPIO_MODE8_15, 1, (unsigned char *)®, 1);
|
||||
if (ret) {
|
||||
ret = da9093_get_reg(LED_REG, ®);
|
||||
if (ret == 0) {
|
||||
if (red) reg &= ~RED_MASK;
|
||||
else reg |= RED_MASK;
|
||||
|
||||
if (green) reg &= ~GREEN_MASK;
|
||||
else reg |= GREEN_MASK;
|
||||
|
||||
(void)i2c_write(PMIC_I2C_ADDR, PMIC_REG_GPIO_MODE8_15, 1, (unsigned char *)®, 1);
|
||||
(void)da9093_set_reg(LED_REG, reg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#define CONFIG_SYS_I2C_BUS 2
|
||||
#define CONFIG_IOEXT_I2C_ADDR 0x74
|
||||
#define IOEXT_REG_DIR 0x06
|
||||
#define IOEXT_REG_DATA 0x02
|
||||
|
||||
static void init_indicator_leds(void)
|
||||
{
|
||||
int ret;
|
||||
int old_bus;
|
||||
const u8 dir[2] = { 0x00, 0x00 };
|
||||
const u8 val[2] = { 0xFF, 0xFD };
|
||||
|
||||
old_bus = i2c_get_bus_num();
|
||||
i2c_set_bus_num(CONFIG_SYS_I2C_BUS);
|
||||
|
||||
/* Set all IOs as output */
|
||||
(void)i2c_write(CONFIG_IOEXT_I2C_ADDR, IOEXT_REG_DIR, 1, &dir, 2);
|
||||
|
||||
/* Set LED5 green, all others off */
|
||||
(void)i2c_write(CONFIG_IOEXT_I2C_ADDR, IOEXT_REG_DATA, 1, &val, 2);
|
||||
|
||||
i2c_set_bus_num(old_bus);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Basic board specific setup. Pinmux has been handled already.
|
||||
*/
|
||||
|
|
@ -541,8 +605,16 @@ int board_init(void)
|
|||
#if defined(CONFIG_NOR) || defined(CONFIG_NAND)
|
||||
gpmc_init();
|
||||
#endif
|
||||
/* Configure both I2C buses used in NRHW20 */
|
||||
i2c_set_bus_num(0);
|
||||
i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
|
||||
i2c_set_bus_num(2);
|
||||
i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
|
||||
i2c_set_bus_num(0);
|
||||
|
||||
da9063_init(CONFIG_PMIC_I2C_BUS);
|
||||
set_status_led(1, 1); /* Orange */
|
||||
init_indicator_leds();
|
||||
|
||||
/* Keep unused subsystems in reset */
|
||||
REQUEST_AND_CLEAR_GPIO(NETBIRD_GPIO_WLAN_EN);
|
||||
|
|
@ -872,6 +944,8 @@ int board_late_init(void)
|
|||
set_devicetree_name();
|
||||
|
||||
set_console();
|
||||
|
||||
set_status_led(0, 1); /* Green */
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
|
||||
|
|
@ -1021,38 +1095,3 @@ int board_fit_config_name_match(const char *name)
|
|||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#if !defined(CONFIG_SPL_BUILD)
|
||||
#if 0
|
||||
/* TODO: Move to dedicated file */
|
||||
|
||||
#include <miiphy.h>
|
||||
#include <phy.h>
|
||||
|
||||
static int xmdio_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
||||
{
|
||||
struct mii_dev *bus;
|
||||
int val;
|
||||
|
||||
bus = mdio_get_current_dev();
|
||||
printf("mdio bus name %s\n", bus->name);
|
||||
miiphy_set_current_dev(bus->name);
|
||||
|
||||
val = bus->read(bus, 0xF, 0x0 /*devad*/, 0 /* reg */);
|
||||
printf("PHY read 0xF:0 -> val %04x\n", val);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
U_BOOT_CMD(
|
||||
xmdio, 5, 5, xmdio_cmd,
|
||||
"xmdio - xmdio access via ppu (marvell switch)\n",
|
||||
"args: port dev reg <value>\n"
|
||||
);
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue