gumstix.c 4.6 KB

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