devices.c 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. /*
  2. * linux/arch/arm/mach-tcc8k/devices.c
  3. *
  4. * Copyright (C) Telechips, Inc.
  5. * Copyright (C) 2009 Hans J. Koch <hjk@linutronix.de>
  6. *
  7. * Licensed under the terms of GPL v2.
  8. *
  9. */
  10. #include <linux/dma-mapping.h>
  11. #include <linux/init.h>
  12. #include <linux/io.h>
  13. #include <linux/kernel.h>
  14. #include <linux/module.h>
  15. #include <asm/mach/map.h>
  16. #include <mach/tcc8k-regs.h>
  17. #include <mach/irqs.h>
  18. #include "common.h"
  19. static u64 tcc8k_dmamask = DMA_BIT_MASK(32);
  20. #ifdef CONFIG_MTD_NAND_TCC
  21. /* NAND controller */
  22. static struct resource tcc_nand_resources[] = {
  23. {
  24. .start = (resource_size_t)NFC_BASE,
  25. .end = (resource_size_t)NFC_BASE + 0x7f,
  26. .flags = IORESOURCE_MEM,
  27. }, {
  28. .start = INT_NFC,
  29. .end = INT_NFC,
  30. .flags = IORESOURCE_IRQ,
  31. },
  32. };
  33. struct platform_device tcc_nand_device = {
  34. .name = "tcc_nand",
  35. .id = 0,
  36. .num_resources = ARRAY_SIZE(tcc_nand_resources),
  37. .resource = tcc_nand_resources,
  38. };
  39. #endif
  40. #ifdef CONFIG_MMC_TCC8K
  41. /* MMC controller */
  42. static struct resource tcc8k_mmc0_resource[] = {
  43. {
  44. .start = INT_SD0,
  45. .end = INT_SD0,
  46. .flags = IORESOURCE_IRQ,
  47. },
  48. };
  49. static struct resource tcc8k_mmc1_resource[] = {
  50. {
  51. .start = INT_SD1,
  52. .end = INT_SD1,
  53. .flags = IORESOURCE_IRQ,
  54. },
  55. };
  56. struct platform_device tcc8k_mmc0_device = {
  57. .name = "tcc-mmc",
  58. .id = 0,
  59. .num_resources = ARRAY_SIZE(tcc8k_mmc0_resource),
  60. .resource = tcc8k_mmc0_resource,
  61. .dev = {
  62. .dma_mask = &tcc8k_dmamask,
  63. .coherent_dma_mask = DMA_BIT_MASK(32),
  64. }
  65. };
  66. struct platform_device tcc8k_mmc1_device = {
  67. .name = "tcc-mmc",
  68. .id = 1,
  69. .num_resources = ARRAY_SIZE(tcc8k_mmc1_resource),
  70. .resource = tcc8k_mmc1_resource,
  71. .dev = {
  72. .dma_mask = &tcc8k_dmamask,
  73. .coherent_dma_mask = DMA_BIT_MASK(32),
  74. }
  75. };
  76. static inline void tcc8k_init_mmc(void)
  77. {
  78. u32 reg = __raw_readl(GPIOPS_BASE + GPIOPS_FS1_OFFS);
  79. reg |= GPIOPS_FS1_SDH0_BITS | GPIOPS_FS1_SDH1_BITS;
  80. __raw_writel(reg, GPIOPS_BASE + GPIOPS_FS1_OFFS);
  81. platform_device_register(&tcc8k_mmc0_device);
  82. platform_device_register(&tcc8k_mmc1_device);
  83. }
  84. #else
  85. static inline void tcc8k_init_mmc(void) { }
  86. #endif
  87. #ifdef CONFIG_USB_OHCI_HCD
  88. static int tcc8k_ohci_init(struct device *dev)
  89. {
  90. u32 reg;
  91. /* Use GPIO PK19 as VBUS control output */
  92. reg = __raw_readl(GPIOPK_BASE + GPIOPK_FS0_OFFS);
  93. reg &= ~(1 << 19);
  94. __raw_writel(reg, GPIOPK_BASE + GPIOPK_FS0_OFFS);
  95. reg = __raw_readl(GPIOPK_BASE + GPIOPK_FS1_OFFS);
  96. reg &= ~(1 << 19);
  97. __raw_writel(reg, GPIOPK_BASE + GPIOPK_FS1_OFFS);
  98. reg = __raw_readl(GPIOPK_BASE + GPIOPK_DOE_OFFS);
  99. reg |= (1 << 19);
  100. __raw_writel(reg, GPIOPK_BASE + GPIOPK_DOE_OFFS);
  101. /* Turn on VBUS */
  102. reg = __raw_readl(GPIOPK_BASE + GPIOPK_DAT_OFFS);
  103. reg |= (1 << 19);
  104. __raw_writel(reg, GPIOPK_BASE + GPIOPK_DAT_OFFS);
  105. return 0;
  106. }
  107. static struct resource tcc8k_ohci0_resources[] = {
  108. [0] = {
  109. .start = (resource_size_t)USBH0_BASE,
  110. .end = (resource_size_t)USBH0_BASE + 0x5c,
  111. .flags = IORESOURCE_MEM,
  112. },
  113. [1] = {
  114. .start = INT_USBH0,
  115. .end = INT_USBH0,
  116. .flags = IORESOURCE_IRQ,
  117. }
  118. };
  119. static struct resource tcc8k_ohci1_resources[] = {
  120. [0] = {
  121. .start = (resource_size_t)USBH1_BASE,
  122. .end = (resource_size_t)USBH1_BASE + 0x5c,
  123. .flags = IORESOURCE_MEM,
  124. },
  125. [1] = {
  126. .start = INT_USBH1,
  127. .end = INT_USBH1,
  128. .flags = IORESOURCE_IRQ,
  129. }
  130. };
  131. static struct tccohci_platform_data tcc8k_ohci0_platform_data = {
  132. .controller = 0,
  133. .port_mode = PMM_PERPORT_MODE,
  134. .init = tcc8k_ohci_init,
  135. };
  136. static struct tccohci_platform_data tcc8k_ohci1_platform_data = {
  137. .controller = 1,
  138. .port_mode = PMM_PERPORT_MODE,
  139. .init = tcc8k_ohci_init,
  140. };
  141. static struct platform_device ohci0_device = {
  142. .name = "tcc-ohci",
  143. .id = 0,
  144. .dev = {
  145. .dma_mask = &tcc8k_dmamask,
  146. .coherent_dma_mask = DMA_BIT_MASK(32),
  147. .platform_data = &tcc8k_ohci0_platform_data,
  148. },
  149. .num_resources = ARRAY_SIZE(tcc8k_ohci0_resources),
  150. .resource = tcc8k_ohci0_resources,
  151. };
  152. static struct platform_device ohci1_device = {
  153. .name = "tcc-ohci",
  154. .id = 1,
  155. .dev = {
  156. .dma_mask = &tcc8k_dmamask,
  157. .coherent_dma_mask = DMA_BIT_MASK(32),
  158. .platform_data = &tcc8k_ohci1_platform_data,
  159. },
  160. .num_resources = ARRAY_SIZE(tcc8k_ohci1_resources),
  161. .resource = tcc8k_ohci1_resources,
  162. };
  163. static void __init tcc8k_init_usbhost(void)
  164. {
  165. platform_device_register(&ohci0_device);
  166. platform_device_register(&ohci1_device);
  167. }
  168. #else
  169. static void __init tcc8k_init_usbhost(void) { }
  170. #endif
  171. /* USB device controller*/
  172. #ifdef CONFIG_USB_GADGET_TCC8K
  173. static struct resource udc_resources[] = {
  174. [0] = {
  175. .start = INT_USBD,
  176. .end = INT_USBD,
  177. .flags = IORESOURCE_IRQ,
  178. },
  179. [1] = {
  180. .start = INT_UDMA,
  181. .end = INT_UDMA,
  182. .flags = IORESOURCE_IRQ,
  183. },
  184. };
  185. static struct platform_device tcc8k_udc_device = {
  186. .name = "tcc-udc",
  187. .id = 0,
  188. .resource = udc_resources,
  189. .num_resources = ARRAY_SIZE(udc_resources),
  190. .dev = {
  191. .dma_mask = &tcc8k_dmamask,
  192. .coherent_dma_mask = DMA_BIT_MASK(32),
  193. },
  194. };
  195. static void __init tcc8k_init_usb_gadget(void)
  196. {
  197. platform_device_register(&tcc8k_udc_device);
  198. }
  199. #else
  200. static void __init tcc8k_init_usb_gadget(void) { }
  201. #endif /* CONFIG_USB_GADGET_TCC83X */
  202. static int __init tcc8k_init_devices(void)
  203. {
  204. tcc8k_init_mmc();
  205. tcc8k_init_usbhost();
  206. tcc8k_init_usb_gadget();
  207. return 0;
  208. }
  209. arch_initcall(tcc8k_init_devices);