Blame view

include/linux/bcma/bcma.h 8.46 KB
8369ae33b   Rafał Miłecki   bcma: add Broadco...
1
2
3
4
5
6
7
8
  #ifndef LINUX_BCMA_H_
  #define LINUX_BCMA_H_
  
  #include <linux/pci.h>
  #include <linux/mod_devicetable.h>
  
  #include <linux/bcma/bcma_driver_chipcommon.h>
  #include <linux/bcma/bcma_driver_pci.h>
21e0534ad   Hauke Mehrtens   bcma: add mips dr...
9
  #include <linux/bcma/bcma_driver_mips.h>
27f18dc2d   Rafał Miłecki   bcma: read SPROM ...
10
  #include <linux/ssb/ssb.h> /* SPROM sharing */
8369ae33b   Rafał Miłecki   bcma: add Broadco...
11
12
13
14
15
16
17
  
  #include "bcma_regs.h"
  
  struct bcma_device;
  struct bcma_bus;
  
  enum bcma_hosttype {
8369ae33b   Rafał Miłecki   bcma: add Broadco...
18
19
  	BCMA_HOSTTYPE_PCI,
  	BCMA_HOSTTYPE_SDIO,
ecd177c21   Hauke Mehrtens   bcma: add SOC bus
20
  	BCMA_HOSTTYPE_SOC,
8369ae33b   Rafał Miłecki   bcma: add Broadco...
21
22
23
24
25
26
27
  };
  
  struct bcma_chipinfo {
  	u16 id;
  	u8 rev;
  	u8 pkg;
  };
7424dd0d0   Rafał Miłecki   bcma: allow setti...
28
29
30
31
  enum bcma_clkmode {
  	BCMA_CLKMODE_FAST,
  	BCMA_CLKMODE_DYNAMIC,
  };
