2 * Broadcom specific AMBA
3 * System on Chip (SoC) Host
5 * Licensed under the GNU/GPL. See COPYING for details.
8 #include "bcma_private.h"
10 #include <linux/bcma/bcma.h>
11 #include <linux/bcma/bcma_soc.h>
13 static u8
bcma_host_soc_read8(struct bcma_device
*core
, u16 offset
)
15 return readb(core
->io_addr
+ offset
);
18 static u16
bcma_host_soc_read16(struct bcma_device
*core
, u16 offset
)
20 return readw(core
->io_addr
+ offset
);
23 static u32
bcma_host_soc_read32(struct bcma_device
*core
, u16 offset
)
25 return readl(core
->io_addr
+ offset
);
28 static void bcma_host_soc_write8(struct bcma_device
*core
, u16 offset
,
31 writeb(value
, core
->io_addr
+ offset
);
34 static void bcma_host_soc_write16(struct bcma_device
*core
, u16 offset
,
37 writew(value
, core
->io_addr
+ offset
);
40 static void bcma_host_soc_write32(struct bcma_device
*core
, u16 offset
,
43 writel(value
, core
->io_addr
+ offset
);
46 #ifdef CONFIG_BCMA_BLOCKIO
47 static void bcma_host_soc_block_read(struct bcma_device
*core
, void *buffer
,
48 size_t count
, u16 offset
, u8 reg_width
)
50 void __iomem
*addr
= core
->io_addr
+ offset
;
57 *buf
= __raw_readb(addr
);
68 *buf
= (__force __le16
)__raw_readw(addr
);
79 *buf
= (__force __le32
)__raw_readl(addr
);
90 static void bcma_host_soc_block_write(struct bcma_device
*core
,
92 size_t count
, u16 offset
, u8 reg_width
)
94 void __iomem
*addr
= core
->io_addr
+ offset
;
98 const u8
*buf
= buffer
;
101 __raw_writeb(*buf
, addr
);
108 const __le16
*buf
= buffer
;
112 __raw_writew((__force u16
)(*buf
), addr
);
119 const __le32
*buf
= buffer
;
123 __raw_writel((__force u32
)(*buf
), addr
);
133 #endif /* CONFIG_BCMA_BLOCKIO */
135 static u32
bcma_host_soc_aread32(struct bcma_device
*core
, u16 offset
)
137 return readl(core
->io_wrap
+ offset
);
140 static void bcma_host_soc_awrite32(struct bcma_device
*core
, u16 offset
,
143 writel(value
, core
->io_wrap
+ offset
);
146 const struct bcma_host_ops bcma_host_soc_ops
= {
147 .read8
= bcma_host_soc_read8
,
148 .read16
= bcma_host_soc_read16
,
149 .read32
= bcma_host_soc_read32
,
150 .write8
= bcma_host_soc_write8
,
151 .write16
= bcma_host_soc_write16
,
152 .write32
= bcma_host_soc_write32
,
153 #ifdef CONFIG_BCMA_BLOCKIO
154 .block_read
= bcma_host_soc_block_read
,
155 .block_write
= bcma_host_soc_block_write
,
157 .aread32
= bcma_host_soc_aread32
,
158 .awrite32
= bcma_host_soc_awrite32
,
161 int __init
bcma_host_soc_register(struct bcma_soc
*soc
)
163 struct bcma_bus
*bus
= &soc
->bus
;
166 /* iomap only first core. We have to read some register on this core
169 bus
->mmio
= ioremap_nocache(BCMA_ADDR_BASE
, BCMA_CORE_SIZE
* 1);
174 bus
->hosttype
= BCMA_HOSTTYPE_SOC
;
175 bus
->ops
= &bcma_host_soc_ops
;
178 err
= bcma_bus_early_register(bus
, &soc
->core_cc
, &soc
->core_mips
);