Fabio Estevam | adac83a | 2011-09-06 09:05:43 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2011 Freescale Semiconductor, Inc. |
| 3 | * |
| 4 | * Author: Fabio Estevam <fabio.estevam@freescale.com> |
| 5 | * |
| 6 | * See file CREDITS for list of people who contributed to this |
| 7 | * project. |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or |
| 10 | * modify it under the terms of the GNU General Public License as |
| 11 | * published by the Free Software Foundation; either version 2 of |
| 12 | * the License, or (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | */ |
| 19 | |
| 20 | #include <common.h> |
| 21 | #include <asm/io.h> |
Fabio Estevam | 1de48fa | 2012-10-23 06:34:49 +0000 | [diff] [blame^] | 22 | #include <asm/gpio.h> |
Fabio Estevam | adac83a | 2011-09-06 09:05:43 +0000 | [diff] [blame] | 23 | #include <asm/arch/imx-regs.h> |
| 24 | #include <asm/arch/imx25-pinmux.h> |
| 25 | #include <asm/arch/sys_proto.h> |
Fabio Estevam | 1de48fa | 2012-10-23 06:34:49 +0000 | [diff] [blame^] | 26 | #include <asm/arch/clock.h> |
| 27 | #include <mmc.h> |
| 28 | #include <fsl_esdhc.h> |
| 29 | |
| 30 | #define CARD_DETECT IMX_GPIO_NR(2, 1) |
Fabio Estevam | adac83a | 2011-09-06 09:05:43 +0000 | [diff] [blame] | 31 | |
| 32 | DECLARE_GLOBAL_DATA_PTR; |
| 33 | |
Fabio Estevam | 1de48fa | 2012-10-23 06:34:49 +0000 | [diff] [blame^] | 34 | #ifdef CONFIG_FSL_ESDHC |
| 35 | struct fsl_esdhc_cfg esdhc_cfg[1] = { |
| 36 | {IMX_MMC_SDHC1_BASE}, |
| 37 | }; |
| 38 | #endif |
| 39 | |
Fabio Estevam | adac83a | 2011-09-06 09:05:43 +0000 | [diff] [blame] | 40 | int dram_init(void) |
| 41 | { |
| 42 | /* dram_init must store complete ramsize in gd->ram_size */ |
| 43 | gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE, |
| 44 | PHYS_SDRAM_1_SIZE); |
| 45 | return 0; |
| 46 | } |
| 47 | |
Fabio Estevam | adac83a | 2011-09-06 09:05:43 +0000 | [diff] [blame] | 48 | int board_early_init_f(void) |
| 49 | { |
| 50 | mx25_uart1_init_pins(); |
| 51 | |
| 52 | return 0; |
| 53 | } |
| 54 | |
| 55 | int board_init(void) |
| 56 | { |
Fabio Estevam | adac83a | 2011-09-06 09:05:43 +0000 | [diff] [blame] | 57 | /* address of boot parameters */ |
| 58 | gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100; |
| 59 | |
| 60 | return 0; |
| 61 | } |
Fabio Estevam | 1de48fa | 2012-10-23 06:34:49 +0000 | [diff] [blame^] | 62 | |
| 63 | #ifdef CONFIG_FSL_ESDHC |
| 64 | int board_mmc_getcd(struct mmc *mmc) |
| 65 | { |
| 66 | struct iomuxc_mux_ctl *muxctl; |
| 67 | struct iomuxc_pad_ctl *padctl; |
| 68 | u32 gpio_mux_mode = MX25_PIN_MUX_MODE(5); |
| 69 | |
| 70 | /* |
| 71 | * Set up the Card Detect pin. |
| 72 | * |
| 73 | * SD1_GPIO_CD: gpio2_1 is ALT 5 mode of pin A15 |
| 74 | * |
| 75 | */ |
| 76 | muxctl = (struct iomuxc_mux_ctl *)IMX_IOPADMUX_BASE; |
| 77 | padctl = (struct iomuxc_pad_ctl *)IMX_IOPADCTL_BASE; |
| 78 | |
| 79 | writel(gpio_mux_mode, &muxctl->pad_a15); |
| 80 | writel(0x0, &padctl->pad_a15); |
| 81 | |
| 82 | gpio_direction_input(CARD_DETECT); |
| 83 | return !gpio_get_value(CARD_DETECT); |
| 84 | } |
| 85 | |
| 86 | int board_mmc_init(bd_t *bis) |
| 87 | { |
| 88 | struct iomuxc_mux_ctl *muxctl; |
| 89 | u32 sdhc1_mux_mode = MX25_PIN_MUX_MODE(0) | MX25_PIN_MUX_SION; |
| 90 | |
| 91 | muxctl = (struct iomuxc_mux_ctl *)IMX_IOPADMUX_BASE; |
| 92 | writel(sdhc1_mux_mode, &muxctl->pad_sd1_cmd); |
| 93 | writel(sdhc1_mux_mode, &muxctl->pad_sd1_clk); |
| 94 | writel(sdhc1_mux_mode, &muxctl->pad_sd1_data0); |
| 95 | writel(sdhc1_mux_mode, &muxctl->pad_sd1_data1); |
| 96 | writel(sdhc1_mux_mode, &muxctl->pad_sd1_data2); |
| 97 | writel(sdhc1_mux_mode, &muxctl->pad_sd1_data3); |
| 98 | |
| 99 | esdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC1_CLK); |
| 100 | return fsl_esdhc_initialize(bis, &esdhc_cfg[0]); |
| 101 | } |
| 102 | #endif |
Fabio Estevam | adac83a | 2011-09-06 09:05:43 +0000 | [diff] [blame] | 103 | |
| 104 | int checkboard(void) |
| 105 | { |
| 106 | puts("Board: MX25PDK\n"); |
| 107 | |
| 108 | return 0; |
| 109 | } |