aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ssb
diff options
context:
space:
mode:
authorRafał Miłecki <zajec5@gmail.com>2015-10-25 14:32:42 -0400
committerKalle Valo <kvalo@codeaurora.org>2015-10-28 15:05:21 -0400
commit830c7df46247b44aa46ae276073e2e10727c9e93 (patch)
treeb87ad6e0c83d8af2d6db206fd21d37095c00de0e /drivers/ssb
parent399500da18f7fe79699c0e4f603f8874cecb3898 (diff)
ssb: move functions specific to SoC hosted bus to separated file
This cleans main.c a bit and will allow us to compile SoC related code conditionally in the future. Signed-off-by: Rafał Miłecki <zajec5@gmail.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Diffstat (limited to 'drivers/ssb')
-rw-r--r--drivers/ssb/Makefile1
-rw-r--r--drivers/ssb/host_soc.c173
-rw-r--r--drivers/ssb/main.c162
-rw-r--r--drivers/ssb/ssb_private.h5
4 files changed, 180 insertions, 161 deletions
diff --git a/drivers/ssb/Makefile b/drivers/ssb/Makefile
index 7daa03e34b37..30194c5072f5 100644
--- a/drivers/ssb/Makefile
+++ b/drivers/ssb/Makefile
@@ -7,6 +7,7 @@ ssb-$(CONFIG_SSB_SPROM) += sprom.o
7ssb-$(CONFIG_SSB_PCIHOST) += pci.o pcihost_wrapper.o 7ssb-$(CONFIG_SSB_PCIHOST) += pci.o pcihost_wrapper.o
8ssb-$(CONFIG_SSB_PCMCIAHOST) += pcmcia.o bridge_pcmcia_80211.o 8ssb-$(CONFIG_SSB_PCMCIAHOST) += pcmcia.o bridge_pcmcia_80211.o
9ssb-$(CONFIG_SSB_SDIOHOST) += sdio.o 9ssb-$(CONFIG_SSB_SDIOHOST) += sdio.o
10ssb-y += host_soc.o
10 11
11# built-in drivers 12# built-in drivers
12ssb-y += driver_chipcommon.o 13ssb-y += driver_chipcommon.o
diff --git a/drivers/ssb/host_soc.c b/drivers/ssb/host_soc.c
new file mode 100644
index 000000000000..c809f255af34
--- /dev/null
+++ b/drivers/ssb/host_soc.c
@@ -0,0 +1,173 @@
1/*
2 * Sonics Silicon Backplane SoC host related functions.
3 * Subsystem core
4 *
5 * Copyright 2005, Broadcom Corporation
6 * Copyright 2006, 2007, Michael Buesch <m@bues.ch>
7 *
8 * Licensed under the GNU/GPL. See COPYING for details.
9 */
10
11#include <linux/ssb/ssb.h>
12
13#include "ssb_private.h"
14
15static u8 ssb_host_soc_read8(struct ssb_device *dev, u16 offset)
16{
17 struct ssb_bus *bus = dev->bus;
18
19 offset += dev->core_index * SSB_CORE_SIZE;
20 return readb(bus->mmio + offset);
21}
22
23static u16 ssb_host_soc_read16(struct ssb_device *dev, u16 offset)
24{
25 struct ssb_bus *bus = dev->bus;
26
27 offset += dev->core_index * SSB_CORE_SIZE;
28 return readw(bus->mmio + offset);
29}
30
31static u32 ssb_host_soc_read32(struct ssb_device *dev, u16 offset)
32{
33 struct ssb_bus *bus = dev->bus;
34
35 offset += dev->core_index * SSB_CORE_SIZE;
36 return readl(bus->mmio + offset);
37}
38
39#ifdef CONFIG_SSB_BLOCKIO
40static void ssb_host_soc_block_read(struct ssb_device *dev, void *buffer,
41 size_t count, u16 offset, u8 reg_width)
42{
43 struct ssb_bus *bus = dev->bus;
44 void __iomem *addr;
45
46 offset += dev->core_index * SSB_CORE_SIZE;
47 addr = bus->mmio + offset;
48
49 switch (reg_width) {
50 case sizeof(u8): {
51 u8 *buf = buffer;
52
53 while (count) {
54 *buf = __raw_readb(addr);
55 buf++;
56 count--;
57 }
58 break;
59 }
60 case sizeof(u16): {
61 __le16 *buf = buffer;
62
63 SSB_WARN_ON(count & 1);
64 while (count) {
65 *buf = (__force __le16)__raw_readw(addr);
66 buf++;
67 count -= 2;
68 }
69 break;
70 }
71 case sizeof(u32): {
72 __le32 *buf = buffer;
73
74 SSB_WARN_ON(count & 3);
75 while (count) {
76 *buf = (__force __le32)__raw_readl(addr);
77 buf++;
78 count -= 4;
79 }
80 break;
81 }
82 default:
83 SSB_WARN_ON(1);
84 }
85}
86#endif /* CONFIG_SSB_BLOCKIO */
87
88static void ssb_host_soc_write8(struct ssb_device *dev, u16 offset, u8 value)
89{
90 struct ssb_bus *bus = dev->bus;
91
92 offset += dev->core_index * SSB_CORE_SIZE;
93 writeb(value, bus->mmio + offset);
94}
95
96static void ssb_host_soc_write16(struct ssb_device *dev, u16 offset, u16 value)
97{
98 struct ssb_bus *bus = dev->bus;
99
100 offset += dev->core_index * SSB_CORE_SIZE;
101 writew(value, bus->mmio + offset);
102}
103
104static void ssb_host_soc_write32(struct ssb_device *dev, u16 offset, u32 value)
105{
106 struct ssb_bus *bus = dev->bus;
107
108 offset += dev->core_index * SSB_CORE_SIZE;
109 writel(value, bus->mmio + offset);
110}
111
112#ifdef CONFIG_SSB_BLOCKIO
113static void ssb_host_soc_block_write(struct ssb_device *dev, const void *buffer,
114 size_t count, u16 offset, u8 reg_width)
115{
116 struct ssb_bus *bus = dev->bus;
117 void __iomem *addr;
118
119 offset += dev->core_index * SSB_CORE_SIZE;
120 addr = bus->mmio + offset;
121
122 switch (reg_width) {
123 case sizeof(u8): {
124 const u8 *buf = buffer;
125
126 while (count) {
127 __raw_writeb(*buf, addr);
128 buf++;
129 count--;
130 }
131 break;
132 }
133 case sizeof(u16): {
134 const __le16 *buf = buffer;
135
136 SSB_WARN_ON(count & 1);
137 while (count) {
138 __raw_writew((__force u16)(*buf), addr);
139 buf++;
140 count -= 2;
141 }
142 break;
143 }
144 case sizeof(u32): {
145 const __le32 *buf = buffer;
146
147 SSB_WARN_ON(count & 3);
148 while (count) {
149 __raw_writel((__force u32)(*buf), addr);
150 buf++;
151 count -= 4;
152 }
153 break;
154 }
155 default:
156 SSB_WARN_ON(1);
157 }
158}
159#endif /* CONFIG_SSB_BLOCKIO */
160
161/* Ops for the plain SSB bus without a host-device (no PCI or PCMCIA). */
162const 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
173};
diff --git a/drivers/ssb/main.c b/drivers/ssb/main.c
index 90ec6a048b4c..bea823e824eb 100644
--- a/drivers/ssb/main.c
+++ b/drivers/ssb/main.c
@@ -596,166 +596,6 @@ error:
596 return err; 596 return err;
597} 597}
598 598
599static u8 ssb_ssb_read8(struct ssb_device *dev, u16 offset)
600{
601 struct ssb_bus *bus = dev->bus;
602
603 offset += dev->core_index * SSB_CORE_SIZE;
604 return readb(bus->mmio + offset);
605}
606
607static u16 ssb_ssb_read16(struct ssb_device *dev, u16 offset)
608{
609 struct ssb_bus *bus = dev->bus;
610
611 offset += dev->core_index * SSB_CORE_SIZE;
612 return readw(bus->mmio + offset);
613}
614
615static u32 ssb_ssb_read32(struct ssb_device *dev, u16 offset)
616{
617 struct ssb_bus *bus = dev->bus;
618
619 offset += dev->core_index * SSB_CORE_SIZE;
620 return readl(bus->mmio + offset);
621}
622
623#ifdef CONFIG_SSB_BLOCKIO
624static void ssb_ssb_block_read(struct ssb_device *dev, void *buffer,
625 size_t count, u16 offset, u8 reg_width)
626{
627 struct ssb_bus *bus = dev->bus;
628 void __iomem *addr;
629
630 offset += dev->core_index * SSB_CORE_SIZE;
631 addr = bus->mmio + offset;
632
633 switch (reg_width) {
634 case sizeof(u8): {
635 u8 *buf = buffer;
636
637 while (count) {
638 *buf = __raw_readb(addr);
639 buf++;
640 count--;
641 }
642 break;
643 }
644 case sizeof(u16): {
645 __le16 *buf = buffer;
646
647 SSB_WARN_ON(count & 1);
648 while (count) {
649 *buf = (__force __le16)__raw_readw(addr);
650 buf++;
651 count -= 2;
652 }
653 break;
654 }
655 case sizeof(u32): {
656 __le32 *buf = buffer;
657
658 SSB_WARN_ON(count & 3);
659 while (count) {
660 *buf = (__force __le32)__raw_readl(addr);
661 buf++;
662 count -= 4;
663 }
664 break;
665 }
666 default:
667 SSB_WARN_ON(1);
668 }
669}
670#endif /* CONFIG_SSB_BLOCKIO */
671
672static void ssb_ssb_write8(struct ssb_device *dev, u16 offset, u8 value)
673{
674 struct ssb_bus *bus = dev->bus;
675
676 offset += dev->core_index * SSB_CORE_SIZE;
677 writeb(value, bus->mmio + offset);
678}
679
680static void ssb_ssb_write16(struct ssb_device *dev, u16 offset, u16 value)
681{
682 struct ssb_bus *bus = dev->bus;
683
684 offset += dev->core_index * SSB_CORE_SIZE;
685 writew(value, bus->mmio + offset);
686}
687
688static void ssb_ssb_write32(struct ssb_device *dev, u16 offset, u32 value)
689{
690 struct ssb_bus *bus = dev->bus;
691
692 offset += dev->core_index * SSB_CORE_SIZE;
693 writel(value, bus->mmio + offset);
694}
695
696#ifdef CONFIG_SSB_BLOCKIO
697static void ssb_ssb_block_write(struct ssb_device *dev, const void *buffer,
698 size_t count, u16 offset, u8 reg_width)
699{
700 struct ssb_bus *bus = dev->bus;
701 void __iomem *addr;
702
703 offset += dev->core_index * SSB_CORE_SIZE;
704 addr = bus->mmio + offset;
705
706 switch (reg_width) {
707 case sizeof(u8): {
708 const u8 *buf = buffer;
709
710 while (count) {
711 __raw_writeb(*buf, addr);
712 buf++;
713 count--;
714 }
715 break;
716 }
717 case sizeof(u16): {
718 const __le16 *buf = buffer;
719
720 SSB_WARN_ON(count & 1);
721 while (count) {
722 __raw_writew((__force u16)(*buf), addr);
723 buf++;
724 count -= 2;
725 }
726 break;
727 }
728 case sizeof(u32): {
729 const __le32 *buf = buffer;
730
731 SSB_WARN_ON(count & 3);
732 while (count) {
733 __raw_writel((__force u32)(*buf), addr);
734 buf++;
735 count -= 4;
736 }
737 break;
738 }
739 default:
740 SSB_WARN_ON(1);
741 }
742}
743#endif /* CONFIG_SSB_BLOCKIO */
744
745/* Ops for the plain SSB bus without a host-device (no PCI or PCMCIA). */
746static const struct ssb_bus_ops ssb_ssb_ops = {
747 .read8 = ssb_ssb_read8,
748 .read16 = ssb_ssb_read16,
749 .read32 = ssb_ssb_read32,
750 .write8 = ssb_ssb_write8,
751 .write16 = ssb_ssb_write16,
752 .write32 = ssb_ssb_write32,
753#ifdef CONFIG_SSB_BLOCKIO
754 .block_read = ssb_ssb_block_read,
755 .block_write = ssb_ssb_block_write,
756#endif
757};
758
759static int ssb_fetch_invariants(struct ssb_bus *bus, 599static int ssb_fetch_invariants(struct ssb_bus *bus,
760 ssb_invariants_func_t get_invariants) 600 ssb_invariants_func_t get_invariants)
761{ 601{
@@ -927,7 +767,7 @@ int ssb_bus_ssbbus_register(struct ssb_bus *bus, unsigned long baseaddr,
927 int err; 767 int err;
928 768
929 bus->bustype = SSB_BUSTYPE_SSB; 769 bus->bustype = SSB_BUSTYPE_SSB;
930 bus->ops = &ssb_ssb_ops; 770 bus->ops = &ssb_host_soc_ops;
931 771
932 err = ssb_bus_register(bus, get_invariants, baseaddr); 772 err = ssb_bus_register(bus, get_invariants, baseaddr);
933 if (!err) { 773 if (!err) {
diff --git a/drivers/ssb/ssb_private.h b/drivers/ssb/ssb_private.h
index 93bb8f0195a9..0a756c2519e5 100644
--- a/drivers/ssb/ssb_private.h
+++ b/drivers/ssb/ssb_private.h
@@ -157,6 +157,11 @@ static inline int ssb_sdio_init(struct ssb_bus *bus)
157} 157}
158#endif /* CONFIG_SSB_SDIOHOST */ 158#endif /* CONFIG_SSB_SDIOHOST */
159 159
160/**************************************************
161 * host_soc.c
162 **************************************************/
163
164extern const struct ssb_bus_ops ssb_host_soc_ops;
160 165
161/* scan.c */ 166/* scan.c */
162extern const char *ssb_core_name(u16 coreid); 167extern const char *ssb_core_name(u16 coreid);