020-ssb_update.patch 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  1. --- a/drivers/ssb/Kconfig
  2. +++ b/drivers/ssb/Kconfig
  3. @@ -138,13 +138,13 @@ config SSB_DRIVER_MIPS
  4. config SSB_SFLASH
  5. bool "SSB serial flash support"
  6. - depends on SSB_DRIVER_MIPS && BROKEN
  7. + depends on SSB_DRIVER_MIPS
  8. default y
  9. # Assumption: We are on embedded, if we compile the MIPS core.
  10. config SSB_EMBEDDED
  11. bool
  12. - depends on SSB_DRIVER_MIPS
  13. + depends on SSB_DRIVER_MIPS && SSB_PCICORE_HOSTMODE
  14. default y
  15. config SSB_DRIVER_EXTIF
  16. @@ -168,6 +168,7 @@ config SSB_DRIVER_GIGE
  17. config SSB_DRIVER_GPIO
  18. bool "SSB GPIO driver"
  19. depends on SSB && GPIOLIB
  20. + select IRQ_DOMAIN if SSB_EMBEDDED
  21. help
  22. Driver to provide access to the GPIO pins on the bus.
  23. --- a/drivers/ssb/driver_chipcommon_sflash.c
  24. +++ b/drivers/ssb/driver_chipcommon_sflash.c
  25. @@ -9,6 +9,19 @@
  26. #include "ssb_private.h"
  27. +static struct resource ssb_sflash_resource = {
  28. + .name = "ssb_sflash",
  29. + .start = SSB_FLASH2,
  30. + .end = 0,
  31. + .flags = IORESOURCE_MEM | IORESOURCE_READONLY,
  32. +};
  33. +
  34. +struct platform_device ssb_sflash_dev = {
  35. + .name = "ssb_sflash",
  36. + .resource = &ssb_sflash_resource,
  37. + .num_resources = 1,
  38. +};
  39. +
  40. struct ssb_sflash_tbl_e {
  41. char *name;
  42. u32 id;
  43. @@ -16,7 +29,7 @@ struct ssb_sflash_tbl_e {
  44. u16 numblocks;
  45. };
  46. -static struct ssb_sflash_tbl_e ssb_sflash_st_tbl[] = {
  47. +static const struct ssb_sflash_tbl_e ssb_sflash_st_tbl[] = {
  48. { "M25P20", 0x11, 0x10000, 4, },
  49. { "M25P40", 0x12, 0x10000, 8, },
  50. @@ -24,10 +37,10 @@ static struct ssb_sflash_tbl_e ssb_sflas
  51. { "M25P32", 0x15, 0x10000, 64, },
  52. { "M25P64", 0x16, 0x10000, 128, },
  53. { "M25FL128", 0x17, 0x10000, 256, },
  54. - { 0 },
  55. + { NULL },
  56. };
  57. -static struct ssb_sflash_tbl_e ssb_sflash_sst_tbl[] = {
  58. +static const struct ssb_sflash_tbl_e ssb_sflash_sst_tbl[] = {
  59. { "SST25WF512", 1, 0x1000, 16, },
  60. { "SST25VF512", 0x48, 0x1000, 16, },
  61. { "SST25WF010", 2, 0x1000, 32, },
  62. @@ -42,10 +55,10 @@ static struct ssb_sflash_tbl_e ssb_sflas
  63. { "SST25VF016", 0x41, 0x1000, 512, },
  64. { "SST25VF032", 0x4a, 0x1000, 1024, },
  65. { "SST25VF064", 0x4b, 0x1000, 2048, },
  66. - { 0 },
  67. + { NULL },
  68. };
  69. -static struct ssb_sflash_tbl_e ssb_sflash_at_tbl[] = {
  70. +static const struct ssb_sflash_tbl_e ssb_sflash_at_tbl[] = {
  71. { "AT45DB011", 0xc, 256, 512, },
  72. { "AT45DB021", 0x14, 256, 1024, },
  73. { "AT45DB041", 0x1c, 256, 2048, },
  74. @@ -53,7 +66,7 @@ static struct ssb_sflash_tbl_e ssb_sflas
  75. { "AT45DB161", 0x2c, 512, 4096, },
  76. { "AT45DB321", 0x34, 512, 8192, },
  77. { "AT45DB642", 0x3c, 1024, 8192, },
  78. - { 0 },
  79. + { NULL },
  80. };
  81. static void ssb_sflash_cmd(struct ssb_chipcommon *cc, u32 opcode)
  82. @@ -73,7 +86,8 @@ static void ssb_sflash_cmd(struct ssb_ch
  83. /* Initialize serial flash access */
  84. int ssb_sflash_init(struct ssb_chipcommon *cc)
  85. {
  86. - struct ssb_sflash_tbl_e *e;
  87. + struct ssb_sflash *sflash = &cc->dev->bus->mipscore.sflash;
  88. + const struct ssb_sflash_tbl_e *e;
  89. u32 id, id2;
  90. switch (cc->capabilities & SSB_CHIPCO_CAP_FLASHT) {
  91. @@ -131,10 +145,20 @@ int ssb_sflash_init(struct ssb_chipcommo
  92. return -ENOTSUPP;
  93. }
  94. - pr_info("Found %s serial flash (blocksize: 0x%X, blocks: %d)\n",
  95. - e->name, e->blocksize, e->numblocks);
  96. -
  97. - pr_err("Serial flash support is not implemented yet!\n");
  98. + sflash->window = SSB_FLASH2;
  99. + sflash->blocksize = e->blocksize;
  100. + sflash->numblocks = e->numblocks;
  101. + sflash->size = sflash->blocksize * sflash->numblocks;
  102. + sflash->present = true;
  103. +
  104. + pr_info("Found %s serial flash (size: %dKiB, blocksize: 0x%X, blocks: %d)\n",
  105. + e->name, sflash->size / 1024, e->blocksize, e->numblocks);
  106. +
  107. + /* Prepare platform device, but don't register it yet. It's too early,
  108. + * malloc (required by device_private_init) is not available yet. */
  109. + ssb_sflash_dev.resource[0].end = ssb_sflash_dev.resource[0].start +
  110. + sflash->size;
  111. + ssb_sflash_dev.dev.platform_data = sflash;
  112. - return -ENOTSUPP;
  113. + return 0;
  114. }
  115. --- a/drivers/ssb/driver_gpio.c
  116. +++ b/drivers/ssb/driver_gpio.c
  117. @@ -9,16 +9,40 @@
  118. */
  119. #include <linux/gpio.h>
  120. +#include <linux/irq.h>
  121. +#include <linux/interrupt.h>
  122. +#include <linux/irqdomain.h>
  123. #include <linux/export.h>
  124. #include <linux/ssb/ssb.h>
  125. #include "ssb_private.h"
  126. +
  127. +/**************************************************
  128. + * Shared
  129. + **************************************************/
  130. +
  131. static struct ssb_bus *ssb_gpio_get_bus(struct gpio_chip *chip)
  132. {
  133. return container_of(chip, struct ssb_bus, gpio);
  134. }
  135. +#if IS_ENABLED(CONFIG_SSB_EMBEDDED)
  136. +static int ssb_gpio_to_irq(struct gpio_chip *chip, unsigned gpio)
  137. +{
  138. + struct ssb_bus *bus = ssb_gpio_get_bus(chip);
  139. +
  140. + if (bus->bustype == SSB_BUSTYPE_SSB)
  141. + return irq_find_mapping(bus->irq_domain, gpio);
  142. + else
  143. + return -EINVAL;
  144. +}
  145. +#endif
  146. +
  147. +/**************************************************
  148. + * ChipCommon
  149. + **************************************************/
  150. +
  151. static int ssb_gpio_chipco_get_value(struct gpio_chip *chip, unsigned gpio)
  152. {
  153. struct ssb_bus *bus = ssb_gpio_get_bus(chip);
  154. @@ -74,19 +98,129 @@ static void ssb_gpio_chipco_free(struct
  155. ssb_chipco_gpio_pullup(&bus->chipco, 1 << gpio, 0);
  156. }
  157. -static int ssb_gpio_chipco_to_irq(struct gpio_chip *chip, unsigned gpio)
  158. +#if IS_ENABLED(CONFIG_SSB_EMBEDDED)
  159. +static void ssb_gpio_irq_chipco_mask(struct irq_data *d)
  160. {
  161. - struct ssb_bus *bus = ssb_gpio_get_bus(chip);
  162. + struct ssb_bus *bus = irq_data_get_irq_chip_data(d);
  163. + int gpio = irqd_to_hwirq(d);
  164. - if (bus->bustype == SSB_BUSTYPE_SSB)
  165. - return ssb_mips_irq(bus->chipco.dev) + 2;
  166. - else
  167. - return -EINVAL;
  168. + ssb_chipco_gpio_intmask(&bus->chipco, BIT(gpio), 0);
  169. +}
  170. +
  171. +static void ssb_gpio_irq_chipco_unmask(struct irq_data *d)
  172. +{
  173. + struct ssb_bus *bus = irq_data_get_irq_chip_data(d);
  174. + int gpio = irqd_to_hwirq(d);
  175. + u32 val = ssb_chipco_gpio_in(&bus->chipco, BIT(gpio));
  176. +
  177. + ssb_chipco_gpio_polarity(&bus->chipco, BIT(gpio), val);
  178. + ssb_chipco_gpio_intmask(&bus->chipco, BIT(gpio), BIT(gpio));
  179. +}
  180. +
  181. +static struct irq_chip ssb_gpio_irq_chipco_chip = {
  182. + .name = "SSB-GPIO-CC",
  183. + .irq_mask = ssb_gpio_irq_chipco_mask,
  184. + .irq_unmask = ssb_gpio_irq_chipco_unmask,
  185. +};
  186. +
  187. +static irqreturn_t ssb_gpio_irq_chipco_handler(int irq, void *dev_id)
  188. +{
  189. + struct ssb_bus *bus = dev_id;
  190. + struct ssb_chipcommon *chipco = &bus->chipco;
  191. + u32 val = chipco_read32(chipco, SSB_CHIPCO_GPIOIN);
  192. + u32 mask = chipco_read32(chipco, SSB_CHIPCO_GPIOIRQ);
  193. + u32 pol = chipco_read32(chipco, SSB_CHIPCO_GPIOPOL);
  194. + unsigned long irqs = (val ^ pol) & mask;
  195. + int gpio;
  196. +
  197. + if (!irqs)
  198. + return IRQ_NONE;
  199. +
  200. + for_each_set_bit(gpio, &irqs, bus->gpio.ngpio)
  201. + generic_handle_irq(ssb_gpio_to_irq(&bus->gpio, gpio));
  202. + ssb_chipco_gpio_polarity(chipco, irqs, val & irqs);
  203. +
  204. + return IRQ_HANDLED;
  205. +}
  206. +
  207. +static int ssb_gpio_irq_chipco_domain_init(struct ssb_bus *bus)
  208. +{
  209. + struct ssb_chipcommon *chipco = &bus->chipco;
  210. + struct gpio_chip *chip = &bus->gpio;
  211. + int gpio, hwirq, err;
  212. +
  213. + if (bus->bustype != SSB_BUSTYPE_SSB)
  214. + return 0;
  215. +
  216. + bus->irq_domain = irq_domain_add_linear(NULL, chip->ngpio,
  217. + &irq_domain_simple_ops, chipco);
  218. + if (!bus->irq_domain) {
  219. + err = -ENODEV;
  220. + goto err_irq_domain;
  221. + }
  222. + for (gpio = 0; gpio < chip->ngpio; gpio++) {
  223. + int irq = irq_create_mapping(bus->irq_domain, gpio);
  224. +
  225. + irq_set_chip_data(irq, bus);
  226. + irq_set_chip_and_handler(irq, &ssb_gpio_irq_chipco_chip,
  227. + handle_simple_irq);
  228. + }
  229. +
  230. + hwirq = ssb_mips_irq(bus->chipco.dev) + 2;
  231. + err = request_irq(hwirq, ssb_gpio_irq_chipco_handler, IRQF_SHARED,
  232. + "gpio", bus);
  233. + if (err)
  234. + goto err_req_irq;
  235. +
  236. + ssb_chipco_gpio_intmask(&bus->chipco, ~0, 0);
  237. + chipco_set32(chipco, SSB_CHIPCO_IRQMASK, SSB_CHIPCO_IRQ_GPIO);
  238. +
  239. + return 0;
  240. +
  241. +err_req_irq:
  242. + for (gpio = 0; gpio < chip->ngpio; gpio++) {
  243. + int irq = irq_find_mapping(bus->irq_domain, gpio);
  244. +
  245. + irq_dispose_mapping(irq);
  246. + }
  247. + irq_domain_remove(bus->irq_domain);
  248. +err_irq_domain:
  249. + return err;
  250. +}
  251. +
  252. +static void ssb_gpio_irq_chipco_domain_exit(struct ssb_bus *bus)
  253. +{
  254. + struct ssb_chipcommon *chipco = &bus->chipco;
  255. + struct gpio_chip *chip = &bus->gpio;
  256. + int gpio;
  257. +
  258. + if (bus->bustype != SSB_BUSTYPE_SSB)
  259. + return;
  260. +
  261. + chipco_mask32(chipco, SSB_CHIPCO_IRQMASK, ~SSB_CHIPCO_IRQ_GPIO);
  262. + free_irq(ssb_mips_irq(bus->chipco.dev) + 2, chipco);
  263. + for (gpio = 0; gpio < chip->ngpio; gpio++) {
  264. + int irq = irq_find_mapping(bus->irq_domain, gpio);
  265. +
  266. + irq_dispose_mapping(irq);
  267. + }
  268. + irq_domain_remove(bus->irq_domain);
  269. +}
  270. +#else
  271. +static int ssb_gpio_irq_chipco_domain_init(struct ssb_bus *bus)
  272. +{
  273. + return 0;
  274. +}
  275. +
  276. +static void ssb_gpio_irq_chipco_domain_exit(struct ssb_bus *bus)
  277. +{
  278. }
  279. +#endif
  280. static int ssb_gpio_chipco_init(struct ssb_bus *bus)
  281. {
  282. struct gpio_chip *chip = &bus->gpio;
  283. + int err;
  284. chip->label = "ssb_chipco_gpio";
  285. chip->owner = THIS_MODULE;
  286. @@ -96,7 +230,9 @@ static int ssb_gpio_chipco_init(struct s
  287. chip->set = ssb_gpio_chipco_set_value;
  288. chip->direction_input = ssb_gpio_chipco_direction_input;
  289. chip->direction_output = ssb_gpio_chipco_direction_output;
  290. - chip->to_irq = ssb_gpio_chipco_to_irq;
  291. +#if IS_ENABLED(CONFIG_SSB_EMBEDDED)
  292. + chip->to_irq = ssb_gpio_to_irq;
  293. +#endif
  294. chip->ngpio = 16;
  295. /* There is just one SoC in one device and its GPIO addresses should be
  296. * deterministic to address them more easily. The other buses could get
  297. @@ -106,9 +242,23 @@ static int ssb_gpio_chipco_init(struct s
  298. else
  299. chip->base = -1;
  300. - return gpiochip_add(chip);
  301. + err = ssb_gpio_irq_chipco_domain_init(bus);
  302. + if (err)
  303. + return err;
  304. +
  305. + err = gpiochip_add(chip);
  306. + if (err) {
  307. + ssb_gpio_irq_chipco_domain_exit(bus);
  308. + return err;
  309. + }
  310. +
  311. + return 0;
  312. }
  313. +/**************************************************
  314. + * EXTIF
  315. + **************************************************/
  316. +
  317. #ifdef CONFIG_SSB_DRIVER_EXTIF
  318. static int ssb_gpio_extif_get_value(struct gpio_chip *chip, unsigned gpio)
  319. @@ -145,19 +295,127 @@ static int ssb_gpio_extif_direction_outp
  320. return 0;
  321. }
  322. -static int ssb_gpio_extif_to_irq(struct gpio_chip *chip, unsigned gpio)
  323. +#if IS_ENABLED(CONFIG_SSB_EMBEDDED)
  324. +static void ssb_gpio_irq_extif_mask(struct irq_data *d)
  325. {
  326. - struct ssb_bus *bus = ssb_gpio_get_bus(chip);
  327. + struct ssb_bus *bus = irq_data_get_irq_chip_data(d);
  328. + int gpio = irqd_to_hwirq(d);
  329. - if (bus->bustype == SSB_BUSTYPE_SSB)
  330. - return ssb_mips_irq(bus->extif.dev) + 2;
  331. - else
  332. - return -EINVAL;
  333. + ssb_extif_gpio_intmask(&bus->extif, BIT(gpio), 0);
  334. +}
  335. +
  336. +static void ssb_gpio_irq_extif_unmask(struct irq_data *d)
  337. +{
  338. + struct ssb_bus *bus = irq_data_get_irq_chip_data(d);
  339. + int gpio = irqd_to_hwirq(d);
  340. + u32 val = ssb_extif_gpio_in(&bus->extif, BIT(gpio));
  341. +
  342. + ssb_extif_gpio_polarity(&bus->extif, BIT(gpio), val);
  343. + ssb_extif_gpio_intmask(&bus->extif, BIT(gpio), BIT(gpio));
  344. +}
  345. +
  346. +static struct irq_chip ssb_gpio_irq_extif_chip = {
  347. + .name = "SSB-GPIO-EXTIF",
  348. + .irq_mask = ssb_gpio_irq_extif_mask,
  349. + .irq_unmask = ssb_gpio_irq_extif_unmask,
  350. +};
  351. +
  352. +static irqreturn_t ssb_gpio_irq_extif_handler(int irq, void *dev_id)
  353. +{
  354. + struct ssb_bus *bus = dev_id;
  355. + struct ssb_extif *extif = &bus->extif;
  356. + u32 val = ssb_read32(extif->dev, SSB_EXTIF_GPIO_IN);
  357. + u32 mask = ssb_read32(extif->dev, SSB_EXTIF_GPIO_INTMASK);
  358. + u32 pol = ssb_read32(extif->dev, SSB_EXTIF_GPIO_INTPOL);
  359. + unsigned long irqs = (val ^ pol) & mask;
  360. + int gpio;
  361. +
  362. + if (!irqs)
  363. + return IRQ_NONE;
  364. +
  365. + for_each_set_bit(gpio, &irqs, bus->gpio.ngpio)
  366. + generic_handle_irq(ssb_gpio_to_irq(&bus->gpio, gpio));
  367. + ssb_extif_gpio_polarity(extif, irqs, val & irqs);
  368. +
  369. + return IRQ_HANDLED;
  370. +}
  371. +
  372. +static int ssb_gpio_irq_extif_domain_init(struct ssb_bus *bus)
  373. +{
  374. + struct ssb_extif *extif = &bus->extif;
  375. + struct gpio_chip *chip = &bus->gpio;
  376. + int gpio, hwirq, err;
  377. +
  378. + if (bus->bustype != SSB_BUSTYPE_SSB)
  379. + return 0;
  380. +
  381. + bus->irq_domain = irq_domain_add_linear(NULL, chip->ngpio,
  382. + &irq_domain_simple_ops, extif);
  383. + if (!bus->irq_domain) {
  384. + err = -ENODEV;
  385. + goto err_irq_domain;
  386. + }
  387. + for (gpio = 0; gpio < chip->ngpio; gpio++) {
  388. + int irq = irq_create_mapping(bus->irq_domain, gpio);
  389. +
  390. + irq_set_chip_data(irq, bus);
  391. + irq_set_chip_and_handler(irq, &ssb_gpio_irq_extif_chip,
  392. + handle_simple_irq);
  393. + }
  394. +
  395. + hwirq = ssb_mips_irq(bus->extif.dev) + 2;
  396. + err = request_irq(hwirq, ssb_gpio_irq_extif_handler, IRQF_SHARED,
  397. + "gpio", bus);
  398. + if (err)
  399. + goto err_req_irq;
  400. +
  401. + ssb_extif_gpio_intmask(&bus->extif, ~0, 0);
  402. +
  403. + return 0;
  404. +
  405. +err_req_irq:
  406. + for (gpio = 0; gpio < chip->ngpio; gpio++) {
  407. + int irq = irq_find_mapping(bus->irq_domain, gpio);
  408. +
  409. + irq_dispose_mapping(irq);
  410. + }
  411. + irq_domain_remove(bus->irq_domain);
  412. +err_irq_domain:
  413. + return err;
  414. }
  415. +static void ssb_gpio_irq_extif_domain_exit(struct ssb_bus *bus)
  416. +{
  417. + struct ssb_extif *extif = &bus->extif;
  418. + struct gpio_chip *chip = &bus->gpio;
  419. + int gpio;
  420. +
  421. + if (bus->bustype != SSB_BUSTYPE_SSB)
  422. + return;
  423. +
  424. + free_irq(ssb_mips_irq(bus->extif.dev) + 2, extif);
  425. + for (gpio = 0; gpio < chip->ngpio; gpio++) {
  426. + int irq = irq_find_mapping(bus->irq_domain, gpio);
  427. +
  428. + irq_dispose_mapping(irq);
  429. + }
  430. + irq_domain_remove(bus->irq_domain);
  431. +}
  432. +#else
  433. +static int ssb_gpio_irq_extif_domain_init(struct ssb_bus *bus)
  434. +{
  435. + return 0;
  436. +}
  437. +
  438. +static void ssb_gpio_irq_extif_domain_exit(struct ssb_bus *bus)
  439. +{
  440. +}
  441. +#endif
  442. +
  443. static int ssb_gpio_extif_init(struct ssb_bus *bus)
  444. {
  445. struct gpio_chip *chip = &bus->gpio;
  446. + int err;
  447. chip->label = "ssb_extif_gpio";
  448. chip->owner = THIS_MODULE;
  449. @@ -165,7 +423,9 @@ static int ssb_gpio_extif_init(struct ss
  450. chip->set = ssb_gpio_extif_set_value;
  451. chip->direction_input = ssb_gpio_extif_direction_input;
  452. chip->direction_output = ssb_gpio_extif_direction_output;
  453. - chip->to_irq = ssb_gpio_extif_to_irq;
  454. +#if IS_ENABLED(CONFIG_SSB_EMBEDDED)
  455. + chip->to_irq = ssb_gpio_to_irq;
  456. +#endif
  457. chip->ngpio = 5;
  458. /* There is just one SoC in one device and its GPIO addresses should be
  459. * deterministic to address them more easily. The other buses could get
  460. @@ -175,7 +435,17 @@ static int ssb_gpio_extif_init(struct ss
  461. else
  462. chip->base = -1;
  463. - return gpiochip_add(chip);
  464. + err = ssb_gpio_irq_extif_domain_init(bus);
  465. + if (err)
  466. + return err;
  467. +
  468. + err = gpiochip_add(chip);
  469. + if (err) {
  470. + ssb_gpio_irq_extif_domain_exit(bus);
  471. + return err;
  472. + }
  473. +
  474. + return 0;
  475. }
  476. #else
  477. @@ -185,6 +455,10 @@ static int ssb_gpio_extif_init(struct ss
  478. }
  479. #endif
  480. +/**************************************************
  481. + * Init
  482. + **************************************************/
  483. +
  484. int ssb_gpio_init(struct ssb_bus *bus)
  485. {
  486. if (ssb_chipco_available(&bus->chipco))
  487. --- a/drivers/ssb/main.c
  488. +++ b/drivers/ssb/main.c
  489. @@ -553,6 +553,14 @@ static int ssb_devices_register(struct s
  490. }
  491. #endif
  492. +#ifdef CONFIG_SSB_SFLASH
  493. + if (bus->mipscore.sflash.present) {
  494. + err = platform_device_register(&ssb_sflash_dev);
  495. + if (err)
  496. + pr_err("Error registering serial flash\n");
  497. + }
  498. +#endif
  499. +
  500. return 0;
  501. error:
  502. /* Unwind the already registered devices. */
  503. @@ -582,6 +590,13 @@ static int ssb_attach_queued_buses(void)
  504. ssb_pcicore_init(&bus->pcicore);
  505. if (bus->bustype == SSB_BUSTYPE_SSB)
  506. ssb_watchdog_register(bus);
  507. +
  508. + err = ssb_gpio_init(bus);
  509. + if (err == -ENOTSUPP)
  510. + ssb_dbg("GPIO driver not activated\n");
  511. + else if (err)
  512. + ssb_dbg("Error registering GPIO driver: %i\n", err);
  513. +
  514. ssb_bus_may_powerdown(bus);
  515. err = ssb_devices_register(bus);
  516. @@ -819,11 +834,6 @@ static int ssb_bus_register(struct ssb_b
  517. ssb_chipcommon_init(&bus->chipco);
  518. ssb_extif_init(&bus->extif);
  519. ssb_mipscore_init(&bus->mipscore);
  520. - err = ssb_gpio_init(bus);
  521. - if (err == -ENOTSUPP)
  522. - ssb_dbg("GPIO driver not activated\n");
  523. - else if (err)
  524. - ssb_dbg("Error registering GPIO driver: %i\n", err);
  525. err = ssb_fetch_invariants(bus, get_invariants);
  526. if (err) {
  527. ssb_bus_may_powerdown(bus);
  528. --- a/drivers/ssb/pcihost_wrapper.c
  529. +++ b/drivers/ssb/pcihost_wrapper.c
  530. @@ -38,7 +38,7 @@ static int ssb_pcihost_resume(struct pci
  531. struct ssb_bus *ssb = pci_get_drvdata(dev);
  532. int err;
  533. - pci_set_power_state(dev, 0);
  534. + pci_set_power_state(dev, PCI_D0);
  535. err = pci_enable_device(dev);
  536. if (err)
  537. return err;
  538. --- a/drivers/ssb/sprom.c
  539. +++ b/drivers/ssb/sprom.c
  540. @@ -54,7 +54,7 @@ static int hex2sprom(u16 *sprom, const c
  541. while (cnt < sprom_size_words) {
  542. memcpy(tmp, dump, 4);
  543. dump += 4;
  544. - err = strict_strtoul(tmp, 16, &parsed);
  545. + err = kstrtoul(tmp, 16, &parsed);
  546. if (err)
  547. return err;
  548. sprom[cnt++] = swab16((u16)parsed);
  549. --- a/drivers/ssb/ssb_private.h
  550. +++ b/drivers/ssb/ssb_private.h
  551. @@ -243,6 +243,10 @@ static inline int ssb_sflash_init(struct
  552. extern struct platform_device ssb_pflash_dev;
  553. #endif
  554. +#ifdef CONFIG_SSB_SFLASH
  555. +extern struct platform_device ssb_sflash_dev;
  556. +#endif
  557. +
  558. #ifdef CONFIG_SSB_DRIVER_EXTIF
  559. extern u32 ssb_extif_watchdog_timer_set_wdt(struct bcm47xx_wdt *wdt, u32 ticks);
  560. extern u32 ssb_extif_watchdog_timer_set_ms(struct bcm47xx_wdt *wdt, u32 ms);
  561. --- a/include/linux/ssb/ssb.h
  562. +++ b/include/linux/ssb/ssb.h
  563. @@ -486,6 +486,7 @@ struct ssb_bus {
  564. #endif /* EMBEDDED */
  565. #ifdef CONFIG_SSB_DRIVER_GPIO
  566. struct gpio_chip gpio;
  567. + struct irq_domain *irq_domain;
  568. #endif /* DRIVER_GPIO */
  569. /* Internal-only stuff follows. Do not touch. */
  570. --- a/include/linux/ssb/ssb_driver_gige.h
  571. +++ b/include/linux/ssb/ssb_driver_gige.h
  572. @@ -108,6 +108,16 @@ static inline int ssb_gige_get_macaddr(s
  573. return 0;
  574. }
  575. +/* Get the device phy address */
  576. +static inline int ssb_gige_get_phyaddr(struct pci_dev *pdev)
  577. +{
  578. + struct ssb_gige *dev = pdev_to_ssb_gige(pdev);
  579. + if (!dev)
  580. + return -ENODEV;
  581. +
  582. + return dev->dev->bus->sprom.et0phyaddr;
  583. +}
  584. +
  585. extern int ssb_gige_pcibios_plat_dev_init(struct ssb_device *sdev,
  586. struct pci_dev *pdev);
  587. extern int ssb_gige_map_irq(struct ssb_device *sdev,
  588. @@ -174,6 +184,10 @@ static inline int ssb_gige_get_macaddr(s
  589. {
  590. return -ENODEV;
  591. }
  592. +static inline int ssb_gige_get_phyaddr(struct pci_dev *pdev)
  593. +{
  594. + return -ENODEV;
  595. +}
  596. #endif /* CONFIG_SSB_DRIVER_GIGE */
  597. #endif /* LINUX_SSB_DRIVER_GIGE_H_ */
  598. --- a/include/linux/ssb/ssb_driver_mips.h
  599. +++ b/include/linux/ssb/ssb_driver_mips.h
  600. @@ -20,6 +20,18 @@ struct ssb_pflash {
  601. u32 window_size;
  602. };
  603. +#ifdef CONFIG_SSB_SFLASH
  604. +struct ssb_sflash {
  605. + bool present;
  606. + u32 window;
  607. + u32 blocksize;
  608. + u16 numblocks;
  609. + u32 size;
  610. +
  611. + void *priv;
  612. +};
  613. +#endif
  614. +
  615. struct ssb_mipscore {
  616. struct ssb_device *dev;
  617. @@ -27,6 +39,9 @@ struct ssb_mipscore {
  618. struct ssb_serial_port serial_ports[4];
  619. struct ssb_pflash pflash;
  620. +#ifdef CONFIG_SSB_SFLASH
  621. + struct ssb_sflash sflash;
  622. +#endif
  623. };
  624. extern void ssb_mipscore_init(struct ssb_mipscore *mcore);
  625. --- a/include/linux/ssb/ssb_regs.h
  626. +++ b/include/linux/ssb/ssb_regs.h
  627. @@ -172,6 +172,7 @@
  628. #define SSB_SPROMSIZE_WORDS_R4 220
  629. #define SSB_SPROMSIZE_BYTES_R123 (SSB_SPROMSIZE_WORDS_R123 * sizeof(u16))
  630. #define SSB_SPROMSIZE_BYTES_R4 (SSB_SPROMSIZE_WORDS_R4 * sizeof(u16))
  631. +#define SSB_SPROMSIZE_WORDS_R10 230
  632. #define SSB_SPROM_BASE1 0x1000
  633. #define SSB_SPROM_BASE31 0x0800
  634. #define SSB_SPROM_REVISION 0x007E