kc1.c 3.6 KB

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