dm365evm.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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_defs.h>
  25. #include <netdev.h>
  26. #include "../common/misc.h"
  27. DECLARE_GLOBAL_DATA_PTR;
  28. int board_init(void)
  29. {
  30. gd->bd->bi_arch_number = MACH_TYPE_DAVINCI_DM365_EVM;
  31. gd->bd->bi_boot_params = PHYS_SDRAM_1 + 0x100;
  32. return 0;
  33. }
  34. #ifdef CONFIG_DRIVER_TI_EMAC
  35. int board_eth_init(bd_t *bis)
  36. {
  37. uint8_t eeprom_enetaddr[6];
  38. int i;
  39. struct davinci_gpio *gpio1_base =
  40. (struct davinci_gpio *)DAVINCI_GPIO_BANK01;
  41. /* Configure PINMUX 3 to enable EMAC pins */
  42. writel((readl(PINMUX3) | 0x1affff), PINMUX3);
  43. /* Configure GPIO20 as output */
  44. writel((readl(&gpio1_base->dir) & ~(1 << 20)), &gpio1_base->dir);
  45. /* Toggle GPIO 20 */
  46. for (i = 0; i < 20; i++) {
  47. /* GPIO 20 low */
  48. writel((readl(&gpio1_base->out_data) & ~(1 << 20)),
  49. &gpio1_base->out_data);
  50. udelay(1000);
  51. /* GPIO 20 high */
  52. writel((readl(&gpio1_base->out_data) | (1 << 20)),
  53. &gpio1_base->out_data);
  54. }
  55. /* Configure I2C pins so that EEPROM can be read */
  56. writel((readl(PINMUX3) | 0x01400000), PINMUX3);
  57. /* Read Ethernet MAC address from EEPROM */
  58. if (dvevm_read_mac_address(eeprom_enetaddr))
  59. davinci_sync_env_enetaddr(eeprom_enetaddr);
  60. davinci_emac_initialize();
  61. return 0;
  62. }
  63. #endif
  64. #ifdef CONFIG_NAND_DAVINCI
  65. static void nand_dm365evm_select_chip(struct mtd_info *mtd, int chip)
  66. {
  67. struct nand_chip *this = mtd->priv;
  68. unsigned long wbase = (unsigned long) this->IO_ADDR_W;
  69. unsigned long rbase = (unsigned long) this->IO_ADDR_R;
  70. if (chip == 1) {
  71. __set_bit(14, &wbase);
  72. __set_bit(14, &rbase);
  73. } else {
  74. __clear_bit(14, &wbase);
  75. __clear_bit(14, &rbase);
  76. }
  77. this->IO_ADDR_W = (void *)wbase;
  78. this->IO_ADDR_R = (void *)rbase;
  79. }
  80. int board_nand_init(struct nand_chip *nand)
  81. {
  82. davinci_nand_init(nand);
  83. nand->select_chip = nand_dm365evm_select_chip;
  84. return 0;
  85. }
  86. #endif