diff options
author | Michael Buesch <mb@bu3sch.de> | 2007-11-07 13:03:35 -0500 |
---|---|---|
committer | David S. Miller <davem@sunset.davemloft.net> | 2007-11-11 01:01:53 -0500 |
commit | 60d78c4473493674531a1df0772ca9e4d6133a62 (patch) | |
tree | 6aa49f29e15f4d71b05fd2a6dca5db213434671a /drivers | |
parent | d52a60ad389d8aeac162350b19e4303c6cde7f93 (diff) |
ssb: Fix PCMCIA-host lowlevel bus access
This fixes the lowlevel bus access routines for
PCMCIA based devices.
There are still a few issues with register access sideeffects after
this patch. This will be addressed in a later patch.
Signed-off-by: Michael Buesch <mb@bu3sch.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/ssb/main.c | 1 | ||||
-rw-r--r-- | drivers/ssb/pcmcia.c | 56 |
2 files changed, 29 insertions, 28 deletions
diff --git a/drivers/ssb/main.c b/drivers/ssb/main.c index fc1d589dc675..85a20546e827 100644 --- a/drivers/ssb/main.c +++ b/drivers/ssb/main.c | |||
@@ -440,6 +440,7 @@ static int ssb_devices_register(struct ssb_bus *bus) | |||
440 | break; | 440 | break; |
441 | case SSB_BUSTYPE_PCMCIA: | 441 | case SSB_BUSTYPE_PCMCIA: |
442 | #ifdef CONFIG_SSB_PCMCIAHOST | 442 | #ifdef CONFIG_SSB_PCMCIAHOST |
443 | sdev->irq = bus->host_pcmcia->irq.AssignedIRQ; | ||
443 | dev->parent = &bus->host_pcmcia->dev; | 444 | dev->parent = &bus->host_pcmcia->dev; |
444 | #endif | 445 | #endif |
445 | break; | 446 | break; |
diff --git a/drivers/ssb/pcmcia.c b/drivers/ssb/pcmcia.c index b6abee846f02..bb44a76b3eb5 100644 --- a/drivers/ssb/pcmcia.c +++ b/drivers/ssb/pcmcia.c | |||
@@ -63,17 +63,17 @@ int ssb_pcmcia_switch_coreidx(struct ssb_bus *bus, | |||
63 | err = pcmcia_access_configuration_register(pdev, ®); | 63 | err = pcmcia_access_configuration_register(pdev, ®); |
64 | if (err != CS_SUCCESS) | 64 | if (err != CS_SUCCESS) |
65 | goto error; | 65 | goto error; |
66 | read_addr |= (reg.Value & 0xF) << 12; | 66 | read_addr |= ((u32)(reg.Value & 0x0F)) << 12; |
67 | reg.Offset = 0x30; | 67 | reg.Offset = 0x30; |
68 | err = pcmcia_access_configuration_register(pdev, ®); | 68 | err = pcmcia_access_configuration_register(pdev, ®); |
69 | if (err != CS_SUCCESS) | 69 | if (err != CS_SUCCESS) |
70 | goto error; | 70 | goto error; |
71 | read_addr |= reg.Value << 16; | 71 | read_addr |= ((u32)reg.Value) << 16; |
72 | reg.Offset = 0x32; | 72 | reg.Offset = 0x32; |
73 | err = pcmcia_access_configuration_register(pdev, ®); | 73 | err = pcmcia_access_configuration_register(pdev, ®); |
74 | if (err != CS_SUCCESS) | 74 | if (err != CS_SUCCESS) |
75 | goto error; | 75 | goto error; |
76 | read_addr |= reg.Value << 24; | 76 | read_addr |= ((u32)reg.Value) << 24; |
77 | 77 | ||
78 | cur_core = (read_addr - SSB_ENUM_BASE) / SSB_CORE_SIZE; | 78 | cur_core = (read_addr - SSB_ENUM_BASE) / SSB_CORE_SIZE; |
79 | if (cur_core == coreidx) | 79 | if (cur_core == coreidx) |
@@ -152,28 +152,29 @@ error: | |||
152 | goto out_unlock; | 152 | goto out_unlock; |
153 | } | 153 | } |
154 | 154 | ||
155 | /* These are the main device register access functions. | 155 | static int select_core_and_segment(struct ssb_device *dev, |
156 | * do_select_core is inline to have the likely hotpath inline. | 156 | u16 *offset) |
157 | * All unlikely codepaths are out-of-line. */ | ||
158 | static inline int do_select_core(struct ssb_bus *bus, | ||
159 | struct ssb_device *dev, | ||
160 | u16 *offset) | ||
161 | { | 157 | { |
158 | struct ssb_bus *bus = dev->bus; | ||
162 | int err; | 159 | int err; |
163 | u8 need_seg = (*offset >= 0x800) ? 1 : 0; | 160 | u8 need_segment; |
161 | |||
162 | if (*offset >= 0x800) { | ||
163 | *offset -= 0x800; | ||
164 | need_segment = 1; | ||
165 | } else | ||
166 | need_segment = 0; | ||
164 | 167 | ||
165 | if (unlikely(dev != bus->mapped_device)) { | 168 | if (unlikely(dev != bus->mapped_device)) { |
166 | err = ssb_pcmcia_switch_core(bus, dev); | 169 | err = ssb_pcmcia_switch_core(bus, dev); |
167 | if (unlikely(err)) | 170 | if (unlikely(err)) |
168 | return err; | 171 | return err; |
169 | } | 172 | } |
170 | if (unlikely(need_seg != bus->mapped_pcmcia_seg)) { | 173 | if (unlikely(need_segment != bus->mapped_pcmcia_seg)) { |
171 | err = ssb_pcmcia_switch_segment(bus, need_seg); | 174 | err = ssb_pcmcia_switch_segment(bus, need_segment); |
172 | if (unlikely(err)) | 175 | if (unlikely(err)) |
173 | return err; | 176 | return err; |
174 | } | 177 | } |
175 | if (need_seg == 1) | ||
176 | *offset -= 0x800; | ||
177 | 178 | ||
178 | return 0; | 179 | return 0; |
179 | } | 180 | } |
@@ -181,32 +182,31 @@ static inline int do_select_core(struct ssb_bus *bus, | |||
181 | static u16 ssb_pcmcia_read16(struct ssb_device *dev, u16 offset) | 182 | static u16 ssb_pcmcia_read16(struct ssb_device *dev, u16 offset) |
182 | { | 183 | { |
183 | struct ssb_bus *bus = dev->bus; | 184 | struct ssb_bus *bus = dev->bus; |
184 | u16 x; | ||
185 | 185 | ||
186 | if (unlikely(do_select_core(bus, dev, &offset))) | 186 | if (unlikely(select_core_and_segment(dev, &offset))) |
187 | return 0xFFFF; | 187 | return 0xFFFF; |
188 | x = readw(bus->mmio + offset); | ||
189 | 188 | ||
190 | return x; | 189 | return readw(bus->mmio + offset); |
191 | } | 190 | } |
192 | 191 | ||
193 | static u32 ssb_pcmcia_read32(struct ssb_device *dev, u16 offset) | 192 | static u32 ssb_pcmcia_read32(struct ssb_device *dev, u16 offset) |
194 | { | 193 | { |
195 | struct ssb_bus *bus = dev->bus; | 194 | struct ssb_bus *bus = dev->bus; |
196 | u32 x; | 195 | u32 lo, hi; |
197 | 196 | ||
198 | if (unlikely(do_select_core(bus, dev, &offset))) | 197 | if (unlikely(select_core_and_segment(dev, &offset))) |
199 | return 0xFFFFFFFF; | 198 | return 0xFFFFFFFF; |
200 | x = readl(bus->mmio + offset); | 199 | lo = readw(bus->mmio + offset); |
200 | hi = readw(bus->mmio + offset + 2); | ||
201 | 201 | ||
202 | return x; | 202 | return (lo | (hi << 16)); |
203 | } | 203 | } |
204 | 204 | ||
205 | static void ssb_pcmcia_write16(struct ssb_device *dev, u16 offset, u16 value) | 205 | static void ssb_pcmcia_write16(struct ssb_device *dev, u16 offset, u16 value) |
206 | { | 206 | { |
207 | struct ssb_bus *bus = dev->bus; | 207 | struct ssb_bus *bus = dev->bus; |
208 | 208 | ||
209 | if (unlikely(do_select_core(bus, dev, &offset))) | 209 | if (unlikely(select_core_and_segment(dev, &offset))) |
210 | return; | 210 | return; |
211 | writew(value, bus->mmio + offset); | 211 | writew(value, bus->mmio + offset); |
212 | } | 212 | } |
@@ -215,12 +215,12 @@ static void ssb_pcmcia_write32(struct ssb_device *dev, u16 offset, u32 value) | |||
215 | { | 215 | { |
216 | struct ssb_bus *bus = dev->bus; | 216 | struct ssb_bus *bus = dev->bus; |
217 | 217 | ||
218 | if (unlikely(do_select_core(bus, dev, &offset))) | 218 | if (unlikely(select_core_and_segment(dev, &offset))) |
219 | return; | 219 | return; |
220 | readw(bus->mmio + offset); | 220 | writeb((value & 0xFF000000) >> 24, bus->mmio + offset + 3); |
221 | writew(value >> 16, bus->mmio + offset + 2); | 221 | writeb((value & 0x00FF0000) >> 16, bus->mmio + offset + 2); |
222 | readw(bus->mmio + offset); | 222 | writeb((value & 0x0000FF00) >> 8, bus->mmio + offset + 1); |
223 | writew(value, bus->mmio + offset); | 223 | writeb((value & 0x000000FF) >> 0, bus->mmio + offset + 0); |
224 | } | 224 | } |
225 | 225 | ||
226 | /* Not "static", as it's used in main.c */ | 226 | /* Not "static", as it's used in main.c */ |