aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafał Miłecki <zajec5@gmail.com>2012-07-11 03:23:43 -0400
committerJohn W. Linville <linville@tuxdriver.com>2012-07-12 15:27:18 -0400
commite1ac4b409037b128f9a3eca3b3ab5dbbb71a7e6f (patch)
tree33eb5d7bb0751f17f0968bdd29901df1807797fd
parent97cfda8fecacc40c5652b0924c4c0f5ab508dc9a (diff)
bcma: add trivial GBIT MAC COMMON driver
GMAC COMMON core is present on BCM4706 and is used for example to access board PHYs (PHYs can not be accessed directly using GBIT MAC core). Signed-off-by: Rafał Miłecki <zajec5@gmail.com> Acked-by: Hauke Mehrtens <hauke@hauke-m.de> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/bcma/Kconfig9
-rw-r--r--drivers/bcma/Makefile1
-rw-r--r--drivers/bcma/driver_gmac_cmn.c14
-rw-r--r--drivers/bcma/main.c8
-rw-r--r--drivers/bcma/scan.c16
-rw-r--r--include/linux/bcma/bcma.h2
-rw-r--r--include/linux/bcma/bcma_driver_gmac_cmn.h100
7 files changed, 144 insertions, 6 deletions
diff --git a/drivers/bcma/Kconfig b/drivers/bcma/Kconfig
index fb7c80fb721e..9319cde8d751 100644
--- a/drivers/bcma/Kconfig
+++ b/drivers/bcma/Kconfig
@@ -46,6 +46,15 @@ config BCMA_DRIVER_MIPS
46 46
47 If unsure, say N 47 If unsure, say N
48 48
49config BCMA_DRIVER_GMAC_CMN
50 bool "BCMA Broadcom GBIT MAC COMMON core driver"
51 depends on BCMA
52 help
53 Driver for the Broadcom GBIT MAC COMMON core attached to Broadcom
54 specific Advanced Microcontroller Bus.
55
56 If unsure, say N
57
49config BCMA_DEBUG 58config BCMA_DEBUG
50 bool "BCMA debugging" 59 bool "BCMA debugging"
51 depends on BCMA 60 depends on BCMA
diff --git a/drivers/bcma/Makefile b/drivers/bcma/Makefile
index 82de24e5340c..d13803faf1d6 100644
--- a/drivers/bcma/Makefile
+++ b/drivers/bcma/Makefile
@@ -3,6 +3,7 @@ bcma-y += driver_chipcommon.o driver_chipcommon_pmu.o
3bcma-y += driver_pci.o 3bcma-y += driver_pci.o
4bcma-$(CONFIG_BCMA_DRIVER_PCI_HOSTMODE) += driver_pci_host.o 4bcma-$(CONFIG_BCMA_DRIVER_PCI_HOSTMODE) += driver_pci_host.o
5bcma-$(CONFIG_BCMA_DRIVER_MIPS) += driver_mips.o 5bcma-$(CONFIG_BCMA_DRIVER_MIPS) += driver_mips.o
6bcma-$(CONFIG_BCMA_DRIVER_GMAC_CMN) += driver_gmac_cmn.o
6bcma-$(CONFIG_BCMA_HOST_PCI) += host_pci.o 7bcma-$(CONFIG_BCMA_HOST_PCI) += host_pci.o
7bcma-$(CONFIG_BCMA_HOST_SOC) += host_soc.o 8bcma-$(CONFIG_BCMA_HOST_SOC) += host_soc.o
8obj-$(CONFIG_BCMA) += bcma.o 9obj-$(CONFIG_BCMA) += bcma.o
diff --git a/drivers/bcma/driver_gmac_cmn.c b/drivers/bcma/driver_gmac_cmn.c
new file mode 100644
index 000000000000..834225f65e8f
--- /dev/null
+++ b/drivers/bcma/driver_gmac_cmn.c
@@ -0,0 +1,14 @@
1/*
2 * Broadcom specific AMBA
3 * GBIT MAC COMMON Core
4 *
5 * Licensed under the GNU/GPL. See COPYING for details.
6 */
7
8#include "bcma_private.h"
9#include <linux/bcma/bcma.h>
10
11void __devinit bcma_core_gmac_cmn_init(struct bcma_drv_gmac_cmn *gc)
12{
13 mutex_init(&gc->phy_mutex);
14}
diff --git a/drivers/bcma/main.c b/drivers/bcma/main.c
index 151bddc57e16..758af9ccdef0 100644
--- a/drivers/bcma/main.c
+++ b/drivers/bcma/main.c
@@ -103,6 +103,7 @@ static int bcma_register_cores(struct bcma_bus *bus)
103 case BCMA_CORE_PCI: 103 case BCMA_CORE_PCI:
104 case BCMA_CORE_PCIE: 104 case BCMA_CORE_PCIE:
105 case BCMA_CORE_MIPS_74K: 105 case BCMA_CORE_MIPS_74K:
106 case BCMA_CORE_4706_MAC_GBIT_COMMON:
106 continue; 107 continue;
107 } 108 }
108 109
@@ -185,6 +186,13 @@ int __devinit bcma_bus_register(struct bcma_bus *bus)
185 bcma_core_pci_init(&bus->drv_pci); 186 bcma_core_pci_init(&bus->drv_pci);
186 } 187 }
187 188
189 /* Init GBIT MAC COMMON core */
190 core = bcma_find_core(bus, BCMA_CORE_4706_MAC_GBIT_COMMON);
191 if (core) {
192 bus->drv_gmac_cmn.core = core;
193 bcma_core_gmac_cmn_init(&bus->drv_gmac_cmn);
194 }
195
188 /* Try to get SPROM */ 196 /* Try to get SPROM */
189 err = bcma_sprom_get(bus); 197 err = bcma_sprom_get(bus);
190 if (err == -ENOENT) { 198 if (err == -ENOENT) {
diff --git a/drivers/bcma/scan.c b/drivers/bcma/scan.c
index a0272bbfc4f6..3bc3ec26fd0e 100644
--- a/drivers/bcma/scan.c
+++ b/drivers/bcma/scan.c
@@ -21,6 +21,7 @@ struct bcma_device_id_name {
21}; 21};
22 22
23static const struct bcma_device_id_name bcma_arm_device_names[] = { 23static const struct bcma_device_id_name bcma_arm_device_names[] = {
24 { BCMA_CORE_4706_MAC_GBIT_COMMON, "BCM4706 GBit MAC Common" },
24 { BCMA_CORE_ARM_1176, "ARM 1176" }, 25 { BCMA_CORE_ARM_1176, "ARM 1176" },
25 { BCMA_CORE_ARM_7TDMI, "ARM 7TDMI" }, 26 { BCMA_CORE_ARM_7TDMI, "ARM 7TDMI" },
26 { BCMA_CORE_ARM_CM3, "ARM CM3" }, 27 { BCMA_CORE_ARM_CM3, "ARM CM3" },
@@ -33,7 +34,6 @@ static const struct bcma_device_id_name bcma_bcm_device_names[] = {
33 { BCMA_CORE_4706_MAC_GBIT, "BCM4706 GBit MAC" }, 34 { BCMA_CORE_4706_MAC_GBIT, "BCM4706 GBit MAC" },
34 { BCMA_CORE_AMEMC, "AMEMC (DDR)" }, 35 { BCMA_CORE_AMEMC, "AMEMC (DDR)" },
35 { BCMA_CORE_ALTA, "ALTA (I2S)" }, 36 { BCMA_CORE_ALTA, "ALTA (I2S)" },
36 { BCMA_CORE_4706_MAC_GBIT_COMMON, "BCM4706 GBit MAC Common" },
37 { BCMA_CORE_INVALID, "Invalid" }, 37 { BCMA_CORE_INVALID, "Invalid" },
38 { BCMA_CORE_CHIPCOMMON, "ChipCommon" }, 38 { BCMA_CORE_CHIPCOMMON, "ChipCommon" },
39 { BCMA_CORE_ILINE20, "ILine 20" }, 39 { BCMA_CORE_ILINE20, "ILine 20" },
@@ -295,11 +295,15 @@ static int bcma_get_next_core(struct bcma_bus *bus, u32 __iomem **eromptr,
295 295
296 /* check if component is a core at all */ 296 /* check if component is a core at all */
297 if (wrappers[0] + wrappers[1] == 0) { 297 if (wrappers[0] + wrappers[1] == 0) {
298 /* we could save addrl of the router 298 /* Some specific cores don't need wrappers */
299 if (cid == BCMA_CORE_OOB_ROUTER) 299 switch (core->id.id) {
300 */ 300 case BCMA_CORE_4706_MAC_GBIT_COMMON:
301 bcma_erom_skip_component(bus, eromptr); 301 /* Not used yet: case BCMA_CORE_OOB_ROUTER: */
302 return -ENXIO; 302 break;
303 default:
304 bcma_erom_skip_component(bus, eromptr);
305 return -ENXIO;
306 }
303 } 307 }
304 308
305 if (bcma_erom_is_bridge(bus, eromptr)) { 309 if (bcma_erom_is_bridge(bus, eromptr)) {
diff --git a/include/linux/bcma/bcma.h b/include/linux/bcma/bcma.h
index 03b2f30d2ace..1954a4e305a3 100644
--- a/include/linux/bcma/bcma.h
+++ b/include/linux/bcma/bcma.h
@@ -7,6 +7,7 @@
7#include <linux/bcma/bcma_driver_chipcommon.h> 7#include <linux/bcma/bcma_driver_chipcommon.h>
8#include <linux/bcma/bcma_driver_pci.h> 8#include <linux/bcma/bcma_driver_pci.h>
9#include <linux/bcma/bcma_driver_mips.h> 9#include <linux/bcma/bcma_driver_mips.h>
10#include <linux/bcma/bcma_driver_gmac_cmn.h>
10#include <linux/ssb/ssb.h> /* SPROM sharing */ 11#include <linux/ssb/ssb.h> /* SPROM sharing */
11 12
12#include "bcma_regs.h" 13#include "bcma_regs.h"
@@ -252,6 +253,7 @@ struct bcma_bus {
252 struct bcma_drv_cc drv_cc; 253 struct bcma_drv_cc drv_cc;
253 struct bcma_drv_pci drv_pci; 254 struct bcma_drv_pci drv_pci;
254 struct bcma_drv_mips drv_mips; 255 struct bcma_drv_mips drv_mips;
256 struct bcma_drv_gmac_cmn drv_gmac_cmn;
255 257
256 /* We decided to share SPROM struct with SSB as long as we do not need 258 /* We decided to share SPROM struct with SSB as long as we do not need
257 * any hacks for BCMA. This simplifies drivers code. */ 259 * any hacks for BCMA. This simplifies drivers code. */
diff --git a/include/linux/bcma/bcma_driver_gmac_cmn.h b/include/linux/bcma/bcma_driver_gmac_cmn.h
new file mode 100644
index 000000000000..def894b83b0d
--- /dev/null
+++ b/include/linux/bcma/bcma_driver_gmac_cmn.h
@@ -0,0 +1,100 @@
1#ifndef LINUX_BCMA_DRIVER_GMAC_CMN_H_
2#define LINUX_BCMA_DRIVER_GMAC_CMN_H_
3
4#include <linux/types.h>
5
6#define BCMA_GMAC_CMN_STAG0 0x000
7#define BCMA_GMAC_CMN_STAG1 0x004
8#define BCMA_GMAC_CMN_STAG2 0x008
9#define BCMA_GMAC_CMN_STAG3 0x00C
10#define BCMA_GMAC_CMN_PARSER_CTL 0x020
11#define BCMA_GMAC_CMN_MIB_MAX_LEN 0x024
12#define BCMA_GMAC_CMN_PHY_ACCESS 0x100
13#define BCMA_GMAC_CMN_PA_DATA_MASK 0x0000ffff
14#define BCMA_GMAC_CMN_PA_ADDR_MASK 0x001f0000
15#define BCMA_GMAC_CMN_PA_ADDR_SHIFT 16
16#define BCMA_GMAC_CMN_PA_REG_MASK 0x1f000000
17#define BCMA_GMAC_CMN_PA_REG_SHIFT 24
18#define BCMA_GMAC_CMN_PA_WRITE 0x20000000
19#define BCMA_GMAC_CMN_PA_START 0x40000000
20#define BCMA_GMAC_CMN_PHY_CTL 0x104
21#define BCMA_GMAC_CMN_PC_EPA_MASK 0x0000001f
22#define BCMA_GMAC_CMN_PC_MCT_MASK 0x007f0000
23#define BCMA_GMAC_CMN_PC_MCT_SHIFT 16
24#define BCMA_GMAC_CMN_PC_MTE 0x00800000
25#define BCMA_GMAC_CMN_GMAC0_RGMII_CTL 0x110
26#define BCMA_GMAC_CMN_CFP_ACCESS 0x200
27#define BCMA_GMAC_CMN_CFP_TCAM_DATA0 0x210
28#define BCMA_GMAC_CMN_CFP_TCAM_DATA1 0x214
29#define BCMA_GMAC_CMN_CFP_TCAM_DATA2 0x218
30#define BCMA_GMAC_CMN_CFP_TCAM_DATA3 0x21C
31#define BCMA_GMAC_CMN_CFP_TCAM_DATA4 0x220
32#define BCMA_GMAC_CMN_CFP_TCAM_DATA5 0x224
33#define BCMA_GMAC_CMN_CFP_TCAM_DATA6 0x228
34#define BCMA_GMAC_CMN_CFP_TCAM_DATA7 0x22C
35#define BCMA_GMAC_CMN_CFP_TCAM_MASK0 0x230
36#define BCMA_GMAC_CMN_CFP_TCAM_MASK1 0x234
37#define BCMA_GMAC_CMN_CFP_TCAM_MASK2 0x238
38#define BCMA_GMAC_CMN_CFP_TCAM_MASK3 0x23C
39#define BCMA_GMAC_CMN_CFP_TCAM_MASK4 0x240
40#define BCMA_GMAC_CMN_CFP_TCAM_MASK5 0x244
41#define BCMA_GMAC_CMN_CFP_TCAM_MASK6 0x248
42#define BCMA_GMAC_CMN_CFP_TCAM_MASK7 0x24C
43#define BCMA_GMAC_CMN_CFP_ACTION_DATA 0x250
44#define BCMA_GMAC_CMN_TCAM_BIST_CTL 0x2A0
45#define BCMA_GMAC_CMN_TCAM_BIST_STATUS 0x2A4
46#define BCMA_GMAC_CMN_TCAM_CMP_STATUS 0x2A8
47#define BCMA_GMAC_CMN_TCAM_DISABLE 0x2AC
48#define BCMA_GMAC_CMN_TCAM_TEST_CTL 0x2F0
49#define BCMA_GMAC_CMN_UDF_0_A3_A0 0x300
50#define BCMA_GMAC_CMN_UDF_0_A7_A4 0x304
51#define BCMA_GMAC_CMN_UDF_0_A8 0x308
52#define BCMA_GMAC_CMN_UDF_1_A3_A0 0x310
53#define BCMA_GMAC_CMN_UDF_1_A7_A4 0x314
54#define BCMA_GMAC_CMN_UDF_1_A8 0x318
55#define BCMA_GMAC_CMN_UDF_2_A3_A0 0x320
56#define BCMA_GMAC_CMN_UDF_2_A7_A4 0x324
57#define BCMA_GMAC_CMN_UDF_2_A8 0x328
58#define BCMA_GMAC_CMN_UDF_0_B3_B0 0x330
59#define BCMA_GMAC_CMN_UDF_0_B7_B4 0x334
60#define BCMA_GMAC_CMN_UDF_0_B8 0x338
61#define BCMA_GMAC_CMN_UDF_1_B3_B0 0x340
62#define BCMA_GMAC_CMN_UDF_1_B7_B4 0x344
63#define BCMA_GMAC_CMN_UDF_1_B8 0x348
64#define BCMA_GMAC_CMN_UDF_2_B3_B0 0x350
65#define BCMA_GMAC_CMN_UDF_2_B7_B4 0x354
66#define BCMA_GMAC_CMN_UDF_2_B8 0x358
67#define BCMA_GMAC_CMN_UDF_0_C3_C0 0x360
68#define BCMA_GMAC_CMN_UDF_0_C7_C4 0x364
69#define BCMA_GMAC_CMN_UDF_0_C8 0x368
70#define BCMA_GMAC_CMN_UDF_1_C3_C0 0x370
71#define BCMA_GMAC_CMN_UDF_1_C7_C4 0x374
72#define BCMA_GMAC_CMN_UDF_1_C8 0x378
73#define BCMA_GMAC_CMN_UDF_2_C3_C0 0x380
74#define BCMA_GMAC_CMN_UDF_2_C7_C4 0x384
75#define BCMA_GMAC_CMN_UDF_2_C8 0x388
76#define BCMA_GMAC_CMN_UDF_0_D3_D0 0x390
77#define BCMA_GMAC_CMN_UDF_0_D7_D4 0x394
78#define BCMA_GMAC_CMN_UDF_0_D11_D8 0x394
79
80struct bcma_drv_gmac_cmn {
81 struct bcma_device *core;
82
83 /* Drivers accessing BCMA_GMAC_CMN_PHY_ACCESS and
84 * BCMA_GMAC_CMN_PHY_CTL need to take that mutex first. */
85 struct mutex phy_mutex;
86};
87
88/* Register access */
89#define gmac_cmn_read16(gc, offset) bcma_read16((gc)->core, offset)
90#define gmac_cmn_read32(gc, offset) bcma_read32((gc)->core, offset)
91#define gmac_cmn_write16(gc, offset, val) bcma_write16((gc)->core, offset, val)
92#define gmac_cmn_write32(gc, offset, val) bcma_write32((gc)->core, offset, val)
93
94#ifdef CONFIG_BCMA_DRIVER_GMAC_CMN
95extern void __devinit bcma_core_gmac_cmn_init(struct bcma_drv_gmac_cmn *gc);
96#else
97static inline void bcma_core_gmac_cmn_init(struct bcma_drv_gmac_cmn *gc) { }
98#endif
99
100#endif /* LINUX_BCMA_DRIVER_GMAC_CMN_H_ */