From a07db05063b86707021be69f3f33ee4dfa694ff1 Mon Sep 17 00:00:00 2001
From: jogo <jogo@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Date: Tue, 31 Jul 2012 14:27:47 +0000
Subject: bcm63xx: Add nb6 support (BCM6362 SoC base boards)

Signed-off-by: Miguel GAIO <miguel.gaio@efixo.com>
Signed-off-by: Jonas Gorski <jonas.gorski+openwrt@gmail.com>
[jonas.gorski@gmail.com: add network config for nb6, make switch fix a
platform patch]

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@32924 3c298f89-4303-0410-b956-a3cf2f4a3e73
---
 .../brcm63xx/base-files/etc/uci-defaults/network   |   1 +
 target/linux/brcm63xx/base-files/lib/brcm63xx.sh   |   4 +
 target/linux/brcm63xx/config-3.3                   |   4 +-
 target/linux/brcm63xx/image/Makefile               |   2 +
 .../linux/brcm63xx/patches-3.3/528-board_nb6.patch | 146 +++++++++++++++++++++
 .../patches-3.3/550-alice_gate2_leds.patch         |   2 +-
 .../brcm63xx/patches-3.3/551-96348gw_a_leds.patch  |   2 +-
 .../552-board_96348gw-10_reset_button.patch        |   2 +-
 .../801-ssb_export_fallback_sprom.patch            |   4 +-
 .../802-rtl8367r_fix_RGMII_support.patch           |  30 +++++
 10 files changed, 191 insertions(+), 6 deletions(-)
 create mode 100644 target/linux/brcm63xx/patches-3.3/528-board_nb6.patch
 create mode 100644 target/linux/brcm63xx/patches-3.3/802-rtl8367r_fix_RGMII_support.patch

diff --git a/target/linux/brcm63xx/base-files/etc/uci-defaults/network b/target/linux/brcm63xx/base-files/etc/uci-defaults/network
index 10b6e5a1b..53c29ac5a 100755
--- a/target/linux/brcm63xx/base-files/etc/uci-defaults/network
+++ b/target/linux/brcm63xx/base-files/etc/uci-defaults/network
@@ -23,6 +23,7 @@ AW4339U |\
 CPVA642 |\
 CT536_CT5621 |\
 D-4P-W |\
+NB6 |\
 SPW303V |\
 SPW500V |\
 V2110 |\
diff --git a/target/linux/brcm63xx/base-files/lib/brcm63xx.sh b/target/linux/brcm63xx/base-files/lib/brcm63xx.sh
index 5fe0cdc06..11774770d 100755
--- a/target/linux/brcm63xx/base-files/lib/brcm63xx.sh
+++ b/target/linux/brcm63xx/base-files/lib/brcm63xx.sh
@@ -82,6 +82,10 @@ brcm63xx_detect() {
 		brcm63xx_has_reset_button="true"
 		ifname=eth0
 		;;
+	NB6)
+		brcm63xx_has_reset_button="true"
+		ifname=eth0
+		;;
 	*)
 		;;
 	esac
diff --git a/target/linux/brcm63xx/config-3.3 b/target/linux/brcm63xx/config-3.3
index c8adb6870..f8cf4869c 100644
--- a/target/linux/brcm63xx/config-3.3
+++ b/target/linux/brcm63xx/config-3.3
@@ -11,7 +11,7 @@ CONFIG_BCM63XX_CPU_6338=y
 CONFIG_BCM63XX_CPU_6345=y
 CONFIG_BCM63XX_CPU_6348=y
 CONFIG_BCM63XX_CPU_6358=y
-# CONFIG_BCM63XX_CPU_6362 is not set
+CONFIG_BCM63XX_CPU_6362=y
 CONFIG_BCM63XX_CPU_6368=y
 CONFIG_BCM63XX_ENET=y
 CONFIG_BCM63XX_PHY=y
@@ -120,6 +120,8 @@ CONFIG_PCIEPORTBUS=y
 CONFIG_PCI_DOMAINS=y
 CONFIG_PERF_USE_VMALLOC=y
 CONFIG_PHYLIB=y
