csb726.c 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. /*
  2. * Support for Cogent CSB726
  3. *
  4. * Copyright (c) 2008 Dmitry Eremin-Solenikov
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. *
  10. */
  11. #include <linux/kernel.h>
  12. #include <linux/init.h>
  13. #include <linux/io.h>
  14. #include <linux/gpio.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/mtd/physmap.h>
  17. #include <linux/mtd/partitions.h>
  18. #include <linux/sm501.h>
  19. #include <asm/mach-types.h>
  20. #include <asm/mach/arch.h>
  21. #include <mach/csb726.h>
  22. #include <mach/mfp-pxa27x.h>
  23. #include <mach/i2c.h>
  24. #include <mach/mmc.h>
  25. #include <mach/ohci.h>
  26. #include <mach/pxa2xx-regs.h>
  27. #include "generic.h"
  28. #include "devices.h"
  29. /*
  30. * n/a: 2, 5, 6, 7, 8, 23, 24, 25, 26, 27, 87, 88, 89,
  31. * nu: 58 -- 77, 90, 91, 93, 102, 105-108, 114-116,
  32. * XXX: 21,
  33. * XXX: 79 CS_3 for LAN9215 or PSKTSEL on R2, R3
  34. * XXX: 33 CS_5 for LAN9215 on R1
  35. */
  36. static unsigned long csb726_pin_config[] = {
  37. GPIO78_nCS_2, /* EXP_CS */
  38. GPIO79_nCS_3, /* SMSC9215 */
  39. GPIO80_nCS_4, /* SM501 */
  40. GPIO52_GPIO, /* #SMSC9251 int */
  41. GPIO53_GPIO, /* SM501 int */
  42. GPIO1_GPIO, /* GPIO0 */
  43. GPIO11_GPIO, /* GPIO1 */
  44. GPIO9_GPIO, /* GPIO2 */
  45. GPIO10_GPIO, /* GPIO3 */
  46. GPIO16_PWM0_OUT, /* or GPIO4 */
  47. GPIO17_PWM1_OUT, /* or GPIO5 */
  48. GPIO94_GPIO, /* GPIO6 */
  49. GPIO95_GPIO, /* GPIO7 */
  50. GPIO96_GPIO, /* GPIO8 */
  51. GPIO97_GPIO, /* GPIO9 */
  52. GPIO15_GPIO, /* EXP_IRQ */
  53. GPIO18_RDY, /* EXP_WAIT */
  54. GPIO0_GPIO, /* PWR_INT */
  55. GPIO104_GPIO, /* PWR_OFF */
  56. GPIO12_GPIO, /* touch irq */
  57. GPIO13_SSP2_TXD,
  58. GPIO14_SSP2_SFRM,
  59. MFP_CFG_OUT(GPIO19, AF1, DRIVE_LOW),/* SSP2_SYSCLK */
  60. GPIO22_SSP2_SCLK,
  61. GPIO81_SSP3_TXD,
  62. GPIO82_SSP3_RXD,
  63. GPIO83_SSP3_SFRM,
  64. GPIO84_SSP3_SCLK,
  65. GPIO20_GPIO, /* SDIO int */
  66. GPIO32_MMC_CLK,
  67. GPIO92_MMC_DAT_0,
  68. GPIO109_MMC_DAT_1,
  69. GPIO110_MMC_DAT_2,
  70. GPIO111_MMC_DAT_3,
  71. GPIO112_MMC_CMD,
  72. GPIO100_GPIO, /* SD CD */
  73. GPIO101_GPIO, /* SD WP */
  74. GPIO28_AC97_BITCLK,
  75. GPIO29_AC97_SDATA_IN_0,
  76. GPIO30_AC97_SDATA_OUT,
  77. GPIO31_AC97_SYNC,
  78. GPIO113_AC97_nRESET,
  79. GPIO34_FFUART_RXD,
  80. GPIO35_FFUART_CTS,
  81. GPIO36_FFUART_DCD,
  82. GPIO37_FFUART_DSR,
  83. GPIO38_FFUART_RI,
  84. GPIO39_FFUART_TXD,
  85. GPIO40_FFUART_DTR,
  86. GPIO41_FFUART_RTS,
  87. GPIO42_BTUART_RXD,
  88. GPIO43_BTUART_TXD,
  89. GPIO44_BTUART_CTS,
  90. GPIO45_BTUART_RTS,
  91. GPIO46_STUART_RXD,
  92. GPIO47_STUART_TXD,
  93. GPIO48_nPOE,
  94. GPIO49_nPWE,
  95. GPIO50_nPIOR,
  96. GPIO51_nPIOW,
  97. GPIO54_nPCE_2,
  98. GPIO55_nPREG,
  99. GPIO56_nPWAIT,
  100. GPIO57_nIOIS16, /* maybe unused */
  101. GPIO85_nPCE_1,
  102. GPIO98_GPIO, /* CF IRQ */
  103. GPIO99_GPIO, /* CF CD */
  104. GPIO103_GPIO, /* Reset */
  105. GPIO117_I2C_SCL,
  106. GPIO118_I2C_SDA,
  107. };
  108. static struct pxamci_platform_data csb726_mci_data;
  109. static int csb726_mci_init(struct device *dev,
  110. irq_handler_t detect, void *data)
  111. {
  112. int err;
  113. csb726_mci_data.detect_delay = msecs_to_jiffies(500);
  114. err = gpio_request(CSB726_GPIO_MMC_DETECT, "MMC detect");
  115. if (err)
  116. goto err_det_req;
  117. err = gpio_direction_input(CSB726_GPIO_MMC_DETECT);
  118. if (err)
  119. goto err_det_dir;
  120. err = gpio_request(CSB726_GPIO_MMC_RO, "MMC ro");
  121. if (err)
  122. goto err_ro_req;
  123. err = gpio_direction_input(CSB726_GPIO_MMC_RO);
  124. if (err)
  125. goto err_ro_dir;
  126. err = request_irq(gpio_to_irq(CSB726_GPIO_MMC_DETECT), detect,
  127. IRQF_DISABLED, "MMC card detect", data);
  128. if (err)
  129. goto err_irq;
  130. return 0;
  131. err_irq:
  132. err_ro_dir:
  133. gpio_free(CSB726_GPIO_MMC_RO);
  134. err_ro_req:
  135. err_det_dir:
  136. gpio_free(CSB726_GPIO_MMC_DETECT);
  137. err_det_req:
  138. return err;
  139. }
  140. static int csb726_mci_get_ro(struct device *dev)
  141. {
  142. return gpio_get_value(CSB726_GPIO_MMC_RO);
  143. }
  144. static void csb726_mci_exit(struct device *dev, void *data)
  145. {
  146. free_irq(gpio_to_irq(CSB726_GPIO_MMC_DETECT), data);
  147. gpio_free(CSB726_GPIO_MMC_RO);
  148. gpio_free(CSB726_GPIO_MMC_DETECT);
  149. }
  150. static struct pxamci_platform_data csb726_mci = {
  151. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  152. .init = csb726_mci_init,
  153. .get_ro = csb726_mci_get_ro,
  154. /* FIXME setpower */
  155. .exit = csb726_mci_exit,
  156. };
  157. static struct pxaohci_platform_data csb726_ohci_platform_data = {
  158. .port_mode = PMM_NPS_MODE,
  159. .flags = ENABLE_PORT1 | NO_OC_PROTECTION,
  160. };
  161. static struct mtd_partition csb726_flash_partitions[] = {
  162. {
  163. .name = "Bootloader",
  164. .offset = 0,
  165. .size = CSB726_FLASH_uMON,
  166. .mask_flags = MTD_WRITEABLE /* force read-only */
  167. },
  168. {
  169. .name = "root",
  170. .offset = MTDPART_OFS_APPEND,
  171. .size = MTDPART_SIZ_FULL,
  172. }
  173. };
  174. static struct physmap_flash_data csb726_flash_data = {
  175. .width = 2,
  176. .parts = csb726_flash_partitions,
  177. .nr_parts = ARRAY_SIZE(csb726_flash_partitions),
  178. };
  179. static struct resource csb726_flash_resources[] = {
  180. {
  181. .start = PXA_CS0_PHYS,
  182. .end = PXA_CS0_PHYS + CSB726_FLASH_SIZE - 1 ,
  183. .flags = IORESOURCE_MEM,
  184. }
  185. };
  186. static struct platform_device csb726_flash = {
  187. .name = "physmap-flash",
  188. .dev = {
  189. .platform_data = &csb726_flash_data,
  190. },
  191. .resource = csb726_flash_resources,
  192. .num_resources = ARRAY_SIZE(csb726_flash_resources),
  193. };
  194. static struct resource csb726_sm501_resources[] = {
  195. {
  196. .start = PXA_CS4_PHYS,
  197. .end = PXA_CS4_PHYS + SZ_8M - 1,
  198. .flags = IORESOURCE_MEM,
  199. .name = "sm501-localmem",
  200. },
  201. {
  202. .start = PXA_CS4_PHYS + SZ_64M - SZ_2M,
  203. .end = PXA_CS4_PHYS + SZ_64M - 1,
  204. .flags = IORESOURCE_MEM,
  205. .name = "sm501-regs",
  206. },
  207. {
  208. .start = CSB726_IRQ_SM501,
  209. .end = CSB726_IRQ_SM501,
  210. .flags = IORESOURCE_IRQ,
  211. },
  212. };
  213. static struct sm501_initdata csb726_sm501_initdata = {
  214. /* .devices = SM501_USE_USB_HOST, */
  215. .devices = SM501_USE_USB_HOST | SM501_USE_UART0 | SM501_USE_UART1,
  216. };
  217. static struct sm501_platdata csb726_sm501_platdata = {
  218. .init = &csb726_sm501_initdata,
  219. };
  220. static struct platform_device csb726_sm501 = {
  221. .name = "sm501",
  222. .id = 0,
  223. .num_resources = ARRAY_SIZE(csb726_sm501_resources),
  224. .resource = csb726_sm501_resources,
  225. .dev = {
  226. .platform_data = &csb726_sm501_platdata,
  227. },
  228. };
  229. static struct resource csb726_lan_resources[] = {
  230. {
  231. .start = PXA_CS3_PHYS,
  232. .end = PXA_CS3_PHYS + SZ_64K - 1,
  233. .flags = IORESOURCE_MEM,
  234. },
  235. {
  236. .start = CSB726_IRQ_LAN,
  237. .end = CSB726_IRQ_LAN,
  238. .flags = IORESOURCE_IRQ,
  239. },
  240. };
  241. static struct platform_device csb726_lan = {
  242. .name = "smc911x",
  243. .id = -1,
  244. .num_resources = ARRAY_SIZE(csb726_lan_resources),
  245. .resource = csb726_lan_resources,
  246. };
  247. static struct platform_device *devices[] __initdata = {
  248. &csb726_flash,
  249. &csb726_sm501,
  250. &csb726_lan,
  251. };
  252. static void __init csb726_init(void)
  253. {
  254. pxa2xx_mfp_config(ARRAY_AND_SIZE(csb726_pin_config));
  255. /* MSC1 = 0x7ffc3ffc; *//* LAN9215/EXP_CS */
  256. /* MSC2 = 0x06697ff4; *//* none/SM501 */
  257. MSC2 = (MSC2 & ~0xffff) | 0x7ff4; /* SM501 */
  258. pxa_set_i2c_info(NULL);
  259. pxa27x_set_i2c_power_info(NULL);
  260. pxa_set_mci_info(&csb726_mci);
  261. pxa_set_ohci_info(&csb726_ohci_platform_data);
  262. platform_add_devices(devices, ARRAY_SIZE(devices));
  263. }
  264. MACHINE_START(CSB726, "Cogent CSB726")
  265. .phys_io = 0x40000000,
  266. .boot_params = 0xa0000100,
  267. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  268. .map_io = pxa_map_io,
  269. .init_irq = pxa27x_init_irq,
  270. .init_machine = csb726_init,
  271. .timer = &pxa_timer,
  272. MACHINE_END