183d290c5STom Rini // SPDX-License-Identifier: GPL-2.0+
26b0071c1SPeter Senna Tschudin /*
36b0071c1SPeter Senna Tschudin * Copyright 2017 General Electric Company
46b0071c1SPeter Senna Tschudin *
56b0071c1SPeter Senna Tschudin * Based on board/freescale/mx53loco/mx53loco.c:
66b0071c1SPeter Senna Tschudin *
76b0071c1SPeter Senna Tschudin * Copyright (C) 2011 Freescale Semiconductor, Inc.
86b0071c1SPeter Senna Tschudin * Jason Liu <r64343@freescale.com>
96b0071c1SPeter Senna Tschudin */
106b0071c1SPeter Senna Tschudin
116b0071c1SPeter Senna Tschudin #include <common.h>
126b0071c1SPeter Senna Tschudin #include <asm/io.h>
136b0071c1SPeter Senna Tschudin #include <asm/arch/imx-regs.h>
146b0071c1SPeter Senna Tschudin #include <asm/arch/sys_proto.h>
156b0071c1SPeter Senna Tschudin #include <asm/arch/crm_regs.h>
166b0071c1SPeter Senna Tschudin #include <asm/arch/clock.h>
176b0071c1SPeter Senna Tschudin #include <asm/arch/iomux-mx53.h>
186b0071c1SPeter Senna Tschudin #include <asm/arch/clock.h>
196b0071c1SPeter Senna Tschudin #include <linux/errno.h>
206b0071c1SPeter Senna Tschudin #include <asm/mach-imx/mxc_i2c.h>
216b0071c1SPeter Senna Tschudin #include <asm/mach-imx/mx5_video.h>
229925f1dbSAlex Kiernan #include <environment.h>
236b0071c1SPeter Senna Tschudin #include <netdev.h>
246b0071c1SPeter Senna Tschudin #include <i2c.h>
256b0071c1SPeter Senna Tschudin #include <mmc.h>
266b0071c1SPeter Senna Tschudin #include <fsl_esdhc.h>
276b0071c1SPeter Senna Tschudin #include <asm/gpio.h>
286b0071c1SPeter Senna Tschudin #include <power/pmic.h>
296b0071c1SPeter Senna Tschudin #include <dialog_pmic.h>
306b0071c1SPeter Senna Tschudin #include <fsl_pmic.h>
316b0071c1SPeter Senna Tschudin #include <linux/fb.h>
326b0071c1SPeter Senna Tschudin #include <ipu_pixfmt.h>
336b0071c1SPeter Senna Tschudin #include <watchdog.h>
346b0071c1SPeter Senna Tschudin #include "ppd_gpio.h"
356b0071c1SPeter Senna Tschudin #include <stdlib.h>
36647155bcSMartyn Welch #include "../../ge/common/ge_common.h"
376b0071c1SPeter Senna Tschudin #include "../../ge/common/vpd_reader.h"
386b0071c1SPeter Senna Tschudin
396b0071c1SPeter Senna Tschudin #define MX53PPD_LCD_POWER IMX_GPIO_NR(3, 24)
406b0071c1SPeter Senna Tschudin
416b0071c1SPeter Senna Tschudin DECLARE_GLOBAL_DATA_PTR;
426b0071c1SPeter Senna Tschudin
436b0071c1SPeter Senna Tschudin static u32 mx53_dram_size[2];
446b0071c1SPeter Senna Tschudin
get_effective_memsize(void)456b0071c1SPeter Senna Tschudin phys_size_t get_effective_memsize(void)
466b0071c1SPeter Senna Tschudin {
476b0071c1SPeter Senna Tschudin /*
486b0071c1SPeter Senna Tschudin * WARNING: We must override get_effective_memsize() function here
496b0071c1SPeter Senna Tschudin * to report only the size of the first DRAM bank. This is to make
506b0071c1SPeter Senna Tschudin * U-Boot relocator place U-Boot into valid memory, that is, at the
516b0071c1SPeter Senna Tschudin * end of the first DRAM bank. If we did not override this function
526b0071c1SPeter Senna Tschudin * like so, U-Boot would be placed at the address of the first DRAM
536b0071c1SPeter Senna Tschudin * bank + total DRAM size - sizeof(uboot), which in the setup where
546b0071c1SPeter Senna Tschudin * each DRAM bank contains 512MiB of DRAM would result in placing
556b0071c1SPeter Senna Tschudin * U-Boot into invalid memory area close to the end of the first
566b0071c1SPeter Senna Tschudin * DRAM bank.
576b0071c1SPeter Senna Tschudin */
586b0071c1SPeter Senna Tschudin return mx53_dram_size[0];
596b0071c1SPeter Senna Tschudin }
606b0071c1SPeter Senna Tschudin
dram_init(void)616b0071c1SPeter Senna Tschudin int dram_init(void)
626b0071c1SPeter Senna Tschudin {
636b0071c1SPeter Senna Tschudin mx53_dram_size[0] = get_ram_size((void *)PHYS_SDRAM_1, 1 << 30);
646b0071c1SPeter Senna Tschudin mx53_dram_size[1] = get_ram_size((void *)PHYS_SDRAM_2, 1 << 30);
656b0071c1SPeter Senna Tschudin
666b0071c1SPeter Senna Tschudin gd->ram_size = mx53_dram_size[0] + mx53_dram_size[1];
676b0071c1SPeter Senna Tschudin
686b0071c1SPeter Senna Tschudin return 0;
696b0071c1SPeter Senna Tschudin }
706b0071c1SPeter Senna Tschudin
dram_init_banksize(void)716b0071c1SPeter Senna Tschudin int dram_init_banksize(void)
726b0071c1SPeter Senna Tschudin {
736b0071c1SPeter Senna Tschudin gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
746b0071c1SPeter Senna Tschudin gd->bd->bi_dram[0].size = mx53_dram_size[0];
756b0071c1SPeter Senna Tschudin
766b0071c1SPeter Senna Tschudin gd->bd->bi_dram[1].start = PHYS_SDRAM_2;
776b0071c1SPeter Senna Tschudin gd->bd->bi_dram[1].size = mx53_dram_size[1];
786b0071c1SPeter Senna Tschudin
796b0071c1SPeter Senna Tschudin return 0;
806b0071c1SPeter Senna Tschudin }
816b0071c1SPeter Senna Tschudin
get_board_rev(void)826b0071c1SPeter Senna Tschudin u32 get_board_rev(void)
836b0071c1SPeter Senna Tschudin {
846b0071c1SPeter Senna Tschudin return get_cpu_rev() & ~(0xF << 8);
856b0071c1SPeter Senna Tschudin }
866b0071c1SPeter Senna Tschudin
876b0071c1SPeter Senna Tschudin #define UART_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_DSE_HIGH | \
886b0071c1SPeter Senna Tschudin PAD_CTL_PUS_100K_UP | PAD_CTL_ODE)
896b0071c1SPeter Senna Tschudin
906b0071c1SPeter Senna Tschudin #ifdef CONFIG_USB_EHCI_MX5
board_ehci_hcd_init(int port)916b0071c1SPeter Senna Tschudin int board_ehci_hcd_init(int port)
926b0071c1SPeter Senna Tschudin {
936b0071c1SPeter Senna Tschudin /* request VBUS power enable pin, GPIO7_8 */
946b0071c1SPeter Senna Tschudin imx_iomux_v3_setup_pad(MX53_PAD_PATA_DA_2__GPIO7_8);
956b0071c1SPeter Senna Tschudin gpio_direction_output(IMX_GPIO_NR(7, 8), 1);
966b0071c1SPeter Senna Tschudin return 0;
976b0071c1SPeter Senna Tschudin }
986b0071c1SPeter Senna Tschudin #endif
996b0071c1SPeter Senna Tschudin
setup_iomux_fec(void)1006b0071c1SPeter Senna Tschudin static void setup_iomux_fec(void)
1016b0071c1SPeter Senna Tschudin {
1026b0071c1SPeter Senna Tschudin static const iomux_v3_cfg_t fec_pads[] = {
1036b0071c1SPeter Senna Tschudin NEW_PAD_CTRL(MX53_PAD_FEC_MDIO__FEC_MDIO, PAD_CTL_HYS |
1046b0071c1SPeter Senna Tschudin PAD_CTL_DSE_HIGH | PAD_CTL_PUS_22K_UP |
1056b0071c1SPeter Senna Tschudin PAD_CTL_ODE),
1066b0071c1SPeter Senna Tschudin NEW_PAD_CTRL(MX53_PAD_FEC_MDC__FEC_MDC, PAD_CTL_DSE_HIGH),
1076b0071c1SPeter Senna Tschudin NEW_PAD_CTRL(MX53_PAD_FEC_RXD1__FEC_RDATA_1,
1086b0071c1SPeter Senna Tschudin PAD_CTL_HYS | PAD_CTL_PKE),
1096b0071c1SPeter Senna Tschudin NEW_PAD_CTRL(MX53_PAD_FEC_RXD0__FEC_RDATA_0,
1106b0071c1SPeter Senna Tschudin PAD_CTL_HYS | PAD_CTL_PKE),
1116b0071c1SPeter Senna Tschudin NEW_PAD_CTRL(MX53_PAD_FEC_TXD1__FEC_TDATA_1, PAD_CTL_DSE_HIGH),
1126b0071c1SPeter Senna Tschudin NEW_PAD_CTRL(MX53_PAD_FEC_TXD0__FEC_TDATA_0, PAD_CTL_DSE_HIGH),
1136b0071c1SPeter Senna Tschudin NEW_PAD_CTRL(MX53_PAD_FEC_TX_EN__FEC_TX_EN, PAD_CTL_DSE_HIGH),
1146b0071c1SPeter Senna Tschudin NEW_PAD_CTRL(MX53_PAD_FEC_REF_CLK__FEC_TX_CLK,
1156b0071c1SPeter Senna Tschudin PAD_CTL_HYS | PAD_CTL_PKE),
1166b0071c1SPeter Senna Tschudin NEW_PAD_CTRL(MX53_PAD_FEC_RX_ER__FEC_RX_ER,
1176b0071c1SPeter Senna Tschudin PAD_CTL_HYS | PAD_CTL_PKE),
1186b0071c1SPeter Senna Tschudin NEW_PAD_CTRL(MX53_PAD_FEC_CRS_DV__FEC_RX_DV,
1196b0071c1SPeter Senna Tschudin PAD_CTL_HYS | PAD_CTL_PKE),
1206b0071c1SPeter Senna Tschudin };
1216b0071c1SPeter Senna Tschudin
1226b0071c1SPeter Senna Tschudin imx_iomux_v3_setup_multiple_pads(fec_pads, ARRAY_SIZE(fec_pads));
1236b0071c1SPeter Senna Tschudin }
1246b0071c1SPeter Senna Tschudin
1256b0071c1SPeter Senna Tschudin #ifdef CONFIG_FSL_ESDHC
1266b0071c1SPeter Senna Tschudin struct fsl_esdhc_cfg esdhc_cfg[2] = {
1276b0071c1SPeter Senna Tschudin {MMC_SDHC3_BASE_ADDR},
1286b0071c1SPeter Senna Tschudin {MMC_SDHC1_BASE_ADDR},
1296b0071c1SPeter Senna Tschudin };
1306b0071c1SPeter Senna Tschudin
board_mmc_getcd(struct mmc * mmc)1316b0071c1SPeter Senna Tschudin int board_mmc_getcd(struct mmc *mmc)
1326b0071c1SPeter Senna Tschudin {
1336b0071c1SPeter Senna Tschudin return 1;
1346b0071c1SPeter Senna Tschudin }
1356b0071c1SPeter Senna Tschudin
1366b0071c1SPeter Senna Tschudin #define SD_CMD_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_DSE_HIGH | \
1376b0071c1SPeter Senna Tschudin PAD_CTL_PUS_100K_UP)
1386b0071c1SPeter Senna Tschudin #define SD_PAD_CTRL (PAD_CTL_HYS | PAD_CTL_PUS_47K_UP | \
1396b0071c1SPeter Senna Tschudin PAD_CTL_DSE_HIGH)
1406b0071c1SPeter Senna Tschudin
board_mmc_init(bd_t * bis)1416b0071c1SPeter Senna Tschudin int board_mmc_init(bd_t *bis)
1426b0071c1SPeter Senna Tschudin {
1436b0071c1SPeter Senna Tschudin static const iomux_v3_cfg_t sd1_pads[] = {
1446b0071c1SPeter Senna Tschudin NEW_PAD_CTRL(MX53_PAD_PATA_RESET_B__ESDHC3_CMD,
1456b0071c1SPeter Senna Tschudin SD_CMD_PAD_CTRL),
1466b0071c1SPeter Senna Tschudin NEW_PAD_CTRL(MX53_PAD_PATA_IORDY__ESDHC3_CLK, SD_PAD_CTRL),
1476b0071c1SPeter Senna Tschudin NEW_PAD_CTRL(MX53_PAD_PATA_DATA8__ESDHC3_DAT0, SD_PAD_CTRL),
1486b0071c1SPeter Senna Tschudin NEW_PAD_CTRL(MX53_PAD_PATA_DATA9__ESDHC3_DAT1, SD_PAD_CTRL),
1496b0071c1SPeter Senna Tschudin NEW_PAD_CTRL(MX53_PAD_PATA_DATA10__ESDHC3_DAT2, SD_PAD_CTRL),
1506b0071c1SPeter Senna Tschudin NEW_PAD_CTRL(MX53_PAD_PATA_DATA11__ESDHC3_DAT3, SD_PAD_CTRL),
1516b0071c1SPeter Senna Tschudin NEW_PAD_CTRL(MX53_PAD_PATA_DATA0__ESDHC3_DAT4, SD_PAD_CTRL),
1526b0071c1SPeter Senna Tschudin NEW_PAD_CTRL(MX53_PAD_PATA_DATA1__ESDHC3_DAT5, SD_PAD_CTRL),
1536b0071c1SPeter Senna Tschudin NEW_PAD_CTRL(MX53_PAD_PATA_DATA2__ESDHC3_DAT6, SD_PAD_CTRL),
1546b0071c1SPeter Senna Tschudin NEW_PAD_CTRL(MX53_PAD_PATA_DATA3__ESDHC3_DAT7, SD_PAD_CTRL),
1556b0071c1SPeter Senna Tschudin MX53_PAD_EIM_DA11__GPIO3_11,
1566b0071c1SPeter Senna Tschudin };
1576b0071c1SPeter Senna Tschudin
1586b0071c1SPeter Senna Tschudin static const iomux_v3_cfg_t sd2_pads[] = {
1596b0071c1SPeter Senna Tschudin NEW_PAD_CTRL(MX53_PAD_SD1_CMD__ESDHC1_CMD, SD_CMD_PAD_CTRL),
1606b0071c1SPeter Senna Tschudin NEW_PAD_CTRL(MX53_PAD_SD1_CLK__ESDHC1_CLK, SD_PAD_CTRL),
1616b0071c1SPeter Senna Tschudin NEW_PAD_CTRL(MX53_PAD_SD1_DATA0__ESDHC1_DAT0, SD_PAD_CTRL),
1626b0071c1SPeter Senna Tschudin NEW_PAD_CTRL(MX53_PAD_SD1_DATA1__ESDHC1_DAT1, SD_PAD_CTRL),
1636b0071c1SPeter Senna Tschudin NEW_PAD_CTRL(MX53_PAD_SD1_DATA2__ESDHC1_DAT2, SD_PAD_CTRL),
1646b0071c1SPeter Senna Tschudin NEW_PAD_CTRL(MX53_PAD_SD1_DATA3__ESDHC1_DAT3, SD_PAD_CTRL),
1656b0071c1SPeter Senna Tschudin MX53_PAD_EIM_DA13__GPIO3_13,
1666b0071c1SPeter Senna Tschudin };
1676b0071c1SPeter Senna Tschudin
1686b0071c1SPeter Senna Tschudin u32 index;
1696b0071c1SPeter Senna Tschudin int ret;
1706b0071c1SPeter Senna Tschudin
1716b0071c1SPeter Senna Tschudin esdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK);
1726b0071c1SPeter Senna Tschudin esdhc_cfg[1].sdhc_clk = mxc_get_clock(MXC_ESDHC_CLK);
1736b0071c1SPeter Senna Tschudin
1746b0071c1SPeter Senna Tschudin for (index = 0; index < CONFIG_SYS_FSL_ESDHC_NUM; index++) {
1756b0071c1SPeter Senna Tschudin switch (index) {
1766b0071c1SPeter Senna Tschudin case 0:
1776b0071c1SPeter Senna Tschudin imx_iomux_v3_setup_multiple_pads(sd1_pads,
1786b0071c1SPeter Senna Tschudin ARRAY_SIZE(sd1_pads));
1796b0071c1SPeter Senna Tschudin break;
1806b0071c1SPeter Senna Tschudin case 1:
1816b0071c1SPeter Senna Tschudin imx_iomux_v3_setup_multiple_pads(sd2_pads,
1826b0071c1SPeter Senna Tschudin ARRAY_SIZE(sd2_pads));
1836b0071c1SPeter Senna Tschudin break;
1846b0071c1SPeter Senna Tschudin default:
1856b0071c1SPeter Senna Tschudin printf("Warning: you configured more ESDHC controller (%d) as supported by the board(2)\n",
1866b0071c1SPeter Senna Tschudin CONFIG_SYS_FSL_ESDHC_NUM);
1876b0071c1SPeter Senna Tschudin return -EINVAL;
1886b0071c1SPeter Senna Tschudin }
1896b0071c1SPeter Senna Tschudin ret = fsl_esdhc_initialize(bis, &esdhc_cfg[index]);
1906b0071c1SPeter Senna Tschudin if (ret)
1916b0071c1SPeter Senna Tschudin return ret;
1926b0071c1SPeter Senna Tschudin }
1936b0071c1SPeter Senna Tschudin
1946b0071c1SPeter Senna Tschudin return 0;
1956b0071c1SPeter Senna Tschudin }
1966b0071c1SPeter Senna Tschudin #endif
1976b0071c1SPeter Senna Tschudin
1986b0071c1SPeter Senna Tschudin #define I2C_PAD_CTRL (PAD_CTL_SRE_FAST | PAD_CTL_DSE_HIGH | \
1996b0071c1SPeter Senna Tschudin PAD_CTL_PUS_100K_UP | PAD_CTL_ODE)
2006b0071c1SPeter Senna Tschudin
setup_iomux_i2c(void)2016b0071c1SPeter Senna Tschudin static void setup_iomux_i2c(void)
2026b0071c1SPeter Senna Tschudin {
2036b0071c1SPeter Senna Tschudin static const iomux_v3_cfg_t i2c1_pads[] = {
2046b0071c1SPeter Senna Tschudin NEW_PAD_CTRL(MX53_PAD_CSI0_DAT8__I2C1_SDA, I2C_PAD_CTRL),
2056b0071c1SPeter Senna Tschudin NEW_PAD_CTRL(MX53_PAD_CSI0_DAT9__I2C1_SCL, I2C_PAD_CTRL),
2066b0071c1SPeter Senna Tschudin };
2076b0071c1SPeter Senna Tschudin
2086b0071c1SPeter Senna Tschudin imx_iomux_v3_setup_multiple_pads(i2c1_pads, ARRAY_SIZE(i2c1_pads));
2096b0071c1SPeter Senna Tschudin }
2106b0071c1SPeter Senna Tschudin
2116b0071c1SPeter Senna Tschudin #define I2C_PAD MUX_PAD_CTRL(I2C_PAD_CTRL)
2126b0071c1SPeter Senna Tschudin
2136b0071c1SPeter Senna Tschudin static struct i2c_pads_info i2c_pad_info1 = {
2146b0071c1SPeter Senna Tschudin .scl = {
2156b0071c1SPeter Senna Tschudin .i2c_mode = MX53_PAD_EIM_D21__I2C1_SCL | I2C_PAD,
2166b0071c1SPeter Senna Tschudin .gpio_mode = MX53_PAD_EIM_D28__GPIO3_28 | I2C_PAD,
2176b0071c1SPeter Senna Tschudin .gp = IMX_GPIO_NR(3, 28)
2186b0071c1SPeter Senna Tschudin },
2196b0071c1SPeter Senna Tschudin .sda = {
2206b0071c1SPeter Senna Tschudin .i2c_mode = MX53_PAD_EIM_D28__I2C1_SDA | I2C_PAD,
2216b0071c1SPeter Senna Tschudin .gpio_mode = MX53_PAD_EIM_D21__GPIO3_21 | I2C_PAD,
2226b0071c1SPeter Senna Tschudin .gp = IMX_GPIO_NR(3, 21)
2236b0071c1SPeter Senna Tschudin }
2246b0071c1SPeter Senna Tschudin };
2256b0071c1SPeter Senna Tschudin
clock_1GHz(void)2266b0071c1SPeter Senna Tschudin static int clock_1GHz(void)
2276b0071c1SPeter Senna Tschudin {
2286b0071c1SPeter Senna Tschudin int ret;
2296b0071c1SPeter Senna Tschudin u32 ref_clk = MXC_HCLK;
2306b0071c1SPeter Senna Tschudin /*
2316b0071c1SPeter Senna Tschudin * After increasing voltage to 1.25V, we can switch
2326b0071c1SPeter Senna Tschudin * CPU clock to 1GHz and DDR to 400MHz safely
2336b0071c1SPeter Senna Tschudin */
2346b0071c1SPeter Senna Tschudin ret = mxc_set_clock(ref_clk, 1000, MXC_ARM_CLK);
2356b0071c1SPeter Senna Tschudin if (ret) {
2366b0071c1SPeter Senna Tschudin printf("CPU: Switch CPU clock to 1GHZ failed\n");
2376b0071c1SPeter Senna Tschudin return -1;
2386b0071c1SPeter Senna Tschudin }
2396b0071c1SPeter Senna Tschudin
2406b0071c1SPeter Senna Tschudin ret = mxc_set_clock(ref_clk, 400, MXC_PERIPH_CLK);
2416b0071c1SPeter Senna Tschudin ret |= mxc_set_clock(ref_clk, 400, MXC_DDR_CLK);
2426b0071c1SPeter Senna Tschudin if (ret) {
2436b0071c1SPeter Senna Tschudin printf("CPU: Switch DDR clock to 400MHz failed\n");
2446b0071c1SPeter Senna Tschudin return -1;
2456b0071c1SPeter Senna Tschudin }
2466b0071c1SPeter Senna Tschudin
2476b0071c1SPeter Senna Tschudin return 0;
2486b0071c1SPeter Senna Tschudin }
2496b0071c1SPeter Senna Tschudin
ppd_gpio_init(void)2506b0071c1SPeter Senna Tschudin void ppd_gpio_init(void)
2516b0071c1SPeter Senna Tschudin {
2526b0071c1SPeter Senna Tschudin int i;
2536b0071c1SPeter Senna Tschudin
2546b0071c1SPeter Senna Tschudin imx_iomux_v3_setup_multiple_pads(ppd_pads, ARRAY_SIZE(ppd_pads));
2556b0071c1SPeter Senna Tschudin for (i = 0; i < ARRAY_SIZE(ppd_gpios); ++i)
2566b0071c1SPeter Senna Tschudin gpio_direction_output(ppd_gpios[i].gpio, ppd_gpios[i].value);
2576b0071c1SPeter Senna Tschudin }
2586b0071c1SPeter Senna Tschudin
board_early_init_f(void)2596b0071c1SPeter Senna Tschudin int board_early_init_f(void)
2606b0071c1SPeter Senna Tschudin {
2616b0071c1SPeter Senna Tschudin setup_iomux_fec();
2626b0071c1SPeter Senna Tschudin setup_iomux_lcd();
2636b0071c1SPeter Senna Tschudin ppd_gpio_init();
2646b0071c1SPeter Senna Tschudin
2656b0071c1SPeter Senna Tschudin return 0;
2666b0071c1SPeter Senna Tschudin }
2676b0071c1SPeter Senna Tschudin
2686b0071c1SPeter Senna Tschudin /*
2696b0071c1SPeter Senna Tschudin * Do not overwrite the console
2706b0071c1SPeter Senna Tschudin * Use always serial for U-Boot console
2716b0071c1SPeter Senna Tschudin */
overwrite_console(void)2726b0071c1SPeter Senna Tschudin int overwrite_console(void)
2736b0071c1SPeter Senna Tschudin {
2746b0071c1SPeter Senna Tschudin return 1;
2756b0071c1SPeter Senna Tschudin }
2766b0071c1SPeter Senna Tschudin
2776b0071c1SPeter Senna Tschudin #define VPD_TYPE_INVALID 0x00
2786b0071c1SPeter Senna Tschudin #define VPD_BLOCK_NETWORK 0x20
2796b0071c1SPeter Senna Tschudin #define VPD_BLOCK_HWID 0x44
2806b0071c1SPeter Senna Tschudin #define VPD_PRODUCT_PPD 4
2816b0071c1SPeter Senna Tschudin #define VPD_HAS_MAC1 0x1
2826b0071c1SPeter Senna Tschudin #define VPD_MAC_ADDRESS_LENGTH 6
2836b0071c1SPeter Senna Tschudin
2846b0071c1SPeter Senna Tschudin struct vpd_cache {
2856b0071c1SPeter Senna Tschudin u8 product_id;
2866b0071c1SPeter Senna Tschudin u8 has;
2876b0071c1SPeter Senna Tschudin unsigned char mac1[VPD_MAC_ADDRESS_LENGTH];
2886b0071c1SPeter Senna Tschudin };
2896b0071c1SPeter Senna Tschudin
2906b0071c1SPeter Senna Tschudin /*
2916b0071c1SPeter Senna Tschudin * Extracts MAC and product information from the VPD.
2926b0071c1SPeter Senna Tschudin */
vpd_callback(struct vpd_cache * userdata,u8 id,u8 version,u8 type,size_t size,u8 const * data)293*f026c1d9SPeng Fan static int vpd_callback(struct vpd_cache *userdata, u8 id, u8 version,
294*f026c1d9SPeng Fan u8 type, size_t size, u8 const *data)
2956b0071c1SPeter Senna Tschudin {
296*f026c1d9SPeng Fan struct vpd_cache *vpd = userdata;
2976b0071c1SPeter Senna Tschudin
2986b0071c1SPeter Senna Tschudin if (id == VPD_BLOCK_HWID && version == 1 && type != VPD_TYPE_INVALID &&
2996b0071c1SPeter Senna Tschudin size >= 1) {
3006b0071c1SPeter Senna Tschudin vpd->product_id = data[0];
3016b0071c1SPeter Senna Tschudin
3026b0071c1SPeter Senna Tschudin } else if (id == VPD_BLOCK_NETWORK && version == 1 &&
3036b0071c1SPeter Senna Tschudin type != VPD_TYPE_INVALID) {
3046b0071c1SPeter Senna Tschudin if (size >= 6) {
3056b0071c1SPeter Senna Tschudin vpd->has |= VPD_HAS_MAC1;
3066b0071c1SPeter Senna Tschudin memcpy(vpd->mac1, data, VPD_MAC_ADDRESS_LENGTH);
3076b0071c1SPeter Senna Tschudin }
3086b0071c1SPeter Senna Tschudin }
3096b0071c1SPeter Senna Tschudin
3106b0071c1SPeter Senna Tschudin return 0;
3116b0071c1SPeter Senna Tschudin }
3126b0071c1SPeter Senna Tschudin
process_vpd(struct vpd_cache * vpd)3136b0071c1SPeter Senna Tschudin static void process_vpd(struct vpd_cache *vpd)
3146b0071c1SPeter Senna Tschudin {
3156b0071c1SPeter Senna Tschudin int fec_index = -1;
3166b0071c1SPeter Senna Tschudin
3176b0071c1SPeter Senna Tschudin if (vpd->product_id == VPD_PRODUCT_PPD)
3186b0071c1SPeter Senna Tschudin fec_index = 0;
3196b0071c1SPeter Senna Tschudin
3206b0071c1SPeter Senna Tschudin if (fec_index >= 0 && (vpd->has & VPD_HAS_MAC1))
3216b0071c1SPeter Senna Tschudin eth_env_set_enetaddr("ethaddr", vpd->mac1);
3226b0071c1SPeter Senna Tschudin }
3236b0071c1SPeter Senna Tschudin
board_init(void)3246b0071c1SPeter Senna Tschudin int board_init(void)
3256b0071c1SPeter Senna Tschudin {
3266b0071c1SPeter Senna Tschudin gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
3276b0071c1SPeter Senna Tschudin
3286b0071c1SPeter Senna Tschudin mxc_set_sata_internal_clock();
3296b0071c1SPeter Senna Tschudin setup_iomux_i2c();
3306b0071c1SPeter Senna Tschudin
3316b0071c1SPeter Senna Tschudin setup_i2c(1, CONFIG_SYS_I2C_SPEED, 0x7f, &i2c_pad_info1);
3326b0071c1SPeter Senna Tschudin
3336b0071c1SPeter Senna Tschudin return 0;
3346b0071c1SPeter Senna Tschudin }
3356b0071c1SPeter Senna Tschudin
misc_init_r(void)3366b0071c1SPeter Senna Tschudin int misc_init_r(void)
3376b0071c1SPeter Senna Tschudin {
3386b0071c1SPeter Senna Tschudin const char *cause;
3396b0071c1SPeter Senna Tschudin
3406b0071c1SPeter Senna Tschudin /* We care about WDOG only, treating everything else as
3416b0071c1SPeter Senna Tschudin * a power-on-reset.
3426b0071c1SPeter Senna Tschudin */
3436b0071c1SPeter Senna Tschudin if (get_imx_reset_cause() & 0x0010)
3446b0071c1SPeter Senna Tschudin cause = "WDOG";
3456b0071c1SPeter Senna Tschudin else
3466b0071c1SPeter Senna Tschudin cause = "POR";
3476b0071c1SPeter Senna Tschudin
3486b0071c1SPeter Senna Tschudin env_set("bootcause", cause);
3496b0071c1SPeter Senna Tschudin
3506b0071c1SPeter Senna Tschudin return 0;
3516b0071c1SPeter Senna Tschudin }
3526b0071c1SPeter Senna Tschudin
board_late_init(void)3536b0071c1SPeter Senna Tschudin int board_late_init(void)
3546b0071c1SPeter Senna Tschudin {
3556b0071c1SPeter Senna Tschudin int res;
3564dcbccf7SDenis Zalevskiy struct vpd_cache vpd;
3576b0071c1SPeter Senna Tschudin
3584dcbccf7SDenis Zalevskiy memset(&vpd, 0, sizeof(vpd));
3594dcbccf7SDenis Zalevskiy res = read_vpd(&vpd, vpd_callback);
3604dcbccf7SDenis Zalevskiy if (!res)
3614dcbccf7SDenis Zalevskiy process_vpd(&vpd);
3624dcbccf7SDenis Zalevskiy else
3634dcbccf7SDenis Zalevskiy printf("Can't read VPD");
3646b0071c1SPeter Senna Tschudin
3656b0071c1SPeter Senna Tschudin res = clock_1GHz();
3666b0071c1SPeter Senna Tschudin if (res != 0)
3676b0071c1SPeter Senna Tschudin return res;
3686b0071c1SPeter Senna Tschudin
3696b0071c1SPeter Senna Tschudin print_cpuinfo();
3706b0071c1SPeter Senna Tschudin hw_watchdog_init();
3716b0071c1SPeter Senna Tschudin
3726b0071c1SPeter Senna Tschudin check_time();
3736b0071c1SPeter Senna Tschudin
3746b0071c1SPeter Senna Tschudin return 0;
3756b0071c1SPeter Senna Tschudin }
3766b0071c1SPeter Senna Tschudin
checkboard(void)3776b0071c1SPeter Senna Tschudin int checkboard(void)
3786b0071c1SPeter Senna Tschudin {
3796b0071c1SPeter Senna Tschudin puts("Board: GE PPD\n");
3806b0071c1SPeter Senna Tschudin
3816b0071c1SPeter Senna Tschudin return 0;
3826b0071c1SPeter Senna Tschudin }
383