sonata.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. * SPDX-License-Identifier: GPL-2.0+
  12. * ----------------------------------------------------------------------------
  13. */
  14. #include <common.h>
  15. #include <nand.h>
  16. #include <asm/ti-common/davinci_nand.h>
  17. #include <asm/arch/hardware.h>
  18. #include <asm/arch/davinci_misc.h>
  19. DECLARE_GLOBAL_DATA_PTR;
  20. int board_init(void)
  21. {
  22. /* address of boot parameters */
  23. gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR;
  24. /* Configure AEMIF pins (although this should be configured at boot time
  25. * with pull-up/pull-down resistors) */
  26. REG(PINMUX0) = 0x00000c1f;
  27. davinci_errata_workarounds();
  28. /* Power on required peripherals */
  29. lpsc_on(DAVINCI_LPSC_GPIO);
  30. #if !defined(CONFIG_SYS_USE_DSPLINK)
  31. /* Powerup the DSP */
  32. dsp_on();
  33. #endif /* CONFIG_SYS_USE_DSPLINK */
  34. davinci_enable_uart0();
  35. davinci_enable_emac();
  36. davinci_enable_i2c();
  37. lpsc_on(DAVINCI_LPSC_TIMER1);
  38. timer_init();
  39. return(0);
  40. }
  41. int misc_init_r(void)
  42. {
  43. uint8_t eeprom_enetaddr[6];
  44. /* Read Ethernet MAC address from EEPROM if available. */
  45. if (dvevm_read_mac_address(eeprom_enetaddr))
  46. davinci_sync_env_enetaddr(eeprom_enetaddr);
  47. return(0);
  48. }
  49. #ifdef CONFIG_NAND_DAVINCI
  50. /* Set WP on deselect, write enable on select */
  51. static void nand_sonata_select_chip(struct mtd_info *mtd, int chip)
  52. {
  53. #define GPIO_SET_DATA01 0x01c67018
  54. #define GPIO_CLR_DATA01 0x01c6701c
  55. #define GPIO_NAND_WP (1 << 4)
  56. #ifdef SONATA_BOARD_GPIOWP
  57. if (chip < 0) {
  58. REG(GPIO_CLR_DATA01) |= GPIO_NAND_WP;
  59. } else {
  60. REG(GPIO_SET_DATA01) |= GPIO_NAND_WP;
  61. }
  62. #endif
  63. }
  64. int board_nand_init(struct nand_chip *nand)
  65. {
  66. davinci_nand_init(nand);
  67. nand->select_chip = nand_sonata_select_chip;
  68. return 0;
  69. }
  70. #endif /* CONFIG_NAND_DAVINCI */