1 Add support for 8bit reads/writes to SSB.
2 --- a/drivers/ssb/main.c
3 +++ b/drivers/ssb/main.c
8 +static u8 ssb_ssb_read8(struct ssb_device *dev, u16 offset)
10 + struct ssb_bus *bus = dev->bus;
12 + offset += dev->core_index * SSB_CORE_SIZE;
13 + return readb(bus->mmio + offset);
16 static u16 ssb_ssb_read16(struct ssb_device *dev, u16 offset)
18 struct ssb_bus *bus = dev->bus;
20 return readl(bus->mmio + offset);
23 +static void ssb_ssb_write8(struct ssb_device *dev, u16 offset, u8 value)
25 + struct ssb_bus *bus = dev->bus;
27 + offset += dev->core_index * SSB_CORE_SIZE;
28 + writeb(value, bus->mmio + offset);
31 static void ssb_ssb_write16(struct ssb_device *dev, u16 offset, u16 value)
33 struct ssb_bus *bus = dev->bus;
36 /* Ops for the plain SSB bus without a host-device (no PCI or PCMCIA). */
37 static const struct ssb_bus_ops ssb_ssb_ops = {
38 + .read8 = ssb_ssb_read8,
39 .read16 = ssb_ssb_read16,
40 .read32 = ssb_ssb_read32,
41 + .write8 = ssb_ssb_write8,
42 .write16 = ssb_ssb_write16,
43 .write32 = ssb_ssb_write32,
45 --- a/drivers/ssb/pci.c
46 +++ b/drivers/ssb/pci.c
51 +static u8 ssb_pci_read8(struct ssb_device *dev, u16 offset)
53 + struct ssb_bus *bus = dev->bus;
55 + if (unlikely(ssb_pci_assert_buspower(bus)))
57 + if (unlikely(bus->mapped_device != dev)) {
58 + if (unlikely(ssb_pci_switch_core(bus, dev)))
61 + return ioread8(bus->mmio + offset);
64 static u16 ssb_pci_read16(struct ssb_device *dev, u16 offset)
66 struct ssb_bus *bus = dev->bus;
68 return ioread32(bus->mmio + offset);
71 +static void ssb_pci_write8(struct ssb_device *dev, u16 offset, u8 value)
73 + struct ssb_bus *bus = dev->bus;
75 + if (unlikely(ssb_pci_assert_buspower(bus)))
77 + if (unlikely(bus->mapped_device != dev)) {
78 + if (unlikely(ssb_pci_switch_core(bus, dev)))
81 + iowrite8(value, bus->mmio + offset);
84 static void ssb_pci_write16(struct ssb_device *dev, u16 offset, u16 value)
86 struct ssb_bus *bus = dev->bus;
89 /* Not "static", as it's used in main.c */
90 const struct ssb_bus_ops ssb_pci_ops = {
91 + .read8 = ssb_pci_read8,
92 .read16 = ssb_pci_read16,
93 .read32 = ssb_pci_read32,
94 + .write8 = ssb_pci_write8,
95 .write16 = ssb_pci_write16,
96 .write32 = ssb_pci_write32,
98 --- a/drivers/ssb/pcmcia.c
99 +++ b/drivers/ssb/pcmcia.c
104 +static u8 ssb_pcmcia_read8(struct ssb_device *dev, u16 offset)
106 + struct ssb_bus *bus = dev->bus;
107 + unsigned long flags;
111 + spin_lock_irqsave(&bus->bar_lock, flags);
112 + err = select_core_and_segment(dev, &offset);
114 + value = readb(bus->mmio + offset);
115 + spin_unlock_irqrestore(&bus->bar_lock, flags);
120 static u16 ssb_pcmcia_read16(struct ssb_device *dev, u16 offset)
122 struct ssb_bus *bus = dev->bus;
124 return (lo | (hi << 16));
127 +static void ssb_pcmcia_write8(struct ssb_device *dev, u16 offset, u8 value)
129 + struct ssb_bus *bus = dev->bus;
130 + unsigned long flags;
133 + spin_lock_irqsave(&bus->bar_lock, flags);
134 + err = select_core_and_segment(dev, &offset);
136 + writeb(value, bus->mmio + offset);
138 + spin_unlock_irqrestore(&bus->bar_lock, flags);
141 static void ssb_pcmcia_write16(struct ssb_device *dev, u16 offset, u16 value)
143 struct ssb_bus *bus = dev->bus;
146 /* Not "static", as it's used in main.c */
147 const struct ssb_bus_ops ssb_pcmcia_ops = {
148 + .read8 = ssb_pcmcia_read8,
149 .read16 = ssb_pcmcia_read16,
150 .read32 = ssb_pcmcia_read32,
151 + .write8 = ssb_pcmcia_write8,
152 .write16 = ssb_pcmcia_write16,
153 .write32 = ssb_pcmcia_write32,
155 --- a/include/linux/ssb/ssb.h
156 +++ b/include/linux/ssb/ssb.h
158 /* Lowlevel read/write operations on the device MMIO.
159 * Internal, don't use that outside of ssb. */
161 + u8 (*read8)(struct ssb_device *dev, u16 offset);
162 u16 (*read16)(struct ssb_device *dev, u16 offset);
163 u32 (*read32)(struct ssb_device *dev, u16 offset);
164 + void (*write8)(struct ssb_device *dev, u16 offset, u8 value);
165 void (*write16)(struct ssb_device *dev, u16 offset, u16 value);
166 void (*write32)(struct ssb_device *dev, u16 offset, u32 value);
171 /* Device MMIO register read/write functions. */
172 +static inline u8 ssb_read8(struct ssb_device *dev, u16 offset)
174 + return dev->ops->read8(dev, offset);
176 static inline u16 ssb_read16(struct ssb_device *dev, u16 offset)
178 return dev->ops->read16(dev, offset);
181 return dev->ops->read32(dev, offset);
183 +static inline void ssb_write8(struct ssb_device *dev, u16 offset, u8 value)
185 + dev->ops->write8(dev, offset, value);
187 static inline void ssb_write16(struct ssb_device *dev, u16 offset, u16 value)
189 dev->ops->write16(dev, offset, value);