ssb.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef LINUX_SSB_H_
  3. #define LINUX_SSB_H_
  4. #include <linux/device.h>
  5. #include <linux/list.h>
  6. #include <linux/types.h>
  7. #include <linux/spinlock.h>
  8. #include <linux/pci.h>
  9. #include <linux/gpio/driver.h>
  10. #include <linux/mod_devicetable.h>
  11. #include <linux/dma-mapping.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/ssb/ssb_regs.h>
  14. struct pcmcia_device;
  15. struct ssb_bus;
  16. struct ssb_driver;
  17. struct ssb_sprom_core_pwr_info {
  18. u8 itssi_2g, itssi_5g;
  19. u8 maxpwr_2g, maxpwr_5gl, maxpwr_5g, maxpwr_5gh;
  20. u16 pa_2g[4], pa_5gl[4], pa_5g[4], pa_5gh[4];
  21. };
  22. struct ssb_sprom {
  23. u8 revision;
  24. u8 il0mac[6] __aligned(sizeof(u16)); /* MAC address for 802.11b/g */
  25. u8 et0mac[6] __aligned(sizeof(u16)); /* MAC address for Ethernet */
  26. u8 et1mac[6] __aligned(sizeof(u16)); /* MAC address for 802.11a */
  27. u8 et2mac[6] __aligned(sizeof(u16)); /* MAC address for extra Ethernet */
  28. u8 et0phyaddr; /* MII address for enet0 */
  29. u8 et1phyaddr; /* MII address for enet1 */
  30. u8 et2phyaddr; /* MII address for enet2 */
  31. u8 et0mdcport; /* MDIO for enet0 */
  32. u8 et1mdcport; /* MDIO for enet1 */
  33. u8 et2mdcport; /* MDIO for enet2 */
  34. u16 dev_id; /* Device ID overriding e.g. PCI ID */
  35. u16 board_rev; /* Board revision number from SPROM. */
  36. u16 board_num; /* Board number from SPROM. */
  37. u16 board_type; /* Board type from SPROM. */
  38. u8 country_code; /* Country Code */
  39. char alpha2[2]; /* Country Code as two chars like EU or US */
  40. u8 leddc_on_time; /* LED Powersave Duty Cycle On Count */
  41. u8 leddc_off_time; /* LED Powersave Duty Cycle Off Count */
  42. u8 ant_available_a; /* 2GHz antenna available bits (up to 4) */
  43. u8 ant_available_bg; /* 5GHz antenna available bits (up to 4) */
  44. u16 pa0b0;
  45. u16 pa0b1;
  46. u16 pa0b2;
  47. u16 pa1b0;
  48. u16 pa1b1;
  49. u16 pa1b2;
  50. u16 pa1lob0;
  51. u16 pa1lob1;
  52. u16 pa1lob2;
  53. u16 pa1hib0;
  54. u16 pa1hib1;
  55. u16 pa1hib2;
  56. u8 gpio0; /* GPIO pin 0 */
  57. u8 gpio1; /* GPIO pin 1 */
  58. u8 gpio2; /* GPIO pin 2 */
  59. u8 gpio3; /* GPIO pin 3 */
  60. u8 maxpwr_bg; /* 2.4GHz Amplifier Max Power (in dBm Q5.2) */
  61. u8 maxpwr_al; /* 5.2GHz Amplifier Max Power (in dBm Q5.2) */
  62. u8 maxpwr_a; /* 5.3GHz Amplifier Max Power (in dBm Q5.2) */
  63. u8 maxpwr_ah; /* 5.8GHz Amplifier Max Power (in dBm Q5.2) */
  64. u8 itssi_a; /* Idle TSSI Target for A-PHY */
  65. u8 itssi_bg; /* Idle TSSI Target for B/G-PHY */
  66. u8 tri2g; /* 2.4GHz TX isolation */
  67. u8 tri5gl; /* 5.2GHz TX isolation */
  68. u8 tri5g; /* 5.3GHz TX isolation */
  69. u8 tri5gh; /* 5.8GHz TX isolation */
  70. u8 txpid2g[4]; /* 2GHz TX power index */
  71. u8 txpid5gl[4]; /* 4.9 - 5.1GHz TX power index */
  72. u8 txpid5g[4]; /* 5.1 - 5.5GHz TX power index */
  73. u8 txpid5gh[4]; /* 5.5 - ...GHz TX power index */
  74. s8 rxpo2g; /* 2GHz RX power offset */
  75. s8 rxpo5g; /* 5GHz RX power offset */
  76. u8 rssisav2g; /* 2GHz RSSI params */
  77. u8 rssismc2g;
  78. u8 rssismf2g;
  79. u8 bxa2g; /* 2GHz BX arch */
  80. u8 rssisav5g; /* 5GHz RSSI params */
  81. u8 rssismc5g;
  82. u8 rssismf5g;
  83. u8 bxa5g; /* 5GHz BX arch */
  84. u16 cck2gpo; /* CCK power offset */
  85. u32 ofdm2gpo; /* 2.4GHz OFDM power offset */
  86. u32 ofdm5glpo; /* 5.2GHz OFDM power offset */
  87. u32 ofdm5gpo; /* 5.3GHz OFDM power offset */
  88. u32 ofdm5ghpo; /* 5.8GHz OFDM power offset */
  89. u32 boardflags;
  90. u32 boardflags2;
  91. u32 boardflags3;
  92. /* TODO: Switch all drivers to new u32 fields and drop below ones */
  93. u16 boardflags_lo; /* Board flags (bits 0-15) */
  94. u16 boardflags_hi; /* Board flags (bits 16-31) */
  95. u16 boardflags2_lo; /* Board flags (bits 32-47) */
  96. u16 boardflags2_hi; /* Board flags (bits 48-63) */
  97. struct ssb_sprom_core_pwr_info core_pwr_info[4];
  98. /* Antenna gain values for up to 4 antennas
  99. * on each band. Values in dBm/4 (Q5.2). Negative gain means the
  100. * loss in the connectors is bigger than the gain. */
  101. struct {
  102. s8 a0, a1, a2, a3;
  103. } antenna_gain;
  104. struct {
  105. struct {
  106. u8 tssipos, extpa_gain, pdet_range, tr_iso, antswlut;
  107. } ghz2;
  108. struct {
  109. u8 tssipos, extpa_gain, pdet_range, tr_iso, antswlut;
  110. } ghz5;
  111. } fem;
  112. u16 mcs2gpo[8];
  113. u16 mcs5gpo[8];
  114. u16 mcs5glpo[8];
  115. u16 mcs5ghpo[8];
  116. u8 opo;
  117. u8 rxgainerr2ga[3];
  118. u8 rxgainerr5gla[3];
  119. u8 rxgainerr5gma[3];
  120. u8 rxgainerr5gha[3];
  121. u8 rxgainerr5gua[3];
  122. u8 noiselvl2ga[3];
  123. u8 noiselvl5gla[3];
  124. u8 noiselvl5gma[3];
  125. u8 noiselvl5gha[3];
  126. u8 noiselvl5gua[3];
  127. u8 regrev;
  128. u8 txchain;
  129. u8 rxchain;
  130. u8 antswitch;
  131. u16 cddpo;
  132. u16 stbcpo;
  133. u16 bw40po;
  134. u16 bwduppo;
  135. u8 tempthresh;
  136. u8 tempoffset;
  137. u16 rawtempsense;
  138. u8 measpower;
  139. u8 tempsense_slope;
  140. u8 tempcorrx;
  141. u8 tempsense_option;
  142. u8 freqoffset_corr;
  143. u8 iqcal_swp_dis;
  144. u8 hw_iqcal_en;
  145. u8 elna2g;
  146. u8 elna5g;
  147. u8 phycal_tempdelta;
  148. u8 temps_period;
  149. u8 temps_hysteresis;
  150. u8 measpower1;
  151. u8 measpower2;
  152. u8 pcieingress_war;
  153. /* power per rate from sromrev 9 */
  154. u16 cckbw202gpo;
  155. u16 cckbw20ul2gpo;
  156. u32 legofdmbw202gpo;
  157. u32 legofdmbw20ul2gpo;
  158. u32 legofdmbw205glpo;
  159. u32 legofdmbw20ul5glpo;
  160. u32 legofdmbw205gmpo;
  161. u32 legofdmbw20ul5gmpo;
  162. u32 legofdmbw205ghpo;
  163. u32 legofdmbw20ul5ghpo;
  164. u32 mcsbw202gpo;
  165. u32 mcsbw20ul2gpo;
  166. u32 mcsbw402gpo;
  167. u32 mcsbw205glpo;
  168. u32 mcsbw20ul5glpo;
  169. u32 mcsbw405glpo;
  170. u32 mcsbw205gmpo;
  171. u32 mcsbw20ul5gmpo;
  172. u32 mcsbw405gmpo;
  173. u32 mcsbw205ghpo;
  174. u32 mcsbw20ul5ghpo;
  175. u32 mcsbw405ghpo;
  176. u16 mcs32po;
  177. u16 legofdm40duppo;
  178. u8 sar2g;
  179. u8 sar5g;
  180. };
  181. /* Information about the PCB the circuitry is soldered on. */
  182. struct ssb_boardinfo {
  183. u16 vendor;
  184. u16 type;
  185. };
  186. struct ssb_device;
  187. /* Lowlevel read/write operations on the device MMIO.
  188. * Internal, don't use that outside of ssb. */
  189. struct ssb_bus_ops {
  190. u8 (*read8)(struct ssb_device *dev, u16 offset);
  191. u16 (*read16)(struct ssb_device *dev, u16 offset);
  192. u32 (*read32)(struct ssb_device *dev, u16 offset);
  193. void (*write8)(struct ssb_device *dev, u16 offset, u8 value);
  194. void (*write16)(struct ssb_device *dev, u16 offset, u16 value);
  195. void (*write32)(struct ssb_device *dev, u16 offset, u32 value);
  196. #ifdef CONFIG_SSB_BLOCKIO
  197. void (*block_read)(struct ssb_device *dev, void *buffer,
  198. size_t count, u16 offset, u8 reg_width);
  199. void (*block_write)(struct ssb_device *dev, const void *buffer,
  200. size_t count, u16 offset, u8 reg_width);
  201. #endif
  202. };
  203. /* Core-ID values. */
  204. #define SSB_DEV_CHIPCOMMON 0x800
  205. #define SSB_DEV_ILINE20 0x801
  206. #define SSB_DEV_SDRAM 0x803
  207. #define SSB_DEV_PCI 0x804
  208. #define SSB_DEV_MIPS 0x805
  209. #define SSB_DEV_ETHERNET 0x806
  210. #define SSB_DEV_V90 0x807
  211. #define SSB_DEV_USB11_HOSTDEV 0x808
  212. #define SSB_DEV_ADSL 0x809
  213. #define SSB_DEV_ILINE100 0x80A
  214. #define SSB_DEV_IPSEC 0x80B
  215. #define SSB_DEV_PCMCIA 0x80D
  216. #define SSB_DEV_INTERNAL_MEM 0x80E
  217. #define SSB_DEV_MEMC_SDRAM 0x80F
  218. #define SSB_DEV_EXTIF 0x811
  219. #define SSB_DEV_80211 0x812
  220. #define SSB_DEV_MIPS_3302 0x816
  221. #define SSB_DEV_USB11_HOST 0x817
  222. #define SSB_DEV_USB11_DEV 0x818
  223. #define SSB_DEV_USB20_HOST 0x819
  224. #define SSB_DEV_USB20_DEV 0x81A
  225. #define SSB_DEV_SDIO_HOST 0x81B
  226. #define SSB_DEV_ROBOSWITCH 0x81C
  227. #define SSB_DEV_PARA_ATA 0x81D
  228. #define SSB_DEV_SATA_XORDMA 0x81E
  229. #define SSB_DEV_ETHERNET_GBIT 0x81F
  230. #define SSB_DEV_PCIE 0x820
  231. #define SSB_DEV_MIMO_PHY 0x821
  232. #define SSB_DEV_SRAM_CTRLR 0x822
  233. #define SSB_DEV_MINI_MACPHY 0x823
  234. #define SSB_DEV_ARM_1176 0x824
  235. #define SSB_DEV_ARM_7TDMI 0x825
  236. #define SSB_DEV_ARM_CM3 0x82A
  237. /* Vendor-ID values */
  238. #define SSB_VENDOR_BROADCOM 0x4243
  239. /* Some kernel subsystems poke with dev->drvdata, so we must use the
  240. * following ugly workaround to get from struct device to struct ssb_device */
  241. struct __ssb_dev_wrapper {
  242. struct device dev;
  243. struct ssb_device *sdev;
  244. };
  245. struct ssb_device {
  246. /* Having a copy of the ops pointer in each dev struct
  247. * is an optimization. */
  248. const struct ssb_bus_ops *ops;
  249. struct device *dev, *dma_dev;
  250. struct ssb_bus *bus;
  251. struct ssb_device_id id;
  252. u8 core_index;
  253. unsigned int irq;
  254. /* Internal-only stuff follows. */
  255. void *drvdata; /* Per-device data */
  256. void *devtypedata; /* Per-devicetype (eg 802.11) data */
  257. };
  258. /* Go from struct device to struct ssb_device. */
  259. static inline
  260. struct ssb_device * dev_to_ssb_dev(struct device *dev)
  261. {
  262. struct __ssb_dev_wrapper *wrap;
  263. wrap = container_of(dev, struct __ssb_dev_wrapper, dev);
  264. return wrap->sdev;
  265. }
  266. /* Device specific user data */
  267. static inline
  268. void ssb_set_drvdata(struct ssb_device *dev, void *data)
  269. {
  270. dev->drvdata = data;
  271. }
  272. static inline
  273. void * ssb_get_drvdata(struct ssb_device *dev)
  274. {
  275. return dev->drvdata;
  276. }
  277. /* Devicetype specific user data. This is per device-type (not per device) */
  278. void ssb_set_devtypedata(struct ssb_device *dev, void *data);
  279. static inline
  280. void * ssb_get_devtypedata(struct ssb_device *dev)
  281. {
  282. return dev->devtypedata;
  283. }
  284. struct ssb_driver {
  285. const char *name;
  286. const struct ssb_device_id *id_table;
  287. int (*probe)(struct ssb_device *dev, const struct ssb_device_id *id);
  288. void (*remove)(struct ssb_device *dev);
  289. int (*suspend)(struct ssb_device *dev, pm_message_t state);
  290. int (*resume)(struct ssb_device *dev);
  291. void (*shutdown)(struct ssb_device *dev);
  292. struct device_driver drv;
  293. };
  294. #define drv_to_ssb_drv(_drv) container_of(_drv, struct ssb_driver, drv)
  295. extern int __ssb_driver_register(struct ssb_driver *drv, struct module *owner);
  296. #define ssb_driver_register(drv) \
  297. __ssb_driver_register(drv, THIS_MODULE)
  298. extern void ssb_driver_unregister(struct ssb_driver *drv);
  299. enum ssb_bustype {
  300. SSB_BUSTYPE_SSB, /* This SSB bus is the system bus */
  301. SSB_BUSTYPE_PCI, /* SSB is connected to PCI bus */
  302. SSB_BUSTYPE_PCMCIA, /* SSB is connected to PCMCIA bus */
  303. SSB_BUSTYPE_SDIO, /* SSB is connected to SDIO bus */
  304. };
  305. /* board_vendor */
  306. #define SSB_BOARDVENDOR_BCM 0x14E4 /* Broadcom */
  307. #define SSB_BOARDVENDOR_DELL 0x1028 /* Dell */
  308. #define SSB_BOARDVENDOR_HP 0x0E11 /* HP */
  309. /* board_type */
  310. #define SSB_BOARD_BCM94301CB 0x0406
  311. #define SSB_BOARD_BCM94301MP 0x0407
  312. #define SSB_BOARD_BU4309 0x040A
  313. #define SSB_BOARD_BCM94309CB 0x040B
  314. #define SSB_BOARD_BCM4309MP 0x040C
  315. #define SSB_BOARD_BU4306 0x0416
  316. #define SSB_BOARD_BCM94306MP 0x0418
  317. #define SSB_BOARD_BCM4309G 0x0421
  318. #define SSB_BOARD_BCM4306CB 0x0417
  319. #define SSB_BOARD_BCM94306PC 0x0425 /* pcmcia 3.3v 4306 card */
  320. #define SSB_BOARD_BCM94306CBSG 0x042B /* with SiGe PA */
  321. #define SSB_BOARD_PCSG94306 0x042D /* with SiGe PA */
  322. #define SSB_BOARD_BU4704SD 0x042E /* with sdram */
  323. #define SSB_BOARD_BCM94704AGR 0x042F /* dual 11a/11g Router */
  324. #define SSB_BOARD_BCM94308MP 0x0430 /* 11a-only minipci */
  325. #define SSB_BOARD_BU4318 0x0447
  326. #define SSB_BOARD_CB4318 0x0448
  327. #define SSB_BOARD_MPG4318 0x0449
  328. #define SSB_BOARD_MP4318 0x044A
  329. #define SSB_BOARD_SD4318 0x044B
  330. #define SSB_BOARD_BCM94306P 0x044C /* with SiGe */
  331. #define SSB_BOARD_BCM94303MP 0x044E
  332. #define SSB_BOARD_BCM94306MPM 0x0450
  333. #define SSB_BOARD_BCM94306MPL 0x0453
  334. #define SSB_BOARD_PC4303 0x0454 /* pcmcia */
  335. #define SSB_BOARD_BCM94306MPLNA 0x0457
  336. #define SSB_BOARD_BCM94306MPH 0x045B
  337. #define SSB_BOARD_BCM94306PCIV 0x045C
  338. #define SSB_BOARD_BCM94318MPGH 0x0463
  339. #define SSB_BOARD_BU4311 0x0464
  340. #define SSB_BOARD_BCM94311MC 0x0465
  341. #define SSB_BOARD_BCM94311MCAG 0x0466
  342. /* 4321 boards */
  343. #define SSB_BOARD_BU4321 0x046B
  344. #define SSB_BOARD_BU4321E 0x047C
  345. #define SSB_BOARD_MP4321 0x046C
  346. #define SSB_BOARD_CB2_4321 0x046D
  347. #define SSB_BOARD_CB2_4321_AG 0x0066
  348. #define SSB_BOARD_MC4321 0x046E
  349. /* 4325 boards */
  350. #define SSB_BOARD_BCM94325DEVBU 0x0490
  351. #define SSB_BOARD_BCM94325BGABU 0x0491
  352. #define SSB_BOARD_BCM94325SDGWB 0x0492
  353. #define SSB_BOARD_BCM94325SDGMDL 0x04AA
  354. #define SSB_BOARD_BCM94325SDGMDL2 0x04C6
  355. #define SSB_BOARD_BCM94325SDGMDL3 0x04C9
  356. #define SSB_BOARD_BCM94325SDABGWBA 0x04E1
  357. /* 4322 boards */
  358. #define SSB_BOARD_BCM94322MC 0x04A4
  359. #define SSB_BOARD_BCM94322USB 0x04A8 /* dualband */
  360. #define SSB_BOARD_BCM94322HM 0x04B0
  361. #define SSB_BOARD_BCM94322USB2D 0x04Bf /* single band discrete front end */
  362. /* 4312 boards */
  363. #define SSB_BOARD_BU4312 0x048A
  364. #define SSB_BOARD_BCM4312MCGSG 0x04B5
  365. /* chip_package */
  366. #define SSB_CHIPPACK_BCM4712S 1 /* Small 200pin 4712 */
  367. #define SSB_CHIPPACK_BCM4712M 2 /* Medium 225pin 4712 */
  368. #define SSB_CHIPPACK_BCM4712L 0 /* Large 340pin 4712 */
  369. #include <linux/ssb/ssb_driver_chipcommon.h>
  370. #include <linux/ssb/ssb_driver_mips.h>
  371. #include <linux/ssb/ssb_driver_extif.h>
  372. #include <linux/ssb/ssb_driver_pci.h>
  373. struct ssb_bus {
  374. /* The MMIO area. */
  375. void __iomem *mmio;
  376. const struct ssb_bus_ops *ops;
  377. /* The core currently mapped into the MMIO window.
  378. * Not valid on all host-buses. So don't use outside of SSB. */
  379. struct ssb_device *mapped_device;
  380. union {
  381. /* Currently mapped PCMCIA segment. (bustype == SSB_BUSTYPE_PCMCIA only) */
  382. u8 mapped_pcmcia_seg;
  383. /* Current SSB base address window for SDIO. */
  384. u32 sdio_sbaddr;
  385. };
  386. /* Lock for core and segment switching.
  387. * On PCMCIA-host busses this is used to protect the whole MMIO access. */
  388. spinlock_t bar_lock;
  389. /* The host-bus this backplane is running on. */
  390. enum ssb_bustype bustype;
  391. /* Pointers to the host-bus. Check bustype before using any of these pointers. */
  392. union {
  393. /* Pointer to the PCI bus (only valid if bustype == SSB_BUSTYPE_PCI). */
  394. struct pci_dev *host_pci;
  395. /* Pointer to the PCMCIA device (only if bustype == SSB_BUSTYPE_PCMCIA). */
  396. struct pcmcia_device *host_pcmcia;
  397. /* Pointer to the SDIO device (only if bustype == SSB_BUSTYPE_SDIO). */
  398. struct sdio_func *host_sdio;
  399. };
  400. /* See enum ssb_quirks */
  401. unsigned int quirks;
  402. #ifdef CONFIG_SSB_SPROM
  403. /* Mutex to protect the SPROM writing. */
  404. struct mutex sprom_mutex;
  405. #endif
  406. /* ID information about the Chip. */
  407. u16 chip_id;
  408. u8 chip_rev;
  409. u16 sprom_offset;
  410. u16 sprom_size; /* number of words in sprom */
  411. u8 chip_package;
  412. /* List of devices (cores) on the backplane. */
  413. struct ssb_device devices[SSB_MAX_NR_CORES];
  414. u8 nr_devices;
  415. /* Software ID number for this bus. */
  416. unsigned int busnumber;
  417. /* The ChipCommon device (if available). */
  418. struct ssb_chipcommon chipco;
  419. /* The PCI-core device (if available). */
  420. struct ssb_pcicore pcicore;
  421. /* The MIPS-core device (if available). */
  422. struct ssb_mipscore mipscore;
  423. /* The EXTif-core device (if available). */
  424. struct ssb_extif extif;
  425. /* The following structure elements are not available in early
  426. * SSB initialization. Though, they are available for regular
  427. * registered drivers at any stage. So be careful when
  428. * using them in the ssb core code. */
  429. /* ID information about the PCB. */
  430. struct ssb_boardinfo boardinfo;
  431. /* Contents of the SPROM. */
  432. struct ssb_sprom sprom;
  433. /* If the board has a cardbus slot, this is set to true. */
  434. bool has_cardbus_slot;
  435. #ifdef CONFIG_SSB_EMBEDDED
  436. /* Lock for GPIO register access. */
  437. spinlock_t gpio_lock;
  438. struct platform_device *watchdog;
  439. #endif /* EMBEDDED */
  440. #ifdef CONFIG_SSB_DRIVER_GPIO
  441. struct gpio_chip gpio;
  442. struct irq_domain *irq_domain;
  443. #endif /* DRIVER_GPIO */
  444. /* Internal-only stuff follows. Do not touch. */
  445. struct list_head list;
  446. /* Is the bus already powered up? */
  447. bool powered_up;
  448. int power_warn_count;
  449. };
  450. enum ssb_quirks {
  451. /* SDIO connected card requires performing a read after writing a 32-bit value */
  452. SSB_QUIRK_SDIO_READ_AFTER_WRITE32 = (1 << 0),
  453. };
  454. /* The initialization-invariants. */
  455. struct ssb_init_invariants {
  456. /* Versioning information about the PCB. */
  457. struct ssb_boardinfo boardinfo;
  458. /* The SPROM information. That's either stored in an
  459. * EEPROM or NVRAM on the board. */
  460. struct ssb_sprom sprom;
  461. /* If the board has a cardbus slot, this is set to true. */
  462. bool has_cardbus_slot;
  463. };
  464. /* Type of function to fetch the invariants. */
  465. typedef int (*ssb_invariants_func_t)(struct ssb_bus *bus,
  466. struct ssb_init_invariants *iv);
  467. /* Register SoC bus. */
  468. extern int ssb_bus_host_soc_register(struct ssb_bus *bus,
  469. unsigned long baseaddr);
  470. #ifdef CONFIG_SSB_PCIHOST
  471. extern int ssb_bus_pcibus_register(struct ssb_bus *bus,
  472. struct pci_dev *host_pci);
  473. #endif /* CONFIG_SSB_PCIHOST */
  474. #ifdef CONFIG_SSB_PCMCIAHOST
  475. extern int ssb_bus_pcmciabus_register(struct ssb_bus *bus,
  476. struct pcmcia_device *pcmcia_dev,
  477. unsigned long baseaddr);
  478. #endif /* CONFIG_SSB_PCMCIAHOST */
  479. #ifdef CONFIG_SSB_SDIOHOST
  480. extern int ssb_bus_sdiobus_register(struct ssb_bus *bus,
  481. struct sdio_func *sdio_func,
  482. unsigned int quirks);
  483. #endif /* CONFIG_SSB_SDIOHOST */
  484. extern void ssb_bus_unregister(struct ssb_bus *bus);
  485. /* Does the device have an SPROM? */
  486. extern bool ssb_is_sprom_available(struct ssb_bus *bus);
  487. /* Set a fallback SPROM.
  488. * See kdoc at the function definition for complete documentation. */
  489. extern int ssb_arch_register_fallback_sprom(
  490. int (*sprom_callback)(struct ssb_bus *bus,
  491. struct ssb_sprom *out));
  492. /* Suspend a SSB bus.
  493. * Call this from the parent bus suspend routine. */
  494. extern int ssb_bus_suspend(struct ssb_bus *bus);
  495. /* Resume a SSB bus.
  496. * Call this from the parent bus resume routine. */
  497. extern int ssb_bus_resume(struct ssb_bus *bus);
  498. extern u32 ssb_clockspeed(struct ssb_bus *bus);
  499. /* Is the device enabled in hardware? */
  500. int ssb_device_is_enabled(struct ssb_device *dev);
  501. /* Enable a device and pass device-specific SSB_TMSLOW flags.
  502. * If no device-specific flags are available, use 0. */
  503. void ssb_device_enable(struct ssb_device *dev, u32 core_specific_flags);
  504. /* Disable a device in hardware and pass SSB_TMSLOW flags (if any). */
  505. void ssb_device_disable(struct ssb_device *dev, u32 core_specific_flags);
  506. /* Device MMIO register read/write functions. */
  507. static inline u8 ssb_read8(struct ssb_device *dev, u16 offset)
  508. {
  509. return dev->ops->read8(dev, offset);
  510. }
  511. static inline u16 ssb_read16(struct ssb_device *dev, u16 offset)
  512. {
  513. return dev->ops->read16(dev, offset);
  514. }
  515. static inline u32 ssb_read32(struct ssb_device *dev, u16 offset)
  516. {
  517. return dev->ops->read32(dev, offset);
  518. }
  519. static inline void ssb_write8(struct ssb_device *dev, u16 offset, u8 value)
  520. {
  521. dev->ops->write8(dev, offset, value);
  522. }
  523. static inline void ssb_write16(struct ssb_device *dev, u16 offset, u16 value)
  524. {
  525. dev->ops->write16(dev, offset, value);
  526. }
  527. static inline void ssb_write32(struct ssb_device *dev, u16 offset, u32 value)
  528. {
  529. dev->ops->write32(dev, offset, value);
  530. }
  531. #ifdef CONFIG_SSB_BLOCKIO
  532. static inline void ssb_block_read(struct ssb_device *dev, void *buffer,
  533. size_t count, u16 offset, u8 reg_width)
  534. {
  535. dev->ops->block_read(dev, buffer, count, offset, reg_width);
  536. }
  537. static inline void ssb_block_write(struct ssb_device *dev, const void *buffer,
  538. size_t count, u16 offset, u8 reg_width)
  539. {
  540. dev->ops->block_write(dev, buffer, count, offset, reg_width);
  541. }
  542. #endif /* CONFIG_SSB_BLOCKIO */
  543. /* The SSB DMA API. Use this API for any DMA operation on the device.
  544. * This API basically is a wrapper that calls the correct DMA API for
  545. * the host device type the SSB device is attached to. */
  546. /* Translation (routing) bits that need to be ORed to DMA
  547. * addresses before they are given to a device. */
  548. extern u32 ssb_dma_translation(struct ssb_device *dev);
  549. #define SSB_DMA_TRANSLATION_MASK 0xC0000000
  550. #define SSB_DMA_TRANSLATION_SHIFT 30
  551. static inline void __cold __ssb_dma_not_implemented(struct ssb_device *dev)
  552. {
  553. #ifdef CONFIG_SSB_DEBUG
  554. printk(KERN_ERR "SSB: BUG! Calling DMA API for "
  555. "unsupported bustype %d\n", dev->bus->bustype);
  556. #endif /* DEBUG */
  557. }
  558. #ifdef CONFIG_SSB_PCIHOST
  559. /* PCI-host wrapper driver */
  560. extern int ssb_pcihost_register(struct pci_driver *driver);
  561. static inline void ssb_pcihost_unregister(struct pci_driver *driver)
  562. {
  563. pci_unregister_driver(driver);
  564. }
  565. static inline
  566. void ssb_pcihost_set_power_state(struct ssb_device *sdev, pci_power_t state)
  567. {
  568. if (sdev->bus->bustype == SSB_BUSTYPE_PCI)
  569. pci_set_power_state(sdev->bus->host_pci, state);
  570. }
  571. #else
  572. static inline void ssb_pcihost_unregister(struct pci_driver *driver)
  573. {
  574. }
  575. static inline
  576. void ssb_pcihost_set_power_state(struct ssb_device *sdev, pci_power_t state)
  577. {
  578. }
  579. #endif /* CONFIG_SSB_PCIHOST */
  580. /* If a driver is shutdown or suspended, call this to signal
  581. * that the bus may be completely powered down. SSB will decide,
  582. * if it's really time to power down the bus, based on if there
  583. * are other devices that want to run. */
  584. extern int ssb_bus_may_powerdown(struct ssb_bus *bus);
  585. /* Before initializing and enabling a device, call this to power-up the bus.
  586. * If you want to allow use of dynamic-power-control, pass the flag.
  587. * Otherwise static always-on powercontrol will be used. */
  588. extern int ssb_bus_powerup(struct ssb_bus *bus, bool dynamic_pctl);
  589. extern void ssb_commit_settings(struct ssb_bus *bus);
  590. /* Various helper functions */
  591. extern u32 ssb_admatch_base(u32 adm);
  592. extern u32 ssb_admatch_size(u32 adm);
  593. /* PCI device mapping and fixup routines.
  594. * Called from the architecture pcibios init code.
  595. * These are only available on SSB_EMBEDDED configurations. */
  596. #ifdef CONFIG_SSB_EMBEDDED
  597. int ssb_pcibios_plat_dev_init(struct pci_dev *dev);
  598. int ssb_pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin);
  599. #endif /* CONFIG_SSB_EMBEDDED */
  600. #endif /* LINUX_SSB_H_ */