pandora.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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 <dm.h>
  17. #include <ns16550.h>
  18. #include <twl4030.h>
  19. #include <asm/io.h>
  20. #include <asm/gpio.h>
  21. #include <asm/arch/mmc_host_def.h>
  22. #include <asm/arch/mux.h>
  23. #include <asm/arch/gpio.h>
  24. #include <asm/arch/sys_proto.h>
  25. #include <asm/mach-types.h>
  26. #include "pandora.h"
  27. DECLARE_GLOBAL_DATA_PTR;
  28. #define TWL4030_BB_CFG_BBCHEN (1 << 4)
  29. #define TWL4030_BB_CFG_BBSEL_3200MV (3 << 2)
  30. #define TWL4030_BB_CFG_BBISEL_500UA 2
  31. #define CONTROL_WKUP_CTRL 0x48002a5c
  32. #define GPIO_IO_PWRDNZ (1 << 6)
  33. #define PBIASLITEVMODE1 (1 << 8)
  34. static const struct ns16550_platdata pandora_serial = {
  35. .base = OMAP34XX_UART3,
  36. .reg_shift = 2,
  37. .clock = V_NS16550_CLK,
  38. .fcr = UART_FCR_DEFVAL,
  39. };
  40. U_BOOT_DEVICE(pandora_uart) = {
  41. "ns16550_serial",
  42. &pandora_serial
  43. };
  44. /*
  45. * Routine: board_init
  46. * Description: Early hardware init.
  47. */
  48. int board_init(void)
  49. {
  50. gpmc_init(); /* in SRAM or SDRAM, finish GPMC */
  51. /* board id for Linux */
  52. gd->bd->bi_arch_number = MACH_TYPE_OMAP3_PANDORA;
  53. /* boot param addr */
  54. gd->bd->bi_boot_params = (OMAP34XX_SDRC_CS0 + 0x100);
  55. return 0;
  56. }
  57. static void set_output_gpio(unsigned int gpio, int value)
  58. {
  59. int ret;
  60. ret = gpio_request(gpio, "");
  61. if (ret != 0) {
  62. printf("could not request GPIO %u\n", gpio);
  63. return;
  64. }
  65. ret = gpio_direction_output(gpio, value);
  66. if (ret != 0)
  67. printf("could not set GPIO %u to %d\n", gpio, value);
  68. }
  69. /*
  70. * Routine: misc_init_r
  71. * Description: Configure board specific parts
  72. */
  73. int misc_init_r(void)
  74. {
  75. t2_t *t2_base = (t2_t *)T2_BASE;
  76. u32 pbias_lite;
  77. twl4030_led_init(TWL4030_LED_LEDEN_LEDBON);
  78. /* set up dual-voltage GPIOs to 1.8V */
  79. pbias_lite = readl(&t2_base->pbias_lite);
  80. pbias_lite &= ~PBIASLITEVMODE1;
  81. pbias_lite |= PBIASLITEPWRDNZ1;
  82. writel(pbias_lite, &t2_base->pbias_lite);
  83. if (get_cpu_family() == CPU_OMAP36XX)
  84. writel(readl(CONTROL_WKUP_CTRL) | GPIO_IO_PWRDNZ,
  85. CONTROL_WKUP_CTRL);
  86. /* make sure audio and BT chips are in powerdown state */
  87. set_output_gpio(14, 0);
  88. set_output_gpio(15, 0);
  89. set_output_gpio(118, 0);
  90. /* enable USB supply */
  91. set_output_gpio(164, 1);
  92. /* wifi needs a short pulse to enter powersave state */
  93. set_output_gpio(23, 1);
  94. udelay(5000);
  95. gpio_direction_output(23, 0);
  96. /* Enable battery backup capacitor (3.2V, 0.5mA charge current) */
  97. twl4030_i2c_write_u8(TWL4030_CHIP_PM_RECEIVER,
  98. TWL4030_PM_RECEIVER_BB_CFG,
  99. TWL4030_BB_CFG_BBCHEN | TWL4030_BB_CFG_BBSEL_3200MV |
  100. TWL4030_BB_CFG_BBISEL_500UA);
  101. omap_die_id_display();
  102. return 0;
  103. }
  104. /*
  105. * Routine: set_muxconf_regs
  106. * Description: Setting up the configuration Mux registers specific to the
  107. * hardware. Many pins need to be moved from protect to primary
  108. * mode.
  109. */
  110. void set_muxconf_regs(void)
  111. {
  112. MUX_PANDORA();
  113. if (get_cpu_family() == CPU_OMAP36XX) {
  114. MUX_PANDORA_3730();
  115. }
  116. }
  117. #ifdef CONFIG_MMC
  118. int board_mmc_init(bd_t *bis)
  119. {
  120. return omap_mmc_init(0, 0, 0, -1, -1);
  121. }
  122. void board_mmc_power_init(void)
  123. {
  124. twl4030_power_mmc_init(0);
  125. }
  126. #endif