8369ae33b   Rafał Miłecki   bcma: add Broadco...
32
33
34
35
36
37
38
  struct bcma_host_ops {
  	u8 (*read8)(struct bcma_device *core, u16 offset);
  	u16 (*read16)(struct bcma_device *core, u16 offset);
  	u32 (*read32)(struct bcma_device *core, u16 offset);
  	void (*write8)(struct bcma_device *core, u16 offset, u8 value);
  	void (*write16)(struct bcma_device *core, u16 offset, u16 value);
  	void (*write32)(struct bcma_device *core, u16 offset, u32 value);
9d75ef0f8   Rafał Miłecki   bcma: host pci: i...
39
40
41
42
43
44
  #ifdef CONFIG_BCMA_BLOCKIO
  	void (*block_read)(struct bcma_device *core, void *buffer,
  			   size_t count, u16 offset, u8 reg_width);
  	void (*block_write)(struct bcma_device *core, const void *buffer,
  			    size_t count, u16 offset, u8 reg_width);
  #endif
8369ae33b   Rafał Miłecki   bcma: add Broadco...
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
  	/* Agent ops */
  	u32 (*aread32)(struct bcma_device *core, u16 offset);
  	void (*awrite32)(struct bcma_device *core, u16 offset, u32 value);
  };
  
  /* Core manufacturers */
  #define BCMA_MANUF_ARM			0x43B
  #define BCMA_MANUF_MIPS			0x4A7
  #define BCMA_MANUF_BCM			0x4BF
  
  /* Core class values. */
  #define BCMA_CL_SIM			0x0
  #define BCMA_CL_EROM			0x1
  #define BCMA_CL_CORESIGHT		0x9
  #define BCMA_CL_VERIF			0xB
  #define BCMA_CL_OPTIMO			0xD
  #define BCMA_CL_GEN			0xE
  #define BCMA_CL_PRIMECELL		0xF
  
  /* Core-ID values. */
  #define BCMA_CORE_OOB_ROUTER		0x367	/* Out of band */
  #define BCMA_CORE_INVALID		0x700
  #define BCMA_CORE_CHIPCOMMON		0x800
  #define BCMA_CORE_ILINE20		0x801
  #define BCMA_CORE_SRAM			0x802
  #define BCMA_CORE_SDRAM			0x803
  #define BCMA_CORE_PCI			0x804
  #define BCMA_CORE_MIPS			0x805
  #define BCMA_CORE_ETHERNET		0x806
  #define BCMA_CORE_V90			0x807
  #define BCMA_CORE_USB11_HOSTDEV		0x808
  #define BCMA_CORE_ADSL			0x809
  #define BCMA_CORE_ILINE100		0x80A
  #define BCMA_CORE_IPSEC			0x80B
  #define BCMA_CORE_UTOPIA		0x80C
  #define BCMA_CORE_PCMCIA		0x80D
  #define BCMA_CORE_INTERNAL_MEM		0x80E
  #define BCMA_CORE_MEMC_SDRAM		0x80F
  #define BCMA_CORE_OFDM			0x810
  #define BCMA_CORE_EXTIF			0x811
  #define BCMA_CORE_80211			0x812
  #define BCMA_CORE_PHY_A			0x813
  #define BCMA_CORE_PHY_B			0x814
  #define BCMA_CORE_PHY_G			0x815
  #define BCMA_CORE_MIPS_3302		0x816
  #define BCMA_CORE_USB11_HOST		0x817
  #define BCMA_CORE_USB11_DEV		0x818
  #define BCMA_CORE_USB20_HOST		0x819
  #define BCMA_CORE_USB20_DEV		0x81A
  #define BCMA_CORE_SDIO_HOST		0x81B
  #define BCMA_CORE_ROBOSWITCH		0x81C
  #define BCMA_CORE_PARA_ATA		0x81D
  #define BCMA_CORE_SATA_XORDMA		0x81E
  #define BCMA_CORE_ETHERNET_GBIT		0x81F
  #define BCMA_CORE_PCIE			0x820
  #define BCMA_CORE_PHY_N			0x821
  #define BCMA_CORE_SRAM_CTL		0x822
  #define BCMA_CORE_MINI_MACPHY		0x823
  #define BCMA_CORE_ARM_1176		0x824
  #define BCMA_CORE_ARM_7TDMI		0x825
  #define BCMA_CORE_PHY_LP		0x826
  #define BCMA_CORE_PMU			0x827
  #define BCMA_CORE_PHY_SSN		0x828
  #define BCMA_CORE_SDIO_DEV		0x829
  #define BCMA_CORE_ARM_CM3		0x82A
  #define BCMA_CORE_PHY_HT		0x82B
  #define BCMA_CORE_MIPS_74K		0x82C
  #define BCMA_CORE_MAC_GBIT		0x82D
  #define BCMA_CORE_DDR12_MEM_CTL		0x82E
  #define BCMA_CORE_PCIE_RC		0x82F	/* PCIe Root Complex */
  #define BCMA_CORE_OCP_OCP_BRIDGE	0x830
  #define BCMA_CORE_SHARED_COMMON		0x831
  #define BCMA_CORE_OCP_AHB_BRIDGE	0x832
  #define BCMA_CORE_SPI_HOST		0x833
  #define BCMA_CORE_I2S			0x834
  #define BCMA_CORE_SDR_DDR1_MEM_CTL	0x835	/* SDR/DDR1 memory controller core */
  #define BCMA_CORE_SHIM			0x837	/* SHIM component in ubus/6362 */
  #define BCMA_CORE_DEFAULT		0xFFF
  
  #define BCMA_MAX_NR_CORES		16
  
  struct bcma_device {
  	struct bcma_bus *bus;
  	struct bcma_device_id id;
  
  	struct device dev;
1bdcd095e   Rafał Miłecki   bcma: add IRQ num...
131
  	struct device *dma_dev;
21e0534ad   Hauke Mehrtens   bcma: add mips dr...
132

1bdcd095e   Rafał Miłecki   bcma: add IRQ num...
133
  	unsigned int irq;
8369ae33b   Rafał Miłecki   bcma: add Broadco...
134
135
136
137
138
139
  	bool dev_registered;
  
  	u8 core_index;
  
  	u32 addr;
  	u32 wrap;
ecd177c21   Hauke Mehrtens   bcma: add SOC bus
140
141
  	void __iomem *io_addr;
  	void __iomem *io_wrap;
8369ae33b   Rafał Miłecki   bcma: add Broadco...
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
  	void *drvdata;
  	struct list_head list;
  };
  
  static inline void *bcma_get_drvdata(struct bcma_device *core)
  {
  	return core->drvdata;
  }
  static inline void bcma_set_drvdata(struct bcma_device *core, void *drvdata)
  {
  	core->drvdata = drvdata;
  }
  
  struct bcma_driver {
  	const char *name;
  	const struct bcma_device_id *id_table;
  
  	int (*probe)(struct bcma_device *dev);
  	void (*remove)(struct bcma_device *dev);
  	int (*suspend)(struct bcma_device *dev, pm_message_t state);
  	int (*resume)(struct bcma_device *dev);
  	void (*shutdown)(struct bcma_device *dev);
  
  	struct device_driver drv;
  };
  extern
  int __bcma_driver_register(struct bcma_driver *drv, struct module *owner);
