[U-Boot] [PATCH 11/11] imx: mx7dsabresd: Add support for MX7D SABRESD board
Fabio Estevam
festevam at gmail.com
Thu Jul 16 17:30:10 CEST 2015
On Wed, Jul 15, 2015 at 7:49 PM, Adrian Alonso <aalonso at freescale.com> wrote:
> * Add i.MX7D SABRESD board BSP codes, with enabled modules:
Better to remove "board BSP codes" as this is too vague.
> UART, PMIC, USB/OTG, SD, eMMC, ENET, I2C, 74LV IOX.
>
> Build target: mx7dsabresd_config
>
> Signed-off-by: Peng Fan <Peng.Fan at freescale.com>
> Signed-off-by: Fugang Duan <B38611 at freescale.com>
> Signed-off-by: Ye.Li <B37916 at freescale.com>
> Signed-off-by: Adrian Alonso <aalonso at freescale.com>
> ---
> board/freescale/mx7dsabresd/Kconfig | 15 +
> board/freescale/mx7dsabresd/Makefile | 6 +
> board/freescale/mx7dsabresd/imximage.cfg | 110 +++++
> board/freescale/mx7dsabresd/mx7dsabresd.c | 656 ++++++++++++++++++++++++++++++
> configs/mx7dsabresd_defconfig | 10 +
> include/configs/mx7_common.h | 22 +
> include/configs/mx7dsabresd.h | 382 +++++++++++++++++
> 7 files changed, 1201 insertions(+)
> create mode 100644 board/freescale/mx7dsabresd/Kconfig
> create mode 100644 board/freescale/mx7dsabresd/Makefile
> create mode 100644 board/freescale/mx7dsabresd/imximage.cfg
> create mode 100644 board/freescale/mx7dsabresd/mx7dsabresd.c
> create mode 100644 configs/mx7dsabresd_defconfig
> create mode 100644 include/configs/mx7_common.h
> create mode 100644 include/configs/mx7dsabresd.h
You missed to add a MAINTAINERS file for this board.
> --- /dev/null
> +++ b/board/freescale/mx7dsabresd/imximage.cfg
> @@ -0,0 +1,110 @@
> +/*
> + * Copyright (C) 2015 Freescale Semiconductor, Inc.
> + *
> + * SPDX-License-Identifier: GPL-2.0+
> + *
> + * Refer docs/README.imxmage for more details about how-to configure
> + * and create imximage boot image
> + *
> + * The syntax is taken as close as possible with the kwbimage
> + */
> +
> +#define __ASSEMBLY__
> +#include <config.h>
> +
> +/* image version */
> +
> +IMAGE_VERSION 2
> +
> +/*
> + * Boot Device : one of
> + * spi/sd/nand/onenand, qspi/nor
> + */
> +
> +#ifdef CONFIG_SYS_BOOT_QSPI
> +BOOT_FROM qspi
> +#elif defined(CONFIG_SYS_BOOT_EIMNOR)
> +BOOT_FROM nor
> +#else
> +BOOT_FROM sd
> +#endif
> +
> +#ifdef CONFIG_USE_PLUGIN
This option only exists in the FSL U-boot, not in mainline.
> +/*PLUGIN plugin-binary-file IRAM_FREE_START_ADDR*/
> +PLUGIN board/freescale/mx7dsabresd/plugin.bin 0x00910000
> +#else
> +
> +#ifdef CONFIG_SECURE_BOOT
> +CSF CONFIG_CSF_SIZE
> +#endif
> +#include <asm/arch/clock.h>
> +#include <asm/arch/imx-regs.h>
> +#include <asm/arch/mx7-pins.h>
> +#include <asm/arch/sys_proto.h>
> +#include <asm/gpio.h>
> +#include <asm/imx-common/iomux-v3.h>
> +#include <asm/imx-common/boot_mode.h>
> +#include <asm/io.h>
> +#include <linux/sizes.h>
> +#include <common.h>
> +#include <fsl_esdhc.h>
> +#include <mmc.h>
> +#include <miiphy.h>
> +#include <netdev.h>
> +#include <power/pmic.h>
> +#include <power/pfuze300_pmic.h>
> +#include "../common/pfuze.h"
> +#ifdef CONFIG_SYS_I2C_MXC
No need to use ifdef for header files.
> +static struct fsl_esdhc_cfg usdhc_cfg[3] = {
> + {USDHC1_BASE_ADDR, 0, 4},
> + {USDHC3_BASE_ADDR},
> +};
> +
> +int mmc_get_env_devno(void)
static
> +{
> + struct bootrom_sw_info **p =
> + (struct bootrom_sw_info **)ROM_SW_INFO_ADDR;
> +
> + u8 boot_type = (*p)->boot_dev_type;
> + u8 dev_no = (*p)->boot_dev_instance;
> +
> + /* If not boot from sd/mmc, use default value */
> + if ((boot_type != BOOT_TYPE_SD) && (boot_type != BOOT_TYPE_MMC))
> + return CONFIG_SYS_MMC_ENV_DEV;
> +
> + if (2 == dev_no)
> + dev_no--;
> +
> + return dev_no;
> +}
> +
> +int mmc_map_to_kernel_blk(int dev_no)
static
> +{
> + if (1 == dev_no)
> + dev_no++;
> +
> + return dev_no;
> +}
> +
> +int board_mmc_getcd(struct mmc *mmc)
> +{
> + struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv;
> + int ret = 0;
> +
> + switch (cfg->esdhc_base) {
> + case USDHC1_BASE_ADDR:
> + ret = !gpio_get_value(USDHC1_CD_GPIO);
> + break;
> + case USDHC3_BASE_ADDR:
> + ret = 1; /* Assume uSDHC3 emmc is always present */
> + break;
> + }
> +
> + return ret;
> +}
> +
> +int board_mmc_init(bd_t *bis)
> +{
> + int i, ret;
> + /*
> + * According to the board_mmc_init() the following map is done:
> + * (U-boot device node) (Physical Port)
> + * mmc0 USDHC1
> + * mmc2 USDHC3 (eMMC)
> + */
> + for (i = 0; i < CONFIG_SYS_FSL_USDHC_NUM; i++) {
> + switch (i) {
> + case 0:
> + imx_iomux_v3_setup_multiple_pads(
> + usdhc1_pads, ARRAY_SIZE(usdhc1_pads));
> + gpio_request(USDHC1_CD_GPIO, "usdhc1_cd");
> + gpio_direction_input(USDHC1_CD_GPIO);
> + gpio_request(USDHC1_PWR_GPIO, "usdhc1_pwr");
> + gpio_direction_output(USDHC1_PWR_GPIO, 0);
> + udelay(500);
> + gpio_direction_output(USDHC1_PWR_GPIO, 1);
> + usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK);
> + break;
> + case 1:
> + imx_iomux_v3_setup_multiple_pads(
> + usdhc3_emmc_pads, ARRAY_SIZE(usdhc3_emmc_pads));
> + gpio_request(USDHC3_PWR_GPIO, "usdhc3_pwr");
> + gpio_direction_output(USDHC3_PWR_GPIO, 0);
> + udelay(500);
> + gpio_direction_output(USDHC3_PWR_GPIO, 1);
> + usdhc_cfg[1].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK);
> + break;
> + default:
> + printf("Warning: you configured more USDHC controllers"
> + "(%d) than supported by the board\n", i + 1);
> + return 0;
You should return -EINVAL.
> + }
> +
> + ret = fsl_esdhc_initialize(bis, &usdhc_cfg[i]);
> + if (ret)
> + return ret;
> + }
> +
> + return 0;
> +}
> +
> +int check_mmc_autodetect(void)
> +{
> + char *autodetect_str = getenv("mmcautodetect");
> +
> + if ((autodetect_str != NULL) &&
> + (strcmp(autodetect_str, "yes") == 0)) {
> + return 1;
> + }
> +
> + return 0;
> +}
> +
> +void board_late_mmc_init(void)
> +{
> + char cmd[32];
> + char mmcblk[32];
> + u32 dev_no = mmc_get_env_devno();
> +
> + if (!check_mmc_autodetect())
> + return;
> +
> + setenv_ulong("mmcdev", dev_no);
> +
> + /* Set mmcblk env */
> + sprintf(mmcblk, "/dev/mmcblk%dp2 rootwait rw",
> + mmc_map_to_kernel_blk(dev_no));
> + setenv("mmcroot", mmcblk);
> +
> + sprintf(cmd, "mmc dev %d", dev_no);
> + run_command(cmd, 0);
> +}
> +
> +#endif
> +
> +#ifdef CONFIG_FEC_MXC
> +int board_eth_init(bd_t *bis)
> +{
> + int ret;
> +
> + setup_iomux_fec();
> +
> + ret = fecmxc_initialize_multi(bis, 0,
> + CONFIG_FEC_MXC_PHYADDR, IMX_FEC_BASE);
> + if (ret)
> + printf("FEC1 MXC: %s:failed\n", __func__);
> +
> + return ret;
> +}
> +
> +static int setup_fec(void)
> +{
> + struct iomuxc_gpr_base_regs *const iomuxc_gpr_regs
> + = (struct iomuxc_gpr_base_regs *) IOMUXC_GPR_BASE_ADDR;
> + int ret;
> +
> + /* Use 125M anatop REF_CLK1 for ENET1, clear gpr1[13], gpr1[17]*/
> + clrsetbits_le32(&iomuxc_gpr_regs->gpr[1],
> + (IOMUXC_GPR_GPR1_GPR_ENET1_TX_CLK_SEL_MASK |
> + IOMUXC_GPR_GPR1_GPR_ENET1_CLK_DIR_MASK), 0);
> +
> + ret = set_clk_enet(ENET_125MHz);
> + if (ret)
> + return ret;
> +
> + return 0;
You could return set_clk_enet
> +#ifdef CONFIG_USB_EHCI_MX7
> +iomux_v3_cfg_t const usb_otg1_pads[] = {
> + MX7D_PAD_GPIO1_IO05__USB_OTG1_PWR | MUX_PAD_CTRL(NO_PAD_CTRL),
> +};
> +
> +iomux_v3_cfg_t const usb_otg2_pads[] = {
> + MX7D_PAD_UART3_CTS_B__USB_OTG2_PWR | MUX_PAD_CTRL(NO_PAD_CTRL),
> +};
> +
> +int board_ehci_hcd_init(int port)
> +{
> + switch (port) {
> + case 0:
> + imx_iomux_v3_setup_multiple_pads(usb_otg1_pads,
> + ARRAY_SIZE(usb_otg1_pads));
> + break;
> + case 1:
> + imx_iomux_v3_setup_multiple_pads(usb_otg2_pads,
> + ARRAY_SIZE(usb_otg2_pads));
> + break;
> + default:
> + printf("MXC USB port %d not yet supported\n", port);
> + return 1;
-EINVAL
> + }
> + return 0;
> +}
> +#endif
> +
> +#ifdef CONFIG_IMX_UDC
> +void udc_pins_setting(void)
> +{
> +}
> +
CONFIG_IMX_UDC does not exist in mainline U-boot.
> +#endif /*CONFIG_IMX_UDC*/
> diff --git a/configs/mx7dsabresd_defconfig b/configs/mx7dsabresd_defconfig
> new file mode 100644
> index 0000000..879847c
> --- /dev/null
> +++ b/configs/mx7dsabresd_defconfig
> @@ -0,0 +1,10 @@
> +CONFIG_SYS_EXTRA_OPTIONS="IMX_CONFIG=board/freescale/mx7dsabresd/imximage.cfg,MX7D"
> +CONFIG_ARM=y
> +CONFIG_TARGET_MX7DSABRESD=y
> +CONFIG_SYS_MALLOC_F=y
> +CONFIG_SYS_MALLOC_F_LEN=0x400
> +# CONFIG_CMD_BOOTD is not set
> +# CONFIG_CMD_SETEXPR is not set
> +# CONFIG_CMD_IMI is not set
> +# CONFIG_CMD_IMLS is not set
> +# CONFIG_CMD_XIMG is not set
> diff --git a/include/configs/mx7_common.h b/include/configs/mx7_common.h
> new file mode 100644
> index 0000000..25f79f3
> --- /dev/null
> +++ b/include/configs/mx7_common.h
> @@ -0,0 +1,22 @@
> +/*
> + * Copyright (C) 2015 Freescale Semiconductor, Inc.
> + *
> + * Configuration settings for the Freescale i.MX7.
> + *
> + * SPDX-License-Identifier: GPL-2.0+
> + */
> +
> +
> +#ifndef __MX7_COMMON_H
> +#define __MX7_COMMON_H
> +
> +#define CONFIG_BOARD_POSTCLK_INIT
> +#define CONFIG_MXC_GPT_HCLK
> +
> +#define CONFIG_SYSCOUNTER_TIMER
> +#define CONFIG_SC_TIMER_CLK 8000000 /* 8Mhz */
> +
> +#define CONFIG_IOMUX_LPSR
> +#define CONFIG_IMX_FIXED_IVT_OFFSET
> +
> +#endif
> diff --git a/include/configs/mx7dsabresd.h b/include/configs/mx7dsabresd.h
> new file mode 100644
> index 0000000..4119646
> --- /dev/null
> +++ b/include/configs/mx7dsabresd.h
> @@ -0,0 +1,382 @@
> +/*
> + * Copyright (C) 2015 Freescale Semiconductor, Inc.
> + *
> + * Configuration settings for the Freescale i.MX7D SABRESD board.
> + *
> + * SPDX-License-Identifier: GPL-2.0+
> + */
> +
> +#ifndef __MX7D_SABRESD_CONFIG_H
> +#define __MX7D_SABRESD_CONFIG_H
> +
> +#include <asm/arch/imx-regs.h>
> +#include <linux/sizes.h>
> +#include "mx7_common.h"
> +#include <asm/imx-common/gpio.h>
> +
> +#define CONFIG_MX7
> +#define CONFIG_ROM_UNIFIED_SECTIONS
> +#define CONFIG_SYS_GENERIC_BOARD
> +#define CONFIG_DISPLAY_CPUINFO
> +#define CONFIG_DISPLAY_BOARDINFO
> +
> +#define CONFIG_DBG_MONITOR
> +/* uncomment for PLUGIN mode support */
> +/* #define CONFIG_USE_PLUGIN */
> +
> +/* uncomment for SECURE mode support */
> +/* #define CONFIG_SECURE_BOOT */
> +
> +#ifdef CONFIG_SECURE_BOOT
> +#ifndef CONFIG_CSF_SIZE
> +#define CONFIG_CSF_SIZE 0x4000
> +#endif
> +#endif
> +
> +#define CONFIG_CMDLINE_TAG
> +#define CONFIG_SETUP_MEMORY_TAGS
> +#define CONFIG_INITRD_TAG
> +#define CONFIG_REVISION_TAG
> +
> +/* Size of malloc() pool */
> +#define CONFIG_SYS_MALLOC_LEN (32 * SZ_1M)
> +
> +#define CONFIG_BOARD_EARLY_INIT_F
> +#define CONFIG_BOARD_LATE_INIT
> +#define CONFIG_MXC_GPIO
> +
> +#define CONFIG_MXC_UART
> +#define CONFIG_MXC_UART_BASE UART1_IPS_BASE_ADDR
> +
> +/* allow to overwrite serial and ethaddr */
> +#define CONFIG_ENV_OVERWRITE
> +#define CONFIG_CONS_INDEX 1
> +#define CONFIG_BAUDRATE 115200
> +
> +#define CONFIG_CMD_FUSE
> +#ifdef CONFIG_CMD_FUSE
> +#define CONFIG_MXC_OCOTP
> +#endif
> +
> +/* MMC Configs */
> +#define CONFIG_FSL_ESDHC
> +#define CONFIG_FSL_USDHC
> +#define CONFIG_SYS_FSL_ESDHC_ADDR 0
> +
> +#define CONFIG_MMC
> +#define CONFIG_CMD_MMC
> +#define CONFIG_GENERIC_MMC
> +#define CONFIG_CMD_FAT
> +#define CONFIG_DOS_PARTITION
> +#define CONFIG_SUPPORT_EMMC_BOOT /* eMMC specific */
> +
> +#define PHYS_SDRAM_SIZE SZ_1G
> +
> +#define CONFIG_CMD_PING
> +#define CONFIG_CMD_DHCP
> +#define CONFIG_CMD_MII
> +#define CONFIG_FEC_MXC
> +#define CONFIG_MII
> +#define CONFIG_FEC_XCV_TYPE RGMII
> +#define CONFIG_ETHPRIME "FEC"
> +#define CONFIG_FEC_MXC_PHYADDR 0
> +
> +#define CONFIG_PHYLIB
> +#define CONFIG_PHY_BROADCOM
> +#define CONFIG_FEC_DMA_MINALIGN 64
> +
> +/* ENET1 */
> +#define IMX_FEC_BASE ENET_IPS_BASE_ADDR
> +
> +/* PMIC */
> +#define CONFIG_POWER
> +#define CONFIG_POWER_I2C
> +#define CONFIG_POWER_PFUZE300
> +#define CONFIG_POWER_PFUZE300_I2C_ADDR 0x08
> +
> +#undef CONFIG_BOOTM_NETBSD
> +#undef CONFIG_BOOTM_PLAN9
> +#undef CONFIG_BOOTM_RTEMS
> +
> +#undef CONFIG_CMD_EXPORTENV
> +#undef CONFIG_CMD_IMPORTENV
> +
> +/* I2C configs */
> +#define CONFIG_CMD_I2C
> +#define CONFIG_SYS_I2C
> +#define CONFIG_SYS_I2C_MXC
> +#define CONFIG_SYS_I2C_MXC_I2C1
> +#define CONFIG_SYS_I2C_SPEED 100000
> +
> +#undef CONFIG_CMD_IMLS
> +
> +#define CONFIG_BOOTDELAY 3
> +
> +#define CONFIG_LOADADDR 0x80800000
> +#define CONFIG_SYS_TEXT_BASE 0x87800000
> +
> +#define CONFIG_SYS_AUXCORE_BOOTDATA 0x60000000 /* Set to QSPI1 A flash at default */
> +#define CONFIG_CMD_BOOTAUX /* Boot M4 */
> +
> +#ifdef CONFIG_CMD_BOOTAUX
This config option does not exist in U-boot mainline.
> +/* Miscellaneous configurable options */
> +#define CONFIG_SYS_LONGHELP
> +#define CONFIG_SYS_HUSH_PARSER
> +#define CONFIG_SYS_PROMPT "=> "
This is the default prompt, no need to set it explicitly.
> +#define CONFIG_AUTO_COMPLETE
> +#define CONFIG_SYS_CBSIZE 1024
> +
> +/* Print Buffer Size */
> +#define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16)
Please remove this line, as it is better to use the default. This
value can cause a U-boot hang if the maximum allowed number of strings
is entered in console.
More information about the U-Boot
mailing list