sonata.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * Copyright (C) 2007 Sergey Kubushyn <ksi@koi8.net>
  3. *
  4. * Parts are shamelessly stolen from various TI sources, original copyright
  5. * follows:
  6. * -----------------------------------------------------------------
  7. *
  8. * Copyright (C) 2004 Texas Instruments.
  9. *
  10. * ----------------------------------------------------------------------------
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  24. * ----------------------------------------------------------------------------
  25. */
  26. #include <common.h>
  27. #include <nand.h>
  28. #include <asm/arch/nand_defs.h>
  29. #include <asm/arch/hardware.h>
  30. #include <asm/arch/davinci_misc.h>
  31. DECLARE_GLOBAL_DATA_PTR;
  32. int board_init(void)
  33. {
  34. /* address of boot parameters */
  35. gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR;
  36. /* Configure AEMIF pins (although this should be configured at boot time
  37. * with pull-up/pull-down resistors) */
  38. REG(PINMUX0) = 0x00000c1f;
  39. davinci_errata_workarounds();
  40. /* Power on required peripherals */
  41. lpsc_on(DAVINCI_LPSC_GPIO);
  42. #if !defined(CONFIG_SYS_USE_DSPLINK)
  43. /* Powerup the DSP */
  44. dsp_on();
  45. #endif /* CONFIG_SYS_USE_DSPLINK */
  46. davinci_enable_uart0();
  47. davinci_enable_emac();
  48. davinci_enable_i2c();
  49. lpsc_on(DAVINCI_LPSC_TIMER1);
  50. timer_init();
  51. return(0);
  52. }
  53. int misc_init_r(void)
  54. {
  55. uint8_t eeprom_enetaddr[6];
  56. /* Read Ethernet MAC address from EEPROM if available. */
  57. if (dvevm_read_mac_address(eeprom_enetaddr))
  58. davinci_sync_env_enetaddr(eeprom_enetaddr);
  59. return(0);
  60. }
  61. #ifdef CONFIG_NAND_DAVINCI
  62. /* Set WP on deselect, write enable on select */
  63. static void nand_sonata_select_chip(struct mtd_info *mtd, int chip)
  64. {
  65. #define GPIO_SET_DATA01 0x01c67018
  66. #define GPIO_CLR_DATA01 0x01c6701c
  67. #define GPIO_NAND_WP (1 << 4)
  68. #ifdef SONATA_BOARD_GPIOWP
  69. if (chip < 0) {
  70. REG(GPIO_CLR_DATA01) |= GPIO_NAND_WP;
  71. } else {
  72. REG(GPIO_SET_DATA01) |= GPIO_NAND_WP;
  73. }
  74. #endif
  75. }
  76. int board_nand_init(struct nand_chip *nand)
  77. {
  78. davinci_nand_init(nand);
  79. nand->select_chip = nand_sonata_select_chip;
  80. return 0;
  81. }
  82. #endif /* CONFIG_NAND_DAVINCI */