gumstix.c 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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. };
  82. static void __init gumstix_mmc_init(void)
  83. {
  84. pxa_set_mci_info(&gumstix_mci_platform_data);
  85. }
  86. #else
  87. static void __init gumstix_mmc_init(void)
  88. {
  89. pr_debug("Gumstix mmc disabled\n");
  90. }
  91. #endif
  92. #ifdef CONFIG_USB_GADGET_PXA25X
  93. static struct pxa2xx_udc_mach_info gumstix_udc_info __initdata = {
  94. .gpio_vbus = GPIO_GUMSTIX_USB_GPIOn,
  95. .gpio_pullup = GPIO_GUMSTIX_USB_GPIOx,
  96. };
  97. static void __init gumstix_udc_init(void)
  98. {
  99. pxa_set_udc_info(&gumstix_udc_info);
  100. }
  101. #else
  102. static void gumstix_udc_init(void)
  103. {
  104. pr_debug("Gumstix udc is disabled\n");
  105. }
  106. #endif
  107. #ifdef CONFIG_BT
  108. /* Normally, the bootloader would have enabled this 32kHz clock but many
  109. ** boards still have u-boot 1.1.4 so we check if it has been turned on and
  110. ** if not, we turn it on with a warning message. */
  111. static void gumstix_setup_bt_clock(void)
  112. {
  113. int timeout = 500;
  114. if (!(OSCC & OSCC_OOK))
  115. pr_warning("32kHz clock was not on. Bootloader may need to "
  116. "be updated\n");
  117. else
  118. return;
  119. OSCC |= OSCC_OON;
  120. do {
  121. if (OSCC & OSCC_OOK)
  122. break;
  123. udelay(1);
  124. } while (--timeout);
  125. if (!timeout)
  126. pr_err("Failed to start 32kHz clock\n");
  127. }
  128. static void __init gumstix_bluetooth_init(void)
  129. {
  130. int err;
  131. gumstix_setup_bt_clock();
  132. err = gpio_request(GPIO_GUMSTIX_BTRESET, "BTRST");
  133. if (err) {
  134. pr_err("gumstix: failed request gpio for bluetooth reset\n");
  135. return;
  136. }
  137. err = gpio_direction_output(GPIO_GUMSTIX_BTRESET, 1);
  138. if (err) {
  139. pr_err("gumstix: can't reset bluetooth\n");
  140. return;
  141. }
  142. gpio_set_value(GPIO_GUMSTIX_BTRESET, 0);
  143. udelay(100);
  144. gpio_set_value(GPIO_GUMSTIX_BTRESET, 1);
  145. }
  146. #else
  147. static void gumstix_bluetooth_init(void)
  148. {
  149. pr_debug("Gumstix Bluetooth is disabled\n");
  150. }
  151. #endif
  152. static unsigned long gumstix_pin_config[] __initdata = {
  153. GPIO12_32KHz,
  154. /* BTUART */
  155. GPIO42_HWUART_RXD,
  156. GPIO43_HWUART_TXD,
  157. GPIO44_HWUART_CTS,
  158. GPIO45_HWUART_RTS,
  159. /* MMC */
  160. GPIO6_MMC_CLK,
  161. GPIO53_MMC_CLK,
  162. GPIO8_MMC_CS0,
  163. };
  164. int __attribute__((weak)) am200_init(void)
  165. {
  166. return 0;
  167. }
  168. int __attribute__((weak)) am300_init(void)
  169. {
  170. return 0;
  171. }
  172. static void __init carrier_board_init(void)
  173. {
  174. /*
  175. * put carrier/expansion board init here if
  176. * they cannot be detected programatically
  177. */
  178. am200_init();
  179. am300_init();
  180. }
  181. static void __init gumstix_init(void)
  182. {
  183. pxa2xx_mfp_config(ARRAY_AND_SIZE(gumstix_pin_config));
  184. gumstix_bluetooth_init();
  185. gumstix_udc_init();
  186. gumstix_mmc_init();
  187. (void) platform_add_devices(devices, ARRAY_SIZE(devices));
  188. carrier_board_init();
  189. }
  190. MACHINE_START(GUMSTIX, "Gumstix")
  191. .phys_io = 0x40000000,
  192. .boot_params = 0xa0000100, /* match u-boot bi_boot_params */
  193. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  194. .map_io = pxa_map_io,
  195. .init_irq = pxa25x_init_irq,
  196. .timer = &pxa_timer,
  197. .init_machine = gumstix_init,
  198. MACHINE_END