driver_chipcommon.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  1. /*
  2. * Sonics Silicon Backplane
  3. * Broadcom ChipCommon 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/ssb/ssb_regs.h>
  12. #include <linux/pci.h>
  13. #include "ssb_private.h"
  14. /* Clock sources */
  15. enum ssb_clksrc {
  16. /* PCI clock */
  17. SSB_CHIPCO_CLKSRC_PCI,
  18. /* Crystal slow clock oscillator */
  19. SSB_CHIPCO_CLKSRC_XTALOS,
  20. /* Low power oscillator */
  21. SSB_CHIPCO_CLKSRC_LOPWROS,
  22. };
  23. static inline u32 chipco_write32_masked(struct ssb_chipcommon *cc, u16 offset,
  24. u32 mask, u32 value)
  25. {
  26. value &= mask;
  27. value |= chipco_read32(cc, offset) & ~mask;
  28. chipco_write32(cc, offset, value);
  29. return value;
  30. }
  31. void ssb_chipco_set_clockmode(struct ssb_chipcommon *cc,
  32. enum ssb_clkmode mode)
  33. {
  34. struct ssb_device *ccdev = cc->dev;
  35. struct ssb_bus *bus;
  36. u32 tmp;
  37. if (!ccdev)
  38. return;
  39. bus = ccdev->bus;
  40. /* We support SLOW only on 6..9 */
  41. if (ccdev->id.revision >= 10 && mode == SSB_CLKMODE_SLOW)
  42. mode = SSB_CLKMODE_DYNAMIC;
  43. if (cc->capabilities & SSB_CHIPCO_CAP_PMU)
  44. return; /* PMU controls clockmode, separated function needed */
  45. SSB_WARN_ON(ccdev->id.revision >= 20);
  46. /* chipcommon cores prior to rev6 don't support dynamic clock control */
  47. if (ccdev->id.revision < 6)
  48. return;
  49. /* ChipCommon cores rev10+ need testing */
  50. if (ccdev->id.revision >= 10)
  51. return;
  52. if (!(cc->capabilities & SSB_CHIPCO_CAP_PCTL))
  53. return;
  54. switch (mode) {
  55. case SSB_CLKMODE_SLOW: /* For revs 6..9 only */
  56. tmp = chipco_read32(cc, SSB_CHIPCO_SLOWCLKCTL);
  57. tmp |= SSB_CHIPCO_SLOWCLKCTL_FSLOW;
  58. chipco_write32(cc, SSB_CHIPCO_SLOWCLKCTL, tmp);
  59. break;
  60. case SSB_CLKMODE_FAST:
  61. if (ccdev->id.revision < 10) {
  62. ssb_pci_xtal(bus, SSB_GPIO_XTAL, 1); /* Force crystal on */
  63. tmp = chipco_read32(cc, SSB_CHIPCO_SLOWCLKCTL);
  64. tmp &= ~SSB_CHIPCO_SLOWCLKCTL_FSLOW;
  65. tmp |= SSB_CHIPCO_SLOWCLKCTL_IPLL;
  66. chipco_write32(cc, SSB_CHIPCO_SLOWCLKCTL, tmp);
  67. } else {
  68. chipco_write32(cc, SSB_CHIPCO_SYSCLKCTL,
  69. (chipco_read32(cc, SSB_CHIPCO_SYSCLKCTL) |
  70. SSB_CHIPCO_SYSCLKCTL_FORCEHT));
  71. /* udelay(150); TODO: not available in early init */
  72. }
  73. break;
  74. case SSB_CLKMODE_DYNAMIC:
  75. if (ccdev->id.revision < 10) {
  76. tmp = chipco_read32(cc, SSB_CHIPCO_SLOWCLKCTL);
  77. tmp &= ~SSB_CHIPCO_SLOWCLKCTL_FSLOW;
  78. tmp &= ~SSB_CHIPCO_SLOWCLKCTL_IPLL;
  79. tmp &= ~SSB_CHIPCO_SLOWCLKCTL_ENXTAL;
  80. if ((tmp & SSB_CHIPCO_SLOWCLKCTL_SRC) !=
  81. SSB_CHIPCO_SLOWCLKCTL_SRC_XTAL)
  82. tmp |= SSB_CHIPCO_SLOWCLKCTL_ENXTAL;
  83. chipco_write32(cc, SSB_CHIPCO_SLOWCLKCTL, tmp);
  84. /* For dynamic control, we have to release our xtal_pu
  85. * "force on" */
  86. if (tmp & SSB_CHIPCO_SLOWCLKCTL_ENXTAL)
  87. ssb_pci_xtal(bus, SSB_GPIO_XTAL, 0);
  88. } else {
  89. chipco_write32(cc, SSB_CHIPCO_SYSCLKCTL,
  90. (chipco_read32(cc, SSB_CHIPCO_SYSCLKCTL) &
  91. ~SSB_CHIPCO_SYSCLKCTL_FORCEHT));
  92. }
  93. break;
  94. default:
  95. SSB_WARN_ON(1);
  96. }
  97. }
  98. /* Get the Slow Clock Source */
  99. static enum ssb_clksrc chipco_pctl_get_slowclksrc(struct ssb_chipcommon *cc)
  100. {
  101. struct ssb_bus *bus = cc->dev->bus;
  102. u32 uninitialized_var(tmp);
  103. if (cc->dev->id.revision < 6) {
  104. if (bus->bustype == SSB_BUSTYPE_SSB ||
  105. bus->bustype == SSB_BUSTYPE_PCMCIA)
  106. return SSB_CHIPCO_CLKSRC_XTALOS;
  107. if (bus->bustype == SSB_BUSTYPE_PCI) {
  108. pci_read_config_dword(bus->host_pci, SSB_GPIO_OUT, &tmp);
  109. if (tmp & 0x10)
  110. return SSB_CHIPCO_CLKSRC_PCI;
  111. return SSB_CHIPCO_CLKSRC_XTALOS;
  112. }
  113. }
  114. if (cc->dev->id.revision < 10) {
  115. tmp = chipco_read32(cc, SSB_CHIPCO_SLOWCLKCTL);
  116. tmp &= 0x7;
  117. if (tmp == 0)
  118. return SSB_CHIPCO_CLKSRC_LOPWROS;
  119. if (tmp == 1)
  120. return SSB_CHIPCO_CLKSRC_XTALOS;
  121. if (tmp == 2)
  122. return SSB_CHIPCO_CLKSRC_PCI;
  123. }
  124. return SSB_CHIPCO_CLKSRC_XTALOS;
  125. }
  126. /* Get maximum or minimum (depending on get_max flag) slowclock frequency. */
  127. static int chipco_pctl_clockfreqlimit(struct ssb_chipcommon *cc, int get_max)
  128. {
  129. int uninitialized_var(limit);
  130. enum ssb_clksrc clocksrc;
  131. int divisor = 1;
  132. u32 tmp;
  133. clocksrc = chipco_pctl_get_slowclksrc(cc);
  134. if (cc->dev->id.revision < 6) {
  135. switch (clocksrc) {
  136. case SSB_CHIPCO_CLKSRC_PCI:
  137. divisor = 64;
  138. break;
  139. case SSB_CHIPCO_CLKSRC_XTALOS:
  140. divisor = 32;
  141. break;
  142. default:
  143. SSB_WARN_ON(1);
  144. }
  145. } else if (cc->dev->id.revision < 10) {
  146. switch (clocksrc) {
  147. case SSB_CHIPCO_CLKSRC_LOPWROS:
  148. break;
  149. case SSB_CHIPCO_CLKSRC_XTALOS:
  150. case SSB_CHIPCO_CLKSRC_PCI:
  151. tmp = chipco_read32(cc, SSB_CHIPCO_SLOWCLKCTL);
  152. divisor = (tmp >> 16) + 1;
  153. divisor *= 4;
  154. break;
  155. }
  156. } else {
  157. tmp = chipco_read32(cc, SSB_CHIPCO_SYSCLKCTL);
  158. divisor = (tmp >> 16) + 1;
  159. divisor *= 4;
  160. }
  161. switch (clocksrc) {
  162. case SSB_CHIPCO_CLKSRC_LOPWROS:
  163. if (get_max)
  164. limit = 43000;
  165. else
  166. limit = 25000;
  167. break;
  168. case SSB_CHIPCO_CLKSRC_XTALOS:
  169. if (get_max)
  170. limit = 20200000;
  171. else
  172. limit = 19800000;
  173. break;
  174. case SSB_CHIPCO_CLKSRC_PCI:
  175. if (get_max)
  176. limit = 34000000;
  177. else
  178. limit = 25000000;
  179. break;
  180. }
  181. limit /= divisor;
  182. return limit;
  183. }
  184. static void chipco_powercontrol_init(struct ssb_chipcommon *cc)
  185. {
  186. struct ssb_bus *bus = cc->dev->bus;
  187. if (bus->chip_id == 0x4321) {
  188. if (bus->chip_rev == 0)
  189. chipco_write32(cc, SSB_CHIPCO_CHIPCTL, 0x3A4);
  190. else if (bus->chip_rev == 1)
  191. chipco_write32(cc, SSB_CHIPCO_CHIPCTL, 0xA4);
  192. }
  193. if (!(cc->capabilities & SSB_CHIPCO_CAP_PCTL))
  194. return;
  195. if (cc->dev->id.revision >= 10) {
  196. /* Set Idle Power clock rate to 1Mhz */
  197. chipco_write32(cc, SSB_CHIPCO_SYSCLKCTL,
  198. (chipco_read32(cc, SSB_CHIPCO_SYSCLKCTL) &
  199. 0x0000FFFF) | 0x00040000);
  200. } else {
  201. int maxfreq;
  202. maxfreq = chipco_pctl_clockfreqlimit(cc, 1);
  203. chipco_write32(cc, SSB_CHIPCO_PLLONDELAY,
  204. (maxfreq * 150 + 999999) / 1000000);
  205. chipco_write32(cc, SSB_CHIPCO_FREFSELDELAY,
  206. (maxfreq * 15 + 999999) / 1000000);
  207. }
  208. }
  209. /* http://bcm-v4.sipsolutions.net/802.11/PmuFastPwrupDelay */
  210. static u16 pmu_fast_powerup_delay(struct ssb_chipcommon *cc)
  211. {
  212. struct ssb_bus *bus = cc->dev->bus;
  213. switch (bus->chip_id) {
  214. case 0x4312:
  215. case 0x4322:
  216. case 0x4328:
  217. return 7000;
  218. case 0x4325:
  219. /* TODO: */
  220. default:
  221. return 15000;
  222. }
  223. }
  224. /* http://bcm-v4.sipsolutions.net/802.11/ClkctlFastPwrupDelay */
  225. static void calc_fast_powerup_delay(struct ssb_chipcommon *cc)
  226. {
  227. struct ssb_bus *bus = cc->dev->bus;
  228. int minfreq;
  229. unsigned int tmp;
  230. u32 pll_on_delay;
  231. if (bus->bustype != SSB_BUSTYPE_PCI)
  232. return;
  233. if (cc->capabilities & SSB_CHIPCO_CAP_PMU) {
  234. cc->fast_pwrup_delay = pmu_fast_powerup_delay(cc);
  235. return;
  236. }
  237. if (!(cc->capabilities & SSB_CHIPCO_CAP_PCTL))
  238. return;
  239. minfreq = chipco_pctl_clockfreqlimit(cc, 0);
  240. pll_on_delay = chipco_read32(cc, SSB_CHIPCO_PLLONDELAY);
  241. tmp = (((pll_on_delay + 2) * 1000000) + (minfreq - 1)) / minfreq;
  242. SSB_WARN_ON(tmp & ~0xFFFF);
  243. cc->fast_pwrup_delay = tmp;
  244. }
  245. void ssb_chipcommon_init(struct ssb_chipcommon *cc)
  246. {
  247. if (!cc->dev)
  248. return; /* We don't have a ChipCommon */
  249. if (cc->dev->id.revision >= 11)
  250. cc->status = chipco_read32(cc, SSB_CHIPCO_CHIPSTAT);
  251. ssb_dprintk(KERN_INFO PFX "chipcommon status is 0x%x\n", cc->status);
  252. if (cc->dev->id.revision >= 20) {
  253. chipco_write32(cc, SSB_CHIPCO_GPIOPULLUP, 0);
  254. chipco_write32(cc, SSB_CHIPCO_GPIOPULLDOWN, 0);
  255. }
  256. ssb_pmu_init(cc);
  257. chipco_powercontrol_init(cc);
  258. ssb_chipco_set_clockmode(cc, SSB_CLKMODE_FAST);
  259. calc_fast_powerup_delay(cc);
  260. }
  261. void ssb_chipco_suspend(struct ssb_chipcommon *cc)
  262. {
  263. if (!cc->dev)
  264. return;
  265. ssb_chipco_set_clockmode(cc, SSB_CLKMODE_SLOW);
  266. }
  267. void ssb_chipco_resume(struct ssb_chipcommon *cc)
  268. {
  269. if (!cc->dev)
  270. return;
  271. chipco_powercontrol_init(cc);
  272. ssb_chipco_set_clockmode(cc, SSB_CLKMODE_FAST);
  273. }
  274. /* Get the processor clock */
  275. void ssb_chipco_get_clockcpu(struct ssb_chipcommon *cc,
  276. u32 *plltype, u32 *n, u32 *m)
  277. {
  278. *n = chipco_read32(cc, SSB_CHIPCO_CLOCK_N);
  279. *plltype = (cc->capabilities & SSB_CHIPCO_CAP_PLLT);
  280. switch (*plltype) {
  281. case SSB_PLLTYPE_2:
  282. case SSB_PLLTYPE_4:
  283. case SSB_PLLTYPE_6:
  284. case SSB_PLLTYPE_7:
  285. *m = chipco_read32(cc, SSB_CHIPCO_CLOCK_MIPS);
  286. break;
  287. case SSB_PLLTYPE_3:
  288. /* 5350 uses m2 to control mips */
  289. *m = chipco_read32(cc, SSB_CHIPCO_CLOCK_M2);
  290. break;
  291. default:
  292. *m = chipco_read32(cc, SSB_CHIPCO_CLOCK_SB);
  293. break;
  294. }
  295. }
  296. /* Get the bus clock */
  297. void ssb_chipco_get_clockcontrol(struct ssb_chipcommon *cc,
  298. u32 *plltype, u32 *n, u32 *m)
  299. {
  300. *n = chipco_read32(cc, SSB_CHIPCO_CLOCK_N);
  301. *plltype = (cc->capabilities & SSB_CHIPCO_CAP_PLLT);
  302. switch (*plltype) {
  303. case SSB_PLLTYPE_6: /* 100/200 or 120/240 only */
  304. *m = chipco_read32(cc, SSB_CHIPCO_CLOCK_MIPS);
  305. break;
  306. case SSB_PLLTYPE_3: /* 25Mhz, 2 dividers */
  307. if (cc->dev->bus->chip_id != 0x5365) {
  308. *m = chipco_read32(cc, SSB_CHIPCO_CLOCK_M2);
  309. break;
  310. }
  311. /* Fallthough */
  312. default:
  313. *m = chipco_read32(cc, SSB_CHIPCO_CLOCK_SB);
  314. }
  315. }
  316. void ssb_chipco_timing_init(struct ssb_chipcommon *cc,
  317. unsigned long ns)
  318. {
  319. struct ssb_device *dev = cc->dev;
  320. struct ssb_bus *bus = dev->bus;
  321. u32 tmp;
  322. /* set register for external IO to control LED. */
  323. chipco_write32(cc, SSB_CHIPCO_PROG_CFG, 0x11);
  324. tmp = DIV_ROUND_UP(10, ns) << SSB_PROG_WCNT_3_SHIFT; /* Waitcount-3 = 10ns */
  325. tmp |= DIV_ROUND_UP(40, ns) << SSB_PROG_WCNT_1_SHIFT; /* Waitcount-1 = 40ns */
  326. tmp |= DIV_ROUND_UP(240, ns); /* Waitcount-0 = 240ns */
  327. chipco_write32(cc, SSB_CHIPCO_PROG_WAITCNT, tmp); /* 0x01020a0c for a 100Mhz clock */
  328. /* Set timing for the flash */
  329. tmp = DIV_ROUND_UP(10, ns) << SSB_FLASH_WCNT_3_SHIFT; /* Waitcount-3 = 10nS */
  330. tmp |= DIV_ROUND_UP(10, ns) << SSB_FLASH_WCNT_1_SHIFT; /* Waitcount-1 = 10nS */
  331. tmp |= DIV_ROUND_UP(120, ns); /* Waitcount-0 = 120nS */
  332. if ((bus->chip_id == 0x5365) ||
  333. (dev->id.revision < 9))
  334. chipco_write32(cc, SSB_CHIPCO_FLASH_WAITCNT, tmp);
  335. if ((bus->chip_id == 0x5365) ||
  336. (dev->id.revision < 9) ||
  337. ((bus->chip_id == 0x5350) && (bus->chip_rev == 0)))
  338. chipco_write32(cc, SSB_CHIPCO_PCMCIA_MEMWAIT, tmp);
  339. if (bus->chip_id == 0x5350) {
  340. /* Enable EXTIF */
  341. tmp = DIV_ROUND_UP(10, ns) << SSB_PROG_WCNT_3_SHIFT; /* Waitcount-3 = 10ns */
  342. tmp |= DIV_ROUND_UP(20, ns) << SSB_PROG_WCNT_2_SHIFT; /* Waitcount-2 = 20ns */
  343. tmp |= DIV_ROUND_UP(100, ns) << SSB_PROG_WCNT_1_SHIFT; /* Waitcount-1 = 100ns */
  344. tmp |= DIV_ROUND_UP(120, ns); /* Waitcount-0 = 120ns */
  345. chipco_write32(cc, SSB_CHIPCO_PROG_WAITCNT, tmp); /* 0x01020a0c for a 100Mhz clock */
  346. }
  347. }
  348. /* Set chip watchdog reset timer to fire in 'ticks' backplane cycles */
  349. void ssb_chipco_watchdog_timer_set(struct ssb_chipcommon *cc, u32 ticks)
  350. {
  351. /* instant NMI */
  352. chipco_write32(cc, SSB_CHIPCO_WATCHDOG, ticks);
  353. }
  354. void ssb_chipco_irq_mask(struct ssb_chipcommon *cc, u32 mask, u32 value)
  355. {
  356. chipco_write32_masked(cc, SSB_CHIPCO_IRQMASK, mask, value);
  357. }
  358. u32 ssb_chipco_irq_status(struct ssb_chipcommon *cc, u32 mask)
  359. {
  360. return chipco_read32(cc, SSB_CHIPCO_IRQSTAT) & mask;
  361. }
  362. u32 ssb_chipco_gpio_in(struct ssb_chipcommon *cc, u32 mask)
  363. {
  364. return chipco_read32(cc, SSB_CHIPCO_GPIOIN) & mask;
  365. }
  366. u32 ssb_chipco_gpio_out(struct ssb_chipcommon *cc, u32 mask, u32 value)
  367. {
  368. return chipco_write32_masked(cc, SSB_CHIPCO_GPIOOUT, mask, value);
  369. }
  370. u32 ssb_chipco_gpio_outen(struct ssb_chipcommon *cc, u32 mask, u32 value)
  371. {
  372. return chipco_write32_masked(cc, SSB_CHIPCO_GPIOOUTEN, mask, value);
  373. }
  374. u32 ssb_chipco_gpio_control(struct ssb_chipcommon *cc, u32 mask, u32 value)
  375. {
  376. return chipco_write32_masked(cc, SSB_CHIPCO_GPIOCTL, mask, value);
  377. }
  378. EXPORT_SYMBOL(ssb_chipco_gpio_control);
  379. u32 ssb_chipco_gpio_intmask(struct ssb_chipcommon *cc, u32 mask, u32 value)
  380. {
  381. return chipco_write32_masked(cc, SSB_CHIPCO_GPIOIRQ, mask, value);
  382. }
  383. u32 ssb_chipco_gpio_polarity(struct ssb_chipcommon *cc, u32 mask, u32 value)
  384. {
  385. return chipco_write32_masked(cc, SSB_CHIPCO_GPIOPOL, mask, value);
  386. }
  387. #ifdef CONFIG_SSB_SERIAL
  388. int ssb_chipco_serial_init(struct ssb_chipcommon *cc,
  389. struct ssb_serial_port *ports)
  390. {
  391. struct ssb_bus *bus = cc->dev->bus;
  392. int nr_ports = 0;
  393. u32 plltype;
  394. unsigned int irq;
  395. u32 baud_base, div;
  396. u32 i, n;
  397. unsigned int ccrev = cc->dev->id.revision;
  398. plltype = (cc->capabilities & SSB_CHIPCO_CAP_PLLT);
  399. irq = ssb_mips_irq(cc->dev);
  400. if (plltype == SSB_PLLTYPE_1) {
  401. /* PLL clock */
  402. baud_base = ssb_calc_clock_rate(plltype,
  403. chipco_read32(cc, SSB_CHIPCO_CLOCK_N),
  404. chipco_read32(cc, SSB_CHIPCO_CLOCK_M2));
  405. div = 1;
  406. } else {
  407. if (ccrev == 20) {
  408. /* BCM5354 uses constant 25MHz clock */
  409. baud_base = 25000000;
  410. div = 48;
  411. /* Set the override bit so we don't divide it */
  412. chipco_write32(cc, SSB_CHIPCO_CORECTL,
  413. chipco_read32(cc, SSB_CHIPCO_CORECTL)
  414. | SSB_CHIPCO_CORECTL_UARTCLK0);
  415. } else if ((ccrev >= 11) && (ccrev != 15)) {
  416. /* Fixed ALP clock */
  417. baud_base = 20000000;
  418. if (cc->capabilities & SSB_CHIPCO_CAP_PMU) {
  419. /* FIXME: baud_base is different for devices with a PMU */
  420. SSB_WARN_ON(1);
  421. }
  422. div = 1;
  423. if (ccrev >= 21) {
  424. /* Turn off UART clock before switching clocksource. */
  425. chipco_write32(cc, SSB_CHIPCO_CORECTL,
  426. chipco_read32(cc, SSB_CHIPCO_CORECTL)
  427. & ~SSB_CHIPCO_CORECTL_UARTCLKEN);
  428. }
  429. /* Set the override bit so we don't divide it */
  430. chipco_write32(cc, SSB_CHIPCO_CORECTL,
  431. chipco_read32(cc, SSB_CHIPCO_CORECTL)
  432. | SSB_CHIPCO_CORECTL_UARTCLK0);
  433. if (ccrev >= 21) {
  434. /* Re-enable the UART clock. */
  435. chipco_write32(cc, SSB_CHIPCO_CORECTL,
  436. chipco_read32(cc, SSB_CHIPCO_CORECTL)
  437. | SSB_CHIPCO_CORECTL_UARTCLKEN);
  438. }
  439. } else if (ccrev >= 3) {
  440. /* Internal backplane clock */
  441. baud_base = ssb_clockspeed(bus);
  442. div = chipco_read32(cc, SSB_CHIPCO_CLKDIV)
  443. & SSB_CHIPCO_CLKDIV_UART;
  444. } else {
  445. /* Fixed internal backplane clock */
  446. baud_base = 88000000;
  447. div = 48;
  448. }
  449. /* Clock source depends on strapping if UartClkOverride is unset */
  450. if ((ccrev > 0) &&
  451. !(chipco_read32(cc, SSB_CHIPCO_CORECTL) & SSB_CHIPCO_CORECTL_UARTCLK0)) {
  452. if ((cc->capabilities & SSB_CHIPCO_CAP_UARTCLK) ==
  453. SSB_CHIPCO_CAP_UARTCLK_INT) {
  454. /* Internal divided backplane clock */
  455. baud_base /= div;
  456. } else {
  457. /* Assume external clock of 1.8432 MHz */
  458. baud_base = 1843200;
  459. }
  460. }
  461. }
  462. /* Determine the registers of the UARTs */
  463. n = (cc->capabilities & SSB_CHIPCO_CAP_NRUART);
  464. for (i = 0; i < n; i++) {
  465. void __iomem *cc_mmio;
  466. void __iomem *uart_regs;
  467. cc_mmio = cc->dev->bus->mmio + (cc->dev->core_index * SSB_CORE_SIZE);
  468. uart_regs = cc_mmio + SSB_CHIPCO_UART0_DATA;
  469. /* Offset changed at after rev 0 */
  470. if (ccrev == 0)
  471. uart_regs += (i * 8);
  472. else
  473. uart_regs += (i * 256);
  474. nr_ports++;
  475. ports[i].regs = uart_regs;
  476. ports[i].irq = irq;
  477. ports[i].baud_base = baud_base;
  478. ports[i].reg_shift = 0;
  479. }
  480. return nr_ports;
  481. }
  482. #endif /* CONFIG_SSB_SERIAL */