gumstix.c 5.0 KB

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