driver_pcicore.c 15 KB

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