csb726.c 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Support for Cogent CSB726
  4. *
  5. * Copyright (c) 2008 Dmitry Eremin-Solenikov
  6. */
  7. #include <linux/kernel.h>
  8. #include <linux/init.h>
  9. #include <linux/io.h>
  10. #include <linux/gpio/machine.h>
  11. #include <linux/platform_device.h>
  12. #include <linux/mtd/physmap.h>
  13. #include <linux/mtd/partitions.h>
  14. #include <linux/sm501.h>
  15. #include <linux/smsc911x.h>
  16. #include <linux/platform_data/i2c-pxa.h>
  17. #include <asm/mach-types.h>
  18. #include <asm/mach/arch.h>
  19. #include "csb726.h"
  20. #include "pxa27x.h"
  21. #include <linux/platform_data/mmc-pxamci.h>
  22. #include <linux/platform_data/usb-ohci-pxa27x.h>
  23. #include <linux/platform_data/asoc-pxa.h>
  24. #include "smemc.h"
  25. #include "generic.h"
  26. #include "devices.h"
  27. /*
  28. * n/a: 2, 5, 6, 7, 8, 23, 24, 25, 26, 27, 87, 88, 89,
  29. * nu: 58 -- 77, 90, 91, 93, 102, 105-108, 114-116,
  30. * XXX: 21,
  31. * XXX: 79 CS_3 for LAN9215 or PSKTSEL on R2, R3
  32. * XXX: 33 CS_5 for LAN9215 on R1
  33. */
  34. static unsigned long csb726_pin_config[] = {
  35. GPIO78_nCS_2, /* EXP_CS */
  36. GPIO79_nCS_3, /* SMSC9215 */
  37. GPIO80_nCS_4, /* SM501 */
  38. GPIO52_GPIO, /* #SMSC9251 int */
  39. GPIO53_GPIO, /* SM501 int */
  40. GPIO1_GPIO, /* GPIO0 */
  41. GPIO11_GPIO, /* GPIO1 */
  42. GPIO9_GPIO, /* GPIO2 */
  43. GPIO10_GPIO, /* GPIO3 */
  44. GPIO16_PWM0_OUT, /* or GPIO4 */
  45. GPIO17_PWM1_OUT, /* or GPIO5 */
  46. GPIO94_GPIO, /* GPIO6 */
  47. GPIO95_GPIO, /* GPIO7 */
  48. GPIO96_GPIO, /* GPIO8 */
  49. GPIO97_GPIO, /* GPIO9 */
  50. GPIO15_GPIO, /* EXP_IRQ */
  51. GPIO18_RDY, /* EXP_WAIT */
  52. GPIO0_GPIO, /* PWR_INT */
  53. GPIO104_GPIO, /* PWR_OFF */
  54. GPIO12_GPIO, /* touch irq */
  55. GPIO13_SSP2_TXD,
  56. GPIO14_SSP2_SFRM,
  57. MFP_CFG_OUT(GPIO19, AF1, DRIVE_LOW),/* SSP2_SYSCLK */
  58. GPIO22_SSP2_SCLK,
  59. GPIO81_SSP3_TXD,
  60. GPIO82_SSP3_RXD,
  61. GPIO83_SSP3_SFRM,
  62. GPIO84_SSP3_SCLK,
  63. GPIO20_GPIO, /* SDIO int */
  64. GPIO32_MMC_CLK,
  65. GPIO92_MMC_DAT_0,
  66. GPIO109_MMC_DAT_1,
  67. GPIO110_MMC_DAT_2,
  68. GPIO111_MMC_DAT_3,
  69. GPIO112_MMC_CMD,
  70. GPIO100_GPIO, /* SD CD */
  71. GPIO101_GPIO, /* SD WP */
  72. GPIO28_AC97_BITCLK,
  73. GPIO29_AC97_SDATA_IN_0,
  74. GPIO30_AC97_SDATA_OUT,
  75. GPIO31_AC97_SYNC,
  76. GPIO113_AC97_nRESET,
  77. GPIO34_FFUART_RXD,
  78. GPIO35_FFUART_CTS,
  79. GPIO36_FFUART_DCD,
  80. GPIO37_FFUART_DSR,
  81. GPIO38_FFUART_RI,
  82. GPIO39_FFUART_TXD,
  83. GPIO40_FFUART_DTR,
  84. GPIO41_FFUART_RTS,
  85. GPIO42_BTUART_RXD,
  86. GPIO43_BTUART_TXD,
  87. GPIO44_BTUART_CTS,
  88. GPIO45_BTUART_RTS,
  89. GPIO46_STUART_RXD,
  90. GPIO47_STUART_TXD,
  91. GPIO48_nPOE,
  92. GPIO49_nPWE,
  93. GPIO50_nPIOR,
  94. GPIO51_nPIOW,
  95. GPIO54_nPCE_2,
  96. GPIO55_nPREG,
  97. GPIO56_nPWAIT,
  98. GPIO57_nIOIS16, /* maybe unused */
  99. GPIO85_nPCE_1,
  100. GPIO98_GPIO, /* CF IRQ */
  101. GPIO99_GPIO, /* CF CD */
  102. GPIO103_GPIO, /* Reset */
  103. GPIO117_I2C_SCL,
  104. GPIO118_I2C_SDA,
  105. };
  106. static struct pxamci_platform_data csb726_mci = {
  107. .detect_delay_ms = 500,
  108. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  109. /* FIXME setpower */
  110. };
  111. static struct gpiod_lookup_table csb726_mci_gpio_table = {
  112. .dev_id = "pxa2xx-mci.0",
  113. .table = {
  114. /* Card detect on GPIO 100 */
  115. GPIO_LOOKUP("gpio-pxa", CSB726_GPIO_MMC_DETECT,
  116. "cd", GPIO_ACTIVE_LOW),
  117. /* Write protect on GPIO 101 */
  118. GPIO_LOOKUP("gpio-pxa", CSB726_GPIO_MMC_RO,
  119. "wp", GPIO_ACTIVE_LOW),
  120. { },
  121. },
  122. };
  123. static struct pxaohci_platform_data csb726_ohci_platform_data = {
  124. .port_mode = PMM_NPS_MODE,
  125. .flags = ENABLE_PORT1 | NO_OC_PROTECTION,
  126. };
  127. static struct mtd_partition csb726_flash_partitions[] = {
  128. {
  129. .name = "Bootloader",
  130. .offset = 0,
  131. .size = CSB726_FLASH_uMON,
  132. .mask_flags = MTD_WRITEABLE /* force read-only */
  133. },
  134. {
  135. .name = "root",
  136. .offset = MTDPART_OFS_APPEND,
  137. .size = MTDPART_SIZ_FULL,
  138. }
  139. };
  140. static struct physmap_flash_data csb726_flash_data = {
  141. .width = 2,
  142. .parts = csb726_flash_partitions,
  143. .nr_parts = ARRAY_SIZE(csb726_flash_partitions),
  144. };
  145. static struct resource csb726_flash_resources[] = {
  146. {
  147. .start = PXA_CS0_PHYS,
  148. .end = PXA_CS0_PHYS + CSB726_FLASH_SIZE - 1 ,
  149. .flags = IORESOURCE_MEM,
  150. }
  151. };
  152. static struct platform_device csb726_flash = {
  153. .name = "physmap-flash",
  154. .dev = {
  155. .platform_data = &csb726_flash_data,
  156. },
  157. .resource = csb726_flash_resources,
  158. .num_resources = ARRAY_SIZE(csb726_flash_resources),
  159. };
  160. static struct resource csb726_sm501_resources[] = {
  161. {
  162. .start = PXA_CS4_PHYS,
  163. .end = PXA_CS4_PHYS + SZ_8M - 1,
  164. .flags = IORESOURCE_MEM,
  165. .name = "sm501-localmem",
  166. },
  167. {
  168. .start = PXA_CS4_PHYS + SZ_64M - SZ_2M,
  169. .end = PXA_CS4_PHYS + SZ_64M - 1,
  170. .flags = IORESOURCE_MEM,
  171. .name = "sm501-regs",
  172. },
  173. {
  174. .start = CSB726_IRQ_SM501,
  175. .end = CSB726_IRQ_SM501,
  176. .flags = IORESOURCE_IRQ,
  177. },
  178. };
  179. static struct sm501_initdata csb726_sm501_initdata = {
  180. /* .devices = SM501_USE_USB_HOST, */
  181. .devices = SM501_USE_USB_HOST | SM501_USE_UART0 | SM501_USE_UART1,
  182. };
  183. static struct sm501_platdata csb726_sm501_platdata = {
  184. .init = &csb726_sm501_initdata,
  185. };
  186. static struct platform_device csb726_sm501 = {
  187. .name = "sm501",
  188. .id = 0,
  189. .num_resources = ARRAY_SIZE(csb726_sm501_resources),
  190. .resource = csb726_sm501_resources,
  191. .dev = {
  192. .platform_data = &csb726_sm501_platdata,
  193. },
  194. };
  195. static struct resource csb726_lan_resources[] = {
  196. {
  197. .start = PXA_CS3_PHYS,
  198. .end = PXA_CS3_PHYS + SZ_64K - 1,
  199. .flags = IORESOURCE_MEM,
  200. },
  201. {
  202. .start = CSB726_IRQ_LAN,
  203. .end = CSB726_IRQ_LAN,
  204. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
  205. },
  206. };
  207. struct smsc911x_platform_config csb726_lan_config = {
  208. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  209. .irq_type = SMSC911X_IRQ_TYPE_PUSH_PULL,
  210. .flags = SMSC911X_USE_32BIT,
  211. .phy_interface = PHY_INTERFACE_MODE_MII,
  212. };
  213. static struct platform_device csb726_lan = {
  214. .name = "smsc911x",
  215. .id = -1,
  216. .num_resources = ARRAY_SIZE(csb726_lan_resources),
  217. .resource = csb726_lan_resources,
  218. .dev = {
  219. .platform_data = &csb726_lan_config,
  220. },
  221. };
  222. static struct platform_device *devices[] __initdata = {
  223. &csb726_flash,
  224. &csb726_sm501,
  225. &csb726_lan,
  226. };
  227. static void __init csb726_init(void)
  228. {
  229. pxa2xx_mfp_config(ARRAY_AND_SIZE(csb726_pin_config));
  230. /* __raw_writel(0x7ffc3ffc, MSC1); *//* LAN9215/EXP_CS */
  231. /* __raw_writel(0x06697ff4, MSC2); *//* none/SM501 */
  232. __raw_writel((__raw_readl(MSC2) & ~0xffff) | 0x7ff4, MSC2); /* SM501 */
  233. pxa_set_ffuart_info(NULL);
  234. pxa_set_btuart_info(NULL);
  235. pxa_set_stuart_info(NULL);
  236. pxa_set_i2c_info(NULL);
  237. pxa27x_set_i2c_power_info(NULL);
  238. gpiod_add_lookup_table(&csb726_mci_gpio_table);
  239. pxa_set_mci_info(&csb726_mci);
  240. pxa_set_ohci_info(&csb726_ohci_platform_data);
  241. pxa_set_ac97_info(NULL);
  242. platform_add_devices(devices, ARRAY_SIZE(devices));
  243. }
  244. MACHINE_START(CSB726, "Cogent CSB726")
  245. .atag_offset = 0x100,
  246. .map_io = pxa27x_map_io,
  247. .nr_irqs = PXA_NR_IRQS,
  248. .init_irq = pxa27x_init_irq,
  249. .handle_irq = pxa27x_handle_irq,
  250. .init_machine = csb726_init,
  251. .init_time = pxa_timer_init,
  252. .restart = pxa_restart,
  253. MACHINE_END