driver_chipcommon.c 14 KB

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