+CONFIG_RTL8366_SMI=y
+CONFIG_RTL8367_PHY=y
 CONFIG_POSIX_MQUEUE=y
 CONFIG_POSIX_MQUEUE_SYSCTL=y
 # CONFIG_PREEMPT_RCU is not set
diff --git a/target/linux/brcm63xx/image/Makefile b/target/linux/brcm63xx/image/Makefile
index 06d5a82f8..af5a68c82 100644
--- a/target/linux/brcm63xx/image/Makefile
+++ b/target/linux/brcm63xx/image/Makefile
@@ -191,6 +191,8 @@ define Image/Build
 	$(call Image/Build/CFEFIXUP,$(1),96348GW,GW6200,6348,GW6200,$(shell printf '\x99'))
 	# Neufbox4
 	$(call Image/Build/CFE,$(1),96358VW,6358,NEUFBOX4,OpenWRT-$(REVISION))
+	# Neufbox6
+	$(call Image/Build/CFE,$(1),NB6-SER-r0,6362,NEUFBOX6,OpenWRT-$(REVISION))
 	# Comtrend 6373
 	$(call Image/Build/CFE,$(1),CT6373-1,6358,CT6373)
 	# Comtrend 536, 5621
diff --git a/target/linux/brcm63xx/patches-3.3/528-board_nb6.patch b/target/linux/brcm63xx/patches-3.3/528-board_nb6.patch
new file mode 100644
index 000000000..f178efdc0
--- /dev/null
+++ b/target/linux/brcm63xx/patches-3.3/528-board_nb6.patch
@@ -0,0 +1,146 @@
+--- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
++++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
+@@ -17,6 +17,7 @@
+ #include <linux/spi/spi.h>
+ #include <linux/spi/spi_gpio.h>
+ #include <linux/spi/74x164.h>
++#include <linux/rtl8367.h>
+ #include <asm/addrspace.h>
+ #include <bcm63xx_board.h>
+ #include <bcm63xx_cpu.h>
+@@ -50,6 +51,8 @@
+ #define NB4_SPI_GPIO_MOSI	7
+ #define NB4_SPI_GPIO_CLK	6
+ #define NB4_74HC64_GPIO(X)	(NB4_74X164_GPIO_BASE + (X))
++#define NB6_GPIO_RTL8367_SDA	18
++#define NB6_GPIO_RTL8367_SCK	20
+ 
+ #define CT6373_PID_OFFSET		0xff80
+ #define CT6373_74X164_GPIO_BASE	64
+@@ -2489,6 +2492,103 @@ static struct board_info __initdata boar
+ };
+ #endif
+ 
++#ifdef CONFIG_BCM63XX_CPU_6362
++static struct rtl8367_extif_config nb6_rtl8367_extif0_cfg = {
++	.mode = RTL8367_EXTIF_MODE_RGMII,
++	.txdelay = 1,
++	.rxdelay = 5,
++	.ability = {
++		.force_mode = 1,
++		.txpause = 1,
++		.rxpause = 1,
++		.link = 1,
++		.duplex = 1,
++		.speed = RTL8367_PORT_SPEED_1000,
++	},
++};
++
++static struct rtl8367_platform_data nb6_rtl8367_data = {
++	.gpio_sda	= NB6_GPIO_RTL8367_SDA,
++	.gpio_sck	= NB6_GPIO_RTL8367_SCK,
++	.extif0_cfg	= &nb6_rtl8367_extif0_cfg,
++};
++
++static struct platform_device nb6_rtl8367_device = {
++	.name		= RTL8367_DRIVER_NAME,
++	.id		= -1,
++	.dev = {
++		.platform_data	= &nb6_rtl8367_data,
++	}
++};
++
++static struct platform_device * __initdata nb6_devices[] = {
++	&nb6_rtl8367_device,
++};
++
++static struct board_info __initdata board_nb6 = {
++	.name				= "NB6",
++	.expected_cpu_id		= 0x6362,
++
++	.has_uart0			= 1,
++
++	.has_ohci0			= 1,
++	.has_ehci0			= 1,
++
++	.has_enetsw			= 1,
++
++	.enetsw = {
++		.used_ports = {
++			[4] = {
++				.used	= 1,
++				.phy_id	= 0xff,
++				.bypass_link = 1,
++				.force_speed = 1000,
++				.force_duplex_full = 1,
++				.name	= "RGMII",
++			},
++		},
++	},
++
++	.buttons = {
++		{
++			.desc		= "reset",
++			.gpio		= 24,
++			.type		= EV_KEY,
++			.code		= KEY_RESTART,
++			.debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
++			.active_low	= 1,
++		},
++		{
++			.desc		= "wps",
++			.gpio		= 25,
++			.type		= EV_KEY,
++			.code		= KEY_WPS_BUTTON,
++			.debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
++			.active_low	= 1,
++		},
++		{
++			.desc		= "wlan",
++			.gpio		= 12,
++			.type		= EV_KEY,
++			.code		= KEY_WLAN,
++			.debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
++			.active_low	= 1,
++		},
++		{
++			.desc		= "service",
++			.gpio		= 10,
++			.type		= EV_KEY,
++			.code		= BTN_0,
++			.debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
++			.active_low	= 1,
++		},
++	},
++
++	.devs = nb6_devices,
++	.num_devs = ARRAY_SIZE(nb6_devices),
++};
++#endif
++
+ /*
+  * known 6368 boards
+  */
+@@ -2685,6 +2785,10 @@ static const struct board_info __initdat
+ 	&board_DVAG3810BN,
+ #endif
+ 
++#ifdef CONFIG_BCM63XX_CPU_6362
++	&board_nb6,
++#endif
++
+ #ifdef CONFIG_BCM63XX_CPU_6368
+ 	&board_96368mvwg,
+ 	&board_96368mvngr,
+@@ -2759,6 +2863,11 @@ static void __init boardid_fixup(u8 *boo
+ 	struct bcm_tag *tag = (struct bcm_tag *)(boot_addr + CFE_OFFSET_64K);
+ 	char *board_name = (char *)bcm63xx_nvram_get_name();
+ 
++	if (BCMCPU_IS_6362() && (!strncmp(board_name, "NB6-", sizeof("NB6-") - 1))) {
++		board_name[sizeof("NB6") - 1] = '\0';
++		return ;
++	}
++
+ 	/* check if bcm_tag is at 64k offset */
+ 	if (strncmp(board_name, tag->boardid, BOARDID_LEN) != 0) {
+ 		/* else try 128k */
diff --git a/target/linux/brcm63xx/patches-3.3/550-alice_gate2_leds.patch b/target/linux/brcm63xx/patches-3.3/550-alice_gate2_leds.patch
index ebf6f6542..c25aafd8d 100644
--- a/target/linux/brcm63xx/patches-3.3/550-alice_gate2_leds.patch
+++ b/target/linux/brcm63xx/patches-3.3/550-alice_gate2_leds.patch
@@ -1,6 +1,6 @@
 --- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
 +++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
-@@ -1609,6 +1609,98 @@ static struct board_info __initdata boar
+@@ -1612,6 +1612,98 @@ static struct board_info __initdata boar
  
  	.has_ohci0 = 1,
  	.has_ehci0 = 1,
diff --git a/target/linux/brcm63xx/patches-3.3/551-96348gw_a_leds.patch b/target/linux/brcm63xx/patches-3.3/551-96348gw_a_leds.patch
index 02938c3ee..816e8164c 100644
--- a/target/linux/brcm63xx/patches-3.3/551-96348gw_a_leds.patch
+++ b/target/linux/brcm63xx/patches-3.3/551-96348gw_a_leds.patch
@@ -1,6 +1,6 @@
 --- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
 +++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
-@@ -1066,6 +1066,19 @@ static struct board_info __initdata boar
+@@ -1069,6 +1069,19 @@ static struct board_info __initdata boar
  	},
  
  	.has_ohci0 = 1,
diff --git a/target/linux/brcm63xx/patches-3.3/552-board_96348gw-10_reset_button.patch b/target/linux/brcm63xx/patches-3.3/552-board_96348gw-10_reset_button.patch
index 0a464c8d5..3c0fe8b9d 100644
--- a/target/linux/brcm63xx/patches-3.3/552-board_96348gw-10_reset_button.patch
+++ b/target/linux/brcm63xx/patches-3.3/552-board_96348gw-10_reset_button.patch
@@ -1,6 +1,6 @@
 --- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
 +++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
-@@ -583,6 +583,17 @@ static struct board_info __initdata boar
+@@ -586,6 +586,17 @@ static struct board_info __initdata boar
  			.active_low	= 1,
  		},
  	},
