Re: [U-Boot] [PATCH] ARM: imx6: Add DHCOM i.MX6 PDK board support
On 10/09/2017 09:28 PM, Stefano Babic wrote: > Hi Marek, Hi, clip please ... [...] >> +static int setup_dhcom_mac_from_fuse(void) >> +{ >> +unsigned char enetaddr[6]; >> +u32 fuseval[2]; >> +int ret; >> + >> +ret = eth_env_get_enetaddr("ethaddr", enetaddr); >> +if (ret)/* ethaddr is already set */ >> +return 0; >> + >> +ret = fuse_read(4, 2, [0]); >> +if (ret) { >> +printf("Error reading the eFUSE0 with MAC address\n"); >> +return ret; >> +} >> + >> +ret = fuse_read(4, 3, [1]); >> +if (ret) { >> +printf("Error reading the eFUSE1 with MAC address\n"); >> +return ret; >> +} >> + >> +enetaddr[0] = fuseval[1] >> 8; >> +enetaddr[1] = fuseval[1] >> 0; >> +enetaddr[2] = fuseval[0] >> 24; >> +enetaddr[3] = fuseval[0] >> 16; >> +enetaddr[4] = fuseval[0] >> 8; >> +enetaddr[5] = fuseval[0] >> 0; >> + > > > Is the first part different as imx_get_mac_from_fuse() ? It looks like > to me that MAC is stored as usually in bank 4, address 2. > > If yes, you can call the function instead reading yourself from fuses. Cool, that's what I was looking for, thanks. >> +if (is_valid_ethaddr(enetaddr)) { >> +eth_env_set_enetaddr("ethaddr", enetaddr); >> +return 0; >> +} >> + >> +ret = i2c_set_bus_num(2); >> +if (ret) { >> +printf("Error switching I2C bus!\n"); >> +return ret; >> +} >> + >> +ret = i2c_read(EEPROM_I2C_ADDRESS, 0xfa, 0x1, enetaddr, 0x6); >> +if (ret) { >> +printf("Error reading configuration EEPROM!\n"); >> +return ret; >> +} >> + >> +if (is_valid_ethaddr(enetaddr)) >> +eth_env_set_enetaddr("ethaddr", enetaddr); >> + >> +return 0; >> +} >> + >> +int board_early_init_f(void) >> +{ >> +#ifdef CONFIG_USB_EHCI_MX6 >> +setup_usb(); >> +#endif >> + >> +return 0; >> +} >> + >> +#ifdef CONFIG_MXC_SPI >> +int board_spi_cs_gpio(unsigned bus, unsigned cs) >> +{ >> +if (bus == 0 && cs == 0) >> +return IMX_GPIO_NR(2, 30); >> +else >> +return -1; >> +} >> +#endif >> + >> +int board_init(void) >> +{ >> +struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR; >> + >> +/* address of boot parameters */ >> +gd->bd->bi_boot_params = PHYS_SDRAM + 0x100; >> + >> +/* Enable eim_slow clocks */ >> +setbits_le32(_ccm->CCGR6, 0x1 << MXC_CCM_CCGR6_EMI_SLOW_OFFSET); >> + >> +#ifdef CONFIG_SYS_I2C_MXC >> +if (is_mx6dq()) { >> +setup_i2c(0, CONFIG_SYS_I2C_SPEED, 0x7f, _i2c_pad_info0); >> +setup_i2c(1, CONFIG_SYS_I2C_SPEED, 0x7f, _i2c_pad_info1); >> +setup_i2c(2, CONFIG_SYS_I2C_SPEED, 0x7f, _i2c_pad_info2); >> +} else { >> +setup_i2c(0, CONFIG_SYS_I2C_SPEED, 0x7f, _i2c_pad_info0); >> +setup_i2c(1, CONFIG_SYS_I2C_SPEED, 0x7f, _i2c_pad_info1); >> +setup_i2c(2, CONFIG_SYS_I2C_SPEED, 0x7f, _i2c_pad_info2); >> +} >> +#endif >> + >> +#ifdef CONFIG_SATA >> +setup_sata(); >> +#endif >> + >> +setup_dhcom_mac_from_fuse(); >> + >> +return 0; >> +} >> + >> +#ifdef CONFIG_CMD_BMODE >> +static const struct boot_mode board_boot_modes[] = { >> +/* 4 bit bus width */ >> +{"sd2", MAKE_CFGVAL(0x40, 0x28, 0x00, 0x00)}, >> +{"sd3", MAKE_CFGVAL(0x40, 0x30, 0x00, 0x00)}, >> +/* 8 bit bus width */ >> +{"emmc", MAKE_CFGVAL(0x40, 0x38, 0x00, 0x00)}, >> +{NULL, 0}, >> +}; >> +#endif >> + >> +#define HW_CODE_BIT_0 IMX_GPIO_NR(2, 19) >> +#define HW_CODE_BIT_1 IMX_GPIO_NR(6, 6) >> +#define HW_CODE_BIT_2 IMX_GPIO_NR(2, 16) >> + >> +static int board_get_hwcode(void) >> +{ >> +int hw_code; >> + >> +gpio_direction_input(HW_CODE_BIT_0); >> +gpio_direction_input(HW_CODE_BIT_1); >> +gpio_direction_input(HW_CODE_BIT_2); >> + >> +/* HW 100 + HW 200 = 00b; HW 300 = 01b */ >> +hw_code = ((gpio_get_value(HW_CODE_BIT_2) << 2) | >> + (gpio_get_value(HW_CODE_BIT_1) << 1) | >> +gpio_get_value(HW_CODE_BIT_0)) + 2; >> + >> +return hw_code; >> +} >> + >> +int board_late_init(void) >> +{ >> +u32 hw_code, cpu_rev; >> +char buf[16]; >> + >> +cpu_rev = get_cpu_rev(); >> +hw_code = board_get_hwcode(); >> + >> +switch (cpu_rev >> 12) { > > Nitpick: there is a macro for it, get_cpu_type() Fixed >> +case MXC_CPU_MX6SOLO: >> +snprintf(buf, sizeof(buf), "imx6s-dhcom%1d", hw_code); >> +break; >> +case MXC_CPU_MX6DL: >> +snprintf(buf, sizeof(buf), "imx6dl-dhcom%1d", hw_code); >> +break; >> +case MXC_CPU_MX6D: >> +snprintf(buf, sizeof(buf), "imx6d-dhcom%1d", hw_code); >> +break; >> +case MXC_CPU_MX6Q: >> +snprintf(buf, sizeof(buf), "imx6q-dhcom%1d", hw_code); >> +break; >> +default: >> +snprintf(buf, sizeof(buf), "UNKNOWN%1d",
Re: [U-Boot] [PATCH] ARM: imx6: Add DHCOM i.MX6 PDK board support
Hi Marek, On 09/10/2017 20:13, Marek Vasut wrote: > Add support for the DHCOM i.MX6 PDK board. This board has: > - FEC ethernet > - EHCI USB host > - 3x SDMMC > > Signed-off-by: Marek Vasut> Cc: Stefano Babic > --- > arch/arm/mach-imx/mx6/Kconfig | 10 + > board/dhelectronics/dh_imx6/Kconfig | 12 + > board/dhelectronics/dh_imx6/MAINTAINERS | 7 + > board/dhelectronics/dh_imx6/Makefile | 11 + > board/dhelectronics/dh_imx6/dh_imx6.c | 456 > ++ > board/dhelectronics/dh_imx6/dh_imx6_spl.c | 399 ++ > configs/dh_imx6_defconfig | 51 > include/configs/dh_imx6.h | 191 + > 8 files changed, 1137 insertions(+) > create mode 100644 board/dhelectronics/dh_imx6/Kconfig > create mode 100644 board/dhelectronics/dh_imx6/MAINTAINERS > create mode 100644 board/dhelectronics/dh_imx6/Makefile > create mode 100644 board/dhelectronics/dh_imx6/dh_imx6.c > create mode 100644 board/dhelectronics/dh_imx6/dh_imx6_spl.c > create mode 100644 configs/dh_imx6_defconfig > create mode 100644 include/configs/dh_imx6.h > > diff --git a/arch/arm/mach-imx/mx6/Kconfig b/arch/arm/mach-imx/mx6/Kconfig > index 540f2b29b1..b82db3af22 100644 > --- a/arch/arm/mach-imx/mx6/Kconfig > +++ b/arch/arm/mach-imx/mx6/Kconfig > @@ -129,6 +129,15 @@ config TARGET_COLIBRI_IMX6 > select DM_SERIAL > select DM_THERMAL > > +config TARGET_DHCOMIMX6 > + bool "dh_imx6" > + select BOARD_LATE_INIT > + select BOARD_EARLY_INIT_F > + select SUPPORT_SPL > + select DM > + select DM_THERMAL > + imply CMD_SPL > + > config TARGET_EMBESTMX6BOARDS > bool "embestmx6boards" > select BOARD_LATE_INIT > @@ -428,6 +437,7 @@ source "board/boundary/nitrogen6x/Kconfig" > source "board/ccv/xpress/Kconfig" > source "board/compulab/cm_fx6/Kconfig" > source "board/congatec/cgtqmx6eval/Kconfig" > +source "board/dhelectronics/dh_imx6/Kconfig" > source "board/el/el6x/Kconfig" > source "board/embest/mx6boards/Kconfig" > source "board/engicam/geam6ul/Kconfig" > diff --git a/board/dhelectronics/dh_imx6/Kconfig > b/board/dhelectronics/dh_imx6/Kconfig > new file mode 100644 > index 00..0cfef9b097 > --- /dev/null > +++ b/board/dhelectronics/dh_imx6/Kconfig > @@ -0,0 +1,12 @@ > +if TARGET_DHCOMIMX6 > + > +config SYS_BOARD > + default "dh_imx6" > + > +config SYS_VENDOR > + default "dhelectronics" > + > +config SYS_CONFIG_NAME > + default "dh_imx6" > + > +endif > diff --git a/board/dhelectronics/dh_imx6/MAINTAINERS > b/board/dhelectronics/dh_imx6/MAINTAINERS > new file mode 100644 > index 00..e54bd60adb > --- /dev/null > +++ b/board/dhelectronics/dh_imx6/MAINTAINERS > @@ -0,0 +1,7 @@ > +DH_IMX6 BOARD > +M: Andreas Geisreiter , Ludwig Zenz > > +S: Maintained > +F: board/dhelectronics/dh_imx6/ > +F: include/configs/dh_imx6.h > +F: configs/dh_mx6q_defconfig > +F: configs/dh_mx6dl_defconfig > diff --git a/board/dhelectronics/dh_imx6/Makefile > b/board/dhelectronics/dh_imx6/Makefile > new file mode 100644 > index 00..bddc8d8568 > --- /dev/null > +++ b/board/dhelectronics/dh_imx6/Makefile > @@ -0,0 +1,11 @@ > +# > +# Copyright (C) 2017 Marek Vasut > +# > +# SPDX-License-Identifier: GPL-2.0+ > +# > + > +ifdef CONFIG_SPL_BUILD > +obj-y:= dh_imx6_spl.o > +else > +obj-y:= dh_imx6.o > +endif > diff --git a/board/dhelectronics/dh_imx6/dh_imx6.c > b/board/dhelectronics/dh_imx6/dh_imx6.c > new file mode 100644 > index 00..e372fbad32 > --- /dev/null > +++ b/board/dhelectronics/dh_imx6/dh_imx6.c > @@ -0,0 +1,456 @@ > +/* > + * DHCOM DH-iMX6 PDK board support > + * > + * Copyright (C) 2017 Marek Vasut > + * > + * SPDX-License-Identifier: GPL-2.0+ > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +DECLARE_GLOBAL_DATA_PTR; > + > +#define I2C_PAD_CTRL \ > + (PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | \ > + PAD_CTL_HYS | PAD_CTL_ODE | PAD_CTL_SRE_FAST) > + > +#define EEPROM_I2C_ADDRESS 0x50 > + > +#define PC MUX_PAD_CTRL(I2C_PAD_CTRL) > + > +static struct i2c_pads_info dh6sdl_i2c_pad_info0 = { > + .scl = { > + .i2c_mode = MX6DL_PAD_EIM_D21__I2C1_SCL | PC, > + .gpio_mode = MX6DL_PAD_EIM_D21__GPIO3_IO21 | PC, > + .gp = IMX_GPIO_NR(3, 21) > + }, > + .sda = { > + .i2c_mode = MX6DL_PAD_EIM_D28__I2C1_SDA | PC, > + .gpio_mode = MX6DL_PAD_EIM_D28__GPIO3_IO28 | PC, > + .gp =
[U-Boot] [PATCH] ARM: imx6: Add DHCOM i.MX6 PDK board support
Add support for the DHCOM i.MX6 PDK board. This board has: - FEC ethernet - EHCI USB host - 3x SDMMC Signed-off-by: Marek VasutCc: Stefano Babic --- arch/arm/mach-imx/mx6/Kconfig | 10 + board/dhelectronics/dh_imx6/Kconfig | 12 + board/dhelectronics/dh_imx6/MAINTAINERS | 7 + board/dhelectronics/dh_imx6/Makefile | 11 + board/dhelectronics/dh_imx6/dh_imx6.c | 456 ++ board/dhelectronics/dh_imx6/dh_imx6_spl.c | 399 ++ configs/dh_imx6_defconfig | 51 include/configs/dh_imx6.h | 191 + 8 files changed, 1137 insertions(+) create mode 100644 board/dhelectronics/dh_imx6/Kconfig create mode 100644 board/dhelectronics/dh_imx6/MAINTAINERS create mode 100644 board/dhelectronics/dh_imx6/Makefile create mode 100644 board/dhelectronics/dh_imx6/dh_imx6.c create mode 100644 board/dhelectronics/dh_imx6/dh_imx6_spl.c create mode 100644 configs/dh_imx6_defconfig create mode 100644 include/configs/dh_imx6.h diff --git a/arch/arm/mach-imx/mx6/Kconfig b/arch/arm/mach-imx/mx6/Kconfig index 540f2b29b1..b82db3af22 100644 --- a/arch/arm/mach-imx/mx6/Kconfig +++ b/arch/arm/mach-imx/mx6/Kconfig @@ -129,6 +129,15 @@ config TARGET_COLIBRI_IMX6 select DM_SERIAL select DM_THERMAL +config TARGET_DHCOMIMX6 + bool "dh_imx6" + select BOARD_LATE_INIT + select BOARD_EARLY_INIT_F + select SUPPORT_SPL + select DM + select DM_THERMAL + imply CMD_SPL + config TARGET_EMBESTMX6BOARDS bool "embestmx6boards" select BOARD_LATE_INIT @@ -428,6 +437,7 @@ source "board/boundary/nitrogen6x/Kconfig" source "board/ccv/xpress/Kconfig" source "board/compulab/cm_fx6/Kconfig" source "board/congatec/cgtqmx6eval/Kconfig" +source "board/dhelectronics/dh_imx6/Kconfig" source "board/el/el6x/Kconfig" source "board/embest/mx6boards/Kconfig" source "board/engicam/geam6ul/Kconfig" diff --git a/board/dhelectronics/dh_imx6/Kconfig b/board/dhelectronics/dh_imx6/Kconfig new file mode 100644 index 00..0cfef9b097 --- /dev/null +++ b/board/dhelectronics/dh_imx6/Kconfig @@ -0,0 +1,12 @@ +if TARGET_DHCOMIMX6 + +config SYS_BOARD + default "dh_imx6" + +config SYS_VENDOR + default "dhelectronics" + +config SYS_CONFIG_NAME + default "dh_imx6" + +endif diff --git a/board/dhelectronics/dh_imx6/MAINTAINERS b/board/dhelectronics/dh_imx6/MAINTAINERS new file mode 100644 index 00..e54bd60adb --- /dev/null +++ b/board/dhelectronics/dh_imx6/MAINTAINERS @@ -0,0 +1,7 @@ +DH_IMX6 BOARD +M: Andreas Geisreiter , Ludwig Zenz +S: Maintained +F: board/dhelectronics/dh_imx6/ +F: include/configs/dh_imx6.h +F: configs/dh_mx6q_defconfig +F: configs/dh_mx6dl_defconfig diff --git a/board/dhelectronics/dh_imx6/Makefile b/board/dhelectronics/dh_imx6/Makefile new file mode 100644 index 00..bddc8d8568 --- /dev/null +++ b/board/dhelectronics/dh_imx6/Makefile @@ -0,0 +1,11 @@ +# +# Copyright (C) 2017 Marek Vasut +# +# SPDX-License-Identifier: GPL-2.0+ +# + +ifdef CONFIG_SPL_BUILD +obj-y := dh_imx6_spl.o +else +obj-y := dh_imx6.o +endif diff --git a/board/dhelectronics/dh_imx6/dh_imx6.c b/board/dhelectronics/dh_imx6/dh_imx6.c new file mode 100644 index 00..e372fbad32 --- /dev/null +++ b/board/dhelectronics/dh_imx6/dh_imx6.c @@ -0,0 +1,456 @@ +/* + * DHCOM DH-iMX6 PDK board support + * + * Copyright (C) 2017 Marek Vasut + * + * SPDX-License-Identifier:GPL-2.0+ + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +#define I2C_PAD_CTRL \ + (PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | \ + PAD_CTL_HYS | PAD_CTL_ODE | PAD_CTL_SRE_FAST) + +#define EEPROM_I2C_ADDRESS 0x50 + +#define PC MUX_PAD_CTRL(I2C_PAD_CTRL) + +static struct i2c_pads_info dh6sdl_i2c_pad_info0 = { + .scl = { + .i2c_mode = MX6DL_PAD_EIM_D21__I2C1_SCL | PC, + .gpio_mode = MX6DL_PAD_EIM_D21__GPIO3_IO21 | PC, + .gp = IMX_GPIO_NR(3, 21) + }, + .sda = { +.i2c_mode = MX6DL_PAD_EIM_D28__I2C1_SDA | PC, +.gpio_mode = MX6DL_PAD_EIM_D28__GPIO3_IO28 | PC, +.gp = IMX_GPIO_NR(3, 28) +} +}; + +static struct i2c_pads_info dh6sdl_i2c_pad_info1 = { + .scl = { + .i2c_mode = MX6DL_PAD_KEY_COL3__I2C2_SCL | PC, + .gpio_mode = MX6DL_PAD_KEY_COL3__GPIO4_IO12 | PC, + .gp = IMX_GPIO_NR(4, 12) + }, + .sda = { +