tegra30.c 25 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (C) 2014 NVIDIA CORPORATION. All rights reserved.
  4. */
  5. #include <linux/of.h>
  6. #include <linux/of_device.h>
  7. #include <linux/slab.h>
  8. #include <dt-bindings/memory/tegra30-mc.h>
  9. #include "mc.h"
  10. static const unsigned long tegra30_mc_emem_regs[] = {
  11. MC_EMEM_ARB_CFG,
  12. MC_EMEM_ARB_OUTSTANDING_REQ,
  13. MC_EMEM_ARB_TIMING_RCD,
  14. MC_EMEM_ARB_TIMING_RP,
  15. MC_EMEM_ARB_TIMING_RC,
  16. MC_EMEM_ARB_TIMING_RAS,
  17. MC_EMEM_ARB_TIMING_FAW,
  18. MC_EMEM_ARB_TIMING_RRD,
  19. MC_EMEM_ARB_TIMING_RAP2PRE,
  20. MC_EMEM_ARB_TIMING_WAP2PRE,
  21. MC_EMEM_ARB_TIMING_R2R,
  22. MC_EMEM_ARB_TIMING_W2W,
  23. MC_EMEM_ARB_TIMING_R2W,
  24. MC_EMEM_ARB_TIMING_W2R,
  25. MC_EMEM_ARB_DA_TURNS,
  26. MC_EMEM_ARB_DA_COVERS,
  27. MC_EMEM_ARB_MISC0,
  28. MC_EMEM_ARB_RING1_THROTTLE,
  29. };
  30. static const struct tegra_mc_client tegra30_mc_clients[] = {
  31. {
  32. .id = 0x00,
  33. .name = "ptcr",
  34. .swgroup = TEGRA_SWGROUP_PTC,
  35. .regs = {
  36. .la = {
  37. .reg = 0x34c,
  38. .shift = 0,
  39. .mask = 0xff,
  40. .def = 0x0,
  41. },
  42. },
  43. .fifo_size = 16 * 2,
  44. }, {
  45. .id = 0x01,
  46. .name = "display0a",
  47. .swgroup = TEGRA_SWGROUP_DC,
  48. .regs = {
  49. .smmu = {
  50. .reg = 0x228,
  51. .bit = 1,
  52. },
  53. .la = {
  54. .reg = 0x2e8,
  55. .shift = 0,
  56. .mask = 0xff,
  57. .def = 0x4e,
  58. },
  59. },
  60. .fifo_size = 16 * 128,
  61. }, {
  62. .id = 0x02,
  63. .name = "display0ab",
  64. .swgroup = TEGRA_SWGROUP_DCB,
  65. .regs = {
  66. .smmu = {
  67. .reg = 0x228,
  68. .bit = 2,
  69. },
  70. .la = {
  71. .reg = 0x2f4,
  72. .shift = 0,
  73. .mask = 0xff,
  74. .def = 0x4e,
  75. },
  76. },
  77. .fifo_size = 16 * 128,
  78. }, {
  79. .id = 0x03,
  80. .name = "display0b",
  81. .swgroup = TEGRA_SWGROUP_DC,
  82. .regs = {
  83. .smmu = {
  84. .reg = 0x228,
  85. .bit = 3,
  86. },
  87. .la = {
  88. .reg = 0x2e8,
  89. .shift = 16,
  90. .mask = 0xff,
  91. .def = 0x4e,
  92. },
  93. },
  94. .fifo_size = 16 * 64,
  95. }, {
  96. .id = 0x04,
  97. .name = "display0bb",
  98. .swgroup = TEGRA_SWGROUP_DCB,
  99. .regs = {
  100. .smmu = {
  101. .reg = 0x228,
  102. .bit = 4,
  103. },
  104. .la = {
  105. .reg = 0x2f4,
  106. .shift = 16,
  107. .mask = 0xff,
  108. .def = 0x4e,
  109. },
  110. },
  111. .fifo_size = 16 * 64,
  112. }, {
  113. .id = 0x05,
  114. .name = "display0c",
  115. .swgroup = TEGRA_SWGROUP_DC,
  116. .regs = {
  117. .smmu = {
  118. .reg = 0x228,
  119. .bit = 5,
  120. },
  121. .la = {
  122. .reg = 0x2ec,
  123. .shift = 0,
  124. .mask = 0xff,
  125. .def = 0x4e,
  126. },
  127. },
  128. .fifo_size = 16 * 128,
  129. }, {
  130. .id = 0x06,
  131. .name = "display0cb",
  132. .swgroup = TEGRA_SWGROUP_DCB,
  133. .regs = {
  134. .smmu = {
  135. .reg = 0x228,
  136. .bit = 6,
  137. },
  138. .la = {
  139. .reg = 0x2f8,
  140. .shift = 0,
  141. .mask = 0xff,
  142. .def = 0x4e,
  143. },
  144. },
  145. .fifo_size = 16 * 128,
  146. }, {
  147. .id = 0x07,
  148. .name = "display1b",
  149. .swgroup = TEGRA_SWGROUP_DC,
  150. .regs = {
  151. .smmu = {
  152. .reg = 0x228,
  153. .bit = 7,
  154. },
  155. .la = {
  156. .reg = 0x2ec,
  157. .shift = 16,
  158. .mask = 0xff,
  159. .def = 0x4e,
  160. },
  161. },
  162. .fifo_size = 16 * 64,
  163. }, {
  164. .id = 0x08,
  165. .name = "display1bb",
  166. .swgroup = TEGRA_SWGROUP_DCB,
  167. .regs = {
  168. .smmu = {
  169. .reg = 0x228,
  170. .bit = 8,
  171. },
  172. .la = {
  173. .reg = 0x2f8,
  174. .shift = 16,
  175. .mask = 0xff,
  176. .def = 0x4e,
  177. },
  178. },
  179. .fifo_size = 16 * 64,
  180. }, {
  181. .id = 0x09,
  182. .name = "eppup",
  183. .swgroup = TEGRA_SWGROUP_EPP,
  184. .regs = {
  185. .smmu = {
  186. .reg = 0x228,
  187. .bit = 9,
  188. },
  189. .la = {
  190. .reg = 0x300,
  191. .shift = 0,
  192. .mask = 0xff,
  193. .def = 0x17,
  194. },
  195. },
  196. .fifo_size = 16 * 8,
  197. }, {
  198. .id = 0x0a,
  199. .name = "g2pr",
  200. .swgroup = TEGRA_SWGROUP_G2,
  201. .regs = {
  202. .smmu = {
  203. .reg = 0x228,
  204. .bit = 10,
  205. },
  206. .la = {
  207. .reg = 0x308,
  208. .shift = 0,
  209. .mask = 0xff,
  210. .def = 0x09,
  211. },
  212. },
  213. .fifo_size = 16 * 64,
  214. }, {
  215. .id = 0x0b,
  216. .name = "g2sr",
  217. .swgroup = TEGRA_SWGROUP_G2,
  218. .regs = {
  219. .smmu = {
  220. .reg = 0x228,
  221. .bit = 11,
  222. },
  223. .la = {
  224. .reg = 0x308,
  225. .shift = 16,
  226. .mask = 0xff,
  227. .def = 0x09,
  228. },
  229. },
  230. .fifo_size = 16 * 64,
  231. }, {
  232. .id = 0x0c,
  233. .name = "mpeunifbr",
  234. .swgroup = TEGRA_SWGROUP_MPE,
  235. .regs = {
  236. .smmu = {
  237. .reg = 0x228,
  238. .bit = 12,
  239. },
  240. .la = {
  241. .reg = 0x328,
  242. .shift = 0,
  243. .mask = 0xff,
  244. .def = 0x50,
  245. },
  246. },
  247. .fifo_size = 16 * 8,
  248. }, {
  249. .id = 0x0d,
  250. .name = "viruv",
  251. .swgroup = TEGRA_SWGROUP_VI,
  252. .regs = {
  253. .smmu = {
  254. .reg = 0x228,
  255. .bit = 13,
  256. },
  257. .la = {
  258. .reg = 0x364,
  259. .shift = 0,
  260. .mask = 0xff,
  261. .def = 0x2c,
  262. },
  263. },
  264. .fifo_size = 16 * 8,
  265. }, {
  266. .id = 0x0e,
  267. .name = "afir",
  268. .swgroup = TEGRA_SWGROUP_AFI,
  269. .regs = {
  270. .smmu = {
  271. .reg = 0x228,
  272. .bit = 14,
  273. },
  274. .la = {
  275. .reg = 0x2e0,
  276. .shift = 0,
  277. .mask = 0xff,
  278. .def = 0x10,
  279. },
  280. },
  281. .fifo_size = 16 * 32,
  282. }, {
  283. .id = 0x0f,
  284. .name = "avpcarm7r",
  285. .swgroup = TEGRA_SWGROUP_AVPC,
  286. .regs = {
  287. .smmu = {
  288. .reg = 0x228,
  289. .bit = 15,
  290. },
  291. .la = {
  292. .reg = 0x2e4,
  293. .shift = 0,
  294. .mask = 0xff,
  295. .def = 0x04,
  296. },
  297. },
  298. .fifo_size = 16 * 2,
  299. }, {
  300. .id = 0x10,
  301. .name = "displayhc",
  302. .swgroup = TEGRA_SWGROUP_DC,
  303. .regs = {
  304. .smmu = {
  305. .reg = 0x228,
  306. .bit = 16,
  307. },
  308. .la = {
  309. .reg = 0x2f0,
  310. .shift = 0,
  311. .mask = 0xff,
  312. .def = 0xff,
  313. },
  314. },
  315. .fifo_size = 16 * 2,
  316. }, {
  317. .id = 0x11,
  318. .name = "displayhcb",
  319. .swgroup = TEGRA_SWGROUP_DCB,
  320. .regs = {
  321. .smmu = {
  322. .reg = 0x228,
  323. .bit = 17,
  324. },
  325. .la = {
  326. .reg = 0x2fc,
  327. .shift = 0,
  328. .mask = 0xff,
  329. .def = 0xff,
  330. },
  331. },
  332. .fifo_size = 16 * 2,
  333. }, {
  334. .id = 0x12,
  335. .name = "fdcdrd",
  336. .swgroup = TEGRA_SWGROUP_NV,
  337. .regs = {
  338. .smmu = {
  339. .reg = 0x228,
  340. .bit = 18,
  341. },
  342. .la = {
  343. .reg = 0x334,
  344. .shift = 0,
  345. .mask = 0xff,
  346. .def = 0x0a,
  347. },
  348. },
  349. .fifo_size = 16 * 48,
  350. }, {
  351. .id = 0x13,
  352. .name = "fdcdrd2",
  353. .swgroup = TEGRA_SWGROUP_NV2,
  354. .regs = {
  355. .smmu = {
  356. .reg = 0x228,
  357. .bit = 19,
  358. },
  359. .la = {
  360. .reg = 0x33c,
  361. .shift = 0,
  362. .mask = 0xff,
  363. .def = 0x0a,
  364. },
  365. },
  366. .fifo_size = 16 * 48,
  367. }, {
  368. .id = 0x14,
  369. .name = "g2dr",
  370. .swgroup = TEGRA_SWGROUP_G2,
  371. .regs = {
  372. .smmu = {
  373. .reg = 0x228,
  374. .bit = 20,
  375. },
  376. .la = {
  377. .reg = 0x30c,
  378. .shift = 0,
  379. .mask = 0xff,
  380. .def = 0x0a,
  381. },
  382. },
  383. .fifo_size = 16 * 48,
  384. }, {
  385. .id = 0x15,
  386. .name = "hdar",
  387. .swgroup = TEGRA_SWGROUP_HDA,
  388. .regs = {
  389. .smmu = {
  390. .reg = 0x228,
  391. .bit = 21,
  392. },
  393. .la = {
  394. .reg = 0x318,
  395. .shift = 0,
  396. .mask = 0xff,
  397. .def = 0xff,
  398. },
  399. },
  400. .fifo_size = 16 * 16,
  401. }, {
  402. .id = 0x16,
  403. .name = "host1xdmar",
  404. .swgroup = TEGRA_SWGROUP_HC,
  405. .regs = {
  406. .smmu = {
  407. .reg = 0x228,
  408. .bit = 22,
  409. },
  410. .la = {
  411. .reg = 0x310,
  412. .shift = 0,
  413. .mask = 0xff,
  414. .def = 0x05,
  415. },
  416. },
  417. .fifo_size = 16 * 16,
  418. }, {
  419. .id = 0x17,
  420. .name = "host1xr",
  421. .swgroup = TEGRA_SWGROUP_HC,
  422. .regs = {
  423. .smmu = {
  424. .reg = 0x228,
  425. .bit = 23,
  426. },
  427. .la = {
  428. .reg = 0x310,
  429. .shift = 16,
  430. .mask = 0xff,
  431. .def = 0x50,
  432. },
  433. },
  434. .fifo_size = 16 * 8,
  435. }, {
  436. .id = 0x18,
  437. .name = "idxsrd",
  438. .swgroup = TEGRA_SWGROUP_NV,
  439. .regs = {
  440. .smmu = {
  441. .reg = 0x228,
  442. .bit = 24,
  443. },
  444. .la = {
  445. .reg = 0x334,
  446. .shift = 16,
  447. .mask = 0xff,
  448. .def = 0x13,
  449. },
  450. },
  451. .fifo_size = 16 * 64,
  452. }, {
  453. .id = 0x19,
  454. .name = "idxsrd2",
  455. .swgroup = TEGRA_SWGROUP_NV2,
  456. .regs = {
  457. .smmu = {
  458. .reg = 0x228,
  459. .bit = 25,
  460. },
  461. .la = {
  462. .reg = 0x33c,
  463. .shift = 16,
  464. .mask = 0xff,
  465. .def = 0x13,
  466. },
  467. },
  468. .fifo_size = 16 * 64,
  469. }, {
  470. .id = 0x1a,
  471. .name = "mpe_ipred",
  472. .swgroup = TEGRA_SWGROUP_MPE,
  473. .regs = {
  474. .smmu = {
  475. .reg = 0x228,
  476. .bit = 26,
  477. },
  478. .la = {
  479. .reg = 0x328,
  480. .shift = 16,
  481. .mask = 0xff,
  482. .def = 0x80,
  483. },
  484. },
  485. .fifo_size = 16 * 2,
  486. }, {
  487. .id = 0x1b,
  488. .name = "mpeamemrd",
  489. .swgroup = TEGRA_SWGROUP_MPE,
  490. .regs = {
  491. .smmu = {
  492. .reg = 0x228,
  493. .bit = 27,
  494. },
  495. .la = {
  496. .reg = 0x32c,
  497. .shift = 0,
  498. .mask = 0xff,
  499. .def = 0x42,
  500. },
  501. },
  502. .fifo_size = 16 * 64,
  503. }, {
  504. .id = 0x1c,
  505. .name = "mpecsrd",
  506. .swgroup = TEGRA_SWGROUP_MPE,
  507. .regs = {
  508. .smmu = {
  509. .reg = 0x228,
  510. .bit = 28,
  511. },
  512. .la = {
  513. .reg = 0x32c,
  514. .shift = 16,
  515. .mask = 0xff,
  516. .def = 0xff,
  517. },
  518. },
  519. .fifo_size = 16 * 8,
  520. }, {
  521. .id = 0x1d,
  522. .name = "ppcsahbdmar",
  523. .swgroup = TEGRA_SWGROUP_PPCS,
  524. .regs = {
  525. .smmu = {
  526. .reg = 0x228,
  527. .bit = 29,
  528. },
  529. .la = {
  530. .reg = 0x344,
  531. .shift = 0,
  532. .mask = 0xff,
  533. .def = 0x10,
  534. },
  535. },
  536. .fifo_size = 16 * 2,
  537. }, {
  538. .id = 0x1e,
  539. .name = "ppcsahbslvr",
  540. .swgroup = TEGRA_SWGROUP_PPCS,
  541. .regs = {
  542. .smmu = {
  543. .reg = 0x228,
  544. .bit = 30,
  545. },
  546. .la = {
  547. .reg = 0x344,
  548. .shift = 16,
  549. .mask = 0xff,
  550. .def = 0x12,
  551. },
  552. },
  553. .fifo_size = 16 * 8,
  554. }, {
  555. .id = 0x1f,
  556. .name = "satar",
  557. .swgroup = TEGRA_SWGROUP_SATA,
  558. .regs = {
  559. .smmu = {
  560. .reg = 0x228,
  561. .bit = 31,
  562. },
  563. .la = {
  564. .reg = 0x350,
  565. .shift = 0,
  566. .mask = 0xff,
  567. .def = 0x33,
  568. },
  569. },
  570. .fifo_size = 16 * 32,
  571. }, {
  572. .id = 0x20,
  573. .name = "texsrd",
  574. .swgroup = TEGRA_SWGROUP_NV,
  575. .regs = {
  576. .smmu = {
  577. .reg = 0x22c,
  578. .bit = 0,
  579. },
  580. .la = {
  581. .reg = 0x338,
  582. .shift = 0,
  583. .mask = 0xff,
  584. .def = 0x13,
  585. },
  586. },
  587. .fifo_size = 16 * 64,
  588. }, {
  589. .id = 0x21,
  590. .name = "texsrd2",
  591. .swgroup = TEGRA_SWGROUP_NV2,
  592. .regs = {
  593. .smmu = {
  594. .reg = 0x22c,
  595. .bit = 1,
  596. },
  597. .la = {
  598. .reg = 0x340,
  599. .shift = 0,
  600. .mask = 0xff,
  601. .def = 0x13,
  602. },
  603. },
  604. .fifo_size = 16 * 64,
  605. }, {
  606. .id = 0x22,
  607. .name = "vdebsevr",
  608. .swgroup = TEGRA_SWGROUP_VDE,
  609. .regs = {
  610. .smmu = {
  611. .reg = 0x22c,
  612. .bit = 2,
  613. },
  614. .la = {
  615. .reg = 0x354,
  616. .shift = 0,
  617. .mask = 0xff,
  618. .def = 0xff,
  619. },
  620. },
  621. .fifo_size = 16 * 8,
  622. }, {
  623. .id = 0x23,
  624. .name = "vdember",
  625. .swgroup = TEGRA_SWGROUP_VDE,
  626. .regs = {
  627. .smmu = {
  628. .reg = 0x22c,
  629. .bit = 3,
  630. },
  631. .la = {
  632. .reg = 0x354,
  633. .shift = 16,
  634. .mask = 0xff,
  635. .def = 0xd0,
  636. },
  637. },
  638. .fifo_size = 16 * 4,
  639. }, {
  640. .id = 0x24,
  641. .name = "vdemcer",
  642. .swgroup = TEGRA_SWGROUP_VDE,
  643. .regs = {
  644. .smmu = {
  645. .reg = 0x22c,
  646. .bit = 4,
  647. },
  648. .la = {
  649. .reg = 0x358,
  650. .shift = 0,
  651. .mask = 0xff,
  652. .def = 0x2a,
  653. },
  654. },
  655. .fifo_size = 16 * 16,
  656. }, {
  657. .id = 0x25,
  658. .name = "vdetper",
  659. .swgroup = TEGRA_SWGROUP_VDE,
  660. .regs = {
  661. .smmu = {
  662. .reg = 0x22c,
  663. .bit = 5,
  664. },
  665. .la = {
  666. .reg = 0x358,
  667. .shift = 16,
  668. .mask = 0xff,
  669. .def = 0x74,
  670. },
  671. },
  672. .fifo_size = 16 * 16,
  673. }, {
  674. .id = 0x26,
  675. .name = "mpcorelpr",
  676. .swgroup = TEGRA_SWGROUP_MPCORELP,
  677. .regs = {
  678. .la = {
  679. .reg = 0x324,
  680. .shift = 0,
  681. .mask = 0xff,
  682. .def = 0x04,
  683. },
  684. },
  685. .fifo_size = 16 * 14,
  686. }, {
  687. .id = 0x27,
  688. .name = "mpcorer",
  689. .swgroup = TEGRA_SWGROUP_MPCORE,
  690. .regs = {
  691. .la = {
  692. .reg = 0x320,
  693. .shift = 0,
  694. .mask = 0xff,
  695. .def = 0x04,
  696. },
  697. },
  698. .fifo_size = 16 * 14,
  699. }, {
  700. .id = 0x28,
  701. .name = "eppu",
  702. .swgroup = TEGRA_SWGROUP_EPP,
  703. .regs = {
  704. .smmu = {
  705. .reg = 0x22c,
  706. .bit = 8,
  707. },
  708. .la = {
  709. .reg = 0x300,
  710. .shift = 16,
  711. .mask = 0xff,
  712. .def = 0x6c,
  713. },
  714. },
  715. .fifo_size = 16 * 64,
  716. }, {
  717. .id = 0x29,
  718. .name = "eppv",
  719. .swgroup = TEGRA_SWGROUP_EPP,
  720. .regs = {
  721. .smmu = {
  722. .reg = 0x22c,
  723. .bit = 9,
  724. },
  725. .la = {
  726. .reg = 0x304,
  727. .shift = 0,
  728. .mask = 0xff,
  729. .def = 0x6c,
  730. },
  731. },
  732. .fifo_size = 16 * 64,
  733. }, {
  734. .id = 0x2a,
  735. .name = "eppy",
  736. .swgroup = TEGRA_SWGROUP_EPP,
  737. .regs = {
  738. .smmu = {
  739. .reg = 0x22c,
  740. .bit = 10,
  741. },
  742. .la = {
  743. .reg = 0x304,
  744. .shift = 16,
  745. .mask = 0xff,
  746. .def = 0x6c,
  747. },
  748. },
  749. .fifo_size = 16 * 64,
  750. }, {
  751. .id = 0x2b,
  752. .name = "mpeunifbw",
  753. .swgroup = TEGRA_SWGROUP_MPE,
  754. .regs = {
  755. .smmu = {
  756. .reg = 0x22c,
  757. .bit = 11,
  758. },
  759. .la = {
  760. .reg = 0x330,
  761. .shift = 0,
  762. .mask = 0xff,
  763. .def = 0x13,
  764. },
  765. },
  766. .fifo_size = 16 * 8,
  767. }, {
  768. .id = 0x2c,
  769. .name = "viwsb",
  770. .swgroup = TEGRA_SWGROUP_VI,
  771. .regs = {
  772. .smmu = {
  773. .reg = 0x22c,
  774. .bit = 12,
  775. },
  776. .la = {
  777. .reg = 0x364,
  778. .shift = 16,
  779. .mask = 0xff,
  780. .def = 0x12,
  781. },
  782. },
  783. .fifo_size = 16 * 64,
  784. }, {
  785. .id = 0x2d,
  786. .name = "viwu",
  787. .swgroup = TEGRA_SWGROUP_VI,
  788. .regs = {
  789. .smmu = {
  790. .reg = 0x22c,
  791. .bit = 13,
  792. },
  793. .la = {
  794. .reg = 0x368,
  795. .shift = 0,
  796. .mask = 0xff,
  797. .def = 0xb2,
  798. },
  799. },
  800. .fifo_size = 16 * 64,
  801. }, {
  802. .id = 0x2e,
  803. .name = "viwv",
  804. .swgroup = TEGRA_SWGROUP_VI,
  805. .regs = {
  806. .smmu = {
  807. .reg = 0x22c,
  808. .bit = 14,
  809. },
  810. .la = {
  811. .reg = 0x368,
  812. .shift = 16,
  813. .mask = 0xff,
  814. .def = 0xb2,
  815. },
  816. },
  817. .fifo_size = 16 * 64,
  818. }, {
  819. .id = 0x2f,
  820. .name = "viwy",
  821. .swgroup = TEGRA_SWGROUP_VI,
  822. .regs = {
  823. .smmu = {
  824. .reg = 0x22c,
  825. .bit = 15,
  826. },
  827. .la = {
  828. .reg = 0x36c,
  829. .shift = 0,
  830. .mask = 0xff,
  831. .def = 0x12,
  832. },
  833. },
  834. .fifo_size = 16 * 64,
  835. }, {
  836. .id = 0x30,
  837. .name = "g2dw",
  838. .swgroup = TEGRA_SWGROUP_G2,
  839. .regs = {
  840. .smmu = {
  841. .reg = 0x22c,
  842. .bit = 16,
  843. },
  844. .la = {
  845. .reg = 0x30c,
  846. .shift = 16,
  847. .mask = 0xff,
  848. .def = 0x9,
  849. },
  850. },
  851. .fifo_size = 16 * 128,
  852. }, {
  853. .id = 0x31,
  854. .name = "afiw",
  855. .swgroup = TEGRA_SWGROUP_AFI,
  856. .regs = {
  857. .smmu = {
  858. .reg = 0x22c,
  859. .bit = 17,
  860. },
  861. .la = {
  862. .reg = 0x2e0,
  863. .shift = 16,
  864. .mask = 0xff,
  865. .def = 0x0c,
  866. },
  867. },
  868. .fifo_size = 16 * 32,
  869. }, {
  870. .id = 0x32,
  871. .name = "avpcarm7w",
  872. .swgroup = TEGRA_SWGROUP_AVPC,
  873. .regs = {
  874. .smmu = {
  875. .reg = 0x22c,
  876. .bit = 18,
  877. },
  878. .la = {
  879. .reg = 0x2e4,
  880. .shift = 16,
  881. .mask = 0xff,
  882. .def = 0x0e,
  883. },
  884. },
  885. .fifo_size = 16 * 2,
  886. }, {
  887. .id = 0x33,
  888. .name = "fdcdwr",
  889. .swgroup = TEGRA_SWGROUP_NV,
  890. .regs = {
  891. .smmu = {
  892. .reg = 0x22c,
  893. .bit = 19,
  894. },
  895. .la = {
  896. .reg = 0x338,
  897. .shift = 16,
  898. .mask = 0xff,
  899. .def = 0x0a,
  900. },
  901. },
  902. .fifo_size = 16 * 48,
  903. }, {
  904. .id = 0x34,
  905. .name = "fdcdwr2",
  906. .swgroup = TEGRA_SWGROUP_NV2,
  907. .regs = {
  908. .smmu = {
  909. .reg = 0x22c,
  910. .bit = 20,
  911. },
  912. .la = {
  913. .reg = 0x340,
  914. .shift = 16,
  915. .mask = 0xff,
  916. .def = 0x0a,
  917. },
  918. },
  919. .fifo_size = 16 * 48,
  920. }, {
  921. .id = 0x35,
  922. .name = "hdaw",
  923. .swgroup = TEGRA_SWGROUP_HDA,
  924. .regs = {
  925. .smmu = {
  926. .reg = 0x22c,
  927. .bit = 21,
  928. },
  929. .la = {
  930. .reg = 0x318,
  931. .shift = 16,
  932. .mask = 0xff,
  933. .def = 0xff,
  934. },
  935. },
  936. .fifo_size = 16 * 16,
  937. }, {
  938. .id = 0x36,
  939. .name = "host1xw",
  940. .swgroup = TEGRA_SWGROUP_HC,
  941. .regs = {
  942. .smmu = {
  943. .reg = 0x22c,
  944. .bit = 22,
  945. },
  946. .la = {
  947. .reg = 0x314,
  948. .shift = 0,
  949. .mask = 0xff,
  950. .def = 0x10,
  951. },
  952. },
  953. .fifo_size = 16 * 32,
  954. }, {
  955. .id = 0x37,
  956. .name = "ispw",
  957. .swgroup = TEGRA_SWGROUP_ISP,
  958. .regs = {
  959. .smmu = {
  960. .reg = 0x22c,
  961. .bit = 23,
  962. },
  963. .la = {
  964. .reg = 0x31c,
  965. .shift = 0,
  966. .mask = 0xff,
  967. .def = 0xff,
  968. },
  969. },
  970. .fifo_size = 16 * 64,
  971. }, {
  972. .id = 0x38,
  973. .name = "mpcorelpw",
  974. .swgroup = TEGRA_SWGROUP_MPCORELP,
  975. .regs = {
  976. .la = {
  977. .reg = 0x324,
  978. .shift = 16,
  979. .mask = 0xff,
  980. .def = 0x0e,
  981. },
  982. },
  983. .fifo_size = 16 * 24,
  984. }, {
  985. .id = 0x39,
  986. .name = "mpcorew",
  987. .swgroup = TEGRA_SWGROUP_MPCORE,
  988. .regs = {
  989. .la = {
  990. .reg = 0x320,
  991. .shift = 16,
  992. .mask = 0xff,
  993. .def = 0x0e,
  994. },
  995. },
  996. .fifo_size = 16 * 24,
  997. }, {
  998. .id = 0x3a,
  999. .name = "mpecswr",
  1000. .swgroup = TEGRA_SWGROUP_MPE,
  1001. .regs = {
  1002. .smmu = {
  1003. .reg = 0x22c,
  1004. .bit = 26,
  1005. },
  1006. .la = {
  1007. .reg = 0x330,
  1008. .shift = 16,
  1009. .mask = 0xff,
  1010. .def = 0xff,
  1011. },
  1012. },
  1013. .fifo_size = 16 * 8,
  1014. }, {
  1015. .id = 0x3b,
  1016. .name = "ppcsahbdmaw",
  1017. .swgroup = TEGRA_SWGROUP_PPCS,
  1018. .regs = {
  1019. .smmu = {
  1020. .reg = 0x22c,
  1021. .bit = 27,
  1022. },
  1023. .la = {
  1024. .reg = 0x348,
  1025. .shift = 0,
  1026. .mask = 0xff,
  1027. .def = 0x10,
  1028. },
  1029. },
  1030. .fifo_size = 16 * 2,
  1031. }, {
  1032. .id = 0x3c,
  1033. .name = "ppcsahbslvw",
  1034. .swgroup = TEGRA_SWGROUP_PPCS,
  1035. .regs = {
  1036. .smmu = {
  1037. .reg = 0x22c,
  1038. .bit = 28,
  1039. },
  1040. .la = {
  1041. .reg = 0x348,
  1042. .shift = 16,
  1043. .mask = 0xff,
  1044. .def = 0x06,
  1045. },
  1046. },
  1047. .fifo_size = 16 * 4,
  1048. }, {
  1049. .id = 0x3d,
  1050. .name = "sataw",
  1051. .swgroup = TEGRA_SWGROUP_SATA,
  1052. .regs = {
  1053. .smmu = {
  1054. .reg = 0x22c,
  1055. .bit = 29,
  1056. },
  1057. .la = {
  1058. .reg = 0x350,
  1059. .shift = 16,
  1060. .mask = 0xff,
  1061. .def = 0x33,
  1062. },
  1063. },
  1064. .fifo_size = 16 * 32,
  1065. }, {
  1066. .id = 0x3e,
  1067. .name = "vdebsevw",
  1068. .swgroup = TEGRA_SWGROUP_VDE,
  1069. .regs = {
  1070. .smmu = {
  1071. .reg = 0x22c,
  1072. .bit = 30,
  1073. },
  1074. .la = {
  1075. .reg = 0x35c,
  1076. .shift = 0,
  1077. .mask = 0xff,
  1078. .def = 0xff,
  1079. },
  1080. },
  1081. .fifo_size = 16 * 4,
  1082. }, {
  1083. .id = 0x3f,
  1084. .name = "vdedbgw",
  1085. .swgroup = TEGRA_SWGROUP_VDE,
  1086. .regs = {
  1087. .smmu = {
  1088. .reg = 0x22c,
  1089. .bit = 31,
  1090. },
  1091. .la = {
  1092. .reg = 0x35c,
  1093. .shift = 16,
  1094. .mask = 0xff,
  1095. .def = 0xff,
  1096. },
  1097. },
  1098. .fifo_size = 16 * 16,
  1099. }, {
  1100. .id = 0x40,
  1101. .name = "vdembew",
  1102. .swgroup = TEGRA_SWGROUP_VDE,
  1103. .regs = {
  1104. .smmu = {
  1105. .reg = 0x230,
  1106. .bit = 0,
  1107. },
  1108. .la = {
  1109. .reg = 0x360,
  1110. .shift = 0,
  1111. .mask = 0xff,
  1112. .def = 0x42,
  1113. },
  1114. },
  1115. .fifo_size = 16 * 2,
  1116. }, {
  1117. .id = 0x41,
  1118. .name = "vdetpmw",
  1119. .swgroup = TEGRA_SWGROUP_VDE,
  1120. .regs = {
  1121. .smmu = {
  1122. .reg = 0x230,
  1123. .bit = 1,
  1124. },
  1125. .la = {
  1126. .reg = 0x360,
  1127. .shift = 16,
  1128. .mask = 0xff,
  1129. .def = 0x2a,
  1130. },
  1131. },
  1132. .fifo_size = 16 * 16,
  1133. },
  1134. };
  1135. static const struct tegra_smmu_swgroup tegra30_swgroups[] = {
  1136. { .name = "dc", .swgroup = TEGRA_SWGROUP_DC, .reg = 0x240 },
  1137. { .name = "dcb", .swgroup = TEGRA_SWGROUP_DCB, .reg = 0x244 },
  1138. { .name = "epp", .swgroup = TEGRA_SWGROUP_EPP, .reg = 0x248 },
  1139. { .name = "g2", .swgroup = TEGRA_SWGROUP_G2, .reg = 0x24c },
  1140. { .name = "mpe", .swgroup = TEGRA_SWGROUP_MPE, .reg = 0x264 },
  1141. { .name = "vi", .swgroup = TEGRA_SWGROUP_VI, .reg = 0x280 },
  1142. { .name = "afi", .swgroup = TEGRA_SWGROUP_AFI, .reg = 0x238 },
  1143. { .name = "avpc", .swgroup = TEGRA_SWGROUP_AVPC, .reg = 0x23c },
  1144. { .name = "nv", .swgroup = TEGRA_SWGROUP_NV, .reg = 0x268 },
  1145. { .name = "nv2", .swgroup = TEGRA_SWGROUP_NV2, .reg = 0x26c },
  1146. { .name = "hda", .swgroup = TEGRA_SWGROUP_HDA, .reg = 0x254 },
  1147. { .name = "hc", .swgroup = TEGRA_SWGROUP_HC, .reg = 0x250 },
  1148. { .name = "ppcs", .swgroup = TEGRA_SWGROUP_PPCS, .reg = 0x270 },
  1149. { .name = "sata", .swgroup = TEGRA_SWGROUP_SATA, .reg = 0x278 },
  1150. { .name = "vde", .swgroup = TEGRA_SWGROUP_VDE, .reg = 0x27c },
  1151. { .name = "isp", .swgroup = TEGRA_SWGROUP_ISP, .reg = 0x258 },
  1152. };
  1153. static const unsigned int tegra30_group_drm[] = {
  1154. TEGRA_SWGROUP_DC,
  1155. TEGRA_SWGROUP_DCB,
  1156. TEGRA_SWGROUP_G2,
  1157. TEGRA_SWGROUP_NV,
  1158. TEGRA_SWGROUP_NV2,
  1159. };
  1160. static const struct tegra_smmu_group_soc tegra30_groups[] = {
  1161. {
  1162. .name = "drm",
  1163. .swgroups = tegra30_group_drm,
  1164. .num_swgroups = ARRAY_SIZE(tegra30_group_drm),
  1165. },
  1166. };
  1167. static const struct tegra_smmu_soc tegra30_smmu_soc = {
  1168. .clients = tegra30_mc_clients,
  1169. .num_clients = ARRAY_SIZE(tegra30_mc_clients),
  1170. .swgroups = tegra30_swgroups,
  1171. .num_swgroups = ARRAY_SIZE(tegra30_swgroups),
  1172. .groups = tegra30_groups,
  1173. .num_groups = ARRAY_SIZE(tegra30_groups),
  1174. .supports_round_robin_arbitration = false,
  1175. .supports_request_limit = false,
  1176. .num_tlb_lines = 16,
  1177. .num_asids = 4,
  1178. };
  1179. #define TEGRA30_MC_RESET(_name, _control, _status, _bit) \
  1180. { \
  1181. .name = #_name, \
  1182. .id = TEGRA30_MC_RESET_##_name, \
  1183. .control = _control, \
  1184. .status = _status, \
  1185. .bit = _bit, \
  1186. }
  1187. static const struct tegra_mc_reset tegra30_mc_resets[] = {
  1188. TEGRA30_MC_RESET(AFI, 0x200, 0x204, 0),
  1189. TEGRA30_MC_RESET(AVPC, 0x200, 0x204, 1),
  1190. TEGRA30_MC_RESET(DC, 0x200, 0x204, 2),
  1191. TEGRA30_MC_RESET(DCB, 0x200, 0x204, 3),
  1192. TEGRA30_MC_RESET(EPP, 0x200, 0x204, 4),
  1193. TEGRA30_MC_RESET(2D, 0x200, 0x204, 5),
  1194. TEGRA30_MC_RESET(HC, 0x200, 0x204, 6),
  1195. TEGRA30_MC_RESET(HDA, 0x200, 0x204, 7),
  1196. TEGRA30_MC_RESET(ISP, 0x200, 0x204, 8),
  1197. TEGRA30_MC_RESET(MPCORE, 0x200, 0x204, 9),
  1198. TEGRA30_MC_RESET(MPCORELP, 0x200, 0x204, 10),
  1199. TEGRA30_MC_RESET(MPE, 0x200, 0x204, 11),
  1200. TEGRA30_MC_RESET(3D, 0x200, 0x204, 12),
  1201. TEGRA30_MC_RESET(3D2, 0x200, 0x204, 13),
  1202. TEGRA30_MC_RESET(PPCS, 0x200, 0x204, 14),
  1203. TEGRA30_MC_RESET(SATA, 0x200, 0x204, 15),
  1204. TEGRA30_MC_RESET(VDE, 0x200, 0x204, 16),
  1205. TEGRA30_MC_RESET(VI, 0x200, 0x204, 17),
  1206. };
  1207. static void tegra30_mc_tune_client_latency(struct tegra_mc *mc,
  1208. const struct tegra_mc_client *client,
  1209. unsigned int bandwidth_mbytes_sec)
  1210. {
  1211. u32 arb_tolerance_compensation_nsec, arb_tolerance_compensation_div;
  1212. unsigned int fifo_size = client->fifo_size;
  1213. u32 arb_nsec, la_ticks, value;
  1214. /* see 18.4.1 Client Configuration in Tegra3 TRM v03p */
  1215. if (bandwidth_mbytes_sec)
  1216. arb_nsec = fifo_size * NSEC_PER_USEC / bandwidth_mbytes_sec;
  1217. else
  1218. arb_nsec = U32_MAX;
  1219. /*
  1220. * Latency allowness should be set with consideration for the module's
  1221. * latency tolerance and internal buffering capabilities.
  1222. *
  1223. * Display memory clients use isochronous transfers and have very low
  1224. * tolerance to a belated transfers. Hence we need to compensate the
  1225. * memory arbitration imperfection for them in order to prevent FIFO
  1226. * underflow condition when memory bus is busy.
  1227. *
  1228. * VI clients also need a stronger compensation.
  1229. */
  1230. switch (client->swgroup) {
  1231. case TEGRA_SWGROUP_MPCORE:
  1232. case TEGRA_SWGROUP_PTC:
  1233. /*
  1234. * We always want lower latency for these clients, hence
  1235. * don't touch them.
  1236. */
  1237. return;
  1238. case TEGRA_SWGROUP_DC:
  1239. case TEGRA_SWGROUP_DCB:
  1240. arb_tolerance_compensation_nsec = 1050;
  1241. arb_tolerance_compensation_div = 2;
  1242. break;
  1243. case TEGRA_SWGROUP_VI:
  1244. arb_tolerance_compensation_nsec = 1050;
  1245. arb_tolerance_compensation_div = 1;
  1246. break;
  1247. default:
  1248. arb_tolerance_compensation_nsec = 150;
  1249. arb_tolerance_compensation_div = 1;
  1250. break;
  1251. }
  1252. if (arb_nsec > arb_tolerance_compensation_nsec)
  1253. arb_nsec -= arb_tolerance_compensation_nsec;
  1254. else
  1255. arb_nsec = 0;
  1256. arb_nsec /= arb_tolerance_compensation_div;
  1257. /*
  1258. * Latency allowance is a number of ticks a request from a particular
  1259. * client may wait in the EMEM arbiter before it becomes a high-priority
  1260. * request.
  1261. */
  1262. la_ticks = arb_nsec / mc->tick;
  1263. la_ticks = min(la_ticks, client->regs.la.mask);
  1264. value = mc_readl(mc, client->regs.la.reg);
  1265. value &= ~(client->regs.la.mask << client->regs.la.shift);
  1266. value |= la_ticks << client->regs.la.shift;
  1267. mc_writel(mc, value, client->regs.la.reg);
  1268. }
  1269. static int tegra30_mc_icc_set(struct icc_node *src, struct icc_node *dst)
  1270. {
  1271. struct tegra_mc *mc = icc_provider_to_tegra_mc(src->provider);
  1272. const struct tegra_mc_client *client = &mc->soc->clients[src->id];
  1273. u64 peak_bandwidth = icc_units_to_bps(src->peak_bw);
  1274. /*
  1275. * Skip pre-initialization that is done by icc_node_add(), which sets
  1276. * bandwidth to maximum for all clients before drivers are loaded.
  1277. *
  1278. * This doesn't make sense for us because we don't have drivers for all
  1279. * clients and it's okay to keep configuration left from bootloader
  1280. * during boot, at least for today.
  1281. */
  1282. if (src == dst)
  1283. return 0;
  1284. /* convert bytes/sec to megabytes/sec */
  1285. do_div(peak_bandwidth, 1000000);
  1286. tegra30_mc_tune_client_latency(mc, client, peak_bandwidth);
  1287. return 0;
  1288. }
  1289. static int tegra30_mc_icc_aggreate(struct icc_node *node, u32 tag, u32 avg_bw,
  1290. u32 peak_bw, u32 *agg_avg, u32 *agg_peak)
  1291. {
  1292. /*
  1293. * ISO clients need to reserve extra bandwidth up-front because
  1294. * there could be high bandwidth pressure during initial filling
  1295. * of the client's FIFO buffers. Secondly, we need to take into
  1296. * account impurities of the memory subsystem.
  1297. */
  1298. if (tag & TEGRA_MC_ICC_TAG_ISO)
  1299. peak_bw = tegra_mc_scale_percents(peak_bw, 400);
  1300. *agg_avg += avg_bw;
  1301. *agg_peak = max(*agg_peak, peak_bw);
  1302. return 0;
  1303. }
  1304. static struct icc_node_data *
  1305. tegra30_mc_of_icc_xlate_extended(struct of_phandle_args *spec, void *data)
  1306. {
  1307. struct tegra_mc *mc = icc_provider_to_tegra_mc(data);
  1308. const struct tegra_mc_client *client;
  1309. unsigned int i, idx = spec->args[0];
  1310. struct icc_node_data *ndata;
  1311. struct icc_node *node;
  1312. list_for_each_entry(node, &mc->provider.nodes, node_list) {
  1313. if (node->id != idx)
  1314. continue;
  1315. ndata = kzalloc(sizeof(*ndata), GFP_KERNEL);
  1316. if (!ndata)
  1317. return ERR_PTR(-ENOMEM);
  1318. client = &mc->soc->clients[idx];
  1319. ndata->node = node;
  1320. switch (client->swgroup) {
  1321. case TEGRA_SWGROUP_DC:
  1322. case TEGRA_SWGROUP_DCB:
  1323. case TEGRA_SWGROUP_PTC:
  1324. case TEGRA_SWGROUP_VI:
  1325. /* these clients are isochronous by default */
  1326. ndata->tag = TEGRA_MC_ICC_TAG_ISO;
  1327. break;
  1328. default:
  1329. ndata->tag = TEGRA_MC_ICC_TAG_DEFAULT;
  1330. break;
  1331. }
  1332. return ndata;
  1333. }
  1334. for (i = 0; i < mc->soc->num_clients; i++) {
  1335. if (mc->soc->clients[i].id == idx)
  1336. return ERR_PTR(-EPROBE_DEFER);
  1337. }
  1338. dev_err(mc->dev, "invalid ICC client ID %u\n", idx);
  1339. return ERR_PTR(-EINVAL);
  1340. }
  1341. static const struct tegra_mc_icc_ops tegra30_mc_icc_ops = {
  1342. .xlate_extended = tegra30_mc_of_icc_xlate_extended,
  1343. .aggregate = tegra30_mc_icc_aggreate,
  1344. .set = tegra30_mc_icc_set,
  1345. };
  1346. const struct tegra_mc_soc tegra30_mc_soc = {
  1347. .clients = tegra30_mc_clients,
  1348. .num_clients = ARRAY_SIZE(tegra30_mc_clients),
  1349. .num_address_bits = 32,
  1350. .atom_size = 16,
  1351. .client_id_mask = 0x7f,
  1352. .smmu = &tegra30_smmu_soc,
  1353. .emem_regs = tegra30_mc_emem_regs,
  1354. .num_emem_regs = ARRAY_SIZE(tegra30_mc_emem_regs),
  1355. .intmask = MC_INT_INVALID_SMMU_PAGE | MC_INT_SECURITY_VIOLATION |
  1356. MC_INT_DECERR_EMEM,
  1357. .reset_ops = &tegra_mc_reset_ops_common,
  1358. .resets = tegra30_mc_resets,
  1359. .num_resets = ARRAY_SIZE(tegra30_mc_resets),
  1360. .icc_ops = &tegra30_mc_icc_ops,
  1361. .ops = &tegra30_mc_ops,
  1362. };