driver_pcicore.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  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. .mem_offset = 0x24000000,
  214. };
  215. static u32 ssb_pcicore_pcibus_iobase = 0x100;
  216. static u32 ssb_pcicore_pcibus_membase = SSB_PCI_DMA;
  217. /* This function is called when doing a pci_enable_device().
  218. * We must first check if the device is a device on the PCI-core bridge. */
  219. int ssb_pcicore_plat_dev_init(struct pci_dev *d)
  220. {
  221. struct resource *res;
  222. int pos, size;
  223. u32 *base;
  224. if (d->bus->ops != &ssb_pcicore_pciops) {
  225. /* This is not a device on the PCI-core bridge. */
  226. return -ENODEV;
  227. }
  228. ssb_printk(KERN_INFO "PCI: Fixing up device %s\n",
  229. pci_name(d));
  230. /* Fix up resource bases */
  231. for (pos = 0; pos < 6; pos++) {
  232. res = &d->resource[pos];
  233. if (res->flags & IORESOURCE_IO)
  234. base = &ssb_pcicore_pcibus_iobase;
  235. else
  236. base = &ssb_pcicore_pcibus_membase;
  237. res->flags |= IORESOURCE_PCI_FIXED;
  238. if (res->end) {
  239. size = res->end - res->start + 1;
  240. if (*base & (size - 1))
  241. *base = (*base + size) & ~(size - 1);
  242. res->start = *base;
  243. res->end = res->start + size - 1;
  244. *base += size;
  245. pci_write_config_dword(d, PCI_BASE_ADDRESS_0 + (pos << 2), res->start);
  246. }
  247. /* Fix up PCI bridge BAR0 only */
  248. if (d->bus->number == 0 && PCI_SLOT(d->devfn) == 0)
  249. break;
  250. }
  251. /* Fix up interrupt lines */
  252. d->irq = ssb_mips_irq(extpci_core->dev) + 2;
  253. pci_write_config_byte(d, PCI_INTERRUPT_LINE, d->irq);
  254. return 0;
  255. }
  256. /* Early PCI fixup for a device on the PCI-core bridge. */
  257. static void ssb_pcicore_fixup_pcibridge(struct pci_dev *dev)
  258. {
  259. u8 lat;
  260. if (dev->bus->ops != &ssb_pcicore_pciops) {
  261. /* This is not a device on the PCI-core bridge. */
  262. return;
  263. }
  264. if (dev->bus->number != 0 || PCI_SLOT(dev->devfn) != 0)
  265. return;
  266. ssb_printk(KERN_INFO "PCI: Fixing up bridge %s\n", pci_name(dev));
  267. /* Enable PCI bridge bus mastering and memory space */
  268. pci_set_master(dev);
  269. if (pcibios_enable_device(dev, ~0) < 0) {
  270. ssb_printk(KERN_ERR "PCI: SSB bridge enable failed\n");
  271. return;
  272. }
  273. /* Enable PCI bridge BAR1 prefetch and burst */
  274. pci_write_config_dword(dev, SSB_BAR1_CONTROL, 3);
  275. /* Make sure our latency is high enough to handle the devices behind us */
  276. lat = 168;
  277. ssb_printk(KERN_INFO "PCI: Fixing latency timer of device %s to %u\n",
  278. pci_name(dev), lat);
  279. pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat);
  280. }
  281. DECLARE_PCI_FIXUP_EARLY(PCI_ANY_ID, PCI_ANY_ID, ssb_pcicore_fixup_pcibridge);
  282. /* PCI device IRQ mapping. */
  283. int ssb_pcicore_pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
  284. {
  285. if (dev->bus->ops != &ssb_pcicore_pciops) {
  286. /* This is not a device on the PCI-core bridge. */
  287. return -ENODEV;
  288. }
  289. return ssb_mips_irq(extpci_core->dev) + 2;
  290. }
  291. static void ssb_pcicore_init_hostmode(struct ssb_pcicore *pc)
  292. {
  293. u32 val;
  294. if (WARN_ON(extpci_core))
  295. return;
  296. extpci_core = pc;
  297. ssb_dprintk(KERN_INFO PFX "PCIcore in host mode found\n");
  298. /* Reset devices on the external PCI bus */
  299. val = SSB_PCICORE_CTL_RST_OE;
  300. val |= SSB_PCICORE_CTL_CLK_OE;
  301. pcicore_write32(pc, SSB_PCICORE_CTL, val);
  302. val |= SSB_PCICORE_CTL_CLK; /* Clock on */
  303. pcicore_write32(pc, SSB_PCICORE_CTL, val);
  304. udelay(150); /* Assertion time demanded by the PCI standard */
  305. val |= SSB_PCICORE_CTL_RST; /* Deassert RST# */
  306. pcicore_write32(pc, SSB_PCICORE_CTL, val);
  307. val = SSB_PCICORE_ARBCTL_INTERN;
  308. pcicore_write32(pc, SSB_PCICORE_ARBCTL, val);
  309. udelay(1); /* Assertion time demanded by the PCI standard */
  310. if (pc->dev->bus->has_cardbus_slot) {
  311. ssb_dprintk(KERN_INFO PFX "CardBus slot detected\n");
  312. pc->cardbusmode = 1;
  313. /* GPIO 1 resets the bridge */
  314. ssb_gpio_out(pc->dev->bus, 1, 1);
  315. ssb_gpio_outen(pc->dev->bus, 1, 1);
  316. pcicore_write16(pc, SSB_PCICORE_SPROM(0),
  317. pcicore_read16(pc, SSB_PCICORE_SPROM(0))
  318. | 0x0400);
  319. }
  320. /* 64MB I/O window */
  321. pcicore_write32(pc, SSB_PCICORE_SBTOPCI0,
  322. SSB_PCICORE_SBTOPCI_IO);
  323. /* 64MB config space */
  324. pcicore_write32(pc, SSB_PCICORE_SBTOPCI1,
  325. SSB_PCICORE_SBTOPCI_CFG0);
  326. /* 1GB memory window */
  327. pcicore_write32(pc, SSB_PCICORE_SBTOPCI2,
  328. SSB_PCICORE_SBTOPCI_MEM | SSB_PCI_DMA);
  329. /* Enable PCI bridge BAR0 prefetch and burst */
  330. val = PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
  331. ssb_extpci_write_config(pc, 0, 0, 0, PCI_COMMAND, &val, 2);
  332. /* Clear error conditions */
  333. val = 0;
  334. ssb_extpci_write_config(pc, 0, 0, 0, PCI_STATUS, &val, 2);
  335. /* Enable PCI interrupts */
  336. pcicore_write32(pc, SSB_PCICORE_IMASK,
  337. SSB_PCICORE_IMASK_INTA);
  338. /* Ok, ready to run, register it to the system.
  339. * The following needs change, if we want to port hostmode
  340. * to non-MIPS platform. */
  341. ssb_pcicore_controller.io_map_base = (unsigned long)ioremap_nocache(SSB_PCI_MEM, 0x04000000);
  342. set_io_port_base(ssb_pcicore_controller.io_map_base);
  343. /* Give some time to the PCI controller to configure itself with the new
  344. * values. Not waiting at this point causes crashes of the machine. */
  345. mdelay(10);
  346. register_pci_controller(&ssb_pcicore_controller);
  347. }
  348. static int pcicore_is_in_hostmode(struct ssb_pcicore *pc)
  349. {
  350. struct ssb_bus *bus = pc->dev->bus;
  351. u16 chipid_top;
  352. u32 tmp;
  353. chipid_top = (bus->chip_id & 0xFF00);
  354. if (chipid_top != 0x4700 &&
  355. chipid_top != 0x5300)
  356. return 0;
  357. if (bus->sprom.boardflags_lo & SSB_PCICORE_BFL_NOPCI)
  358. return 0;
  359. /* The 200-pin BCM4712 package does not bond out PCI. Even when
  360. * PCI is bonded out, some boards may leave the pins floating. */
  361. if (bus->chip_id == 0x4712) {
  362. if (bus->chip_package == SSB_CHIPPACK_BCM4712S)
  363. return 0;
  364. if (bus->chip_package == SSB_CHIPPACK_BCM4712M)
  365. return 0;
  366. }
  367. if (bus->chip_id == 0x5350)
  368. return 0;
  369. return !mips_busprobe32(tmp, (bus->mmio + (pc->dev->core_index * SSB_CORE_SIZE)));
  370. }
  371. #endif /* CONFIG_SSB_PCICORE_HOSTMODE */
  372. /**************************************************
  373. * Generic and Clientmode operation code.
  374. **************************************************/
  375. static void ssb_pcicore_init_clientmode(struct ssb_pcicore *pc)
  376. {
  377. /* Disable PCI interrupts. */
  378. ssb_write32(pc->dev, SSB_INTVEC, 0);
  379. }
  380. void ssb_pcicore_init(struct ssb_pcicore *pc)
  381. {
  382. struct ssb_device *dev = pc->dev;
  383. struct ssb_bus *bus;
  384. if (!dev)
  385. return;
  386. bus = dev->bus;
  387. if (!ssb_device_is_enabled(dev))
  388. ssb_device_enable(dev, 0);
  389. #ifdef CONFIG_SSB_PCICORE_HOSTMODE
  390. pc->hostmode = pcicore_is_in_hostmode(pc);
  391. if (pc->hostmode)
  392. ssb_pcicore_init_hostmode(pc);
  393. #endif /* CONFIG_SSB_PCICORE_HOSTMODE */
  394. if (!pc->hostmode)
  395. ssb_pcicore_init_clientmode(pc);
  396. }
  397. static u32 ssb_pcie_read(struct ssb_pcicore *pc, u32 address)
  398. {
  399. pcicore_write32(pc, 0x130, address);
  400. return pcicore_read32(pc, 0x134);
  401. }
  402. static void ssb_pcie_write(struct ssb_pcicore *pc, u32 address, u32 data)
  403. {
  404. pcicore_write32(pc, 0x130, address);
  405. pcicore_write32(pc, 0x134, data);
  406. }
  407. static void ssb_pcie_mdio_write(struct ssb_pcicore *pc, u8 device,
  408. u8 address, u16 data)
  409. {
  410. const u16 mdio_control = 0x128;
  411. const u16 mdio_data = 0x12C;
  412. u32 v;
  413. int i;
  414. v = 0x80; /* Enable Preamble Sequence */
  415. v |= 0x2; /* MDIO Clock Divisor */
  416. pcicore_write32(pc, mdio_control, v);
  417. v = (1 << 30); /* Start of Transaction */
  418. v |= (1 << 28); /* Write Transaction */
  419. v |= (1 << 17); /* Turnaround */
  420. v |= (u32)device << 22;
  421. v |= (u32)address << 18;
  422. v |= data;
  423. pcicore_write32(pc, mdio_data, v);
  424. /* Wait for the device to complete the transaction */
  425. udelay(10);
  426. for (i = 0; i < 10; i++) {
  427. v = pcicore_read32(pc, mdio_control);
  428. if (v & 0x100 /* Trans complete */)
  429. break;
  430. msleep(1);
  431. }
  432. pcicore_write32(pc, mdio_control, 0);
  433. }
  434. static void ssb_broadcast_value(struct ssb_device *dev,
  435. u32 address, u32 data)
  436. {
  437. /* This is used for both, PCI and ChipCommon core, so be careful. */
  438. BUILD_BUG_ON(SSB_PCICORE_BCAST_ADDR != SSB_CHIPCO_BCAST_ADDR);
  439. BUILD_BUG_ON(SSB_PCICORE_BCAST_DATA != SSB_CHIPCO_BCAST_DATA);
  440. ssb_write32(dev, SSB_PCICORE_BCAST_ADDR, address);
  441. ssb_read32(dev, SSB_PCICORE_BCAST_ADDR); /* flush */
  442. ssb_write32(dev, SSB_PCICORE_BCAST_DATA, data);
  443. ssb_read32(dev, SSB_PCICORE_BCAST_DATA); /* flush */
  444. }
  445. static void ssb_commit_settings(struct ssb_bus *bus)
  446. {
  447. struct ssb_device *dev;
  448. dev = bus->chipco.dev ? bus->chipco.dev : bus->pcicore.dev;
  449. if (WARN_ON(!dev))
  450. return;
  451. /* This forces an update of the cached registers. */
  452. ssb_broadcast_value(dev, 0xFD8, 0);
  453. }
  454. int ssb_pcicore_dev_irqvecs_enable(struct ssb_pcicore *pc,
  455. struct ssb_device *dev)
  456. {
  457. struct ssb_device *pdev = pc->dev;
  458. struct ssb_bus *bus;
  459. int err = 0;
  460. u32 tmp;
  461. if (dev->bus->bustype != SSB_BUSTYPE_PCI) {
  462. /* This SSB device is not on a PCI host-bus. So the IRQs are
  463. * not routed through the PCI core.
  464. * So we must not enable routing through the PCI core. */
  465. goto out;
  466. }
  467. if (!pdev)
  468. goto out;
  469. bus = pdev->bus;
  470. might_sleep_if(pdev->id.coreid != SSB_DEV_PCI);
  471. /* Enable interrupts for this device. */
  472. if (bus->host_pci &&
  473. ((pdev->id.revision >= 6) || (pdev->id.coreid == SSB_DEV_PCIE))) {
  474. u32 coremask;
  475. /* Calculate the "coremask" for the device. */
  476. coremask = (1 << dev->core_index);
  477. err = pci_read_config_dword(bus->host_pci, SSB_PCI_IRQMASK, &tmp);
  478. if (err)
  479. goto out;
  480. tmp |= coremask << 8;
  481. err = pci_write_config_dword(bus->host_pci, SSB_PCI_IRQMASK, tmp);
  482. if (err)
  483. goto out;
  484. } else {
  485. u32 intvec;
  486. intvec = ssb_read32(pdev, SSB_INTVEC);
  487. tmp = ssb_read32(dev, SSB_TPSFLAG);
  488. tmp &= SSB_TPSFLAG_BPFLAG;
  489. intvec |= (1 << tmp);
  490. ssb_write32(pdev, SSB_INTVEC, intvec);
  491. }
  492. /* Setup PCIcore operation. */
  493. if (pc->setup_done)
  494. goto out;
  495. if (pdev->id.coreid == SSB_DEV_PCI) {
  496. tmp = pcicore_read32(pc, SSB_PCICORE_SBTOPCI2);
  497. tmp |= SSB_PCICORE_SBTOPCI_PREF;
  498. tmp |= SSB_PCICORE_SBTOPCI_BURST;
  499. pcicore_write32(pc, SSB_PCICORE_SBTOPCI2, tmp);
  500. if (pdev->id.revision < 5) {
  501. tmp = ssb_read32(pdev, SSB_IMCFGLO);
  502. tmp &= ~SSB_IMCFGLO_SERTO;
  503. tmp |= 2;
  504. tmp &= ~SSB_IMCFGLO_REQTO;
  505. tmp |= 3 << SSB_IMCFGLO_REQTO_SHIFT;
  506. ssb_write32(pdev, SSB_IMCFGLO, tmp);
  507. ssb_commit_settings(bus);
  508. } else if (pdev->id.revision >= 11) {
  509. tmp = pcicore_read32(pc, SSB_PCICORE_SBTOPCI2);
  510. tmp |= SSB_PCICORE_SBTOPCI_MRM;
  511. pcicore_write32(pc, SSB_PCICORE_SBTOPCI2, tmp);
  512. }
  513. } else {
  514. WARN_ON(pdev->id.coreid != SSB_DEV_PCIE);
  515. //TODO: Better make defines for all these magic PCIE values.
  516. if ((pdev->id.revision == 0) || (pdev->id.revision == 1)) {
  517. /* TLP Workaround register. */
  518. tmp = ssb_pcie_read(pc, 0x4);
  519. tmp |= 0x8;
  520. ssb_pcie_write(pc, 0x4, tmp);
  521. }
  522. if (pdev->id.revision == 0) {
  523. const u8 serdes_rx_device = 0x1F;
  524. ssb_pcie_mdio_write(pc, serdes_rx_device,
  525. 2 /* Timer */, 0x8128);
  526. ssb_pcie_mdio_write(pc, serdes_rx_device,
  527. 6 /* CDR */, 0x0100);
  528. ssb_pcie_mdio_write(pc, serdes_rx_device,
  529. 7 /* CDR BW */, 0x1466);
  530. } else if (pdev->id.revision == 1) {
  531. /* DLLP Link Control register. */
  532. tmp = ssb_pcie_read(pc, 0x100);
  533. tmp |= 0x40;
  534. ssb_pcie_write(pc, 0x100, tmp);
  535. }
  536. }
  537. pc->setup_done = 1;
  538. out:
  539. return err;
  540. }
  541. EXPORT_SYMBOL(ssb_pcicore_dev_irqvecs_enable);