pandora.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2008
  4. * Grazvydas Ignotas <notasas@gmail.com>
  5. *
  6. * Derived from Beagle Board, 3430 SDP, and OMAP3EVM code by
  7. * Richard Woodruff <r-woodruff2@ti.com>
  8. * Syed Mohammed Khasim <khasim@ti.com>
  9. * Sunil Kumar <sunilsaini05@gmail.com>
  10. * Shashi Ranjan <shashiranjanmca05@gmail.com>
  11. *
  12. * (C) Copyright 2004-2008
  13. * Texas Instruments, <www.ti.com>
  14. */
  15. #include <common.h>
  16. #include <twl4030.h>
  17. #include <asm/io.h>
  18. #include <asm/gpio.h>
  19. #include <asm/arch/mmc_host_def.h>
  20. #include <asm/arch/mux.h>
  21. #include <asm/arch/gpio.h>
  22. #include <asm/arch/sys_proto.h>
  23. #include <asm/mach-types.h>
  24. #include "pandora.h"
  25. DECLARE_GLOBAL_DATA_PTR;
  26. #define TWL4030_BB_CFG_BBCHEN (1 << 4)
  27. #define TWL4030_BB_CFG_BBSEL_3200MV (3 << 2)
  28. #define TWL4030_BB_CFG_BBISEL_500UA 2
  29. #define CONTROL_WKUP_CTRL 0x48002a5c
  30. #define GPIO_IO_PWRDNZ (1 << 6)
  31. #define PBIASLITEVMODE1 (1 << 8)
  32. /*
  33. * Routine: board_init
  34. * Description: Early hardware init.
  35. */
  36. int board_init(void)
  37. {
  38. gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
  39. /* board id for Linux */
  40. gd->bd->bi_arch_number = MACH_TYPE_OMAP3_PANDORA;
  41. /* boot param addr */
  42. gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
  43. return 0;
  44. }
  45. static void set_output_gpio(unsigned int gpio, int value)
  46. {
  47. int ret;
  48. ret = gpio_request(gpio, "");
  49. if (ret != 0) {
  50. printf("could not request GPIO %u\n", gpio);
  51. return;
  52. }
  53. ret = gpio_direction_output(gpio, value);
  54. if (ret != 0)
  55. printf("could not set GPIO %u to %d\n", gpio, value);
  56. }
  57. /*
  58. * Routine: misc_init_r
  59. * Description: Configure board specific parts
  60. */
  61. int misc_init_r(void)
  62. {
  63. t2_t *t2_base = (t2_t *)T2_BASE;
  64. u32 pbias_lite;
  65. twl4030_led_init(TWL4030_LED_LEDEN_LEDBON);
  66. /* set up dual-voltage GPIOs to 1.8V */
  67. pbias_lite = readl(&t2_base->pbias_lite);
  68. pbias_lite &= ~PBIASLITEVMODE1;
  69. pbias_lite |= PBIASLITEPWRDNZ1;
  70. writel(pbias_lite, &t2_base->pbias_lite);
  71. if (get_cpu_family() == CPU_OMAP36XX)
  72. writel(readl(CONTROL_WKUP_CTRL) | GPIO_IO_PWRDNZ,
  73. CONTROL_WKUP_CTRL);
  74. /* make sure audio and BT chips are in powerdown state */
  75. set_output_gpio(14, 0);
  76. set_output_gpio(15, 0);
  77. set_output_gpio(118, 0);
  78. /* enable USB supply */
  79. set_output_gpio(164, 1);
  80. /* wifi needs a short pulse to enter powersave state */
  81. set_output_gpio(23, 1);
  82. udelay(5000);
  83. gpio_direction_output(23, 0);
  84. /* Enable battery backup capacitor (3.2V, 0.5mA charge current) */
  85. twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER,
  86. TWL4030_PM_RECEIVER_BB_CFG,
  87. TWL4030_BB_CFG_BBCHEN | TWL4030_BB_CFG_BBSEL_3200MV |
  88. TWL4030_BB_CFG_BBISEL_500UA);
  89. omap_die_id_display();
  90. return 0;
  91. }
  92. /*
  93. * Routine: set_muxconf_regs
  94. * Description: Setting up the configuration Mux registers specific to the
  95. * hardware. Many pins need to be moved from protect to primary
  96. * mode.
  97. */
  98. void set_muxconf_regs(void)
  99. {
  100. MUX_PANDORA();
  101. if (get_cpu_family() == CPU_OMAP36XX) {
  102. MUX_PANDORA_3730();
  103. }
  104. }
  105. #ifdef CONFIG_MMC
  106. int board_mmc_init(bd_t *bis)
  107. {
  108. return omap_mmc_init(0, 0, 0, -1, -1);
  109. }
  110. void board_mmc_power_init(void)
  111. {
  112. twl4030_power_mmc_init(0);
  113. }
  114. #endif