gumstix.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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 <asm/setup.h>
  29. #include <asm/memory.h>
  30. #include <asm/mach-types.h>
  31. #include <mach/hardware.h>
  32. #include <asm/irq.h>
  33. #include <asm/sizes.h>
  34. #include <asm/mach/arch.h>
  35. #include <asm/mach/map.h>
  36. #include <asm/mach/irq.h>
  37. #include <asm/mach/flash.h>
  38. #include <mach/pxa25x.h>
  39. #include <mach/mmc.h>
  40. #include <mach/udc.h>
  41. #include <mach/gumstix.h>
  42. #include "generic.h"
  43. static struct resource flash_resource = {
  44. .start = 0x00000000,
  45. .end = SZ_64M - 1,
  46. .flags = IORESOURCE_MEM,
  47. };
  48. static struct mtd_partition gumstix_partitions[] = {
  49. {
  50. .name = "Bootloader",
  51. .size = 0x00040000,
  52. .offset = 0,
  53. .mask_flags = MTD_WRITEABLE /* force read-only */
  54. } , {
  55. .name = "rootfs",
  56. .size = MTDPART_SIZ_FULL,
  57. .offset = MTDPART_OFS_APPEND
  58. }
  59. };
  60. static struct flash_platform_data gumstix_flash_data = {
  61. .map_name = "cfi_probe",
  62. .parts = gumstix_partitions,
  63. .nr_parts = ARRAY_SIZE(gumstix_partitions),
  64. .width = 2,
  65. };
  66. static struct platform_device gumstix_flash_device = {
  67. .name = "pxa2xx-flash",
  68. .id = 0,
  69. .dev = {
  70. .platform_data = &gumstix_flash_data,
  71. },
  72. .resource = &flash_resource,
  73. .num_resources = 1,
  74. };
  75. static struct platform_device *devices[] __initdata = {
  76. &gumstix_flash_device,
  77. };
  78. #ifdef CONFIG_MMC_PXA
  79. static struct pxamci_platform_data gumstix_mci_platform_data = {
  80. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  81. .gpio_card_detect = -1,
  82. .gpio_card_ro = -1,
  83. .gpio_power = -1,
  84. };
  85. static void __init gumstix_mmc_init(void)
  86. {
  87. pxa_set_mci_info(&gumstix_mci_platform_data);
  88. }
  89. #else
  90. static void __init gumstix_mmc_init(void)
  91. {
  92. pr_debug("Gumstix mmc disabled\n");
  93. }
  94. #endif
  95. #ifdef CONFIG_USB_GADGET_PXA25X
  96. static struct pxa2xx_udc_mach_info gumstix_udc_info __initdata = {
  97. .gpio_vbus = GPIO_GUMSTIX_USB_GPIOn,
  98. .gpio_pullup = GPIO_GUMSTIX_USB_GPIOx,
  99. };
  100. static void __init gumstix_udc_init(void)
  101. {
  102. pxa_set_udc_info(&gumstix_udc_info);
  103. }
  104. #else
  105. static void gumstix_udc_init(void)
  106. {
  107. pr_debug("Gumstix udc is disabled\n");
  108. }
  109. #endif
  110. #ifdef CONFIG_BT
  111. /* Normally, the bootloader would have enabled this 32kHz clock but many
  112. ** boards still have u-boot 1.1.4 so we check if it has been turned on and
  113. ** if not, we turn it on with a warning message. */
  114. static void gumstix_setup_bt_clock(void)
  115. {
  116. int timeout = 500;
  117. if (!(OSCC & OSCC_OOK))
  118. pr_warning("32kHz clock was not on. Bootloader may need to "
  119. "be updated\n");
  120. else
  121. return;
  122. OSCC |= OSCC_OON;
  123. do {
  124. if (OSCC & OSCC_OOK)
  125. break;
  126. udelay(1);
  127. } while (--timeout);
  128. if (!timeout)
  129. pr_err("Failed to start 32kHz clock\n");
  130. }
  131. static void __init gumstix_bluetooth_init(void)
  132. {
  133. int err;
  134. gumstix_setup_bt_clock();
  135. err = gpio_request(GPIO_GUMSTIX_BTRESET, "BTRST");
  136. if (err) {
  137. pr_err("gumstix: failed request gpio for bluetooth reset\n");
  138. return;
  139. }
  140. err = gpio_direction_output(GPIO_GUMSTIX_BTRESET, 1);
  141. if (err) {
  142. pr_err("gumstix: can't reset bluetooth\n");
  143. return;
  144. }
  145. gpio_set_value(GPIO_GUMSTIX_BTRESET, 0);
  146. udelay(100);
  147. gpio_set_value(GPIO_GUMSTIX_BTRESET, 1);
  148. }
  149. #else
  150. static void gumstix_bluetooth_init(void)
  151. {
  152. pr_debug("Gumstix Bluetooth is disabled\n");
  153. }
  154. #endif
  155. static unsigned long gumstix_pin_config[] __initdata = {
  156. GPIO12_32KHz,
  157. /* BTUART */
  158. GPIO42_HWUART_RXD,
  159. GPIO43_HWUART_TXD,
  160. GPIO44_HWUART_CTS,
  161. GPIO45_HWUART_RTS,
  162. /* MMC */
  163. GPIO6_MMC_CLK,
  164. GPIO53_MMC_CLK,
  165. GPIO8_MMC_CS0,
  166. };
  167. int __attribute__((weak)) am200_init(void)
  168. {
  169. return 0;
  170. }
  171. int __attribute__((weak)) am300_init(void)
  172. {
  173. return 0;
  174. }
  175. static void __init carrier_board_init(void)
  176. {
  177. /*
  178. * put carrier/expansion board init here if
  179. * they cannot be detected programatically
  180. */
  181. am200_init();
  182. am300_init();
  183. }
  184. static void __init gumstix_init(void)
  185. {
  186. pxa2xx_mfp_config(ARRAY_AND_SIZE(gumstix_pin_config));
  187. gumstix_bluetooth_init();
  188. gumstix_udc_init();
  189. gumstix_mmc_init();
  190. (void) platform_add_devices(devices, ARRAY_SIZE(devices));
  191. carrier_board_init();
  192. }
  193. MACHINE_START(GUMSTIX, "Gumstix")
  194. .phys_io = 0x40000000,
  195. .boot_params = 0xa0000100, /* match u-boot bi_boot_params */
  196. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  197. .map_io = pxa_map_io,
  198. .init_irq = pxa25x_init_irq,
  199. .timer = &pxa_timer,
  200. .init_machine = gumstix_init,
  201. MACHINE_END