sniper.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * LG Optimus Black codename sniper board
  4. *
  5. * Copyright (C) 2015 Paul Kocialkowski <contact@paulk.fr>
  6. */
  7. #include <config.h>
  8. #include <common.h>
  9. #include <dm.h>
  10. #include <env.h>
  11. #include <linux/ctype.h>
  12. #include <linux/usb/musb.h>
  13. #include <asm/omap_musb.h>
  14. #include <asm/arch/mmc_host_def.h>
  15. #include <asm/arch/sys_proto.h>
  16. #include <asm/arch/mem.h>
  17. #include <asm/io.h>
  18. #include <ns16550.h>
  19. #include <twl4030.h>
  20. #include "sniper.h"
  21. DECLARE_GLOBAL_DATA_PTR;
  22. const omap3_sysinfo sysinfo = {
  23. .mtype = DDR_STACKED,
  24. .board_string = "sniper",
  25. .nand_string = "MMC"
  26. };
  27. static const struct ns16550_platdata serial_omap_platdata = {
  28. .base = OMAP34XX_UART3,
  29. .reg_shift = 2,
  30. .clock = V_NS16550_CLK,
  31. .fcr = UART_FCR_DEFVAL,
  32. };
  33. U_BOOT_DEVICE(sniper_serial) = {
  34. .name = "ns16550_serial",
  35. .platdata = &serial_omap_platdata
  36. };
  37. static struct musb_hdrc_config musb_config = {
  38. .multipoint = 1,
  39. .dyn_fifo = 1,
  40. .num_eps = 16,
  41. .ram_bits = 12
  42. };
  43. static struct omap_musb_board_data musb_board_data = {
  44. .interface_type = MUSB_INTERFACE_ULPI,
  45. };
  46. static struct musb_hdrc_platform_data musb_platform_data = {
  47. .mode = MUSB_PERIPHERAL,
  48. .config = &musb_config,
  49. .power = 100,
  50. .platform_ops = &omap2430_ops,
  51. .board_data = &musb_board_data,
  52. };
  53. void set_muxconf_regs(void)
  54. {
  55. MUX_SNIPER();
  56. }
  57. #ifdef CONFIG_SPL_BUILD
  58. void get_board_mem_timings(struct board_sdrc_timings *timings)
  59. {
  60. timings->mcfg = HYNIX_V_MCFG_200(256 << 20);
  61. timings->ctrla = HYNIX_V_ACTIMA_200;
  62. timings->ctrlb = HYNIX_V_ACTIMB_200;
  63. timings->rfr_ctrl = SDP_3430_SDRC_RFR_CTRL_200MHz;
  64. timings->mr = MICRON_V_MR_165;
  65. }
  66. #endif
  67. int board_init(void)
  68. {
  69. /* GPMC init */
  70. gpmc_init();
  71. /* MACH number */
  72. gd->bd->bi_arch_number = 3000;
  73. /* ATAGs location */
  74. gd->bd->bi_boot_params = OMAP34XX_SDRC_CS0 + 0x100;
  75. return 0;
  76. }
  77. int misc_init_r(void)
  78. {
  79. unsigned char keypad_matrix[64] = { 0 };
  80. char reboot_mode[2] = { 0 };
  81. unsigned char keys[3];
  82. unsigned char data = 0;
  83. int rc;
  84. /* Power button reset init */
  85. twl4030_power_reset_init();
  86. /* Keypad */
  87. twl4030_keypad_scan((unsigned char *)&keypad_matrix);
  88. keys[0] = twl4030_keypad_key((unsigned char *)&keypad_matrix, 0, 0);
  89. keys[1] = twl4030_keypad_key((unsigned char *)&keypad_matrix, 0, 1);
  90. keys[2] = twl4030_keypad_key((unsigned char *)&keypad_matrix, 0, 2);
  91. /* Reboot mode */
  92. rc = omap_reboot_mode(reboot_mode, sizeof(reboot_mode));
  93. if (keys[0])
  94. reboot_mode[0] = 'r';
  95. else if (keys[1])
  96. reboot_mode[0] = 'b';
  97. if (rc < 0 || reboot_mode[0] == 'o') {
  98. /*
  99. * When not rebooting, valid power on reasons are either the
  100. * power button, charger plug or USB plug.
  101. */
  102. data |= twl4030_input_power_button();
  103. data |= twl4030_input_charger();
  104. data |= twl4030_input_usb();
  105. if (!data)
  106. twl4030_power_off();
  107. }
  108. if (reboot_mode[0] > 0 && isascii(reboot_mode[0])) {
  109. if (!env_get("reboot-mode"))
  110. env_set("reboot-mode", (char *)reboot_mode);
  111. }
  112. omap_reboot_mode_clear();
  113. /* Serial number */
  114. omap_die_id_serial();
  115. /* MUSB */
  116. musb_register(&musb_platform_data, &musb_board_data, (void *)MUSB_BASE);
  117. return 0;
  118. }
  119. u32 get_board_rev(void)
  120. {
  121. /* Sold devices are expected to be at least revision F. */
  122. return 6;
  123. }
  124. void get_board_serial(struct tag_serialnr *serialnr)
  125. {
  126. omap_die_id_get_board_serial(serialnr);
  127. }
  128. void reset_misc(void)
  129. {
  130. char reboot_mode[2] = { 0 };
  131. /*
  132. * Valid resets must contain the reboot mode magic, but we must not
  133. * override it when set previously (e.g. reboot to bootloader).
  134. */
  135. omap_reboot_mode(reboot_mode, sizeof(reboot_mode));
  136. omap_reboot_mode_store(reboot_mode);
  137. }
  138. int fastboot_set_reboot_flag(void)
  139. {
  140. return omap_reboot_mode_store("b");
  141. }
  142. int board_mmc_init(bd_t *bis)
  143. {
  144. return omap_mmc_init(1, 0, 0, -1, -1);
  145. }
  146. void board_mmc_power_init(void)
  147. {
  148. twl4030_power_mmc_init(1);
  149. }