alarmDataOperation.c 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. /*
  2. * On-Chip devices setup code for the AT91SAM9G45 family
  3. *
  4. * Copyright (C) 2009 Atmel Corporation.
  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 as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. */
  12. #include <asm/mach/arch.h>
  13. #include <asm/mach/map.h>
  14. #include <linux/dma-mapping.h>
  15. #include <linux/gpio.h>
  16. #include <linux/clk.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/i2c-gpio.h>
  19. #include <linux/atmel-mci.h>
  20. #include <linux/platform_data/atmel-aes.h>
  21. #include <linux/platform_data/at91_adc.h>
  22. #include <linux/fb.h>
  23. #include <video/atmel_lcdc.h>
  24. #include <mach/at91_adc.h>
  25. #include <mach/at91sam9g45.h>
  26. #include <mach/at91sam9g45_matrix.h>
  27. #include <mach/at91_matrix.h>
  28. #include <mach/at91sam9_smc.h>
  29. #include <linux/platform_data/dma-atmel.h>
  30. #include <mach/atmel-mci.h>
  31. #include <media/atmel-isi.h>
  32. #include "board.h"
  33. #include "generic.h"
  34. #include "clock.h"
  35. /* --------------------------------------------------------------------
  36. * HDMAC - AHB DMA Controller
  37. * -------------------------------------------------------------------- */
  38. #if defined(CONFIG_AT_HDMAC) || defined(CONFIG_AT_HDMAC_MODULE)
  39. static u64 hdmac_dmamask = DMA_BIT_MASK(32);
  40. static struct resource hdmac_resources[] = {
  41. [0] = {
  42. .start = AT91SAM9G45_BASE_DMA,
  43. .end = AT91SAM9G45_BASE_DMA + SZ_512 - 1,
  44. .flags = IORESOURCE_MEM,
  45. },
  46. [1] = {
  47. .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_DMA,
  48. .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_DMA,
  49. .flags = IORESOURCE_IRQ,
  50. },
  51. };
  52. static struct platform_device at_hdmac_device = {
  53. .name = "at91sam9g45_dma",
  54. .id = -1,
  55. .dev = {
  56. .dma_mask = &hdmac_dmamask,
  57. .coherent_dma_mask = DMA_BIT_MASK(32),
  58. },
  59. .resource = hdmac_resources,
  60. .num_resources = ARRAY_SIZE(hdmac_resources),
  61. };
  62. void __init at91_add_device_hdmac(void)
  63. {
  64. platform_device_register(&at_hdmac_device);
  65. }
  66. #else
  67. void __init at91_add_device_hdmac(void) {}
  68. #endif
  69. /* --------------------------------------------------------------------
  70. * USB Host (OHCI)
  71. * -------------------------------------------------------------------- */
  72. #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
  73. static u64 ohci_dmamask = DMA_BIT_MASK(32);
  74. static struct at91_usbh_data usbh_ohci_data;
  75. static struct resource usbh_ohci_resources[] = {
  76. [0] = {
  77. .start = AT91SAM9G45_OHCI_BASE,
  78. .end = AT91SAM9G45_OHCI_BASE + SZ_1M - 1,
  79. .flags = IORESOURCE_MEM,
  80. },
  81. [1] = {
  82. .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_UHPHS,
  83. .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_UHPHS,
  84. .flags = IORESOURCE_IRQ,
  85. },
  86. };
  87. static struct platform_device at91_usbh_ohci_device = {
  88. .name = "at91_ohci",
  89. .id = -1,
  90. .dev = {
  91. .dma_mask = &ohci_dmamask,
  92. .coherent_dma_mask = DMA_BIT_MASK(32),
  93. .platform_data = &usbh_ohci_data,
  94. },
  95. .resource = usbh_ohci_resources,
  96. .num_resources = ARRAY_SIZE(usbh_ohci_resources),
  97. };
  98. void __init at91_add_device_usbh_ohci(struct at91_usbh_data *data)
  99. {
  100. int i;
  101. if (!data)
  102. return;
  103. /* Enable VBus control for UHP ports */
  104. for (i = 0; i < data->ports; i++) {
  105. if (gpio_is_valid(data->vbus_pin[i]))
  106. at91_set_gpio_output(data->vbus_pin[i],
  107. data->vbus_pin_active_low[i]);
  108. }
  109. /* Enable overcurrent notification */
  110. for (i = 0; i < data->ports; i++) {
  111. if (gpio_is_valid(data->overcurrent_pin[i]))
  112. at91_set_gpio_input(data->overcurrent_pin[i], 1);
  113. }
  114. usbh_ohci_data = *data;
  115. platform_device_register(&at91_usbh_ohci_device);
  116. }
  117. #else
  118. void __init at91_add_device_usbh_ohci(struct at91_usbh_data *data) {}
  119. #endif
  120. /* --------------------------------------------------------------------
  121. * USB Host HS (EHCI)
  122. * Needs an OHCI host for low and full speed management
  123. * -------------------------------------------------------------------- */
  124. #if defined(CONFIG_USB_EHCI_HCD) || defined(CONFIG_USB_EHCI_HCD_MODULE)
  125. static u64 ehci_dmamask = DMA_BIT_MASK(32);
  126. static struct at91_usbh_data usbh_ehci_data;
  127. static struct resource usbh_ehci_resources[] = {
  128. [0] = {
  129. .start = AT91SAM9G45_EHCI_BASE,
  130. .end = AT91SAM9G45_EHCI_BASE + SZ_1M - 1,
  131. .flags = IORESOURCE_MEM,
  132. },
  133. [1] = {
  134. .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_UHPHS,
  135. .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_UHPHS,
  136. .flags = IORESOURCE_IRQ,
  137. },
  138. };
  139. static struct platform_device at91_usbh_ehci_device = {
  140. .name = "atmel-ehci",
  141. .id = -1,
  142. .dev = {
  143. .dma_mask = &ehci_dmamask,
  144. .coherent_dma_mask = DMA_BIT_MASK(32),
  145. .platform_data = &usbh_ehci_data,
  146. },
  147. .resource = usbh_ehci_resources,
  148. .num_resources = ARRAY_SIZE(usbh_ehci_resources),
  149. };
  150. void __init at91_add_device_usbh_ehci(struct at91_usbh_data *data)
  151. {
  152. int i;
  153. if (!data)
  154. return;
  155. /* Enable VBus control for UHP ports */
  156. for (i = 0; i < data->ports; i++) {
  157. if (gpio_is_valid(data->vbus_pin[i]))
  158. at91_set_gpio_output(data->vbus_pin[i],
  159. data->vbus_pin_active_low[i]);
  160. }
  161. usbh_ehci_data = *data;
  162. platform_device_register(&at91_usbh_ehci_device);
  163. }
  164. #else
  165. void __init at91_add_device_usbh_ehci(struct at91_usbh_data *data) {}
  166. #endif
  167. /* --------------------------------------------------------------------
  168. * USB HS Device (Gadget)
  169. * -------------------------------------------------------------------- */
  170. #if defined(CONFIG_USB_ATMEL_USBA) || defined(CONFIG_USB_ATMEL_USBA_MODULE)
  171. static struct resource usba_udc_resources[] = {
  172. [0] = {
  173. .start = AT91SAM9G45_UDPHS_FIFO,
  174. .end = AT91SAM9G45_UDPHS_FIFO + SZ_512K - 1,
  175. .flags = IORESOURCE_MEM,
  176. },
  177. [1] = {
  178. .start = AT91SAM9G45_BASE_UDPHS,
  179. .end = AT91SAM9G45_BASE_UDPHS + SZ_1K - 1,
  180. .flags = IORESOURCE_MEM,
  181. },
  182. [2] = {
  183. .start = NR_IRQS_LEGACY + AT91SAM9G45_ID_UDPHS,
  184. .end = NR_IRQS_LEGACY + AT91SAM9G45_ID_UDPHS,
  185. .flags = IORESOURCE_IRQ,
  186. },
  187. };
  188. #define EP(nam, idx, maxpkt, maxbk, dma, isoc) \
  189. [idx] = { \
  190. .name = nam, \
  191. .index = idx, \
  192. .fifo_size = maxpkt, \
  193. .nr_banks = maxbk, \
  194. .can_dma = dma, \
  195. .can_isoc = isoc, \
  196. }
  197. static struct usba_ep_data usba_udc_ep[] __initdata = {
  198. EP("ep0", 0, 64, 1, 0, 0),
  199. EP("ep1", 1, 1024, 2, 1, 1),
  200. EP("ep2", 2, 1024, 2, 1, 1),
  201. EP("ep3", 3, 1024, 3, 1, 0),
  202. EP("ep4", 4, 1024, 3, 1, 0),
  203. EP("ep5", 5, 1024, 3, 1, 1),
  204. EP("ep6", 6, 1024, 3, 1, 1),
  205. };
  206. #undef EP
  207. /*
  208. * pdata doesn't have room for any endpoints, so we need to
  209. * append room for the ones we need right after it.
  210. */
  211. static struct {
  212. struct usba_platform_data pdata;
  213. struct usba_ep_data ep[7];
  214. } usba_udc_data;
  215. static struct platform_device at91_usba_udc_device = {
  216. .name = "atmel_usba_udc",
  217. .id = -1,
  218. .dev = {
  219. .platform_data = &usba_udc_data.pdata,
  220. },
  221. .resource = usba_udc_resources,
  222. .num_resources = ARRAY_SIZE(usba_udc_resources),
  223. };
  224. void __init at91_add_device_usba(struct usba_platform_data *data)
  225. {
  226. usba_udc_data.pdata.vbus_pin = -EINVAL;
  227. usba_udc_data.pdata.num_ep = ARRAY_SIZE(usba_udc_ep);
  228. memcpy(usba_udc_data.ep, usba_udc_ep, sizeof(usba_udc_ep));
  229. if (data && gpio_is_valid(data->vbus_pin)) {
  230. at91_set_gpio_input(data->vbus_pin, 0);
  231. at91_set_deglitch(data->vbus_pin, 1);
  232. usba_udc_data.pdata.vbus_pin = data->vbus_pin;
  233. }
  234. /* Pullup pin is handled internally by USB device peripheral */
  235. platform_device_register(&at91_usba_udc_device);
  236. }
  237. #else
  238. void __init at91_add_device_usba(struct usba_platform_data *data) {}
  239. #endif
  240. /* --------------------------------------------------------------------
  241. * Ethernet
  242. * -------------------------------------------------------------------- */
  243. #if defined(CONFIG_MACB) || defined(CONFIG_MACB_MODULE)