bcma.h 5.9 KB

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