dm365evm.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*
  2. * Copyright (C) 2009 Texas Instruments Incorporated
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <common.h>
  7. #include <nand.h>
  8. #include <asm/io.h>
  9. #include <asm/arch/hardware.h>
  10. #include <asm/ti-common/davinci_nand.h>
  11. #include <asm/arch/gpio.h>
  12. #include <netdev.h>
  13. #include <asm/arch/davinci_misc.h>
  14. #ifdef CONFIG_DAVINCI_MMC
  15. #include <mmc.h>
  16. #include <asm/arch/sdmmc_defs.h>
  17. #endif
  18. DECLARE_GLOBAL_DATA_PTR;
  19. int board_init(void)
  20. {
  21. gd->bd->bi_arch_number = MACH_TYPE_DAVINCI_DM365_EVM;
  22. gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
  23. return 0;
  24. }
  25. #ifdef CONFIG_DRIVER_TI_EMAC
  26. int board_eth_init(bd_t *bis)
  27. {
  28. uint8_t eeprom_enetaddr[6];
  29. int i;
  30. struct davinci_gpio *gpio1_base =
  31. (struct davinci_gpio *)DAVINCI_GPIO_BANK01;
  32. /* Configure PINMUX 3 to enable EMAC pins */
  33. writel((readl(PINMUX3) | 0x1affff), PINMUX3);
  34. /* Configure GPIO20 as output */
  35. writel((readl(&gpio1_base->dir) & ~(1 << 20)), &gpio1_base->dir);
  36. /* Toggle GPIO 20 */
  37. for (i = 0; i < 20; i++) {
  38. /* GPIO 20 low */
  39. writel((readl(&gpio1_base->out_data) & ~(1 << 20)),
  40. &gpio1_base->out_data);
  41. udelay(1000);
  42. /* GPIO 20 high */
  43. writel((readl(&gpio1_base->out_data) | (1 << 20)),
  44. &gpio1_base->out_data);
  45. }
  46. /* Configure I2C pins so that EEPROM can be read */
  47. writel((readl(PINMUX3) | 0x01400000), PINMUX3);
  48. /* Read Ethernet MAC address from EEPROM */
  49. if (dvevm_read_mac_address(eeprom_enetaddr))
  50. davinci_sync_env_enetaddr(eeprom_enetaddr);
  51. davinci_emac_initialize();
  52. return 0;
  53. }
  54. #endif
  55. #ifdef CONFIG_NAND_DAVINCI
  56. static void nand_dm365evm_select_chip(struct mtd_info *mtd, int chip)
  57. {
  58. struct nand_chip *this = mtd->priv;
  59. unsigned long wbase = (unsigned long) this->IO_ADDR_W;
  60. unsigned long rbase = (unsigned long) this->IO_ADDR_R;
  61. if (chip == 1) {
  62. __set_bit(14, &wbase);
  63. __set_bit(14, &rbase);
  64. } else {
  65. __clear_bit(14, &wbase);
  66. __clear_bit(14, &rbase);
  67. }
  68. this->IO_ADDR_W = (void *)wbase;
  69. this->IO_ADDR_R = (void *)rbase;
  70. }
  71. int board_nand_init(struct nand_chip *nand)
  72. {
  73. davinci_nand_init(nand);
  74. nand->select_chip = nand_dm365evm_select_chip;
  75. return 0;
  76. }
  77. #endif
  78. #ifdef CONFIG_DAVINCI_MMC
  79. static struct davinci_mmc mmc_sd0 = {
  80. .reg_base = (struct davinci_mmc_regs *)DAVINCI_MMC_SD0_BASE,
  81. .input_clk = 121500000,
  82. .host_caps = MMC_MODE_4BIT,
  83. .voltages = MMC_VDD_32_33 | MMC_VDD_33_34,
  84. .version = MMC_CTLR_VERSION_2,
  85. };
  86. #ifdef CONFIG_DAVINCI_MMC_SD1
  87. static struct davinci_mmc mmc_sd1 = {
  88. .reg_base = (struct davinci_mmc_regs *)DAVINCI_MMC_SD1_BASE,
  89. .input_clk = 121500000,
  90. .host_caps = MMC_MODE_4BIT,
  91. .voltages = MMC_VDD_32_33 | MMC_VDD_33_34,
  92. .version = MMC_CTLR_VERSION_2,
  93. };
  94. #endif
  95. int board_mmc_init(bd_t *bis)
  96. {
  97. int err;
  98. /* Add slot-0 to mmc subsystem */
  99. err = davinci_mmc_init(bis, &mmc_sd0);
  100. if (err)
  101. return err;
  102. #ifdef CONFIG_DAVINCI_MMC_SD1
  103. #define PUPDCTL1 0x01c4007c
  104. /* PINMUX(4)-DAT0-3/CMD; PINMUX(0)-CLK */
  105. writel((readl(PINMUX4) | 0x55400000), PINMUX4);
  106. writel((readl(PINMUX0) | 0x00010000), PINMUX0);
  107. /* Configure MMC/SD pins as pullup */
  108. writel((readl(PUPDCTL1) & ~0x07c0), PUPDCTL1);
  109. /* Add slot-1 to mmc subsystem */
  110. err = davinci_mmc_init(bis, &mmc_sd1);
  111. #endif
  112. return err;
  113. }
  114. #endif