#ifndef __ASM_SYSTEM_H #define __ASM_SYSTEM_H #include #include /* Clear and set 'TS' bit respectively */ #define clts() __asm__ __volatile__ ("clts") #define stts() write_cr0(X86_CR0_TS|read_cr0()) #define wbinvd() \ __asm__ __volatile__ ("wbinvd": : :"memory"); #define nop() __asm__ __volatile__ ("nop") #define xchg(ptr,v) ((__typeof__(*(ptr)))__xchg((unsigned long)(v),(ptr),sizeof(*(ptr)))) struct __xchg_dummy { unsigned long a[100]; }; #define __xg(x) ((struct __xchg_dummy *)(x)) /* * Note: no "lock" prefix even on SMP: xchg always implies lock anyway * Note 2: xchg has side effect, so that attribute volatile is necessary, * but generally the primitive is invalid, *ptr is output argument. --ANK */ static always_inline unsigned long __xchg(unsigned long x, volatile void * ptr, int size) { switch (size) { case 1: __asm__ __volatile__("xchgb %b0,%1" :"=q" (x) :"m" (*__xg((volatile void *)ptr)), "0" (x) :"memory"); break; case 2: __asm__ __volatile__("xchgw %w0,%1" :"=r" (x) :"m" (*__xg((volatile void *)ptr)), "0" (x) :"memory"); break; #if defined(__i386__) case 4: __asm__ __volatile__("xchgl %0,%1" :"=r" (x) :"m" (*__xg((volatile void *)ptr)), "0" (x) :"memory"); break; #elif defined(__x86_64__) case 4: __asm__ __volatile__("xchgl %k0,%1" :"=r" (x) :"m" (*__xg((volatile void *)ptr)), "0" (x) :"memory"); break; case 8: __asm__ __volatile__("xchgq %0,%1" :"=r" (x) :"m" (*__xg((volatile void *)ptr)), "0" (x) :"memory"); break; #endif } return x; } /* * Atomic compare and exchange. Compare OLD with MEM, if identical, * store NEW in MEM. Return the initial value in MEM. Success is * indicated by comparing RETURN with OLD. */ static always_inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size) { unsigned long prev; switch (size) { case 1: __asm__ __volatile__(LOCK_PREFIX "cmpxchgb %b1,%2" : "=a"(prev) : "q"(new), "m"(*__xg((volatile void *)ptr)), "0"(old) : "memory"); return prev; case 2: __asm__ __volatile__(LOCK_PREFIX "cmpxchgw %w1,%2" : "=a"(prev) : "r"(new), "m"(*__xg((volatile void *)ptr)), "0"(old) : "memory"); return prev; #if defined(__i386__) case 4: __asm__ __volatile__(LOCK_PREFIX "cmpxchgl %1,%2" : "=a"(prev) : "r"(new), "m"(*__xg((volatile void *)ptr)), "0"(old) : "memory"); return prev; #elif defined(__x86_64__) case 4: __asm__ __volatile__(LOCK_PREFIX "cmpxchgl %k1,%2" : "=a"(prev) : "r"(new), "m"(*__xg((volatile void *)ptr)), "0"(old) : "memory"); return prev; case 8: __asm__ __volatile__(LOCK_PREFIX "cmpxchgq %1,%2" : "=a"(prev) : "r"(new), "m"(*__xg((volatile void *)ptr)), "0"(old) : "memory"); return prev; #endif } return old; } #define cmpxchg(ptr,o,n)\ ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o),\ (unsigned long)(n),sizeof(*(ptr)))) /* * This function causes value _o to be changed to _n at location _p. * If this access causes a fault then we return 1, otherwise we return 0. * If no fault occurs then _o is updated to the value we saw at _p. If this * is the same as the initial value of _o then _n is written to location _p. */ #ifdef __i386__ #define __cmpxchg_user(_p,_o,_n,_isuff,_oppre,_regtype) \ __asm__ __volatile__ ( \ "1: " LOCK_PREFIX "cmpxchg"_isuff" %"_oppre"2,%3\n" \ "2:\n" \ ".section .fixup,\"ax\"\n" \ "3: movl $1,%1\n" \ " jmp 2b\n" \ ".previous\n" \ ".section __ex_table,\"a\"\n" \ " .align 4\n" \ " .long 1b,3b\n" \ ".previous" \ : "=a" (_o), "=r" (_rc) \ : _regtype (_n), "m" (*__xg((volatile void *)_p)), "0" (_o), "1" (0) \ : "memory"); #define cmpxchg_user(_p,_o,_n) \ ({ \ int _rc; \ switch ( sizeof(*(_p)) ) { \ case 1: \ __cmpxchg_user(_p,_o,_n,"b","b","q"); \ break; \ case 2: \ __cmpxchg_user(_p,_o,_n,"w","w","r"); \ break; \ case 4: \ __cmpxchg_user(_p,_o,_n,"l","","r"); \ break; \ } \ _rc; \ }) #else #define __cmpxchg_user(_p,_o,_n,_isuff,_oppre,_regtype) \ __asm__ __volatile__ ( \ "1: " LOCK_PREFIX "cmpxchg"_isuff" %"_oppre"2,%3\n" \ "2:\n" \ ".section .fixup,\"ax\"\n" \ "3: movl $1,%1\n" \ " jmp 2b\n" \ ".previous\n" \ ".section __ex_table,\"a\"\n" \ " .align 8\n" \ " .quad 1b,3b\n" \ ".previous" \ : "=a" (_o), "=r" (_rc) \ : _regtype (_n), "m" (*__xg((volatile void *)_p)), "0" (_o), "1" (0) \ : "memory"); #define cmpxchg_user(_p,_o,_n) \ ({ \ int _rc; \ switch ( sizeof(*(_p)) ) { \ case 1: \ __cmpxchg_user(_p,_o,_n,"b","b","q"); \ break; \ case 2: \ __cmpxchg_user(_p,_o,_n,"w","w","r"); \ break; \ case 4: \ __cmpxchg_user(_p,_o,_n,"l","k","r"); \ break; \ case 8: \ __cmpxchg_user(_p,_o,_n,"q","","r"); \ break; \ } \ _rc;
--- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
+++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
@@ -12,6 +12,8 @@
 #include <linux/string.h>
 #include <linux/gpio_keys.h>
 #include <linux/input.h>
