bcma.h 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. #ifndef LINUX_BCMA_H_
  2. #define LINUX_BCMA_H_
  3. #include <linux/pci.h>
  4. #include <linux/mod_devicetable.h>
  5. #include <linux/bcma/bcma_driver_chipcommon.h>
  6. #include <linux/bcma/bcma_driver_pci.h>
  7. #include <linux/ssb/ssb.h> /* SPROM sharing */
  8. #include "bcma_regs.h"
  9. struct bcma_device;
  10. struct bcma_bus;
  11. enum bcma_hosttype {
  12. BCMA_HOSTTYPE_NONE,
  13. BCMA_HOSTTYPE_PCI,
  14. BCMA_HOSTTYPE_SDIO,
  15. };
  16. struct bcma_chipinfo {
  17. u16 id;
  18. u8 rev;
  19. u8 pkg;
  20. };
  21. struct bcma_host_ops {
  22. u8 (*read8)(struct bcma_device *core, u16 offset);
  23. u16 (*read16)(struct bcma_device *core, u16 offset);
  24. u32 (*read32)(struct bcma_device *core, u16 offset);
  25. void (*write8)(struct bcma_device *core, u16 offset, u8 value);
  26. void (*write16)(struct bcma_device *core, u16 offset, u16 value);
  27. void (*write32)(struct bcma_device *core, u16 offset, u32 value);
  28. #ifdef CONFIG_BCMA_BLOCKIO
  29. void (*block_read)(struct bcma_device *core, void *buffer,
  30. size_t count, u16 offset, u8 reg_width);
  31. void (*block_write)(struct bcma_device *core, const void *buffer,
  32. size_t count, u16 offset, u8 reg_width);
  33. #endif
  34. /* Agent ops */
  35. u32 (*aread32)(struct bcma_device *core, u16 offset);
  36. void (*awrite32)(struct bcma_device *core, u16 offset, u32 value);
  37. };
  38. /* Core manufacturers */
  39. #define BCMA_MANUF_ARM 0x43B
  40. #define BCMA_MANUF_MIPS 0x4A7
  41. #define BCMA_MANUF_BCM 0x4BF
  42. /* Core class values. */
  43. #define BCMA_CL_SIM 0x0
  44. #define BCMA_CL_EROM 0x1
  45. #define BCMA_CL_CORESIGHT 0x9
  46. #define BCMA_CL_VERIF 0xB
  47. #define BCMA_CL_OPTIMO 0xD
  48. #define BCMA_CL_GEN 0xE
  49. #define BCMA_CL_PRIMECELL 0xF
  50. /* Core-ID values. */
  51. #define BCMA_CORE_OOB_ROUTER 0x367 /* Out of band */
  52. #define BCMA_CORE_INVALID 0x700
  53. #define BCMA_CORE_CHIPCOMMON 0x800
  54. #define BCMA_CORE_ILINE20 0x801
  55. #define BCMA_CORE_SRAM 0x802
  56. #define BCMA_CORE_SDRAM 0x803
  57. #define BCMA_CORE_PCI 0x804
  58. #define BCMA_CORE_MIPS 0x805
  59. #define BCMA_CORE_ETHERNET 0x806
  60. #define BCMA_CORE_V90 0x807
  61. #define BCMA_CORE_USB11_HOSTDEV 0x808
  62. #define BCMA_CORE_ADSL 0x809
  63. #define BCMA_CORE_ILINE100 0x80A
  64. #define BCMA_CORE_IPSEC 0x80B
  65. #define BCMA_CORE_UTOPIA 0x80C
  66. #define BCMA_CORE_PCMCIA 0x80D
  67. #define BCMA_CORE_INTERNAL_MEM 0x80E
  68. #define BCMA_CORE_MEMC_SDRAM 0x80F
  69. #define BCMA_CORE_OFDM 0x810
  70. #define BCMA_CORE_EXTIF 0x811
  71. #define BCMA_CORE_80211 0x812
  72. #define BCMA_CORE_PHY_A 0x813
  73. #define BCMA_CORE_PHY_B 0x814
  74. #define BCMA_CORE_PHY_G 0x815
  75. #define BCMA_CORE_MIPS_3302 0x816
  76. #define BCMA_CORE_USB11_HOST 0x817
  77. #define BCMA_CORE_USB11_DEV 0x818
  78. #define BCMA_CORE_USB20_HOST 0x819
  79. #define BCMA_CORE_USB20_DEV 0x81A
  80. #define BCMA_CORE_SDIO_HOST 0x81B
  81. #define BCMA_CORE_ROBOSWITCH 0x81C
  82. #define BCMA_CORE_PARA_ATA 0x81D
  83. #define BCMA_CORE_SATA_XORDMA 0x81E
  84. #define BCMA_CORE_ETHERNET_GBIT 0x81F
  85. #define BCMA_CORE_PCIE 0x820
  86. #define BCMA_CORE_PHY_N 0x821
  87. #define BCMA_CORE_SRAM_CTL 0x822
  88. #define BCMA_CORE_MINI_MACPHY 0x823
  89. #define BCMA_CORE_ARM_1176 0x824
  90. #define BCMA_CORE_ARM_7TDMI 0x825
  91. #define BCMA_CORE_PHY_LP 0x826
  92. #define BCMA_CORE_PMU 0x827
  93. #define BCMA_CORE_PHY_SSN 0x828
  94. #define BCMA_CORE_SDIO_DEV 0x829
  95. #define BCMA_CORE_ARM_CM3 0x82A
  96. #define BCMA_CORE_PHY_HT 0x82B
  97. #define BCMA_CORE_MIPS_74K 0x82C
  98. #define BCMA_CORE_MAC_GBIT 0x82D
  99. #define BCMA_CORE_DDR12_MEM_CTL 0x82E
  100. #define BCMA_CORE_PCIE_RC 0x82F /* PCIe Root Complex */
  101. #define BCMA_CORE_OCP_OCP_BRIDGE 0x830
  102. #define BCMA_CORE_SHARED_COMMON 0x831
  103. #define BCMA_CORE_OCP_AHB_BRIDGE 0x832
  104. #define BCMA_CORE_SPI_HOST 0x833
  105. #define BCMA_CORE_I2S 0x834
  106. #define BCMA_CORE_SDR_DDR1_MEM_CTL 0x835 /* SDR/DDR1 memory controller core */
  107. #define BCMA_CORE_SHIM 0x837 /* SHIM component in ubus/6362 */
  108. #define BCMA_CORE_DEFAULT 0xFFF
  109. #define BCMA_MAX_NR_CORES 16
  110. struct bcma_device {
  111. struct bcma_bus *bus;
  112. struct bcma_device_id id;
  113. struct device dev;
  114. struct device *dma_dev;
  115. unsigned int irq;
  116. bool dev_registered;
  117. u8 core_index;
  118. u32 addr;
  119. u32 wrap;
  120. void *drvdata;
  121. struct list_head list;
  122. };
  123. static inline void *bcma_get_drvdata(struct bcma_device *core)
  124. {
  125. return core->drvdata;
  126. }
  127. static inline void bcma_set_drvdata(struct bcma_device *core, void *drvdata)
  128. {
  129. core->drvdata = drvdata;
  130. }
  131. struct bcma_driver {
  132. const char *name;
  133. const struct bcma_device_id *id_table;
  134. int (*probe)(struct bcma_device *dev);
  135. void (*remove)(struct bcma_device *dev);
  136. int (*suspend)(struct bcma_device *dev, pm_message_t state);
  137. int (*resume)(struct bcma_device *dev);
  138. void (*shutdown)(struct bcma_device *dev);
  139. struct device_driver drv;
  140. };
  141. extern
  142. int __bcma_driver_register(struct bcma_driver *drv, struct module *owner);
  143. static inline int bcma_driver_register(struct bcma_driver *drv)
  144. {
  145. return __bcma_driver_register(drv, THIS_MODULE);
  146. }
  147. extern void bcma_driver_unregister(struct bcma_driver *drv);
  148. struct bcma_bus {
  149. /* The MMIO area. */
  150. void __iomem *mmio;
  151. const struct bcma_host_ops *ops;
  152. enum bcma_hosttype hosttype;
  153. union {
  154. /* Pointer to the PCI bus (only for BCMA_HOSTTYPE_PCI) */
  155. struct pci_dev *host_pci;
  156. /* Pointer to the SDIO device (only for BCMA_HOSTTYPE_SDIO) */
  157. struct sdio_func *host_sdio;
  158. };
  159. struct bcma_chipinfo chipinfo;
  160. struct bcma_device *mapped_core;
  161. struct list_head cores;
  162. u8 nr_cores;
  163. struct bcma_drv_cc drv_cc;
  164. struct bcma_drv_pci drv_pci;
  165. /* We decided to share SPROM struct with SSB as long as we do not need
  166. * any hacks for BCMA. This simplifies drivers code. */
  167. struct ssb_sprom sprom;
  168. };
  169. extern inline u32 bcma_read8(struct bcma_device *core, u16 offset)
  170. {
  171. return core->bus->ops->read8(core, offset);
  172. }
  173. extern inline u32 bcma_read16(struct bcma_device *core, u16 offset)
  174. {
  175. return core->bus->ops->read16(core, offset);
  176. }
  177. extern inline u32 bcma_read32(struct bcma_device *core, u16 offset)
  178. {
  179. return core->bus->ops->read32(core, offset);
  180. }
  181. extern inline
  182. void bcma_write8(struct bcma_device *core, u16 offset, u32 value)
  183. {
  184. core->bus->ops->write8(core, offset, value);
  185. }
  186. extern inline
  187. void bcma_write16(struct bcma_device *core, u16 offset, u32 value)
  188. {
  189. core->bus->ops->write16(core, offset, value);
  190. }
  191. extern inline
  192. void bcma_write32(struct bcma_device *core, u16 offset, u32 value)
  193. {
  194. core->bus->ops->write32(core, offset, value);
  195. }
  196. #ifdef CONFIG_BCMA_BLOCKIO
  197. extern inline void bcma_block_read(struct bcma_device *core, void *buffer,
  198. size_t count, u16 offset, u8 reg_width)
  199. {
  200. core->bus->ops->block_read(core, buffer, count, offset, reg_width);
  201. }
  202. extern inline void bcma_block_write(struct bcma_device *core, const void *buffer,
  203. size_t count, u16 offset, u8 reg_width)
  204. {
  205. core->bus->ops->block_write(core, buffer, count, offset, reg_width);
  206. }
  207. #endif
  208. extern inline u32 bcma_aread32(struct bcma_device *core, u16 offset)
  209. {
  210. return core->bus->ops->aread32(core, offset);
  211. }
  212. extern inline
  213. void bcma_awrite32(struct bcma_device *core, u16 offset, u32 value)
  214. {
  215. core->bus->ops->awrite32(core, offset, value);
  216. }
  217. extern bool bcma_core_is_enabled(struct bcma_device *core);
  218. extern void bcma_core_disable(struct bcma_device *core, u32 flags);
  219. extern int bcma_core_enable(struct bcma_device *core, u32 flags);
  220. #endif /* LINUX_BCMA_H_ */