gumstix.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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 "pxa25x.h"
  40. #include <linux/platform_data/mmc-pxamci.h>
  41. #include "udc.h"
  42. #include "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_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 (!(readl(OSCC) & OSCC_OOK))
  126. pr_warn("32kHz clock was not on. Bootloader may need to be updated\n");
  127. else
  128. return;
  129. writel(readl(OSCC) | OSCC_OON, OSCC);
  130. do {
  131. if (readl(OSCC) & OSCC_OOK)
  132. break;
  133. udelay(1);
  134. } while (--timeout);
  135. if (!timeout)
  136. pr_err("Failed to start 32kHz clock\n");
  137. }
  138. static void __init gumstix_bluetooth_init(void)
  139. {
  140. int err;
  141. gumstix_setup_bt_clock();
  142. err = gpio_request(GPIO_GUMSTIX_BTRESET, "BTRST");
  143. if (err) {
  144. pr_err("gumstix: failed request gpio for bluetooth reset\n");
  145. return;
  146. }
  147. err = gpio_direction_output(GPIO_GUMSTIX_BTRESET, 1);
  148. if (err) {
  149. pr_err("gumstix: can't reset bluetooth\n");
  150. return;
  151. }
  152. gpio_set_value(GPIO_GUMSTIX_BTRESET, 0);
  153. udelay(100);
  154. gpio_set_value(GPIO_GUMSTIX_BTRESET, 1);
  155. }
  156. #else
  157. static void gumstix_bluetooth_init(void)
  158. {
  159. pr_debug("Gumstix Bluetooth is disabled\n");
  160. }
  161. #endif
  162. static unsigned long gumstix_pin_config[] __initdata = {
  163. GPIO12_32KHz,
  164. /* BTUART */
  165. GPIO42_HWUART_RXD,
  166. GPIO43_HWUART_TXD,
  167. GPIO44_HWUART_CTS,
  168. GPIO45_HWUART_RTS,
  169. /* MMC */
  170. GPIO6_MMC_CLK,
  171. GPIO53_MMC_CLK,
  172. GPIO8_MMC_CS0,
  173. };
  174. int __attribute__((weak)) am200_init(void)
  175. {
  176. return 0;
  177. }
  178. int __attribute__((weak)) am300_init(void)
  179. {
  180. return 0;
  181. }
  182. static void __init carrier_board_init(void)
  183. {
  184. /*
  185. * put carrier/expansion board init here if
  186. * they cannot be detected programatically
  187. */
  188. am200_init();
  189. am300_init();
  190. }
  191. static void __init gumstix_init(void)
  192. {
  193. pxa2xx_mfp_config(ARRAY_AND_SIZE(gumstix_pin_config));
  194. pxa_set_ffuart_info(NULL);
  195. pxa_set_btuart_info(NULL);
  196. pxa_set_stuart_info(NULL);
  197. pxa_set_hwuart_info(NULL);
  198. gumstix_bluetooth_init();
  199. gumstix_udc_init();
  200. gumstix_mmc_init();
  201. (void) platform_add_devices(devices, ARRAY_SIZE(devices));
  202. carrier_board_init();
  203. }
  204. MACHINE_START(GUMSTIX, "Gumstix")
  205. .atag_offset = 0x100, /* match u-boot bi_boot_params */
  206. .map_io = pxa25x_map_io,
  207. .nr_irqs = PXA_NR_IRQS,
  208. .init_irq = pxa25x_init_irq,
  209. .handle_irq = pxa25x_handle_irq,
  210. .init_time = pxa_timer_init,
  211. .init_machine = gumstix_init,
  212. .restart = pxa_restart,
  213. MACHINE_END