025-bcma_backport.patch 61 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988
  1. --- a/arch/mips/bcm47xx/serial.c
  2. +++ b/arch/mips/bcm47xx/serial.c
  3. @@ -62,7 +62,7 @@ static int __init uart8250_init_bcma(voi
  4. p->mapbase = (unsigned int) bcma_port->regs;
  5. p->membase = (void *) bcma_port->regs;
  6. - p->irq = bcma_port->irq + 2;
  7. + p->irq = bcma_port->irq;
  8. p->uartclk = bcma_port->baud_base;
  9. p->regshift = bcma_port->reg_shift;
  10. p->iotype = UPIO_MEM;
  11. --- a/drivers/bcma/Kconfig
  12. +++ b/drivers/bcma/Kconfig
  13. @@ -26,6 +26,7 @@ config BCMA_HOST_PCI_POSSIBLE
  14. config BCMA_HOST_PCI
  15. bool "Support for BCMA on PCI-host bus"
  16. depends on BCMA_HOST_PCI_POSSIBLE
  17. + default y
  18. config BCMA_DRIVER_PCI_HOSTMODE
  19. bool "Driver for PCI core working in hostmode"
  20. @@ -34,8 +35,14 @@ config BCMA_DRIVER_PCI_HOSTMODE
  21. PCI core hostmode operation (external PCI bus).
  22. config BCMA_HOST_SOC
  23. - bool
  24. - depends on BCMA_DRIVER_MIPS
  25. + bool "Support for BCMA in a SoC"
  26. + depends on BCMA
  27. + help
  28. + Host interface for a Broadcom AIX bus directly mapped into
  29. + the memory. This only works with the Broadcom SoCs from the
  30. + BCM47XX line.
  31. +
  32. + If unsure, say N
  33. config BCMA_DRIVER_MIPS
  34. bool "BCMA Broadcom MIPS core driver"
  35. --- a/drivers/bcma/bcma_private.h
  36. +++ b/drivers/bcma/bcma_private.h
  37. @@ -22,6 +22,8 @@
  38. struct bcma_bus;
  39. /* main.c */
  40. +bool bcma_wait_value(struct bcma_device *core, u16 reg, u32 mask, u32 value,
  41. + int timeout);
  42. int bcma_bus_register(struct bcma_bus *bus);
  43. void bcma_bus_unregister(struct bcma_bus *bus);
  44. int __init bcma_bus_early_register(struct bcma_bus *bus,
  45. @@ -31,6 +33,8 @@ int __init bcma_bus_early_register(struc
  46. int bcma_bus_suspend(struct bcma_bus *bus);
  47. int bcma_bus_resume(struct bcma_bus *bus);
  48. #endif
  49. +struct bcma_device *bcma_find_core_unit(struct bcma_bus *bus, u16 coreid,
  50. + u8 unit);
  51. /* scan.c */
  52. int bcma_bus_scan(struct bcma_bus *bus);
  53. @@ -45,6 +49,7 @@ int bcma_sprom_get(struct bcma_bus *bus)
  54. /* driver_chipcommon.c */
  55. #ifdef CONFIG_BCMA_DRIVER_MIPS
  56. void bcma_chipco_serial_init(struct bcma_drv_cc *cc);
  57. +extern struct platform_device bcma_pflash_dev;
  58. #endif /* CONFIG_BCMA_DRIVER_MIPS */
  59. /* driver_chipcommon_pmu.c */
  60. --- a/drivers/bcma/core.c
  61. +++ b/drivers/bcma/core.c
  62. @@ -9,6 +9,25 @@
  63. #include <linux/export.h>
  64. #include <linux/bcma/bcma.h>
  65. +static bool bcma_core_wait_value(struct bcma_device *core, u16 reg, u32 mask,
  66. + u32 value, int timeout)
  67. +{
  68. + unsigned long deadline = jiffies + timeout;
  69. + u32 val;
  70. +
  71. + do {
  72. + val = bcma_aread32(core, reg);
  73. + if ((val & mask) == value)
  74. + return true;
  75. + cpu_relax();
  76. + udelay(10);
  77. + } while (!time_after_eq(jiffies, deadline));
  78. +
  79. + bcma_warn(core->bus, "Timeout waiting for register 0x%04X!\n", reg);
  80. +
  81. + return false;
  82. +}
  83. +
  84. bool bcma_core_is_enabled(struct bcma_device *core)
  85. {
  86. if ((bcma_aread32(core, BCMA_IOCTL) & (BCMA_IOCTL_CLK | BCMA_IOCTL_FGC))
  87. @@ -25,13 +44,15 @@ void bcma_core_disable(struct bcma_devic
  88. if (bcma_aread32(core, BCMA_RESET_CTL) & BCMA_RESET_CTL_RESET)
  89. return;
  90. - bcma_awrite32(core, BCMA_IOCTL, flags);
  91. - bcma_aread32(core, BCMA_IOCTL);
  92. - udelay(10);
  93. + bcma_core_wait_value(core, BCMA_RESET_ST, ~0, 0, 300);
  94. bcma_awrite32(core, BCMA_RESET_CTL, BCMA_RESET_CTL_RESET);
  95. bcma_aread32(core, BCMA_RESET_CTL);
  96. udelay(1);
  97. +
  98. + bcma_awrite32(core, BCMA_IOCTL, flags);
  99. + bcma_aread32(core, BCMA_IOCTL);
  100. + udelay(10);
  101. }
  102. EXPORT_SYMBOL_GPL(bcma_core_disable);
  103. @@ -43,6 +64,7 @@ int bcma_core_enable(struct bcma_device
  104. bcma_aread32(core, BCMA_IOCTL);
  105. bcma_awrite32(core, BCMA_RESET_CTL, 0);
  106. + bcma_aread32(core, BCMA_RESET_CTL);
  107. udelay(1);
  108. bcma_awrite32(core, BCMA_IOCTL, (BCMA_IOCTL_CLK | flags));
  109. @@ -104,7 +126,13 @@ void bcma_core_pll_ctl(struct bcma_devic
  110. if (i)
  111. bcma_err(core->bus, "PLL enable timeout\n");
  112. } else {
  113. - bcma_warn(core->bus, "Disabling PLL not supported yet!\n");
  114. + /*
  115. + * Mask the PLL but don't wait for it to be disabled. PLL may be
  116. + * shared between cores and will be still up if there is another
  117. + * core using it.
  118. + */
  119. + bcma_mask32(core, BCMA_CLKCTLST, ~req);
  120. + bcma_read32(core, BCMA_CLKCTLST);
  121. }
  122. }
  123. EXPORT_SYMBOL_GPL(bcma_core_pll_ctl);
  124. --- a/drivers/bcma/driver_chipcommon.c
  125. +++ b/drivers/bcma/driver_chipcommon.c
  126. @@ -25,13 +25,14 @@ static inline u32 bcma_cc_write32_masked
  127. return value;
  128. }
  129. -static u32 bcma_chipco_get_alp_clock(struct bcma_drv_cc *cc)
  130. +u32 bcma_chipco_get_alp_clock(struct bcma_drv_cc *cc)
  131. {
  132. if (cc->capabilities & BCMA_CC_CAP_PMU)
  133. return bcma_pmu_get_alp_clock(cc);
  134. return 20000000;
  135. }
  136. +EXPORT_SYMBOL_GPL(bcma_chipco_get_alp_clock);
  137. static u32 bcma_chipco_watchdog_get_max_timer(struct bcma_drv_cc *cc)
  138. {
  139. @@ -139,8 +140,15 @@ void bcma_core_chipcommon_init(struct bc
  140. bcma_core_chipcommon_early_init(cc);
  141. if (cc->core->id.rev >= 20) {
  142. - bcma_cc_write32(cc, BCMA_CC_GPIOPULLUP, 0);
  143. - bcma_cc_write32(cc, BCMA_CC_GPIOPULLDOWN, 0);
  144. + u32 pullup = 0, pulldown = 0;
  145. +
  146. + if (cc->core->bus->chipinfo.id == BCMA_CHIP_ID_BCM43142) {
  147. + pullup = 0x402e0;
  148. + pulldown = 0x20500;
  149. + }
  150. +
  151. + bcma_cc_write32(cc, BCMA_CC_GPIOPULLUP, pullup);
  152. + bcma_cc_write32(cc, BCMA_CC_GPIOPULLDOWN, pulldown);
  153. }
  154. if (cc->capabilities & BCMA_CC_CAP_PMU)
  155. @@ -213,6 +221,7 @@ u32 bcma_chipco_gpio_out(struct bcma_drv
  156. return res;
  157. }
  158. +EXPORT_SYMBOL_GPL(bcma_chipco_gpio_out);
  159. u32 bcma_chipco_gpio_outen(struct bcma_drv_cc *cc, u32 mask, u32 value)
  160. {
  161. @@ -225,6 +234,7 @@ u32 bcma_chipco_gpio_outen(struct bcma_d
  162. return res;
  163. }
  164. +EXPORT_SYMBOL_GPL(bcma_chipco_gpio_outen);
  165. /*
  166. * If the bit is set to 0, chipcommon controlls this GPIO,
  167. @@ -329,7 +339,7 @@ void bcma_chipco_serial_init(struct bcma
  168. return;
  169. }
  170. - irq = bcma_core_mips_irq(cc->core);
  171. + irq = bcma_core_irq(cc->core);
  172. /* Determine the registers of the UARTs */
  173. cc->nr_serial_ports = (cc->capabilities & BCMA_CC_CAP_NRUART);
  174. --- a/drivers/bcma/driver_chipcommon_nflash.c
  175. +++ b/drivers/bcma/driver_chipcommon_nflash.c
  176. @@ -5,11 +5,11 @@
  177. * Licensed under the GNU/GPL. See COPYING for details.
  178. */
  179. +#include "bcma_private.h"
  180. +
  181. #include <linux/platform_device.h>
  182. #include <linux/bcma/bcma.h>
  183. -#include "bcma_private.h"
  184. -
  185. struct platform_device bcma_nflash_dev = {
  186. .name = "bcma_nflash",
  187. .num_resources = 0,
  188. --- a/drivers/bcma/driver_chipcommon_pmu.c
  189. +++ b/drivers/bcma/driver_chipcommon_pmu.c
  190. @@ -56,6 +56,109 @@ void bcma_chipco_regctl_maskset(struct b
  191. }
  192. EXPORT_SYMBOL_GPL(bcma_chipco_regctl_maskset);
  193. +static u32 bcma_pmu_xtalfreq(struct bcma_drv_cc *cc)
  194. +{
  195. + u32 ilp_ctl, alp_hz;
  196. +
  197. + if (!(bcma_cc_read32(cc, BCMA_CC_PMU_STAT) &
  198. + BCMA_CC_PMU_STAT_EXT_LPO_AVAIL))
  199. + return 0;
  200. +
  201. + bcma_cc_write32(cc, BCMA_CC_PMU_XTAL_FREQ,
  202. + BIT(BCMA_CC_PMU_XTAL_FREQ_MEASURE_SHIFT));
  203. + usleep_range(1000, 2000);
  204. +
  205. + ilp_ctl = bcma_cc_read32(cc, BCMA_CC_PMU_XTAL_FREQ);
  206. + ilp_ctl &= BCMA_CC_PMU_XTAL_FREQ_ILPCTL_MASK;
  207. +
  208. + bcma_cc_write32(cc, BCMA_CC_PMU_XTAL_FREQ, 0);
  209. +
  210. + alp_hz = ilp_ctl * 32768 / 4;
  211. + return (alp_hz + 50000) / 100000 * 100;
  212. +}
  213. +
  214. +static void bcma_pmu2_pll_init0(struct bcma_drv_cc *cc, u32 xtalfreq)
  215. +{
  216. + struct bcma_bus *bus = cc->core->bus;
  217. + u32 freq_tgt_target = 0, freq_tgt_current;
  218. + u32 pll0, mask;
  219. +
  220. + switch (bus->chipinfo.id) {
  221. + case BCMA_CHIP_ID_BCM43142:
  222. + /* pmu2_xtaltab0_adfll_485 */
  223. + switch (xtalfreq) {
  224. + case 12000:
  225. + freq_tgt_target = 0x50D52;
  226. + break;
  227. + case 20000:
  228. + freq_tgt_target = 0x307FE;
  229. + break;
  230. + case 26000:
  231. + freq_tgt_target = 0x254EA;
  232. + break;
  233. + case 37400:
  234. + freq_tgt_target = 0x19EF8;
  235. + break;
  236. + case 52000:
  237. + freq_tgt_target = 0x12A75;
  238. + break;
  239. + }
  240. + break;
  241. + }
  242. +
  243. + if (!freq_tgt_target) {
  244. + bcma_err(bus, "Unknown TGT frequency for xtalfreq %d\n",
  245. + xtalfreq);
  246. + return;
  247. + }
  248. +
  249. + pll0 = bcma_chipco_pll_read(cc, BCMA_CC_PMU15_PLL_PLLCTL0);
  250. + freq_tgt_current = (pll0 & BCMA_CC_PMU15_PLL_PC0_FREQTGT_MASK) >>
  251. + BCMA_CC_PMU15_PLL_PC0_FREQTGT_SHIFT;
  252. +
  253. + if (freq_tgt_current == freq_tgt_target) {
  254. + bcma_debug(bus, "Target TGT frequency already set\n");
  255. + return;
  256. + }
  257. +
  258. + /* Turn off PLL */
  259. + switch (bus->chipinfo.id) {
  260. + case BCMA_CHIP_ID_BCM43142:
  261. + mask = (u32)~(BCMA_RES_4314_HT_AVAIL |
  262. + BCMA_RES_4314_MACPHY_CLK_AVAIL);
  263. +
  264. + bcma_cc_mask32(cc, BCMA_CC_PMU_MINRES_MSK, mask);
  265. + bcma_cc_mask32(cc, BCMA_CC_PMU_MAXRES_MSK, mask);
  266. + bcma_wait_value(cc->core, BCMA_CLKCTLST,
  267. + BCMA_CLKCTLST_HAVEHT, 0, 20000);
  268. + break;
  269. + }
  270. +
  271. + pll0 &= ~BCMA_CC_PMU15_PLL_PC0_FREQTGT_MASK;
  272. + pll0 |= freq_tgt_target << BCMA_CC_PMU15_PLL_PC0_FREQTGT_SHIFT;
  273. + bcma_chipco_pll_write(cc, BCMA_CC_PMU15_PLL_PLLCTL0, pll0);
  274. +
  275. + /* Flush */
  276. + if (cc->pmu.rev >= 2)
  277. + bcma_cc_set32(cc, BCMA_CC_PMU_CTL, BCMA_CC_PMU_CTL_PLL_UPD);
  278. +
  279. + /* TODO: Do we need to update OTP? */
  280. +}
  281. +
  282. +static void bcma_pmu_pll_init(struct bcma_drv_cc *cc)
  283. +{
  284. + struct bcma_bus *bus = cc->core->bus;
  285. + u32 xtalfreq = bcma_pmu_xtalfreq(cc);
  286. +
  287. + switch (bus->chipinfo.id) {
  288. + case BCMA_CHIP_ID_BCM43142:
  289. + if (xtalfreq == 0)
  290. + xtalfreq = 20000;
  291. + bcma_pmu2_pll_init0(cc, xtalfreq);
  292. + break;
  293. + }
  294. +}
  295. +
  296. static void bcma_pmu_resources_init(struct bcma_drv_cc *cc)
  297. {
  298. struct bcma_bus *bus = cc->core->bus;
  299. @@ -66,6 +169,25 @@ static void bcma_pmu_resources_init(stru
  300. min_msk = 0x200D;
  301. max_msk = 0xFFFF;
  302. break;
  303. + case BCMA_CHIP_ID_BCM43142:
  304. + min_msk = BCMA_RES_4314_LPLDO_PU |
  305. + BCMA_RES_4314_PMU_SLEEP_DIS |
  306. + BCMA_RES_4314_PMU_BG_PU |
  307. + BCMA_RES_4314_CBUCK_LPOM_PU |
  308. + BCMA_RES_4314_CBUCK_PFM_PU |
  309. + BCMA_RES_4314_CLDO_PU |
  310. + BCMA_RES_4314_LPLDO2_LVM |
  311. + BCMA_RES_4314_WL_PMU_PU |
  312. + BCMA_RES_4314_LDO3P3_PU |
  313. + BCMA_RES_4314_OTP_PU |
  314. + BCMA_RES_4314_WL_PWRSW_PU |
  315. + BCMA_RES_4314_LQ_AVAIL |
  316. + BCMA_RES_4314_LOGIC_RET |
  317. + BCMA_RES_4314_MEM_SLEEP |
  318. + BCMA_RES_4314_MACPHY_RET |
  319. + BCMA_RES_4314_WL_CORE_READY;
  320. + max_msk = 0x3FFFFFFF;
  321. + break;
  322. default:
  323. bcma_debug(bus, "PMU resource config unknown or not needed for device 0x%04X\n",
  324. bus->chipinfo.id);
  325. @@ -165,6 +287,7 @@ void bcma_pmu_init(struct bcma_drv_cc *c
  326. bcma_cc_set32(cc, BCMA_CC_PMU_CTL,
  327. BCMA_CC_PMU_CTL_NOILPONW);
  328. + bcma_pmu_pll_init(cc);
  329. bcma_pmu_resources_init(cc);
  330. bcma_pmu_workarounds(cc);
  331. }
  332. @@ -174,19 +297,35 @@ u32 bcma_pmu_get_alp_clock(struct bcma_d
  333. struct bcma_bus *bus = cc->core->bus;
  334. switch (bus->chipinfo.id) {
  335. + case BCMA_CHIP_ID_BCM4313:
  336. + case BCMA_CHIP_ID_BCM43224:
  337. + case BCMA_CHIP_ID_BCM43225:
  338. + case BCMA_CHIP_ID_BCM43227:
  339. + case BCMA_CHIP_ID_BCM43228:
  340. + case BCMA_CHIP_ID_BCM4331:
  341. + case BCMA_CHIP_ID_BCM43421:
  342. + case BCMA_CHIP_ID_BCM43428:
  343. + case BCMA_CHIP_ID_BCM43431:
  344. case BCMA_CHIP_ID_BCM4716:
  345. - case BCMA_CHIP_ID_BCM4748:
  346. case BCMA_CHIP_ID_BCM47162:
  347. - case BCMA_CHIP_ID_BCM4313:
  348. - case BCMA_CHIP_ID_BCM5357:
  349. + case BCMA_CHIP_ID_BCM4748:
  350. case BCMA_CHIP_ID_BCM4749:
  351. + case BCMA_CHIP_ID_BCM5357:
  352. case BCMA_CHIP_ID_BCM53572:
  353. + case BCMA_CHIP_ID_BCM6362:
  354. /* always 20Mhz */
  355. return 20000 * 1000;
  356. - case BCMA_CHIP_ID_BCM5356:
  357. case BCMA_CHIP_ID_BCM4706:
  358. + case BCMA_CHIP_ID_BCM5356:
  359. /* always 25Mhz */
  360. return 25000 * 1000;
  361. + case BCMA_CHIP_ID_BCM43460:
  362. + case BCMA_CHIP_ID_BCM4352:
  363. + case BCMA_CHIP_ID_BCM4360:
  364. + if (cc->status & BCMA_CC_CHIPST_4360_XTAL_40MZ)
  365. + return 40000 * 1000;
  366. + else
  367. + return 20000 * 1000;
  368. default:
  369. bcma_warn(bus, "No ALP clock specified for %04X device, pmu rev. %d, using default %d Hz\n",
  370. bus->chipinfo.id, cc->pmu.rev, BCMA_CC_PMU_ALP_CLOCK);
  371. @@ -264,7 +403,7 @@ static u32 bcma_pmu_pll_clock_bcm4706(st
  372. }
  373. /* query bus clock frequency for PMU-enabled chipcommon */
  374. -static u32 bcma_pmu_get_bus_clock(struct bcma_drv_cc *cc)
  375. +u32 bcma_pmu_get_bus_clock(struct bcma_drv_cc *cc)
  376. {
  377. struct bcma_bus *bus = cc->core->bus;
  378. @@ -293,6 +432,7 @@ static u32 bcma_pmu_get_bus_clock(struct
  379. }
  380. return BCMA_CC_PMU_HT_CLOCK;
  381. }
  382. +EXPORT_SYMBOL_GPL(bcma_pmu_get_bus_clock);
  383. /* query cpu clock frequency for PMU-enabled chipcommon */
  384. u32 bcma_pmu_get_cpu_clock(struct bcma_drv_cc *cc)
  385. @@ -372,7 +512,7 @@ void bcma_pmu_spuravoid_pllupdate(struct
  386. tmp |= (bcm5357_bcm43236_ndiv[spuravoid]) << BCMA_CC_PMU1_PLL0_PC2_NDIV_INT_SHIFT;
  387. bcma_cc_write32(cc, BCMA_CC_PLLCTL_DATA, tmp);
  388. - tmp = 1 << 10;
  389. + tmp = BCMA_CC_PMU_CTL_PLL_UPD;
  390. break;
  391. case BCMA_CHIP_ID_BCM4331:
  392. @@ -393,7 +533,7 @@ void bcma_pmu_spuravoid_pllupdate(struct
  393. bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
  394. 0x03000a08);
  395. }
  396. - tmp = 1 << 10;
  397. + tmp = BCMA_CC_PMU_CTL_PLL_UPD;
  398. break;
  399. case BCMA_CHIP_ID_BCM43224:
  400. @@ -426,7 +566,7 @@ void bcma_pmu_spuravoid_pllupdate(struct
  401. bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL5,
  402. 0x88888815);
  403. }
  404. - tmp = 1 << 10;
  405. + tmp = BCMA_CC_PMU_CTL_PLL_UPD;
  406. break;
  407. case BCMA_CHIP_ID_BCM4716:
  408. @@ -460,7 +600,7 @@ void bcma_pmu_spuravoid_pllupdate(struct
  409. 0x88888815);
  410. }
  411. - tmp = 3 << 9;
  412. + tmp = BCMA_CC_PMU_CTL_PLL_UPD | BCMA_CC_PMU_CTL_NOILPONW;
  413. break;
  414. case BCMA_CHIP_ID_BCM43227:
  415. @@ -496,7 +636,7 @@ void bcma_pmu_spuravoid_pllupdate(struct
  416. bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL5,
  417. 0x88888815);
  418. }
  419. - tmp = 1 << 10;
  420. + tmp = BCMA_CC_PMU_CTL_PLL_UPD;
  421. break;
  422. default:
  423. bcma_err(bus, "Unknown spuravoidance settings for chip 0x%04X, not changing PLL\n",
  424. --- a/drivers/bcma/driver_chipcommon_sflash.c
  425. +++ b/drivers/bcma/driver_chipcommon_sflash.c
  426. @@ -5,11 +5,11 @@
  427. * Licensed under the GNU/GPL. See COPYING for details.
  428. */
  429. +#include "bcma_private.h"
  430. +
  431. #include <linux/platform_device.h>
  432. #include <linux/bcma/bcma.h>
  433. -#include "bcma_private.h"
  434. -
  435. static struct resource bcma_sflash_resource = {
  436. .name = "bcma_sflash",
  437. .start = BCMA_SOC_FLASH2,
  438. @@ -30,7 +30,7 @@ struct bcma_sflash_tbl_e {
  439. u16 numblocks;
  440. };
  441. -static struct bcma_sflash_tbl_e bcma_sflash_st_tbl[] = {
  442. +static const struct bcma_sflash_tbl_e bcma_sflash_st_tbl[] = {
  443. { "M25P20", 0x11, 0x10000, 4, },
  444. { "M25P40", 0x12, 0x10000, 8, },
  445. @@ -41,7 +41,7 @@ static struct bcma_sflash_tbl_e bcma_sfl
  446. { 0 },
  447. };
  448. -static struct bcma_sflash_tbl_e bcma_sflash_sst_tbl[] = {
  449. +static const struct bcma_sflash_tbl_e bcma_sflash_sst_tbl[] = {
  450. { "SST25WF512", 1, 0x1000, 16, },
  451. { "SST25VF512", 0x48, 0x1000, 16, },
  452. { "SST25WF010", 2, 0x1000, 32, },
  453. @@ -59,7 +59,7 @@ static struct bcma_sflash_tbl_e bcma_sfl
  454. { 0 },
  455. };
  456. -static struct bcma_sflash_tbl_e bcma_sflash_at_tbl[] = {
  457. +static const struct bcma_sflash_tbl_e bcma_sflash_at_tbl[] = {
  458. { "AT45DB011", 0xc, 256, 512, },
  459. { "AT45DB021", 0x14, 256, 1024, },
  460. { "AT45DB041", 0x1c, 256, 2048, },
  461. @@ -89,7 +89,7 @@ int bcma_sflash_init(struct bcma_drv_cc
  462. {
  463. struct bcma_bus *bus = cc->core->bus;
  464. struct bcma_sflash *sflash = &cc->sflash;
  465. - struct bcma_sflash_tbl_e *e;
  466. + const struct bcma_sflash_tbl_e *e;
  467. u32 id, id2;
  468. switch (cc->capabilities & BCMA_CC_CAP_FLASHT) {
  469. --- a/drivers/bcma/driver_gpio.c
  470. +++ b/drivers/bcma/driver_gpio.c
  471. @@ -73,6 +73,16 @@ static void bcma_gpio_free(struct gpio_c
  472. bcma_chipco_gpio_pullup(cc, 1 << gpio, 0);
  473. }
  474. +static int bcma_gpio_to_irq(struct gpio_chip *chip, unsigned gpio)
  475. +{
  476. + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
  477. +
  478. + if (cc->core->bus->hosttype == BCMA_HOSTTYPE_SOC)
  479. + return bcma_core_irq(cc->core);
  480. + else
  481. + return -EINVAL;
  482. +}
  483. +
  484. int bcma_gpio_init(struct bcma_drv_cc *cc)
  485. {
  486. struct gpio_chip *chip = &cc->gpio;
  487. @@ -85,6 +95,7 @@ int bcma_gpio_init(struct bcma_drv_cc *c
  488. chip->set = bcma_gpio_set_value;
  489. chip->direction_input = bcma_gpio_direction_input;
  490. chip->direction_output = bcma_gpio_direction_output;
  491. + chip->to_irq = bcma_gpio_to_irq;
  492. chip->ngpio = 16;
  493. /* There is just one SoC in one device and its GPIO addresses should be
  494. * deterministic to address them more easily. The other buses could get
  495. --- a/drivers/bcma/driver_mips.c
  496. +++ b/drivers/bcma/driver_mips.c
  497. @@ -14,11 +14,33 @@
  498. #include <linux/bcma/bcma.h>
  499. +#include <linux/mtd/physmap.h>
  500. +#include <linux/platform_device.h>
  501. #include <linux/serial.h>
  502. #include <linux/serial_core.h>
  503. #include <linux/serial_reg.h>
  504. #include <linux/time.h>
  505. +static const char *part_probes[] = { "bcm47xxpart", NULL };
  506. +
  507. +static struct physmap_flash_data bcma_pflash_data = {
  508. + .part_probe_types = part_probes,
  509. +};
  510. +
  511. +static struct resource bcma_pflash_resource = {
  512. + .name = "bcma_pflash",
  513. + .flags = IORESOURCE_MEM,
  514. +};
  515. +
  516. +struct platform_device bcma_pflash_dev = {
  517. + .name = "physmap-flash",
  518. + .dev = {
  519. + .platform_data = &bcma_pflash_data,
  520. + },
  521. + .resource = &bcma_pflash_resource,
  522. + .num_resources = 1,
  523. +};
  524. +
  525. /* The 47162a0 hangs when reading MIPS DMP registers registers */
  526. static inline bool bcma_core_mips_bcm47162a0_quirk(struct bcma_device *dev)
  527. {
  528. @@ -74,28 +96,41 @@ static u32 bcma_core_mips_irqflag(struct
  529. return dev->core_index;
  530. flag = bcma_aread32(dev, BCMA_MIPS_OOBSELOUTA30);
  531. - return flag & 0x1F;
  532. + if (flag)
  533. + return flag & 0x1F;
  534. + else
  535. + return 0x3f;
  536. }
  537. /* Get the MIPS IRQ assignment for a specified device.
  538. * If unassigned, 0 is returned.
  539. + * If disabled, 5 is returned.
  540. + * If not supported, 6 is returned.
  541. */
  542. -unsigned int bcma_core_mips_irq(struct bcma_device *dev)
  543. +static unsigned int bcma_core_mips_irq(struct bcma_device *dev)
  544. {
  545. struct bcma_device *mdev = dev->bus->drv_mips.core;
  546. u32 irqflag;
  547. unsigned int irq;
  548. irqflag = bcma_core_mips_irqflag(dev);
  549. + if (irqflag == 0x3f)
  550. + return 6;
  551. - for (irq = 1; irq <= 4; irq++)
  552. + for (irq = 0; irq <= 4; irq++)
  553. if (bcma_read32(mdev, BCMA_MIPS_MIPS74K_INTMASK(irq)) &
  554. (1 << irqflag))
  555. return irq;
  556. - return 0;
  557. + return 5;
  558. }
  559. -EXPORT_SYMBOL(bcma_core_mips_irq);
  560. +
  561. +unsigned int bcma_core_irq(struct bcma_device *dev)
  562. +{
  563. + unsigned int mips_irq = bcma_core_mips_irq(dev);
  564. + return mips_irq <= 4 ? mips_irq + 2 : 0;
  565. +}
  566. +EXPORT_SYMBOL(bcma_core_irq);
  567. static void bcma_core_mips_set_irq(struct bcma_device *dev, unsigned int irq)
  568. {
  569. @@ -114,7 +149,7 @@ static void bcma_core_mips_set_irq(struc
  570. bcma_write32(mdev, BCMA_MIPS_MIPS74K_INTMASK(0),
  571. bcma_read32(mdev, BCMA_MIPS_MIPS74K_INTMASK(0)) &
  572. ~(1 << irqflag));
  573. - else
  574. + else if (oldirq != 5)
  575. bcma_write32(mdev, BCMA_MIPS_MIPS74K_INTMASK(oldirq), 0);
  576. /* assign the new one */
  577. @@ -123,9 +158,9 @@ static void bcma_core_mips_set_irq(struc
  578. bcma_read32(mdev, BCMA_MIPS_MIPS74K_INTMASK(0)) |
  579. (1 << irqflag));
  580. } else {
  581. - u32 oldirqflag = bcma_read32(mdev,
  582. - BCMA_MIPS_MIPS74K_INTMASK(irq));
  583. - if (oldirqflag) {
  584. + u32 irqinitmask = bcma_read32(mdev,
  585. + BCMA_MIPS_MIPS74K_INTMASK(irq));
  586. + if (irqinitmask) {
  587. struct bcma_device *core;
  588. /* backplane irq line is in use, find out who uses
  589. @@ -133,7 +168,7 @@ static void bcma_core_mips_set_irq(struc
  590. */
  591. list_for_each_entry(core, &bus->cores, list) {
  592. if ((1 << bcma_core_mips_irqflag(core)) ==
  593. - oldirqflag) {
  594. + irqinitmask) {
  595. bcma_core_mips_set_irq(core, 0);
  596. break;
  597. }
  598. @@ -143,15 +178,31 @@ static void bcma_core_mips_set_irq(struc
  599. 1 << irqflag);
  600. }
  601. - bcma_info(bus, "set_irq: core 0x%04x, irq %d => %d\n",
  602. - dev->id.id, oldirq + 2, irq + 2);
  603. + bcma_debug(bus, "set_irq: core 0x%04x, irq %d => %d\n",
  604. + dev->id.id, oldirq <= 4 ? oldirq + 2 : 0, irq + 2);
  605. +}
  606. +
  607. +static void bcma_core_mips_set_irq_name(struct bcma_bus *bus, unsigned int irq,
  608. + u16 coreid, u8 unit)
  609. +{
  610. + struct bcma_device *core;
  611. +
  612. + core = bcma_find_core_unit(bus, coreid, unit);
  613. + if (!core) {
  614. + bcma_warn(bus,
  615. + "Can not find core (id: 0x%x, unit %i) for IRQ configuration.\n",
  616. + coreid, unit);
  617. + return;
  618. + }
  619. +
  620. + bcma_core_mips_set_irq(core, irq);
  621. }
  622. static void bcma_core_mips_print_irq(struct bcma_device *dev, unsigned int irq)
  623. {
  624. int i;
  625. static const char *irq_name[] = {"2(S)", "3", "4", "5", "6", "D", "I"};
  626. - printk(KERN_INFO KBUILD_MODNAME ": core 0x%04x, irq :", dev->id.id);
  627. + printk(KERN_DEBUG KBUILD_MODNAME ": core 0x%04x, irq :", dev->id.id);
  628. for (i = 0; i <= 6; i++)
  629. printk(" %s%s", irq_name[i], i == irq ? "*" : " ");
  630. printk("\n");
  631. @@ -182,6 +233,7 @@ static void bcma_core_mips_flash_detect(
  632. {
  633. struct bcma_bus *bus = mcore->core->bus;
  634. struct bcma_drv_cc *cc = &bus->drv_cc;
  635. + struct bcma_pflash *pflash = &cc->pflash;
  636. switch (cc->capabilities & BCMA_CC_CAP_FLASHT) {
  637. case BCMA_CC_FLASHT_STSER:
  638. @@ -191,15 +243,20 @@ static void bcma_core_mips_flash_detect(
  639. break;
  640. case BCMA_CC_FLASHT_PARA:
  641. bcma_debug(bus, "Found parallel flash\n");
  642. - cc->pflash.present = true;
  643. - cc->pflash.window = BCMA_SOC_FLASH2;
  644. - cc->pflash.window_size = BCMA_SOC_FLASH2_SZ;
  645. + pflash->present = true;
  646. + pflash->window = BCMA_SOC_FLASH2;
  647. + pflash->window_size = BCMA_SOC_FLASH2_SZ;
  648. if ((bcma_read32(cc->core, BCMA_CC_FLASH_CFG) &
  649. BCMA_CC_FLASH_CFG_DS) == 0)
  650. - cc->pflash.buswidth = 1;
  651. + pflash->buswidth = 1;
  652. else
  653. - cc->pflash.buswidth = 2;
  654. + pflash->buswidth = 2;
  655. +
  656. + bcma_pflash_data.width = pflash->buswidth;
  657. + bcma_pflash_resource.start = pflash->window;
  658. + bcma_pflash_resource.end = pflash->window + pflash->window_size;
  659. +
  660. break;
  661. default:
  662. bcma_err(bus, "Flash type not supported\n");
  663. @@ -227,6 +284,32 @@ void bcma_core_mips_early_init(struct bc
  664. mcore->early_setup_done = true;
  665. }
  666. +static void bcma_fix_i2s_irqflag(struct bcma_bus *bus)
  667. +{
  668. + struct bcma_device *cpu, *pcie, *i2s;
  669. +
  670. + /* Fixup the interrupts in 4716/4748 for i2s core (2010 Broadcom SDK)
  671. + * (IRQ flags > 7 are ignored when setting the interrupt masks)
  672. + */
  673. + if (bus->chipinfo.id != BCMA_CHIP_ID_BCM4716 &&
  674. + bus->chipinfo.id != BCMA_CHIP_ID_BCM4748)
  675. + return;
  676. +
  677. + cpu = bcma_find_core(bus, BCMA_CORE_MIPS_74K);
  678. + pcie = bcma_find_core(bus, BCMA_CORE_PCIE);
  679. + i2s = bcma_find_core(bus, BCMA_CORE_I2S);
  680. + if (cpu && pcie && i2s &&
  681. + bcma_aread32(cpu, BCMA_MIPS_OOBSELINA74) == 0x08060504 &&
  682. + bcma_aread32(pcie, BCMA_MIPS_OOBSELINA74) == 0x08060504 &&
  683. + bcma_aread32(i2s, BCMA_MIPS_OOBSELOUTA30) == 0x88) {
  684. + bcma_awrite32(cpu, BCMA_MIPS_OOBSELINA74, 0x07060504);
  685. + bcma_awrite32(pcie, BCMA_MIPS_OOBSELINA74, 0x07060504);
  686. + bcma_awrite32(i2s, BCMA_MIPS_OOBSELOUTA30, 0x87);
  687. + bcma_debug(bus,
  688. + "Moved i2s interrupt to oob line 7 instead of 8\n");
  689. + }
  690. +}
  691. +
  692. void bcma_core_mips_init(struct bcma_drv_mips *mcore)
  693. {
  694. struct bcma_bus *bus;
  695. @@ -236,43 +319,55 @@ void bcma_core_mips_init(struct bcma_drv
  696. if (mcore->setup_done)
  697. return;
  698. - bcma_info(bus, "Initializing MIPS core...\n");
  699. + bcma_debug(bus, "Initializing MIPS core...\n");
  700. bcma_core_mips_early_init(mcore);
  701. - mcore->assigned_irqs = 1;
  702. + bcma_fix_i2s_irqflag(bus);
  703. - /* Assign IRQs to all cores on the bus */
  704. - list_for_each_entry(core, &bus->cores, list) {
  705. - int mips_irq;
  706. - if (core->irq)
  707. - continue;
  708. -
  709. - mips_irq = bcma_core_mips_irq(core);
  710. - if (mips_irq > 4)
  711. - core->irq = 0;
  712. - else
  713. - core->irq = mips_irq + 2;
  714. - if (core->irq > 5)
  715. - continue;
  716. - switch (core->id.id) {
  717. - case BCMA_CORE_PCI:
  718. - case BCMA_CORE_PCIE:
  719. - case BCMA_CORE_ETHERNET:
  720. - case BCMA_CORE_ETHERNET_GBIT:
  721. - case BCMA_CORE_MAC_GBIT:
  722. - case BCMA_CORE_80211:
  723. - case BCMA_CORE_USB20_HOST:
  724. - /* These devices get their own IRQ line if available,
  725. - * the rest goes on IRQ0
  726. - */
  727. - if (mcore->assigned_irqs <= 4)
  728. - bcma_core_mips_set_irq(core,
  729. - mcore->assigned_irqs++);
  730. - break;
  731. + switch (bus->chipinfo.id) {
  732. + case BCMA_CHIP_ID_BCM4716:
  733. + case BCMA_CHIP_ID_BCM4748:
  734. + bcma_core_mips_set_irq_name(bus, 1, BCMA_CORE_80211, 0);
  735. + bcma_core_mips_set_irq_name(bus, 2, BCMA_CORE_MAC_GBIT, 0);
  736. + bcma_core_mips_set_irq_name(bus, 3, BCMA_CORE_USB20_HOST, 0);
  737. + bcma_core_mips_set_irq_name(bus, 4, BCMA_CORE_PCIE, 0);
  738. + bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_CHIPCOMMON, 0);
  739. + bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_I2S, 0);
  740. + break;
  741. + case BCMA_CHIP_ID_BCM5356:
  742. + case BCMA_CHIP_ID_BCM47162:
  743. + case BCMA_CHIP_ID_BCM53572:
  744. + bcma_core_mips_set_irq_name(bus, 1, BCMA_CORE_80211, 0);
  745. + bcma_core_mips_set_irq_name(bus, 2, BCMA_CORE_MAC_GBIT, 0);
  746. + bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_CHIPCOMMON, 0);
  747. + break;
  748. + case BCMA_CHIP_ID_BCM5357:
  749. + case BCMA_CHIP_ID_BCM4749:
  750. + bcma_core_mips_set_irq_name(bus, 1, BCMA_CORE_80211, 0);
  751. + bcma_core_mips_set_irq_name(bus, 2, BCMA_CORE_MAC_GBIT, 0);
  752. + bcma_core_mips_set_irq_name(bus, 3, BCMA_CORE_USB20_HOST, 0);
  753. + bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_CHIPCOMMON, 0);
  754. + bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_I2S, 0);
  755. + break;
  756. + case BCMA_CHIP_ID_BCM4706:
  757. + bcma_core_mips_set_irq_name(bus, 1, BCMA_CORE_PCIE, 0);
  758. + bcma_core_mips_set_irq_name(bus, 2, BCMA_CORE_4706_MAC_GBIT,
  759. + 0);
  760. + bcma_core_mips_set_irq_name(bus, 3, BCMA_CORE_PCIE, 1);
  761. + bcma_core_mips_set_irq_name(bus, 4, BCMA_CORE_USB20_HOST, 0);
  762. + bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_4706_CHIPCOMMON,
  763. + 0);
  764. + break;
  765. + default:
  766. + list_for_each_entry(core, &bus->cores, list) {
  767. + core->irq = bcma_core_irq(core);
  768. }
  769. + bcma_err(bus,
  770. + "Unknown device (0x%x) found, can not configure IRQs\n",
  771. + bus->chipinfo.id);
  772. }
  773. - bcma_info(bus, "IRQ reconfiguration done\n");
  774. + bcma_debug(bus, "IRQ reconfiguration done\n");
  775. bcma_core_mips_dump_irq(bus);
  776. mcore->setup_done = true;
  777. --- a/drivers/bcma/driver_pci_host.c
  778. +++ b/drivers/bcma/driver_pci_host.c
  779. @@ -94,19 +94,19 @@ static int bcma_extpci_read_config(struc
  780. if (dev == 0) {
  781. /* we support only two functions on device 0 */
  782. if (func > 1)
  783. - return -EINVAL;
  784. + goto out;
  785. /* accesses to config registers with offsets >= 256
  786. * requires indirect access.
  787. */
  788. if (off >= PCI_CONFIG_SPACE_SIZE) {
  789. addr = (func << 12);
  790. - addr |= (off & 0x0FFF);
  791. + addr |= (off & 0x0FFC);
  792. val = bcma_pcie_read_config(pc, addr);
  793. } else {
  794. addr = BCMA_CORE_PCI_PCICFG0;
  795. addr |= (func << 8);
  796. - addr |= (off & 0xfc);
  797. + addr |= (off & 0xFC);
  798. val = pcicore_read32(pc, addr);
  799. }
  800. } else {
  801. @@ -119,11 +119,9 @@ static int bcma_extpci_read_config(struc
  802. goto out;
  803. if (mips_busprobe32(val, mmio)) {
  804. - val = 0xffffffff;
  805. + val = 0xFFFFFFFF;
  806. goto unmap;
  807. }
  808. -
  809. - val = readl(mmio);
  810. }
  811. val >>= (8 * (off & 3));
  812. @@ -151,7 +149,7 @@ static int bcma_extpci_write_config(stru
  813. const void *buf, int len)
  814. {
  815. int err = -EINVAL;
  816. - u32 addr = 0, val = 0;
  817. + u32 addr, val;
  818. void __iomem *mmio = 0;
  819. u16 chipid = pc->core->bus->chipinfo.id;
  820. @@ -159,16 +157,22 @@ static int bcma_extpci_write_config(stru
  821. if (unlikely(len != 1 && len != 2 && len != 4))
  822. goto out;
  823. if (dev == 0) {
  824. + /* we support only two functions on device 0 */
  825. + if (func > 1)
  826. + goto out;
  827. +
  828. /* accesses to config registers with offsets >= 256
  829. * requires indirect access.
  830. */
  831. - if (off < PCI_CONFIG_SPACE_SIZE) {
  832. - addr = pc->core->addr + BCMA_CORE_PCI_PCICFG0;
  833. + if (off >= PCI_CONFIG_SPACE_SIZE) {
  834. + addr = (func << 12);
  835. + addr |= (off & 0x0FFC);
  836. + val = bcma_pcie_read_config(pc, addr);
  837. + } else {
  838. + addr = BCMA_CORE_PCI_PCICFG0;
  839. addr |= (func << 8);
  840. - addr |= (off & 0xfc);
  841. - mmio = ioremap_nocache(addr, sizeof(val));
  842. - if (!mmio)
  843. - goto out;
  844. + addr |= (off & 0xFC);
  845. + val = pcicore_read32(pc, addr);
  846. }
  847. } else {
  848. addr = bcma_get_cfgspace_addr(pc, dev, func, off);
  849. @@ -180,19 +184,17 @@ static int bcma_extpci_write_config(stru
  850. goto out;
  851. if (mips_busprobe32(val, mmio)) {
  852. - val = 0xffffffff;
  853. + val = 0xFFFFFFFF;
  854. goto unmap;
  855. }
  856. }
  857. switch (len) {
  858. case 1:
  859. - val = readl(mmio);
  860. val &= ~(0xFF << (8 * (off & 3)));
  861. val |= *((const u8 *)buf) << (8 * (off & 3));
  862. break;
  863. case 2:
  864. - val = readl(mmio);
  865. val &= ~(0xFFFF << (8 * (off & 3)));
  866. val |= *((const u16 *)buf) << (8 * (off & 3));
  867. break;
  868. @@ -200,13 +202,14 @@ static int bcma_extpci_write_config(stru
  869. val = *((const u32 *)buf);
  870. break;
  871. }
  872. - if (dev == 0 && !addr) {
  873. + if (dev == 0) {
  874. /* accesses to config registers with offsets >= 256
  875. * requires indirect access.
  876. */
  877. - addr = (func << 12);
  878. - addr |= (off & 0x0FFF);
  879. - bcma_pcie_write_config(pc, addr, val);
  880. + if (off >= PCI_CONFIG_SPACE_SIZE)
  881. + bcma_pcie_write_config(pc, addr, val);
  882. + else
  883. + pcicore_write32(pc, addr, val);
  884. } else {
  885. writel(val, mmio);
  886. @@ -276,7 +279,7 @@ static u8 bcma_find_pci_capability(struc
  887. /* check for Header type 0 */
  888. bcma_extpci_read_config(pc, dev, func, PCI_HEADER_TYPE, &byte_val,
  889. sizeof(u8));
  890. - if ((byte_val & 0x7f) != PCI_HEADER_TYPE_NORMAL)
  891. + if ((byte_val & 0x7F) != PCI_HEADER_TYPE_NORMAL)
  892. return cap_ptr;
  893. /* check if the capability pointer field exists */
  894. @@ -401,6 +404,8 @@ void bcma_core_pci_hostmode_init(struct
  895. return;
  896. }
  897. + spin_lock_init(&pc_host->cfgspace_lock);
  898. +
  899. pc->host_controller = pc_host;
  900. pc_host->pci_controller.io_resource = &pc_host->io_resource;
  901. pc_host->pci_controller.mem_resource = &pc_host->mem_resource;
  902. @@ -426,7 +431,7 @@ void bcma_core_pci_hostmode_init(struct
  903. /* Reset RC */
  904. usleep_range(3000, 5000);
  905. pcicore_write32(pc, BCMA_CORE_PCI_CTL, BCMA_CORE_PCI_CTL_RST_OE);
  906. - usleep_range(1000, 2000);
  907. + msleep(50);
  908. pcicore_write32(pc, BCMA_CORE_PCI_CTL, BCMA_CORE_PCI_CTL_RST |
  909. BCMA_CORE_PCI_CTL_RST_OE);
  910. @@ -488,6 +493,17 @@ void bcma_core_pci_hostmode_init(struct
  911. bcma_core_pci_enable_crs(pc);
  912. + if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4706 ||
  913. + bus->chipinfo.id == BCMA_CHIP_ID_BCM4716) {
  914. + u16 val16;
  915. + bcma_extpci_read_config(pc, 0, 0, BCMA_CORE_PCI_CFG_DEVCTRL,
  916. + &val16, sizeof(val16));
  917. + val16 |= (2 << 5); /* Max payload size of 512 */
  918. + val16 |= (2 << 12); /* MRRS 512 */
  919. + bcma_extpci_write_config(pc, 0, 0, BCMA_CORE_PCI_CFG_DEVCTRL,
  920. + &val16, sizeof(val16));
  921. + }
  922. +
  923. /* Enable PCI bridge BAR0 memory & master access */
  924. tmp = PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY;
  925. bcma_extpci_write_config(pc, 0, 0, PCI_COMMAND, &tmp, sizeof(tmp));
  926. @@ -565,6 +581,7 @@ DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI
  927. int bcma_core_pci_plat_dev_init(struct pci_dev *dev)
  928. {
  929. struct bcma_drv_pci_host *pc_host;
  930. + int readrq;
  931. if (dev->bus->ops->read != bcma_core_pci_hostmode_read_config) {
  932. /* This is not a device on the PCI-core bridge. */
  933. @@ -576,9 +593,14 @@ int bcma_core_pci_plat_dev_init(struct p
  934. pr_info("PCI: Fixing up device %s\n", pci_name(dev));
  935. /* Fix up interrupt lines */
  936. - dev->irq = bcma_core_mips_irq(pc_host->pdev->core) + 2;
  937. + dev->irq = bcma_core_irq(pc_host->pdev->core);
  938. pci_write_config_byte(dev, PCI_INTERRUPT_LINE, dev->irq);
  939. + readrq = pcie_get_readrq(dev);
  940. + if (readrq > 128) {
  941. + pr_info("change PCIe max read request size from %i to 128\n", readrq);
  942. + pcie_set_readrq(dev, 128);
  943. + }
  944. return 0;
  945. }
  946. EXPORT_SYMBOL(bcma_core_pci_plat_dev_init);
  947. @@ -595,6 +617,6 @@ int bcma_core_pci_pcibios_map_irq(const
  948. pc_host = container_of(dev->bus->ops, struct bcma_drv_pci_host,
  949. pci_ops);
  950. - return bcma_core_mips_irq(pc_host->pdev->core) + 2;
  951. + return bcma_core_irq(pc_host->pdev->core);
  952. }
  953. EXPORT_SYMBOL(bcma_core_pci_pcibios_map_irq);
  954. --- a/drivers/bcma/host_pci.c
  955. +++ b/drivers/bcma/host_pci.c
  956. @@ -275,6 +275,7 @@ static DEFINE_PCI_DEVICE_TABLE(bcma_pci_
  957. { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4357) },
  958. { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4358) },
  959. { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4359) },
  960. + { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4365) },
  961. { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4727) },
  962. { 0, },
  963. };
  964. --- a/drivers/bcma/main.c
  965. +++ b/drivers/bcma/main.c
  966. @@ -81,8 +81,8 @@ struct bcma_device *bcma_find_core(struc
  967. }
  968. EXPORT_SYMBOL_GPL(bcma_find_core);
  969. -static struct bcma_device *bcma_find_core_unit(struct bcma_bus *bus, u16 coreid,
  970. - u8 unit)
  971. +struct bcma_device *bcma_find_core_unit(struct bcma_bus *bus, u16 coreid,
  972. + u8 unit)
  973. {
  974. struct bcma_device *core;
  975. @@ -93,6 +93,25 @@ static struct bcma_device *bcma_find_cor
  976. return NULL;
  977. }
  978. +bool bcma_wait_value(struct bcma_device *core, u16 reg, u32 mask, u32 value,
  979. + int timeout)
  980. +{
  981. + unsigned long deadline = jiffies + timeout;
  982. + u32 val;
  983. +
  984. + do {
  985. + val = bcma_read32(core, reg);
  986. + if ((val & mask) == value)
  987. + return true;
  988. + cpu_relax();
  989. + udelay(10);
  990. + } while (!time_after_eq(jiffies, deadline));
  991. +
  992. + bcma_warn(core->bus, "Timeout waiting for register 0x%04X!\n", reg);
  993. +
  994. + return false;
  995. +}
  996. +
  997. static void bcma_release_core_dev(struct device *dev)
  998. {
  999. struct bcma_device *core = container_of(dev, struct bcma_device, dev);
  1000. @@ -120,6 +139,11 @@ static int bcma_register_cores(struct bc
  1001. continue;
  1002. }
  1003. + /* Only first GMAC core on BCM4706 is connected and working */
  1004. + if (core->id.id == BCMA_CORE_4706_MAC_GBIT &&
  1005. + core->core_unit > 0)
  1006. + continue;
  1007. +
  1008. core->dev.release = bcma_release_core_dev;
  1009. core->dev.bus = &bcma_bus_type;
  1010. dev_set_name(&core->dev, "bcma%d:%d", bus->num, dev_id);
  1011. @@ -149,6 +173,14 @@ static int bcma_register_cores(struct bc
  1012. dev_id++;
  1013. }
  1014. +#ifdef CONFIG_BCMA_DRIVER_MIPS
  1015. + if (bus->drv_cc.pflash.present) {
  1016. + err = platform_device_register(&bcma_pflash_dev);
  1017. + if (err)
  1018. + bcma_err(bus, "Error registering parallel flash\n");
  1019. + }
  1020. +#endif
  1021. +
  1022. #ifdef CONFIG_BCMA_SFLASH
  1023. if (bus->drv_cc.sflash.present) {
  1024. err = platform_device_register(&bcma_sflash_dev);
  1025. @@ -205,7 +237,7 @@ int bcma_bus_register(struct bcma_bus *b
  1026. err = bcma_bus_scan(bus);
  1027. if (err) {
  1028. bcma_err(bus, "Failed to scan: %d\n", err);
  1029. - return -1;
  1030. + return err;
  1031. }
  1032. /* Early init CC core */
  1033. --- a/drivers/bcma/scan.c
  1034. +++ b/drivers/bcma/scan.c
  1035. @@ -32,6 +32,18 @@ static const struct bcma_device_id_name
  1036. { BCMA_CORE_4706_CHIPCOMMON, "BCM4706 ChipCommon" },
  1037. { BCMA_CORE_4706_SOC_RAM, "BCM4706 SOC RAM" },
  1038. { BCMA_CORE_4706_MAC_GBIT, "BCM4706 GBit MAC" },
  1039. + { BCMA_CORE_PCIEG2, "PCIe Gen 2" },
  1040. + { BCMA_CORE_DMA, "DMA" },
  1041. + { BCMA_CORE_SDIO3, "SDIO3" },
  1042. + { BCMA_CORE_USB20, "USB 2.0" },
  1043. + { BCMA_CORE_USB30, "USB 3.0" },
  1044. + { BCMA_CORE_A9JTAG, "ARM Cortex A9 JTAG" },
  1045. + { BCMA_CORE_DDR23, "Denali DDR2/DDR3 memory controller" },
  1046. + { BCMA_CORE_ROM, "ROM" },
  1047. + { BCMA_CORE_NAND, "NAND flash controller" },
  1048. + { BCMA_CORE_QSPI, "SPI flash controller" },
  1049. + { BCMA_CORE_CHIPCOMMON_B, "Chipcommon B" },
  1050. + { BCMA_CORE_ARMCA9, "ARM Cortex A9 core (ihost)" },
  1051. { BCMA_CORE_AMEMC, "AMEMC (DDR)" },
  1052. { BCMA_CORE_ALTA, "ALTA (I2S)" },
  1053. { BCMA_CORE_INVALID, "Invalid" },
  1054. @@ -84,6 +96,8 @@ static const struct bcma_device_id_name
  1055. { BCMA_CORE_I2S, "I2S" },
  1056. { BCMA_CORE_SDR_DDR1_MEM_CTL, "SDR/DDR1 Memory Controller" },
  1057. { BCMA_CORE_SHIM, "SHIM" },
  1058. + { BCMA_CORE_PCIE2, "PCIe Gen2" },
  1059. + { BCMA_CORE_ARM_CR4, "ARM CR4" },
  1060. { BCMA_CORE_DEFAULT, "Default" },
  1061. };
  1062. @@ -137,19 +151,19 @@ static void bcma_scan_switch_core(struct
  1063. addr);
  1064. }
  1065. -static u32 bcma_erom_get_ent(struct bcma_bus *bus, u32 **eromptr)
  1066. +static u32 bcma_erom_get_ent(struct bcma_bus *bus, u32 __iomem **eromptr)
  1067. {
  1068. u32 ent = readl(*eromptr);
  1069. (*eromptr)++;
  1070. return ent;
  1071. }
  1072. -static void bcma_erom_push_ent(u32 **eromptr)
  1073. +static void bcma_erom_push_ent(u32 __iomem **eromptr)
  1074. {
  1075. (*eromptr)--;
  1076. }
  1077. -static s32 bcma_erom_get_ci(struct bcma_bus *bus, u32 **eromptr)
  1078. +static s32 bcma_erom_get_ci(struct bcma_bus *bus, u32 __iomem **eromptr)
  1079. {
  1080. u32 ent = bcma_erom_get_ent(bus, eromptr);
  1081. if (!(ent & SCAN_ER_VALID))
  1082. @@ -159,14 +173,14 @@ static s32 bcma_erom_get_ci(struct bcma_
  1083. return ent;
  1084. }
  1085. -static bool bcma_erom_is_end(struct bcma_bus *bus, u32 **eromptr)
  1086. +static bool bcma_erom_is_end(struct bcma_bus *bus, u32 __iomem **eromptr)
  1087. {
  1088. u32 ent = bcma_erom_get_ent(bus, eromptr);
  1089. bcma_erom_push_ent(eromptr);
  1090. return (ent == (SCAN_ER_TAG_END | SCAN_ER_VALID));
  1091. }
  1092. -static bool bcma_erom_is_bridge(struct bcma_bus *bus, u32 **eromptr)
  1093. +static bool bcma_erom_is_bridge(struct bcma_bus *bus, u32 __iomem **eromptr)
  1094. {
  1095. u32 ent = bcma_erom_get_ent(bus, eromptr);
  1096. bcma_erom_push_ent(eromptr);
  1097. @@ -175,7 +189,7 @@ static bool bcma_erom_is_bridge(struct b
  1098. ((ent & SCAN_ADDR_TYPE) == SCAN_ADDR_TYPE_BRIDGE));
  1099. }
  1100. -static void bcma_erom_skip_component(struct bcma_bus *bus, u32 **eromptr)
  1101. +static void bcma_erom_skip_component(struct bcma_bus *bus, u32 __iomem **eromptr)
  1102. {
  1103. u32 ent;
  1104. while (1) {
  1105. @@ -189,7 +203,7 @@ static void bcma_erom_skip_component(str
  1106. bcma_erom_push_ent(eromptr);
  1107. }
  1108. -static s32 bcma_erom_get_mst_port(struct bcma_bus *bus, u32 **eromptr)
  1109. +static s32 bcma_erom_get_mst_port(struct bcma_bus *bus, u32 __iomem **eromptr)
  1110. {
  1111. u32 ent = bcma_erom_get_ent(bus, eromptr);
  1112. if (!(ent & SCAN_ER_VALID))
  1113. @@ -199,7 +213,7 @@ static s32 bcma_erom_get_mst_port(struct
  1114. return ent;
  1115. }
  1116. -static s32 bcma_erom_get_addr_desc(struct bcma_bus *bus, u32 **eromptr,
  1117. +static u32 bcma_erom_get_addr_desc(struct bcma_bus *bus, u32 __iomem **eromptr,
  1118. u32 type, u8 port)
  1119. {
  1120. u32 addrl, addrh, sizel, sizeh = 0;
  1121. @@ -211,7 +225,7 @@ static s32 bcma_erom_get_addr_desc(struc
  1122. ((ent & SCAN_ADDR_TYPE) != type) ||
  1123. (((ent & SCAN_ADDR_PORT) >> SCAN_ADDR_PORT_SHIFT) != port)) {
  1124. bcma_erom_push_ent(eromptr);
  1125. - return -EINVAL;
  1126. + return (u32)-EINVAL;
  1127. }
  1128. addrl = ent & SCAN_ADDR_ADDR;
  1129. @@ -255,11 +269,13 @@ static struct bcma_device *bcma_find_cor
  1130. return NULL;
  1131. }
  1132. +#define IS_ERR_VALUE_U32(x) ((x) >= (u32)-MAX_ERRNO)
  1133. +
  1134. static int bcma_get_next_core(struct bcma_bus *bus, u32 __iomem **eromptr,
  1135. struct bcma_device_id *match, int core_num,
  1136. struct bcma_device *core)
  1137. {
  1138. - s32 tmp;
  1139. + u32 tmp;
  1140. u8 i, j;
  1141. s32 cia, cib;
  1142. u8 ports[2], wrappers[2];
  1143. @@ -337,11 +353,11 @@ static int bcma_get_next_core(struct bcm
  1144. * the main register space for the core
  1145. */
  1146. tmp = bcma_erom_get_addr_desc(bus, eromptr, SCAN_ADDR_TYPE_SLAVE, 0);
  1147. - if (tmp <= 0) {
  1148. + if (tmp == 0 || IS_ERR_VALUE_U32(tmp)) {
  1149. /* Try again to see if it is a bridge */
  1150. tmp = bcma_erom_get_addr_desc(bus, eromptr,
  1151. SCAN_ADDR_TYPE_BRIDGE, 0);
  1152. - if (tmp <= 0) {
  1153. + if (tmp == 0 || IS_ERR_VALUE_U32(tmp)) {
  1154. return -EILSEQ;
  1155. } else {
  1156. bcma_info(bus, "Bridge found\n");
  1157. @@ -355,7 +371,7 @@ static int bcma_get_next_core(struct bcm
  1158. for (j = 0; ; j++) {
  1159. tmp = bcma_erom_get_addr_desc(bus, eromptr,
  1160. SCAN_ADDR_TYPE_SLAVE, i);
  1161. - if (tmp < 0) {
  1162. + if (IS_ERR_VALUE_U32(tmp)) {
  1163. /* no more entries for port _i_ */
  1164. /* pr_debug("erom: slave port %d "
  1165. * "has %d descriptors\n", i, j); */
  1166. @@ -372,7 +388,7 @@ static int bcma_get_next_core(struct bcm
  1167. for (j = 0; ; j++) {
  1168. tmp = bcma_erom_get_addr_desc(bus, eromptr,
  1169. SCAN_ADDR_TYPE_MWRAP, i);
  1170. - if (tmp < 0) {
  1171. + if (IS_ERR_VALUE_U32(tmp)) {
  1172. /* no more entries for port _i_ */
  1173. /* pr_debug("erom: master wrapper %d "
  1174. * "has %d descriptors\n", i, j); */
  1175. @@ -390,7 +406,7 @@ static int bcma_get_next_core(struct bcm
  1176. for (j = 0; ; j++) {
  1177. tmp = bcma_erom_get_addr_desc(bus, eromptr,
  1178. SCAN_ADDR_TYPE_SWRAP, i + hack);
  1179. - if (tmp < 0) {
  1180. + if (IS_ERR_VALUE_U32(tmp)) {
  1181. /* no more entries for port _i_ */
  1182. /* pr_debug("erom: master wrapper %d "
  1183. * has %d descriptors\n", i, j); */
  1184. --- a/drivers/bcma/sprom.c
  1185. +++ b/drivers/bcma/sprom.c
  1186. @@ -72,12 +72,12 @@ fail:
  1187. * R/W ops.
  1188. **************************************************/
  1189. -static void bcma_sprom_read(struct bcma_bus *bus, u16 offset, u16 *sprom)
  1190. +static void bcma_sprom_read(struct bcma_bus *bus, u16 offset, u16 *sprom,
  1191. + size_t words)
  1192. {
  1193. int i;
  1194. - for (i = 0; i < SSB_SPROMSIZE_WORDS_R4; i++)
  1195. - sprom[i] = bcma_read16(bus->drv_cc.core,
  1196. - offset + (i * 2));
  1197. + for (i = 0; i < words; i++)
  1198. + sprom[i] = bcma_read16(bus->drv_cc.core, offset + (i * 2));
  1199. }
  1200. /**************************************************
  1201. @@ -124,29 +124,29 @@ static inline u8 bcma_crc8(u8 crc, u8 da
  1202. return t[crc ^ data];
  1203. }
  1204. -static u8 bcma_sprom_crc(const u16 *sprom)
  1205. +static u8 bcma_sprom_crc(const u16 *sprom, size_t words)
  1206. {
  1207. int word;
  1208. u8 crc = 0xFF;
  1209. - for (word = 0; word < SSB_SPROMSIZE_WORDS_R4 - 1; word++) {
  1210. + for (word = 0; word < words - 1; word++) {
  1211. crc = bcma_crc8(crc, sprom[word] & 0x00FF);
  1212. crc = bcma_crc8(crc, (sprom[word] & 0xFF00) >> 8);
  1213. }
  1214. - crc = bcma_crc8(crc, sprom[SSB_SPROMSIZE_WORDS_R4 - 1] & 0x00FF);
  1215. + crc = bcma_crc8(crc, sprom[words - 1] & 0x00FF);
  1216. crc ^= 0xFF;
  1217. return crc;
  1218. }
  1219. -static int bcma_sprom_check_crc(const u16 *sprom)
  1220. +static int bcma_sprom_check_crc(const u16 *sprom, size_t words)
  1221. {
  1222. u8 crc;
  1223. u8 expected_crc;
  1224. u16 tmp;
  1225. - crc = bcma_sprom_crc(sprom);
  1226. - tmp = sprom[SSB_SPROMSIZE_WORDS_R4 - 1] & SSB_SPROM_REVISION_CRC;
  1227. + crc = bcma_sprom_crc(sprom, words);
  1228. + tmp = sprom[words - 1] & SSB_SPROM_REVISION_CRC;
  1229. expected_crc = tmp >> SSB_SPROM_REVISION_CRC_SHIFT;
  1230. if (crc != expected_crc)
  1231. return -EPROTO;
  1232. @@ -154,21 +154,25 @@ static int bcma_sprom_check_crc(const u1
  1233. return 0;
  1234. }
  1235. -static int bcma_sprom_valid(const u16 *sprom)
  1236. +static int bcma_sprom_valid(struct bcma_bus *bus, const u16 *sprom,
  1237. + size_t words)
  1238. {
  1239. u16 revision;
  1240. int err;
  1241. - err = bcma_sprom_check_crc(sprom);
  1242. + err = bcma_sprom_check_crc(sprom, words);
  1243. if (err)
  1244. return err;
  1245. - revision = sprom[SSB_SPROMSIZE_WORDS_R4 - 1] & SSB_SPROM_REVISION_REV;
  1246. - if (revision != 8 && revision != 9) {
  1247. + revision = sprom[words - 1] & SSB_SPROM_REVISION_REV;
  1248. + if (revision != 8 && revision != 9 && revision != 10) {
  1249. pr_err("Unsupported SPROM revision: %d\n", revision);
  1250. return -ENOENT;
  1251. }
  1252. + bus->sprom.revision = revision;
  1253. + bcma_debug(bus, "Found SPROM revision %d\n", revision);
  1254. +
  1255. return 0;
  1256. }
  1257. @@ -208,15 +212,13 @@ static void bcma_sprom_extract_r8(struct
  1258. BUILD_BUG_ON(ARRAY_SIZE(pwr_info_offset) !=
  1259. ARRAY_SIZE(bus->sprom.core_pwr_info));
  1260. - bus->sprom.revision = sprom[SSB_SPROMSIZE_WORDS_R4 - 1] &
  1261. - SSB_SPROM_REVISION_REV;
  1262. -
  1263. for (i = 0; i < 3; i++) {
  1264. v = sprom[SPOFF(SSB_SPROM8_IL0MAC) + i];
  1265. *(((__be16 *)bus->sprom.il0mac) + i) = cpu_to_be16(v);
  1266. }
  1267. SPEX(board_rev, SSB_SPROM8_BOARDREV, ~0, 0);
  1268. + SPEX(board_type, SSB_SPROM1_SPID, ~0, 0);
  1269. SPEX(txpid2g[0], SSB_SPROM4_TXPID2G01, SSB_SPROM4_TXPID2G0,
  1270. SSB_SPROM4_TXPID2G0_SHIFT);
  1271. @@ -501,7 +503,7 @@ static bool bcma_sprom_onchip_available(
  1272. case BCMA_CHIP_ID_BCM4331:
  1273. present = chip_status & BCMA_CC_CHIPST_4331_OTP_PRESENT;
  1274. break;
  1275. -
  1276. + case BCMA_CHIP_ID_BCM43142:
  1277. case BCMA_CHIP_ID_BCM43224:
  1278. case BCMA_CHIP_ID_BCM43225:
  1279. /* for these chips OTP is always available */
  1280. @@ -549,7 +551,9 @@ int bcma_sprom_get(struct bcma_bus *bus)
  1281. {
  1282. u16 offset = BCMA_CC_SPROM;
  1283. u16 *sprom;
  1284. - int err = 0;
  1285. + size_t sprom_sizes[] = { SSB_SPROMSIZE_WORDS_R4,
  1286. + SSB_SPROMSIZE_WORDS_R10, };
  1287. + int i, err = 0;
  1288. if (!bus->drv_cc.core)
  1289. return -EOPNOTSUPP;
  1290. @@ -578,32 +582,37 @@ int bcma_sprom_get(struct bcma_bus *bus)
  1291. }
  1292. }
  1293. - sprom = kcalloc(SSB_SPROMSIZE_WORDS_R4, sizeof(u16),
  1294. - GFP_KERNEL);
  1295. - if (!sprom)
  1296. - return -ENOMEM;
  1297. -
  1298. if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4331 ||
  1299. bus->chipinfo.id == BCMA_CHIP_ID_BCM43431)
  1300. bcma_chipco_bcm4331_ext_pa_lines_ctl(&bus->drv_cc, false);
  1301. bcma_debug(bus, "SPROM offset 0x%x\n", offset);
  1302. - bcma_sprom_read(bus, offset, sprom);
  1303. + for (i = 0; i < ARRAY_SIZE(sprom_sizes); i++) {
  1304. + size_t words = sprom_sizes[i];
  1305. +
  1306. + sprom = kcalloc(words, sizeof(u16), GFP_KERNEL);
  1307. + if (!sprom)
  1308. + return -ENOMEM;
  1309. +
  1310. + bcma_sprom_read(bus, offset, sprom, words);
  1311. + err = bcma_sprom_valid(bus, sprom, words);
  1312. + if (!err)
  1313. + break;
  1314. +
  1315. + kfree(sprom);
  1316. + }
  1317. if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4331 ||
  1318. bus->chipinfo.id == BCMA_CHIP_ID_BCM43431)
  1319. bcma_chipco_bcm4331_ext_pa_lines_ctl(&bus->drv_cc, true);
  1320. - err = bcma_sprom_valid(sprom);
  1321. if (err) {
  1322. - bcma_warn(bus, "invalid sprom read from the PCIe card, try to use fallback sprom\n");
  1323. + bcma_warn(bus, "Invalid SPROM read from the PCIe card, trying to use fallback SPROM\n");
  1324. err = bcma_fill_sprom_with_fallback(bus, &bus->sprom);
  1325. - goto out;
  1326. + } else {
  1327. + bcma_sprom_extract_r8(bus, sprom);
  1328. + kfree(sprom);
  1329. }
  1330. - bcma_sprom_extract_r8(bus, sprom);
  1331. -
  1332. -out:
  1333. - kfree(sprom);
  1334. return err;
  1335. }
  1336. --- a/include/linux/bcma/bcma.h
  1337. +++ b/include/linux/bcma/bcma.h
  1338. @@ -72,7 +72,19 @@ struct bcma_host_ops {
  1339. /* Core-ID values. */
  1340. #define BCMA_CORE_OOB_ROUTER 0x367 /* Out of band */
  1341. #define BCMA_CORE_4706_CHIPCOMMON 0x500
  1342. +#define BCMA_CORE_PCIEG2 0x501
  1343. +#define BCMA_CORE_DMA 0x502
  1344. +#define BCMA_CORE_SDIO3 0x503
  1345. +#define BCMA_CORE_USB20 0x504
  1346. +#define BCMA_CORE_USB30 0x505
  1347. +#define BCMA_CORE_A9JTAG 0x506
  1348. +#define BCMA_CORE_DDR23 0x507
  1349. +#define BCMA_CORE_ROM 0x508
  1350. +#define BCMA_CORE_NAND 0x509
  1351. +#define BCMA_CORE_QSPI 0x50A
  1352. +#define BCMA_CORE_CHIPCOMMON_B 0x50B
  1353. #define BCMA_CORE_4706_SOC_RAM 0x50E
  1354. +#define BCMA_CORE_ARMCA9 0x510
  1355. #define BCMA_CORE_4706_MAC_GBIT 0x52D
  1356. #define BCMA_CORE_AMEMC 0x52E /* DDR1/2 memory controller core */
  1357. #define BCMA_CORE_ALTA 0x534 /* I2S core */
  1358. @@ -134,12 +146,20 @@ struct bcma_host_ops {
  1359. #define BCMA_CORE_I2S 0x834
  1360. #define BCMA_CORE_SDR_DDR1_MEM_CTL 0x835 /* SDR/DDR1 memory controller core */
  1361. #define BCMA_CORE_SHIM 0x837 /* SHIM component in ubus/6362 */
  1362. +#define BCMA_CORE_PHY_AC 0x83B
  1363. +#define BCMA_CORE_PCIE2 0x83C /* PCI Express Gen2 */
  1364. +#define BCMA_CORE_USB30_DEV 0x83D
  1365. +#define BCMA_CORE_ARM_CR4 0x83E
  1366. #define BCMA_CORE_DEFAULT 0xFFF
  1367. #define BCMA_MAX_NR_CORES 16
  1368. /* Chip IDs of PCIe devices */
  1369. #define BCMA_CHIP_ID_BCM4313 0x4313
  1370. +#define BCMA_CHIP_ID_BCM43142 43142
  1371. +#define BCMA_CHIP_ID_BCM43131 43131
  1372. +#define BCMA_CHIP_ID_BCM43217 43217
  1373. +#define BCMA_CHIP_ID_BCM43222 43222
  1374. #define BCMA_CHIP_ID_BCM43224 43224
  1375. #define BCMA_PKG_ID_BCM43224_FAB_CSM 0x8
  1376. #define BCMA_PKG_ID_BCM43224_FAB_SMIC 0xa
  1377. @@ -172,6 +192,65 @@ struct bcma_host_ops {
  1378. #define BCMA_PKG_ID_BCM5357 11
  1379. #define BCMA_CHIP_ID_BCM53572 53572
  1380. #define BCMA_PKG_ID_BCM47188 9
  1381. +#define BCMA_CHIP_ID_BCM4707 53010
  1382. +#define BCMA_PKG_ID_BCM4707 1
  1383. +#define BCMA_PKG_ID_BCM4708 2
  1384. +#define BCMA_PKG_ID_BCM4709 0
  1385. +#define BCMA_CHIP_ID_BCM53018 53018
  1386. +
  1387. +/* Board types (on PCI usually equals to the subsystem dev id) */
  1388. +/* BCM4313 */
  1389. +#define BCMA_BOARD_TYPE_BCM94313BU 0X050F
  1390. +#define BCMA_BOARD_TYPE_BCM94313HM 0X0510
  1391. +#define BCMA_BOARD_TYPE_BCM94313EPA 0X0511
  1392. +#define BCMA_BOARD_TYPE_BCM94313HMG 0X051C
  1393. +/* BCM4716 */
  1394. +#define BCMA_BOARD_TYPE_BCM94716NR2 0X04CD
  1395. +/* BCM43224 */
  1396. +#define BCMA_BOARD_TYPE_BCM943224X21 0X056E
  1397. +#define BCMA_BOARD_TYPE_BCM943224X21_FCC 0X00D1
  1398. +#define BCMA_BOARD_TYPE_BCM943224X21B 0X00E9
  1399. +#define BCMA_BOARD_TYPE_BCM943224M93 0X008B
  1400. +#define BCMA_BOARD_TYPE_BCM943224M93A 0X0090
  1401. +#define BCMA_BOARD_TYPE_BCM943224X16 0X0093
  1402. +#define BCMA_BOARD_TYPE_BCM94322X9 0X008D
  1403. +#define BCMA_BOARD_TYPE_BCM94322M35E 0X008E
  1404. +/* BCM43228 */
  1405. +#define BCMA_BOARD_TYPE_BCM943228BU8 0X0540
  1406. +#define BCMA_BOARD_TYPE_BCM943228BU9 0X0541
  1407. +#define BCMA_BOARD_TYPE_BCM943228BU 0X0542
  1408. +#define BCMA_BOARD_TYPE_BCM943227HM4L 0X0543
  1409. +#define BCMA_BOARD_TYPE_BCM943227HMB 0X0544
  1410. +#define BCMA_BOARD_TYPE_BCM943228HM4L 0X0545
  1411. +#define BCMA_BOARD_TYPE_BCM943228SD 0X0573
  1412. +/* BCM4331 */
  1413. +#define BCMA_BOARD_TYPE_BCM94331X19 0X00D6
  1414. +#define BCMA_BOARD_TYPE_BCM94331X28 0X00E4
  1415. +#define BCMA_BOARD_TYPE_BCM94331X28B 0X010E
  1416. +#define BCMA_BOARD_TYPE_BCM94331PCIEBT3AX 0X00E4
  1417. +#define BCMA_BOARD_TYPE_BCM94331X12_2G 0X00EC
  1418. +#define BCMA_BOARD_TYPE_BCM94331X12_5G 0X00ED
  1419. +#define BCMA_BOARD_TYPE_BCM94331X29B 0X00EF
  1420. +#define BCMA_BOARD_TYPE_BCM94331CSAX 0X00EF
  1421. +#define BCMA_BOARD_TYPE_BCM94331X19C 0X00F5
  1422. +#define BCMA_BOARD_TYPE_BCM94331X33 0X00F4
  1423. +#define BCMA_BOARD_TYPE_BCM94331BU 0X0523
  1424. +#define BCMA_BOARD_TYPE_BCM94331S9BU 0X0524
  1425. +#define BCMA_BOARD_TYPE_BCM94331MC 0X0525
  1426. +#define BCMA_BOARD_TYPE_BCM94331MCI 0X0526
  1427. +#define BCMA_BOARD_TYPE_BCM94331PCIEBT4 0X0527
  1428. +#define BCMA_BOARD_TYPE_BCM94331HM 0X0574
  1429. +#define BCMA_BOARD_TYPE_BCM94331PCIEDUAL 0X059B
  1430. +#define BCMA_BOARD_TYPE_BCM94331MCH5 0X05A9
  1431. +#define BCMA_BOARD_TYPE_BCM94331CS 0X05C6
  1432. +#define BCMA_BOARD_TYPE_BCM94331CD 0X05DA
  1433. +/* BCM53572 */
  1434. +#define BCMA_BOARD_TYPE_BCM953572BU 0X058D
  1435. +#define BCMA_BOARD_TYPE_BCM953572NR2 0X058E
  1436. +#define BCMA_BOARD_TYPE_BCM947188NR2 0X058F
  1437. +#define BCMA_BOARD_TYPE_BCM953572SDRNR2 0X0590
  1438. +/* BCM43142 */
  1439. +#define BCMA_BOARD_TYPE_BCM943142HM 0X05E0
  1440. struct bcma_device {
  1441. struct bcma_bus *bus;
  1442. --- a/include/linux/bcma/bcma_driver_chipcommon.h
  1443. +++ b/include/linux/bcma/bcma_driver_chipcommon.h
  1444. @@ -27,7 +27,7 @@
  1445. #define BCMA_CC_FLASHT_NONE 0x00000000 /* No flash */
  1446. #define BCMA_CC_FLASHT_STSER 0x00000100 /* ST serial flash */
  1447. #define BCMA_CC_FLASHT_ATSER 0x00000200 /* Atmel serial flash */
  1448. -#define BCMA_CC_FLASHT_NFLASH 0x00000200 /* NAND flash */
  1449. +#define BCMA_CC_FLASHT_NAND 0x00000300 /* NAND flash */
  1450. #define BCMA_CC_FLASHT_PARA 0x00000700 /* Parallel flash */
  1451. #define BCMA_CC_CAP_PLLT 0x00038000 /* PLL Type */
  1452. #define BCMA_PLLTYPE_NONE 0x00000000
  1453. @@ -104,6 +104,7 @@
  1454. #define BCMA_CC_CHIPST_4706_MIPS_BENDIAN BIT(3) /* 0: little, 1: big endian */
  1455. #define BCMA_CC_CHIPST_4706_PCIE1_DISABLE BIT(5) /* PCIE1 enable strap pin */
  1456. #define BCMA_CC_CHIPST_5357_NAND_BOOT BIT(4) /* NAND boot, valid for CC rev 38 and/or BCM5357 */
  1457. +#define BCMA_CC_CHIPST_4360_XTAL_40MZ 0x00000001
  1458. #define BCMA_CC_JCMD 0x0030 /* Rev >= 10 only */
  1459. #define BCMA_CC_JCMD_START 0x80000000
  1460. #define BCMA_CC_JCMD_BUSY 0x80000000
  1461. @@ -315,6 +316,9 @@
  1462. #define BCMA_CC_PMU_CTL 0x0600 /* PMU control */
  1463. #define BCMA_CC_PMU_CTL_ILP_DIV 0xFFFF0000 /* ILP div mask */
  1464. #define BCMA_CC_PMU_CTL_ILP_DIV_SHIFT 16
  1465. +#define BCMA_CC_PMU_CTL_RES 0x00006000 /* reset control mask */
  1466. +#define BCMA_CC_PMU_CTL_RES_SHIFT 13
  1467. +#define BCMA_CC_PMU_CTL_RES_RELOAD 0x2 /* reload POR values */
  1468. #define BCMA_CC_PMU_CTL_PLL_UPD 0x00000400
  1469. #define BCMA_CC_PMU_CTL_NOILPONW 0x00000200 /* No ILP on wait */
  1470. #define BCMA_CC_PMU_CTL_HTREQEN 0x00000100 /* HT req enable */
  1471. @@ -326,6 +330,8 @@
  1472. #define BCMA_CC_PMU_CAP 0x0604 /* PMU capabilities */
  1473. #define BCMA_CC_PMU_CAP_REVISION 0x000000FF /* Revision mask */
  1474. #define BCMA_CC_PMU_STAT 0x0608 /* PMU status */
  1475. +#define BCMA_CC_PMU_STAT_EXT_LPO_AVAIL 0x00000100
  1476. +#define BCMA_CC_PMU_STAT_WDRESET 0x00000080
  1477. #define BCMA_CC_PMU_STAT_INTPEND 0x00000040 /* Interrupt pending */
  1478. #define BCMA_CC_PMU_STAT_SBCLKST 0x00000030 /* Backplane clock status? */
  1479. #define BCMA_CC_PMU_STAT_HAVEALP 0x00000008 /* ALP available */
  1480. @@ -351,6 +357,11 @@
  1481. #define BCMA_CC_REGCTL_DATA 0x065C
  1482. #define BCMA_CC_PLLCTL_ADDR 0x0660
  1483. #define BCMA_CC_PLLCTL_DATA 0x0664
  1484. +#define BCMA_CC_PMU_STRAPOPT 0x0668 /* (corerev >= 28) */
  1485. +#define BCMA_CC_PMU_XTAL_FREQ 0x066C /* (pmurev >= 10) */
  1486. +#define BCMA_CC_PMU_XTAL_FREQ_ILPCTL_MASK 0x00001FFF
  1487. +#define BCMA_CC_PMU_XTAL_FREQ_MEASURE_MASK 0x80000000
  1488. +#define BCMA_CC_PMU_XTAL_FREQ_MEASURE_SHIFT 31
  1489. #define BCMA_CC_SPROM 0x0800 /* SPROM beginning */
  1490. /* NAND flash MLC controller registers (corerev >= 38) */
  1491. #define BCMA_CC_NAND_REVISION 0x0C00
  1492. @@ -431,6 +442,23 @@
  1493. #define BCMA_CC_PMU6_4706_PROC_NDIV_MODE_MASK 0x00000007
  1494. #define BCMA_CC_PMU6_4706_PROC_NDIV_MODE_SHIFT 0
  1495. +/* PMU rev 15 */
  1496. +#define BCMA_CC_PMU15_PLL_PLLCTL0 0
  1497. +#define BCMA_CC_PMU15_PLL_PC0_CLKSEL_MASK 0x00000003
  1498. +#define BCMA_CC_PMU15_PLL_PC0_CLKSEL_SHIFT 0
  1499. +#define BCMA_CC_PMU15_PLL_PC0_FREQTGT_MASK 0x003FFFFC
  1500. +#define BCMA_CC_PMU15_PLL_PC0_FREQTGT_SHIFT 2
  1501. +#define BCMA_CC_PMU15_PLL_PC0_PRESCALE_MASK 0x00C00000
  1502. +#define BCMA_CC_PMU15_PLL_PC0_PRESCALE_SHIFT 22
  1503. +#define BCMA_CC_PMU15_PLL_PC0_KPCTRL_MASK 0x07000000
  1504. +#define BCMA_CC_PMU15_PLL_PC0_KPCTRL_SHIFT 24
  1505. +#define BCMA_CC_PMU15_PLL_PC0_FCNTCTRL_MASK 0x38000000
  1506. +#define BCMA_CC_PMU15_PLL_PC0_FCNTCTRL_SHIFT 27
  1507. +#define BCMA_CC_PMU15_PLL_PC0_FDCMODE_MASK 0x40000000
  1508. +#define BCMA_CC_PMU15_PLL_PC0_FDCMODE_SHIFT 30
  1509. +#define BCMA_CC_PMU15_PLL_PC0_CTRLBIAS_MASK 0x80000000
  1510. +#define BCMA_CC_PMU15_PLL_PC0_CTRLBIAS_SHIFT 31
  1511. +
  1512. /* ALP clock on pre-PMU chips */
  1513. #define BCMA_CC_PMU_ALP_CLOCK 20000000
  1514. /* HT clock for systems with PMU-enabled chipcommon */
  1515. @@ -503,6 +531,37 @@
  1516. #define BCMA_CHIPCTL_5357_I2S_PINS_ENABLE BIT(18)
  1517. #define BCMA_CHIPCTL_5357_I2CSPI_PINS_ENABLE BIT(19)
  1518. +#define BCMA_RES_4314_LPLDO_PU BIT(0)
  1519. +#define BCMA_RES_4314_PMU_SLEEP_DIS BIT(1)
  1520. +#define BCMA_RES_4314_PMU_BG_PU BIT(2)
  1521. +#define BCMA_RES_4314_CBUCK_LPOM_PU BIT(3)
  1522. +#define BCMA_RES_4314_CBUCK_PFM_PU BIT(4)
  1523. +#define BCMA_RES_4314_CLDO_PU BIT(5)
  1524. +#define BCMA_RES_4314_LPLDO2_LVM BIT(6)
  1525. +#define BCMA_RES_4314_WL_PMU_PU BIT(7)
  1526. +#define BCMA_RES_4314_LNLDO_PU BIT(8)
  1527. +#define BCMA_RES_4314_LDO3P3_PU BIT(9)
  1528. +#define BCMA_RES_4314_OTP_PU BIT(10)
  1529. +#define BCMA_RES_4314_XTAL_PU BIT(11)
  1530. +#define BCMA_RES_4314_WL_PWRSW_PU BIT(12)
  1531. +#define BCMA_RES_4314_LQ_AVAIL BIT(13)
  1532. +#define BCMA_RES_4314_LOGIC_RET BIT(14)
  1533. +#define BCMA_RES_4314_MEM_SLEEP BIT(15)
  1534. +#define BCMA_RES_4314_MACPHY_RET BIT(16)
  1535. +#define BCMA_RES_4314_WL_CORE_READY BIT(17)
  1536. +#define BCMA_RES_4314_ILP_REQ BIT(18)
  1537. +#define BCMA_RES_4314_ALP_AVAIL BIT(19)
  1538. +#define BCMA_RES_4314_MISC_PWRSW_PU BIT(20)
  1539. +#define BCMA_RES_4314_SYNTH_PWRSW_PU BIT(21)
  1540. +#define BCMA_RES_4314_RX_PWRSW_PU BIT(22)
  1541. +#define BCMA_RES_4314_RADIO_PU BIT(23)
  1542. +#define BCMA_RES_4314_VCO_LDO_PU BIT(24)
  1543. +#define BCMA_RES_4314_AFE_LDO_PU BIT(25)
  1544. +#define BCMA_RES_4314_RX_LDO_PU BIT(26)
  1545. +#define BCMA_RES_4314_TX_LDO_PU BIT(27)
  1546. +#define BCMA_RES_4314_HT_AVAIL BIT(28)
  1547. +#define BCMA_RES_4314_MACPHY_CLK_AVAIL BIT(29)
  1548. +
  1549. /* Data for the PMU, if available.
  1550. * Check availability with ((struct bcma_chipcommon)->capabilities & BCMA_CC_CAP_PMU)
  1551. */
  1552. @@ -528,6 +587,7 @@ struct bcma_sflash {
  1553. u32 size;
  1554. struct mtd_info *mtd;
  1555. + void *priv;
  1556. };
  1557. #endif
  1558. @@ -606,6 +666,8 @@ void bcma_chipco_bcm4331_ext_pa_lines_ct
  1559. extern u32 bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc, u32 ticks);
  1560. +extern u32 bcma_chipco_get_alp_clock(struct bcma_drv_cc *cc);
  1561. +
  1562. void bcma_chipco_irq_mask(struct bcma_drv_cc *cc, u32 mask, u32 value);
  1563. u32 bcma_chipco_irq_status(struct bcma_drv_cc *cc, u32 mask);
  1564. @@ -634,4 +696,6 @@ extern void bcma_chipco_regctl_maskset(s
  1565. u32 offset, u32 mask, u32 set);
  1566. extern void bcma_pmu_spuravoid_pllupdate(struct bcma_drv_cc *cc, int spuravoid);
  1567. +extern u32 bcma_pmu_get_bus_clock(struct bcma_drv_cc *cc);
  1568. +
  1569. #endif /* LINUX_BCMA_DRIVER_CC_H_ */
  1570. --- a/include/linux/bcma/bcma_driver_mips.h
  1571. +++ b/include/linux/bcma/bcma_driver_mips.h
  1572. @@ -28,6 +28,7 @@
  1573. #define BCMA_MIPS_MIPS74K_GPIOEN 0x0048
  1574. #define BCMA_MIPS_MIPS74K_CLKCTLST 0x01E0
  1575. +#define BCMA_MIPS_OOBSELINA74 0x004
  1576. #define BCMA_MIPS_OOBSELOUTA30 0x100
  1577. struct bcma_device;
  1578. @@ -36,19 +37,23 @@ struct bcma_drv_mips {
  1579. struct bcma_device *core;
  1580. u8 setup_done:1;
  1581. u8 early_setup_done:1;
  1582. - unsigned int assigned_irqs;
  1583. };
  1584. #ifdef CONFIG_BCMA_DRIVER_MIPS
  1585. extern void bcma_core_mips_init(struct bcma_drv_mips *mcore);
  1586. extern void bcma_core_mips_early_init(struct bcma_drv_mips *mcore);
  1587. +
  1588. +extern unsigned int bcma_core_irq(struct bcma_device *core);
  1589. #else
  1590. static inline void bcma_core_mips_init(struct bcma_drv_mips *mcore) { }
  1591. static inline void bcma_core_mips_early_init(struct bcma_drv_mips *mcore) { }
  1592. +
  1593. +static inline unsigned int bcma_core_irq(struct bcma_device *core)
  1594. +{
  1595. + return 0;
  1596. +}
  1597. #endif
  1598. extern u32 bcma_cpu_clock(struct bcma_drv_mips *mcore);
  1599. -extern unsigned int bcma_core_mips_irq(struct bcma_device *dev);
  1600. -
  1601. #endif /* LINUX_BCMA_DRIVER_MIPS_H_ */
  1602. --- a/include/linux/bcma/bcma_driver_pci.h
  1603. +++ b/include/linux/bcma/bcma_driver_pci.h
  1604. @@ -179,10 +179,33 @@ struct pci_dev;
  1605. #define BCMA_CORE_PCI_CFG_FUN_MASK 7 /* Function mask */
  1606. #define BCMA_CORE_PCI_CFG_OFF_MASK 0xfff /* Register mask */
  1607. +#define BCMA_CORE_PCI_CFG_DEVCTRL 0xd8
  1608. +
  1609. +#define BCMA_CORE_PCI_
  1610. +
  1611. +/* MDIO devices (SERDES modules) */
  1612. +#define BCMA_CORE_PCI_MDIO_IEEE0 0x000
  1613. +#define BCMA_CORE_PCI_MDIO_IEEE1 0x001
  1614. +#define BCMA_CORE_PCI_MDIO_BLK0 0x800
  1615. +#define BCMA_CORE_PCI_MDIO_BLK1 0x801
  1616. +#define BCMA_CORE_PCI_MDIO_BLK1_MGMT0 0x16
  1617. +#define BCMA_CORE_PCI_MDIO_BLK1_MGMT1 0x17
  1618. +#define BCMA_CORE_PCI_MDIO_BLK1_MGMT2 0x18
  1619. +#define BCMA_CORE_PCI_MDIO_BLK1_MGMT3 0x19
  1620. +#define BCMA_CORE_PCI_MDIO_BLK1_MGMT4 0x1A
  1621. +#define BCMA_CORE_PCI_MDIO_BLK2 0x802
  1622. +#define BCMA_CORE_PCI_MDIO_BLK3 0x803
  1623. +#define BCMA_CORE_PCI_MDIO_BLK4 0x804
  1624. +#define BCMA_CORE_PCI_MDIO_TXPLL 0x808 /* TXPLL register block idx */
  1625. +#define BCMA_CORE_PCI_MDIO_TXCTRL0 0x820
  1626. +#define BCMA_CORE_PCI_MDIO_SERDESID 0x831
  1627. +#define BCMA_CORE_PCI_MDIO_RXCTRL0 0x840
  1628. +
  1629. /* PCIE Root Capability Register bits (Host mode only) */
  1630. #define BCMA_CORE_PCI_RC_CRS_VISIBILITY 0x0001
  1631. struct bcma_drv_pci;
  1632. +struct bcma_bus;
  1633. #ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE
  1634. struct bcma_drv_pci_host {
  1635. @@ -217,7 +240,9 @@ struct bcma_drv_pci {
  1636. extern void bcma_core_pci_init(struct bcma_drv_pci *pc);
  1637. extern int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc,
  1638. struct bcma_device *core, bool enable);
  1639. -extern void bcma_core_pci_extend_L1timer(struct bcma_drv_pci *pc, bool extend);
  1640. +extern void bcma_core_pci_up(struct bcma_bus *bus);
  1641. +extern void bcma_core_pci_down(struct bcma_bus *bus);
  1642. +extern void bcma_core_pci_power_save(struct bcma_bus *bus, bool up);
  1643. extern int bcma_core_pci_pcibios_map_irq(const struct pci_dev *dev);
  1644. extern int bcma_core_pci_plat_dev_init(struct pci_dev *dev);
  1645. --- a/include/linux/bcma/bcma_regs.h
  1646. +++ b/include/linux/bcma/bcma_regs.h
  1647. @@ -37,6 +37,7 @@
  1648. #define BCMA_IOST_BIST_DONE 0x8000
  1649. #define BCMA_RESET_CTL 0x0800
  1650. #define BCMA_RESET_CTL_RESET 0x0001
  1651. +#define BCMA_RESET_ST 0x0804
  1652. /* BCMA PCI config space registers. */
  1653. #define BCMA_PCI_PMCSR 0x44
  1654. --- a/drivers/bcma/driver_pci.c
  1655. +++ b/drivers/bcma/driver_pci.c
  1656. @@ -31,7 +31,7 @@ static void bcma_pcie_write(struct bcma_
  1657. pcicore_write32(pc, BCMA_CORE_PCI_PCIEIND_DATA, data);
  1658. }
  1659. -static void bcma_pcie_mdio_set_phy(struct bcma_drv_pci *pc, u8 phy)
  1660. +static void bcma_pcie_mdio_set_phy(struct bcma_drv_pci *pc, u16 phy)
  1661. {
  1662. u32 v;
  1663. int i;
  1664. @@ -55,7 +55,7 @@ static void bcma_pcie_mdio_set_phy(struc
  1665. }
  1666. }
  1667. -static u16 bcma_pcie_mdio_read(struct bcma_drv_pci *pc, u8 device, u8 address)
  1668. +static u16 bcma_pcie_mdio_read(struct bcma_drv_pci *pc, u16 device, u8 address)
  1669. {
  1670. int max_retries = 10;
  1671. u16 ret = 0;
  1672. @@ -98,7 +98,7 @@ static u16 bcma_pcie_mdio_read(struct bc
  1673. return ret;
  1674. }
  1675. -static void bcma_pcie_mdio_write(struct bcma_drv_pci *pc, u8 device,
  1676. +static void bcma_pcie_mdio_write(struct bcma_drv_pci *pc, u16 device,
  1677. u8 address, u16 data)
  1678. {
  1679. int max_retries = 10;
  1680. @@ -137,6 +137,13 @@ static void bcma_pcie_mdio_write(struct
  1681. pcicore_write32(pc, BCMA_CORE_PCI_MDIO_CONTROL, 0);
  1682. }
  1683. +static u16 bcma_pcie_mdio_writeread(struct bcma_drv_pci *pc, u16 device,
  1684. + u8 address, u16 data)
  1685. +{
  1686. + bcma_pcie_mdio_write(pc, device, address, data);
  1687. + return bcma_pcie_mdio_read(pc, device, address);
  1688. +}
  1689. +
  1690. /**************************************************
  1691. * Workarounds.
  1692. **************************************************/
  1693. @@ -229,6 +236,32 @@ void bcma_core_pci_init(struct bcma_drv_
  1694. bcma_core_pci_clientmode_init(pc);
  1695. }
  1696. +void bcma_core_pci_power_save(struct bcma_bus *bus, bool up)
  1697. +{
  1698. + struct bcma_drv_pci *pc;
  1699. + u16 data;
  1700. +
  1701. + if (bus->hosttype != BCMA_HOSTTYPE_PCI)
  1702. + return;
  1703. +
  1704. + pc = &bus->drv_pci[0];
  1705. +
  1706. + if (pc->core->id.rev >= 15 && pc->core->id.rev <= 20) {
  1707. + data = up ? 0x74 : 0x7C;
  1708. + bcma_pcie_mdio_writeread(pc, BCMA_CORE_PCI_MDIO_BLK1,
  1709. + BCMA_CORE_PCI_MDIO_BLK1_MGMT1, 0x7F64);
  1710. + bcma_pcie_mdio_writeread(pc, BCMA_CORE_PCI_MDIO_BLK1,
  1711. + BCMA_CORE_PCI_MDIO_BLK1_MGMT3, data);
  1712. + } else if (pc->core->id.rev >= 21 && pc->core->id.rev <= 22) {
  1713. + data = up ? 0x75 : 0x7D;
  1714. + bcma_pcie_mdio_writeread(pc, BCMA_CORE_PCI_MDIO_BLK1,
  1715. + BCMA_CORE_PCI_MDIO_BLK1_MGMT1, 0x7E65);
  1716. + bcma_pcie_mdio_writeread(pc, BCMA_CORE_PCI_MDIO_BLK1,
  1717. + BCMA_CORE_PCI_MDIO_BLK1_MGMT3, data);
  1718. + }
  1719. +}
  1720. +EXPORT_SYMBOL_GPL(bcma_core_pci_power_save);
  1721. +
  1722. int bcma_core_pci_irq_ctl(struct bcma_drv_pci *pc, struct bcma_device *core,
  1723. bool enable)
  1724. {
  1725. @@ -262,7 +295,7 @@ out:
  1726. }
  1727. EXPORT_SYMBOL_GPL(bcma_core_pci_irq_ctl);
  1728. -void bcma_core_pci_extend_L1timer(struct bcma_drv_pci *pc, bool extend)
  1729. +static void bcma_core_pci_extend_L1timer(struct bcma_drv_pci *pc, bool extend)
  1730. {
  1731. u32 w;
  1732. @@ -274,4 +307,29 @@ void bcma_core_pci_extend_L1timer(struct
  1733. bcma_pcie_write(pc, BCMA_CORE_PCI_DLLP_PMTHRESHREG, w);
  1734. bcma_pcie_read(pc, BCMA_CORE_PCI_DLLP_PMTHRESHREG);
  1735. }
  1736. -EXPORT_SYMBOL_GPL(bcma_core_pci_extend_L1timer);
  1737. +
  1738. +void bcma_core_pci_up(struct bcma_bus *bus)
  1739. +{
  1740. + struct bcma_drv_pci *pc;
  1741. +
  1742. + if (bus->hosttype != BCMA_HOSTTYPE_PCI)
  1743. + return;
  1744. +
  1745. + pc = &bus->drv_pci[0];
  1746. +
  1747. + bcma_core_pci_extend_L1timer(pc, true);
  1748. +}
  1749. +EXPORT_SYMBOL_GPL(bcma_core_pci_up);
  1750. +
  1751. +void bcma_core_pci_down(struct bcma_bus *bus)
  1752. +{
  1753. + struct bcma_drv_pci *pc;
  1754. +
  1755. + if (bus->hosttype != BCMA_HOSTTYPE_PCI)
  1756. + return;
  1757. +
  1758. + pc = &bus->drv_pci[0];
  1759. +
  1760. + bcma_core_pci_extend_L1timer(pc, false);
  1761. +}
  1762. +EXPORT_SYMBOL_GPL(bcma_core_pci_down);
  1763. --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
  1764. +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
  1765. @@ -685,27 +685,6 @@ bool ai_clkctl_cc(struct si_pub *sih, en
  1766. return mode == BCMA_CLKMODE_FAST;
  1767. }
  1768. -void ai_pci_up(struct si_pub *sih)
  1769. -{
  1770. - struct si_info *sii;
  1771. -
  1772. - sii = container_of(sih, struct si_info, pub);
  1773. -
  1774. - if (sii->icbus->hosttype == BCMA_HOSTTYPE_PCI)
  1775. - bcma_core_pci_extend_L1timer(&sii->icbus->drv_pci[0], true);
  1776. -}
  1777. -
  1778. -/* Unconfigure and/or apply various WARs when going down */
  1779. -void ai_pci_down(struct si_pub *sih)
  1780. -{
  1781. - struct si_info *sii;
  1782. -
  1783. - sii = container_of(sih, struct si_info, pub);
  1784. -
  1785. - if (sii->icbus->hosttype == BCMA_HOSTTYPE_PCI)
  1786. - bcma_core_pci_extend_L1timer(&sii->icbus->drv_pci[0], false);
  1787. -}
  1788. -
  1789. /* Enable BT-COEX & Ex-PA for 4313 */
  1790. void ai_epa_4313war(struct si_pub *sih)
  1791. {
  1792. --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h
  1793. +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.h
  1794. @@ -183,9 +183,6 @@ extern u16 ai_clkctl_fast_pwrup_delay(st
  1795. extern bool ai_clkctl_cc(struct si_pub *sih, enum bcma_clkmode mode);
  1796. extern bool ai_deviceremoved(struct si_pub *sih);
  1797. -extern void ai_pci_down(struct si_pub *sih);
  1798. -extern void ai_pci_up(struct si_pub *sih);
  1799. -
  1800. /* Enable Ex-PA for 4313 */
  1801. extern void ai_epa_4313war(struct si_pub *sih);
  1802. --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
  1803. +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
  1804. @@ -4648,7 +4648,7 @@ static int brcms_b_attach(struct brcms_c
  1805. brcms_c_coredisable(wlc_hw);
  1806. /* Match driver "down" state */
  1807. - ai_pci_down(wlc_hw->sih);
  1808. + bcma_core_pci_down(wlc_hw->d11core->bus);
  1809. /* turn off pll and xtal to match driver "down" state */
  1810. brcms_b_xtal(wlc_hw, OFF);
  1811. @@ -4991,12 +4991,12 @@ static int brcms_b_up_prep(struct brcms_
  1812. */
  1813. if (brcms_b_radio_read_hwdisabled(wlc_hw)) {
  1814. /* put SB PCI in down state again */
  1815. - ai_pci_down(wlc_hw->sih);
  1816. + bcma_core_pci_down(wlc_hw->d11core->bus);
  1817. brcms_b_xtal(wlc_hw, OFF);
  1818. return -ENOMEDIUM;
  1819. }
  1820. - ai_pci_up(wlc_hw->sih);
  1821. + bcma_core_pci_up(wlc_hw->d11core->bus);
  1822. /* reset the d11 core */
  1823. brcms_b_corereset(wlc_hw, BRCMS_USE_COREFLAGS);
  1824. @@ -5193,7 +5193,7 @@ static int brcms_b_down_finish(struct br
  1825. /* turn off primary xtal and pll */
  1826. if (!wlc_hw->noreset) {
  1827. - ai_pci_down(wlc_hw->sih);
  1828. + bcma_core_pci_down(wlc_hw->d11core->bus);
  1829. brcms_b_xtal(wlc_hw, OFF);
  1830. }
  1831. }