025-bcma_backport.patch 61 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000
  1. --- a/drivers/bcma/Kconfig
  2. +++ b/drivers/bcma/Kconfig
  3. @@ -48,12 +48,12 @@ config BCMA_DRIVER_MIPS
  4. config BCMA_SFLASH
  5. bool
  6. - depends on BCMA_DRIVER_MIPS && BROKEN
  7. + depends on BCMA_DRIVER_MIPS
  8. default y
  9. config BCMA_NFLASH
  10. bool
  11. - depends on BCMA_DRIVER_MIPS && BROKEN
  12. + depends on BCMA_DRIVER_MIPS
  13. default y
  14. config BCMA_DRIVER_GMAC_CMN
  15. @@ -65,6 +65,14 @@ config BCMA_DRIVER_GMAC_CMN
  16. If unsure, say N
  17. +config BCMA_DRIVER_GPIO
  18. + bool "BCMA GPIO driver"
  19. + depends on BCMA && GPIOLIB
  20. + help
  21. + Driver to provide access to the GPIO pins of the bcma bus.
  22. +
  23. + If unsure, say N
  24. +
  25. config BCMA_DEBUG
  26. bool "BCMA debugging"
  27. depends on BCMA
  28. --- a/drivers/bcma/Makefile
  29. +++ b/drivers/bcma/Makefile
  30. @@ -6,6 +6,7 @@ bcma-y += driver_pci.o
  31. bcma-$(CONFIG_BCMA_DRIVER_PCI_HOSTMODE) += driver_pci_host.o
  32. bcma-$(CONFIG_BCMA_DRIVER_MIPS) += driver_mips.o
  33. bcma-$(CONFIG_BCMA_DRIVER_GMAC_CMN) += driver_gmac_cmn.o
  34. +bcma-$(CONFIG_BCMA_DRIVER_GPIO) += driver_gpio.o
  35. bcma-$(CONFIG_BCMA_HOST_PCI) += host_pci.o
  36. bcma-$(CONFIG_BCMA_HOST_SOC) += host_soc.o
  37. obj-$(CONFIG_BCMA) += bcma.o
  38. --- a/drivers/bcma/bcma_private.h
  39. +++ b/drivers/bcma/bcma_private.h
  40. @@ -31,6 +31,8 @@ int __init bcma_bus_early_register(struc
  41. int bcma_bus_suspend(struct bcma_bus *bus);
  42. int bcma_bus_resume(struct bcma_bus *bus);
  43. #endif
  44. +struct bcma_device *bcma_find_core_unit(struct bcma_bus *bus, u16 coreid,
  45. + u8 unit);
  46. /* scan.c */
  47. int bcma_bus_scan(struct bcma_bus *bus);
  48. @@ -48,12 +50,13 @@ void bcma_chipco_serial_init(struct bcma
  49. #endif /* CONFIG_BCMA_DRIVER_MIPS */
  50. /* driver_chipcommon_pmu.c */
  51. -u32 bcma_pmu_alp_clock(struct bcma_drv_cc *cc);
  52. -u32 bcma_pmu_get_clockcpu(struct bcma_drv_cc *cc);
  53. +u32 bcma_pmu_get_alp_clock(struct bcma_drv_cc *cc);
  54. +u32 bcma_pmu_get_cpu_clock(struct bcma_drv_cc *cc);
  55. #ifdef CONFIG_BCMA_SFLASH
  56. /* driver_chipcommon_sflash.c */
  57. int bcma_sflash_init(struct bcma_drv_cc *cc);
  58. +extern struct platform_device bcma_sflash_dev;
  59. #else
  60. static inline int bcma_sflash_init(struct bcma_drv_cc *cc)
  61. {
  62. @@ -65,6 +68,7 @@ static inline int bcma_sflash_init(struc
  63. #ifdef CONFIG_BCMA_NFLASH
  64. /* driver_chipcommon_nflash.c */
  65. int bcma_nflash_init(struct bcma_drv_cc *cc);
  66. +extern struct platform_device bcma_nflash_dev;
  67. #else
  68. static inline int bcma_nflash_init(struct bcma_drv_cc *cc)
  69. {
  70. @@ -82,9 +86,21 @@ extern void __exit bcma_host_pci_exit(vo
  71. /* driver_pci.c */
  72. u32 bcma_pcie_read(struct bcma_drv_pci *pc, u32 address);
  73. +extern int bcma_chipco_watchdog_register(struct bcma_drv_cc *cc);
  74. +
  75. #ifdef CONFIG_BCMA_DRIVER_PCI_HOSTMODE
  76. bool __devinit bcma_core_pci_is_in_hostmode(struct bcma_drv_pci *pc);
  77. void __devinit bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc);
  78. #endif /* CONFIG_BCMA_DRIVER_PCI_HOSTMODE */
  79. +#ifdef CONFIG_BCMA_DRIVER_GPIO
  80. +/* driver_gpio.c */
  81. +int bcma_gpio_init(struct bcma_drv_cc *cc);
  82. +#else
  83. +static inline int bcma_gpio_init(struct bcma_drv_cc *cc)
  84. +{
  85. + return -ENOTSUPP;
  86. +}
  87. +#endif /* CONFIG_BCMA_DRIVER_GPIO */
  88. +
  89. #endif
  90. --- a/drivers/bcma/core.c
  91. +++ b/drivers/bcma/core.c
  92. @@ -65,7 +65,7 @@ void bcma_core_set_clockmode(struct bcma
  93. switch (clkmode) {
  94. case BCMA_CLKMODE_FAST:
  95. bcma_set32(core, BCMA_CLKCTLST, BCMA_CLKCTLST_FORCEHT);
  96. - udelay(64);
  97. + usleep_range(64, 300);
  98. for (i = 0; i < 1500; i++) {
  99. if (bcma_read32(core, BCMA_CLKCTLST) &
  100. BCMA_CLKCTLST_HAVEHT) {
  101. --- a/drivers/bcma/driver_chipcommon.c
  102. +++ b/drivers/bcma/driver_chipcommon.c
  103. @@ -4,12 +4,15 @@
  104. *
  105. * Copyright 2005, Broadcom Corporation
  106. * Copyright 2006, 2007, Michael Buesch <[email protected]>
  107. + * Copyright 2012, Hauke Mehrtens <[email protected]>
  108. *
  109. * Licensed under the GNU/GPL. See COPYING for details.
  110. */
  111. #include "bcma_private.h"
  112. +#include <linux/bcm47xx_wdt.h>
  113. #include <linux/export.h>
  114. +#include <linux/platform_device.h>
  115. #include <linux/bcma/bcma.h>
  116. static inline u32 bcma_cc_write32_masked(struct bcma_drv_cc *cc, u16 offset,
  117. @@ -22,20 +25,120 @@ static inline u32 bcma_cc_write32_masked
  118. return value;
  119. }
  120. -void bcma_core_chipcommon_init(struct bcma_drv_cc *cc)
  121. +u32 bcma_chipco_get_alp_clock(struct bcma_drv_cc *cc)
  122. {
  123. - u32 leddc_on = 10;
  124. - u32 leddc_off = 90;
  125. + if (cc->capabilities & BCMA_CC_CAP_PMU)
  126. + return bcma_pmu_get_alp_clock(cc);
  127. - if (cc->setup_done)
  128. + return 20000000;
  129. +}
  130. +EXPORT_SYMBOL_GPL(bcma_chipco_get_alp_clock);
  131. +
  132. +static u32 bcma_chipco_watchdog_get_max_timer(struct bcma_drv_cc *cc)
  133. +{
  134. + struct bcma_bus *bus = cc->core->bus;
  135. + u32 nb;
  136. +
  137. + if (cc->capabilities & BCMA_CC_CAP_PMU) {
  138. + if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4706)
  139. + nb = 32;
  140. + else if (cc->core->id.rev < 26)
  141. + nb = 16;
  142. + else
  143. + nb = (cc->core->id.rev >= 37) ? 32 : 24;
  144. + } else {
  145. + nb = 28;
  146. + }
  147. + if (nb == 32)
  148. + return 0xffffffff;
  149. + else
  150. + return (1 << nb) - 1;
  151. +}
  152. +
  153. +static u32 bcma_chipco_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt,
  154. + u32 ticks)
  155. +{
  156. + struct bcma_drv_cc *cc = bcm47xx_wdt_get_drvdata(wdt);
  157. +
  158. + return bcma_chipco_watchdog_timer_set(cc, ticks);
  159. +}
  160. +
  161. +static u32 bcma_chipco_watchdog_timer_set_ms_wdt(struct bcm47xx_wdt *wdt,
  162. + u32 ms)
  163. +{
  164. + struct bcma_drv_cc *cc = bcm47xx_wdt_get_drvdata(wdt);
  165. + u32 ticks;
  166. +
  167. + ticks = bcma_chipco_watchdog_timer_set(cc, cc->ticks_per_ms * ms);
  168. + return ticks / cc->ticks_per_ms;
  169. +}
  170. +
  171. +static int bcma_chipco_watchdog_ticks_per_ms(struct bcma_drv_cc *cc)
  172. +{
  173. + struct bcma_bus *bus = cc->core->bus;
  174. +
  175. + if (cc->capabilities & BCMA_CC_CAP_PMU) {
  176. + if (bus->chipinfo.id == BCMA_CHIP_ID_BCM4706)
  177. + /* 4706 CC and PMU watchdogs are clocked at 1/4 of ALP clock */
  178. + return bcma_chipco_get_alp_clock(cc) / 4000;
  179. + else
  180. + /* based on 32KHz ILP clock */
  181. + return 32;
  182. + } else {
  183. + return bcma_chipco_get_alp_clock(cc) / 1000;
  184. + }
  185. +}
  186. +
  187. +int bcma_chipco_watchdog_register(struct bcma_drv_cc *cc)
  188. +{
  189. + struct bcm47xx_wdt wdt = {};
  190. + struct platform_device *pdev;
  191. +
  192. + wdt.driver_data = cc;
  193. + wdt.timer_set = bcma_chipco_watchdog_timer_set_wdt;
  194. + wdt.timer_set_ms = bcma_chipco_watchdog_timer_set_ms_wdt;
  195. + wdt.max_timer_ms = bcma_chipco_watchdog_get_max_timer(cc) / cc->ticks_per_ms;
  196. +
  197. + pdev = platform_device_register_data(NULL, "bcm47xx-wdt",
  198. + cc->core->bus->num, &wdt,
  199. + sizeof(wdt));
  200. + if (IS_ERR(pdev))
  201. + return PTR_ERR(pdev);
  202. +
  203. + cc->watchdog = pdev;
  204. +
  205. + return 0;
  206. +}
  207. +
  208. +void bcma_core_chipcommon_early_init(struct bcma_drv_cc *cc)
  209. +{
  210. + if (cc->early_setup_done)
  211. return;
  212. + spin_lock_init(&cc->gpio_lock);
  213. +
  214. if (cc->core->id.rev >= 11)
  215. cc->status = bcma_cc_read32(cc, BCMA_CC_CHIPSTAT);
  216. cc->capabilities = bcma_cc_read32(cc, BCMA_CC_CAP);
  217. if (cc->core->id.rev >= 35)
  218. cc->capabilities_ext = bcma_cc_read32(cc, BCMA_CC_CAP_EXT);
  219. + if (cc->capabilities & BCMA_CC_CAP_PMU)
  220. + bcma_pmu_early_init(cc);
  221. +
  222. + cc->early_setup_done = true;
  223. +}
  224. +
  225. +void bcma_core_chipcommon_init(struct bcma_drv_cc *cc)
  226. +{
  227. + u32 leddc_on = 10;
  228. + u32 leddc_off = 90;
  229. +
  230. + if (cc->setup_done)
  231. + return;
  232. +
  233. + bcma_core_chipcommon_early_init(cc);
  234. +
  235. if (cc->core->id.rev >= 20) {
  236. bcma_cc_write32(cc, BCMA_CC_GPIOPULLUP, 0);
  237. bcma_cc_write32(cc, BCMA_CC_GPIOPULLDOWN, 0);
  238. @@ -56,15 +159,33 @@ void bcma_core_chipcommon_init(struct bc
  239. ((leddc_on << BCMA_CC_GPIOTIMER_ONTIME_SHIFT) |
  240. (leddc_off << BCMA_CC_GPIOTIMER_OFFTIME_SHIFT)));
  241. }
  242. + cc->ticks_per_ms = bcma_chipco_watchdog_ticks_per_ms(cc);
  243. cc->setup_done = true;
  244. }
  245. /* Set chip watchdog reset timer to fire in 'ticks' backplane cycles */
  246. -void bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc, u32 ticks)
  247. +u32 bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc, u32 ticks)
  248. {
  249. - /* instant NMI */
  250. - bcma_cc_write32(cc, BCMA_CC_WATCHDOG, ticks);
  251. + u32 maxt;
  252. + enum bcma_clkmode clkmode;
  253. +
  254. + maxt = bcma_chipco_watchdog_get_max_timer(cc);
  255. + if (cc->capabilities & BCMA_CC_CAP_PMU) {
  256. + if (ticks == 1)
  257. + ticks = 2;
  258. + else if (ticks > maxt)
  259. + ticks = maxt;
  260. + bcma_cc_write32(cc, BCMA_CC_PMU_WATCHDOG, ticks);
  261. + } else {
  262. + clkmode = ticks ? BCMA_CLKMODE_FAST : BCMA_CLKMODE_DYNAMIC;
  263. + bcma_core_set_clockmode(cc->core, clkmode);
  264. + if (ticks > maxt)
  265. + ticks = maxt;
  266. + /* instant NMI */
  267. + bcma_cc_write32(cc, BCMA_CC_WATCHDOG, ticks);
  268. + }
  269. + return ticks;
  270. }
  271. void bcma_chipco_irq_mask(struct bcma_drv_cc *cc, u32 mask, u32 value)
  272. @@ -84,28 +205,99 @@ u32 bcma_chipco_gpio_in(struct bcma_drv_
  273. u32 bcma_chipco_gpio_out(struct bcma_drv_cc *cc, u32 mask, u32 value)
  274. {
  275. - return bcma_cc_write32_masked(cc, BCMA_CC_GPIOOUT, mask, value);
  276. + unsigned long flags;
  277. + u32 res;
  278. +
  279. + spin_lock_irqsave(&cc->gpio_lock, flags);
  280. + res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOOUT, mask, value);
  281. + spin_unlock_irqrestore(&cc->gpio_lock, flags);
  282. +
  283. + return res;
  284. }
  285. +EXPORT_SYMBOL_GPL(bcma_chipco_gpio_out);
  286. u32 bcma_chipco_gpio_outen(struct bcma_drv_cc *cc, u32 mask, u32 value)
  287. {
  288. - return bcma_cc_write32_masked(cc, BCMA_CC_GPIOOUTEN, mask, value);
  289. + unsigned long flags;
  290. + u32 res;
  291. +
  292. + spin_lock_irqsave(&cc->gpio_lock, flags);
  293. + res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOOUTEN, mask, value);
  294. + spin_unlock_irqrestore(&cc->gpio_lock, flags);
  295. +
  296. + return res;
  297. }
  298. +EXPORT_SYMBOL_GPL(bcma_chipco_gpio_outen);
  299. +/*
  300. + * If the bit is set to 0, chipcommon controlls this GPIO,
  301. + * if the bit is set to 1, it is used by some part of the chip and not our code.
  302. + */
  303. u32 bcma_chipco_gpio_control(struct bcma_drv_cc *cc, u32 mask, u32 value)
  304. {
  305. - return bcma_cc_write32_masked(cc, BCMA_CC_GPIOCTL, mask, value);
  306. + unsigned long flags;
  307. + u32 res;
  308. +
  309. + spin_lock_irqsave(&cc->gpio_lock, flags);
  310. + res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOCTL, mask, value);
  311. + spin_unlock_irqrestore(&cc->gpio_lock, flags);
  312. +
  313. + return res;
  314. }
  315. EXPORT_SYMBOL_GPL(bcma_chipco_gpio_control);
  316. u32 bcma_chipco_gpio_intmask(struct bcma_drv_cc *cc, u32 mask, u32 value)
  317. {
  318. - return bcma_cc_write32_masked(cc, BCMA_CC_GPIOIRQ, mask, value);
  319. + unsigned long flags;
  320. + u32 res;
  321. +
  322. + spin_lock_irqsave(&cc->gpio_lock, flags);
  323. + res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOIRQ, mask, value);
  324. + spin_unlock_irqrestore(&cc->gpio_lock, flags);
  325. +
  326. + return res;
  327. }
  328. u32 bcma_chipco_gpio_polarity(struct bcma_drv_cc *cc, u32 mask, u32 value)
  329. {
  330. - return bcma_cc_write32_masked(cc, BCMA_CC_GPIOPOL, mask, value);
  331. + unsigned long flags;
  332. + u32 res;
  333. +
  334. + spin_lock_irqsave(&cc->gpio_lock, flags);
  335. + res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOPOL, mask, value);
  336. + spin_unlock_irqrestore(&cc->gpio_lock, flags);
  337. +
  338. + return res;
  339. +}
  340. +
  341. +u32 bcma_chipco_gpio_pullup(struct bcma_drv_cc *cc, u32 mask, u32 value)
  342. +{
  343. + unsigned long flags;
  344. + u32 res;
  345. +
  346. + if (cc->core->id.rev < 20)
  347. + return 0;
  348. +
  349. + spin_lock_irqsave(&cc->gpio_lock, flags);
  350. + res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOPULLUP, mask, value);
  351. + spin_unlock_irqrestore(&cc->gpio_lock, flags);
  352. +
  353. + return res;
  354. +}
  355. +
  356. +u32 bcma_chipco_gpio_pulldown(struct bcma_drv_cc *cc, u32 mask, u32 value)
  357. +{
  358. + unsigned long flags;
  359. + u32 res;
  360. +
  361. + if (cc->core->id.rev < 20)
  362. + return 0;
  363. +
  364. + spin_lock_irqsave(&cc->gpio_lock, flags);
  365. + res = bcma_cc_write32_masked(cc, BCMA_CC_GPIOPULLDOWN, mask, value);
  366. + spin_unlock_irqrestore(&cc->gpio_lock, flags);
  367. +
  368. + return res;
  369. }
  370. #ifdef CONFIG_BCMA_DRIVER_MIPS
  371. @@ -118,8 +310,7 @@ void bcma_chipco_serial_init(struct bcma
  372. struct bcma_serial_port *ports = cc->serial_ports;
  373. if (ccrev >= 11 && ccrev != 15) {
  374. - /* Fixed ALP clock */
  375. - baud_base = bcma_pmu_alp_clock(cc);
  376. + baud_base = bcma_chipco_get_alp_clock(cc);
  377. if (ccrev >= 21) {
  378. /* Turn off UART clock before switching clocksource. */
  379. bcma_cc_write32(cc, BCMA_CC_CORECTL,
  380. --- a/drivers/bcma/driver_chipcommon_nflash.c
  381. +++ b/drivers/bcma/driver_chipcommon_nflash.c
  382. @@ -5,15 +5,40 @@
  383. * Licensed under the GNU/GPL. See COPYING for details.
  384. */
  385. +#include <linux/platform_device.h>
  386. #include <linux/bcma/bcma.h>
  387. -#include <linux/bcma/bcma_driver_chipcommon.h>
  388. -#include <linux/delay.h>
  389. #include "bcma_private.h"
  390. +struct platform_device bcma_nflash_dev = {
  391. + .name = "bcma_nflash",
  392. + .num_resources = 0,
  393. +};
  394. +
  395. /* Initialize NAND flash access */
  396. int bcma_nflash_init(struct bcma_drv_cc *cc)
  397. {
  398. - bcma_err(cc->core->bus, "NAND flash support is broken\n");
  399. + struct bcma_bus *bus = cc->core->bus;
  400. +
  401. + if (bus->chipinfo.id != BCMA_CHIP_ID_BCM4706 &&
  402. + cc->core->id.rev != 0x38) {
  403. + bcma_err(bus, "NAND flash on unsupported board!\n");
  404. + return -ENOTSUPP;
  405. + }
  406. +
  407. + if (!(cc->capabilities & BCMA_CC_CAP_NFLASH)) {
  408. + bcma_err(bus, "NAND flash not present according to ChipCommon\n");
  409. + return -ENODEV;
  410. + }
  411. +
  412. + cc->nflash.present = true;
  413. + if (cc->core->id.rev == 38 &&
  414. + (cc->status & BCMA_CC_CHIPST_5357_NAND_BOOT))
  415. + cc->nflash.boot = true;
  416. +
  417. + /* Prepare platform device, but don't register it yet. It's too early,
  418. + * malloc (required by device_private_init) is not available yet. */
  419. + bcma_nflash_dev.dev.platform_data = &cc->nflash;
  420. +
  421. return 0;
  422. }
  423. --- a/drivers/bcma/driver_chipcommon_pmu.c
  424. +++ b/drivers/bcma/driver_chipcommon_pmu.c
  425. @@ -13,12 +13,13 @@
  426. #include <linux/export.h>
  427. #include <linux/bcma/bcma.h>
  428. -static u32 bcma_chipco_pll_read(struct bcma_drv_cc *cc, u32 offset)
  429. +u32 bcma_chipco_pll_read(struct bcma_drv_cc *cc, u32 offset)
  430. {
  431. bcma_cc_write32(cc, BCMA_CC_PLLCTL_ADDR, offset);
  432. bcma_cc_read32(cc, BCMA_CC_PLLCTL_ADDR);
  433. return bcma_cc_read32(cc, BCMA_CC_PLLCTL_DATA);
  434. }
  435. +EXPORT_SYMBOL_GPL(bcma_chipco_pll_read);
  436. void bcma_chipco_pll_write(struct bcma_drv_cc *cc, u32 offset, u32 value)
  437. {
  438. @@ -76,7 +77,10 @@ static void bcma_pmu_resources_init(stru
  439. if (max_msk)
  440. bcma_cc_write32(cc, BCMA_CC_PMU_MAXRES_MSK, max_msk);
  441. - /* Add some delay; allow resources to come up and settle. */
  442. + /*
  443. + * Add some delay; allow resources to come up and settle.
  444. + * Delay is required for SoC (early init).
  445. + */
  446. mdelay(2);
  447. }
  448. @@ -101,7 +105,7 @@ void bcma_chipco_bcm4331_ext_pa_lines_ct
  449. bcma_cc_write32(cc, BCMA_CC_CHIPCTL, val);
  450. }
  451. -void bcma_pmu_workarounds(struct bcma_drv_cc *cc)
  452. +static void bcma_pmu_workarounds(struct bcma_drv_cc *cc)
  453. {
  454. struct bcma_bus *bus = cc->core->bus;
  455. @@ -141,7 +145,7 @@ void bcma_pmu_workarounds(struct bcma_dr
  456. }
  457. }
  458. -void bcma_pmu_init(struct bcma_drv_cc *cc)
  459. +void bcma_pmu_early_init(struct bcma_drv_cc *cc)
  460. {
  461. u32 pmucap;
  462. @@ -150,7 +154,10 @@ void bcma_pmu_init(struct bcma_drv_cc *c
  463. bcma_debug(cc->core->bus, "Found rev %u PMU (capabilities 0x%08X)\n",
  464. cc->pmu.rev, pmucap);
  465. +}
  466. +void bcma_pmu_init(struct bcma_drv_cc *cc)
  467. +{
  468. if (cc->pmu.rev == 1)
  469. bcma_cc_mask32(cc, BCMA_CC_PMU_CTL,
  470. ~BCMA_CC_PMU_CTL_NOILPONW);
  471. @@ -162,24 +169,40 @@ void bcma_pmu_init(struct bcma_drv_cc *c
  472. bcma_pmu_workarounds(cc);
  473. }
  474. -u32 bcma_pmu_alp_clock(struct bcma_drv_cc *cc)
  475. +u32 bcma_pmu_get_alp_clock(struct bcma_drv_cc *cc)
  476. {
  477. struct bcma_bus *bus = cc->core->bus;
  478. switch (bus->chipinfo.id) {
  479. + case BCMA_CHIP_ID_BCM4313:
  480. + case BCMA_CHIP_ID_BCM43224:
  481. + case BCMA_CHIP_ID_BCM43225:
  482. + case BCMA_CHIP_ID_BCM43227:
  483. + case BCMA_CHIP_ID_BCM43228:
  484. + case BCMA_CHIP_ID_BCM4331:
  485. + case BCMA_CHIP_ID_BCM43421:
  486. + case BCMA_CHIP_ID_BCM43428:
  487. + case BCMA_CHIP_ID_BCM43431:
  488. case BCMA_CHIP_ID_BCM4716:
  489. - case BCMA_CHIP_ID_BCM4748:
  490. case BCMA_CHIP_ID_BCM47162:
  491. - case BCMA_CHIP_ID_BCM4313:
  492. - case BCMA_CHIP_ID_BCM5357:
  493. + case BCMA_CHIP_ID_BCM4748:
  494. case BCMA_CHIP_ID_BCM4749:
  495. + case BCMA_CHIP_ID_BCM5357:
  496. case BCMA_CHIP_ID_BCM53572:
  497. + case BCMA_CHIP_ID_BCM6362:
  498. /* always 20Mhz */
  499. return 20000 * 1000;
  500. - case BCMA_CHIP_ID_BCM5356:
  501. case BCMA_CHIP_ID_BCM4706:
  502. + case BCMA_CHIP_ID_BCM5356:
  503. /* always 25Mhz */
  504. return 25000 * 1000;
  505. + case BCMA_CHIP_ID_BCM43460:
  506. + case BCMA_CHIP_ID_BCM4352:
  507. + case BCMA_CHIP_ID_BCM4360:
  508. + if (cc->status & BCMA_CC_CHIPST_4360_XTAL_40MZ)
  509. + return 40000 * 1000;
  510. + else
  511. + return 20000 * 1000;
  512. default:
  513. bcma_warn(bus, "No ALP clock specified for %04X device, pmu rev. %d, using default %d Hz\n",
  514. bus->chipinfo.id, cc->pmu.rev, BCMA_CC_PMU_ALP_CLOCK);
  515. @@ -190,7 +213,7 @@ u32 bcma_pmu_alp_clock(struct bcma_drv_c
  516. /* Find the output of the "m" pll divider given pll controls that start with
  517. * pllreg "pll0" i.e. 12 for main 6 for phy, 0 for misc.
  518. */
  519. -static u32 bcma_pmu_clock(struct bcma_drv_cc *cc, u32 pll0, u32 m)
  520. +static u32 bcma_pmu_pll_clock(struct bcma_drv_cc *cc, u32 pll0, u32 m)
  521. {
  522. u32 tmp, div, ndiv, p1, p2, fc;
  523. struct bcma_bus *bus = cc->core->bus;
  524. @@ -219,14 +242,14 @@ static u32 bcma_pmu_clock(struct bcma_dr
  525. ndiv = (tmp & BCMA_CC_PPL_NDIV_MASK) >> BCMA_CC_PPL_NDIV_SHIFT;
  526. /* Do calculation in Mhz */
  527. - fc = bcma_pmu_alp_clock(cc) / 1000000;
  528. + fc = bcma_pmu_get_alp_clock(cc) / 1000000;
  529. fc = (p1 * ndiv * fc) / p2;
  530. /* Return clock in Hertz */
  531. return (fc / div) * 1000000;
  532. }
  533. -static u32 bcma_pmu_clock_bcm4706(struct bcma_drv_cc *cc, u32 pll0, u32 m)
  534. +static u32 bcma_pmu_pll_clock_bcm4706(struct bcma_drv_cc *cc, u32 pll0, u32 m)
  535. {
  536. u32 tmp, ndiv, p1div, p2div;
  537. u32 clock;
  538. @@ -257,7 +280,7 @@ static u32 bcma_pmu_clock_bcm4706(struct
  539. }
  540. /* query bus clock frequency for PMU-enabled chipcommon */
  541. -u32 bcma_pmu_get_clockcontrol(struct bcma_drv_cc *cc)
  542. +static u32 bcma_pmu_get_bus_clock(struct bcma_drv_cc *cc)
  543. {
  544. struct bcma_bus *bus = cc->core->bus;
  545. @@ -265,40 +288,42 @@ u32 bcma_pmu_get_clockcontrol(struct bcm
  546. case BCMA_CHIP_ID_BCM4716:
  547. case BCMA_CHIP_ID_BCM4748:
  548. case BCMA_CHIP_ID_BCM47162:
  549. - return bcma_pmu_clock(cc, BCMA_CC_PMU4716_MAINPLL_PLL0,
  550. - BCMA_CC_PMU5_MAINPLL_SSB);
  551. + return bcma_pmu_pll_clock(cc, BCMA_CC_PMU4716_MAINPLL_PLL0,
  552. + BCMA_CC_PMU5_MAINPLL_SSB);
  553. case BCMA_CHIP_ID_BCM5356:
  554. - return bcma_pmu_clock(cc, BCMA_CC_PMU5356_MAINPLL_PLL0,
  555. - BCMA_CC_PMU5_MAINPLL_SSB);
  556. + return bcma_pmu_pll_clock(cc, BCMA_CC_PMU5356_MAINPLL_PLL0,
  557. + BCMA_CC_PMU5_MAINPLL_SSB);
  558. case BCMA_CHIP_ID_BCM5357:
  559. case BCMA_CHIP_ID_BCM4749:
  560. - return bcma_pmu_clock(cc, BCMA_CC_PMU5357_MAINPLL_PLL0,
  561. - BCMA_CC_PMU5_MAINPLL_SSB);
  562. + return bcma_pmu_pll_clock(cc, BCMA_CC_PMU5357_MAINPLL_PLL0,
  563. + BCMA_CC_PMU5_MAINPLL_SSB);
  564. case BCMA_CHIP_ID_BCM4706:
  565. - return bcma_pmu_clock_bcm4706(cc, BCMA_CC_PMU4706_MAINPLL_PLL0,
  566. - BCMA_CC_PMU5_MAINPLL_SSB);
  567. + return bcma_pmu_pll_clock_bcm4706(cc,
  568. + BCMA_CC_PMU4706_MAINPLL_PLL0,
  569. + BCMA_CC_PMU5_MAINPLL_SSB);
  570. case BCMA_CHIP_ID_BCM53572:
  571. return 75000000;
  572. default:
  573. - bcma_warn(bus, "No backplane clock specified for %04X device, pmu rev. %d, using default %d Hz\n",
  574. + bcma_warn(bus, "No bus clock specified for %04X device, pmu rev. %d, using default %d Hz\n",
  575. bus->chipinfo.id, cc->pmu.rev, BCMA_CC_PMU_HT_CLOCK);
  576. }
  577. return BCMA_CC_PMU_HT_CLOCK;
  578. }
  579. /* query cpu clock frequency for PMU-enabled chipcommon */
  580. -u32 bcma_pmu_get_clockcpu(struct bcma_drv_cc *cc)
  581. +u32 bcma_pmu_get_cpu_clock(struct bcma_drv_cc *cc)
  582. {
  583. struct bcma_bus *bus = cc->core->bus;
  584. if (bus->chipinfo.id == BCMA_CHIP_ID_BCM53572)
  585. return 300000000;
  586. + /* New PMUs can have different clock for bus and CPU */
  587. if (cc->pmu.rev >= 5) {
  588. u32 pll;
  589. switch (bus->chipinfo.id) {
  590. case BCMA_CHIP_ID_BCM4706:
  591. - return bcma_pmu_clock_bcm4706(cc,
  592. + return bcma_pmu_pll_clock_bcm4706(cc,
  593. BCMA_CC_PMU4706_MAINPLL_PLL0,
  594. BCMA_CC_PMU5_MAINPLL_CPU);
  595. case BCMA_CHIP_ID_BCM5356:
  596. @@ -313,10 +338,11 @@ u32 bcma_pmu_get_clockcpu(struct bcma_dr
  597. break;
  598. }
  599. - return bcma_pmu_clock(cc, pll, BCMA_CC_PMU5_MAINPLL_CPU);
  600. + return bcma_pmu_pll_clock(cc, pll, BCMA_CC_PMU5_MAINPLL_CPU);
  601. }
  602. - return bcma_pmu_get_clockcontrol(cc);
  603. + /* On old PMUs CPU has the same clock as the bus */
  604. + return bcma_pmu_get_bus_clock(cc);
  605. }
  606. static void bcma_pmu_spuravoid_pll_write(struct bcma_drv_cc *cc, u32 offset,
  607. @@ -362,7 +388,7 @@ void bcma_pmu_spuravoid_pllupdate(struct
  608. tmp |= (bcm5357_bcm43236_ndiv[spuravoid]) << BCMA_CC_PMU1_PLL0_PC2_NDIV_INT_SHIFT;
  609. bcma_cc_write32(cc, BCMA_CC_PLLCTL_DATA, tmp);
  610. - tmp = 1 << 10;
  611. + tmp = BCMA_CC_PMU_CTL_PLL_UPD;
  612. break;
  613. case BCMA_CHIP_ID_BCM4331:
  614. @@ -383,7 +409,7 @@ void bcma_pmu_spuravoid_pllupdate(struct
  615. bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL2,
  616. 0x03000a08);
  617. }
  618. - tmp = 1 << 10;
  619. + tmp = BCMA_CC_PMU_CTL_PLL_UPD;
  620. break;
  621. case BCMA_CHIP_ID_BCM43224:
  622. @@ -416,7 +442,7 @@ void bcma_pmu_spuravoid_pllupdate(struct
  623. bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL5,
  624. 0x88888815);
  625. }
  626. - tmp = 1 << 10;
  627. + tmp = BCMA_CC_PMU_CTL_PLL_UPD;
  628. break;
  629. case BCMA_CHIP_ID_BCM4716:
  630. @@ -450,7 +476,7 @@ void bcma_pmu_spuravoid_pllupdate(struct
  631. 0x88888815);
  632. }
  633. - tmp = 3 << 9;
  634. + tmp = BCMA_CC_PMU_CTL_PLL_UPD | BCMA_CC_PMU_CTL_NOILPONW;
  635. break;
  636. case BCMA_CHIP_ID_BCM43227:
  637. @@ -486,7 +512,7 @@ void bcma_pmu_spuravoid_pllupdate(struct
  638. bcma_pmu_spuravoid_pll_write(cc, BCMA_CC_PMU_PLL_CTL5,
  639. 0x88888815);
  640. }
  641. - tmp = 1 << 10;
  642. + tmp = BCMA_CC_PMU_CTL_PLL_UPD;
  643. break;
  644. default:
  645. bcma_err(bus, "Unknown spuravoidance settings for chip 0x%04X, not changing PLL\n",
  646. --- a/drivers/bcma/driver_chipcommon_sflash.c
  647. +++ b/drivers/bcma/driver_chipcommon_sflash.c
  648. @@ -5,15 +5,161 @@
  649. * Licensed under the GNU/GPL. See COPYING for details.
  650. */
  651. +#include <linux/platform_device.h>
  652. #include <linux/bcma/bcma.h>
  653. -#include <linux/bcma/bcma_driver_chipcommon.h>
  654. -#include <linux/delay.h>
  655. #include "bcma_private.h"
  656. +static struct resource bcma_sflash_resource = {
  657. + .name = "bcma_sflash",
  658. + .start = BCMA_SOC_FLASH2,
  659. + .end = 0,
  660. + .flags = IORESOURCE_MEM | IORESOURCE_READONLY,
  661. +};
  662. +
  663. +struct platform_device bcma_sflash_dev = {
  664. + .name = "bcma_sflash",
  665. + .resource = &bcma_sflash_resource,
  666. + .num_resources = 1,
  667. +};
  668. +
  669. +struct bcma_sflash_tbl_e {
  670. + char *name;
  671. + u32 id;
  672. + u32 blocksize;
  673. + u16 numblocks;
  674. +};
  675. +
  676. +static struct bcma_sflash_tbl_e bcma_sflash_st_tbl[] = {
  677. + { "M25P20", 0x11, 0x10000, 4, },
  678. + { "M25P40", 0x12, 0x10000, 8, },
  679. +
  680. + { "M25P16", 0x14, 0x10000, 32, },
  681. + { "M25P32", 0x15, 0x10000, 64, },
  682. + { "M25P64", 0x16, 0x10000, 128, },
  683. + { "M25FL128", 0x17, 0x10000, 256, },
  684. + { 0 },
  685. +};
  686. +
  687. +static struct bcma_sflash_tbl_e bcma_sflash_sst_tbl[] = {
  688. + { "SST25WF512", 1, 0x1000, 16, },
  689. + { "SST25VF512", 0x48, 0x1000, 16, },
  690. + { "SST25WF010", 2, 0x1000, 32, },
  691. + { "SST25VF010", 0x49, 0x1000, 32, },
  692. + { "SST25WF020", 3, 0x1000, 64, },
  693. + { "SST25VF020", 0x43, 0x1000, 64, },
  694. + { "SST25WF040", 4, 0x1000, 128, },
  695. + { "SST25VF040", 0x44, 0x1000, 128, },
  696. + { "SST25VF040B", 0x8d, 0x1000, 128, },
  697. + { "SST25WF080", 5, 0x1000, 256, },
  698. + { "SST25VF080B", 0x8e, 0x1000, 256, },
  699. + { "SST25VF016", 0x41, 0x1000, 512, },
  700. + { "SST25VF032", 0x4a, 0x1000, 1024, },
  701. + { "SST25VF064", 0x4b, 0x1000, 2048, },
  702. + { 0 },
  703. +};
  704. +
  705. +static struct bcma_sflash_tbl_e bcma_sflash_at_tbl[] = {
  706. + { "AT45DB011", 0xc, 256, 512, },
  707. + { "AT45DB021", 0x14, 256, 1024, },
  708. + { "AT45DB041", 0x1c, 256, 2048, },
  709. + { "AT45DB081", 0x24, 256, 4096, },
  710. + { "AT45DB161", 0x2c, 512, 4096, },
  711. + { "AT45DB321", 0x34, 512, 8192, },
  712. + { "AT45DB642", 0x3c, 1024, 8192, },
  713. + { 0 },
  714. +};
  715. +
  716. +static void bcma_sflash_cmd(struct bcma_drv_cc *cc, u32 opcode)
  717. +{
  718. + int i;
  719. + bcma_cc_write32(cc, BCMA_CC_FLASHCTL,
  720. + BCMA_CC_FLASHCTL_START | opcode);
  721. + for (i = 0; i < 1000; i++) {
  722. + if (!(bcma_cc_read32(cc, BCMA_CC_FLASHCTL) &
  723. + BCMA_CC_FLASHCTL_BUSY))
  724. + return;
  725. + cpu_relax();
  726. + }
  727. + bcma_err(cc->core->bus, "SFLASH control command failed (timeout)!\n");
  728. +}
  729. +
  730. /* Initialize serial flash access */
  731. int bcma_sflash_init(struct bcma_drv_cc *cc)
  732. {
  733. - bcma_err(cc->core->bus, "Serial flash support is broken\n");
  734. + struct bcma_bus *bus = cc->core->bus;
  735. + struct bcma_sflash *sflash = &cc->sflash;
  736. + struct bcma_sflash_tbl_e *e;
  737. + u32 id, id2;
  738. +
  739. + switch (cc->capabilities & BCMA_CC_CAP_FLASHT) {
  740. + case BCMA_CC_FLASHT_STSER:
  741. + bcma_sflash_cmd(cc, BCMA_CC_FLASHCTL_ST_DP);
  742. +
  743. + bcma_cc_write32(cc, BCMA_CC_FLASHADDR, 0);
  744. + bcma_sflash_cmd(cc, BCMA_CC_FLASHCTL_ST_RES);
  745. + id = bcma_cc_read32(cc, BCMA_CC_FLASHDATA);
  746. +
  747. + bcma_cc_write32(cc, BCMA_CC_FLASHADDR, 1);
  748. + bcma_sflash_cmd(cc, BCMA_CC_FLASHCTL_ST_RES);
  749. + id2 = bcma_cc_read32(cc, BCMA_CC_FLASHDATA);
  750. +
  751. + switch (id) {
  752. + case 0xbf:
  753. + for (e = bcma_sflash_sst_tbl; e->name; e++) {
  754. + if (e->id == id2)
  755. + break;
  756. + }
  757. + break;
  758. + case 0x13:
  759. + return -ENOTSUPP;
  760. + default:
  761. + for (e = bcma_sflash_st_tbl; e->name; e++) {
  762. + if (e->id == id)
  763. + break;
  764. + }
  765. + break;
  766. + }
  767. + if (!e->name) {
  768. + bcma_err(bus, "Unsupported ST serial flash (id: 0x%X, id2: 0x%X)\n", id, id2);
  769. + return -ENOTSUPP;
  770. + }
  771. +
  772. + break;
  773. + case BCMA_CC_FLASHT_ATSER:
  774. + bcma_sflash_cmd(cc, BCMA_CC_FLASHCTL_AT_STATUS);
  775. + id = bcma_cc_read32(cc, BCMA_CC_FLASHDATA) & 0x3c;
  776. +
  777. + for (e = bcma_sflash_at_tbl; e->name; e++) {
  778. + if (e->id == id)
  779. + break;
  780. + }
  781. + if (!e->name) {
  782. + bcma_err(bus, "Unsupported Atmel serial flash (id: 0x%X)\n", id);
  783. + return -ENOTSUPP;
  784. + }
  785. +
  786. + break;
  787. + default:
  788. + bcma_err(bus, "Unsupported flash type\n");
  789. + return -ENOTSUPP;
  790. + }
  791. +
  792. + sflash->window = BCMA_SOC_FLASH2;
  793. + sflash->blocksize = e->blocksize;
  794. + sflash->numblocks = e->numblocks;
  795. + sflash->size = sflash->blocksize * sflash->numblocks;
  796. + sflash->present = true;
  797. +
  798. + bcma_info(bus, "Found %s serial flash (size: %dKiB, blocksize: 0x%X, blocks: %d)\n",
  799. + e->name, sflash->size / 1024, sflash->blocksize,
  800. + sflash->numblocks);
  801. +
  802. + /* Prepare platform device, but don't register it yet. It's too early,
  803. + * malloc (required by device_private_init) is not available yet. */
  804. + bcma_sflash_dev.resource[0].end = bcma_sflash_dev.resource[0].start +
  805. + sflash->size;
  806. + bcma_sflash_dev.dev.platform_data = sflash;
  807. +
  808. return 0;
  809. }
  810. --- /dev/null
  811. +++ b/drivers/bcma/driver_gpio.c
  812. @@ -0,0 +1,98 @@
  813. +/*
  814. + * Broadcom specific AMBA
  815. + * GPIO driver
  816. + *
  817. + * Copyright 2011, Broadcom Corporation
  818. + * Copyright 2012, Hauke Mehrtens <[email protected]>
  819. + *
  820. + * Licensed under the GNU/GPL. See COPYING for details.
  821. + */
  822. +
  823. +#include <linux/gpio.h>
  824. +#include <linux/export.h>
  825. +#include <linux/bcma/bcma.h>
  826. +
  827. +#include "bcma_private.h"
  828. +
  829. +static inline struct bcma_drv_cc *bcma_gpio_get_cc(struct gpio_chip *chip)
  830. +{
  831. + return container_of(chip, struct bcma_drv_cc, gpio);
  832. +}
  833. +
  834. +static int bcma_gpio_get_value(struct gpio_chip *chip, unsigned gpio)
  835. +{
  836. + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
  837. +
  838. + return !!bcma_chipco_gpio_in(cc, 1 << gpio);
  839. +}
  840. +
  841. +static void bcma_gpio_set_value(struct gpio_chip *chip, unsigned gpio,
  842. + int value)
  843. +{
  844. + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
  845. +
  846. + bcma_chipco_gpio_out(cc, 1 << gpio, value ? 1 << gpio : 0);
  847. +}
  848. +
  849. +static int bcma_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
  850. +{
  851. + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
  852. +
  853. + bcma_chipco_gpio_outen(cc, 1 << gpio, 0);
  854. + return 0;
  855. +}
  856. +
  857. +static int bcma_gpio_direction_output(struct gpio_chip *chip, unsigned gpio,
  858. + int value)
  859. +{
  860. + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
  861. +
  862. + bcma_chipco_gpio_outen(cc, 1 << gpio, 1 << gpio);
  863. + bcma_chipco_gpio_out(cc, 1 << gpio, value ? 1 << gpio : 0);
  864. + return 0;
  865. +}
  866. +
  867. +static int bcma_gpio_request(struct gpio_chip *chip, unsigned gpio)
  868. +{
  869. + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
  870. +
  871. + bcma_chipco_gpio_control(cc, 1 << gpio, 0);
  872. + /* clear pulldown */
  873. + bcma_chipco_gpio_pulldown(cc, 1 << gpio, 0);
  874. + /* Set pullup */
  875. + bcma_chipco_gpio_pullup(cc, 1 << gpio, 1 << gpio);
  876. +
  877. + return 0;
  878. +}
  879. +
  880. +static void bcma_gpio_free(struct gpio_chip *chip, unsigned gpio)
  881. +{
  882. + struct bcma_drv_cc *cc = bcma_gpio_get_cc(chip);
  883. +
  884. + /* clear pullup */
  885. + bcma_chipco_gpio_pullup(cc, 1 << gpio, 0);
  886. +}
  887. +
  888. +int bcma_gpio_init(struct bcma_drv_cc *cc)
  889. +{
  890. + struct gpio_chip *chip = &cc->gpio;
  891. +
  892. + chip->label = "bcma_gpio";
  893. + chip->owner = THIS_MODULE;
  894. + chip->request = bcma_gpio_request;
  895. + chip->free = bcma_gpio_free;
  896. + chip->get = bcma_gpio_get_value;
  897. + chip->set = bcma_gpio_set_value;
  898. + chip->direction_input = bcma_gpio_direction_input;
  899. + chip->direction_output = bcma_gpio_direction_output;
  900. + chip->ngpio = 16;
  901. + /* There is just one SoC in one device and its GPIO addresses should be
  902. + * deterministic to address them more easily. The other buses could get
  903. + * a random base number. */
  904. + if (cc->core->bus->hosttype == BCMA_HOSTTYPE_SOC)
  905. + chip->base = 0;
  906. + else
  907. + chip->base = -1;
  908. +
  909. + return gpiochip_add(chip);
  910. +}
  911. --- a/drivers/bcma/driver_mips.c
  912. +++ b/drivers/bcma/driver_mips.c
  913. @@ -74,11 +74,16 @@ static u32 bcma_core_mips_irqflag(struct
  914. return dev->core_index;
  915. flag = bcma_aread32(dev, BCMA_MIPS_OOBSELOUTA30);
  916. - return flag & 0x1F;
  917. + if (flag)
  918. + return flag & 0x1F;
  919. + else
  920. + return 0x3f;
  921. }
  922. /* Get the MIPS IRQ assignment for a specified device.
  923. * If unassigned, 0 is returned.
  924. + * If disabled, 5 is returned.
  925. + * If not supported, 6 is returned.
  926. */
  927. unsigned int bcma_core_mips_irq(struct bcma_device *dev)
  928. {
  929. @@ -87,13 +92,15 @@ unsigned int bcma_core_mips_irq(struct b
  930. unsigned int irq;
  931. irqflag = bcma_core_mips_irqflag(dev);
  932. + if (irqflag == 0x3f)
  933. + return 6;
  934. - for (irq = 1; irq <= 4; irq++)
  935. + for (irq = 0; irq <= 4; irq++)
  936. if (bcma_read32(mdev, BCMA_MIPS_MIPS74K_INTMASK(irq)) &
  937. (1 << irqflag))
  938. return irq;
  939. - return 0;
  940. + return 5;
  941. }
  942. EXPORT_SYMBOL(bcma_core_mips_irq);
  943. @@ -114,8 +121,8 @@ static void bcma_core_mips_set_irq(struc
  944. bcma_write32(mdev, BCMA_MIPS_MIPS74K_INTMASK(0),
  945. bcma_read32(mdev, BCMA_MIPS_MIPS74K_INTMASK(0)) &
  946. ~(1 << irqflag));
  947. - else
  948. - bcma_write32(mdev, BCMA_MIPS_MIPS74K_INTMASK(irq), 0);
  949. + else if (oldirq != 5)
  950. + bcma_write32(mdev, BCMA_MIPS_MIPS74K_INTMASK(oldirq), 0);
  951. /* assign the new one */
  952. if (irq == 0) {
  953. @@ -123,9 +130,9 @@ static void bcma_core_mips_set_irq(struc
  954. bcma_read32(mdev, BCMA_MIPS_MIPS74K_INTMASK(0)) |
  955. (1 << irqflag));
  956. } else {
  957. - u32 oldirqflag = bcma_read32(mdev,
  958. - BCMA_MIPS_MIPS74K_INTMASK(irq));
  959. - if (oldirqflag) {
  960. + u32 irqinitmask = bcma_read32(mdev,
  961. + BCMA_MIPS_MIPS74K_INTMASK(irq));
  962. + if (irqinitmask) {
  963. struct bcma_device *core;
  964. /* backplane irq line is in use, find out who uses
  965. @@ -133,7 +140,7 @@ static void bcma_core_mips_set_irq(struc
  966. */
  967. list_for_each_entry(core, &bus->cores, list) {
  968. if ((1 << bcma_core_mips_irqflag(core)) ==
  969. - oldirqflag) {
  970. + irqinitmask) {
  971. bcma_core_mips_set_irq(core, 0);
  972. break;
  973. }
  974. @@ -143,15 +150,31 @@ static void bcma_core_mips_set_irq(struc
  975. 1 << irqflag);
  976. }
  977. - bcma_info(bus, "set_irq: core 0x%04x, irq %d => %d\n",
  978. - dev->id.id, oldirq + 2, irq + 2);
  979. + bcma_debug(bus, "set_irq: core 0x%04x, irq %d => %d\n",
  980. + dev->id.id, oldirq <= 4 ? oldirq + 2 : 0, irq + 2);
  981. +}
  982. +
  983. +static void bcma_core_mips_set_irq_name(struct bcma_bus *bus, unsigned int irq,
  984. + u16 coreid, u8 unit)
  985. +{
  986. + struct bcma_device *core;
  987. +
  988. + core = bcma_find_core_unit(bus, coreid, unit);
  989. + if (!core) {
  990. + bcma_warn(bus,
  991. + "Can not find core (id: 0x%x, unit %i) for IRQ configuration.\n",
  992. + coreid, unit);
  993. + return;
  994. + }
  995. +
  996. + bcma_core_mips_set_irq(core, irq);
  997. }
  998. static void bcma_core_mips_print_irq(struct bcma_device *dev, unsigned int irq)
  999. {
  1000. int i;
  1001. static const char *irq_name[] = {"2(S)", "3", "4", "5", "6", "D", "I"};
  1002. - printk(KERN_INFO KBUILD_MODNAME ": core 0x%04x, irq :", dev->id.id);
  1003. + printk(KERN_DEBUG KBUILD_MODNAME ": core 0x%04x, irq :", dev->id.id);
  1004. for (i = 0; i <= 6; i++)
  1005. printk(" %s%s", irq_name[i], i == irq ? "*" : " ");
  1006. printk("\n");
  1007. @@ -171,7 +194,7 @@ u32 bcma_cpu_clock(struct bcma_drv_mips
  1008. struct bcma_bus *bus = mcore->core->bus;
  1009. if (bus->drv_cc.capabilities & BCMA_CC_CAP_PMU)
  1010. - return bcma_pmu_get_clockcpu(&bus->drv_cc);
  1011. + return bcma_pmu_get_cpu_clock(&bus->drv_cc);
  1012. bcma_err(bus, "No PMU available, need this to get the cpu clock\n");
  1013. return 0;
  1014. @@ -181,85 +204,109 @@ EXPORT_SYMBOL(bcma_cpu_clock);
  1015. static void bcma_core_mips_flash_detect(struct bcma_drv_mips *mcore)
  1016. {
  1017. struct bcma_bus *bus = mcore->core->bus;
  1018. + struct bcma_drv_cc *cc = &bus->drv_cc;
  1019. - switch (bus->drv_cc.capabilities & BCMA_CC_CAP_FLASHT) {
  1020. + switch (cc->capabilities & BCMA_CC_CAP_FLASHT) {
  1021. case BCMA_CC_FLASHT_STSER:
  1022. case BCMA_CC_FLASHT_ATSER:
  1023. bcma_debug(bus, "Found serial flash\n");
  1024. - bcma_sflash_init(&bus->drv_cc);
  1025. + bcma_sflash_init(cc);
  1026. break;
  1027. case BCMA_CC_FLASHT_PARA:
  1028. bcma_debug(bus, "Found parallel flash\n");
  1029. - bus->drv_cc.pflash.window = 0x1c000000;
  1030. - bus->drv_cc.pflash.window_size = 0x02000000;
  1031. + cc->pflash.present = true;
  1032. + cc->pflash.window = BCMA_SOC_FLASH2;
  1033. + cc->pflash.window_size = BCMA_SOC_FLASH2_SZ;
  1034. - if ((bcma_read32(bus->drv_cc.core, BCMA_CC_FLASH_CFG) &
  1035. + if ((bcma_read32(cc->core, BCMA_CC_FLASH_CFG) &
  1036. BCMA_CC_FLASH_CFG_DS) == 0)
  1037. - bus->drv_cc.pflash.buswidth = 1;
  1038. + cc->pflash.buswidth = 1;
  1039. else
  1040. - bus->drv_cc.pflash.buswidth = 2;
  1041. + cc->pflash.buswidth = 2;
  1042. break;
  1043. default:
  1044. bcma_err(bus, "Flash type not supported\n");
  1045. }
  1046. - if (bus->drv_cc.core->id.rev == 38 ||
  1047. + if (cc->core->id.rev == 38 ||
  1048. bus->chipinfo.id == BCMA_CHIP_ID_BCM4706) {
  1049. - if (bus->drv_cc.capabilities & BCMA_CC_CAP_NFLASH) {
  1050. + if (cc->capabilities & BCMA_CC_CAP_NFLASH) {
  1051. bcma_debug(bus, "Found NAND flash\n");
  1052. - bcma_nflash_init(&bus->drv_cc);
  1053. + bcma_nflash_init(cc);
  1054. }
  1055. }
  1056. }
  1057. +void bcma_core_mips_early_init(struct bcma_drv_mips *mcore)
  1058. +{
  1059. + struct bcma_bus *bus = mcore->core->bus;
  1060. +
  1061. + if (mcore->early_setup_done)
  1062. + return;
  1063. +
  1064. + bcma_chipco_serial_init(&bus->drv_cc);
  1065. + bcma_core_mips_flash_detect(mcore);
  1066. +
  1067. + mcore->early_setup_done = true;
  1068. +}
  1069. +
  1070. void bcma_core_mips_init(struct bcma_drv_mips *mcore)
  1071. {
  1072. struct bcma_bus *bus;
  1073. struct bcma_device *core;
  1074. bus = mcore->core->bus;
  1075. - bcma_info(bus, "Initializing MIPS core...\n");
  1076. + if (mcore->setup_done)
  1077. + return;
  1078. - if (!mcore->setup_done)
  1079. - mcore->assigned_irqs = 1;
  1080. + bcma_debug(bus, "Initializing MIPS core...\n");
  1081. - /* Assign IRQs to all cores on the bus */
  1082. - list_for_each_entry(core, &bus->cores, list) {
  1083. - int mips_irq;
  1084. - if (core->irq)
  1085. - continue;
  1086. -
  1087. - mips_irq = bcma_core_mips_irq(core);
  1088. - if (mips_irq > 4)
  1089. - core->irq = 0;
  1090. - else
  1091. - core->irq = mips_irq + 2;
  1092. - if (core->irq > 5)
  1093. - continue;
  1094. - switch (core->id.id) {
  1095. - case BCMA_CORE_PCI:
  1096. - case BCMA_CORE_PCIE:
  1097. - case BCMA_CORE_ETHERNET:
  1098. - case BCMA_CORE_ETHERNET_GBIT:
  1099. - case BCMA_CORE_MAC_GBIT:
  1100. - case BCMA_CORE_80211:
  1101. - case BCMA_CORE_USB20_HOST:
  1102. - /* These devices get their own IRQ line if available,
  1103. - * the rest goes on IRQ0
  1104. - */
  1105. - if (mcore->assigned_irqs <= 4)
  1106. - bcma_core_mips_set_irq(core,
  1107. - mcore->assigned_irqs++);
  1108. - break;
  1109. + bcma_core_mips_early_init(mcore);
  1110. +
  1111. + switch (bus->chipinfo.id) {
  1112. + case BCMA_CHIP_ID_BCM4716:
  1113. + case BCMA_CHIP_ID_BCM4748:
  1114. + bcma_core_mips_set_irq_name(bus, 1, BCMA_CORE_80211, 0);
  1115. + bcma_core_mips_set_irq_name(bus, 2, BCMA_CORE_MAC_GBIT, 0);
  1116. + bcma_core_mips_set_irq_name(bus, 3, BCMA_CORE_USB20_HOST, 0);
  1117. + bcma_core_mips_set_irq_name(bus, 4, BCMA_CORE_PCIE, 0);
  1118. + bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_CHIPCOMMON, 0);
  1119. + bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_I2S, 0);
  1120. + break;
  1121. + case BCMA_CHIP_ID_BCM5356:
  1122. + case BCMA_CHIP_ID_BCM47162:
  1123. + case BCMA_CHIP_ID_BCM53572:
  1124. + bcma_core_mips_set_irq_name(bus, 1, BCMA_CORE_80211, 0);
  1125. + bcma_core_mips_set_irq_name(bus, 2, BCMA_CORE_MAC_GBIT, 0);
  1126. + bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_CHIPCOMMON, 0);
  1127. + break;
  1128. + case BCMA_CHIP_ID_BCM5357:
  1129. + case BCMA_CHIP_ID_BCM4749:
  1130. + bcma_core_mips_set_irq_name(bus, 1, BCMA_CORE_80211, 0);
  1131. + bcma_core_mips_set_irq_name(bus, 2, BCMA_CORE_MAC_GBIT, 0);
  1132. + bcma_core_mips_set_irq_name(bus, 3, BCMA_CORE_USB20_HOST, 0);
  1133. + bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_CHIPCOMMON, 0);
  1134. + bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_I2S, 0);
  1135. + break;
  1136. + case BCMA_CHIP_ID_BCM4706:
  1137. + bcma_core_mips_set_irq_name(bus, 1, BCMA_CORE_PCIE, 0);
  1138. + bcma_core_mips_set_irq_name(bus, 2, BCMA_CORE_4706_MAC_GBIT,
  1139. + 0);
  1140. + bcma_core_mips_set_irq_name(bus, 3, BCMA_CORE_PCIE, 1);
  1141. + bcma_core_mips_set_irq_name(bus, 4, BCMA_CORE_USB20_HOST, 0);
  1142. + bcma_core_mips_set_irq_name(bus, 0, BCMA_CORE_4706_CHIPCOMMON,
  1143. + 0);
  1144. + break;
  1145. + default:
  1146. + list_for_each_entry(core, &bus->cores, list) {
  1147. + core->irq = bcma_core_mips_irq(core) + 2;
  1148. }
  1149. + bcma_err(bus,
  1150. + "Unknown device (0x%x) found, can not configure IRQs\n",
  1151. + bus->chipinfo.id);
  1152. }
  1153. - bcma_info(bus, "IRQ reconfiguration done\n");
  1154. + bcma_debug(bus, "IRQ reconfiguration done\n");
  1155. bcma_core_mips_dump_irq(bus);
  1156. - if (mcore->setup_done)
  1157. - return;
  1158. -
  1159. - bcma_chipco_serial_init(&bus->drv_cc);
  1160. - bcma_core_mips_flash_detect(mcore);
  1161. mcore->setup_done = true;
  1162. }
  1163. --- a/drivers/bcma/driver_pci.c
  1164. +++ b/drivers/bcma/driver_pci.c
  1165. @@ -51,7 +51,7 @@ static void bcma_pcie_mdio_set_phy(struc
  1166. v = pcicore_read32(pc, BCMA_CORE_PCI_MDIO_CONTROL);
  1167. if (v & BCMA_CORE_PCI_MDIOCTL_ACCESS_DONE)
  1168. break;
  1169. - msleep(1);
  1170. + usleep_range(1000, 2000);
  1171. }
  1172. }
  1173. @@ -92,7 +92,7 @@ static u16 bcma_pcie_mdio_read(struct bc
  1174. ret = pcicore_read32(pc, BCMA_CORE_PCI_MDIO_DATA);
  1175. break;
  1176. }
  1177. - msleep(1);
  1178. + usleep_range(1000, 2000);
  1179. }
  1180. pcicore_write32(pc, BCMA_CORE_PCI_MDIO_CONTROL, 0);
  1181. return ret;
  1182. @@ -132,7 +132,7 @@ static void bcma_pcie_mdio_write(struct
  1183. v = pcicore_read32(pc, BCMA_CORE_PCI_MDIO_CONTROL);
  1184. if (v & BCMA_CORE_PCI_MDIOCTL_ACCESS_DONE)
  1185. break;
  1186. - msleep(1);
  1187. + usleep_range(1000, 2000);
  1188. }
  1189. pcicore_write32(pc, BCMA_CORE_PCI_MDIO_CONTROL, 0);
  1190. }
  1191. --- a/drivers/bcma/driver_pci_host.c
  1192. +++ b/drivers/bcma/driver_pci_host.c
  1193. @@ -35,11 +35,6 @@ bool __devinit bcma_core_pci_is_in_hostm
  1194. chipid_top != 0x5300)
  1195. return false;
  1196. - if (bus->sprom.boardflags_lo & BCMA_CORE_PCI_BFL_NOPCI) {
  1197. - bcma_info(bus, "This PCI core is disabled and not working\n");
  1198. - return false;
  1199. - }
  1200. -
  1201. bcma_core_enable(pc->core, 0);
  1202. return !mips_busprobe32(tmp, pc->core->io_addr);
  1203. @@ -396,6 +391,11 @@ void __devinit bcma_core_pci_hostmode_in
  1204. bcma_info(bus, "PCIEcore in host mode found\n");
  1205. + if (bus->sprom.boardflags_lo & BCMA_CORE_PCI_BFL_NOPCI) {
  1206. + bcma_info(bus, "This PCIE core is disabled and not working\n");
  1207. + return;
  1208. + }
  1209. +
  1210. pc_host = kzalloc(sizeof(*pc_host), GFP_KERNEL);
  1211. if (!pc_host) {
  1212. bcma_err(bus, "can not allocate memory");
  1213. @@ -425,9 +425,9 @@ void __devinit bcma_core_pci_hostmode_in
  1214. pc_host->io_resource.flags = IORESOURCE_IO | IORESOURCE_PCI_FIXED;
  1215. /* Reset RC */
  1216. - udelay(3000);
  1217. + usleep_range(3000, 5000);
  1218. pcicore_write32(pc, BCMA_CORE_PCI_CTL, BCMA_CORE_PCI_CTL_RST_OE);
  1219. - udelay(1000);
  1220. + usleep_range(1000, 2000);
  1221. pcicore_write32(pc, BCMA_CORE_PCI_CTL, BCMA_CORE_PCI_CTL_RST |
  1222. BCMA_CORE_PCI_CTL_RST_OE);
  1223. @@ -452,6 +452,8 @@ void __devinit bcma_core_pci_hostmode_in
  1224. pc_host->mem_resource.start = BCMA_SOC_PCI_MEM;
  1225. pc_host->mem_resource.end = BCMA_SOC_PCI_MEM +
  1226. BCMA_SOC_PCI_MEM_SZ - 1;
  1227. + pc_host->io_resource.start = 0x100;
  1228. + pc_host->io_resource.end = 0x47F;
  1229. pci_membase_1G = BCMA_SOC_PCIE_DMA_H32;
  1230. pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI0,
  1231. tmp | BCMA_SOC_PCI_MEM);
  1232. @@ -459,6 +461,8 @@ void __devinit bcma_core_pci_hostmode_in
  1233. pc_host->mem_resource.start = BCMA_SOC_PCI1_MEM;
  1234. pc_host->mem_resource.end = BCMA_SOC_PCI1_MEM +
  1235. BCMA_SOC_PCI_MEM_SZ - 1;
  1236. + pc_host->io_resource.start = 0x480;
  1237. + pc_host->io_resource.end = 0x7FF;
  1238. pci_membase_1G = BCMA_SOC_PCIE1_DMA_H32;
  1239. pc_host->host_cfg_addr = BCMA_SOC_PCI1_CFG;
  1240. pcicore_write32(pc, BCMA_CORE_PCI_SBTOPCI0,
  1241. @@ -481,7 +485,7 @@ void __devinit bcma_core_pci_hostmode_in
  1242. * before issuing configuration requests to PCI Express
  1243. * devices.
  1244. */
  1245. - udelay(100000);
  1246. + msleep(100);
  1247. bcma_core_pci_enable_crs(pc);
  1248. @@ -501,7 +505,7 @@ void __devinit bcma_core_pci_hostmode_in
  1249. set_io_port_base(pc_host->pci_controller.io_map_base);
  1250. /* Give some time to the PCI controller to configure itself with the new
  1251. * values. Not waiting at this point causes crashes of the machine. */
  1252. - mdelay(10);
  1253. + usleep_range(10000, 15000);
  1254. register_pci_controller(&pc_host->pci_controller);
  1255. return;
  1256. }
  1257. @@ -534,7 +538,7 @@ DECLARE_PCI_FIXUP_EARLY(PCI_ANY_ID, PCI_
  1258. static void bcma_core_pci_fixup_addresses(struct pci_dev *dev)
  1259. {
  1260. struct resource *res;
  1261. - int pos;
  1262. + int pos, err;
  1263. if (dev->bus->ops->read != bcma_core_pci_hostmode_read_config) {
  1264. /* This is not a device on the PCI-core bridge. */
  1265. @@ -547,8 +551,12 @@ static void bcma_core_pci_fixup_addresse
  1266. for (pos = 0; pos < 6; pos++) {
  1267. res = &dev->resource[pos];
  1268. - if (res->flags & (IORESOURCE_IO | IORESOURCE_MEM))
  1269. - pci_assign_resource(dev, pos);
  1270. + if (res->flags & (IORESOURCE_IO | IORESOURCE_MEM)) {
  1271. + err = pci_assign_resource(dev, pos);
  1272. + if (err)
  1273. + pr_err("PCI: Problem fixing up the addresses on %s\n",
  1274. + pci_name(dev));
  1275. + }
  1276. }
  1277. }
  1278. DECLARE_PCI_FIXUP_HEADER(PCI_ANY_ID, PCI_ANY_ID, bcma_core_pci_fixup_addresses);
  1279. --- a/drivers/bcma/host_pci.c
  1280. +++ b/drivers/bcma/host_pci.c
  1281. @@ -77,8 +77,8 @@ static void bcma_host_pci_write32(struct
  1282. }
  1283. #ifdef CONFIG_BCMA_BLOCKIO
  1284. -void bcma_host_pci_block_read(struct bcma_device *core, void *buffer,
  1285. - size_t count, u16 offset, u8 reg_width)
  1286. +static void bcma_host_pci_block_read(struct bcma_device *core, void *buffer,
  1287. + size_t count, u16 offset, u8 reg_width)
  1288. {
  1289. void __iomem *addr = core->bus->mmio + offset;
  1290. if (core->bus->mapped_core != core)
  1291. @@ -100,8 +100,9 @@ void bcma_host_pci_block_read(struct bcm
  1292. }
  1293. }
  1294. -void bcma_host_pci_block_write(struct bcma_device *core, const void *buffer,
  1295. - size_t count, u16 offset, u8 reg_width)
  1296. +static void bcma_host_pci_block_write(struct bcma_device *core,
  1297. + const void *buffer, size_t count,
  1298. + u16 offset, u8 reg_width)
  1299. {
  1300. void __iomem *addr = core->bus->mmio + offset;
  1301. if (core->bus->mapped_core != core)
  1302. @@ -139,7 +140,7 @@ static void bcma_host_pci_awrite32(struc
  1303. iowrite32(value, core->bus->mmio + (1 * BCMA_CORE_SIZE) + offset);
  1304. }
  1305. -const struct bcma_host_ops bcma_host_pci_ops = {
  1306. +static const struct bcma_host_ops bcma_host_pci_ops = {
  1307. .read8 = bcma_host_pci_read8,
  1308. .read16 = bcma_host_pci_read16,
  1309. .read32 = bcma_host_pci_read32,
  1310. @@ -237,7 +238,7 @@ static void __devexit bcma_host_pci_remo
  1311. pci_set_drvdata(dev, NULL);
  1312. }
  1313. -#ifdef CONFIG_PM
  1314. +#ifdef CONFIG_PM_SLEEP
  1315. static int bcma_host_pci_suspend(struct device *dev)
  1316. {
  1317. struct pci_dev *pdev = to_pci_dev(dev);
  1318. @@ -260,11 +261,11 @@ static SIMPLE_DEV_PM_OPS(bcma_pm_ops, bc
  1319. bcma_host_pci_resume);
  1320. #define BCMA_PM_OPS (&bcma_pm_ops)
  1321. -#else /* CONFIG_PM */
  1322. +#else /* CONFIG_PM_SLEEP */
  1323. #define BCMA_PM_OPS NULL
  1324. -#endif /* CONFIG_PM */
  1325. +#endif /* CONFIG_PM_SLEEP */
  1326. static DEFINE_PCI_DEVICE_TABLE(bcma_pci_bridge_tbl) = {
  1327. { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x0576) },
  1328. @@ -272,6 +273,7 @@ static DEFINE_PCI_DEVICE_TABLE(bcma_pci_
  1329. { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4331) },
  1330. { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4353) },
  1331. { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4357) },
  1332. + { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4358) },
  1333. { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4359) },
  1334. { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4727) },
  1335. { 0, },
  1336. --- a/drivers/bcma/host_soc.c
  1337. +++ b/drivers/bcma/host_soc.c
  1338. @@ -143,7 +143,7 @@ static void bcma_host_soc_awrite32(struc
  1339. writel(value, core->io_wrap + offset);
  1340. }
  1341. -const struct bcma_host_ops bcma_host_soc_ops = {
  1342. +static const struct bcma_host_ops bcma_host_soc_ops = {
  1343. .read8 = bcma_host_soc_read8,
  1344. .read16 = bcma_host_soc_read16,
  1345. .read32 = bcma_host_soc_read32,
  1346. --- a/drivers/bcma/main.c
  1347. +++ b/drivers/bcma/main.c
  1348. @@ -7,6 +7,7 @@
  1349. #include "bcma_private.h"
  1350. #include <linux/module.h>
  1351. +#include <linux/platform_device.h>
  1352. #include <linux/bcma/bcma.h>
  1353. #include <linux/slab.h>
  1354. @@ -80,6 +81,18 @@ struct bcma_device *bcma_find_core(struc
  1355. }
  1356. EXPORT_SYMBOL_GPL(bcma_find_core);
  1357. +struct bcma_device *bcma_find_core_unit(struct bcma_bus *bus, u16 coreid,
  1358. + u8 unit)
  1359. +{
  1360. + struct bcma_device *core;
  1361. +
  1362. + list_for_each_entry(core, &bus->cores, list) {
  1363. + if (core->id.id == coreid && core->core_unit == unit)
  1364. + return core;
  1365. + }
  1366. + return NULL;
  1367. +}
  1368. +
  1369. static void bcma_release_core_dev(struct device *dev)
  1370. {
  1371. struct bcma_device *core = container_of(dev, struct bcma_device, dev);
  1372. @@ -136,6 +149,33 @@ static int bcma_register_cores(struct bc
  1373. dev_id++;
  1374. }
  1375. +#ifdef CONFIG_BCMA_SFLASH
  1376. + if (bus->drv_cc.sflash.present) {
  1377. + err = platform_device_register(&bcma_sflash_dev);
  1378. + if (err)
  1379. + bcma_err(bus, "Error registering serial flash\n");
  1380. + }
  1381. +#endif
  1382. +
  1383. +#ifdef CONFIG_BCMA_NFLASH
  1384. + if (bus->drv_cc.nflash.present) {
  1385. + err = platform_device_register(&bcma_nflash_dev);
  1386. + if (err)
  1387. + bcma_err(bus, "Error registering NAND flash\n");
  1388. + }
  1389. +#endif
  1390. + err = bcma_gpio_init(&bus->drv_cc);
  1391. + if (err == -ENOTSUPP)
  1392. + bcma_debug(bus, "GPIO driver not activated\n");
  1393. + else if (err)
  1394. + bcma_err(bus, "Error registering GPIO driver: %i\n", err);
  1395. +
  1396. + if (bus->hosttype == BCMA_HOSTTYPE_SOC) {
  1397. + err = bcma_chipco_watchdog_register(&bus->drv_cc);
  1398. + if (err)
  1399. + bcma_err(bus, "Error registering watchdog driver\n");
  1400. + }
  1401. +
  1402. return 0;
  1403. }
  1404. @@ -148,6 +188,8 @@ static void bcma_unregister_cores(struct
  1405. if (core->dev_registered)
  1406. device_unregister(&core->dev);
  1407. }
  1408. + if (bus->hosttype == BCMA_HOSTTYPE_SOC)
  1409. + platform_device_unregister(bus->drv_cc.watchdog);
  1410. }
  1411. int __devinit bcma_bus_register(struct bcma_bus *bus)
  1412. @@ -166,6 +208,20 @@ int __devinit bcma_bus_register(struct b
  1413. return -1;
  1414. }
  1415. + /* Early init CC core */
  1416. + core = bcma_find_core(bus, bcma_cc_core_id(bus));
  1417. + if (core) {
  1418. + bus->drv_cc.core = core;
  1419. + bcma_core_chipcommon_early_init(&bus->drv_cc);
  1420. + }
  1421. +
  1422. + /* Try to get SPROM */
  1423. + err = bcma_sprom_get(bus);
  1424. + if (err == -ENOENT) {
  1425. + bcma_err(bus, "No SPROM available\n");
  1426. + } else if (err)
  1427. + bcma_err(bus, "Failed to get SPROM: %d\n", err);
  1428. +
  1429. /* Init CC core */
  1430. core = bcma_find_core(bus, bcma_cc_core_id(bus));
  1431. if (core) {
  1432. @@ -181,10 +237,17 @@ int __devinit bcma_bus_register(struct b
  1433. }
  1434. /* Init PCIE core */
  1435. - core = bcma_find_core(bus, BCMA_CORE_PCIE);
  1436. + core = bcma_find_core_unit(bus, BCMA_CORE_PCIE, 0);
  1437. + if (core) {
  1438. + bus->drv_pci[0].core = core;
  1439. + bcma_core_pci_init(&bus->drv_pci[0]);
  1440. + }
  1441. +
  1442. + /* Init PCIE core */
  1443. + core = bcma_find_core_unit(bus, BCMA_CORE_PCIE, 1);
  1444. if (core) {
  1445. - bus->drv_pci.core = core;
  1446. - bcma_core_pci_init(&bus->drv_pci);
  1447. + bus->drv_pci[1].core = core;
  1448. + bcma_core_pci_init(&bus->drv_pci[1]);
  1449. }
  1450. /* Init GBIT MAC COMMON core */
  1451. @@ -194,13 +257,6 @@ int __devinit bcma_bus_register(struct b
  1452. bcma_core_gmac_cmn_init(&bus->drv_gmac_cmn);
  1453. }
  1454. - /* Try to get SPROM */
  1455. - err = bcma_sprom_get(bus);
  1456. - if (err == -ENOENT) {
  1457. - bcma_err(bus, "No SPROM available\n");
  1458. - } else if (err)
  1459. - bcma_err(bus, "Failed to get SPROM: %d\n", err);
  1460. -
  1461. /* Register found cores */
  1462. bcma_register_cores(bus);
  1463. @@ -211,7 +267,17 @@ int __devinit bcma_bus_register(struct b
  1464. void bcma_bus_unregister(struct bcma_bus *bus)
  1465. {
  1466. + struct bcma_device *cores[3];
  1467. +
  1468. + cores[0] = bcma_find_core(bus, BCMA_CORE_MIPS_74K);
  1469. + cores[1] = bcma_find_core(bus, BCMA_CORE_PCIE);
  1470. + cores[2] = bcma_find_core(bus, BCMA_CORE_4706_MAC_GBIT_COMMON);
  1471. +
  1472. bcma_unregister_cores(bus);
  1473. +
  1474. + kfree(cores[2]);
  1475. + kfree(cores[1]);
  1476. + kfree(cores[0]);
  1477. }
  1478. int __init bcma_bus_early_register(struct bcma_bus *bus,
  1479. @@ -248,18 +314,18 @@ int __init bcma_bus_early_register(struc
  1480. return -1;
  1481. }
  1482. - /* Init CC core */
  1483. + /* Early init CC core */
  1484. core = bcma_find_core(bus, bcma_cc_core_id(bus));
  1485. if (core) {
  1486. bus->drv_cc.core = core;
  1487. - bcma_core_chipcommon_init(&bus->drv_cc);
  1488. + bcma_core_chipcommon_early_init(&bus->drv_cc);
  1489. }
  1490. - /* Init MIPS core */
  1491. + /* Early init MIPS core */
  1492. core = bcma_find_core(bus, BCMA_CORE_MIPS_74K);
  1493. if (core) {
  1494. bus->drv_mips.core = core;
  1495. - bcma_core_mips_init(&bus->drv_mips);
  1496. + bcma_core_mips_early_init(&bus->drv_mips);
  1497. }
  1498. bcma_info(bus, "Early bus registered\n");
  1499. --- a/drivers/bcma/sprom.c
  1500. +++ b/drivers/bcma/sprom.c
  1501. @@ -507,7 +507,9 @@ static bool bcma_sprom_onchip_available(
  1502. /* for these chips OTP is always available */
  1503. present = true;
  1504. break;
  1505. + case BCMA_CHIP_ID_BCM43227:
  1506. case BCMA_CHIP_ID_BCM43228:
  1507. + case BCMA_CHIP_ID_BCM43428:
  1508. present = chip_status & BCMA_CC_CHIPST_43228_OTP_PRESENT;
  1509. break;
  1510. default:
  1511. @@ -593,8 +595,11 @@ int bcma_sprom_get(struct bcma_bus *bus)
  1512. bcma_chipco_bcm4331_ext_pa_lines_ctl(&bus->drv_cc, true);
  1513. err = bcma_sprom_valid(sprom);
  1514. - if (err)
  1515. + if (err) {
  1516. + bcma_warn(bus, "invalid sprom read from the PCIe card, try to use fallback sprom\n");
  1517. + err = bcma_fill_sprom_with_fallback(bus, &bus->sprom);
  1518. goto out;
  1519. + }
  1520. bcma_sprom_extract_r8(bus, sprom);
  1521. --- a/include/linux/bcma/bcma.h
  1522. +++ b/include/linux/bcma/bcma.h
  1523. @@ -10,7 +10,7 @@
  1524. #include <linux/bcma/bcma_driver_gmac_cmn.h>
  1525. #include <linux/ssb/ssb.h> /* SPROM sharing */
  1526. -#include "bcma_regs.h"
  1527. +#include <linux/bcma/bcma_regs.h>
  1528. struct bcma_device;
  1529. struct bcma_bus;
  1530. @@ -157,6 +157,7 @@ struct bcma_host_ops {
  1531. /* Chip IDs of SoCs */
  1532. #define BCMA_CHIP_ID_BCM4706 0x5300
  1533. +#define BCMA_PKG_ID_BCM4706L 1
  1534. #define BCMA_CHIP_ID_BCM4716 0x4716
  1535. #define BCMA_PKG_ID_BCM4716 8
  1536. #define BCMA_PKG_ID_BCM4717 9
  1537. @@ -166,7 +167,11 @@ struct bcma_host_ops {
  1538. #define BCMA_CHIP_ID_BCM4749 0x4749
  1539. #define BCMA_CHIP_ID_BCM5356 0x5356
  1540. #define BCMA_CHIP_ID_BCM5357 0x5357
  1541. +#define BCMA_PKG_ID_BCM5358 9
  1542. +#define BCMA_PKG_ID_BCM47186 10
  1543. +#define BCMA_PKG_ID_BCM5357 11
  1544. #define BCMA_CHIP_ID_BCM53572 53572
  1545. +#define BCMA_PKG_ID_BCM47188 9
  1546. struct bcma_device {
  1547. struct bcma_bus *bus;
  1548. @@ -251,7 +256,7 @@ struct bcma_bus {
  1549. u8 num;
  1550. struct bcma_drv_cc drv_cc;
  1551. - struct bcma_drv_pci drv_pci;
  1552. + struct bcma_drv_pci drv_pci[2];
  1553. struct bcma_drv_mips drv_mips;
  1554. struct bcma_drv_gmac_cmn drv_gmac_cmn;
  1555. @@ -345,6 +350,7 @@ extern void bcma_core_set_clockmode(stru
  1556. enum bcma_clkmode clkmode);
  1557. extern void bcma_core_pll_ctl(struct bcma_device *core, u32 req, u32 status,
  1558. bool on);
  1559. +extern u32 bcma_chipco_pll_read(struct bcma_drv_cc *cc, u32 offset);
  1560. #define BCMA_DMA_TRANSLATION_MASK 0xC0000000
  1561. #define BCMA_DMA_TRANSLATION_NONE 0x00000000
  1562. #define BCMA_DMA_TRANSLATION_DMA32_CMT 0x40000000 /* Client Mode Translation for 32-bit DMA */
  1563. --- a/include/linux/bcma/bcma_driver_chipcommon.h
  1564. +++ b/include/linux/bcma/bcma_driver_chipcommon.h
  1565. @@ -1,6 +1,9 @@
  1566. #ifndef LINUX_BCMA_DRIVER_CC_H_
  1567. #define LINUX_BCMA_DRIVER_CC_H_
  1568. +#include <linux/platform_device.h>
  1569. +#include <linux/gpio.h>
  1570. +
  1571. /** ChipCommon core registers. **/
  1572. #define BCMA_CC_ID 0x0000
  1573. #define BCMA_CC_ID_ID 0x0000FFFF
  1574. @@ -100,6 +103,8 @@
  1575. #define BCMA_CC_CHIPST_4706_SFLASH_TYPE BIT(2) /* 0: 8b-p/ST-s flash, 1: 16b-p/Atmal-s flash */
  1576. #define BCMA_CC_CHIPST_4706_MIPS_BENDIAN BIT(3) /* 0: little, 1: big endian */
  1577. #define BCMA_CC_CHIPST_4706_PCIE1_DISABLE BIT(5) /* PCIE1 enable strap pin */
  1578. +#define BCMA_CC_CHIPST_5357_NAND_BOOT BIT(4) /* NAND boot, valid for CC rev 38 and/or BCM5357 */
  1579. +#define BCMA_CC_CHIPST_4360_XTAL_40MZ 0x00000001
  1580. #define BCMA_CC_JCMD 0x0030 /* Rev >= 10 only */
  1581. #define BCMA_CC_JCMD_START 0x80000000
  1582. #define BCMA_CC_JCMD_BUSY 0x80000000
  1583. @@ -266,6 +271,29 @@
  1584. #define BCMA_CC_SROM_CONTROL_SIZE_16K 0x00000004
  1585. #define BCMA_CC_SROM_CONTROL_SIZE_SHIFT 1
  1586. #define BCMA_CC_SROM_CONTROL_PRESENT 0x00000001
  1587. +/* Block 0x140 - 0x190 registers are chipset specific */
  1588. +#define BCMA_CC_4706_FLASHSCFG 0x18C /* Flash struct configuration */
  1589. +#define BCMA_CC_4706_FLASHSCFG_MASK 0x000000ff
  1590. +#define BCMA_CC_4706_FLASHSCFG_SF1 0x00000001 /* 2nd serial flash present */
  1591. +#define BCMA_CC_4706_FLASHSCFG_PF1 0x00000002 /* 2nd parallel flash present */
  1592. +#define BCMA_CC_4706_FLASHSCFG_SF1_TYPE 0x00000004 /* 2nd serial flash type : 0 : ST, 1 : Atmel */
  1593. +#define BCMA_CC_4706_FLASHSCFG_NF1 0x00000008 /* 2nd NAND flash present */
  1594. +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_MASK 0x000000f0
  1595. +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_4MB 0x00000010 /* 4MB */
  1596. +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_8MB 0x00000020 /* 8MB */
  1597. +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_16MB 0x00000030 /* 16MB */
  1598. +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_32MB 0x00000040 /* 32MB */
  1599. +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_64MB 0x00000050 /* 64MB */
  1600. +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_128MB 0x00000060 /* 128MB */
  1601. +#define BCMA_CC_4706_FLASHSCFG_1ST_MADDR_SEG_256MB 0x00000070 /* 256MB */
  1602. +/* NAND flash registers for BCM4706 (corerev = 31) */
  1603. +#define BCMA_CC_NFLASH_CTL 0x01A0
  1604. +#define BCMA_CC_NFLASH_CTL_ERR 0x08000000
  1605. +#define BCMA_CC_NFLASH_CONF 0x01A4
  1606. +#define BCMA_CC_NFLASH_COL_ADDR 0x01A8
  1607. +#define BCMA_CC_NFLASH_ROW_ADDR 0x01AC
  1608. +#define BCMA_CC_NFLASH_DATA 0x01B0
  1609. +#define BCMA_CC_NFLASH_WAITCNT0 0x01B4
  1610. /* 0x1E0 is defined as shared BCMA_CLKCTLST */
  1611. #define BCMA_CC_HW_WORKAROUND 0x01E4 /* Hardware workaround (rev >= 20) */
  1612. #define BCMA_CC_UART0_DATA 0x0300
  1613. @@ -325,6 +353,60 @@
  1614. #define BCMA_CC_PLLCTL_ADDR 0x0660
  1615. #define BCMA_CC_PLLCTL_DATA 0x0664
  1616. #define BCMA_CC_SPROM 0x0800 /* SPROM beginning */
  1617. +/* NAND flash MLC controller registers (corerev >= 38) */
  1618. +#define BCMA_CC_NAND_REVISION 0x0C00
  1619. +#define BCMA_CC_NAND_CMD_START 0x0C04
  1620. +#define BCMA_CC_NAND_CMD_ADDR_X 0x0C08
  1621. +#define BCMA_CC_NAND_CMD_ADDR 0x0C0C
  1622. +#define BCMA_CC_NAND_CMD_END_ADDR 0x0C10
  1623. +#define BCMA_CC_NAND_CS_NAND_SELECT 0x0C14
  1624. +#define BCMA_CC_NAND_CS_NAND_XOR 0x0C18
  1625. +#define BCMA_CC_NAND_SPARE_RD0 0x0C20
  1626. +#define BCMA_CC_NAND_SPARE_RD4 0x0C24
  1627. +#define BCMA_CC_NAND_SPARE_RD8 0x0C28
  1628. +#define BCMA_CC_NAND_SPARE_RD12 0x0C2C
  1629. +#define BCMA_CC_NAND_SPARE_WR0 0x0C30
  1630. +#define BCMA_CC_NAND_SPARE_WR4 0x0C34
  1631. +#define BCMA_CC_NAND_SPARE_WR8 0x0C38
  1632. +#define BCMA_CC_NAND_SPARE_WR12 0x0C3C
  1633. +#define BCMA_CC_NAND_ACC_CONTROL 0x0C40
  1634. +#define BCMA_CC_NAND_CONFIG 0x0C48
  1635. +#define BCMA_CC_NAND_TIMING_1 0x0C50
  1636. +#define BCMA_CC_NAND_TIMING_2 0x0C54
  1637. +#define BCMA_CC_NAND_SEMAPHORE 0x0C58
  1638. +#define BCMA_CC_NAND_DEVID 0x0C60
  1639. +#define BCMA_CC_NAND_DEVID_X 0x0C64
  1640. +#define BCMA_CC_NAND_BLOCK_LOCK_STATUS 0x0C68
  1641. +#define BCMA_CC_NAND_INTFC_STATUS 0x0C6C
  1642. +#define BCMA_CC_NAND_ECC_CORR_ADDR_X 0x0C70
  1643. +#define BCMA_CC_NAND_ECC_CORR_ADDR 0x0C74
  1644. +#define BCMA_CC_NAND_ECC_UNC_ADDR_X 0x0C78
  1645. +#define BCMA_CC_NAND_ECC_UNC_ADDR 0x0C7C
  1646. +#define BCMA_CC_NAND_READ_ERROR_COUNT 0x0C80
  1647. +#define BCMA_CC_NAND_CORR_STAT_THRESHOLD 0x0C84
  1648. +#define BCMA_CC_NAND_READ_ADDR_X 0x0C90
  1649. +#define BCMA_CC_NAND_READ_ADDR 0x0C94
  1650. +#define BCMA_CC_NAND_PAGE_PROGRAM_ADDR_X 0x0C98
  1651. +#define BCMA_CC_NAND_PAGE_PROGRAM_ADDR 0x0C9C
  1652. +#define BCMA_CC_NAND_COPY_BACK_ADDR_X 0x0CA0
  1653. +#define BCMA_CC_NAND_COPY_BACK_ADDR 0x0CA4
  1654. +#define BCMA_CC_NAND_BLOCK_ERASE_ADDR_X 0x0CA8
  1655. +#define BCMA_CC_NAND_BLOCK_ERASE_ADDR 0x0CAC
  1656. +#define BCMA_CC_NAND_INV_READ_ADDR_X 0x0CB0
  1657. +#define BCMA_CC_NAND_INV_READ_ADDR 0x0CB4
  1658. +#define BCMA_CC_NAND_BLK_WR_PROTECT 0x0CC0
  1659. +#define BCMA_CC_NAND_ACC_CONTROL_CS1 0x0CD0
  1660. +#define BCMA_CC_NAND_CONFIG_CS1 0x0CD4
  1661. +#define BCMA_CC_NAND_TIMING_1_CS1 0x0CD8
  1662. +#define BCMA_CC_NAND_TIMING_2_CS1 0x0CDC
  1663. +#define BCMA_CC_NAND_SPARE_RD16 0x0D30
  1664. +#define BCMA_CC_NAND_SPARE_RD20 0x0D34
  1665. +#define BCMA_CC_NAND_SPARE_RD24 0x0D38
  1666. +#define BCMA_CC_NAND_SPARE_RD28 0x0D3C
  1667. +#define BCMA_CC_NAND_CACHE_ADDR 0x0D40
  1668. +#define BCMA_CC_NAND_CACHE_DATA 0x0D44
  1669. +#define BCMA_CC_NAND_CTRL_CONFIG 0x0D48
  1670. +#define BCMA_CC_NAND_CTRL_STATUS 0x0D4C
  1671. /* Divider allocation in 4716/47162/5356 */
  1672. #define BCMA_CC_PMU5_MAINPLL_CPU 1
  1673. @@ -415,6 +497,13 @@
  1674. /* 4313 Chip specific ChipControl register bits */
  1675. #define BCMA_CCTRL_4313_12MA_LED_DRIVE 0x00000007 /* 12 mA drive strengh for later 4313 */
  1676. +/* BCM5357 ChipControl register bits */
  1677. +#define BCMA_CHIPCTL_5357_EXTPA BIT(14)
  1678. +#define BCMA_CHIPCTL_5357_ANT_MUX_2O3 BIT(15)
  1679. +#define BCMA_CHIPCTL_5357_NFLASH BIT(16)
  1680. +#define BCMA_CHIPCTL_5357_I2S_PINS_ENABLE BIT(18)
  1681. +#define BCMA_CHIPCTL_5357_I2CSPI_PINS_ENABLE BIT(19)
  1682. +
  1683. /* Data for the PMU, if available.
  1684. * Check availability with ((struct bcma_chipcommon)->capabilities & BCMA_CC_CAP_PMU)
  1685. */
  1686. @@ -425,11 +514,35 @@ struct bcma_chipcommon_pmu {
  1687. #ifdef CONFIG_BCMA_DRIVER_MIPS
  1688. struct bcma_pflash {
  1689. + bool present;
  1690. u8 buswidth;
  1691. u32 window;
  1692. u32 window_size;
  1693. };
  1694. +#ifdef CONFIG_BCMA_SFLASH
  1695. +struct bcma_sflash {
  1696. + bool present;
  1697. + u32 window;
  1698. + u32 blocksize;
  1699. + u16 numblocks;
  1700. + u32 size;
  1701. +
  1702. + struct mtd_info *mtd;
  1703. +};
  1704. +#endif
  1705. +
  1706. +#ifdef CONFIG_BCMA_NFLASH
  1707. +struct mtd_info;
  1708. +
  1709. +struct bcma_nflash {
  1710. + bool present;
  1711. + bool boot; /* This is the flash the SoC boots from */
  1712. +
  1713. + struct mtd_info *mtd;
  1714. +};
  1715. +#endif
  1716. +
  1717. struct bcma_serial_port {
  1718. void *regs;
  1719. unsigned long clockspeed;
  1720. @@ -445,15 +558,30 @@ struct bcma_drv_cc {
  1721. u32 capabilities;
  1722. u32 capabilities_ext;
  1723. u8 setup_done:1;
  1724. + u8 early_setup_done:1;
  1725. /* Fast Powerup Delay constant */
  1726. u16 fast_pwrup_delay;
  1727. struct bcma_chipcommon_pmu pmu;
  1728. #ifdef CONFIG_BCMA_DRIVER_MIPS
  1729. struct bcma_pflash pflash;
  1730. +#ifdef CONFIG_BCMA_SFLASH
  1731. + struct bcma_sflash sflash;
  1732. +#endif
  1733. +#ifdef CONFIG_BCMA_NFLASH
  1734. + struct bcma_nflash nflash;
  1735. +#endif
  1736. int nr_serial_ports;
  1737. struct bcma_serial_port serial_ports[4];
  1738. #endif /* CONFIG_BCMA_DRIVER_MIPS */
  1739. + u32 ticks_per_ms;
  1740. + struct platform_device *watchdog;
  1741. +
  1742. + /* Lock for GPIO register access. */
  1743. + spinlock_t gpio_lock;
  1744. +#ifdef CONFIG_BCMA_DRIVER_GPIO
  1745. + struct gpio_chip gpio;
  1746. +#endif
  1747. };
  1748. /* Register access */
  1749. @@ -470,14 +598,16 @@ struct bcma_drv_cc {
  1750. bcma_cc_write32(cc, offset, (bcma_cc_read32(cc, offset) & (mask)) | (set))
  1751. extern void bcma_core_chipcommon_init(struct bcma_drv_cc *cc);
  1752. +extern void bcma_core_chipcommon_early_init(struct bcma_drv_cc *cc);
  1753. extern void bcma_chipco_suspend(struct bcma_drv_cc *cc);
  1754. extern void bcma_chipco_resume(struct bcma_drv_cc *cc);
  1755. void bcma_chipco_bcm4331_ext_pa_lines_ctl(struct bcma_drv_cc *cc, bool enable);
  1756. -extern void bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc,
  1757. - u32 ticks);
  1758. +extern u32 bcma_chipco_watchdog_timer_set(struct bcma_drv_cc *cc, u32 ticks);
  1759. +
  1760. +extern u32 bcma_chipco_get_alp_clock(struct bcma_drv_cc *cc);
  1761. void bcma_chipco_irq_mask(struct bcma_drv_cc *cc, u32 mask, u32 value);
  1762. @@ -490,9 +620,12 @@ u32 bcma_chipco_gpio_outen(struct bcma_d
  1763. u32 bcma_chipco_gpio_control(struct bcma_drv_cc *cc, u32 mask, u32 value);
  1764. u32 bcma_chipco_gpio_intmask(struct bcma_drv_cc *cc, u32 mask, u32 value);
  1765. u32 bcma_chipco_gpio_polarity(struct bcma_drv_cc *cc, u32 mask, u32 value);
  1766. +u32 bcma_chipco_gpio_pullup(struct bcma_drv_cc *cc, u32 mask, u32 value);
  1767. +u32 bcma_chipco_gpio_pulldown(struct bcma_drv_cc *cc, u32 mask, u32 value);
  1768. /* PMU support */
  1769. extern void bcma_pmu_init(struct bcma_drv_cc *cc);
  1770. +extern void bcma_pmu_early_init(struct bcma_drv_cc *cc);
  1771. extern void bcma_chipco_pll_write(struct bcma_drv_cc *cc, u32 offset,
  1772. u32 value);
  1773. --- a/include/linux/bcma/bcma_driver_mips.h
  1774. +++ b/include/linux/bcma/bcma_driver_mips.h
  1775. @@ -35,13 +35,15 @@ struct bcma_device;
  1776. struct bcma_drv_mips {
  1777. struct bcma_device *core;
  1778. u8 setup_done:1;
  1779. - unsigned int assigned_irqs;
  1780. + u8 early_setup_done:1;
  1781. };
  1782. #ifdef CONFIG_BCMA_DRIVER_MIPS
  1783. extern void bcma_core_mips_init(struct bcma_drv_mips *mcore);
  1784. +extern void bcma_core_mips_early_init(struct bcma_drv_mips *mcore);
  1785. #else
  1786. static inline void bcma_core_mips_init(struct bcma_drv_mips *mcore) { }
  1787. +static inline void bcma_core_mips_early_init(struct bcma_drv_mips *mcore) { }
  1788. #endif
  1789. extern u32 bcma_cpu_clock(struct bcma_drv_mips *mcore);
  1790. --- a/include/linux/bcma/bcma_regs.h
  1791. +++ b/include/linux/bcma/bcma_regs.h
  1792. @@ -11,11 +11,13 @@
  1793. #define BCMA_CLKCTLST_HAVEHTREQ 0x00000010 /* HT available request */
  1794. #define BCMA_CLKCTLST_HWCROFF 0x00000020 /* Force HW clock request off */
  1795. #define BCMA_CLKCTLST_EXTRESREQ 0x00000700 /* Mask of external resource requests */
  1796. +#define BCMA_CLKCTLST_EXTRESREQ_SHIFT 8
  1797. #define BCMA_CLKCTLST_HAVEALP 0x00010000 /* ALP available */
  1798. #define BCMA_CLKCTLST_HAVEHT 0x00020000 /* HT available */
  1799. #define BCMA_CLKCTLST_BP_ON_ALP 0x00040000 /* RO: running on ALP clock */
  1800. #define BCMA_CLKCTLST_BP_ON_HT 0x00080000 /* RO: running on HT clock */
  1801. #define BCMA_CLKCTLST_EXTRESST 0x07000000 /* Mask of external resource status */
  1802. +#define BCMA_CLKCTLST_EXTRESST_SHIFT 24
  1803. /* Is there any BCM4328 on BCMA bus? */
  1804. #define BCMA_CLKCTLST_4328A0_HAVEHT 0x00010000 /* 4328a0 has reversed bits */
  1805. #define BCMA_CLKCTLST_4328A0_HAVEALP 0x00020000 /* 4328a0 has reversed bits */
  1806. @@ -83,4 +85,9 @@
  1807. * (2 ZettaBytes), high 32 bits
  1808. */
  1809. +#define BCMA_SOC_FLASH1 0x1fc00000 /* MIPS Flash Region 1 */
  1810. +#define BCMA_SOC_FLASH1_SZ 0x00400000 /* MIPS Size of Flash Region 1 */
  1811. +#define BCMA_SOC_FLASH2 0x1c000000 /* Flash Region 2 (region 1 shadowed here) */
  1812. +#define BCMA_SOC_FLASH2_SZ 0x02000000 /* Size of Flash Region 2 */
  1813. +
  1814. #endif /* LINUX_BCMA_REGS_H_ */
  1815. --- a/drivers/net/wireless/b43/main.c
  1816. +++ b/drivers/net/wireless/b43/main.c
  1817. @@ -4622,7 +4622,7 @@ static int b43_wireless_core_init(struct
  1818. switch (dev->dev->bus_type) {
  1819. #ifdef CONFIG_B43_BCMA
  1820. case B43_BUS_BCMA:
  1821. - bcma_core_pci_irq_ctl(&dev->dev->bdev->bus->drv_pci,
  1822. + bcma_core_pci_irq_ctl(&dev->dev->bdev->bus->drv_pci[0],
  1823. dev->dev->bdev, true);
  1824. break;
  1825. #endif
  1826. --- a/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
  1827. +++ b/drivers/net/wireless/brcm80211/brcmsmac/aiutils.c
  1828. @@ -695,7 +695,7 @@ void ai_pci_up(struct si_pub *sih)
  1829. sii = container_of(sih, struct si_info, pub);
  1830. if (sii->icbus->hosttype == BCMA_HOSTTYPE_PCI)
  1831. - bcma_core_pci_extend_L1timer(&sii->icbus->drv_pci, true);
  1832. + bcma_core_pci_extend_L1timer(&sii->icbus->drv_pci[0], true);
  1833. }
  1834. /* Unconfigure and/or apply various WARs when going down */
  1835. @@ -706,7 +706,7 @@ void ai_pci_down(struct si_pub *sih)
  1836. sii = container_of(sih, struct si_info, pub);
  1837. if (sii->icbus->hosttype == BCMA_HOSTTYPE_PCI)
  1838. - bcma_core_pci_extend_L1timer(&sii->icbus->drv_pci, false);
  1839. + bcma_core_pci_extend_L1timer(&sii->icbus->drv_pci[0], false);
  1840. }
  1841. /* Enable BT-COEX & Ex-PA for 4313 */
  1842. --- a/drivers/net/wireless/brcm80211/brcmsmac/main.c
  1843. +++ b/drivers/net/wireless/brcm80211/brcmsmac/main.c
  1844. @@ -5077,7 +5077,7 @@ static int brcms_b_up_prep(struct brcms_
  1845. * Configure pci/pcmcia here instead of in brcms_c_attach()
  1846. * to allow mfg hotswap: down, hotswap (chip power cycle), up.
  1847. */
  1848. - bcma_core_pci_irq_ctl(&wlc_hw->d11core->bus->drv_pci, wlc_hw->d11core,
  1849. + bcma_core_pci_irq_ctl(&wlc_hw->d11core->bus->drv_pci[0], wlc_hw->d11core,
  1850. true);
  1851. /*