sniper.c 3.7 KB

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