kc1.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Amazon Kindle Fire (first generation) codename kc1 config
  4. *
  5. * Copyright (C) 2016 Paul Kocialkowski <contact@paulk.fr>
  6. */
  7. #include <config.h>
  8. #include <common.h>
  9. #include <env.h>
  10. #include <init.h>
  11. #include <linux/ctype.h>
  12. #include <linux/usb/musb.h>
  13. #include <asm/omap_musb.h>
  14. #include <asm/arch/sys_proto.h>
  15. #include <asm/arch/mmc_host_def.h>
  16. #include <asm/gpio.h>
  17. #include <asm/emif.h>
  18. #include <twl6030.h>
  19. #include "kc1.h"
  20. #include <asm/mach-types.h>
  21. DECLARE_GLOBAL_DATA_PTR;
  22. const struct omap_sysinfo sysinfo = {
  23. .board_string = "kc1"
  24. };
  25. static struct musb_hdrc_config musb_config = {
  26. .multipoint = 1,
  27. .dyn_fifo = 1,
  28. .num_eps = 16,
  29. .ram_bits = 12
  30. };
  31. static struct omap_musb_board_data musb_board_data = {
  32. .interface_type = MUSB_INTERFACE_UTMI,
  33. };
  34. static struct musb_hdrc_platform_data musb_platform_data = {
  35. .mode = MUSB_PERIPHERAL,
  36. .config = &musb_config,
  37. .power = 100,
  38. .platform_ops = &omap2430_ops,
  39. .board_data = &musb_board_data,
  40. };
  41. void set_muxconf_regs(void)
  42. {
  43. do_set_mux((*ctrl)->control_padconf_core_base, core_padconf_array,
  44. sizeof(core_padconf_array) / sizeof(struct pad_conf_entry));
  45. }
  46. struct lpddr2_device_details *emif_get_device_details(u32 emif_nr, u8 cs,
  47. struct lpddr2_device_details *lpddr2_dev_details)
  48. {
  49. if (cs == CS1)
  50. return NULL;
  51. *lpddr2_dev_details = elpida_2G_S4_details;
  52. return lpddr2_dev_details;
  53. }
  54. void emif_get_device_timings(u32 emif_nr,
  55. const struct lpddr2_device_timings **cs0_device_timings,
  56. const struct lpddr2_device_timings **cs1_device_timings)
  57. {
  58. *cs0_device_timings = &elpida_2G_S4_timings;
  59. *cs1_device_timings = NULL;
  60. }
  61. int board_init(void)
  62. {
  63. /* GPMC init */
  64. gpmc_init();
  65. /* MACH number */
  66. gd->bd->bi_arch_number = MACH_TYPE_OMAP_4430SDP;
  67. /* ATAGs location */
  68. gd->bd->bi_boot_params = OMAP44XX_DRAM_ADDR_SPACE_START + 0x100;
  69. return 0;
  70. }
  71. int misc_init_r(void)
  72. {
  73. char reboot_mode[2] = { 0 };
  74. u32 data = 0;
  75. u32 value;
  76. int rc;
  77. /* Reboot mode */
  78. rc = omap_reboot_mode(reboot_mode, sizeof(reboot_mode));
  79. /* USB ID pin pull-up indicates factory (fastboot) cable detection. */
  80. gpio_request(KC1_GPIO_USB_ID, "USB_ID");
  81. gpio_direction_input(KC1_GPIO_USB_ID);
  82. value = gpio_get_value(KC1_GPIO_USB_ID);
  83. if (value)
  84. reboot_mode[0] = 'b';
  85. if (rc < 0 || reboot_mode[0] == 'o') {
  86. /*
  87. * When not rebooting, valid power on reasons are either the
  88. * power button, charger plug or USB plug.
  89. */
  90. data |= twl6030_input_power_button();
  91. data |= twl6030_input_charger();
  92. data |= twl6030_input_usb();
  93. if (!data)
  94. twl6030_power_off();
  95. }
  96. if (reboot_mode[0] > 0 && isascii(reboot_mode[0])) {
  97. if (!env_get("reboot-mode"))
  98. env_set("reboot-mode", (char *)reboot_mode);
  99. }
  100. omap_reboot_mode_clear();
  101. /* Serial number */
  102. omap_die_id_serial();
  103. /* MUSB */
  104. musb_register(&musb_platform_data, &musb_board_data, (void *)MUSB_BASE);
  105. return 0;
  106. }
  107. u32 get_board_rev(void)
  108. {
  109. u32 value = 0;
  110. gpio_request(KC1_GPIO_MBID0, "MBID0");
  111. gpio_request(KC1_GPIO_MBID1, "MBID1");
  112. gpio_request(KC1_GPIO_MBID2, "MBID2");
  113. gpio_request(KC1_GPIO_MBID3, "MBID3");
  114. gpio_direction_input(KC1_GPIO_MBID0);
  115. gpio_direction_input(KC1_GPIO_MBID1);
  116. gpio_direction_input(KC1_GPIO_MBID2);
  117. gpio_direction_input(KC1_GPIO_MBID3);
  118. value |= (gpio_get_value(KC1_GPIO_MBID0) << 0);
  119. value |= (gpio_get_value(KC1_GPIO_MBID1) << 1);
  120. value |= (gpio_get_value(KC1_GPIO_MBID2) << 2);
  121. value |= (gpio_get_value(KC1_GPIO_MBID3) << 3);
  122. return value;
  123. }
  124. void get_board_serial(struct tag_serialnr *serialnr)
  125. {
  126. omap_die_id_get_board_serial(serialnr);
  127. }
  128. int fastboot_set_reboot_flag(void)
  129. {
  130. return omap_reboot_mode_store("b");
  131. }
  132. int board_mmc_init(struct bd_info *bis)
  133. {
  134. return omap_mmc_init(1, 0, 0, -1, -1);
  135. }
  136. void board_mmc_power_init(void)
  137. {
  138. twl6030_power_mmc_init(1);
  139. }