eb5589a8f   Paul Gortmaker   include: convert ...
169
170
  #define bcma_driver_register(drv) \
  	__bcma_driver_register(drv, THIS_MODULE)
8369ae33b   Rafał Miłecki   bcma: add Broadco...
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
  extern void bcma_driver_unregister(struct bcma_driver *drv);
  
  struct bcma_bus {
  	/* The MMIO area. */
  	void __iomem *mmio;
  
  	const struct bcma_host_ops *ops;
  
  	enum bcma_hosttype hosttype;
  	union {
  		/* Pointer to the PCI bus (only for BCMA_HOSTTYPE_PCI) */
  		struct pci_dev *host_pci;
  		/* Pointer to the SDIO device (only for BCMA_HOSTTYPE_SDIO) */
  		struct sdio_func *host_sdio;
  	};
  
  	struct bcma_chipinfo chipinfo;
  
  	struct bcma_device *mapped_core;
  	struct list_head cores;
  	u8 nr_cores;
517f43e5a   Hauke Mehrtens   bcma: add functio...
192
  	u8 init_done:1;
8369ae33b   Rafał Miłecki   bcma: add Broadco...
193
194
195
  
  	struct bcma_drv_cc drv_cc;
  	struct bcma_drv_pci drv_pci;
21e0534ad   Hauke Mehrtens   bcma: add mips dr...
196
  	struct bcma_drv_mips drv_mips;
27f18dc2d   Rafał Miłecki   bcma: read SPROM ...
197
198
199
200
  
  	/* We decided to share SPROM struct with SSB as long as we do not need
  	 * any hacks for BCMA. This simplifies drivers code. */
  	struct ssb_sprom sprom;
8369ae33b   Rafał Miłecki   bcma: add Broadco...
201
  };
084455524   Arend van Spriel   bcma: use static ...
202
  static inline u32 bcma_read8(struct bcma_device *core, u16 offset)
8369ae33b   Rafał Miłecki   bcma: add Broadco...
203
204
205
  {
  	return core->bus->ops->read8(core, offset);
  }
084455524   Arend van Spriel   bcma: use static ...
206
  static inline u32 bcma_read16(struct bcma_device *core, u16 offset)
8369ae33b   Rafał Miłecki   bcma: add Broadco...
207
208
209
  {
  	return core->bus->ops->read16(core, offset);
  }
084455524   Arend van Spriel   bcma: use static ...
210
  static inline u32 bcma_read32(struct bcma_device *core, u16 offset)
8369ae33b   Rafał Miłecki   bcma: add Broadco...
211
212
213
  {
  	return core->bus->ops->read32(core, offset);
  }
084455524   Arend van Spriel   bcma: use static ...
214
  static inline
8369ae33b   Rafał Miłecki   bcma: add Broadco...
215
216
217
218
  void bcma_write8(struct bcma_device *core, u16 offset, u32 value)
  {
  	core->bus->ops->write8(core, offset, value);
  }
084455524   Arend van Spriel   bcma: use static ...
219
  static inline
8369ae33b   Rafał Miłecki   bcma: add Broadco...
220
221
222
223
  void bcma_write16(struct bcma_device *core, u16 offset, u32 value)
  {
  	core->bus->ops->write16(core, offset, value);
  }
084455524   Arend van Spriel   bcma: use static ...
224
  static inline
8369ae33b   Rafał Miłecki   bcma: add Broadco...
225
226
227
228
  void bcma_write32(struct bcma_device *core, u16 offset, u32 value)
  {
  	core->bus->ops->write32(core, offset, value);
  }
9d75ef0f8   Rafał Miłecki   bcma: host pci: i...
229
  #ifdef CONFIG_BCMA_BLOCKIO