diff --git a/target/linux/brcm63xx/patches-3.3/801-ssb_export_fallback_sprom.patch b/target/linux/brcm63xx/patches-3.3/801-ssb_export_fallback_sprom.patch
index 3802cfce5..ca6e5aa28 100644
--- a/target/linux/brcm63xx/patches-3.3/801-ssb_export_fallback_sprom.patch
+++ b/target/linux/brcm63xx/patches-3.3/801-ssb_export_fallback_sprom.patch
@@ -8,7 +8,7 @@
  #include <linux/spi/spi.h>
  #include <linux/spi/spi_gpio.h>
  #include <linux/spi/74x164.h>
-@@ -2829,7 +2830,7 @@ static void __init nb4_nvram_fixup(void)
+@@ -2933,7 +2934,7 @@ static void __init nb4_nvram_fixup(void)
   * bcm4318 WLAN work
   */
  #ifdef CONFIG_SSB_PCIHOST
@@ -17,7 +17,7 @@
  	.revision		= 0x02,
  	.board_rev		= 0x17,
  	.country_code		= 0x0,
-@@ -2849,6 +2850,7 @@ static struct ssb_sprom bcm63xx_sprom =
+@@ -2953,6 +2954,7 @@ static struct ssb_sprom bcm63xx_sprom =
  	.boardflags_lo		= 0x2848,
  	.boardflags_hi		= 0x0000,
  };
