gumstix.c 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * linux/arch/arm/mach-pxa/gumstix.c
  4. *
  5. * Support for the Gumstix motherboards.
  6. *
  7. * Original Author: Craig Hughes
  8. * Created: Feb 14, 2008
  9. * Copyright: Craig Hughes
  10. *
  11. * Implemented based on lubbock.c by Nicolas Pitre and code from Craig
  12. * Hughes
  13. */
  14. #include <linux/module.h>
  15. #include <linux/kernel.h>
  16. #include <linux/init.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/interrupt.h>
  19. #include <linux/delay.h>
  20. #include <linux/mtd/mtd.h>
  21. #include <linux/mtd/partitions.h>
  22. #include <linux/gpio/machine.h>
  23. #include <linux/gpio.h>
  24. #include <linux/err.h>
  25. #include <linux/clk.h>
  26. #include <asm/setup.h>
  27. #include <asm/memory.h>
  28. #include <asm/mach-types.h>
  29. #include <asm/irq.h>
  30. #include <linux/sizes.h>
  31. #include <asm/mach/arch.h>
  32. #include <asm/mach/map.h>
  33. #include <asm/mach/irq.h>
  34. #include <asm/mach/flash.h>
  35. #include "pxa25x.h"
  36. #include <linux/platform_data/mmc-pxamci.h>
  37. #include "udc.h"
  38. #include "gumstix.h"
  39. #include "generic.h"
  40. static struct resource flash_resource = {
  41. .start = 0x00000000,
  42. .end = SZ_64M - 1,
  43. .flags = IORESOURCE_MEM,
  44. };
  45. static struct mtd_partition gumstix_partitions[] = {
  46. {
  47. .name = "Bootloader",
  48. .size = 0x00040000,
  49. .offset = 0,
  50. .mask_flags = MTD_WRITEABLE /* force read-only */
  51. } , {
  52. .name = "rootfs",
  53. .size = MTDPART_SIZ_FULL,
  54. .offset = MTDPART_OFS_APPEND
  55. }
  56. };
  57. static struct flash_platform_data gumstix_flash_data = {
  58. .map_name = "cfi_probe",
  59. .parts = gumstix_partitions,
  60. .nr_parts = ARRAY_SIZE(gumstix_partitions),
  61. .width = 2,
  62. };
  63. static struct platform_device gumstix_flash_device = {
  64. .name = "pxa2xx-flash",
  65. .id = 0,
  66. .dev = {
  67. .platform_data = &gumstix_flash_data,
  68. },
  69. .resource = &flash_resource,
  70. .num_resources = 1,
  71. };
  72. static struct platform_device *devices[] __initdata = {
  73. &gumstix_flash_device,
  74. };
  75. #ifdef CONFIG_MMC_PXA
  76. static struct pxamci_platform_data gumstix_mci_platform_data = {
  77. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  78. };
  79. static void __init gumstix_mmc_init(void)
  80. {
  81. pxa_set_mci_info(&gumstix_mci_platform_data);
  82. }
  83. #else
  84. static void __init gumstix_mmc_init(void)
  85. {
  86. pr_debug("Gumstix mmc disabled\n");
  87. }
  88. #endif
  89. #ifdef CONFIG_USB_PXA25X
  90. static struct gpiod_lookup_table gumstix_gpio_vbus_gpiod_table = {
  91. .dev_id = "gpio-vbus",
  92. .table = {
  93. GPIO_LOOKUP("gpio-pxa", GPIO_GUMSTIX_USB_GPIOn,
  94. "vbus", GPIO_ACTIVE_HIGH),
  95. GPIO_LOOKUP("gpio-pxa", GPIO_GUMSTIX_USB_GPIOx,
  96. "pullup", GPIO_ACTIVE_HIGH),
  97. { },
  98. },
  99. };
  100. static struct platform_device gumstix_gpio_vbus = {
  101. .name = "gpio-vbus",
  102. .id = -1,
  103. };
  104. static void __init gumstix_udc_init(void)
  105. {
  106. gpiod_add_lookup_table(&gumstix_gpio_vbus_gpiod_table);
  107. platform_device_register(&gumstix_gpio_vbus);
  108. }
  109. #else
  110. static void gumstix_udc_init(void)
  111. {
  112. pr_debug("Gumstix udc is disabled\n");
  113. }
  114. #endif
  115. #ifdef CONFIG_BT
  116. /* Normally, the bootloader would have enabled this 32kHz clock but many
  117. ** boards still have u-boot 1.1.4 so we check if it has been turned on and
  118. ** if not, we turn it on with a warning message. */
  119. static void gumstix_setup_bt_clock(void)
  120. {
  121. int timeout = 500;
  122. if (!(readl(OSCC) & OSCC_OOK))
  123. pr_warn("32kHz clock was not on. Bootloader may need to be updated\n");
  124. else
  125. return;
  126. writel(readl(OSCC) | OSCC_OON, OSCC);
  127. do {
  128. if (readl(OSCC) & OSCC_OOK)
  129. break;
  130. udelay(1);
  131. } while (--timeout);
  132. if (!timeout)
  133. pr_err("Failed to start 32kHz clock\n");
  134. }
  135. static void __init gumstix_bluetooth_init(void)
  136. {
  137. int err;
  138. gumstix_setup_bt_clock();
  139. err = gpio_request(GPIO_GUMSTIX_BTRESET, "BTRST");
  140. if (err) {
  141. pr_err("gumstix: failed request gpio for bluetooth reset\n");
  142. return;
  143. }
  144. err = gpio_direction_output(GPIO_GUMSTIX_BTRESET, 1);
  145. if (err) {
  146. pr_err("gumstix: can't reset bluetooth\n");
  147. return;
  148. }
  149. gpio_set_value(GPIO_GUMSTIX_BTRESET, 0);
  150. udelay(100);
  151. gpio_set_value(GPIO_GUMSTIX_BTRESET, 1);
  152. }
  153. #else
  154. static void gumstix_bluetooth_init(void)
  155. {
  156. pr_debug("Gumstix Bluetooth is disabled\n");
  157. }
  158. #endif
  159. static unsigned long gumstix_pin_config[] __initdata = {
  160. GPIO12_32KHz,
  161. /* BTUART */
  162. GPIO42_HWUART_RXD,
  163. GPIO43_HWUART_TXD,
  164. GPIO44_HWUART_CTS,
  165. GPIO45_HWUART_RTS,
  166. /* MMC */
  167. GPIO6_MMC_CLK,
  168. GPIO53_MMC_CLK,
  169. GPIO8_MMC_CS0,
  170. };
  171. int __attribute__((weak)) am200_init(void)
  172. {
  173. return 0;
  174. }
  175. int __attribute__((weak)) am300_init(void)
  176. {
  177. return 0;
  178. }
  179. static void __init carrier_board_init(void)
  180. {
  181. /*
  182. * put carrier/expansion board init here if
  183. * they cannot be detected programatically
  184. */
  185. am200_init();
  186. am300_init();
  187. }
  188. static void __init gumstix_init(void)
  189. {
  190. pxa2xx_mfp_config(ARRAY_AND_SIZE(gumstix_pin_config));
  191. pxa_set_ffuart_info(NULL);
  192. pxa_set_btuart_info(NULL);
  193. pxa_set_stuart_info(NULL);
  194. pxa_set_hwuart_info(NULL);
  195. gumstix_bluetooth_init();
  196. gumstix_udc_init();
  197. gumstix_mmc_init();
  198. (void) platform_add_devices(devices, ARRAY_SIZE(devices));
  199. carrier_board_init();
  200. }
  201. MACHINE_START(GUMSTIX, "Gumstix")
  202. .atag_offset = 0x100, /* match u-boot bi_boot_params */
  203. .map_io = pxa25x_map_io,
  204. .nr_irqs = PXA_NR_IRQS,
  205. .init_irq = pxa25x_init_irq,
  206. .handle_irq = pxa25x_handle_irq,
  207. .init_time = pxa_timer_init,
  208. .init_machine = gumstix_init,
  209. .restart = pxa_restart,
  210. MACHINE_END