pci_tegra.c 28 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193
  1. /*
  2. * Copyright (c) 2010, CompuLab, Ltd.
  3. * Author: Mike Rapoport <mike@compulab.co.il>
  4. *
  5. * Based on NVIDIA PCIe driver
  6. * Copyright (c) 2008-2009, NVIDIA Corporation.
  7. *
  8. * Copyright (c) 2013-2014, NVIDIA Corporation.
  9. *
  10. * SPDX-License-Identifier: GPL-2.0
  11. */
  12. #define pr_fmt(fmt) "tegra-pcie: " fmt
  13. #include <common.h>
  14. #include <clk.h>
  15. #include <dm.h>
  16. #include <errno.h>
  17. #include <malloc.h>
  18. #include <pci.h>
  19. #include <power-domain.h>
  20. #include <reset.h>
  21. #include <asm/io.h>
  22. #include <asm/gpio.h>
  23. #include <linux/ioport.h>
  24. #include <linux/list.h>
  25. #ifndef CONFIG_TEGRA186
  26. #include <asm/arch/clock.h>
  27. #include <asm/arch/powergate.h>
  28. #include <asm/arch-tegra/xusb-padctl.h>
  29. #include <dt-bindings/pinctrl/pinctrl-tegra-xusb.h>
  30. #endif
  31. /*
  32. * FIXME: TODO: This driver contains a number of ifdef CONFIG_TEGRA186 that
  33. * should not be present. These are needed because newer Tegra SoCs support
  34. * only the standard clock/reset APIs, whereas older Tegra SoCs support only
  35. * a custom Tegra-specific API. ASAP the older Tegra SoCs' code should be
  36. * fixed to implement the standard APIs, and all drivers converted to solely
  37. * use the new standard APIs, with no ifdefs.
  38. */
  39. DECLARE_GLOBAL_DATA_PTR;
  40. #define AFI_AXI_BAR0_SZ 0x00
  41. #define AFI_AXI_BAR1_SZ 0x04
  42. #define AFI_AXI_BAR2_SZ 0x08
  43. #define AFI_AXI_BAR3_SZ 0x0c
  44. #define AFI_AXI_BAR4_SZ 0x10
  45. #define AFI_AXI_BAR5_SZ 0x14
  46. #define AFI_AXI_BAR0_START 0x18
  47. #define AFI_AXI_BAR1_START 0x1c
  48. #define AFI_AXI_BAR2_START 0x20
  49. #define AFI_AXI_BAR3_START 0x24
  50. #define AFI_AXI_BAR4_START 0x28
  51. #define AFI_AXI_BAR5_START 0x2c
  52. #define AFI_FPCI_BAR0 0x30
  53. #define AFI_FPCI_BAR1 0x34
  54. #define AFI_FPCI_BAR2 0x38
  55. #define AFI_FPCI_BAR3 0x3c
  56. #define AFI_FPCI_BAR4 0x40
  57. #define AFI_FPCI_BAR5 0x44
  58. #define AFI_CACHE_BAR0_SZ 0x48
  59. #define AFI_CACHE_BAR0_ST 0x4c
  60. #define AFI_CACHE_BAR1_SZ 0x50
  61. #define AFI_CACHE_BAR1_ST 0x54
  62. #define AFI_MSI_BAR_SZ 0x60
  63. #define AFI_MSI_FPCI_BAR_ST 0x64
  64. #define AFI_MSI_AXI_BAR_ST 0x68
  65. #define AFI_CONFIGURATION 0xac
  66. #define AFI_CONFIGURATION_EN_FPCI (1 << 0)
  67. #define AFI_FPCI_ERROR_MASKS 0xb0
  68. #define AFI_INTR_MASK 0xb4
  69. #define AFI_INTR_MASK_INT_MASK (1 << 0)
  70. #define AFI_INTR_MASK_MSI_MASK (1 << 8)
  71. #define AFI_SM_INTR_ENABLE 0xc4
  72. #define AFI_SM_INTR_INTA_ASSERT (1 << 0)
  73. #define AFI_SM_INTR_INTB_ASSERT (1 << 1)
  74. #define AFI_SM_INTR_INTC_ASSERT (1 << 2)
  75. #define AFI_SM_INTR_INTD_ASSERT (1 << 3)
  76. #define AFI_SM_INTR_INTA_DEASSERT (1 << 4)
  77. #define AFI_SM_INTR_INTB_DEASSERT (1 << 5)
  78. #define AFI_SM_INTR_INTC_DEASSERT (1 << 6)
  79. #define AFI_SM_INTR_INTD_DEASSERT (1 << 7)
  80. #define AFI_AFI_INTR_ENABLE 0xc8
  81. #define AFI_INTR_EN_INI_SLVERR (1 << 0)
  82. #define AFI_INTR_EN_INI_DECERR (1 << 1)
  83. #define AFI_INTR_EN_TGT_SLVERR (1 << 2)
  84. #define AFI_INTR_EN_TGT_DECERR (1 << 3)
  85. #define AFI_INTR_EN_TGT_WRERR (1 << 4)
  86. #define AFI_INTR_EN_DFPCI_DECERR (1 << 5)
  87. #define AFI_INTR_EN_AXI_DECERR (1 << 6)
  88. #define AFI_INTR_EN_FPCI_TIMEOUT (1 << 7)
  89. #define AFI_INTR_EN_PRSNT_SENSE (1 << 8)
  90. #define AFI_PCIE_CONFIG 0x0f8
  91. #define AFI_PCIE_CONFIG_PCIE_DISABLE(x) (1 << ((x) + 1))
  92. #define AFI_PCIE_CONFIG_PCIE_DISABLE_ALL 0xe
  93. #define AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_MASK (0xf << 20)
  94. #define AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_SINGLE (0x0 << 20)
  95. #define AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_420 (0x0 << 20)
  96. #define AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_X2_X1 (0x0 << 20)
  97. #define AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_DUAL (0x1 << 20)
  98. #define AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_222 (0x1 << 20)
  99. #define AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_X4_X1 (0x1 << 20)
  100. #define AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_411 (0x2 << 20)
  101. #define AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_T186_401 (0x0 << 20)
  102. #define AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_T186_211 (0x1 << 20)
  103. #define AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_T186_111 (0x2 << 20)
  104. #define AFI_FUSE 0x104
  105. #define AFI_FUSE_PCIE_T0_GEN2_DIS (1 << 2)
  106. #define AFI_PEX0_CTRL 0x110
  107. #define AFI_PEX1_CTRL 0x118
  108. #define AFI_PEX2_CTRL 0x128
  109. #define AFI_PEX2_CTRL_T186 0x19c
  110. #define AFI_PEX_CTRL_RST (1 << 0)
  111. #define AFI_PEX_CTRL_CLKREQ_EN (1 << 1)
  112. #define AFI_PEX_CTRL_REFCLK_EN (1 << 3)
  113. #define AFI_PEX_CTRL_OVERRIDE_EN (1 << 4)
  114. #define AFI_PLLE_CONTROL 0x160
  115. #define AFI_PLLE_CONTROL_BYPASS_PADS2PLLE_CONTROL (1 << 9)
  116. #define AFI_PLLE_CONTROL_PADS2PLLE_CONTROL_EN (1 << 1)
  117. #define AFI_PEXBIAS_CTRL_0 0x168
  118. #define PADS_CTL_SEL 0x0000009C
  119. #define PADS_CTL 0x000000A0
  120. #define PADS_CTL_IDDQ_1L (1 << 0)
  121. #define PADS_CTL_TX_DATA_EN_1L (1 << 6)
  122. #define PADS_CTL_RX_DATA_EN_1L (1 << 10)
  123. #define PADS_PLL_CTL_TEGRA20 0x000000B8
  124. #define PADS_PLL_CTL_TEGRA30 0x000000B4
  125. #define PADS_PLL_CTL_RST_B4SM (0x1 << 1)
  126. #define PADS_PLL_CTL_LOCKDET (0x1 << 8)
  127. #define PADS_PLL_CTL_REFCLK_MASK (0x3 << 16)
  128. #define PADS_PLL_CTL_REFCLK_INTERNAL_CML (0x0 << 16)
  129. #define PADS_PLL_CTL_REFCLK_INTERNAL_CMOS (0x1 << 16)
  130. #define PADS_PLL_CTL_REFCLK_EXTERNAL (0x2 << 16)
  131. #define PADS_PLL_CTL_TXCLKREF_MASK (0x1 << 20)
  132. #define PADS_PLL_CTL_TXCLKREF_DIV10 (0x0 << 20)
  133. #define PADS_PLL_CTL_TXCLKREF_DIV5 (0x1 << 20)
  134. #define PADS_PLL_CTL_TXCLKREF_BUF_EN (0x1 << 22)
  135. #define PADS_REFCLK_CFG0 0x000000C8
  136. #define PADS_REFCLK_CFG1 0x000000CC
  137. /*
  138. * Fields in PADS_REFCLK_CFG*. Those registers form an array of 16-bit
  139. * entries, one entry per PCIe port. These field definitions and desired
  140. * values aren't in the TRM, but do come from NVIDIA.
  141. */
  142. #define PADS_REFCLK_CFG_TERM_SHIFT 2 /* 6:2 */
  143. #define PADS_REFCLK_CFG_E_TERM_SHIFT 7
  144. #define PADS_REFCLK_CFG_PREDI_SHIFT 8 /* 11:8 */
  145. #define PADS_REFCLK_CFG_DRVI_SHIFT 12 /* 15:12 */
  146. #define RP_VEND_XP 0x00000F00
  147. #define RP_VEND_XP_DL_UP (1 << 30)
  148. #define RP_VEND_CTL2 0x00000FA8
  149. #define RP_VEND_CTL2_PCA_ENABLE (1 << 7)
  150. #define RP_PRIV_MISC 0x00000FE0
  151. #define RP_PRIV_MISC_PRSNT_MAP_EP_PRSNT (0xE << 0)
  152. #define RP_PRIV_MISC_PRSNT_MAP_EP_ABSNT (0xF << 0)
  153. #define RP_LINK_CONTROL_STATUS 0x00000090
  154. #define RP_LINK_CONTROL_STATUS_DL_LINK_ACTIVE 0x20000000
  155. #define RP_LINK_CONTROL_STATUS_LINKSTAT_MASK 0x3fff0000
  156. enum tegra_pci_id {
  157. TEGRA20_PCIE,
  158. TEGRA30_PCIE,
  159. TEGRA124_PCIE,
  160. TEGRA210_PCIE,
  161. TEGRA186_PCIE,
  162. };
  163. struct tegra_pcie_port {
  164. struct tegra_pcie *pcie;
  165. struct fdt_resource regs;
  166. unsigned int num_lanes;
  167. unsigned int index;
  168. struct list_head list;
  169. };
  170. struct tegra_pcie_soc {
  171. unsigned int num_ports;
  172. unsigned long pads_pll_ctl;
  173. unsigned long tx_ref_sel;
  174. unsigned long afi_pex2_ctrl;
  175. u32 pads_refclk_cfg0;
  176. u32 pads_refclk_cfg1;
  177. bool has_pex_clkreq_en;
  178. bool has_pex_bias_ctrl;
  179. bool has_cml_clk;
  180. bool has_gen2;
  181. bool force_pca_enable;
  182. };
  183. struct tegra_pcie {
  184. struct resource pads;
  185. struct resource afi;
  186. struct resource cs;
  187. struct list_head ports;
  188. unsigned long xbar;
  189. const struct tegra_pcie_soc *soc;
  190. #ifdef CONFIG_TEGRA186
  191. struct clk clk_afi;
  192. struct clk clk_pex;
  193. struct reset_ctl reset_afi;
  194. struct reset_ctl reset_pex;
  195. struct reset_ctl reset_pcie_x;
  196. struct power_domain pwrdom;
  197. #else
  198. struct tegra_xusb_phy *phy;
  199. #endif
  200. };
  201. static void afi_writel(struct tegra_pcie *pcie, unsigned long value,
  202. unsigned long offset)
  203. {
  204. writel(value, pcie->afi.start + offset);
  205. }
  206. static unsigned long afi_readl(struct tegra_pcie *pcie, unsigned long offset)
  207. {
  208. return readl(pcie->afi.start + offset);
  209. }
  210. static void pads_writel(struct tegra_pcie *pcie, unsigned long value,
  211. unsigned long offset)
  212. {
  213. writel(value, pcie->pads.start + offset);
  214. }
  215. #ifndef CONFIG_TEGRA186
  216. static unsigned long pads_readl(struct tegra_pcie *pcie, unsigned long offset)
  217. {
  218. return readl(pcie->pads.start + offset);
  219. }
  220. #endif
  221. static unsigned long rp_readl(struct tegra_pcie_port *port,
  222. unsigned long offset)
  223. {
  224. return readl(port->regs.start + offset);
  225. }
  226. static void rp_writel(struct tegra_pcie_port *port, unsigned long value,
  227. unsigned long offset)
  228. {
  229. writel(value, port->regs.start + offset);
  230. }
  231. static unsigned long tegra_pcie_conf_offset(pci_dev_t bdf, int where)
  232. {
  233. return ((where & 0xf00) << 16) | (PCI_BUS(bdf) << 16) |
  234. (PCI_DEV(bdf) << 11) | (PCI_FUNC(bdf) << 8) |
  235. (where & 0xfc);
  236. }
  237. static int tegra_pcie_conf_address(struct tegra_pcie *pcie, pci_dev_t bdf,
  238. int where, unsigned long *address)
  239. {
  240. unsigned int bus = PCI_BUS(bdf);
  241. if (bus == 0) {
  242. unsigned int dev = PCI_DEV(bdf);
  243. struct tegra_pcie_port *port;
  244. list_for_each_entry(port, &pcie->ports, list) {
  245. if (port->index + 1 == dev) {
  246. *address = port->regs.start + (where & ~3);
  247. return 0;
  248. }
  249. }
  250. return -EFAULT;
  251. } else {
  252. #ifdef CONFIG_TEGRA20
  253. unsigned int dev = PCI_DEV(bdf);
  254. if (dev != 0)
  255. return -EFAULT;
  256. #endif
  257. *address = pcie->cs.start + tegra_pcie_conf_offset(bdf, where);
  258. return 0;
  259. }
  260. }
  261. static int pci_tegra_read_config(struct udevice *bus, pci_dev_t bdf,
  262. uint offset, ulong *valuep,
  263. enum pci_size_t size)
  264. {
  265. struct tegra_pcie *pcie = dev_get_priv(bus);
  266. unsigned long address, value;
  267. int err;
  268. err = tegra_pcie_conf_address(pcie, bdf, offset, &address);
  269. if (err < 0) {
  270. value = 0xffffffff;
  271. goto done;
  272. }
  273. value = readl(address);
  274. #ifdef CONFIG_TEGRA20
  275. /* fixup root port class */
  276. if (PCI_BUS(bdf) == 0) {
  277. if ((offset & ~3) == PCI_CLASS_REVISION) {
  278. value &= ~0x00ff0000;
  279. value |= PCI_CLASS_BRIDGE_PCI << 16;
  280. }
  281. }
  282. #endif
  283. done:
  284. *valuep = pci_conv_32_to_size(value, offset, size);
  285. return 0;
  286. }
  287. static int pci_tegra_write_config(struct udevice *bus, pci_dev_t bdf,
  288. uint offset, ulong value,
  289. enum pci_size_t size)
  290. {
  291. struct tegra_pcie *pcie = dev_get_priv(bus);
  292. unsigned long address;
  293. ulong old;
  294. int err;
  295. err = tegra_pcie_conf_address(pcie, bdf, offset, &address);
  296. if (err < 0)
  297. return 0;
  298. old = readl(address);
  299. value = pci_conv_size_to_32(old, value, offset, size);
  300. writel(value, address);
  301. return 0;
  302. }
  303. static int tegra_pcie_port_parse_dt(ofnode node, struct tegra_pcie_port *port)
  304. {
  305. const u32 *addr;
  306. int len;
  307. addr = ofnode_get_property(node, "assigned-addresses", &len);
  308. if (!addr) {
  309. pr_err("property \"assigned-addresses\" not found");
  310. return -FDT_ERR_NOTFOUND;
  311. }
  312. port->regs.start = fdt32_to_cpu(addr[2]);
  313. port->regs.end = port->regs.start + fdt32_to_cpu(addr[4]);
  314. return 0;
  315. }
  316. static int tegra_pcie_get_xbar_config(ofnode node, u32 lanes,
  317. enum tegra_pci_id id, unsigned long *xbar)
  318. {
  319. switch (id) {
  320. case TEGRA20_PCIE:
  321. switch (lanes) {
  322. case 0x00000004:
  323. debug("single-mode configuration\n");
  324. *xbar = AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_SINGLE;
  325. return 0;
  326. case 0x00000202:
  327. debug("dual-mode configuration\n");
  328. *xbar = AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_DUAL;
  329. return 0;
  330. }
  331. break;
  332. case TEGRA30_PCIE:
  333. switch (lanes) {
  334. case 0x00000204:
  335. debug("4x1, 2x1 configuration\n");
  336. *xbar = AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_420;
  337. return 0;
  338. case 0x00020202:
  339. debug("2x3 configuration\n");
  340. *xbar = AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_222;
  341. return 0;
  342. case 0x00010104:
  343. debug("4x1, 1x2 configuration\n");
  344. *xbar = AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_411;
  345. return 0;
  346. }
  347. break;
  348. case TEGRA124_PCIE:
  349. case TEGRA210_PCIE:
  350. switch (lanes) {
  351. case 0x0000104:
  352. debug("4x1, 1x1 configuration\n");
  353. *xbar = AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_X4_X1;
  354. return 0;
  355. case 0x0000102:
  356. debug("2x1, 1x1 configuration\n");
  357. *xbar = AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_X2_X1;
  358. return 0;
  359. }
  360. break;
  361. case TEGRA186_PCIE:
  362. switch (lanes) {
  363. case 0x0010004:
  364. debug("x4 x1 configuration\n");
  365. *xbar = AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_T186_401;
  366. return 0;
  367. case 0x0010102:
  368. debug("x2 x1 x1 configuration\n");
  369. *xbar = AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_T186_211;
  370. return 0;
  371. case 0x0010101:
  372. debug("x1 x1 x1 configuration\n");
  373. *xbar = AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_T186_111;
  374. return 0;
  375. }
  376. break;
  377. default:
  378. break;
  379. }
  380. return -FDT_ERR_NOTFOUND;
  381. }
  382. static int tegra_pcie_parse_port_info(ofnode node, uint *index, uint *lanes)
  383. {
  384. struct fdt_pci_addr addr;
  385. int err;
  386. err = ofnode_read_u32_default(node, "nvidia,num-lanes", -1);
  387. if (err < 0) {
  388. pr_err("failed to parse \"nvidia,num-lanes\" property");
  389. return err;
  390. }
  391. *lanes = err;
  392. err = ofnode_read_pci_addr(node, 0, "reg", &addr);
  393. if (err < 0) {
  394. pr_err("failed to parse \"reg\" property");
  395. return err;
  396. }
  397. *index = PCI_DEV(addr.phys_hi) - 1;
  398. return 0;
  399. }
  400. int __weak tegra_pcie_board_init(void)
  401. {
  402. return 0;
  403. }
  404. static int tegra_pcie_parse_dt(struct udevice *dev, enum tegra_pci_id id,
  405. struct tegra_pcie *pcie)
  406. {
  407. ofnode subnode;
  408. u32 lanes = 0;
  409. int err;
  410. err = dev_read_resource(dev, 0, &pcie->pads);
  411. if (err < 0) {
  412. pr_err("resource \"pads\" not found");
  413. return err;
  414. }
  415. err = dev_read_resource(dev, 1, &pcie->afi);
  416. if (err < 0) {
  417. pr_err("resource \"afi\" not found");
  418. return err;
  419. }
  420. err = dev_read_resource(dev, 2, &pcie->cs);
  421. if (err < 0) {
  422. pr_err("resource \"cs\" not found");
  423. return err;
  424. }
  425. err = tegra_pcie_board_init();
  426. if (err < 0) {
  427. pr_err("tegra_pcie_board_init() failed: err=%d", err);
  428. return err;
  429. }
  430. #ifndef CONFIG_TEGRA186
  431. pcie->phy = tegra_xusb_phy_get(TEGRA_XUSB_PADCTL_PCIE);
  432. if (pcie->phy) {
  433. err = tegra_xusb_phy_prepare(pcie->phy);
  434. if (err < 0) {
  435. pr_err("failed to prepare PHY: %d", err);
  436. return err;
  437. }
  438. }
  439. #endif
  440. dev_for_each_subnode(subnode, dev) {
  441. unsigned int index = 0, num_lanes = 0;
  442. struct tegra_pcie_port *port;
  443. err = tegra_pcie_parse_port_info(subnode, &index, &num_lanes);
  444. if (err < 0) {
  445. pr_err("failed to obtain root port info");
  446. continue;
  447. }
  448. lanes |= num_lanes << (index << 3);
  449. if (!ofnode_is_available(subnode))
  450. continue;
  451. port = malloc(sizeof(*port));
  452. if (!port)
  453. continue;
  454. memset(port, 0, sizeof(*port));
  455. port->num_lanes = num_lanes;
  456. port->index = index;
  457. err = tegra_pcie_port_parse_dt(subnode, port);
  458. if (err < 0) {
  459. free(port);
  460. continue;
  461. }
  462. list_add_tail(&port->list, &pcie->ports);
  463. port->pcie = pcie;
  464. }
  465. err = tegra_pcie_get_xbar_config(dev_ofnode(dev), lanes, id,
  466. &pcie->xbar);
  467. if (err < 0) {
  468. pr_err("invalid lane configuration");
  469. return err;
  470. }
  471. return 0;
  472. }
  473. #ifdef CONFIG_TEGRA186
  474. static int tegra_pcie_power_on(struct tegra_pcie *pcie)
  475. {
  476. int ret;
  477. ret = power_domain_on(&pcie->pwrdom);
  478. if (ret) {
  479. pr_err("power_domain_on() failed: %d\n", ret);
  480. return ret;
  481. }
  482. ret = clk_enable(&pcie->clk_afi);
  483. if (ret) {
  484. pr_err("clk_enable(afi) failed: %d\n", ret);
  485. return ret;
  486. }
  487. ret = clk_enable(&pcie->clk_pex);
  488. if (ret) {
  489. pr_err("clk_enable(pex) failed: %d\n", ret);
  490. return ret;
  491. }
  492. ret = reset_deassert(&pcie->reset_afi);
  493. if (ret) {
  494. pr_err("reset_deassert(afi) failed: %d\n", ret);
  495. return ret;
  496. }
  497. ret = reset_deassert(&pcie->reset_pex);
  498. if (ret) {
  499. pr_err("reset_deassert(pex) failed: %d\n", ret);
  500. return ret;
  501. }
  502. return 0;
  503. }
  504. #else
  505. static int tegra_pcie_power_on(struct tegra_pcie *pcie)
  506. {
  507. const struct tegra_pcie_soc *soc = pcie->soc;
  508. unsigned long value;
  509. int err;
  510. /* reset PCIEXCLK logic, AFI controller and PCIe controller */
  511. reset_set_enable(PERIPH_ID_PCIEXCLK, 1);
  512. reset_set_enable(PERIPH_ID_AFI, 1);
  513. reset_set_enable(PERIPH_ID_PCIE, 1);
  514. err = tegra_powergate_power_off(TEGRA_POWERGATE_PCIE);
  515. if (err < 0) {
  516. pr_err("failed to power off PCIe partition: %d", err);
  517. return err;
  518. }
  519. err = tegra_powergate_sequence_power_up(TEGRA_POWERGATE_PCIE,
  520. PERIPH_ID_PCIE);
  521. if (err < 0) {
  522. pr_err("failed to power up PCIe partition: %d", err);
  523. return err;
  524. }
  525. /* take AFI controller out of reset */
  526. reset_set_enable(PERIPH_ID_AFI, 0);
  527. /* enable AFI clock */
  528. clock_enable(PERIPH_ID_AFI);
  529. if (soc->has_cml_clk) {
  530. /* enable CML clock */
  531. value = readl(NV_PA_CLK_RST_BASE + 0x48c);
  532. value |= (1 << 0);
  533. value &= ~(1 << 1);
  534. writel(value, NV_PA_CLK_RST_BASE + 0x48c);
  535. }
  536. err = tegra_plle_enable();
  537. if (err < 0) {
  538. pr_err("failed to enable PLLE: %d\n", err);
  539. return err;
  540. }
  541. return 0;
  542. }
  543. static int tegra_pcie_pll_wait(struct tegra_pcie *pcie, unsigned long timeout)
  544. {
  545. const struct tegra_pcie_soc *soc = pcie->soc;
  546. unsigned long start = get_timer(0);
  547. u32 value;
  548. while (get_timer(start) < timeout) {
  549. value = pads_readl(pcie, soc->pads_pll_ctl);
  550. if (value & PADS_PLL_CTL_LOCKDET)
  551. return 0;
  552. }
  553. return -ETIMEDOUT;
  554. }
  555. static int tegra_pcie_phy_enable(struct tegra_pcie *pcie)
  556. {
  557. const struct tegra_pcie_soc *soc = pcie->soc;
  558. u32 value;
  559. int err;
  560. /* initialize internal PHY, enable up to 16 PCIe lanes */
  561. pads_writel(pcie, 0, PADS_CTL_SEL);
  562. /* override IDDQ to 1 on all 4 lanes */
  563. value = pads_readl(pcie, PADS_CTL);
  564. value |= PADS_CTL_IDDQ_1L;
  565. pads_writel(pcie, value, PADS_CTL);
  566. /*
  567. * Set up PHY PLL inputs select PLLE output as refclock, set TX
  568. * ref sel to div10 (not div5).
  569. */
  570. value = pads_readl(pcie, soc->pads_pll_ctl);
  571. value &= ~(PADS_PLL_CTL_REFCLK_MASK | PADS_PLL_CTL_TXCLKREF_MASK);
  572. value |= PADS_PLL_CTL_REFCLK_INTERNAL_CML | soc->tx_ref_sel;
  573. pads_writel(pcie, value, soc->pads_pll_ctl);
  574. /* reset PLL */
  575. value = pads_readl(pcie, soc->pads_pll_ctl);
  576. value &= ~PADS_PLL_CTL_RST_B4SM;
  577. pads_writel(pcie, value, soc->pads_pll_ctl);
  578. udelay(20);
  579. /* take PLL out of reset */
  580. value = pads_readl(pcie, soc->pads_pll_ctl);
  581. value |= PADS_PLL_CTL_RST_B4SM;
  582. pads_writel(pcie, value, soc->pads_pll_ctl);
  583. /* wait for the PLL to lock */
  584. err = tegra_pcie_pll_wait(pcie, 500);
  585. if (err < 0) {
  586. pr_err("PLL failed to lock: %d", err);
  587. return err;
  588. }
  589. /* turn off IDDQ override */
  590. value = pads_readl(pcie, PADS_CTL);
  591. value &= ~PADS_CTL_IDDQ_1L;
  592. pads_writel(pcie, value, PADS_CTL);
  593. /* enable TX/RX data */
  594. value = pads_readl(pcie, PADS_CTL);
  595. value |= PADS_CTL_TX_DATA_EN_1L | PADS_CTL_RX_DATA_EN_1L;
  596. pads_writel(pcie, value, PADS_CTL);
  597. return 0;
  598. }
  599. #endif
  600. static int tegra_pcie_enable_controller(struct tegra_pcie *pcie)
  601. {
  602. const struct tegra_pcie_soc *soc = pcie->soc;
  603. struct tegra_pcie_port *port;
  604. u32 value;
  605. int err;
  606. #ifdef CONFIG_TEGRA186
  607. {
  608. #else
  609. if (pcie->phy) {
  610. #endif
  611. value = afi_readl(pcie, AFI_PLLE_CONTROL);
  612. value &= ~AFI_PLLE_CONTROL_BYPASS_PADS2PLLE_CONTROL;
  613. value |= AFI_PLLE_CONTROL_PADS2PLLE_CONTROL_EN;
  614. afi_writel(pcie, value, AFI_PLLE_CONTROL);
  615. }
  616. if (soc->has_pex_bias_ctrl)
  617. afi_writel(pcie, 0, AFI_PEXBIAS_CTRL_0);
  618. value = afi_readl(pcie, AFI_PCIE_CONFIG);
  619. value &= ~AFI_PCIE_CONFIG_SM2TMS0_XBAR_CONFIG_MASK;
  620. value |= AFI_PCIE_CONFIG_PCIE_DISABLE_ALL | pcie->xbar;
  621. list_for_each_entry(port, &pcie->ports, list)
  622. value &= ~AFI_PCIE_CONFIG_PCIE_DISABLE(port->index);
  623. afi_writel(pcie, value, AFI_PCIE_CONFIG);
  624. value = afi_readl(pcie, AFI_FUSE);
  625. if (soc->has_gen2)
  626. value &= ~AFI_FUSE_PCIE_T0_GEN2_DIS;
  627. else
  628. value |= AFI_FUSE_PCIE_T0_GEN2_DIS;
  629. afi_writel(pcie, value, AFI_FUSE);
  630. #ifndef CONFIG_TEGRA186
  631. if (pcie->phy)
  632. err = tegra_xusb_phy_enable(pcie->phy);
  633. else
  634. err = tegra_pcie_phy_enable(pcie);
  635. if (err < 0) {
  636. pr_err("failed to power on PHY: %d\n", err);
  637. return err;
  638. }
  639. #endif
  640. /* take the PCIEXCLK logic out of reset */
  641. #ifdef CONFIG_TEGRA186
  642. err = reset_deassert(&pcie->reset_pcie_x);
  643. if (err) {
  644. pr_err("reset_deassert(pcie_x) failed: %d\n", err);
  645. return err;
  646. }
  647. #else
  648. reset_set_enable(PERIPH_ID_PCIEXCLK, 0);
  649. #endif
  650. /* finally enable PCIe */
  651. value = afi_readl(pcie, AFI_CONFIGURATION);
  652. value |= AFI_CONFIGURATION_EN_FPCI;
  653. afi_writel(pcie, value, AFI_CONFIGURATION);
  654. /* disable all interrupts */
  655. afi_writel(pcie, 0, AFI_AFI_INTR_ENABLE);
  656. afi_writel(pcie, 0, AFI_SM_INTR_ENABLE);
  657. afi_writel(pcie, 0, AFI_INTR_MASK);
  658. afi_writel(pcie, 0, AFI_FPCI_ERROR_MASKS);
  659. return 0;
  660. }
  661. static int tegra_pcie_setup_translations(struct udevice *bus)
  662. {
  663. struct tegra_pcie *pcie = dev_get_priv(bus);
  664. unsigned long fpci, axi, size;
  665. struct pci_region *io, *mem, *pref;
  666. int count;
  667. /* BAR 0: type 1 extended configuration space */
  668. fpci = 0xfe100000;
  669. size = resource_size(&pcie->cs);
  670. axi = pcie->cs.start;
  671. afi_writel(pcie, axi, AFI_AXI_BAR0_START);
  672. afi_writel(pcie, size >> 12, AFI_AXI_BAR0_SZ);
  673. afi_writel(pcie, fpci, AFI_FPCI_BAR0);
  674. count = pci_get_regions(bus, &io, &mem, &pref);
  675. if (count != 3)
  676. return -EINVAL;
  677. /* BAR 1: downstream I/O */
  678. fpci = 0xfdfc0000;
  679. size = io->size;
  680. axi = io->phys_start;
  681. afi_writel(pcie, axi, AFI_AXI_BAR1_START);
  682. afi_writel(pcie, size >> 12, AFI_AXI_BAR1_SZ);
  683. afi_writel(pcie, fpci, AFI_FPCI_BAR1);
  684. /* BAR 2: prefetchable memory */
  685. fpci = (((pref->phys_start >> 12) & 0x0fffffff) << 4) | 0x1;
  686. size = pref->size;
  687. axi = pref->phys_start;
  688. afi_writel(pcie, axi, AFI_AXI_BAR2_START);
  689. afi_writel(pcie, size >> 12, AFI_AXI_BAR2_SZ);
  690. afi_writel(pcie, fpci, AFI_FPCI_BAR2);
  691. /* BAR 3: non-prefetchable memory */
  692. fpci = (((mem->phys_start >> 12) & 0x0fffffff) << 4) | 0x1;
  693. size = mem->size;
  694. axi = mem->phys_start;
  695. afi_writel(pcie, axi, AFI_AXI_BAR3_START);
  696. afi_writel(pcie, size >> 12, AFI_AXI_BAR3_SZ);
  697. afi_writel(pcie, fpci, AFI_FPCI_BAR3);
  698. /* NULL out the remaining BARs as they are not used */
  699. afi_writel(pcie, 0, AFI_AXI_BAR4_START);
  700. afi_writel(pcie, 0, AFI_AXI_BAR4_SZ);
  701. afi_writel(pcie, 0, AFI_FPCI_BAR4);
  702. afi_writel(pcie, 0, AFI_AXI_BAR5_START);
  703. afi_writel(pcie, 0, AFI_AXI_BAR5_SZ);
  704. afi_writel(pcie, 0, AFI_FPCI_BAR5);
  705. /* map all upstream transactions as uncached */
  706. afi_writel(pcie, NV_PA_SDRAM_BASE, AFI_CACHE_BAR0_ST);
  707. afi_writel(pcie, 0, AFI_CACHE_BAR0_SZ);
  708. afi_writel(pcie, 0, AFI_CACHE_BAR1_ST);
  709. afi_writel(pcie, 0, AFI_CACHE_BAR1_SZ);
  710. /* MSI translations are setup only when needed */
  711. afi_writel(pcie, 0, AFI_MSI_FPCI_BAR_ST);
  712. afi_writel(pcie, 0, AFI_MSI_BAR_SZ);
  713. afi_writel(pcie, 0, AFI_MSI_AXI_BAR_ST);
  714. afi_writel(pcie, 0, AFI_MSI_BAR_SZ);
  715. return 0;
  716. }
  717. static unsigned long tegra_pcie_port_get_pex_ctrl(struct tegra_pcie_port *port)
  718. {
  719. unsigned long ret = 0;
  720. switch (port->index) {
  721. case 0:
  722. ret = AFI_PEX0_CTRL;
  723. break;
  724. case 1:
  725. ret = AFI_PEX1_CTRL;
  726. break;
  727. case 2:
  728. ret = port->pcie->soc->afi_pex2_ctrl;
  729. break;
  730. }
  731. return ret;
  732. }
  733. static void tegra_pcie_port_reset(struct tegra_pcie_port *port)
  734. {
  735. unsigned long ctrl = tegra_pcie_port_get_pex_ctrl(port);
  736. unsigned long value;
  737. /* pulse reset signel */
  738. value = afi_readl(port->pcie, ctrl);
  739. value &= ~AFI_PEX_CTRL_RST;
  740. afi_writel(port->pcie, value, ctrl);
  741. udelay(2000);
  742. value = afi_readl(port->pcie, ctrl);
  743. value |= AFI_PEX_CTRL_RST;
  744. afi_writel(port->pcie, value, ctrl);
  745. }
  746. static void tegra_pcie_port_enable(struct tegra_pcie_port *port)
  747. {
  748. struct tegra_pcie *pcie = port->pcie;
  749. const struct tegra_pcie_soc *soc = pcie->soc;
  750. unsigned long ctrl = tegra_pcie_port_get_pex_ctrl(port);
  751. unsigned long value;
  752. /* enable reference clock */
  753. value = afi_readl(pcie, ctrl);
  754. value |= AFI_PEX_CTRL_REFCLK_EN;
  755. if (pcie->soc->has_pex_clkreq_en)
  756. value |= AFI_PEX_CTRL_CLKREQ_EN;
  757. value |= AFI_PEX_CTRL_OVERRIDE_EN;
  758. afi_writel(pcie, value, ctrl);
  759. tegra_pcie_port_reset(port);
  760. if (soc->force_pca_enable) {
  761. value = rp_readl(port, RP_VEND_CTL2);
  762. value |= RP_VEND_CTL2_PCA_ENABLE;
  763. rp_writel(port, value, RP_VEND_CTL2);
  764. }
  765. /* configure the reference clock driver */
  766. pads_writel(pcie, soc->pads_refclk_cfg0, PADS_REFCLK_CFG0);
  767. if (soc->num_ports > 2)
  768. pads_writel(pcie, soc->pads_refclk_cfg1, PADS_REFCLK_CFG1);
  769. }
  770. static bool tegra_pcie_port_check_link(struct tegra_pcie_port *port)
  771. {
  772. unsigned int retries = 3;
  773. unsigned long value;
  774. value = rp_readl(port, RP_PRIV_MISC);
  775. value &= ~RP_PRIV_MISC_PRSNT_MAP_EP_ABSNT;
  776. value |= RP_PRIV_MISC_PRSNT_MAP_EP_PRSNT;
  777. rp_writel(port, value, RP_PRIV_MISC);
  778. do {
  779. unsigned int timeout = 200;
  780. do {
  781. value = rp_readl(port, RP_VEND_XP);
  782. if (value & RP_VEND_XP_DL_UP)
  783. break;
  784. udelay(2000);
  785. } while (--timeout);
  786. if (!timeout) {
  787. debug("link %u down, retrying\n", port->index);
  788. goto retry;
  789. }
  790. timeout = 200;
  791. do {
  792. value = rp_readl(port, RP_LINK_CONTROL_STATUS);
  793. if (value & RP_LINK_CONTROL_STATUS_DL_LINK_ACTIVE)
  794. return true;
  795. udelay(2000);
  796. } while (--timeout);
  797. retry:
  798. tegra_pcie_port_reset(port);
  799. } while (--retries);
  800. return false;
  801. }
  802. static void tegra_pcie_port_disable(struct tegra_pcie_port *port)
  803. {
  804. unsigned long ctrl = tegra_pcie_port_get_pex_ctrl(port);
  805. unsigned long value;
  806. /* assert port reset */
  807. value = afi_readl(port->pcie, ctrl);
  808. value &= ~AFI_PEX_CTRL_RST;
  809. afi_writel(port->pcie, value, ctrl);
  810. /* disable reference clock */
  811. value = afi_readl(port->pcie, ctrl);
  812. value &= ~AFI_PEX_CTRL_REFCLK_EN;
  813. afi_writel(port->pcie, value, ctrl);
  814. }
  815. static void tegra_pcie_port_free(struct tegra_pcie_port *port)
  816. {
  817. list_del(&port->list);
  818. free(port);
  819. }
  820. static int tegra_pcie_enable(struct tegra_pcie *pcie)
  821. {
  822. struct tegra_pcie_port *port, *tmp;
  823. list_for_each_entry_safe(port, tmp, &pcie->ports, list) {
  824. debug("probing port %u, using %u lanes\n", port->index,
  825. port->num_lanes);
  826. tegra_pcie_port_enable(port);
  827. if (tegra_pcie_port_check_link(port))
  828. continue;
  829. debug("link %u down, ignoring\n", port->index);
  830. tegra_pcie_port_disable(port);
  831. tegra_pcie_port_free(port);
  832. }
  833. return 0;
  834. }
  835. static const struct tegra_pcie_soc pci_tegra_soc[] = {
  836. [TEGRA20_PCIE] = {
  837. .num_ports = 2,
  838. .pads_pll_ctl = PADS_PLL_CTL_TEGRA20,
  839. .tx_ref_sel = PADS_PLL_CTL_TXCLKREF_DIV10,
  840. .pads_refclk_cfg0 = 0xfa5cfa5c,
  841. .has_pex_clkreq_en = false,
  842. .has_pex_bias_ctrl = false,
  843. .has_cml_clk = false,
  844. .has_gen2 = false,
  845. },
  846. [TEGRA30_PCIE] = {
  847. .num_ports = 3,
  848. .pads_pll_ctl = PADS_PLL_CTL_TEGRA30,
  849. .tx_ref_sel = PADS_PLL_CTL_TXCLKREF_BUF_EN,
  850. .afi_pex2_ctrl = AFI_PEX2_CTRL,
  851. .pads_refclk_cfg0 = 0xfa5cfa5c,
  852. .pads_refclk_cfg1 = 0xfa5cfa5c,
  853. .has_pex_clkreq_en = true,
  854. .has_pex_bias_ctrl = true,
  855. .has_cml_clk = true,
  856. .has_gen2 = false,
  857. },
  858. [TEGRA124_PCIE] = {
  859. .num_ports = 2,
  860. .pads_pll_ctl = PADS_PLL_CTL_TEGRA30,
  861. .tx_ref_sel = PADS_PLL_CTL_TXCLKREF_BUF_EN,
  862. .pads_refclk_cfg0 = 0x44ac44ac,
  863. .has_pex_clkreq_en = true,
  864. .has_pex_bias_ctrl = true,
  865. .has_cml_clk = true,
  866. .has_gen2 = true,
  867. },
  868. [TEGRA210_PCIE] = {
  869. .num_ports = 2,
  870. .pads_pll_ctl = PADS_PLL_CTL_TEGRA30,
  871. .tx_ref_sel = PADS_PLL_CTL_TXCLKREF_BUF_EN,
  872. .pads_refclk_cfg0 = 0x90b890b8,
  873. .has_pex_clkreq_en = true,
  874. .has_pex_bias_ctrl = true,
  875. .has_cml_clk = true,
  876. .has_gen2 = true,
  877. .force_pca_enable = true,
  878. },
  879. [TEGRA186_PCIE] = {
  880. .num_ports = 3,
  881. .afi_pex2_ctrl = AFI_PEX2_CTRL_T186,
  882. .pads_refclk_cfg0 = 0x80b880b8,
  883. .pads_refclk_cfg1 = 0x000480b8,
  884. .has_pex_clkreq_en = true,
  885. .has_pex_bias_ctrl = true,
  886. .has_gen2 = true,
  887. },
  888. };
  889. static int pci_tegra_ofdata_to_platdata(struct udevice *dev)
  890. {
  891. struct tegra_pcie *pcie = dev_get_priv(dev);
  892. enum tegra_pci_id id;
  893. id = dev_get_driver_data(dev);
  894. pcie->soc = &pci_tegra_soc[id];
  895. INIT_LIST_HEAD(&pcie->ports);
  896. if (tegra_pcie_parse_dt(dev, id, pcie))
  897. return -EINVAL;
  898. return 0;
  899. }
  900. static int pci_tegra_probe(struct udevice *dev)
  901. {
  902. struct tegra_pcie *pcie = dev_get_priv(dev);
  903. int err;
  904. #ifdef CONFIG_TEGRA186
  905. err = clk_get_by_name(dev, "afi", &pcie->clk_afi);
  906. if (err) {
  907. debug("clk_get_by_name(afi) failed: %d\n", err);
  908. return err;
  909. }
  910. err = clk_get_by_name(dev, "pex", &pcie->clk_pex);
  911. if (err) {
  912. debug("clk_get_by_name(pex) failed: %d\n", err);
  913. return err;
  914. }
  915. err = reset_get_by_name(dev, "afi", &pcie->reset_afi);
  916. if (err) {
  917. debug("reset_get_by_name(afi) failed: %d\n", err);
  918. return err;
  919. }
  920. err = reset_get_by_name(dev, "pex", &pcie->reset_pex);
  921. if (err) {
  922. debug("reset_get_by_name(pex) failed: %d\n", err);
  923. return err;
  924. }
  925. err = reset_get_by_name(dev, "pcie_x", &pcie->reset_pcie_x);
  926. if (err) {
  927. debug("reset_get_by_name(pcie_x) failed: %d\n", err);
  928. return err;
  929. }
  930. err = power_domain_get(dev, &pcie->pwrdom);
  931. if (err) {
  932. debug("power_domain_get() failed: %d\n", err);
  933. return err;
  934. }
  935. #endif
  936. err = tegra_pcie_power_on(pcie);
  937. if (err < 0) {
  938. pr_err("failed to power on");
  939. return err;
  940. }
  941. err = tegra_pcie_enable_controller(pcie);
  942. if (err < 0) {
  943. pr_err("failed to enable controller");
  944. return err;
  945. }
  946. err = tegra_pcie_setup_translations(dev);
  947. if (err < 0) {
  948. pr_err("failed to decode ranges");
  949. return err;
  950. }
  951. err = tegra_pcie_enable(pcie);
  952. if (err < 0) {
  953. pr_err("failed to enable PCIe");
  954. return err;
  955. }
  956. return 0;
  957. }
  958. static const struct dm_pci_ops pci_tegra_ops = {
  959. .read_config = pci_tegra_read_config,
  960. .write_config = pci_tegra_write_config,
  961. };
  962. static const struct udevice_id pci_tegra_ids[] = {
  963. { .compatible = "nvidia,tegra20-pcie", .data = TEGRA20_PCIE },
  964. { .compatible = "nvidia,tegra30-pcie", .data = TEGRA30_PCIE },
  965. { .compatible = "nvidia,tegra124-pcie", .data = TEGRA124_PCIE },
  966. { .compatible = "nvidia,tegra210-pcie", .data = TEGRA210_PCIE },
  967. { .compatible = "nvidia,tegra186-pcie", .data = TEGRA186_PCIE },
  968. { }
  969. };
  970. U_BOOT_DRIVER(pci_tegra) = {
  971. .name = "pci_tegra",
  972. .id = UCLASS_PCI,
  973. .of_match = pci_tegra_ids,
  974. .ops = &pci_tegra_ops,
  975. .ofdata_to_platdata = pci_tegra_ofdata_to_platdata,
  976. .probe = pci_tegra_probe,
  977. .priv_auto_alloc_size = sizeof(struct tegra_pcie),
  978. };