dm365evm.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. /*
  2. * Copyright (C) 2009 Texas Instruments Incorporated
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18. #include <common.h>
  19. #include <nand.h>
  20. #include <asm/io.h>
  21. #include <asm/arch/hardware.h>
  22. #include <asm/arch/emif_defs.h>
  23. #include <asm/arch/nand_defs.h>
  24. #include <asm/arch/gpio.h>
  25. #include <netdev.h>
  26. #include <asm/arch/davinci_misc.h>
  27. #ifdef CONFIG_DAVINCI_MMC
  28. #include <mmc.h>
  29. #include <asm/arch/sdmmc_defs.h>
  30. #endif
  31. DECLARE_GLOBAL_DATA_PTR;
  32. int board_init(void)
  33. {
  34. gd->bd->bi_arch_number = MACH_TYPE_DAVINCI_DM365_EVM;
  35. gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
  36. return 0;
  37. }
  38. #ifdef CONFIG_DRIVER_TI_EMAC
  39. int board_eth_init(bd_t *bis)
  40. {
  41. uint8_t eeprom_enetaddr[6];
  42. int i;
  43. struct davinci_gpio *gpio1_base =
  44. (struct davinci_gpio *)DAVINCI_GPIO_BANK01;
  45. /* Configure PINMUX 3 to enable EMAC pins */
  46. writel((readl(PINMUX3) | 0x1affff), PINMUX3);
  47. /* Configure GPIO20 as output */
  48. writel((readl(&gpio1_base->dir) & ~(1 << 20)), &gpio1_base->dir);
  49. /* Toggle GPIO 20 */
  50. for (i = 0; i < 20; i++) {
  51. /* GPIO 20 low */
  52. writel((readl(&gpio1_base->out_data) & ~(1 << 20)),
  53. &gpio1_base->out_data);
  54. udelay(1000);
  55. /* GPIO 20 high */
  56. writel((readl(&gpio1_base->out_data) | (1 << 20)),
  57. &gpio1_base->out_data);
  58. }
  59. /* Configure I2C pins so that EEPROM can be read */
  60. writel((readl(PINMUX3) | 0x01400000), PINMUX3);
  61. /* Read Ethernet MAC address from EEPROM */
  62. if (dvevm_read_mac_address(eeprom_enetaddr))
  63. davinci_sync_env_enetaddr(eeprom_enetaddr);
  64. davinci_emac_initialize();
  65. return 0;
  66. }
  67. #endif
  68. #ifdef CONFIG_NAND_DAVINCI
  69. static void nand_dm365evm_select_chip(struct mtd_info *mtd, int chip)
  70. {
  71. struct nand_chip *this = mtd->priv;
  72. unsigned long wbase = (unsigned long) this->IO_ADDR_W;
  73. unsigned long rbase = (unsigned long) this->IO_ADDR_R;
  74. if (chip == 1) {
  75. __set_bit(14, &wbase);
  76. __set_bit(14, &rbase);
  77. } else {
  78. __clear_bit(14, &wbase);
  79. __clear_bit(14, &rbase);
  80. }
  81. this->IO_ADDR_W = (void *)wbase;
  82. this->IO_ADDR_R = (void *)rbase;
  83. }
  84. int board_nand_init(struct nand_chip *nand)
  85. {
  86. davinci_nand_init(nand);
  87. nand->select_chip = nand_dm365evm_select_chip;
  88. return 0;
  89. }
  90. #endif
  91. #ifdef CONFIG_DAVINCI_MMC
  92. static struct davinci_mmc mmc_sd0 = {
  93. .reg_base = (struct davinci_mmc_regs *)DAVINCI_MMC_SD0_BASE,
  94. .input_clk = 121500000,
  95. .host_caps = MMC_MODE_4BIT,
  96. .voltages = MMC_VDD_32_33 | MMC_VDD_33_34,
  97. .version = MMC_CTLR_VERSION_2,
  98. };
  99. #ifdef CONFIG_DAVINCI_MMC_SD1
  100. static struct davinci_mmc mmc_sd1 = {
  101. .reg_base = (struct davinci_mmc_regs *)DAVINCI_MMC_SD1_BASE,
  102. .input_clk = 121500000,
  103. .host_caps = MMC_MODE_4BIT,
  104. .voltages = MMC_VDD_32_33 | MMC_VDD_33_34,
  105. .version = MMC_CTLR_VERSION_2,
  106. };
  107. #endif
  108. int board_mmc_init(bd_t *bis)
  109. {
  110. int err;
  111. /* Add slot-0 to mmc subsystem */
  112. err = davinci_mmc_init(bis, &mmc_sd0);
  113. if (err)
  114. return err;
  115. #ifdef CONFIG_DAVINCI_MMC_SD1
  116. #define PUPDCTL1 0x01c4007c
  117. /* PINMUX(4)-DAT0-3/CMD; PINMUX(0)-CLK */
  118. writel((readl(PINMUX4) | 0x55400000), PINMUX4);
  119. writel((readl(PINMUX0) | 0x00010000), PINMUX0);
  120. /* Configure MMC/SD pins as pullup */
  121. writel((readl(PUPDCTL1) & ~0x07c0), PUPDCTL1);
  122. /* Add slot-1 to mmc subsystem */
  123. err = davinci_mmc_init(bis, &mmc_sd1);
  124. #endif
  125. return err;
  126. }
  127. #endif