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