driver_pcicore.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. /*
  2. * Sonics Silicon Backplane
  3. * Broadcom PCI-core driver
  4. *
  5. * Copyright 2005, Broadcom Corporation
  6. * Copyright 2006, 2007, Michael Buesch <mb@bu3sch.de>
  7. *
  8. * Licensed under the GNU/GPL. See COPYING for details.
  9. */
  10. #include <linux/ssb/ssb.h>
  11. #include <linux/pci.h>
  12. #include <linux/delay.h>
  13. #include <linux/ssb/ssb_embedded.h>
  14. #include "ssb_private.h"
  15. static inline
  16. u32 pcicore_read32(struct ssb_pcicore *pc, u16 offset)
  17. {
  18. return ssb_read32(pc->dev, offset);
  19. }
  20. static inline
  21. void pcicore_write32(struct ssb_pcicore *pc, u16 offset, u32 value)
  22. {
  23. ssb_write32(pc->dev, offset, value);
  24. }
  25. static inline
  26. u16 pcicore_read16(struct ssb_pcicore *pc, u16 offset)
  27. {
  28. return ssb_read16(pc->dev, offset);
  29. }
  30. static inline
  31. void pcicore_write16(struct ssb_pcicore *pc, u16 offset, u16 value)
  32. {
  33. ssb_write16(pc->dev, offset, value);
  34. }
  35. /**************************************************
  36. * Code for hostmode operation.
  37. **************************************************/
  38. #ifdef CONFIG_SSB_PCICORE_HOSTMODE
  39. #include <asm/paccess.h>
  40. /* Probe a 32bit value on the bus and catch bus exceptions.
  41. * Returns nonzero on a bus exception.
  42. * This is MIPS specific */
  43. #define mips_busprobe32(val, addr) get_dbe((val), ((u32 *)(addr)))
  44. /* Assume one-hot slot wiring */
  45. #define SSB_PCI_SLOT_MAX 16
  46. /* Global lock is OK, as we won't have more than one extpci anyway. */
  47. static DEFINE_SPINLOCK(cfgspace_lock);
  48. /* Core to access the external PCI config space. Can only have one. */
  49. static struct ssb_pcicore *extpci_core;
  50. static u32 ssb_pcicore_pcibus_iobase = 0x100;
  51. static u32 ssb_pcicore_pcibus_membase = SSB_PCI_DMA;
  52. int pcibios_plat_dev_init(struct pci_dev *d)
  53. {
  54. struct resource *res;
  55. int pos, size;
  56. u32 *base;
  57. ssb_printk(KERN_INFO "PCI: Fixing up device %s\n",
  58. pci_name(d));
  59. /* Fix up resource bases */
  60. for (pos = 0; pos < 6; pos++) {
  61. res = &d->resource[pos];
  62. if (res->flags & IORESOURCE_IO)
  63. base = &ssb_pcicore_pcibus_iobase;
  64. else
  65. base = &ssb_pcicore_pcibus_membase;
  66. res->flags |= IORESOURCE_PCI_FIXED;
  67. if (res->end) {
  68. size = res->end - res->start + 1;
  69. if (*base & (size - 1))
  70. *base = (*base + size) & ~(size - 1);
  71. res->start = *base;
  72. res->end = res->start + size - 1;
  73. *base += size;
  74. pci_write_config_dword(d, PCI_BASE_ADDRESS_0 + (pos << 2), res->start);
  75. }
  76. /* Fix up PCI bridge BAR0 only */
  77. if (d->bus->number == 0 && PCI_SLOT(d->devfn) == 0)
  78. break;
  79. }
  80. /* Fix up interrupt lines */
  81. d->irq = ssb_mips_irq(extpci_core->dev) + 2;
  82. pci_write_config_byte(d, PCI_INTERRUPT_LINE, d->irq);
  83. return 0;
  84. }
  85. static void __init ssb_fixup_pcibridge(struct pci_dev *dev)
  86. {
  87. u8 lat;
  88. if (dev->bus->number != 0 || PCI_SLOT(dev->devfn) != 0)
  89. return;
  90. ssb_printk(KERN_INFO "PCI: Fixing up bridge %s\n", pci_name(dev));
  91. /* Enable PCI bridge bus mastering and memory space */
  92. pci_set_master(dev);
  93. pcibios_enable_device(dev, ~0);
  94. /* Enable PCI bridge BAR1 prefetch and burst */
  95. pci_write_config_dword(dev, SSB_BAR1_CONTROL, 3);
  96. /* Make sure our latency is high enough to handle the devices behind us */
  97. lat = 168;
  98. ssb_printk(KERN_INFO "PCI: Fixing latency timer of device %s to %u\n",
  99. pci_name(dev), lat);
  100. pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat);
  101. }
  102. DECLARE_PCI_FIXUP_EARLY(PCI_ANY_ID, PCI_ANY_ID, ssb_fixup_pcibridge);
  103. int __init pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
  104. {
  105. return ssb_mips_irq(extpci_core->dev) + 2;
  106. }
  107. static u32 get_cfgspace_addr(struct ssb_pcicore *pc,
  108. unsigned int bus, unsigned int dev,
  109. unsigned int func, unsigned int off)
  110. {
  111. u32 addr = 0;
  112. u32 tmp;
  113. /* We do only have one cardbus device behind the bridge. */
  114. if (pc->cardbusmode && (dev >= 1))
  115. goto out;
  116. if (bus == 0) {
  117. /* Type 0 transaction */
  118. if (unlikely(dev >= SSB_PCI_SLOT_MAX))
  119. goto out;
  120. /* Slide the window */
  121. tmp = SSB_PCICORE_SBTOPCI_CFG0;
  122. tmp |= ((1 << (dev + 16)) & SSB_PCICORE_SBTOPCI1_MASK);
  123. pcicore_write32(pc, SSB_PCICORE_SBTOPCI1, tmp);
  124. /* Calculate the address */
  125. addr = SSB_PCI_CFG;
  126. addr |= ((1 << (dev + 16)) & ~SSB_PCICORE_SBTOPCI1_MASK);
  127. addr |= (func << 8);
  128. addr |= (off & ~3);
  129. } else {
  130. /* Type 1 transaction */
  131. pcicore_write32(pc, SSB_PCICORE_SBTOPCI1,
  132. SSB_PCICORE_SBTOPCI_CFG1);
  133. /* Calculate the address */
  134. addr = SSB_PCI_CFG;
  135. addr |= (bus << 16);
  136. addr |= (dev << 11);
  137. addr |= (func << 8);
  138. addr |= (off & ~3);
  139. }
  140. out:
  141. return addr;
  142. }
  143. static int ssb_extpci_read_config(struct ssb_pcicore *pc,
  144. unsigned int bus, unsigned int dev,
  145. unsigned int func, unsigned int off,
  146. void *buf, int len)
  147. {
  148. int err = -EINVAL;
  149. u32 addr, val;
  150. void __iomem *mmio;
  151. SSB_WARN_ON(!pc->hostmode);
  152. if (unlikely(len != 1 && len != 2 && len != 4))
  153. goto out;
  154. addr = get_cfgspace_addr(pc, bus, dev, func, off);
  155. if (unlikely(!addr))
  156. goto out;
  157. err = -ENOMEM;
  158. mmio = ioremap_nocache(addr, len);
  159. if (!mmio)
  160. goto out;
  161. if (mips_busprobe32(val, mmio)) {
  162. val = 0xffffffff;
  163. goto unmap;
  164. }
  165. val = readl(mmio);
  166. val >>= (8 * (off & 3));
  167. switch (len) {
  168. case 1:
  169. *((u8 *)buf) = (u8)val;
  170. break;
  171. case 2:
  172. *((u16 *)buf) = (u16)val;
  173. break;
  174. case 4:
  175. *((u32 *)buf) = (u32)val;
  176. break;
  177. }
  178. err = 0;
  179. unmap:
  180. iounmap(mmio);
  181. out:
  182. return err;
  183. }
  184. static int ssb_extpci_write_config(struct ssb_pcicore *pc,
  185. unsigned int bus, unsigned int dev,
  186. unsigned int func, unsigned int off,
  187. const void *buf, int len)
  188. {
  189. int err = -EINVAL;
  190. u32 addr, val = 0;
  191. void __iomem *mmio;
  192. SSB_WARN_ON(!pc->hostmode);
  193. if (unlikely(len != 1 && len != 2 && len != 4))
  194. goto out;
  195. addr = get_cfgspace_addr(pc, bus, dev, func, off);
  196. if (unlikely(!addr))
  197. goto out;
  198. err = -ENOMEM;
  199. mmio = ioremap_nocache(addr, len);
  200. if (!mmio)
  201. goto out;
  202. if (mips_busprobe32(val, mmio)) {
  203. val = 0xffffffff;
  204. goto unmap;
  205. }
  206. switch (len) {
  207. case 1:
  208. val = readl(mmio);
  209. val &= ~(0xFF << (8 * (off & 3)));
  210. val |= *((const u8 *)buf) << (8 * (off & 3));
  211. break;
  212. case 2:
  213. val = readl(mmio);
  214. val &= ~(0xFFFF << (8 * (off & 3)));
  215. val |= *((const u16 *)buf) << (8 * (off & 3));
  216. break;
  217. case 4:
  218. val = *((const u32 *)buf);
  219. break;
  220. }
  221. writel(val, mmio);
  222. err = 0;
  223. unmap:
  224. iounmap(mmio);
  225. out:
  226. return err;
  227. }
  228. static int ssb_pcicore_read_config(struct pci_bus *bus, unsigned int devfn,
  229. int reg, int size, u32 *val)
  230. {
  231. unsigned long flags;
  232. int err;
  233. spin_lock_irqsave(&cfgspace_lock, flags);
  234. err = ssb_extpci_read_config(extpci_core, bus->number, PCI_SLOT(devfn),
  235. PCI_FUNC(devfn), reg, val, size);
  236. spin_unlock_irqrestore(&cfgspace_lock, flags);
  237. return err ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
  238. }
  239. static int ssb_pcicore_write_config(struct pci_bus *bus, unsigned int devfn,
  240. int reg, int size, u32 val)
  241. {
  242. unsigned long flags;
  243. int err;
  244. spin_lock_irqsave(&cfgspace_lock, flags);
  245. err = ssb_extpci_write_config(extpci_core, bus->number, PCI_SLOT(devfn),
  246. PCI_FUNC(devfn), reg, &val, size);
  247. spin_unlock_irqrestore(&cfgspace_lock, flags);
  248. return err ? PCIBIOS_DEVICE_NOT_FOUND : PCIBIOS_SUCCESSFUL;
  249. }
  250. static struct pci_ops ssb_pcicore_pciops = {
  251. .read = ssb_pcicore_read_config,
  252. .write = ssb_pcicore_write_config,
  253. };
  254. static struct resource ssb_pcicore_mem_resource = {
  255. .name = "SSB PCIcore external memory",
  256. .start = SSB_PCI_DMA,
  257. .end = SSB_PCI_DMA + SSB_PCI_DMA_SZ - 1,
  258. .flags = IORESOURCE_MEM | IORESOURCE_PCI_FIXED,
  259. };
  260. static struct resource ssb_pcicore_io_resource = {
  261. .name = "SSB PCIcore external I/O",
  262. .start = 0x100,
  263. .end = 0x7FF,
  264. .flags = IORESOURCE_IO | IORESOURCE_PCI_FIXED,
  265. };
  266. static struct pci_controller ssb_pcicore_controller = {
  267. .pci_ops = &ssb_pcicore_pciops,
  268. .io_resource = &ssb_pcicore_io_resource,
  269. .mem_resource = &ssb_pcicore_mem_resource,
  270. .mem_offset = 0x24000000,
  271. };
  272. static void ssb_pcicore_init_hostmode(struct ssb_pcicore *pc)
  273. {
  274. u32 val;
  275. if (WARN_ON(extpci_core))
  276. return;
  277. extpci_core = pc;
  278. ssb_dprintk(KERN_INFO PFX "PCIcore in host mode found\n");
  279. /* Reset devices on the external PCI bus */
  280. val = SSB_PCICORE_CTL_RST_OE;
  281. val |= SSB_PCICORE_CTL_CLK_OE;
  282. pcicore_write32(pc, SSB_PCICORE_CTL, val);
  283. val |= SSB_PCICORE_CTL_CLK; /* Clock on */
  284. pcicore_write32(pc, SSB_PCICORE_CTL, val);
  285. udelay(150); /* Assertion time demanded by the PCI standard */
  286. val |= SSB_PCICORE_CTL_RST; /* Deassert RST# */
  287. pcicore_write32(pc, SSB_PCICORE_CTL, val);
  288. val = SSB_PCICORE_ARBCTL_INTERN;
  289. pcicore_write32(pc, SSB_PCICORE_ARBCTL, val);
  290. udelay(1); /* Assertion time demanded by the PCI standard */
  291. if (pc->dev->bus->has_cardbus_slot) {
  292. ssb_dprintk(KERN_INFO PFX "CardBus slot detected\n");
  293. pc->cardbusmode = 1;
  294. /* GPIO 1 resets the bridge */
  295. ssb_gpio_out(pc->dev->bus, 1, 1);
  296. ssb_gpio_outen(pc->dev->bus, 1, 1);
  297. pcicore_write16(pc, SSB_PCICORE_SPROM(0),
  298. pcicore_read16(pc, SSB_PCICORE_SPROM(0))
  299. | 0x0400);
  300. }
  301. /* 64MB I/O window */
  302. pcicore_write32(pc, SSB_PCICORE_SBTOPCI0,
  303. SSB_PCICORE_SBTOPCI_IO);
  304. /* 64MB config space */
  305. pcicore_write32(pc, SSB_PCICORE_SBTOPCI1,
  306. SSB_PCICORE_SBTOPCI_CFG0);
  307. /* 1GB memory window */
  308. pcicore_write32(pc, SSB_PCICORE_SBTOPCI2,
  309. SSB_PCICORE_SBTOPCI_MEM | SSB_PCI_DMA);
  310. /* Enable PCI bridge BAR0 prefetch and burst */
  311. val = PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
  312. ssb_extpci_write_config(pc, 0, 0, 0, PCI_COMMAND, &val, 2);
  313. /* Clear error conditions */
  314. val = 0;
  315. ssb_extpci_write_config(pc, 0, 0, 0, PCI_STATUS, &val, 2);
  316. /* Enable PCI interrupts */
  317. pcicore_write32(pc, SSB_PCICORE_IMASK,
  318. SSB_PCICORE_IMASK_INTA);
  319. /* Ok, ready to run, register it to the system.
  320. * The following needs change, if we want to port hostmode
  321. * to non-MIPS platform. */
  322. ssb_pcicore_controller.io_map_base = (unsigned long)ioremap_nocache(SSB_PCI_MEM, 0x04000000);
  323. set_io_port_base(ssb_pcicore_controller.io_map_base);
  324. /* Give some time to the PCI controller to configure itself with the new
  325. * values. Not waiting at this point causes crashes of the machine. */
  326. mdelay(10);
  327. register_pci_controller(&ssb_pcicore_controller);
  328. }
  329. static int pcicore_is_in_hostmode(struct ssb_pcicore *pc)
  330. {
  331. struct ssb_bus *bus = pc->dev->bus;
  332. u16 chipid_top;
  333. u32 tmp;
  334. chipid_top = (bus->chip_id & 0xFF00);
  335. if (chipid_top != 0x4700 &&
  336. chipid_top != 0x5300)
  337. return 0;
  338. if (bus->sprom.r1.boardflags_lo & SSB_PCICORE_BFL_NOPCI)
  339. return 0;
  340. /* The 200-pin BCM4712 package does not bond out PCI. Even when
  341. * PCI is bonded out, some boards may leave the pins floating. */
  342. if (bus->chip_id == 0x4712) {
  343. if (bus->chip_package == SSB_CHIPPACK_BCM4712S)
  344. return 0;
  345. if (bus->chip_package == SSB_CHIPPACK_BCM4712M)
  346. return 0;
  347. }
  348. if (bus->chip_id == 0x5350)
  349. return 0;
  350. return !mips_busprobe32(tmp, (bus->mmio + (pc->dev->core_index * SSB_CORE_SIZE)));
  351. }
  352. #endif /* CONFIG_SSB_PCICORE_HOSTMODE */
  353. /**************************************************
  354. * Generic and Clientmode operation code.
  355. **************************************************/
  356. static void ssb_pcicore_init_clientmode(struct ssb_pcicore *pc)
  357. {
  358. /* Disable PCI interrupts. */
  359. ssb_write32(pc->dev, SSB_INTVEC, 0);
  360. }
  361. void ssb_pcicore_init(struct ssb_pcicore *pc)
  362. {
  363. struct ssb_device *dev = pc->dev;
  364. struct ssb_bus *bus;
  365. if (!dev)
  366. return;
  367. bus = dev->bus;
  368. if (!ssb_device_is_enabled(dev))
  369. ssb_device_enable(dev, 0);
  370. #ifdef CONFIG_SSB_PCICORE_HOSTMODE
  371. pc->hostmode = pcicore_is_in_hostmode(pc);
  372. if (pc->hostmode)
  373. ssb_pcicore_init_hostmode(pc);
  374. #endif /* CONFIG_SSB_PCICORE_HOSTMODE */
  375. if (!pc->hostmode)
  376. ssb_pcicore_init_clientmode(pc);
  377. }
  378. static u32 ssb_pcie_read(struct ssb_pcicore *pc, u32 address)
  379. {
  380. pcicore_write32(pc, 0x130, address);
  381. return pcicore_read32(pc, 0x134);
  382. }
  383. static void ssb_pcie_write(struct ssb_pcicore *pc, u32 address, u32 data)
  384. {
  385. pcicore_write32(pc, 0x130, address);
  386. pcicore_write32(pc, 0x134, data);
  387. }
  388. static void ssb_pcie_mdio_write(struct ssb_pcicore *pc, u8 device,
  389. u8 address, u16 data)
  390. {
  391. const u16 mdio_control = 0x128;
  392. const u16 mdio_data = 0x12C;
  393. u32 v;
  394. int i;
  395. v = 0x80; /* Enable Preamble Sequence */
  396. v |= 0x2; /* MDIO Clock Divisor */
  397. pcicore_write32(pc, mdio_control, v);
  398. v = (1 << 30); /* Start of Transaction */
  399. v |= (1 << 28); /* Write Transaction */
  400. v |= (1 << 17); /* Turnaround */
  401. v |= (u32)device << 22;
  402. v |= (u32)address << 18;
  403. v |= data;
  404. pcicore_write32(pc, mdio_data, v);
  405. /* Wait for the device to complete the transaction */
  406. udelay(10);
  407. for (i = 0; i < 10; i++) {
  408. v = pcicore_read32(pc, mdio_control);
  409. if (v & 0x100 /* Trans complete */)
  410. break;
  411. msleep(1);
  412. }
  413. pcicore_write32(pc, mdio_control, 0);
  414. }
  415. static void ssb_broadcast_value(struct ssb_device *dev,
  416. u32 address, u32 data)
  417. {
  418. /* This is used for both, PCI and ChipCommon core, so be careful. */
  419. BUILD_BUG_ON(SSB_PCICORE_BCAST_ADDR != SSB_CHIPCO_BCAST_ADDR);
  420. BUILD_BUG_ON(SSB_PCICORE_BCAST_DATA != SSB_CHIPCO_BCAST_DATA);
  421. ssb_write32(dev, SSB_PCICORE_BCAST_ADDR, address);
  422. ssb_read32(dev, SSB_PCICORE_BCAST_ADDR); /* flush */
  423. ssb_write32(dev, SSB_PCICORE_BCAST_DATA, data);
  424. ssb_read32(dev, SSB_PCICORE_BCAST_DATA); /* flush */
  425. }
  426. static void ssb_commit_settings(struct ssb_bus *bus)
  427. {
  428. struct ssb_device *dev;
  429. dev = bus->chipco.dev ? bus->chipco.dev : bus->pcicore.dev;
  430. if (WARN_ON(!dev))
  431. return;
  432. /* This forces an update of the cached registers. */
  433. ssb_broadcast_value(dev, 0xFD8, 0);
  434. }
  435. int ssb_pcicore_dev_irqvecs_enable(struct ssb_pcicore *pc,
  436. struct ssb_device *dev)
  437. {
  438. struct ssb_device *pdev = pc->dev;
  439. struct ssb_bus *bus;
  440. int err = 0;
  441. u32 tmp;
  442. might_sleep();
  443. if (!pdev)
  444. goto out;
  445. bus = pdev->bus;
  446. /* Enable interrupts for this device. */
  447. if (bus->host_pci &&
  448. ((pdev->id.revision >= 6) || (pdev->id.coreid == SSB_DEV_PCIE))) {
  449. u32 coremask;
  450. /* Calculate the "coremask" for the device. */
  451. coremask = (1 << dev->core_index);
  452. err = pci_read_config_dword(bus->host_pci, SSB_PCI_IRQMASK, &tmp);
  453. if (err)
  454. goto out;
  455. tmp |= coremask << 8;
  456. err = pci_write_config_dword(bus->host_pci, SSB_PCI_IRQMASK, tmp);
  457. if (err)
  458. goto out;
  459. } else {
  460. u32 intvec;
  461. intvec = ssb_read32(pdev, SSB_INTVEC);
  462. if ((bus->chip_id & 0xFF00) == 0x4400) {
  463. /* Workaround: On the BCM44XX the BPFLAG routing
  464. * bit is wrong. Use a hardcoded constant. */
  465. intvec |= 0x00000002;
  466. } else {
  467. tmp = ssb_read32(dev, SSB_TPSFLAG);
  468. tmp &= SSB_TPSFLAG_BPFLAG;
  469. intvec |= tmp;
  470. }
  471. ssb_write32(pdev, SSB_INTVEC, intvec);
  472. }
  473. /* Setup PCIcore operation. */
  474. if (pc->setup_done)
  475. goto out;
  476. if (pdev->id.coreid == SSB_DEV_PCI) {
  477. tmp = pcicore_read32(pc, SSB_PCICORE_SBTOPCI2);
  478. tmp |= SSB_PCICORE_SBTOPCI_PREF;
  479. tmp |= SSB_PCICORE_SBTOPCI_BURST;
  480. pcicore_write32(pc, SSB_PCICORE_SBTOPCI2, tmp);
  481. if (pdev->id.revision < 5) {
  482. tmp = ssb_read32(pdev, SSB_IMCFGLO);
  483. tmp &= ~SSB_IMCFGLO_SERTO;
  484. tmp |= 2;
  485. tmp &= ~SSB_IMCFGLO_REQTO;
  486. tmp |= 3 << SSB_IMCFGLO_REQTO_SHIFT;
  487. ssb_write32(pdev, SSB_IMCFGLO, tmp);
  488. ssb_commit_settings(bus);
  489. } else if (pdev->id.revision >= 11) {
  490. tmp = pcicore_read32(pc, SSB_PCICORE_SBTOPCI2);
  491. tmp |= SSB_PCICORE_SBTOPCI_MRM;
  492. pcicore_write32(pc, SSB_PCICORE_SBTOPCI2, tmp);
  493. }
  494. } else {
  495. WARN_ON(pdev->id.coreid != SSB_DEV_PCIE);
  496. //TODO: Better make defines for all these magic PCIE values.
  497. if ((pdev->id.revision == 0) || (pdev->id.revision == 1)) {
  498. /* TLP Workaround register. */
  499. tmp = ssb_pcie_read(pc, 0x4);
  500. tmp |= 0x8;
  501. ssb_pcie_write(pc, 0x4, tmp);
  502. }
  503. if (pdev->id.revision == 0) {
  504. const u8 serdes_rx_device = 0x1F;
  505. ssb_pcie_mdio_write(pc, serdes_rx_device,
  506. 2 /* Timer */, 0x8128);
  507. ssb_pcie_mdio_write(pc, serdes_rx_device,
  508. 6 /* CDR */, 0x0100);
  509. ssb_pcie_mdio_write(pc, serdes_rx_device,
  510. 7 /* CDR BW */, 0x1466);
  511. } else if (pdev->id.revision == 1) {
  512. /* DLLP Link Control register. */
  513. tmp = ssb_pcie_read(pc, 0x100);
  514. tmp |= 0x40;
  515. ssb_pcie_write(pc, 0x100, tmp);
  516. }
  517. }
  518. pc->setup_done = 1;
  519. out:
  520. return err;
  521. }
  522. EXPORT_SYMBOL(ssb_pcicore_dev_irqvecs_enable);