irqchip/s3c24xx: Mark init_eint as __maybe_unused
[linux/fpc-iii.git] / drivers / ssb / host_soc.c
blobc809f255af344b43146170623ecf362a2b2d3573
1 /*
2 * Sonics Silicon Backplane SoC host related functions.
3 * Subsystem core
5 * Copyright 2005, Broadcom Corporation
6 * Copyright 2006, 2007, Michael Buesch <m@bues.ch>
8 * Licensed under the GNU/GPL. See COPYING for details.
9 */
11 #include <linux/ssb/ssb.h>
13 #include "ssb_private.h"
15 static u8 ssb_host_soc_read8(struct ssb_device *dev, u16 offset)
17 struct ssb_bus *bus = dev->bus;
19 offset += dev->core_index * SSB_CORE_SIZE;
20 return readb(bus->mmio + offset);
23 static u16 ssb_host_soc_read16(struct ssb_device *dev, u16 offset)
25 struct ssb_bus *bus = dev->bus;
27 offset += dev->core_index * SSB_CORE_SIZE;
28 return readw(bus->mmio + offset);
31 static u32 ssb_host_soc_read32(struct ssb_device *dev, u16 offset)
33 struct ssb_bus *bus = dev->bus;
35 offset += dev->core_index * SSB_CORE_SIZE;
36 return readl(bus->mmio + offset);
39 #ifdef CONFIG_SSB_BLOCKIO
40 static void ssb_host_soc_block_read(struct ssb_device *dev, void *buffer,
41 size_t count, u16 offset, u8 reg_width)
43 struct ssb_bus *bus = dev->bus;
44 void __iomem *addr;
46 offset += dev->core_index * SSB_CORE_SIZE;
47 addr = bus->mmio + offset;
49 switch (reg_width) {
50 case sizeof(u8): {
51 u8 *buf = buffer;
53 while (count) {
54 *buf = __raw_readb(addr);
55 buf++;
56 count--;
58 break;
60 case sizeof(u16): {
61 __le16 *buf = buffer;
63 SSB_WARN_ON(count & 1);
64 while (count) {
65 *buf = (__force __le16)__raw_readw(addr);
66 buf++;
67 count -= 2;
69 break;
71 case sizeof(u32): {
72 __le32 *buf = buffer;
74 SSB_WARN_ON(count & 3);
75 while (count) {
76 *buf = (__force __le32)__raw_readl(addr);
77 buf++;
78 count -= 4;
80 break;
82 default:
83 SSB_WARN_ON(1);
86 #endif /* CONFIG_SSB_BLOCKIO */
88 static void ssb_host_soc_write8(struct ssb_device *dev, u16 offset, u8 value)
90 struct ssb_bus *bus = dev->bus;
92 offset += dev->core_index * SSB_CORE_SIZE;
93 writeb(value, bus->mmio + offset);
96 static void ssb_host_soc_write16(struct ssb_device *dev, u16 offset, u16 value)
98 struct ssb_bus *bus = dev->bus;
100 offset += dev->core_index * SSB_CORE_SIZE;
101 writew(value, bus->mmio + offset);
104 static void ssb_host_soc_write32(struct ssb_device *dev, u16 offset, u32 value)
106 struct ssb_bus *bus = dev->bus;
108 offset += dev->core_index * SSB_CORE_SIZE;
109 writel(value, bus->mmio + offset);
112 #ifdef CONFIG_SSB_BLOCKIO
113 static void ssb_host_soc_block_write(struct ssb_device *dev, const void *buffer,
114 size_t count, u16 offset, u8 reg_width)
116 struct ssb_bus *bus = dev->bus;
117 void __iomem *addr;
119 offset += dev->core_index * SSB_CORE_SIZE;
120 addr = bus->mmio + offset;
122 switch (reg_width) {
123 case sizeof(u8): {
124 const u8 *buf = buffer;
126 while (count) {
127 __raw_writeb(*buf, addr);
128 buf++;
129 count--;
131 break;
133 case sizeof(u16): {
134 const __le16 *buf = buffer;
136 SSB_WARN_ON(count & 1);
137 while (count) {
138 __raw_writew((__force u16)(*buf), addr);
139 buf++;
140 count -= 2;
142 break;
144 case sizeof(u32): {
145 const __le32 *buf = buffer;
147 SSB_WARN_ON(count & 3);
148 while (count) {
149 __raw_writel((__force u32)(*buf), addr);
150 buf++;
151 count -= 4;
153 break;
155 default:
156 SSB_WARN_ON(1);
159 #endif /* CONFIG_SSB_BLOCKIO */
161 /* Ops for the plain SSB bus without a host-device (no PCI or PCMCIA). */
162 const struct ssb_bus_ops ssb_host_soc_ops = {
163 .read8 = ssb_host_soc_read8,
164 .read16 = ssb_host_soc_read16,
165 .read32 = ssb_host_soc_read32,
166 .write8 = ssb_host_soc_write8,
167 .write16 = ssb_host_soc_write16,
168 .write32 = ssb_host_soc_write32,
169 #ifdef CONFIG_SSB_BLOCKIO
170 .block_read = ssb_host_soc_block_read,
171 .block_write = ssb_host_soc_block_write,
172 #endif