mx25pdk.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. #include <common.h>
  20. #include <asm/io.h>
  21. #include <asm/gpio.h>
  22. #include <asm/arch/imx-regs.h>
  23. #include <asm/arch/imx25-pinmux.h>
  24. #include <asm/arch/sys_proto.h>
  25. #include <asm/arch/clock.h>
  26. #include <mmc.h>
  27. #include <fsl_esdhc.h>
  28. #define CARD_DETECT IMX_GPIO_NR(2, 1)
  29. DECLARE_GLOBAL_DATA_PTR;
  30. #ifdef CONFIG_FSL_ESDHC
  31. struct fsl_esdhc_cfg esdhc_cfg[1] = {
  32. {IMX_MMC_SDHC1_BASE},
  33. };
  34. #endif
  35. int dram_init(void)
  36. {
  37. /* dram_init must store complete ramsize in gd->ram_size */
  38. gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE,
  39. PHYS_SDRAM_1_SIZE);
  40. return 0;
  41. }
  42. int board_early_init_f(void)
  43. {
  44. mx25_uart1_init_pins();
  45. return 0;
  46. }
  47. int board_init(void)
  48. {
  49. /* address of boot parameters */
  50. gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
  51. return 0;
  52. }
  53. #ifdef CONFIG_FSL_ESDHC
  54. int board_mmc_getcd(struct mmc *mmc)
  55. {
  56. struct iomuxc_mux_ctl *muxctl;
  57. struct iomuxc_pad_ctl *padctl;
  58. u32 gpio_mux_mode = MX25_PIN_MUX_MODE(5);
  59. /*
  60. * Set up the Card Detect pin.
  61. *
  62. * SD1_GPIO_CD: gpio2_1 is ALT 5 mode of pin A15
  63. *
  64. */
  65. muxctl = (struct iomuxc_mux_ctl *)IMX_IOPADMUX_BASE;
  66. padctl = (struct iomuxc_pad_ctl *)IMX_IOPADCTL_BASE;
  67. writel(gpio_mux_mode, &muxctl->pad_a15);
  68. writel(0x0, &padctl->pad_a15);
  69. gpio_direction_input(CARD_DETECT);
  70. return !gpio_get_value(CARD_DETECT);
  71. }
  72. int board_mmc_init(bd_t *bis)
  73. {
  74. struct iomuxc_mux_ctl *muxctl;
  75. u32 sdhc1_mux_mode = MX25_PIN_MUX_MODE(0) | MX25_PIN_MUX_SION;
  76. muxctl = (struct iomuxc_mux_ctl *)IMX_IOPADMUX_BASE;
  77. writel(sdhc1_mux_mode, &muxctl->pad_sd1_cmd);
  78. writel(sdhc1_mux_mode, &muxctl->pad_sd1_clk);
  79. writel(sdhc1_mux_mode, &muxctl->pad_sd1_data0);
  80. writel(sdhc1_mux_mode, &muxctl->pad_sd1_data1);
  81. writel(sdhc1_mux_mode, &muxctl->pad_sd1_data2);
  82. writel(sdhc1_mux_mode, &muxctl->pad_sd1_data3);
  83. esdhc_cfg[0].sdhc_clk = mxc_get_clock(MXC_ESDHC1_CLK);
  84. return fsl_esdhc_initialize(bis, &esdhc_cfg[0]);
  85. }
  86. #endif
  87. int checkboard(void)
  88. {
  89. puts("Board: MX25PDK\n");
  90. return 0;
  91. }