Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Boris BREZILLON | 7832bf3 | 2015-03-04 13:13:05 +0100 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2013 Freescale Semiconductor, Inc. |
| 4 | * Copyright (C) 2015 ECA Sinters |
| 5 | * |
| 6 | * Author: Fabio Estevam <fabio.estevam@freescale.com> |
| 7 | * Modified by: Boris Brezillon <boris.brezillon@free-electrons.com> |
Boris BREZILLON | 7832bf3 | 2015-03-04 13:13:05 +0100 | [diff] [blame] | 8 | */ |
| 9 | |
Simon Glass | 8e16b1e | 2019-12-28 10:45:05 -0700 | [diff] [blame] | 10 | #include <init.h> |
Simon Glass | 274e0b0 | 2020-05-10 11:39:56 -0600 | [diff] [blame] | 11 | #include <net.h> |
Boris BREZILLON | 7832bf3 | 2015-03-04 13:13:05 +0100 | [diff] [blame] | 12 | #include <asm/arch/clock.h> |
| 13 | #include <asm/arch/imx-regs.h> |
| 14 | #include <asm/arch/iomux.h> |
| 15 | #include <asm/arch/mx6-pins.h> |
Simon Glass | dbd7954 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 16 | #include <linux/delay.h> |
Masahiro Yamada | 56a931c | 2016-09-21 11:28:55 +0900 | [diff] [blame] | 17 | #include <linux/errno.h> |
Boris BREZILLON | 7832bf3 | 2015-03-04 13:13:05 +0100 | [diff] [blame] | 18 | #include <asm/gpio.h> |
Stefano Babic | 33731bc | 2017-06-29 10:16:06 +0200 | [diff] [blame] | 19 | #include <asm/mach-imx/iomux-v3.h> |
| 20 | #include <asm/mach-imx/boot_mode.h> |
Boris BREZILLON | 7832bf3 | 2015-03-04 13:13:05 +0100 | [diff] [blame] | 21 | #include <malloc.h> |
| 22 | #include <mmc.h> |
Yangbo Lu | 7334038 | 2019-06-21 11:42:28 +0800 | [diff] [blame] | 23 | #include <fsl_esdhc_imx.h> |
Boris BREZILLON | 7832bf3 | 2015-03-04 13:13:05 +0100 | [diff] [blame] | 24 | #include <miiphy.h> |
| 25 | #include <netdev.h> |
| 26 | #include <asm/arch/mxc_hdmi.h> |
| 27 | #include <asm/arch/crm_regs.h> |
| 28 | #include <linux/fb.h> |
| 29 | #include <ipu_pixfmt.h> |
| 30 | #include <asm/io.h> |
| 31 | #include <asm/arch/sys_proto.h> |
Stefano Babic | 33731bc | 2017-06-29 10:16:06 +0200 | [diff] [blame] | 32 | #include <asm/mach-imx/mxc_i2c.h> |
Boris BREZILLON | 7832bf3 | 2015-03-04 13:13:05 +0100 | [diff] [blame] | 33 | #include <i2c.h> |
| 34 | |
| 35 | #include "../common/mx6.h" |
| 36 | |
| 37 | DECLARE_GLOBAL_DATA_PTR; |
| 38 | |
| 39 | int dram_init(void) |
| 40 | { |
| 41 | gd->ram_size = get_ram_size((void *)PHYS_SDRAM, PHYS_SDRAM_SIZE); |
| 42 | |
| 43 | return 0; |
| 44 | } |
| 45 | |
| 46 | int board_early_init_f(void) |
| 47 | { |
| 48 | seco_mx6_setup_uart_iomux(); |
| 49 | |
| 50 | return 0; |
| 51 | } |
| 52 | |
| 53 | int board_phy_config(struct phy_device *phydev) |
| 54 | { |
| 55 | seco_mx6_rgmii_rework(phydev); |
| 56 | if (phydev->drv->config) |
| 57 | phydev->drv->config(phydev); |
| 58 | |
| 59 | return 0; |
| 60 | } |
| 61 | |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 62 | int board_eth_init(struct bd_info *bis) |
Boris BREZILLON | 7832bf3 | 2015-03-04 13:13:05 +0100 | [diff] [blame] | 63 | { |
| 64 | uint32_t base = IMX_FEC_BASE; |
| 65 | struct mii_dev *bus = NULL; |
| 66 | struct phy_device *phydev = NULL; |
| 67 | int ret = 0; |
| 68 | |
| 69 | seco_mx6_setup_enet_iomux(); |
| 70 | |
| 71 | #ifdef CONFIG_FEC_MXC |
| 72 | bus = fec_get_miibus(base, -1); |
| 73 | if (!bus) |
| 74 | return -ENOMEM; |
| 75 | |
| 76 | /* scan phy 4,5,6,7 */ |
| 77 | phydev = phy_find_by_mask(bus, (0xf << 4), PHY_INTERFACE_MODE_RGMII); |
| 78 | if (!phydev) { |
| 79 | free(bus); |
| 80 | return -ENOMEM; |
| 81 | } |
| 82 | |
| 83 | printf("using phy at %d\n", phydev->addr); |
| 84 | ret = fec_probe(bis, -1, base, bus, phydev); |
| 85 | if (ret) { |
| 86 | free(phydev); |
| 87 | free(bus); |
| 88 | printf("FEC MXC: %s:failed\n", __func__); |
| 89 | } |
| 90 | #endif |
| 91 | |
| 92 | return ret; |
| 93 | } |
| 94 | |
Julien CORJON | 01d6398 | 2016-02-05 16:19:33 +0100 | [diff] [blame] | 95 | #define USDHC4_CD_GPIO IMX_GPIO_NR(2, 6) |
| 96 | |
Boris BREZILLON | 7832bf3 | 2015-03-04 13:13:05 +0100 | [diff] [blame] | 97 | static struct fsl_esdhc_cfg usdhc_cfg[2] = { |
Julien CORJON | acd0aa8 | 2016-02-05 16:19:32 +0100 | [diff] [blame] | 98 | {USDHC3_BASE_ADDR, 0, 4}, |
| 99 | {USDHC4_BASE_ADDR, 0, 4}, |
Boris BREZILLON | 7832bf3 | 2015-03-04 13:13:05 +0100 | [diff] [blame] | 100 | }; |
| 101 | |
Julien CORJON | 01d6398 | 2016-02-05 16:19:33 +0100 | [diff] [blame] | 102 | int board_mmc_getcd(struct mmc *mmc) |
| 103 | { |
| 104 | struct fsl_esdhc_cfg *cfg = (struct fsl_esdhc_cfg *)mmc->priv; |
| 105 | int ret = 0; |
| 106 | |
| 107 | switch (cfg->esdhc_base) { |
| 108 | case USDHC3_BASE_ADDR: |
| 109 | ret = 1; /* Assume eMMC is always present */ |
| 110 | break; |
| 111 | case USDHC4_BASE_ADDR: |
| 112 | ret = !gpio_get_value(USDHC4_CD_GPIO); |
| 113 | break; |
| 114 | } |
| 115 | |
| 116 | return ret; |
| 117 | } |
| 118 | |
Masahiro Yamada | f7ed78b | 2020-06-26 15:13:33 +0900 | [diff] [blame] | 119 | int board_mmc_init(struct bd_info *bis) |
Boris BREZILLON | 7832bf3 | 2015-03-04 13:13:05 +0100 | [diff] [blame] | 120 | { |
| 121 | u32 index = 0; |
| 122 | int ret; |
| 123 | |
| 124 | /* |
| 125 | * Following map is done: |
Bin Meng | 7557405 | 2016-02-05 19:30:11 -0800 | [diff] [blame] | 126 | * (U-Boot device node) (Physical Port) |
Boris BREZILLON | 7832bf3 | 2015-03-04 13:13:05 +0100 | [diff] [blame] | 127 | * mmc0 eMMC on Board |
| 128 | * mmc1 Ext SD |
| 129 | */ |
| 130 | for (index = 0; index < CONFIG_SYS_FSL_USDHC_NUM; ++index) { |
| 131 | switch (index) { |
| 132 | case 0: |
| 133 | seco_mx6_setup_usdhc_iomux(3); |
| 134 | usdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC3_CLK); |
Boris BREZILLON | 7832bf3 | 2015-03-04 13:13:05 +0100 | [diff] [blame] | 135 | break; |
| 136 | case 1: |
| 137 | seco_mx6_setup_usdhc_iomux(4); |
| 138 | usdhc_cfg[1].sdhc_clk = mxc_get_clock(MXC_ESDHC4_CLK); |
Boris BREZILLON | 7832bf3 | 2015-03-04 13:13:05 +0100 | [diff] [blame] | 139 | break; |
| 140 | |
| 141 | default: |
| 142 | printf("Warning: %d exceed maximum number of SD ports %d\n", |
| 143 | index + 1, CONFIG_SYS_FSL_USDHC_NUM); |
| 144 | return -EINVAL; |
| 145 | } |
| 146 | |
| 147 | ret = fsl_esdhc_initialize(bis, &usdhc_cfg[index]); |
| 148 | if (ret) |
| 149 | return ret; |
| 150 | } |
| 151 | |
| 152 | return 0; |
| 153 | } |
| 154 | |
| 155 | int board_init(void) |
| 156 | { |
| 157 | /* address of boot parameters */ |
| 158 | gd->bd->bi_boot_params = PHYS_SDRAM + 0x100; |
| 159 | |
| 160 | imx_iomux_v3_setup_pad(MX6_PAD_NANDF_D4__GPIO2_IO04 | |
| 161 | MUX_PAD_CTRL(NO_PAD_CTRL)); |
| 162 | |
| 163 | gpio_direction_output(IMX_GPIO_NR(2, 4), 0); |
| 164 | |
| 165 | /* Set Low */ |
| 166 | gpio_set_value(IMX_GPIO_NR(2, 4), 0); |
| 167 | udelay(1000); |
| 168 | |
| 169 | /* Set High */ |
| 170 | gpio_set_value(IMX_GPIO_NR(2, 4), 1); |
| 171 | |
| 172 | return 0; |
| 173 | } |
| 174 | |
| 175 | int checkboard(void) |
| 176 | { |
| 177 | puts("Board: SECO uQ7\n"); |
| 178 | |
| 179 | return 0; |
| 180 | } |