+#include <linux/platform_device.h>
+#include <linux/rtl8367.h>
 #include <asm/addrspace.h>
 #include <bcm63xx_board.h>
 #include <bcm63xx_cpu.h>
@@ -31,6 +33,9 @@
 #define BCM963XX_KEYS_POLL_INTERVAL	20
 #define BCM963XX_KEYS_DEBOUNCE_INTERVAL	(BCM963XX_KEYS_POLL_INTERVAL * 3)
 
+#define NB6_GPIO_RTL8367_SDA	18
+#define NB6_GPIO_RTL8367_SCK	20
+
 /*
  * known 3368 boards
  */
@@ -1292,6 +1297,69 @@ static struct board_info __initdata boar
 };
 #endif /* CONFIG_BCM63XX_CPU_6358 */
 
+#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,
+	.num_usbh_ports			= 2,
+
+	.has_enetsw			= 1,
+
+	.enetsw = {
+		.used_ports = {
+			[4] = {
+				.used	= 1,
+				.phy_id	= 0xff,
+				.bypass_link = 1,
+				.force_speed = 1000,
+				.force_duplex_full = 1,
+				.name	= "RGMII",
+			},
+		},
+	},
+
+	.devs = nb6_devices,
+	.num_devs = ARRAY_SIZE(nb6_devices),
+};
+#endif /* CONFIG_BCM63XX_CPU_6362 */
+
 /*
  * known 6368 boards
  */
@@ -1443,6 +1511,10 @@ static const struct board_info __initcon
 	&board_DVAG3810BN,
 #endif
 
+#ifdef CONFIG_BCM63XX_CPU_6362
+	&board_nb6,
+#endif
+
 #ifdef CONFIG_BCM63XX_CPU_6368
 	&board_96368mvwg,
 	&board_96368mvngr,
@@ -1511,6 +1583,9 @@ static struct of_device_id const bcm963x
 	{ .compatible = "t-com,spw303v", .data = &board_spw303v, },
 	{ .compatible = "telsey,cpva642", .data = &board_CPVA642, },
 #endif
+#ifdef CONFIG_BCM63XX_CPU_6362
+	{ .compatible = "sfr,nb6-ser-r0", .data = &board_nb6, },
+#endif
 #ifdef CONFIG_BCM63XX_CPU_6368
 	{ .compatible = "brcm,bcm96368mvngr", .data = &board_96368mvngr, },
 	{ .compatible = "brcm,bcm96368mvwg", .data = &board_96368mvwg, },