1419adbfbSFabio Estevam /* 2419adbfbSFabio Estevam * (C) Copyright 2011 Freescale Semiconductor, Inc. 3419adbfbSFabio Estevam * 4419adbfbSFabio Estevam * Author: Fabio Estevam <fabio.estevam@freescale.com> 5419adbfbSFabio Estevam * 6419adbfbSFabio Estevam * See file CREDITS for list of people who contributed to this 7419adbfbSFabio Estevam * project. 8419adbfbSFabio Estevam * 9419adbfbSFabio Estevam * This program is free software; you can redistribute it and/or 10419adbfbSFabio Estevam * modify it under the terms of the GNU General Public License as 11419adbfbSFabio Estevam * published by the Free Software Foundation; either version 2 of 12419adbfbSFabio Estevam * the License, or (at your option) any later version. 13419adbfbSFabio Estevam * 14419adbfbSFabio Estevam * This program is distributed in the hope that it will be useful, 15419adbfbSFabio Estevam * but WITHOUT ANY WARRANTY; without even the implied warranty of 16419adbfbSFabio Estevam * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17419adbfbSFabio Estevam * GNU General Public License for more details. 18419adbfbSFabio Estevam */ 19419adbfbSFabio Estevam 20419adbfbSFabio Estevam #include <common.h> 21419adbfbSFabio Estevam #include <asm/io.h> 22af2a4093SFabio Estevam #include <asm/gpio.h> 23419adbfbSFabio Estevam #include <asm/arch/imx-regs.h> 24419adbfbSFabio Estevam #include <asm/arch/imx25-pinmux.h> 25419adbfbSFabio Estevam #include <asm/arch/sys_proto.h> 26af2a4093SFabio Estevam #include <asm/arch/clock.h> 27af2a4093SFabio Estevam #include <mmc.h> 28af2a4093SFabio Estevam #include <fsl_esdhc.h> 29*e00c89dfSFabio Estevam #include <i2c.h> 30*e00c89dfSFabio Estevam #include <pmic.h> 31*e00c89dfSFabio Estevam #include <fsl_pmic.h> 32*e00c89dfSFabio Estevam #include <mc34704.h> 33af2a4093SFabio Estevam 34*e00c89dfSFabio Estevam #define FEC_RESET_B IMX_GPIO_NR(2, 3) 35*e00c89dfSFabio Estevam #define FEC_ENABLE_B IMX_GPIO_NR(4, 8) 36af2a4093SFabio Estevam #define CARD_DETECT IMX_GPIO_NR(2, 1) 37419adbfbSFabio Estevam 38419adbfbSFabio Estevam DECLARE_GLOBAL_DATA_PTR; 39419adbfbSFabio Estevam 40af2a4093SFabio Estevam #ifdef CONFIG_FSL_ESDHC 41af2a4093SFabio Estevam struct fsl_esdhc_cfg esdhc_cfg[1] = { 42af2a4093SFabio Estevam {IMX_MMC_SDHC1_BASE}, 43af2a4093SFabio Estevam }; 44af2a4093SFabio Estevam #endif 45af2a4093SFabio Estevam 46*e00c89dfSFabio Estevam static void mx25pdk_fec_init(void) 47*e00c89dfSFabio Estevam { 48*e00c89dfSFabio Estevam struct iomuxc_mux_ctl *muxctl; 49*e00c89dfSFabio Estevam struct iomuxc_pad_ctl *padctl; 50*e00c89dfSFabio Estevam u32 gpio_mux_mode = MX25_PIN_MUX_MODE(5); 51*e00c89dfSFabio Estevam u32 gpio_mux_mode0_sion = MX25_PIN_MUX_MODE(0) | MX25_PIN_MUX_SION; 52*e00c89dfSFabio Estevam 53*e00c89dfSFabio Estevam /* FEC pin init is generic */ 54*e00c89dfSFabio Estevam mx25_fec_init_pins(); 55*e00c89dfSFabio Estevam 56*e00c89dfSFabio Estevam muxctl = (struct iomuxc_mux_ctl *)IMX_IOPADMUX_BASE; 57*e00c89dfSFabio Estevam padctl = (struct iomuxc_pad_ctl *)IMX_IOPADCTL_BASE; 58*e00c89dfSFabio Estevam /* 59*e00c89dfSFabio Estevam * Set up FEC_RESET_B and FEC_ENABLE_B 60*e00c89dfSFabio Estevam * 61*e00c89dfSFabio Estevam * FEC_RESET_B: gpio2_3 is ALT 5 mode of pin D12 62*e00c89dfSFabio Estevam * FEC_ENABLE_B: gpio4_8 is ALT 5 mode of pin A17 63*e00c89dfSFabio Estevam */ 64*e00c89dfSFabio Estevam writel(gpio_mux_mode, &muxctl->pad_d12); 65*e00c89dfSFabio Estevam writel(gpio_mux_mode, &muxctl->pad_a17); 66*e00c89dfSFabio Estevam 67*e00c89dfSFabio Estevam writel(0x0, &padctl->pad_d12); 68*e00c89dfSFabio Estevam writel(0x0, &padctl->pad_a17); 69*e00c89dfSFabio Estevam 70*e00c89dfSFabio Estevam /* Assert RESET and ENABLE low */ 71*e00c89dfSFabio Estevam gpio_direction_output(FEC_RESET_B, 0); 72*e00c89dfSFabio Estevam gpio_direction_output(FEC_ENABLE_B, 0); 73*e00c89dfSFabio Estevam 74*e00c89dfSFabio Estevam udelay(10); 75*e00c89dfSFabio Estevam 76*e00c89dfSFabio Estevam /* Deassert RESET and ENABLE */ 77*e00c89dfSFabio Estevam gpio_set_value(FEC_RESET_B, 1); 78*e00c89dfSFabio Estevam gpio_set_value(FEC_ENABLE_B, 1); 79*e00c89dfSFabio Estevam 80*e00c89dfSFabio Estevam /* Setup I2C pins so that PMIC can turn on PHY supply */ 81*e00c89dfSFabio Estevam writel(gpio_mux_mode0_sion, &muxctl->pad_i2c1_clk); 82*e00c89dfSFabio Estevam writel(gpio_mux_mode0_sion, &muxctl->pad_i2c1_dat); 83*e00c89dfSFabio Estevam writel(0x1E8, &padctl->pad_i2c1_clk); 84*e00c89dfSFabio Estevam writel(0x1E8, &padctl->pad_i2c1_dat); 85*e00c89dfSFabio Estevam } 86*e00c89dfSFabio Estevam 87419adbfbSFabio Estevam int dram_init(void) 88419adbfbSFabio Estevam { 89419adbfbSFabio Estevam /* dram_init must store complete ramsize in gd->ram_size */ 90419adbfbSFabio Estevam gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE, 91419adbfbSFabio Estevam PHYS_SDRAM_1_SIZE); 92419adbfbSFabio Estevam return 0; 93419adbfbSFabio Estevam } 94419adbfbSFabio Estevam 95419adbfbSFabio Estevam int board_early_init_f(void) 96419adbfbSFabio Estevam { 97419adbfbSFabio Estevam mx25_uart1_init_pins(); 98419adbfbSFabio Estevam 99419adbfbSFabio Estevam return 0; 100419adbfbSFabio Estevam } 101419adbfbSFabio Estevam 102419adbfbSFabio Estevam int board_init(void) 103419adbfbSFabio Estevam { 104419adbfbSFabio Estevam /* address of boot parameters */ 105419adbfbSFabio Estevam gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100; 106419adbfbSFabio Estevam 107419adbfbSFabio Estevam return 0; 108419adbfbSFabio Estevam } 109419adbfbSFabio Estevam 110*e00c89dfSFabio Estevam int board_late_init(void) 111*e00c89dfSFabio Estevam { 112*e00c89dfSFabio Estevam struct pmic *p; 113*e00c89dfSFabio Estevam 114*e00c89dfSFabio Estevam mx25pdk_fec_init(); 115*e00c89dfSFabio Estevam 116*e00c89dfSFabio Estevam pmic_init(); 117*e00c89dfSFabio Estevam p = get_pmic(); 118*e00c89dfSFabio Estevam /* Turn on Ethernet PHY supply */ 119*e00c89dfSFabio Estevam pmic_reg_write(p, MC34704_GENERAL2_REG, ONOFFE); 120*e00c89dfSFabio Estevam 121*e00c89dfSFabio Estevam return 0; 122*e00c89dfSFabio Estevam } 123*e00c89dfSFabio Estevam 124af2a4093SFabio Estevam #ifdef CONFIG_FSL_ESDHC 125af2a4093SFabio Estevam int board_mmc_getcd(struct mmc *mmc) 126af2a4093SFabio Estevam { 127af2a4093SFabio Estevam struct iomuxc_mux_ctl *muxctl; 128af2a4093SFabio Estevam struct iomuxc_pad_ctl *padctl; 129af2a4093SFabio Estevam u32 gpio_mux_mode = MX25_PIN_MUX_MODE(5); 130af2a4093SFabio Estevam 131af2a4093SFabio Estevam /* 132af2a4093SFabio Estevam * Set up the Card Detect pin. 133af2a4093SFabio Estevam * 134af2a4093SFabio Estevam * SD1_GPIO_CD: gpio2_1 is ALT 5 mode of pin A15 135af2a4093SFabio Estevam * 136af2a4093SFabio Estevam */ 137af2a4093SFabio Estevam muxctl = (struct iomuxc_mux_ctl *)IMX_IOPADMUX_BASE; 138af2a4093SFabio Estevam padctl = (struct iomuxc_pad_ctl *)IMX_IOPADCTL_BASE; 139af2a4093SFabio Estevam 140af2a4093SFabio Estevam writel(gpio_mux_mode, &muxctl->pad_a15); 141af2a4093SFabio Estevam writel(0x0, &padctl->pad_a15); 142af2a4093SFabio Estevam 143af2a4093SFabio Estevam gpio_direction_input(CARD_DETECT); 144af2a4093SFabio Estevam return !gpio_get_value(CARD_DETECT); 145af2a4093SFabio Estevam } 146af2a4093SFabio Estevam 147af2a4093SFabio Estevam int board_mmc_init(bd_t *bis) 148af2a4093SFabio Estevam { 149af2a4093SFabio Estevam struct iomuxc_mux_ctl *muxctl; 150af2a4093SFabio Estevam u32 sdhc1_mux_mode = MX25_PIN_MUX_MODE(0) | MX25_PIN_MUX_SION; 151af2a4093SFabio Estevam 152af2a4093SFabio Estevam muxctl = (struct iomuxc_mux_ctl *)IMX_IOPADMUX_BASE; 153af2a4093SFabio Estevam writel(sdhc1_mux_mode, &muxctl->pad_sd1_cmd); 154af2a4093SFabio Estevam writel(sdhc1_mux_mode, &muxctl->pad_sd1_clk); 155af2a4093SFabio Estevam writel(sdhc1_mux_mode, &muxctl->pad_sd1_data0); 156af2a4093SFabio Estevam writel(sdhc1_mux_mode, &muxctl->pad_sd1_data1); 157af2a4093SFabio Estevam writel(sdhc1_mux_mode, &muxctl->pad_sd1_data2); 158af2a4093SFabio Estevam writel(sdhc1_mux_mode, &muxctl->pad_sd1_data3); 159af2a4093SFabio Estevam 160af2a4093SFabio Estevam esdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC1_CLK); 161af2a4093SFabio Estevam return fsl_esdhc_initialize(bis, &esdhc_cfg[0]); 162af2a4093SFabio Estevam } 163af2a4093SFabio Estevam #endif 164af2a4093SFabio Estevam 165419adbfbSFabio Estevam int checkboard(void) 166419adbfbSFabio Estevam { 167419adbfbSFabio Estevam puts("Board: MX25PDK\n"); 168419adbfbSFabio Estevam 169419adbfbSFabio Estevam return 0; 170419adbfbSFabio Estevam } 171