aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/bcma
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/bcma')
-rw-r--r--drivers/bcma/host_pci.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/drivers/bcma/host_pci.c b/drivers/bcma/host_pci.c
index 1b51d8b7ac80..b0994c0e05dc 100644
--- a/drivers/bcma/host_pci.c
+++ b/drivers/bcma/host_pci.c
@@ -21,48 +21,58 @@ static void bcma_host_pci_switch_core(struct bcma_device *core)
21 pr_debug("Switched to core: 0x%X\n", core->id.id); 21 pr_debug("Switched to core: 0x%X\n", core->id.id);
22} 22}
23 23
24static u8 bcma_host_pci_read8(struct bcma_device *core, u16 offset) 24/* Provides access to the requested core. Returns base offset that has to be
25 * used. It makes use of fixed windows when possible. */
26static u16 bcma_host_pci_provide_access_to_core(struct bcma_device *core)
25{ 27{
28 switch (core->id.id) {
29 case BCMA_CORE_CHIPCOMMON:
30 return 3 * BCMA_CORE_SIZE;
31 case BCMA_CORE_PCIE:
32 return 2 * BCMA_CORE_SIZE;
33 }
34
26 if (core->bus->mapped_core != core) 35 if (core->bus->mapped_core != core)
27 bcma_host_pci_switch_core(core); 36 bcma_host_pci_switch_core(core);
37 return 0;
38}
39
40static u8 bcma_host_pci_read8(struct bcma_device *core, u16 offset)
41{
42 offset += bcma_host_pci_provide_access_to_core(core);
28 return ioread8(core->bus->mmio + offset); 43 return ioread8(core->bus->mmio + offset);
29} 44}
30 45
31static u16 bcma_host_pci_read16(struct bcma_device *core, u16 offset) 46static u16 bcma_host_pci_read16(struct bcma_device *core, u16 offset)
32{ 47{
33 if (core->bus->mapped_core != core) 48 offset += bcma_host_pci_provide_access_to_core(core);
34 bcma_host_pci_switch_core(core);
35 return ioread16(core->bus->mmio + offset); 49 return ioread16(core->bus->mmio + offset);
36} 50}
37 51
38static u32 bcma_host_pci_read32(struct bcma_device *core, u16 offset) 52static u32 bcma_host_pci_read32(struct bcma_device *core, u16 offset)
39{ 53{
40 if (core->bus->mapped_core != core) 54 offset += bcma_host_pci_provide_access_to_core(core);
41 bcma_host_pci_switch_core(core);
42 return ioread32(core->bus->mmio + offset); 55 return ioread32(core->bus->mmio + offset);
43} 56}
44 57
45static void bcma_host_pci_write8(struct bcma_device *core, u16 offset, 58static void bcma_host_pci_write8(struct bcma_device *core, u16 offset,
46 u8 value) 59 u8 value)
47{ 60{
48 if (core->bus->mapped_core != core) 61 offset += bcma_host_pci_provide_access_to_core(core);
49 bcma_host_pci_switch_core(core);
50 iowrite8(value, core->bus->mmio + offset); 62 iowrite8(value, core->bus->mmio + offset);
51} 63}
52 64
53static void bcma_host_pci_write16(struct bcma_device *core, u16 offset, 65static void bcma_host_pci_write16(struct bcma_device *core, u16 offset,
54 u16 value) 66 u16 value)
55{ 67{
56 if (core->bus->mapped_core != core) 68 offset += bcma_host_pci_provide_access_to_core(core);
57 bcma_host_pci_switch_core(core);
58 iowrite16(value, core->bus->mmio + offset); 69 iowrite16(value, core->bus->mmio + offset);
59} 70}
60 71
61static void bcma_host_pci_write32(struct bcma_device *core, u16 offset, 72static void bcma_host_pci_write32(struct bcma_device *core, u16 offset,
62 u32 value) 73 u32 value)
63{ 74{
64 if (core->bus->mapped_core != core) 75 offset += bcma_host_pci_provide_access_to_core(core);
65 bcma_host_pci_switch_core(core);
66 iowrite32(value, core->bus->mmio + offset); 76 iowrite32(value, core->bus->mmio + offset);
67} 77}
68 78