dvevm.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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 <i2c.h>
  28. #include <asm/arch/hardware.h>
  29. #include "../common/misc.h"
  30. DECLARE_GLOBAL_DATA_PTR;
  31. int board_init(void)
  32. {
  33. /* arch number of the board */
  34. gd->bd->bi_arch_number = MACH_TYPE_DAVINCI_EVM;
  35. /* address of boot parameters */
  36. gd->bd->bi_boot_params = LINUX_BOOT_PARAM_ADDR;
  37. /* Configure AEMIF pins (although this should be configured at boot time
  38. * with pull-up/pull-down resistors) */
  39. REG(PINMUX0) = 0x00000c1f;
  40. davinci_errata_workarounds();
  41. /* Power on required peripherals */
  42. lpsc_on(DAVINCI_LPSC_GPIO);
  43. lpsc_on(DAVINCI_LPSC_USB);
  44. #if !defined(CONFIG_SYS_USE_DSPLINK)
  45. /* Powerup the DSP */
  46. dsp_on();
  47. #endif /* CONFIG_SYS_USE_DSPLINK */
  48. davinci_enable_uart0();
  49. davinci_enable_emac();
  50. davinci_enable_i2c();
  51. lpsc_on(DAVINCI_LPSC_TIMER1);
  52. timer_init();
  53. return(0);
  54. }
  55. int misc_init_r(void)
  56. {
  57. uint8_t video_mode;
  58. uint8_t eeprom_enetaddr[6];
  59. /* Read Ethernet MAC address from EEPROM if available. */
  60. if (dvevm_read_mac_address(eeprom_enetaddr))
  61. dv_configure_mac_address(eeprom_enetaddr);
  62. i2c_read(0x39, 0x00, 1, &video_mode, 1);
  63. setenv("videostd", ((video_mode & 0x80) ? "pal" : "ntsc"));
  64. return(0);
  65. }
  66. #ifdef CONFIG_USB_DAVINCI
  67. /* IO Expander I2C address and USB VBUS enable mask */
  68. #define IOEXP_I2C_ADDR 0x3A
  69. #define IOEXP_VBUSEN_MASK 1
  70. /*
  71. * This function enables USB VBUS by writting to IO expander using I2C.
  72. * Note that the I2C is already initialized at this stage. This
  73. * function is used by davinci specific USB wrapper code.
  74. */
  75. void enable_vbus(void)
  76. {
  77. uchar data; /* IO Expander data to enable VBUS */
  78. /* Write to IO expander to enable VBUS */
  79. i2c_read(IOEXP_I2C_ADDR, 0, 0, &data, 1);
  80. data &= ~IOEXP_VBUSEN_MASK;
  81. i2c_write(IOEXP_I2C_ADDR, 0, 0, &data, 1);
  82. }
  83. #endif