084455524   Arend van Spriel   bcma: use static ...
230
  static inline void bcma_block_read(struct bcma_device *core, void *buffer,
9d75ef0f8   Rafał Miłecki   bcma: host pci: i...
231
232
233
234
  				   size_t count, u16 offset, u8 reg_width)
  {
  	core->bus->ops->block_read(core, buffer, count, offset, reg_width);
  }
084455524   Arend van Spriel   bcma: use static ...
235
236
237
  static inline void bcma_block_write(struct bcma_device *core,
  				    const void *buffer, size_t count,
  				    u16 offset, u8 reg_width)
9d75ef0f8   Rafał Miłecki   bcma: host pci: i...
238
239
240
241
  {
  	core->bus->ops->block_write(core, buffer, count, offset, reg_width);
  }
  #endif
084455524   Arend van Spriel   bcma: use static ...
242
  static inline u32 bcma_aread32(struct bcma_device *core, u16 offset)
8369ae33b   Rafał Miłecki   bcma: add Broadco...
243
244
245
  {
  	return core->bus->ops->aread32(core, offset);
  }
084455524   Arend van Spriel   bcma: use static ...
246
  static inline
8369ae33b   Rafał Miłecki   bcma: add Broadco...
247
248
249
250
  void bcma_awrite32(struct bcma_device *core, u16 offset, u32 value)
  {
  	core->bus->ops->awrite32(core, offset, value);
  }
9d08f10d3   Arend van Spriel   bcma: add set/mas...
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
  static inline void bcma_mask32(struct bcma_device *cc, u16 offset, u32 mask)
  {
  	bcma_write32(cc, offset, bcma_read32(cc, offset) & mask);
  }
  static inline void bcma_set32(struct bcma_device *cc, u16 offset, u32 set)
  {
  	bcma_write32(cc, offset, bcma_read32(cc, offset) | set);
  }
  static inline void bcma_maskset32(struct bcma_device *cc,
  				  u16 offset, u32 mask, u32 set)
  {
  	bcma_write32(cc, offset, (bcma_read32(cc, offset) & mask) | set);
  }
  static inline void bcma_mask16(struct bcma_device *cc, u16 offset, u16 mask)
  {
  	bcma_write16(cc, offset, bcma_read16(cc, offset) & mask);
  }
  static inline void bcma_set16(struct bcma_device *cc, u16 offset, u16 set)
  {
  	bcma_write16(cc, offset, bcma_read16(cc, offset) | set);
  }
  static inline void bcma_maskset16(struct bcma_device *cc,
  				  u16 offset, u16 mask, u16 set)
  {
  	bcma_write16(cc, offset, (bcma_read16(cc, offset) & mask) | set);
  }
3de1a7748   Rafał Miłecki   bcma: trivial: ad...
277

8369ae33b   Rafał Miłecki   bcma: add Broadco...
278
  extern bool bcma_core_is_enabled(struct bcma_device *core);
e3ae0cac0   Arend van Spriel   drivers: bcma: ex...
279
  extern void bcma_core_disable(struct bcma_device *core, u32 flags);
8369ae33b   Rafał Miłecki   bcma: add Broadco...
280
  extern int bcma_core_enable(struct bcma_device *core, u32 flags);
7424dd0d0   Rafał Miłecki   bcma: allow setti...
281
282
  extern void bcma_core_set_clockmode(struct bcma_device *core,
  				    enum bcma_clkmode clkmode);
6f53912fc   Rafał Miłecki   bcma: allow enabl...
283
284
  extern void bcma_core_pll_ctl(struct bcma_device *core, u32 req, u32 status,
  			      bool on);
05aec2333   Rafał Miłecki   bcma: inform driv...
285
286
287
288
289
  #define BCMA_DMA_TRANSLATION_MASK	0xC0000000
  #define  BCMA_DMA_TRANSLATION_NONE	0x00000000
  #define  BCMA_DMA_TRANSLATION_DMA32_CMT	0x40000000 /* Client Mode Translation for 32-bit DMA */
  #define  BCMA_DMA_TRANSLATION_DMA64_CMT	0x80000000 /* Client Mode Translation for 64-bit DMA */
  extern u32 bcma_core_dma_translation(struct bcma_device *core);
3de1a7748   Rafał Miłecki   bcma: trivial: ad...
290

8369ae33b   Rafał Miłecki   bcma: add Broadco...
291
  #endif /* LINUX_BCMA_H_ */