Commit 088e82c3 by ubuntu16

IGEP0146: Add led and HWtest support

parent 4a829111
/*
* Copyright (c) 2019 ISEE 2007 SL
* Hector Fernandez <hector@iatec.biz>
*
* SPDX-License-Identifier: GPL-2.0+
*/
#include <common.h>
#include <status_led.h>
#include <tca642x.h>
#include "igep0146_led.h"
#ifdef CONFIG_LED_STATUS_GREEN
void green_led_off(void)
{
__led_set(IGEP0146_LED_GREEN, 0);
}
void green_led_on(void)
{
__led_set(IGEP0146_LED_GREEN, 1);
}
#endif
#ifdef CONFIG_LED_STATUS_RED
void red_led_off(void)
{
__led_set(IGEP0146_LED_RED, 0);
}
void red_led_on(void)
{
__led_set(IGEP0146_LED_RED, 1);
}
#endif
void __led_init (led_id_t mask, int state)
{
/* NOTHING */
}
void __led_toggle (led_id_t mask)
{
/* NOTHING */
}
void __led_set (led_id_t mask, int state)
{
uint8_t reg_bit;
switch (mask)
{
case IGEP0146_LED_RED:
reg_bit = 1 << IGEP0146_LED_RED;
break;
case IGEP0146_LED_GREEN:
reg_bit = 1 << IGEP0146_LED_GREEN;
break;
default:
return;
}
tca642x_set_val(CONFIG_SYS_I2C_TCA642X_ADDR, 0, reg_bit, (state ? reg_bit: 0));
}
\ No newline at end of file
/*
* Copyright (c) 2018 ISEE 2007 SL
* Aitor Carrizosa <acarrizosa@iatec.biz>
*
* SPDX-License-Identifier: GPL-2.0+
*/
#ifndef __CONFIG_IGEP0146_LED_H
#define __CONFIG_IGEP0146_LED_H
/* GPIO Leds */
#define IGEP0146_LED_RED 7
#define IGEP0146_LED_GREEN 6
#endif
\ No newline at end of file
......@@ -24,72 +24,31 @@ int gpio_name_to_num(char* name)
return 0;
}
/* GPIO pins for the LEDs */
/* GPIO Leds */
#define IGEP0146_LED_RED_USER0 8
#define IGEP0146_LED_GREEN_USER1 9
#ifdef CONFIG_LED_STATUS_GREEN
void green_led_off(void)
{
#if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0146)
__led_set(IGEP0146_LED_GREEN_USER1, CONFIG_LED_STATUS_OFF);
#elif (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0046)
__led_set(gpio_name_to_num("green"), CONFIG_LED_STATUS_OFF);
#endif
}
void green_led_on(void)
{
#if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0146)
__led_set(IGEP0146_LED_GREEN_USER1, CONFIG_LED_STATUS_ON);
#elif (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0046)
__led_set(gpio_name_to_num("green"), CONFIG_LED_STATUS_ON);
#endif
}
#endif
#ifdef CONFIG_LED_STATUS_RED
void red_led_off(void)
{
#if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0146)
__led_set(IGEP0146_LED_RED_USER0, CONFIG_LED_STATUS_OFF);
#elif (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0046)
__led_set(gpio_name_to_num("red"), CONFIG_LED_STATUS_OFF);
#endif
}
void red_led_on(void)
{
#if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0146)
__led_set(IGEP0146_LED_RED_USER0, CONFIG_LED_STATUS_ON);
#elif (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0046)
__led_set(gpio_name_to_num("red"), CONFIG_LED_STATUS_ON);
#endif
}
#endif
#if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0146)
static int get_led_gpio(led_id_t mask)
{
#ifdef CONFIG_LED_STATUS0
if (CONFIG_LED_STATUS_BIT == mask)
{
return IGEP0146_LED_RED_USER0;
}
#endif
#ifdef CONFIG_LED_STATUS1
if (CONFIG_LED_STATUS_BIT1 == mask)
{
return IGEP0146_LED_GREEN_USER1;
}
#endif
return 0;
}
#elif (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0046)
#if (CONFIG_MACH_TYPE == MACH_TYPE_IGEP0046)
/* Convert Status from gpio mask */
static int get_led_gpio(led_id_t mask)
{
......@@ -139,4 +98,4 @@ void __led_set (led_id_t mask, int state)
{
gpio_direction_output(toggle_gpio, state);
}
}
}
\ No newline at end of file
......@@ -11,4 +11,8 @@ config SYS_CONFIG_NAME
config BASE0040
bool "base0040"
config HWTEST
bool "ENABLE HWTEST"
default false
endif
# Copyright (C) IATEC - http://www.iatec.biz
#
# Copyright (C) 2007, Guennadi Liakhovetski <lg@denx.de>
# Aitor Carrizosa <acarrizosa@iatec.biz>
#
# (C) Copyright 2011 Freescale Semiconductor, Inc.
# Source file for IGEP0146 board
#
# SPDX-License-Identifier: GPL-2.0+
#
obj-y += igep0146.o
obj-y += ../common/eeprom.o
obj-$(CONFIG_LED_STATUS) += ../common/led.o
\ No newline at end of file
obj-$(CONFIG_LED_STATUS) += ../common/igep0146_led.o
\ No newline at end of file
/*
* Copyright (C) 2016 ISEE 2007 SL - http://www.isee.biz
* Copyright (C) IATEC - http://www.iatec.biz
*
* Source file for IGEP0146 board
*
* Author: Jose Miguel Sanchez Sanabria <jsanabria@iseebcn.com>
*
* SPDX-License-Identifier: GPL-2.0+
*/
......@@ -42,19 +40,20 @@
#include "../common/eeprom.h"
#include "../common/igep_common.h"
#include <tca642x.h>
DECLARE_GLOBAL_DATA_PTR;
/* MACRO MUX defines */
/* MUX defines */
#define WEAK_PULLUP (PAD_CTL_PUS_100K_UP | \
PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | PAD_CTL_HYS | \
PAD_CTL_SRE_SLOW)
#define UART_PAD_CTRL (PAD_CTL_PKE | PAD_CTL_PUE | \
PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED | \
PAD_CTL_DSE_40ohm | PAD_CTL_SRE_FAST | PAD_CTL_HYS)
#define GPIO_LED_PAD_CTRL (PAD_CTL_PUS_22K_UP | \
PAD_CTL_SPEED_LOW | PAD_CTL_DSE_40ohm | \
PAD_CTL_SRE_FAST )
#define ENET_PAD_CTRL (PAD_CTL_PUS_100K_UP | PAD_CTL_PUE | \
PAD_CTL_SPEED_HIGH | \
PAD_CTL_DSE_48ohm | PAD_CTL_SRE_FAST | PAD_CTL_HYS)
......@@ -85,18 +84,19 @@ DECLARE_GLOBAL_DATA_PTR;
#define I2C_PAD MUX_PAD_CTRL(I2C_PAD_CTRL)
#endif
#ifdef CONFIG_BASE0040
/* Audio reset */
#define AUDIO_RESET IMX_GPIO_NR(4, 17)
#endif
/* Ethernet Phy 1 reset */
#define ETH_PHY_RESET IMX_GPIO_NR(1, 10)
/* eMMC reset */
#define USDHC2_PWR_GPIO IMX_GPIO_NR(4, 10)
/* GPIO Leds */
#define IGEP0146_LED_RED IMX_GPIO_NR(1,8)
#define IGEP0146_LED_GREEN IMX_GPIO_NR(1,9)
/* Gpio Expander reset */
#define GPIO_NRST_GPIO IMX_GPIO_NR(1, 1)
/*
There are 4 ranges of Locally Administered Address Ranges that can be used on a local network:
......@@ -119,6 +119,24 @@ static struct igep_mf_setup igep0146_eeprom_config = {
.bmac1 = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
};
/**
* @brief tca642x_init - uEVM default values for the GPIO expander
* input reg, output reg, polarity reg, configuration reg
*/
struct tca642x_bank_info tca642x_init[] = {
{ .input_reg = 0x00,
.output_reg = 0x00,
.polarity_reg = 0x00,
.configuration_reg = 0x1f },
{ .input_reg = 0x00,
.output_reg = 0x66,
.polarity_reg = 0x00,
.configuration_reg = 0x01 },
{ .input_reg = 0x00,
.output_reg = 0x80,
.polarity_reg = 0x00,
.configuration_reg = 0x0e },
};
int dram_init(void)
{
......@@ -139,13 +157,6 @@ static iomux_v3_cfg_t const uart3_pads[] =
MX6_PAD_UART3_RX_DATA__UART3_DCE_RX | MUX_PAD_CTRL(UART_PAD_CTRL),
};
static iomux_v3_cfg_t const led_pads[] = {
MX6_PAD_GPIO1_IO08__GPIO1_IO08 | MUX_PAD_CTRL(GPIO_LED_PAD_CTRL),
/* Warning This GPIO actually controls if we select SD or WiFi through a MUX */
MX6_PAD_GPIO1_IO09__GPIO1_IO09 | MUX_PAD_CTRL(GPIO_LED_PAD_CTRL),
};
#ifdef CONFIG_FEC_MXC
/* ethernet */
static iomux_v3_cfg_t const enet1_pads[] = {
......@@ -204,15 +215,12 @@ static iomux_v3_cfg_t const usdhc2_pads[] = {
static iomux_v3_cfg_t const init_pads[] =
{
/* TLV320AIC3106 Audio codec Reset*/
MX6_PAD_CSI_MCLK__GPIO4_IO17 | MUX_PAD_CTRL(NO_PAD_CTRL),
/*MX6_PAD_CSI_MCLK__GPIO4_IO17 | MUX_PAD_CTRL(NO_PAD_CTRL), */
MX6_PAD_CSI_MCLK__GPIO4_IO17 | MUX_PAD_CTRL(WEAK_PULLUP),
/* TCA6424 Gpio Expander Reset */
MX6_PAD_GPIO1_IO01__GPIO1_IO01 | MUX_PAD_CTRL(WEAK_PULLUP),
};
// const uchar igep_mac0 [6] = { 0x02, 0x00, 0x00, 0x00, 0x00, 0xff };
//const uchar igep_mac0 [6] = { 0xb0, 0xd5, 0xcc, 0xb2, 0xa5, 0xb9 };
// static int igep_eeprom_valid = 0;
// static struct igep_mf_setup igep0046_eeprom_config;
/* i2c */
#ifdef CONFIG_SYS_I2C_MXC
static struct i2c_pads_info i2c_pad_info1 =
......@@ -254,19 +262,11 @@ static void setup_iomux_uart(void)
imx_iomux_v3_setup_multiple_pads(uart3_pads, ARRAY_SIZE(uart3_pads));
}
static void setup_iomux_leds(void)
{
imx_iomux_v3_setup_multiple_pads(led_pads, ARRAY_SIZE(led_pads));
}
/*
static void setup_iomux_usdhc(void)
/*static void setup_iomux_usdhc(void)
{
imx_iomux_v3_setup_multiple_pads(usdhc1_pads, ARRAY_SIZE(usdhc1_pads));
imx_iomux_v3_setup_multiple_pads(usdhc2_pads, ARRAY_SIZE(usdhc2_pads));
}
*/
}*/
static void setup_iomux_enet(void)
{
......@@ -296,7 +296,7 @@ static int get_mac_address (void)
}
if (!is_valid_ethaddr(enetaddr)){
printf("MAC Address: Error or not set\n");
printf("MAC Address: Error\n");
return -1;
}
......@@ -359,7 +359,6 @@ int board_eth_init(bd_t *bis)
ret = fecmxc_initialize_multi(bis, 0, CONFIG_FEC_MXC_PHYADDR, IMX_FEC_BASE);
if (ret)
printf("FEC%d MXC: %s:failed\n", 0, __func__);
return 0;
}
......@@ -391,9 +390,7 @@ int board_mmc_getcd(struct mmc *mmc)
ret = 1;
break;
}
return ret;
}
int board_mmc_init(bd_t *bis)
......@@ -440,7 +437,6 @@ int checkboard(void)
int board_early_init_f(void)
{
setup_iomux_uart();
setup_iomux_leds();
setup_iomux_misc();
return 0;
}
......@@ -484,6 +480,17 @@ static int load_eeprom (void)
return result;
}
void reset_gpio_expander(void)
{
/* reset gpio expander */
gpio_direction_output(GPIO_NRST_GPIO, 1);
mdelay(1);
gpio_set_value(GPIO_NRST_GPIO, 0);
mdelay(1);
gpio_set_value(GPIO_NRST_GPIO, 1);
mdelay(2);
}
int board_init(void)
{
......@@ -494,20 +501,22 @@ int board_init(void)
reset_audio();
#endif
reset_gpio_expander();
#ifdef CONFIG_SYS_I2C_MXC
setup_i2c(1, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info1);
setup_i2c(2, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info2);
mdelay(1);
mdelay(2);
#endif
tca642x_set_inital_state(CONFIG_SYS_I2C_TCA642X_ADDR, tca642x_init);
status_led_set(1, 1);
load_eeprom();
set_boardserial();
#if defined(CONFIG_LED_STATUS) && defined(CONFIG_LED_STATUS_BOOT_ENABLE)
status_led_set(CONFIG_LED_STATUS_BOOT, CONFIG_LED_STATUS_ON);
#endif
#ifdef CONFIG_FEC_MXC
setup_phy();
#endif
......
......@@ -24,14 +24,15 @@ CONFIG_CMD_MEMTEST=y
# CONFIG_CMD_FLASH is not set
CONFIG_LOCALVERSION=""
#
# LED Support
#
CONFIG_LED=y
CONFIG_CMD_LED=y
CONFIG_CMD_LED=n
# CONFIG_LED_GPIO is not set
CONFIG_LED_STATUS=y
CONFIG_LED_STATUS_OFF=0
CONFIG_LED_STATUS_BLINKING=1
# CONFIG_LED_STATUS_BLINKING=1
CONFIG_LED_STATUS_ON=1
# CONFIG_LED_STATUS_GPIO is not set
CONFIG_LED_STATUS_BOARD_SPECIFIC=y
......@@ -40,13 +41,13 @@ CONFIG_LED_STATUS_BOARD_SPECIFIC=y
# LEDs parameters
#
CONFIG_LED_STATUS0=y
CONFIG_LED_STATUS_BIT=8
CONFIG_LED_STATUS_BIT=7
CONFIG_LED_STATUS_STATE=1
CONFIG_LED_STATUS_FREQ=500
CONFIG_LED_STATUS_FREQ=1
CONFIG_LED_STATUS1=y
CONFIG_LED_STATUS_BIT1=9
CONFIG_LED_STATUS_BIT1=6
CONFIG_LED_STATUS_STATE1=0
CONFIG_LED_STATUS_FREQ1=500
CONFIG_LED_STATUS_FREQ1=1
CONFIG_LED_STATUS2=n
CONFIG_LED_STATUS_BIT2=400
CONFIG_LED_STATUS_STATE2=0
......
CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/isee/igep0146/mx6ul_igep0146_1x512.cfg,MX6UL"
CONFIG_ARM=y
CONFIG_ARCH_MX6=y
CONFIG_MX6UL=y
CONFIG_TARGET_IGEP0146=y
CONFIG_BOOTDELAY=3
CONFIG_BOARD_EARLY_INIT_F=y
CONFIG_OF_LIBFDT=y
CONFIG_DM=y
CONFIG_DM_THERMAL=y
CONFIG_DISPLAY_BOARDINFO=y
CONFIG_DEFAULT_FDT_FILE="imx6ul-igep-base0040rd102.dtb"
CONFIG_HUSH_PARSER=y
CONFIG_CMD_GPIO=y
CONFIG_CMD_CACHE=y
CONFIG_CMD_MMC=y
CONFIG_CMD_EXT2=y
CONFIG_CMD_EXT4=y
CONFIG_CMD_EXT4_WRITE=y
CONFIG_CMD_FAT=y
CONFIG_CMD_FS_GENERIC=y
CONFIG_CMD_MEMTEST=y
# CONFIG_CMD_IMLS is not set
# CONFIG_CMD_FLASH is not set
CONFIG_LOCALVERSION="
CONFIG_HWTEST=y
#
# LED Support
#
CONFIG_LED=y
CONFIG_CMD_LED=n
# CONFIG_LED_GPIO is not set
CONFIG_LED_STATUS=y
CONFIG_LED_STATUS_OFF=0
# CONFIG_LED_STATUS_BLINKING=1
CONFIG_LED_STATUS_ON=1
# CONFIG_LED_STATUS_GPIO is not set
CONFIG_LED_STATUS_BOARD_SPECIFIC=y
#
# LEDs parameters
#
CONFIG_LED_STATUS0=y
CONFIG_LED_STATUS_BIT=7
CONFIG_LED_STATUS_STATE=1
CONFIG_LED_STATUS_FREQ=1
CONFIG_LED_STATUS1=y
CONFIG_LED_STATUS_BIT1=6
CONFIG_LED_STATUS_STATE1=0
CONFIG_LED_STATUS_FREQ1=1
CONFIG_LED_STATUS2=n
CONFIG_LED_STATUS_BIT2=400
CONFIG_LED_STATUS_STATE2=0
CONFIG_LED_STATUS_FREQ2=500
CONFIG_LED_STATUS3=n
CONFIG_LED_STATUS_BIT3=401
CONFIG_LED_STATUS_STATE3=0
CONFIG_LED_STATUS_FREQ3=500
# CONFIG_LED_STATUS4 is not set
# CONFIG_LED_STATUS5 is not set
# CONFIG_LED_STATUS_BOOT_ENABLE is not set
# CONFIG_LED_STATUS_YELLOW_ENABLE is not set
# CONFIG_LED_STATUS_RED_ENABLE is not set
CONFIG_LED_STATUS_GREEN_ENABLE=y
CONFIG_LED_STATUS_GREEN=0
CONFIG_LED_STATUS_BLUE_ENABLE=y
CONFIG_LED_STATUS_BLUE=0
CONFIG_LED_STATUS_CMD=y
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment