aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/include/asm
diff options
context:
space:
mode:
authorFlorian Fainelli <florian@openwrt.org>2013-06-12 15:53:05 -0400
committerDavid S. Miller <davem@davemloft.net>2013-06-13 20:22:08 -0400
commit3dc6475c0c9e55ac7f053ad6b8b398e779954545 (patch)
treeb0dfa7d618905408e6ed1fe369e263c9fc02170c /arch/mips/include/asm
parentca4ec90b31d1ecf01087c607933cf792057bc8bf (diff)
bcm63xx_enet: add support Broadcom BCM6345 Ethernet
This patch adds support for the Broadcom BCM6345 SoC Ethernet. BCM6345 has a slightly different and older DMA engine which requires the following modifications: - the width of the DMA channels on BCM6345 is 64 bytes vs 16 bytes, which means that the helpers enet_dma{c,s} need to account for this channel width and we can no longer use macros - BCM6345 DMA engine does not have any internal SRAM for transfering buffers - BCM6345 buffer allocation and flow control is not per-channel but global (done in RSET_ENETDMA) - the DMA engine bits are right-shifted by 3 compared to other DMA generations - the DMA enable/interrupt masks are a little different (we need to enabled more bits for 6345) - some register have the same meaning but are offsetted in the ENET_DMAC space so a lookup table is required to return the proper offset The MAC itself is identical and requires no modifications to work. Signed-off-by: Florian Fainelli <florian@openwrt.org> Acked-by: Ralf Baechle <ralf@linux-mips.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'arch/mips/include/asm')
-rw-r--r--arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h3
-rw-r--r--arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_enet.h94
-rw-r--r--arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h43
3 files changed, 131 insertions, 9 deletions
diff --git a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h
index 9981f4f0e42f..e6e65dc7d502 100644
--- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h
+++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_cpu.h
@@ -174,6 +174,7 @@ enum bcm63xx_regs_set {
174#define BCM_6368_RSET_SPI_SIZE 1804 174#define BCM_6368_RSET_SPI_SIZE 1804
175#define RSET_ENET_SIZE 2048 175#define RSET_ENET_SIZE 2048
176#define RSET_ENETDMA_SIZE 256 176#define RSET_ENETDMA_SIZE 256
177#define RSET_6345_ENETDMA_SIZE 64
177#define RSET_ENETDMAC_SIZE(chans) (16 * (chans)) 178#define RSET_ENETDMAC_SIZE(chans) (16 * (chans))
178#define RSET_ENETDMAS_SIZE(chans) (16 * (chans)) 179#define RSET_ENETDMAS_SIZE(chans) (16 * (chans))
179#define RSET_ENETSW_SIZE 65536 180#define RSET_ENETSW_SIZE 65536
@@ -300,7 +301,7 @@ enum bcm63xx_regs_set {
300#define BCM_6345_USBDMA_BASE (0xfffe2800) 301#define BCM_6345_USBDMA_BASE (0xfffe2800)
301#define BCM_6345_ENET0_BASE (0xfffe1800) 302#define BCM_6345_ENET0_BASE (0xfffe1800)
302#define BCM_6345_ENETDMA_BASE (0xfffe2800) 303#define BCM_6345_ENETDMA_BASE (0xfffe2800)
303#define BCM_6345_ENETDMAC_BASE (0xfffe2900) 304#define BCM_6345_ENETDMAC_BASE (0xfffe2840)
304#define BCM_6345_ENETDMAS_BASE (0xfffe2a00) 305#define BCM_6345_ENETDMAS_BASE (0xfffe2a00)
305#define BCM_6345_ENETSW_BASE (0xdeadbeef) 306#define BCM_6345_ENETSW_BASE (0xdeadbeef)
306#define BCM_6345_PCMCIA_BASE (0xfffe2028) 307#define BCM_6345_PCMCIA_BASE (0xfffe2028)
diff --git a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_enet.h b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_enet.h
index 118e3c938841..753953e86242 100644
--- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_enet.h
+++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_dev_enet.h
@@ -4,6 +4,8 @@
4#include <linux/if_ether.h> 4#include <linux/if_ether.h>
5#include <linux/init.h> 5#include <linux/init.h>
6 6
7#include <bcm63xx_regs.h>
8
7/* 9/*
8 * on board ethernet platform data 10 * on board ethernet platform data
9 */ 11 */
@@ -37,6 +39,21 @@ struct bcm63xx_enet_platform_data {
37 int phy_id, int reg), 39 int phy_id, int reg),
38 void (*mii_write)(struct net_device *dev, 40 void (*mii_write)(struct net_device *dev,
39 int phy_id, int reg, int val)); 41 int phy_id, int reg, int val));
42
43 /* DMA channel enable mask */
44 u32 dma_chan_en_mask;
45
46 /* DMA channel interrupt mask */
47 u32 dma_chan_int_mask;
48
49 /* DMA engine has internal SRAM */
50 bool dma_has_sram;
51
52 /* DMA channel register width */
53 unsigned int dma_chan_width;
54
55 /* DMA descriptor shift */
56 unsigned int dma_desc_shift;
40}; 57};
41 58
42/* 59/*
@@ -63,6 +80,18 @@ struct bcm63xx_enetsw_platform_data {
63 char mac_addr[ETH_ALEN]; 80 char mac_addr[ETH_ALEN];
64 int num_ports; 81 int num_ports;
65 struct bcm63xx_enetsw_port used_ports[ENETSW_MAX_PORT]; 82 struct bcm63xx_enetsw_port used_ports[ENETSW_MAX_PORT];
83
84 /* DMA channel enable mask */
85 u32 dma_chan_en_mask;
86
87 /* DMA channel interrupt mask */
88 u32 dma_chan_int_mask;
89
90 /* DMA channel register width */
91 unsigned int dma_chan_width;
92
93 /* DMA engine has internal SRAM */
94 bool dma_has_sram;
66}; 95};
67 96
68int __init bcm63xx_enet_register(int unit, 97int __init bcm63xx_enet_register(int unit,
@@ -70,4 +99,69 @@ int __init bcm63xx_enet_register(int unit,
70 99
71int bcm63xx_enetsw_register(const struct bcm63xx_enetsw_platform_data *pd); 100int bcm63xx_enetsw_register(const struct bcm63xx_enetsw_platform_data *pd);
72 101
102enum bcm63xx_regs_enetdmac {
103 ENETDMAC_CHANCFG,
104 ENETDMAC_IR,
105 ENETDMAC_IRMASK,
106 ENETDMAC_MAXBURST,
107 ENETDMAC_BUFALLOC,
108 ENETDMAC_RSTART,
109 ENETDMAC_FC,
110 ENETDMAC_LEN,
111};
112
113static inline unsigned long bcm63xx_enetdmacreg(enum bcm63xx_regs_enetdmac reg)
114{
115#ifdef BCMCPU_RUNTIME_DETECT
116 extern const unsigned long *bcm63xx_regs_enetdmac;
117
118 return bcm63xx_regs_enetdmac[reg];
119#else
120#ifdef CONFIG_BCM63XX_CPU_6345
121 switch (reg) {
122 case ENETDMAC_CHANCFG:
123 return ENETDMA_6345_CHANCFG_REG;
124 case ENETDMAC_IR:
125 return ENETDMA_6345_IR_REG;
126 case ENETDMAC_IRMASK:
127 return ENETDMA_6345_IRMASK_REG;
128 case ENETDMAC_MAXBURST:
129 return ENETDMA_6345_MAXBURST_REG;
130 case ENETDMAC_BUFALLOC:
131 return ENETDMA_6345_BUFALLOC_REG;
132 case ENETDMAC_RSTART:
133 return ENETDMA_6345_RSTART_REG;
134 case ENETDMAC_FC:
135 return ENETDMA_6345_FC_REG;
136 case ENETDMAC_LEN:
137 return ENETDMA_6345_LEN_REG;
138 }
139#endif
140#if defined(CONFIG_BCM63XX_CPU_6328) || \
141 defined(CONFIG_BCM63XX_CPU_6338) || \
142 defined(CONFIG_BCM63XX_CPU_6348) || \
143 defined(CONFIG_BCM63XX_CPU_6358) || \
144 defined(CONFIG_BCM63XX_CPU_6362) || \
145 defined(CONFIG_BCM63XX_CPU_6368)
146 switch (reg) {
147 case ENETDMAC_CHANCFG:
148 return ENETDMAC_CHANCFG_REG;
149 case ENETDMAC_IR:
150 return ENETDMAC_IR_REG;
151 case ENETDMAC_IRMASK:
152 return ENETDMAC_IRMASK_REG;
153 case ENETDMAC_MAXBURST:
154 return ENETDMAC_MAXBURST_REG;
155 case ENETDMAC_BUFALLOC:
156 case ENETDMAC_RSTART:
157 case ENETDMAC_FC:
158 case ENETDMAC_LEN:
159 return 0;
160 }
161#endif
162#endif
163 return 0;
164}
165
166
73#endif /* ! BCM63XX_DEV_ENET_H_ */ 167#endif /* ! BCM63XX_DEV_ENET_H_ */
diff --git a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h
index 0a2121abb1a6..eff7ca7d12b0 100644
--- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h
+++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h
@@ -727,6 +727,8 @@
727/************************************************************************* 727/*************************************************************************
728 * _REG relative to RSET_ENETDMA 728 * _REG relative to RSET_ENETDMA
729 *************************************************************************/ 729 *************************************************************************/
730#define ENETDMA_CHAN_WIDTH 0x10
731#define ENETDMA_6345_CHAN_WIDTH 0x40
730 732
731/* Controller Configuration Register */ 733/* Controller Configuration Register */
732#define ENETDMA_CFG_REG (0x0) 734#define ENETDMA_CFG_REG (0x0)
@@ -782,31 +784,56 @@
782/* State Ram Word 4 */ 784/* State Ram Word 4 */
783#define ENETDMA_SRAM4_REG(x) (0x20c + (x) * 0x10) 785#define ENETDMA_SRAM4_REG(x) (0x20c + (x) * 0x10)
784 786
787/* Broadcom 6345 ENET DMA definitions */
788#define ENETDMA_6345_CHANCFG_REG (0x00)
789
790#define ENETDMA_6345_MAXBURST_REG (0x40)
791
792#define ENETDMA_6345_RSTART_REG (0x08)
793
794#define ENETDMA_6345_LEN_REG (0x0C)
795
796#define ENETDMA_6345_IR_REG (0x14)
797
798#define ENETDMA_6345_IRMASK_REG (0x18)
799
800#define ENETDMA_6345_FC_REG (0x1C)
801
802#define ENETDMA_6345_BUFALLOC_REG (0x20)
803
804/* Shift down for EOP, SOP and WRAP bits */
805#define ENETDMA_6345_DESC_SHIFT (3)
785 806
786/************************************************************************* 807/*************************************************************************
787 * _REG relative to RSET_ENETDMAC 808 * _REG relative to RSET_ENETDMAC
788 *************************************************************************/ 809 *************************************************************************/
789 810
790/* Channel Configuration register */ 811/* Channel Configuration register */
791#define ENETDMAC_CHANCFG_REG(x) ((x) * 0x10) 812#define ENETDMAC_CHANCFG_REG (0x0)
792#define ENETDMAC_CHANCFG_EN_SHIFT 0 813#define ENETDMAC_CHANCFG_EN_SHIFT 0
793#define ENETDMAC_CHANCFG_EN_MASK (1 << ENETDMAC_CHANCFG_EN_SHIFT) 814#define ENETDMAC_CHANCFG_EN_MASK (1 << ENETDMAC_CHANCFG_EN_SHIFT)
794#define ENETDMAC_CHANCFG_PKTHALT_SHIFT 1 815#define ENETDMAC_CHANCFG_PKTHALT_SHIFT 1
795#define ENETDMAC_CHANCFG_PKTHALT_MASK (1 << ENETDMAC_CHANCFG_PKTHALT_SHIFT) 816#define ENETDMAC_CHANCFG_PKTHALT_MASK (1 << ENETDMAC_CHANCFG_PKTHALT_SHIFT)
796#define ENETDMAC_CHANCFG_BUFHALT_SHIFT 2 817#define ENETDMAC_CHANCFG_BUFHALT_SHIFT 2
797#define ENETDMAC_CHANCFG_BUFHALT_MASK (1 << ENETDMAC_CHANCFG_BUFHALT_SHIFT) 818#define ENETDMAC_CHANCFG_BUFHALT_MASK (1 << ENETDMAC_CHANCFG_BUFHALT_SHIFT)
819#define ENETDMAC_CHANCFG_CHAINING_SHIFT 2
820#define ENETDMAC_CHANCFG_CHAINING_MASK (1 << ENETDMAC_CHANCFG_CHAINING_SHIFT)
821#define ENETDMAC_CHANCFG_WRAP_EN_SHIFT 3
822#define ENETDMAC_CHANCFG_WRAP_EN_MASK (1 << ENETDMAC_CHANCFG_WRAP_EN_SHIFT)
823#define ENETDMAC_CHANCFG_FLOWC_EN_SHIFT 4
824#define ENETDMAC_CHANCFG_FLOWC_EN_MASK (1 << ENETDMAC_CHANCFG_FLOWC_EN_SHIFT)
798 825
799/* Interrupt Control/Status register */ 826/* Interrupt Control/Status register */
800#define ENETDMAC_IR_REG(x) (0x4 + (x) * 0x10) 827#define ENETDMAC_IR_REG (0x4)
801#define ENETDMAC_IR_BUFDONE_MASK (1 << 0) 828#define ENETDMAC_IR_BUFDONE_MASK (1 << 0)
802#define ENETDMAC_IR_PKTDONE_MASK (1 << 1) 829#define ENETDMAC_IR_PKTDONE_MASK (1 << 1)
803#define ENETDMAC_IR_NOTOWNER_MASK (1 << 2) 830#define ENETDMAC_IR_NOTOWNER_MASK (1 << 2)
804 831
805/* Interrupt Mask register */ 832/* Interrupt Mask register */
806#define ENETDMAC_IRMASK_REG(x) (0x8 + (x) * 0x10) 833#define ENETDMAC_IRMASK_REG (0x8)
807 834
808/* Maximum Burst Length */ 835/* Maximum Burst Length */
809#define ENETDMAC_MAXBURST_REG(x) (0xc + (x) * 0x10) 836#define ENETDMAC_MAXBURST_REG (0xc)
810 837
811 838
812/************************************************************************* 839/*************************************************************************
@@ -814,16 +841,16 @@
814 *************************************************************************/ 841 *************************************************************************/
815 842
816/* Ring Start Address register */ 843/* Ring Start Address register */
817#define ENETDMAS_RSTART_REG(x) ((x) * 0x10) 844#define ENETDMAS_RSTART_REG (0x0)
818 845
819/* State Ram Word 2 */ 846/* State Ram Word 2 */
820#define ENETDMAS_SRAM2_REG(x) (0x4 + (x) * 0x10) 847#define ENETDMAS_SRAM2_REG (0x4)
821 848
822/* State Ram Word 3 */ 849/* State Ram Word 3 */
823#define ENETDMAS_SRAM3_REG(x) (0x8 + (x) * 0x10) 850#define ENETDMAS_SRAM3_REG (0x8)
824 851
825/* State Ram Word 4 */ 852/* State Ram Word 4 */
826#define ENETDMAS_SRAM4_REG(x) (0xc + (x) * 0x10) 853#define ENETDMAS_SRAM4_REG (0xc)
827 854
828 855
829/************************************************************************* 856/*************************************************************************