driver_pcicore.c 16 KB

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