dm365evm.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation; either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program; if not, write to the Free Software
  15. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  16. */
  17. #include <common.h>
  18. #include <nand.h>
  19. #include <asm/io.h>
  20. #include <asm/arch/hardware.h>
  21. #include <asm/arch/emif_defs.h>
  22. #include <asm/arch/nand_defs.h>
  23. #include <asm/arch/gpio_defs.h>
  24. #include <netdev.h>
  25. #include "../common/misc.h"
  26. DECLARE_GLOBAL_DATA_PTR;
  27. int board_init(void)
  28. {
  29. gd->bd->bi_arch_number = MACH_TYPE_DAVINCI_DM365_EVM;
  30. gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
  31. return 0;
  32. }
  33. #ifdef CONFIG_DRIVER_TI_EMAC
  34. int board_eth_init(bd_t *bis)
  35. {
  36. uint8_t eeprom_enetaddr[6];
  37. int i;
  38. struct davinci_gpio *gpio1_base =
  39. (struct davinci_gpio *)DAVINCI_GPIO_BANK01;
  40. /* Configure PINMUX 3 to enable EMAC pins */
  41. writel((readl(PINMUX3) | 0x1affff), PINMUX3);
  42. /* Configure GPIO20 as output */
  43. writel((readl(&gpio1_base->dir) & ~(1 << 20)), &gpio1_base->dir);
  44. /* Toggle GPIO 20 */
  45. for (i = 0; i < 20; i++) {
  46. /* GPIO 20 low */
  47. writel((readl(&gpio1_base->out_data) & ~(1 << 20)),
  48. &gpio1_base->out_data);
  49. udelay(1000);
  50. /* GPIO 20 high */
  51. writel((readl(&gpio1_base->out_data) | (1 << 20)),
  52. &gpio1_base->out_data);
  53. }
  54. /* Configure I2C pins so that EEPROM can be read */
  55. writel((readl(PINMUX3) | 0x01400000), PINMUX3);
  56. /* Read Ethernet MAC address from EEPROM */
  57. if (dvevm_read_mac_address(eeprom_enetaddr))
  58. dv_configure_mac_address(eeprom_enetaddr);
  59. davinci_emac_initialize();
  60. return 0;
  61. }
  62. #endif
  63. #ifdef CONFIG_NAND_DAVINCI
  64. static void nand_dm365evm_select_chip(struct mtd_info *mtd, int chip)
  65. {
  66. struct nand_chip *this = mtd->priv;
  67. u32 wbase = (u32) this->IO_ADDR_W;
  68. u32 rbase = (u32) this->IO_ADDR_R;
  69. if (chip == 1) {
  70. __set_bit(14, &wbase);
  71. __set_bit(14, &rbase);
  72. } else {
  73. __clear_bit(14, &wbase);
  74. __clear_bit(14, &rbase);
  75. }
  76. this->IO_ADDR_W = (void *)wbase;
  77. this->IO_ADDR_R = (void *)rbase;
  78. }
  79. int board_nand_init(struct nand_chip *nand)
  80. {
  81. davinci_nand_init(nand);
  82. nand->select_chip = nand_dm365evm_select_chip;
  83. return 0;
  84. }
  85. #endif