diff --git a/target/linux/brcm63xx/patches-3.3/802-rtl8367r_fix_RGMII_support.patch b/target/linux/brcm63xx/patches-3.3/802-rtl8367r_fix_RGMII_support.patch
new file mode 100644
index 000000000..285f3f744
--- /dev/null
+++ b/target/linux/brcm63xx/patches-3.3/802-rtl8367r_fix_RGMII_support.patch
@@ -0,0 +1,30 @@
+From e3208e6087642b95a5bab3101fc9c6e34892c861 Mon Sep 17 00:00:00 2001
+From: Miguel GAIO <miguel.gaio@efixo.com>
+Date: Fri, 6 Jul 2012 14:12:33 +0200
+Subject: [PATCH 6/8] * [rtl8367r] Fix RGMII support
+
+---
+ drivers/net/phy/rtl8367.c  |    5 +++++
+ 1 files changed, 5 insertions(+), 0 deletions(-)
+
+--- a/drivers/net/phy/rtl8367.c
++++ b/drivers/net/phy/rtl8367.c
+@@ -144,6 +144,10 @@
+ #define   RTL8367_EXT_RGMXF_TXDELAY_MASK	1
+ #define   RTL8367_EXT_RGMXF_RXDELAY_MASK	0x7
+ 
++#define RTL8367_PHY_AD_REG			0x130f
++#define    RTL8370_PHY_AD_DUMMY_1_OFFSET	5
++#define    RTL8370_PHY_AD_DUMMY_1_MASK		0xe0
++
+ #define RTL8367_DI_FORCE_REG(_x)		(0x1310 + (_x))
+ #define   RTL8367_DI_FORCE_MODE			BIT(12)
+ #define   RTL8367_DI_FORCE_NWAY			BIT(7)
+@@ -892,6 +896,7 @@ static int rtl8367_extif_set_mode(struct
+ 	case RTL8367_EXTIF_MODE_RGMII_33V:
+ 		REG_WR(smi, RTL8367_CHIP_DEBUG0_REG, 0x0367);
+ 		REG_WR(smi, RTL8367_CHIP_DEBUG1_REG, 0x7777);
++		REG_RMW(smi, RTL8367_PHY_AD_REG, BIT(5), 0);
+ 		break;
+ 
+ 	case RTL8367_EXTIF_MODE_TMII_MAC:
-- 
cgit v1.2.3