ssb.h 20 KB

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