devices.c 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. /*
  2. * Copyright (C) 2006 Atmel Corporation
  3. *
  4. * See file CREDITS for list of people who contributed to this
  5. * project.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License as
  9. * published by the Free Software Foundation; either version 2 of
  10. * the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  20. * MA 02111-1307 USA
  21. */
  22. #include <common.h>
  23. #include <asm/arch/memory-map.h>
  24. #include <asm/arch/platform.h>
  25. #include "../sm.h"
  26. #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
  27. const struct clock_domain chip_clock[] = {
  28. [CLOCK_CPU] = {
  29. .reg = SM_PM_CPU_MASK,
  30. .id = CLOCK_CPU,
  31. .bridge = NO_DEVICE,
  32. },
  33. [CLOCK_HSB] = {
  34. .reg = SM_PM_HSB_MASK,
  35. .id = CLOCK_HSB,
  36. .bridge = NO_DEVICE,
  37. },
  38. [CLOCK_PBA] = {
  39. .reg = SM_PM_PBA_MASK,
  40. .id = CLOCK_PBA,
  41. .bridge = DEVICE_PBA_BRIDGE,
  42. },
  43. [CLOCK_PBB] = {
  44. .reg = SM_PM_PBB_MASK,
  45. .id = CLOCK_PBB,
  46. .bridge = DEVICE_PBB_BRIDGE,
  47. },
  48. };
  49. static const struct resource hebi_resource[] = {
  50. {
  51. .type = RESOURCE_CLOCK,
  52. .u = {
  53. .clock = { CLOCK_HSB, 0 },
  54. },
  55. }, {
  56. .type = RESOURCE_CLOCK,
  57. .u = {
  58. .clock = { CLOCK_PBB, 13 },
  59. },
  60. }, {
  61. .type = RESOURCE_CLOCK,
  62. .u = {
  63. .clock = { CLOCK_PBB, 14 },
  64. },
  65. }, {
  66. .type = RESOURCE_GPIO,
  67. .u = {
  68. .gpio = { 27, DEVICE_PIOE, GPIO_FUNC_A, 0 },
  69. },
  70. },
  71. };
  72. static const struct resource pba_bridge_resource[] = {
  73. {
  74. .type = RESOURCE_CLOCK,
  75. .u = {
  76. .clock = { CLOCK_HSB, 1 },
  77. }
  78. }, {
  79. .type = RESOURCE_CLOCK,
  80. .u = {
  81. /* HSB-HSB Bridge */
  82. .clock = { CLOCK_HSB, 4 },
  83. },
  84. },
  85. };
  86. static const struct resource pbb_bridge_resource[] = {
  87. {
  88. .type = RESOURCE_CLOCK,
  89. .u = {
  90. .clock = { CLOCK_HSB, 2 },
  91. },
  92. },
  93. };
  94. static const struct resource hramc_resource[] = {
  95. {
  96. .type = RESOURCE_CLOCK,
  97. .u = {
  98. .clock = { CLOCK_HSB, 3 },
  99. },
  100. },
  101. };
  102. static const struct resource pioa_resource[] = {
  103. {
  104. .type = RESOURCE_CLOCK,
  105. .u = {
  106. .clock = { CLOCK_PBA, 10 },
  107. },
  108. },
  109. };
  110. static const struct resource piob_resource[] = {
  111. {
  112. .type = RESOURCE_CLOCK,
  113. .u = {
  114. .clock = { CLOCK_PBA, 11 },
  115. },
  116. },
  117. };
  118. static const struct resource pioc_resource[] = {
  119. {
  120. .type = RESOURCE_CLOCK,
  121. .u = {
  122. .clock = { CLOCK_PBA, 12 },
  123. },
  124. },
  125. };
  126. static const struct resource piod_resource[] = {
  127. {
  128. .type = RESOURCE_CLOCK,
  129. .u = {
  130. .clock = { CLOCK_PBA, 13 },
  131. },
  132. },
  133. };
  134. static const struct resource pioe_resource[] = {
  135. {
  136. .type = RESOURCE_CLOCK,
  137. .u = {
  138. .clock = { CLOCK_PBA, 14 },
  139. },
  140. },
  141. };
  142. static const struct resource sm_resource[] = {
  143. {
  144. .type = RESOURCE_CLOCK,
  145. .u = {
  146. .clock = { CLOCK_PBB, 0 },
  147. },
  148. },
  149. };
  150. static const struct resource intc_resource[] = {
  151. {
  152. .type = RESOURCE_CLOCK,
  153. .u = {
  154. .clock = { CLOCK_PBB, 1 },
  155. },
  156. },
  157. };
  158. static const struct resource hmatrix_resource[] = {
  159. {
  160. .type = RESOURCE_CLOCK,
  161. .u = {
  162. .clock = { CLOCK_PBB, 2 },
  163. },
  164. },
  165. };
  166. #if defined(CFG_HPDC)
  167. static const struct resource hpdc_resource[] = {
  168. {
  169. .type = RESOURCE_CLOCK,
  170. .u = {
  171. .clock = { CLOCK_PBA, 16 },
  172. },
  173. },
  174. };
  175. #endif
  176. #if defined(CFG_MACB0)
  177. static const struct resource macb0_resource[] = {
  178. {
  179. .type = RESOURCE_CLOCK,
  180. .u = {
  181. .clock = { CLOCK_HSB, 8 },
  182. },
  183. }, {
  184. .type = RESOURCE_CLOCK,
  185. .u = {
  186. .clock = { CLOCK_PBB, 6 },
  187. },
  188. }, {
  189. .type = RESOURCE_GPIO,
  190. .u = {
  191. .gpio = { 19, DEVICE_PIOC, GPIO_FUNC_A, 0 },
  192. },
  193. },
  194. };
  195. #endif
  196. #if defined(CFG_MACB1)
  197. static const struct resource macb1_resource[] = {
  198. {
  199. .type = RESOURCE_CLOCK,
  200. .u = {
  201. .clock = { CLOCK_HSB, 9 },
  202. },
  203. }, {
  204. .type = RESOURCE_CLOCK,
  205. .u = {
  206. .clock = { CLOCK_PBB, 7 },
  207. },
  208. }, {
  209. .type = RESOURCE_GPIO,
  210. .u = {
  211. .gpio = { 12, DEVICE_PIOC, GPIO_FUNC_B, 19 },
  212. },
  213. }, {
  214. .type = RESOURCE_GPIO,
  215. .u = {
  216. .gpio = { 14, DEVICE_PIOD, GPIO_FUNC_B, 2 },
  217. },
  218. },
  219. };
  220. #endif
  221. #if defined(CFG_LCDC)
  222. static const struct resource lcdc_resource[] = {
  223. {
  224. .type = RESOURCE_CLOCK,
  225. .u = {
  226. .clock = { CLOCK_HSB, 7 },
  227. },
  228. },
  229. };
  230. #endif
  231. #if defined(CFG_USART0)
  232. static const struct resource usart0_resource[] = {
  233. {
  234. .type = RESOURCE_CLOCK,
  235. .u = {
  236. .clock = { CLOCK_PBA, 3 },
  237. },
  238. }, {
  239. .type = RESOURCE_GPIO,
  240. .u = {
  241. .gpio = { 2, DEVICE_PIOA, GPIO_FUNC_B, 8 },
  242. },
  243. },
  244. };
  245. #endif
  246. #if defined(CFG_USART1)
  247. static const struct resource usart1_resource[] = {
  248. {
  249. .type = RESOURCE_CLOCK,
  250. .u = {
  251. .clock = { CLOCK_PBA, 4 },
  252. },
  253. }, {
  254. .type = RESOURCE_GPIO,
  255. .u = {
  256. .gpio = { 2, DEVICE_PIOA, GPIO_FUNC_A, 17 },
  257. },
  258. },
  259. };
  260. #endif
  261. #if defined(CFG_USART2)
  262. static const struct resource usart2_resource[] = {
  263. {
  264. .type = RESOURCE_CLOCK,
  265. .u = {
  266. .clock = { CLOCK_PBA, 5 },
  267. },
  268. }, {
  269. .type = RESOURCE_GPIO,
  270. .u = {
  271. .gpio = { 2, DEVICE_PIOB, GPIO_FUNC_B, 26 },
  272. },
  273. },
  274. };
  275. #endif
  276. #if defined(CFG_USART3)
  277. static const struct resource usart3_resource[] = {
  278. {
  279. .type = RESOURCE_CLOCK,
  280. .u = {
  281. .clock = { CLOCK_PBA, 6 },
  282. },
  283. }, {
  284. .type = RESOURCE_GPIO,
  285. .u = {
  286. .gpio = { 2, DEVICE_PIOB, GPIO_FUNC_B, 17 },
  287. },
  288. },
  289. };
  290. #endif
  291. #if defined(CFG_MMCI)
  292. static const struct resource mmci_resource[] = {
  293. {
  294. .type = RESOURCE_CLOCK,
  295. .u = {
  296. .clock = { CLOCK_PBB, 9 },
  297. },
  298. }, {
  299. .type = RESOURCE_GPIO,
  300. .u = {
  301. .gpio = { 6, DEVICE_PIOA, GPIO_FUNC_A, 10 },
  302. },
  303. },
  304. };
  305. #endif
  306. #if defined(CFG_DMAC)
  307. static const struct resource dmac_resource[] = {
  308. {
  309. .type = RESOURCE_CLOCK,
  310. .u = {
  311. .clock = { CLOCK_HSB, 10 },
  312. },
  313. },
  314. };
  315. #endif
  316. const struct device chip_device[] = {
  317. [DEVICE_HEBI] = {
  318. .regs = (void *)HSMC_BASE,
  319. .nr_resources = ARRAY_SIZE(hebi_resource),
  320. .resource = hebi_resource,
  321. },
  322. [DEVICE_PBA_BRIDGE] = {
  323. .nr_resources = ARRAY_SIZE(pba_bridge_resource),
  324. .resource = pba_bridge_resource,
  325. },
  326. [DEVICE_PBB_BRIDGE] = {
  327. .nr_resources = ARRAY_SIZE(pbb_bridge_resource),
  328. .resource = pbb_bridge_resource,
  329. },
  330. [DEVICE_HRAMC] = {
  331. .nr_resources = ARRAY_SIZE(hramc_resource),
  332. .resource = hramc_resource,
  333. },
  334. [DEVICE_PIOA] = {
  335. .regs = (void *)PIOA_BASE,
  336. .nr_resources = ARRAY_SIZE(pioa_resource),
  337. .resource = pioa_resource,
  338. },
  339. [DEVICE_PIOB] = {
  340. .regs = (void *)PIOB_BASE,
  341. .nr_resources = ARRAY_SIZE(piob_resource),
  342. .resource = piob_resource,
  343. },
  344. [DEVICE_PIOC] = {
  345. .regs = (void *)PIOC_BASE,
  346. .nr_resources = ARRAY_SIZE(pioc_resource),
  347. .resource = pioc_resource,
  348. },
  349. [DEVICE_PIOD] = {
  350. .regs = (void *)PIOD_BASE,
  351. .nr_resources = ARRAY_SIZE(piod_resource),
  352. .resource = piod_resource,
  353. },
  354. [DEVICE_PIOE] = {
  355. .regs = (void *)PIOE_BASE,
  356. .nr_resources = ARRAY_SIZE(pioe_resource),
  357. .resource = pioe_resource,
  358. },
  359. [DEVICE_SM] = {
  360. .regs = (void *)SM_BASE,
  361. .nr_resources = ARRAY_SIZE(sm_resource),
  362. .resource = sm_resource,
  363. },
  364. [DEVICE_INTC] = {
  365. .regs = (void *)INTC_BASE,
  366. .nr_resources = ARRAY_SIZE(intc_resource),
  367. .resource = intc_resource,
  368. },
  369. [DEVICE_HMATRIX] = {
  370. .regs = (void *)HMATRIX_BASE,
  371. .nr_resources = ARRAY_SIZE(hmatrix_resource),
  372. .resource = hmatrix_resource,
  373. },
  374. #if defined(CFG_HPDC)
  375. [DEVICE_HPDC] = {
  376. .nr_resources = ARRAY_SIZE(hpdc_resource),
  377. .resource = hpdc_resource,
  378. },
  379. #endif
  380. #if defined(CFG_MACB0)
  381. [DEVICE_MACB0] = {
  382. .regs = (void *)MACB0_BASE,
  383. .nr_resources = ARRAY_SIZE(macb0_resource),
  384. .resource = macb0_resource,
  385. },
  386. #endif
  387. #if defined(CFG_MACB1)
  388. [DEVICE_MACB1] = {
  389. .regs = (void *)MACB1_BASE,
  390. .nr_resources = ARRAY_SIZE(macb1_resource),
  391. .resource = macb1_resource,
  392. },
  393. #endif
  394. #if defined(CFG_LCDC)
  395. [DEVICE_LCDC] = {
  396. .nr_resources = ARRAY_SIZE(lcdc_resource),
  397. .resource = lcdc_resource,
  398. },
  399. #endif
  400. #if defined(CFG_USART0)
  401. [DEVICE_USART0] = {
  402. .regs = (void *)USART0_BASE,
  403. .nr_resources = ARRAY_SIZE(usart0_resource),
  404. .resource = usart0_resource,
  405. },
  406. #endif
  407. #if defined(CFG_USART1)
  408. [DEVICE_USART1] = {
  409. .regs = (void *)USART1_BASE,
  410. .nr_resources = ARRAY_SIZE(usart1_resource),
  411. .resource = usart1_resource,
  412. },
  413. #endif
  414. #if defined(CFG_USART2)
  415. [DEVICE_USART2] = {
  416. .regs = (void *)USART2_BASE,
  417. .nr_resources = ARRAY_SIZE(usart2_resource),
  418. .resource = usart2_resource,
  419. },
  420. #endif
  421. #if defined(CFG_USART3)
  422. [DEVICE_USART3] = {
  423. .regs = (void *)USART3_BASE,
  424. .nr_resources = ARRAY_SIZE(usart3_resource),
  425. .resource = usart3_resource,
  426. },
  427. #endif
  428. #if defined(CFG_MMCI)
  429. [DEVICE_MMCI] = {
  430. .regs = (void *)MMCI_BASE,
  431. .nr_resources = ARRAY_SIZE(mmci_resource),
  432. .resource = mmci_resource,
  433. },
  434. #endif
  435. #if defined(CFG_DMAC)
  436. [DEVICE_DMAC] = {
  437. .regs = (void *)DMAC_BASE,
  438. .nr_resources = ARRAY_SIZE(dmac_resource),
  439. .resource = dmac_resource,
  440. },
  441. #endif
  442. };