[OpenWrt-Devel] [PATCH] [brcm63xx] do not register leds device if no led defined

2012-08-09 Thread Miguel GAIO
Hi all,

This patch does not register gpio-leds device if there no leds defined.

Kind regards,

Miguel
>From 044cdff8a2b6c7cfb600ae88f0d4cc24418da984 Mon Sep 17 00:00:00 2001
From: Miguel GAIO 
Date: Thu, 9 Aug 2012 16:06:12 +0200
Subject: [PATCH]  * [brcm63xx] leds: do not register device if no leds
 defined


Signed-off-by: Miguel GAIO 
---
 target/linux/brcm63xx/patches-3.3/301-led_count.patch |   15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/target/linux/brcm63xx/patches-3.3/301-led_count.patch b/target/linux/brcm63xx/patches-3.3/301-led_count.patch
index 84d57a0..b6c1196 100644
--- a/target/linux/brcm63xx/patches-3.3/301-led_count.patch
+++ b/target/linux/brcm63xx/patches-3.3/301-led_count.patch
@@ -8,19 +8,26 @@
  
  	if (board.has_uart0)
  		bcm63xx_uart_register(0);
-@@ -900,7 +901,11 @@ int __init board_register_devices(void)
+@@ -900,10 +901,16 @@ int __init board_register_devices(void)
  
  	bcm63xx_flash_register();
  
 -	bcm63xx_led_data.num_leds = ARRAY_SIZE(board.leds);
+-	bcm63xx_led_data.leds = board.leds;
 +	/* count number of LEDs defined by this device */
 +	while (led_count < ARRAY_SIZE(board.leds) && board.leds[led_count].name)
 +		led_count++;
 +
-+	bcm63xx_led_data.num_leds = led_count;
- 	bcm63xx_led_data.leds = board.leds;
++	if (led_count) {
++		bcm63xx_led_data.num_leds = led_count;
++		bcm63xx_led_data.leds = board.leds;
  
- 	platform_device_register(&bcm63xx_gpio_leds);
+-	platform_device_register(&bcm63xx_gpio_leds);
++		platform_device_register(&bcm63xx_gpio_leds);
++	}
+ 
+ 	/* count number of BUTTONs defined by this device */
+ 	while (button_count < ARRAY_SIZE(board.buttons) && board.buttons[button_count].desc)
 --- a/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h
 +++ b/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h
 @@ -57,7 +57,7 @@ struct board_info {
-- 
1.7.10.4

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] [brcm63xx] BCM6358 fix enet clk definitions

2012-08-09 Thread Miguel GAIO
Hi all,

This patch fix some enet clock definition.

Kind regards,

Miguel
>From 709941e00d977821b23961899e47d042fb863cf4 Mon Sep 17 00:00:00 2001
From: Miguel GAIO 
Date: Thu, 9 Aug 2012 14:49:48 +0200
Subject: [PATCH]  * [brcm63xx] BCM6358 fix enet MII clk definitions


Signed-off-by: Miguel GAIO 
---
 .../brcm63xx/patches-3.3/408-6358-enet1-external-mii-clk.patch |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/target/linux/brcm63xx/patches-3.3/408-6358-enet1-external-mii-clk.patch b/target/linux/brcm63xx/patches-3.3/408-6358-enet1-external-mii-clk.patch
index 32c7915..3820e63 100644
--- a/target/linux/brcm63xx/patches-3.3/408-6358-enet1-external-mii-clk.patch
+++ b/target/linux/brcm63xx/patches-3.3/408-6358-enet1-external-mii-clk.patch
@@ -15,8 +15,8 @@
  #define GPIO_MODE_6358_EXTRA_SPI_SS	(1 << 7)
  #define GPIO_MODE_6358_SERIAL_LED	(1 << 10)
  #define GPIO_MODE_6358_UTOPIA		(1 << 12)
-+#define GPIO_MODE_6358_ENET0_MII_CLK_INV (1 << 30)
-+#define GPIO_MODE_6358_ENET1_MII_CLK_INV (1 << 31)
++#define GPIO_MODE_6358_ENET1_MII_CLK_INV (1 << 30)
++#define GPIO_MODE_6358_ENET0_MII_CLK_INV (1 << 31)
  
  #define GPIO_MODE_6368_ANALOG_AFE_0	(1 << 0)
  #define GPIO_MODE_6368_ANALOG_AFE_1	(1 << 1)
-- 
1.7.10.4

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH] brcm63xx: Fix nb4 support

2012-08-09 Thread Miguel GAIO
On Thu, 2012-08-09 at 12:16 +0200, Florian Fainelli wrote:
> Hi Miguel,
Hi Florian,

> 
> On Thursday 09 August 2012 12:08:48 Miguel GAIO wrote:
> > Hi all,
> > 
> > nb4 (BMC6358) boards support is currently broken.
> > 
> > This path fixes that support.
> > Plus, I add definitions for "Service" and "Clip" buttons.
> 
> This specific part does not apply, because the leds have been renamed 
> recently 
> to nb4:color:function, can you fix it?

Really, the patxh was done on top of commit
0301cbafe2f8ebe06f22799ace3789f02345e257
Author: florian 
Date:   Thu Aug 9 09:06:35 2012 +

And the patch does not made any change on leds definitions.

Miguel


> 
> > Then, I remove the specific nb4_nvram_fixup() call to use
> > boardid_fixup()
> 
> Ok, good
> 
> --
> Florian

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH] brcm63xx: Fix nb4 support

2012-08-09 Thread Miguel GAIO
Hi all,

nb4 (BMC6358) boards support is currently broken.

This path fixes that support.
Plus, I add definitions for "Service" and "Clip" buttons.
Then, I remove the specific nb4_nvram_fixup() call to use
boardid_fixup()


Kind Regards,

Miguel
>From 32fc8d64f499f89e397e1bd516f885b73386cb68 Mon Sep 17 00:00:00 2001
From: Miguel GAIO 
Date: Thu, 9 Aug 2012 11:20:40 +0200
Subject: [PATCH]  [brcm63xx] nb4: fix support, add support for SVC and CLIP
 BTN


Signed-off-by: Miguel GAIO 
---
 .../linux/brcm63xx/patches-3.3/501-board-NB4.patch |  131 
 .../patches-3.3/502-board-96338W2_E7T.patch|2 +-
 .../brcm63xx/patches-3.3/503-board-CPVA642.patch   |2 +-
 .../patches-3.3/504-board_dsl_274xb_rev_c.patch|2 +-
 .../brcm63xx/patches-3.3/505-board_spw500v.patch   |2 +-
 .../patches-3.3/506-board_gw6200_gw6000.patch  |2 +-
 .../brcm63xx/patches-3.3/507-board-MAGIC.patch |2 +-
 .../brcm63xx/patches-3.3/508-board_hw553.patch |4 +-
 .../patches-3.3/509-board_rta1320_16m.patch|2 +-
 .../brcm63xx/patches-3.3/510-board_spw303v.patch   |4 +-
 .../brcm63xx/patches-3.3/511-board_V2500V.patch|4 +-
 .../brcm63xx/patches-3.3/512-board_BTV2110.patch   |2 +-
 .../patches-3.3/514-board_ct536_ct5621.patch   |2 +-
 .../patches-3.3/516-board_96348A-122.patch |2 +-
 .../patches-3.3/519_board_CPVA502plus.patch|2 +-
 ...0-bcm63xx-add-support-for-96368MVWG-board.patch |8 +-
 ...-bcm63xx-add-support-for-96368MVNgr-board.patch |4 +-
 ...IPS-BCM63XX-add-96328avng-reference-board.patch |2 +-
 ...IPS-BCM63XX-add-963281TAN-reference-board.patch |2 +-
 .../patches-3.3/524-board_dsl_274xb_rev_f.patch|2 +-
 .../brcm63xx/patches-3.3/525-board_96348w3.patch   |2 +-
 .../brcm63xx/patches-3.3/526-board_CT6373-1.patch  |4 +-
 .../patches-3.3/527-board_dva-g3810bn-tl-1.patch   |4 +-
 .../linux/brcm63xx/patches-3.3/528-board_nb6.patch |   10 +-
 .../801-ssb_export_fallback_sprom.patch|4 +-
 25 files changed, 142 insertions(+), 65 deletions(-)

diff --git a/target/linux/brcm63xx/patches-3.3/501-board-NB4.patch b/target/linux/brcm63xx/patches-3.3/501-board-NB4.patch
index beb8f33..2f96f4b 100644
--- a/target/linux/brcm63xx/patches-3.3/501-board-NB4.patch
+++ b/target/linux/brcm63xx/patches-3.3/501-board-NB4.patch
@@ -22,7 +22,7 @@
  static struct board_info board;
  
  /*
-@@ -666,6 +674,496 @@ static struct board_info __initdata boar
+@@ -666,6 +674,586 @@ static struct board_info __initdata boar
  
  	.has_ohci0			= 1,
  };
@@ -139,6 +139,7 @@
 +			.gpio		= 34,
 +			.type		= EV_KEY,
 +			.code		= KEY_RESTART,
++			.active_low	= 1,
 +			.debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
 +		},
 +		{
@@ -146,6 +147,23 @@
 +			.gpio		= 37,
 +			.type		= EV_KEY,
 +			.code		= KEY_WPS_BUTTON,
++			.active_low	= 1,
++			.debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
++		},
++		{
++			.desc		= "service",
++			.gpio		= 27,
++			.type		= EV_KEY,
++			.code		= BTN_0,
++			.active_low	= 1,
++			.debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
++		},
++		{
++			.desc		= "clip",
++			.gpio		= 31,
++			.type		= EV_KEY,
++			.code		= BTN_1,
++			.active_low	= 1,
 +			.debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
 +		},
 +	},
@@ -232,6 +250,7 @@
 +			.gpio		= 34,
 +			.type		= EV_KEY,
 +			.code		= KEY_RESTART,
++			.active_low	= 1,
 +			.debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
 +		},
 +		{
@@ -239,6 +258,23 @@
 +			.gpio		= 37,
 +			.type		= EV_KEY,
 +			.code		= KEY_WPS_BUTTON,
++			.active_low	= 1,
++			.debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
++		},
++		{
++			.desc		= "service",
++			.gpio		= 27,
++			.type		= EV_KEY,
++			.code		= BTN_0,
++			.active_low	= 1,
++			.debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
++		},
++		{
++			.desc		= "clip",
++			.gpio		= 31,
++			.type		= EV_KEY,
++			.code		= BTN_1,
++			.active_low	= 1,
 +			.debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
 +		},
 +	},
@@ -325,6 +361,7 @@
 +			.gpio		= 34,
 +			.type		= EV_KEY,
 +			.code		= KEY_RESTART,
++			.active_low	= 1,
 +			.debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
 +		},
 +		{
@@ -332,6 +369,23 @@
 +			.gpio		= 37,
 +			.type		= EV_KEY,
 +			.code		= KEY_WPS_BUTTON,
++			.active_low	= 1,
++			.debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
++		},
++		{
++			.desc		= "service",
++			.gpio		= 27,
++			.type		= EV_KEY,
++			.code		= BTN_0,
++			.active_low	= 1,
++			.debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
++		},
++		{
++			.desc		= "clip",
++			.gpio		= 31,
++			.type		= EV_KEY,
++			.code		= BTN_1,
++			.active_low	= 1,
 +			.debounce_interval = BCM963XX_KEYS_DEBOUNCE_INTERVAL,
 +		},
 +	},
@@ -413,6 +467,7 @@
 +			.gpio		= 34,
 +			.type		= EV_KEY,
 +			.code		= KEY_RESTART,
++			.active_low	= 1,
 +			.debounce_interval = 

Re: [OpenWrt-Devel] [PATCHv2] brcm63xx: add support for NB6 boards based on BCM6362 CPU.

2012-07-31 Thread Miguel GAIO
On Sun, 2012-07-22 at 12:59 +0200, Jonas Gorski wrote:
> Hello Miguel,
> 
Hello


> On 6 July 2012 14:19, Miguel GAIO  wrote:
> > This is a second release for NB6 boards support.
> > The first patch add support for 6362 CPU. It's based on 6328 works.
> > It also includes RGMII clock enable.
> > The second patch include support for NB6 boards.
> > The NB6 has a RTL8367R switch connected to internal enetsw using rgmii
> > bus.
> >
> > The third patch change rgmii setup on RTL8366R.
> 
> I confirm that the realtek switch works with these patches. I did some
> changes though.
> 
> 1) I substituted your BCM6362 patches with my own (yours seem to be
> based on an older broadcom SDK), since these are the ones I plan to
> submit eventually to upstream.

Greats


> 2) I made the realtek patch a platform patch, because I do not know
> the impact on other devices using this switch (which didn't need it).
> 3) I added a network config for it
> 4) I commented out the nb6 image build, since even with network
> working you can't do much with it

Hopefully, once your patches are submitted, I can help to get more
working (namely wireless)


> 
> I am more or less ready to commit this, but I am missing your
> signed-off-by. Can you please either reply with it or resend the board
> patch with it added? I created a branch on github with what I plan to
> submit, so you can use that to check that I did not miss anything (
> https://github.com/KanjiMonster/openwrt/tree/neufbox6 ).

> I have some additional questions though:
> 
> How is one supposed to flash the NB6 without serial access? At least I
> did not find anything in the web interface that allowed me to flash an
> image, and the CFE does not provide a web interface either.
> 
Without serial access, users have to use bootp method via SFR button.


> What's the "tftpboot"? I noticed that if I have the "SFR" button
> pressed when powering the device up, CFE prints "** tftpboot
> requested", but then shortly after that CFE crashes.

To use SFR button you have to:
 - setup DHCP server to provide board IP address
 - The DHCP answer needs tftp serveur and bootp image
 - Depending on nature of provided image,
 the cfe can boot vmlinux or burns new tagged image

You can found a wiki at neufbox4.org (in french) which contains HOWTOs
http://www.neufbox4.org/wiki/index.php?title=Flasher_une_NB6



> Lastly, you added an image build for "NB6-SER-r0", shouldn't you also
> add one for "NB6-FXC-r0"? Or do they not care about the board id?
> 
Board id is not care.


Miguel



> 
> Jonas
> _______
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel

>From 9bf7925c23e4bc5982b0af74f980cf1ceb8be841 Mon Sep 17 00:00:00 2001
From: Miguel GAIO 
Date: Fri, 6 Jul 2012 14:10:52 +0200
Subject: [PATCH 05/22]  * [brcm63xx] Add nb6 support (BCM6362 SoC base
 boards)


Signed-off-by: Miguel GAIO 
---
 target/linux/brcm63xx/config-3.3   |2 +
 target/linux/brcm63xx/image/Makefile   |2 +
 .../linux/brcm63xx/patches-3.3/301-led_count.patch |   15 +-
 .../linux/brcm63xx/patches-3.3/554-board_nb6.patch |  146 
 .../801-ssb_export_fallback_sprom.patch|4 +-
 5 files changed, 163 insertions(+), 6 deletions(-)
 create mode 100644 target/linux/brcm63xx/patches-3.3/554-board_nb6.patch

diff --git a/target/linux/brcm63xx/config-3.3 b/target/linux/brcm63xx/config-3.3
index fed43ff..f8cf486 100644
--- a/target/linux/brcm63xx/config-3.3
+++ b/target/linux/brcm63xx/config-3.3
@@ -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 8066430..06c5d64 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 536, 5621
 	$(call Image/Build/CFEFIXUP,$(1),96348GW-11,CT536_CT5621,6348,CT536_CT5621)
 	# Davolink DV201AMR
diff --git a/target/linux/brcm63xx/patches-3.3/301-led_count.patch b/target/linux/brcm63xx/patches-3.3/301-led_count.patch
index 84d57a0..b6c1196 100644
--- a/target/linux/brcm63xx/patches-3.3/301-led_count.patch
+++ b/target/linux/brcm63xx/patches

[OpenWrt-Devel] [PATCH] brcm63xx: add support for NB6 boards based on BCM6362 CPU.

2012-06-12 Thread Miguel GAIO
Hi all,

This is a preliminary support for NB6 boards.
The first patch add support for 6362 CPU.
The chip is closed to the 6328 CPU, so the patch is mainly base on 6328
support.

The second patch add support for NB6 boards.
NB6s provide different board IDs, but all use only one board layout.
The boardid_fixup() is used to fix this point.


Kind Regards,

Miguel
>From a44847487d2582ffbd0e502568fdaf95fdf49dc1 Mon Sep 17 00:00:00 2001
From: Miguel GAIO 
Date: Tue, 12 Jun 2012 15:48:45 +0200
Subject: [PATCH 1/2]  * Add BCM6362 CPU support

---
 target/linux/brcm63xx/config-3.3   |1 +
 ...IPS-BCM63XX-add-basic-BCM6362-CPU-support.patch |  540 
 .../401-MIPS-BCM63XX-register-ohci-device.patch|9 +-
 .../403-MIPS-BCM63XX-register-ehci-device.patch|6 +-
 .../408-6358-enet1-external-mii-clk.patch  |2 +-
 ...4-bcm63xx_enet-split-dma-registers-access.patch |2 +-
 ...t-add-support-for-bcm6368-internal-ethern.patch |2 +-
 ...X-add-HS-SPI-platform-device-and-register.patch |2 +-
 .../419-SPI-MIPS-BCM63XX-Add-HS-SPI-driver.patch   |   54 +-
 ...IPS-BCM63XX-Register-SPI-flash-if-present.patch |   16 +-
 .../427-MTD-m25p80-allow-passing-pp_data.patch |   16 +-
 ...0-MIPS-BCM63XX-pass-caldata-info-to-flash.patch |2 +-
 .../brcm63xx/patches-3.3/511-board_V2500V.patch|2 +-
 .../801-ssb_export_fallback_sprom.patch|4 +-
 14 files changed, 619 insertions(+), 39 deletions(-)
 create mode 100644 target/linux/brcm63xx/patches-3.3/350-MIPS-BCM63XX-add-basic-BCM6362-CPU-support.patch

diff --git a/target/linux/brcm63xx/config-3.3 b/target/linux/brcm63xx/config-3.3
index 42ffabc..fed43ff 100644
--- a/target/linux/brcm63xx/config-3.3
+++ b/target/linux/brcm63xx/config-3.3
@@ -11,6 +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=y
 CONFIG_BCM63XX_CPU_6368=y
 CONFIG_BCM63XX_ENET=y
 CONFIG_BCM63XX_PHY=y
diff --git a/target/linux/brcm63xx/patches-3.3/350-MIPS-BCM63XX-add-basic-BCM6362-CPU-support.patch b/target/linux/brcm63xx/patches-3.3/350-MIPS-BCM63XX-add-basic-BCM6362-CPU-support.patch
new file mode 100644
index 000..10f99a8
--- /dev/null
+++ b/target/linux/brcm63xx/patches-3.3/350-MIPS-BCM63XX-add-basic-BCM6362-CPU-support.patch
@@ -0,0 +1,540 @@
+--- a/arch/mips/bcm63xx/Kconfig
 b/arch/mips/bcm63xx/Kconfig
+@@ -25,6 +25,10 @@ config BCM63XX_CPU_6358
+ 	bool "support 6358 CPU"
+ 	select HW_HAS_PCI
+ 
++config BCM63XX_CPU_6362
++	bool "support 6362 CPU"
++	select HW_HAS_PCI
++
+ config BCM63XX_CPU_6368
+ 	bool "support 6368 CPU"
+ 	select HW_HAS_PCI
+--- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
 b/arch/mips/bcm63xx/boards/board_bcm963xx.c
+@@ -762,8 +762,8 @@ void __init board_prom_init(void)
+ 	u32 val;
+ 
+ 	/* read base address of boot chip select (0)
+-	 * 6328 does not have MPI but boots from a fixed address */
+-	if (BCMCPU_IS_6328())
++	 * 6328,6362 does not have MPI but boots from a fixed address */
++	if (BCMCPU_IS_6328() || BCMCPU_IS_6362())
+ 		val = 0x1800;
+ 	else {
+ 		val = bcm_mpi_readl(MPI_CSBASE_REG(0));
+--- a/arch/mips/bcm63xx/cpu.c
 b/arch/mips/bcm63xx/cpu.c
+@@ -71,6 +71,15 @@ static const int bcm6358_irqs[] = {
+ 
+ };
+ 
++static const unsigned long bcm6362_regs_base[] = {
++	__GEN_CPU_REGS_TABLE(6362)
++};
++
++static const int bcm6362_irqs[] = {
++	__GEN_CPU_IRQ_TABLE(6362)
++
++};
++
+ static const unsigned long bcm6368_regs_base[] = {
+ 	__GEN_CPU_REGS_TABLE(6368)
+ };
+@@ -169,6 +178,44 @@ static unsigned int detect_cpu_clock(voi
+ 		return (16 * 100 * n1 * n2) / m1;
+ 	}
+ 
++	case BCM6362_CPU_ID:
++	{
++		unsigned int tmp, mips_pll_fcvo;
++
++		tmp = bcm_misc_readl(MISC_STRAPBUS_6362_REG);
++		mips_pll_fcvo = (tmp & STRAPBUS_6362_FCVO_MASK)
++>> STRAPBUS_6362_FCVO_SHIFT;
++
++		switch (mips_pll_fcvo) {
++		case 0x04:
++		case 0x0c:
++		case 0x14:
++		case 0x1c:
++			return 16000;
++		case 0x15:
++		case 0x1d:
++			return 2;
++		case 0x03:
++		case 0x0b:
++		case 0x13:
++		case 0x1b:
++			return 24000;
++		case 0x07:
++		case 0x17:
++			return 38400;
++		case 0x05:
++		case 0x06:
++		case 0x0e:
++		case 0x16:
++		case 0x1e:
++		case 0x1f:
++			return 4;
++		default:
++			return 32000;
++		}
++
++	}
++
+ 	case BCM6368_CPU_ID:
+ 	{
+ 		unsigned int tmp, p1, p2, ndiv, m1;
+@@ -205,7 +252,7 @@ static unsigned int detect_memory_size(v
+ 	unsigned int cols = 0, rows = 0, is_32bits = 0, banks = 0;
+ 	u32 val;
+ 
+-	if (BCMCPU_IS_6328())
++	if (BCMCPU_IS_6328() || BCMCPU_IS_6362())
+ 		return bcm_ddr_readl(DDR_CSEND_REG) << 24;
+ 
+ 	if (BCMCPU_IS_6345()) {
+@@ -280,6 +327,11 @@ void __init bcm63xx_cpu_init(void)
+ bcm63xx_regs_base = bcm6328_regs_base;
+ bcm63xx_irqs = bcm6328_irqs;
+ break;
++			case BCM6362_CPU_ID:
++expected_cpu_id = BCM6362_CPU_ID;
++bcm63xx_regs_base = bcm

[OpenWrt-Devel] [PATCH] [bcm63xx] spi driver remove bcm_rset usage

2010-12-09 Thread Miguel GAIO
Hi all,

Since bcm636x platform embeds two spi master device,
the attached patch removes static bcm_rset usage, replaced  by
"bs->regs" field for all I/O operation.

Regards,

Miguel
>From d8afe919203a948a23368e8fdb50ec2d9db30e2b Mon Sep 17 00:00:00 2001
From: Miguel Gaio 
Date: Thu, 9 Dec 2010 15:33:43 +0100
Subject: [PATCH]  * [brcm63xx] spi driver: remove bcm_rset usage

---
 target/linux/brcm63xx/patches-2.6.35/240-spi.patch |  136 +++-
 1 files changed, 74 insertions(+), 62 deletions(-)

diff --git a/target/linux/brcm63xx/patches-2.6.35/240-spi.patch b/target/linux/brcm63xx/patches-2.6.35/240-spi.patch
index 62afe8c..ab12a6f 100644
--- a/target/linux/brcm63xx/patches-2.6.35/240-spi.patch
+++ b/target/linux/brcm63xx/patches-2.6.35/240-spi.patch
@@ -318,7 +318,7 @@
  #endif /* BCM63XX_REGS_H_ */
 --- /dev/null
 +++ b/drivers/spi/bcm63xx_spi.c
-@@ -0,0 +1,479 @@
+@@ -0,0 +1,501 @@
 +/*
 + * Broadcom BCM63xx SPI controller support
 + *
@@ -357,11 +357,11 @@
 +
 +struct bcm63xx_spi {
 +	spinlock_t  lock;
-+	int stopping;
++	int			stopping;
 +struct completion	done;
 +
-+void __iomem		*regs;
-+int			irq;
++	void __iomem		*regs;
++	int			irq;
 +
 +	/* Platform data */
 +u32			speed_hz;
@@ -376,6 +376,30 @@
 +	struct platform_device	*pdev;
 +};
 +
++static inline u8 bcm_spi_readb(struct bcm63xx_hsspi *bs,
++unsigned int offset)
++{
++return bcm_readw(bs->regs + bcm63xx_spireg(offset));
++}
++
++static inline u16 bcm_spi_readw(struct bcm63xx_hsspi *bs,
++unsigned int offset)
++{
++return bcm_readw(bs->regs + bcm63xx_spireg(offset));
++}
++
++static inline void bcm_spi_writeb(struct bcm63xx_hsspi *bs,
++  u8 value, unsigned int offset)
++{
++bcm_writeb(value, bs->regs + bcm63xx_spireg(offset));
++}
++
++static inline void bcm_spi_writew(struct bcm63xx_hsspi *bs,
++  u16 value, unsigned int offset)
++{
++bcm_writew(value, bs->regs + bcm63xx_spireg(offset));
++}
++
 +static int bcm63xx_spi_setup_transfer(struct spi_device *spi,
 +	struct spi_transfer *t)
 +{
@@ -428,7 +452,7 @@
 +		break;
 +	}
 +
-+	bcm_spi_writeb(clk_cfg, SPI_CLK_CFG);
++	bcm_spi_writeb(bs, clk_cfg, SPI_CLK_CFG);
 +	dev_dbg(&spi->dev, "Setting clock register to %d (hz %d, cmd %02x)\n",
 +		div, hz, clk_cfg);
 +
@@ -441,7 +465,7 @@
 +static int bcm63xx_spi_setup(struct spi_device *spi)
 +{
 +	struct bcm63xx_spi *bs;
-+	int retval;
++	int ret;
 +
 +	bs = spi_master_get_devdata(spi->master);
 +
@@ -457,11 +481,11 @@
 +		return -EINVAL;
 +	}
 +
-+	retval = bcm63xx_spi_setup_transfer(spi, NULL);
-+	if (retval < 0) {
++	ret = bcm63xx_spi_setup_transfer(spi, NULL);
++	if (ret < 0) {
 +		dev_err(&spi->dev, "setup: unsupported mode bits %x\n",
 +			spi->mode & ~MODEBITS);
-+		return retval;
++		return ret;
 +	}
 +
 +	dev_dbg(&spi->dev, "%s, mode %d, %u bits/w, %u nsec/bit\n",
@@ -473,20 +497,20 @@
 +/* Fill the TX FIFO with as many bytes as possible */
 +static void bcm63xx_spi_fill_tx_fifo(struct bcm63xx_spi *bs)
 +{
-+u8 tail;
++	u8 tail;
 +
 +/* Fill the Tx FIFO with as many bytes as possible */
-+	tail = bcm_spi_readb(SPI_MSG_TAIL);
++	tail = bcm_spi_readb(bs, SPI_MSG_TAIL);
 +
-+while ((tail < bs->fifo_size) && (bs->remaining_bytes > 0)) {
-+if (bs->tx_ptr)
-+bcm_spi_writeb(*bs->tx_ptr++, SPI_MSG_DATA);
++	while ((tail < bs->fifo_size) && (bs->remaining_bytes > 0)) {
++		if (bs->tx_ptr)
++			bcm_spi_writeb(bs, *bs->tx_ptr++, SPI_MSG_DATA);
 +		else
-+			bcm_spi_writeb(0, SPI_MSG_DATA);
++			bcm_spi_writeb(bs, 0, SPI_MSG_DATA);
 +
-+bs->remaining_bytes--;
-+		tail = bcm_spi_readb(SPI_MSG_TAIL);
-+}
++		bs->remaining_bytes--;
++		tail = bcm_spi_readb(bs, SPI_MSG_TAIL);
++	}
 +}
 +
 +static int bcm63xx_txrx_bufs(struct spi_device *spi, struct spi_transfer *t)
@@ -510,7 +534,7 @@
 +
 +	/* Enable the command done interrupt which
 +	 * we use to determine completion of a command */
-+	bcm_spi_writeb(SPI_INTR_CMD_DONE, SPI_INT_MASK);
++	bcm_spi_writeb(bs, SPI_INTR_CMD_DONE, SPI_INT_MASK);
 +
 +	/* Fill in the Message control register */
 +	msg_ctl = (t->len << SPI_BYTE_CNT_SHIFT);
@@ -522,37 +546,37 @@
 +	else if (t->tx_buf)
 +		msg_ctl |= (SPI_HD_W << SPI_MSG_TYPE_SHIFT);
 +
-+	bcm_spi_writew(msg_ctl, SPI_MSG_CTL);
++	bcm_spi_writew(bs, msg_ctl, SPI_MSG_CTL);
 +
 +	/* Issue the transfer */
 +	cmd = SPI_CMD_START_IMMEDIATE;
 +	cmd |= (0 << SPI_CMD_PREPEND_BYTE_CNT_SHIFT);
-+	bcm_spi_writew(cmd, SPI_CMD);
++	bcm_spi_writew(bs, cmd, SPI_CMD);
 +	wait_for_completion(&bs->done);
 +
 +	/* Disable the CMD_DONE interrupt */
-+	bcm_spi_writeb(0, SPI_INT_MASK);
++	bcm_spi_writeb(bs, 0, SPI_INT_MASK);
 +
 +	return t->len - bs->remaining_bytes;
 +

Re: [OpenWrt-Devel] [bcm63xx] [6358] fix external interrupts

2010-11-21 Thread Miguel Gaio
Hi,

Please, drop the previous patch.

Miguel


On Fri, 2010-11-19 at 10:07 +0100, Miguel GAIO wrote:
> Hi,
> 
> This patch fix external IRQs on 6358 platform.
> They are mapped throw 33 to 37 IRQ lines.
> 
> Kind Regards,
> 
> Miguel



___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [bcm63xx] [6358] fix external interrupts

2010-11-19 Thread Miguel GAIO
Hi,

This patch fix external IRQs on 6358 platform.
They are mapped throw 33 to 37 IRQ lines.

Kind Regards,

Miguel
>From b0507980e6f57c1cde8842517f0ae58bf806a1c3 Mon Sep 17 00:00:00 2001
From: Miguel Gaio 
Date: Fri, 19 Nov 2010 10:05:04 +0100
Subject: [PATCH]  * [brcm63xx] fix external interrupts on 6358 platform

---
 .../patches-2.6.35/006-external-interrupt.patch|  106 
 1 files changed, 106 insertions(+), 0 deletions(-)
 create mode 100644 target/linux/brcm63xx/patches-2.6.35/006-external-interrupt.patch

diff --git a/target/linux/brcm63xx/patches-2.6.35/006-external-interrupt.patch b/target/linux/brcm63xx/patches-2.6.35/006-external-interrupt.patch
new file mode 100644
index 000..7db72e0
--- /dev/null
+++ b/target/linux/brcm63xx/patches-2.6.35/006-external-interrupt.patch
@@ -0,0 +1,106 @@
+--- a/arch/mips/bcm63xx/irq.c
 b/arch/mips/bcm63xx/irq.c
+@@ -109,7 +109,7 @@ static void bcm63xx_external_irq_mask(un
+ {
+ 	u32 reg;
+ 
+-	irq -= IRQ_EXT_BASE;
++	irq -= bcm63xx_irq_ext_base();
+ 	reg = bcm_perf_readl(PERF_EXTIRQ_CFG_REG);
+ 	reg &= ~EXTIRQ_CFG_MASK(irq);
+ 	bcm_perf_writel(reg, PERF_EXTIRQ_CFG_REG);
+@@ -119,7 +119,7 @@ static void bcm63xx_external_irq_unmask(
+ {
+ 	u32 reg;
+ 
+-	irq -= IRQ_EXT_BASE;
++	irq -= bcm63xx_irq_ext_base();
+ 	reg = bcm_perf_readl(PERF_EXTIRQ_CFG_REG);
+ 	reg |= EXTIRQ_CFG_MASK(irq);
+ 	bcm_perf_writel(reg, PERF_EXTIRQ_CFG_REG);
+@@ -129,7 +129,7 @@ static void bcm63xx_external_irq_clear(u
+ {
+ 	u32 reg;
+ 
+-	irq -= IRQ_EXT_BASE;
++	irq -= bcm63xx_irq_ext_base();
+ 	reg = bcm_perf_readl(PERF_EXTIRQ_CFG_REG);
+ 	reg |= EXTIRQ_CFG_CLEAR(irq);
+ 	bcm_perf_writel(reg, PERF_EXTIRQ_CFG_REG);
+@@ -137,7 +137,10 @@ static void bcm63xx_external_irq_clear(u
+ 
+ static unsigned int bcm63xx_external_irq_startup(unsigned int irq)
+ {
+-	set_c0_status(0x100 << (irq - IRQ_MIPS_BASE));
++	if (BCMCPU_IS_6358())
++		bcm63xx_internal_irq_unmask(irq);
++	else
++		set_c0_status(0x100 << (irq - IRQ_MIPS_BASE));
+ 	irq_enable_hazard();
+ 	bcm63xx_external_irq_unmask(irq);
+ 	return 0;
+@@ -146,7 +149,10 @@ static unsigned int bcm63xx_external_irq
+ static void bcm63xx_external_irq_shutdown(unsigned int irq)
+ {
+ 	bcm63xx_external_irq_mask(irq);
+-	clear_c0_status(0x100 << (irq - IRQ_MIPS_BASE));
++	if (BCMCPU_IS_6358())
++		bcm63xx_internal_irq_mask(irq);
++	else
++		clear_c0_status(0x100 << (irq - IRQ_MIPS_BASE));
+ 	irq_disable_hazard();
+ }
+ 
+@@ -156,7 +162,7 @@ static int bcm63xx_external_irq_set_type
+ 	u32 reg;
+ 	struct irq_desc *desc = irq_desc + irq;
+ 
+-	irq -= IRQ_EXT_BASE;
++	irq -= bcm63xx_irq_ext_base();
+ 
+ 	flow_type &= IRQ_TYPE_SENSE_MASK;
+ 
+@@ -238,6 +244,7 @@ static struct irqaction cpu_ip2_cascade_
+ 
+ void __init arch_init_irq(void)
+ {
++	int irq_ext_base = bcm63xx_irq_ext_base();
+ 	int i;
+ 
+ 	mips_cpu_irq_init();
+@@ -245,7 +252,7 @@ void __init arch_init_irq(void)
+ 		set_irq_chip_and_handler(i, &bcm63xx_internal_irq_chip,
+ 	 handle_level_irq);
+ 
+-	for (i = IRQ_EXT_BASE; i < IRQ_EXT_BASE + 4; ++i)
++	for (i = irq_ext_base; i < irq_ext_base + 4; ++i)
+ 		set_irq_chip_and_handler(i, &bcm63xx_external_irq_chip,
+ 	 handle_edge_irq);
+ 
+--- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_irq.h
 b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_irq.h
+@@ -6,10 +6,19 @@
+ #define IRQ_MIPS_BASE			0
+ #define IRQ_INTERNAL_BASE		8
+ 
+-#define IRQ_EXT_BASE			(IRQ_MIPS_BASE + 3)
+-#define IRQ_EXT_0			(IRQ_EXT_BASE + 0)
+-#define IRQ_EXT_1			(IRQ_EXT_BASE + 1)
+-#define IRQ_EXT_2			(IRQ_EXT_BASE + 2)
+-#define IRQ_EXT_3			(IRQ_EXT_BASE + 3)
++static inline unsigned long bcm63xx_irq_ext_base(void)
++{
++	switch (bcm63xx_get_cpu_id()) {
++		case BCM6358_CPU_ID:
++			return IRQ_MIPS_BASE + 33;
++		default:
++			return IRQ_MIPS_BASE + 3;
++	}
++}
++
++#define IRQ_EXT_0			(bcm63xx_irq_ext_base() + 0)
++#define IRQ_EXT_1			(bcm63xx_irq_ext_base() + 1)
++#define IRQ_EXT_2			(bcm63xx_irq_ext_base() + 2)
++#define IRQ_EXT_3			(bcm63xx_irq_ext_base() + 3)
+ 
+ #endif /* ! BCM63XX_IRQ_H_ */
-- 
1.7.2.3

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] Broadcom BCM63xx merge plans

2010-09-15 Thread Miguel GAIO
Hi Florian


On Wed, 2010-09-15 at 09:39 +0200, Florian Fainelli wrote:
> Hi Miguel, Daniel,
> 
> For your information, I have managed to recently get those changes mainline:
> 
> - bcm963xx mtd partition parser [1]
> - bcm63xx watchdog driver (not yet pushed)
> 
> I will ask Maxime to push the OHCI and EHCI usb drivers mainline, so after 
> that the only patches that we have in OpenWrt are:
> 
> - 070_bcm63xx_enet_vlan_incoming_fixed.patch: according to Maxime, this patch 
> is not exactly valid, and the issue is somewhere else, Daniel, if you want to 
> work this out with him
> - 100-reset_buttons.patch: depends on the gpio-buttons driver to be merged
> - 110-gpiodev.patch: useless, /sys/class/gpio/ allows the same kind of usage
> - 140-new_bcm96348gw_leds.patch: needs to be integrated with the proper board 
> id fixup patch from Jonas Gorski [2]
> - 150-alice_gate2_leds.patch: ok
> - 170-board_livebox.patch: not complete, so to be kept until ready
> - 180-udc_preliminary_support.patch: no objections pushing it, although there 
> are no users of it

Some NB4 has UDC device. I can make some tests on it.


> - 200-extended-platform-devices.patch: ok
> - 211-nxp-74hc164-gpio-chip-driver.patch: needs to become a SPI driver after 
> [3]

Sure, I will rewrite this part.


> - 220-board-D4PW.patch: ok
> - 221-board-NB4.patch: ok, after nxp-74hc164 has been merged or reworked
> - 240-spi.patch: needs some rework

I CC Tanguy for this part. He had fixed spi driver to get it working on
NB4. Maybe others tests are needed. I let Tanguy push its fixes to
openwrt.

> - 250-6358-enet1-external-mii-clk.patch: needs testing on other BCM6358 boards

This fix should be safe for all 6358. But sure needs testing.


> - 260-no_ehci_over_current_check.patch: not required, over current checking 
> can be turned off by module parameter (so actually we can patch the ehci 
> driver 
> to turn it off by default without supplying the module parameter)
> 
> [1]:http://git.infradead.org/users/dedekind/l2-
> mtd-2.6.git/commit/eafa90853c493d4b6b556286d2ccd38c59d1985e
> [2]: https://lists.openwrt.org/pipermail/openwrt-devel/2010-June/007375.html
> [3]: http://lkml.org/lkml/2010/9/1/82



Miguel




___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] BCM Roboswitch

2010-09-02 Thread Miguel Gaio
Hi Florian,


On Thu, 2010-09-02 at 21:57 +0200, Florian Fainelli wrote:
> Hello Miguel,
> 
> Le Thursday 2 September 2010 12:16:19, Miguel GAIO a écrit :
> > Hi Florian,
> > 
> > On Thu, 2010-09-02 at 10:40 +0200, Florian Fainelli wrote:
> > > Hi Miguel,
> > > 
> > > On Thursday 02 September 2010 10:36:06 Miguel GAIO wrote:
> > > > Hi all,
> > > > 
> > > > I have started the rewrite for the Broadcom BCM5325 switch.
> > > > It was test on neufbox4 board.
> > > 
> > > This is great work! I will give it a try on a couple of BCM6348/38 boards
> > > and report to you how it goes. Might also be worth testing on BCM47xx
> > > and see if it works.
> > 
> > Thanks for you tests. A bug was introduce in previous
> > 0001-Switch-add-support-for-Broadcom-BCM5325E-phy.patch.
> > Please use attached update.
> 
> I did not get it probing the switch, but I assume this is due to my wrong PHY 
> mask. So far, I set it to 0x and tried with the same mask as the NB4 
> board, either without success.
> 
> The old kmod-switch was able to detect the switch at PHY address 0, so I am 
> not sure what is wrong here. The switch is a BCM5325E.


ID 0 through 4 are switch ports PHYs.
As I did not connect enet1 to any phys, the switch probe was perform via
pseudo PHY (phy address 1Eh), assume Pseudo PHY dev_id is 0x.

If it's not case on your board, I have to rewrite probe part.


Note: probe message is not print on console (log level 7). You should
check via dmesg or via /sys/bus/mdio_bus/.
Or use command
# swicth dev bcm5325e show


> 
> > 
> > > > It's not complete and does not support others Robo switches, comments
> > > > are welcome.
> > > > I can help for BCM5325 and BCM5395 support.
> > > > 
> > > > Kind regards,
> > > > 
> > > > Miguel
> > > 
> > > --
> > > Florian
> > 
> > Miguel



___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] BCM Roboswitch

2010-09-02 Thread Miguel GAIO
Hi Florian,


On Thu, 2010-09-02 at 10:40 +0200, Florian Fainelli wrote:
> Hi Miguel,
> 
> 
> On Thursday 02 September 2010 10:36:06 Miguel GAIO wrote:
> > Hi all,
> > 
> > I have started the rewrite for the Broadcom BCM5325 switch.
> > It was test on neufbox4 board.
> 
> This is great work! I will give it a try on a couple of BCM6348/38 boards and 
> report to you how it goes. Might also be worth testing on BCM47xx and see if 
> it works.
> 

Thanks for you tests. A bug was introduce in previous
0001-Switch-add-support-for-Broadcom-BCM5325E-phy.patch.
Please use attached update.


> > It's not complete and does not support others Robo switches, comments
> > are welcome.
> > I can help for BCM5325 and BCM5395 support.
> > 
> > Kind regards,
> > 
> > Miguel
> --
> Florian


Miguel

>From 8260b90ca26a6c57d013cb3027ea28fd8c6ea549 Mon Sep 17 00:00:00 2001
From: Miguel Gaio 
Date: Thu, 2 Sep 2010 12:11:11 +0200
Subject: [PATCH]  * Switch: add support for Broadcom BCM5325E phy

---
 .../linux/generic/files/drivers/net/phy/bcm5325.c  |  432 +
 .../linux/generic/files/drivers/net/phy/etc53xx.h  |  636 
 .../generic/patches-2.6.32/692-phy_bcm5325.patch   |   21 +
 3 files changed, 1089 insertions(+), 0 deletions(-)
 create mode 100644 target/linux/generic/files/drivers/net/phy/bcm5325.c
 create mode 100644 target/linux/generic/files/drivers/net/phy/etc53xx.h
 create mode 100644 target/linux/generic/patches-2.6.32/692-phy_bcm5325.patch

diff --git a/target/linux/generic/files/drivers/net/phy/bcm5325.c b/target/linux/generic/files/drivers/net/phy/bcm5325.c
new file mode 100644
index 000..293d37d
--- /dev/null
+++ b/target/linux/generic/files/drivers/net/phy/bcm5325.c
@@ -0,0 +1,432 @@
+/*
+ * bcm5325.c: Broadcom 5325 switch driver
+ *
+ * Copyright (C) 2010 Miguel Gaio 
+ * Copyright (C) 2005 Felix Fietkau 
+ * Copyright (C) 2008 Michael Buesch 
+ * Based on 'robocfg' by Oleg I. Vdovikin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "etc53xx.h"
+
+#define BCM5325_DRIVER_DESC	"Broadcom BCM5325 ethernet switch driver"
+#define BCM5325_DRIVER_VER	"0.0.1"
+
+struct bcm5325 {
+	struct phy_device *phydev;
+	struct switch_dev sw_dev;
+	char buf[4096];
+};
+
+static inline struct bcm5325 *sw_to_bcm5325(struct switch_dev *sw)
+{
+	return container_of(sw, struct bcm5325, sw_dev);
+}
+
+static void robo_commit(struct phy_device *phydev, u16 page, u16 reg, u16 op)
+{
+	int i;
+	u16 v;
+
+	/* set page number */
+	v = (page << 8) | REG_MII_PAGE_ENABLE;
+	phy_write(phydev, REG_MII_PAGE, v);
+
+	/* set register address */
+	v = (reg << 8) | op;
+	phy_write(phydev, REG_MII_ADDR, v);
+
+	/* check if operation completed */
+	for (i = 0; i < 5; ++i) {
+		v = phy_read(phydev, REG_MII_ADDR);
+		if (!(v & (REG_MII_ADDR_WRITE | REG_MII_ADDR_READ)))
+			break;
+		udelay(10);
+	}
+
+	if (i == 5) {
+		dev_err(&phydev->dev, "I/O page:%u reg:%u timeout\n", page,
+			reg);
+		return;
+	}
+}
+
+u16 robo_r16(struct phy_device * phydev, u16 page, u16 reg)
+{
+	u16 v;
+
+	robo_commit(phydev, page, reg, REG_MII_ADDR_READ);
+	v = phy_read(phydev, REG_MII_DATA0);
+	return v;
+}
+
+u32 robo_r32(struct phy_device * phydev, u16 page, u16 reg)
+{
+	u32 v;
+
+	robo_commit(phydev, page, reg, REG_MII_ADDR_READ);
+	v = phy_read(phydev,
+		 REG_MII_DATA0) | (phy_read(phydev,
+		REG_MII_DATA0 + 1) << 16);
+	return v;
+}
+
+void robo_w16(struct phy_device *phydev, u16 page, u16 reg, u16 v)
+{
+	phy_write(phydev, REG_MII_DATA0, v);
+	robo_commit(phydev, page, reg, REG_MII_ADDR_WRITE);
+}
+
+void robo_w32(struct phy_device *phydev, u16 page, u16 reg, u32 v)
+{
+	phy_write(phydev, REG_MII_DATA0, v & 0x);
+	phy_write(phydev, REG_MII_DATA0 + 1, v >> 16);
+	robo_commit(phydev, page, reg, REG_MII_ADDR_WRITE);
+}
+
+/* switch */
+
+static int bcm5325_sw_get_vlan_ports(struct switch_dev *dev,
+ struct switch_val *val)
+{
+	struct bcm5325 *priv = sw_to_bcm5325(dev);
+	struct phy_device *phydev = priv->phydev;
+	struct switch_port *port;
+	int i;
+
+	u32 v32;
+	u16 v16;
+
+	v16 = val->port_vlan | (0 << 12) /* read */ |(1 << 13) /* enable */ ;
+	robo_w16(phydev, RO

[OpenWrt-Devel] BCM Roboswitch

2010-09-02 Thread Miguel GAIO
Hi all,

I have started the rewrite for the Broadcom BCM5325 switch.
It was test on neufbox4 board.
It's not complete and does not support others Robo switches, comments
are welcome.
I can help for BCM5325 and BCM5395 support.

Kind regards,

Miguel

>From 15ca0e81dc8389528809662e6235d6efbb8adf3e Mon Sep 17 00:00:00 2001
From: Miguel Gaio 
Date: Thu, 2 Sep 2010 09:35:37 +0200
Subject: [PATCH 1/2]  * Switch: add support for Broadcom BCM5325E phy

---
 .../linux/generic/files/drivers/net/phy/bcm5325.c  |  435 +
 .../linux/generic/files/drivers/net/phy/etc53xx.h  |  636 
 .../generic/patches-2.6.32/692-phy_bcm5325.patch   |   21 +
 3 files changed, 1092 insertions(+), 0 deletions(-)
 create mode 100644 target/linux/generic/files/drivers/net/phy/bcm5325.c
 create mode 100644 target/linux/generic/files/drivers/net/phy/etc53xx.h
 create mode 100644 target/linux/generic/patches-2.6.32/692-phy_bcm5325.patch

diff --git a/target/linux/generic/files/drivers/net/phy/bcm5325.c b/target/linux/generic/files/drivers/net/phy/bcm5325.c
new file mode 100644
index 000..207a98e
--- /dev/null
+++ b/target/linux/generic/files/drivers/net/phy/bcm5325.c
@@ -0,0 +1,435 @@
+/*
+ * bcm5325.c: Broadcom 5325 switch driver
+ *
+ * Copyright (C) 2010 Miguel Gaio 
+ * Copyright (C) 2005 Felix Fietkau 
+ * Copyright (C) 2008 Michael Buesch 
+ * Based on 'robocfg' by Oleg I. Vdovikin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "etc53xx.h"
+
+#define BCM5325_DRIVER_DESC	"Broadcom BCM5325 ethernet switch driver"
+#define BCM5325_DRIVER_VER	"0.0.1"
+
+struct bcm5325 {
+	struct phy_device *phydev;
+	struct switch_dev sw_dev;
+	char buf[4096];
+};
+
+static inline struct bcm5325 *sw_to_bcm5325(struct switch_dev *sw)
+{
+	return container_of(sw, struct bcm5325, sw_dev);
+}
+
+static void robo_commit(struct phy_device *phydev, u16 page, u16 reg, u16 op)
+{
+	int i;
+	u16 v;
+
+	/* set page number */
+	v = (page << 8) | REG_MII_PAGE_ENABLE;
+	phy_write(phydev, REG_MII_PAGE, v);
+
+	/* set register address */
+	v = (reg << 8) | op;
+	phy_write(phydev, REG_MII_ADDR, v);
+
+	/* check if operation completed */
+	for (i = 0; i < 5; ++i) {
+		v = phy_read(phydev, REG_MII_ADDR);
+		if (!(v & (REG_MII_ADDR_WRITE | REG_MII_ADDR_READ)))
+			break;
+		udelay(10);
+	}
+
+	if (i == 5) {
+		dev_err(&phydev->dev, "I/O page:%u reg:%u timeout\n", page,
+			reg);
+		return;
+	}
+}
+
+u16 robo_r16(struct phy_device * phydev, u16 page, u16 reg)
+{
+	u16 v;
+
+	robo_commit(phydev, page, reg, REG_MII_ADDR_READ);
+	v = phy_read(phydev, REG_MII_DATA0);
+	return v;
+}
+
+u32 robo_r32(struct phy_device * phydev, u16 page, u16 reg)
+{
+	u32 v;
+
+	robo_commit(phydev, page, reg, REG_MII_ADDR_READ);
+	v = phy_read(phydev,
+		 REG_MII_DATA0) | (phy_read(phydev,
+		REG_MII_DATA0 + 1) << 16);
+	return v;
+}
+
+void robo_w16(struct phy_device *phydev, u16 page, u16 reg, u16 v)
+{
+	phy_write(phydev, REG_MII_DATA0, v);
+	robo_commit(phydev, page, reg, REG_MII_ADDR_WRITE);
+}
+
+void robo_w32(struct phy_device *phydev, u16 page, u16 reg, u32 v)
+{
+	phy_write(phydev, REG_MII_DATA0, v & 0x);
+	phy_write(phydev, REG_MII_DATA0 + 1, v >> 16);
+	robo_commit(phydev, page, reg, REG_MII_ADDR_WRITE);
+}
+
+/* switch */
+
+static int bcm5325_sw_get_vlan_ports(struct switch_dev *dev,
+ struct switch_val *val)
+{
+	struct bcm5325 *priv = sw_to_bcm5325(dev);
+	struct phy_device *phydev = priv->phydev;
+	struct switch_port *port;
+	int i;
+
+	u32 v32;
+	u16 v16;
+
+	v16 = val->port_vlan | (0 << 12) /* read */ |(1 << 13) /* enable */ ;
+	robo_w16(phydev, ROBO_VLAN_PAGE, ROBO_VLAN_TABLE_ACCESS_5350, v16);
+
+	/* actual read */
+	v32 = robo_r32(phydev, ROBO_VLAN_PAGE, ROBO_VLAN_READ);
+	if (!(v32 & (1 << 20)) /* valid */ )
+		return -EINVAL;
+
+	port = &val->value.ports[0];
+	val->len = 0;
+	for (i = 0; i < dev->ports; i++) {
+		if (!(v32 & BIT(i)))
+			continue;
+
+		port->id = i;
+		if (v32 & BIT(i + 6))
+			port->flags = 0;
+		else
+			port->flags = BIT(SWITCH_PORT_FLAG_TAGGED);
+
+		val->len++;
+		port++;
+	}
+
+	return 0;
+}
+
+static int bcm5325_sw_set_vlan_ports(struct switch_dev *dev,
+ struct switch_val *val)
+{
+	stru

[OpenWrt-Devel] Packages parallel build fixes

2010-07-21 Thread Miguel GAIO
Hi all,

Attached patches fix parallel builds in packages: e2fsprogs, linux-atm,
uclibc++.
Mainly, I prevent the call of "$(MAKE) all install" replaced by
PKG_INSTALL:=1.

Regards,

Miguel
>From 5e3bb11aee0ffa3a5d4ff4f2d89c175d876dd9a2 Mon Sep 17 00:00:00 2001
From: Miguel Gaio 
Date: Wed, 21 Jul 2010 11:16:53 +0200
Subject: [PATCH 1/2]  * e2fsprogs: parallel build fix

---
 package/e2fsprogs/Makefile |8 +---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/package/e2fsprogs/Makefile b/package/e2fsprogs/Makefile
index 847d40d..3a6a966 100644
--- a/package/e2fsprogs/Makefile
+++ b/package/e2fsprogs/Makefile
@@ -1,5 +1,5 @@
 #
-# Copyright (C) 2006-2008 OpenWrt.org
+# Copyright (C) 2006-2010 OpenWrt.org
 # Copyright 2010 Vertical Communications
 # This is free software, licensed under the GNU General Public License v2.
 # See /LICENSE for more information.
@@ -15,6 +15,8 @@ PKG_RELEASE:=1
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
 PKG_SOURCE_URL:=...@sf/e2fsprogs
 
+PKG_INSTALL:=1
+
 include $(INCLUDE_DIR)/package.mk
 
 define Package/e2fsprogs/Default
@@ -64,7 +66,7 @@ define Package/libblkid
 $(call Package/e2fsprogs/Default)
   SECTION:=libs
   CATEGORY:=Libraries
-  TITLE:=block device id library
+  TITLE:=Block device id library
 endef
 
 define Package/libblkid/description
@@ -132,7 +134,7 @@ define Build/Compile
 	$(MAKE) -C $(PKG_BUILD_DIR) \
 		BUILDCC="$(HOSTCC)" \
 		DESTDIR="$(PKG_INSTALL_DIR)" \
-		all install
+		all
 endef
 
 define Build/InstallDev
-- 
1.7.1

>From 799c750310f2e29aeea6036a5b6e01618736c058 Mon Sep 17 00:00:00 2001
From: Miguel Gaio 
Date: Wed, 21 Jul 2010 11:17:52 +0200
Subject: [PATCH 2/2]  * linux-atm: parallel build fix

---
 package/linux-atm/Makefile |8 
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/package/linux-atm/Makefile b/package/linux-atm/Makefile
index fd92cc1..4b12af9 100644
--- a/package/linux-atm/Makefile
+++ b/package/linux-atm/Makefile
@@ -1,5 +1,5 @@
 # 
-# Copyright (C) 2006 OpenWrt.org
+# Copyright (C) 2006-2010 OpenWrt.org
 #
 # This is free software, licensed under the GNU General Public License v2.
 # See /LICENSE for more information.
@@ -16,6 +16,8 @@ PKG_SOURCE:=$(PKG_NAME)_$(PKG_VERSION).orig.tar.gz
 PKG_SOURCE_URL:=http://ftp.debian.org/debian/pool/main/l/linux-atm/
 PKG_MD5SUM:=9560b0e1f410a05b849dfdab465dd758
 
+PKG_INSTALL:=1
+
 include $(INCLUDE_DIR)/package.mk
 
 define Package/linux-atm
@@ -54,9 +56,7 @@ define Build/Compile
 	$(MAKE) -C $(PKG_BUILD_DIR)/src/qgen \
 		LDFLAGS="" \
 		all
-	$(MAKE) -C $(PKG_BUILD_DIR) \
-		DESTDIR="$(PKG_INSTALL_DIR)" \
-		all install
+	$(MAKE) -C $(PKG_BUILD_DIR) all
 endef
 
 define Build/InstallDev
-- 
1.7.1

>From a93c258183151f66007c6b9240d929a2898be028 Mon Sep 17 00:00:00 2001
From: Miguel Gaio 
Date: Wed, 21 Jul 2010 11:19:33 +0200
Subject: [PATCH 1/2]  * uclibc++: parallel build fix

---
 libs/uclibc++/Makefile |   19 +++
 1 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/libs/uclibc++/Makefile b/libs/uclibc++/Makefile
index 5e32966..8351c92 100644
--- a/libs/uclibc++/Makefile
+++ b/libs/uclibc++/Makefile
@@ -17,6 +17,8 @@ PKG_MD5SUM:=1ceef3209cca88be8f1bd9de99735954
 
 PKG_BUILD_DIR:=$(BUILD_DIR)/uClibc++-$(PKG_VERSION)
 
+PKG_INSTALL:=1
+
 include $(INCLUDE_DIR)/package.mk
 
 define Package/uclibcxx
@@ -60,18 +62,11 @@ define Build/Configure
 	fi
 endef
 
-define Build/Compile
-	$(MAKE) -C $(PKG_BUILD_DIR) \
-		$(MAKE_FLAGS) \
-		DESTDIR="$(PKG_INSTALL_DIR)/usr" \
-		all install
-endef
-
 define Build/InstallDev
 	$(INSTALL_DIR) $(2)/bin $(1)/usr/include/uClibc++ $(1)/usr/lib
-	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/g++-uc $(2)/bin/
-	$(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/uClibc++/
-	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libuClibc++*.{a,so*} $(1)/usr/lib/
+	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/bin/g++-uc $(2)/bin/
+	$(CP) $(PKG_INSTALL_DIR)/include/* $(1)/usr/include/uClibc++/
+	$(CP) $(PKG_INSTALL_DIR)/lib/libuClibc++*.a $(1)/usr/lib/
 	$(SED) 's|-I/include/|-I$(STAGING_DIR)/usr/include/uClibc++/|g' $(2)/bin/g++-uc
 	$(SED) 's|-L/lib/|-L$(STAGING_DIR)/usr/lib/|g' $(2)/bin/g++-uc
 # add another wrapper which links against both uClibc++ and libstdc++ 
@@ -83,8 +78,8 @@ endef
 
 define Package/uclibcxx/install
 	$(INSTALL_DIR) $(1)/usr/lib
-	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libuClibc++.so.* $(1)/usr/lib/
-	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libuClibc++-*.so $(1)/usr/lib/
+	$(CP) $(PKG_INSTALL_DIR)/lib/libuClibc++.so.* $(1)/usr/lib/
+	$(CP) $(PKG_INSTALL_DIR)/lib/libuClibc++-*.so $(1)/usr/lib/
 endef
 
 $(eval $(call BuildPackage,uclibcxx))
-- 
1.7.1

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [bcm63xx] fix reset_buttons register

2010-04-29 Thread Miguel GAIO
On Thu, 2010-04-29 at 14:26 +0200, Florian Fainelli wrote:
> Hi Miguel,

Hi Florian,

> 
> On Thursday 29 April 2010 14:23:48 Miguel GAIO wrote:
> > Hi
> > 
> > This is an update of previous patch.
> > 
> > First patch fix gpio buttons device register.
> > Second patch change reset button KEY code from BTN_0 to KEY_RESTART.
> > Last patch add WPS button for NB4 devices.
> > 
> > 0001-bcm63xx-fix-gpio_button-device-register.patch
> > 0002-bcm63xx-fix-gpio-button-key-code.-Match-button-hotpl.patch
> > 0003-bcm63xx-Add-WPS-button-for-nb4-devices.patch
> 
> These patches look fine. May I suggest that we rename the "reset_buttons" 
> field 
> to "buttons" instead, in a subsequent patch for instance.
> 
Sure, I just forgot it.

See new patch

0004-bcm63xx-rename-reset_buttons-to-buttons.patch

> Thank you.
> --
> Florian


Thanks,

Miguel
>From 57a0d78dc8012a2c3cf94f98bd5288dc16d70ca0 Mon Sep 17 00:00:00 2001
From: Miguel Gaio 
Date: Thu, 29 Apr 2010 14:42:36 +0200
Subject: [PATCH 4/4]  * [bcm63xx] rename reset_buttons to buttons

---
 .../patches-2.6.32/100-reset_buttons.patch |   10 +-
 .../patches-2.6.32/140-new_bcm96348gw_leds.patch   |2 +-
 .../patches-2.6.32/150-alice_gate2_leds.patch  |2 +-
 .../200-extended-platform-devices.patch|2 +-
 .../brcm63xx/patches-2.6.32/221-board-NB4.patch|   12 ++--
 .../patches-2.6.33/100-reset_buttons.patch |   10 +-
 .../patches-2.6.33/140-new_bcm96348gw_leds.patch   |2 +-
 .../patches-2.6.33/150-alice_gate2_leds.patch  |2 +-
 .../200-extended-platform-devices.patch|2 +-
 .../brcm63xx/patches-2.6.33/221-board-NB4.patch|   12 ++--
 10 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/target/linux/brcm63xx/patches-2.6.32/100-reset_buttons.patch b/target/linux/brcm63xx/patches-2.6.32/100-reset_buttons.patch
index 45f506b..cbe4d86 100644
--- a/target/linux/brcm63xx/patches-2.6.32/100-reset_buttons.patch
+++ b/target/linux/brcm63xx/patches-2.6.32/100-reset_buttons.patch
@@ -13,7 +13,7 @@
  			.active_low	= 1,
  		},
  	},
-+	.reset_buttons = {
++	.buttons = {
 +		{
 +			.desc		= "reset",
 +			.gpio		= 32,
@@ -30,7 +30,7 @@
  			.active_low	= 1,
  		},
  	},
-+	.reset_buttons = {
++	.buttons = {
 +		{
 +			.desc		= "reset",
 +			.gpio		= 36,
@@ -72,12 +72,12 @@
  	platform_device_register(&bcm63xx_gpio_leds);
  
 +	/* count number of BUTTONs defined by this device */
-+	while (button_count < ARRAY_SIZE(board.reset_buttons) && board.reset_buttons[button_count].desc)
++	while (button_count < ARRAY_SIZE(board.buttons) && board.buttons[button_count].desc)
 +		button_count++;
 +
 +	if (button_count) {
 +		bcm63xx_gpio_buttons_data.nbuttons = button_count;
-+		bcm63xx_gpio_buttons_data.buttons = board.reset_buttons;
++		bcm63xx_gpio_buttons_data.buttons = board.buttons;
 +
 +		platform_device_register(&bcm63xx_gpio_buttons_device);
 +	}
@@ -93,7 +93,7 @@
  	struct gpio_led leds[5];
 +
 +	/* Reset button */
-+	struct gpio_button reset_buttons[2];
++	struct gpio_button buttons[2];
  };
  
  #endif /* ! BOARD_BCM963XX_H_ */
diff --git a/target/linux/brcm63xx/patches-2.6.32/140-new_bcm96348gw_leds.patch b/target/linux/brcm63xx/patches-2.6.32/140-new_bcm96348gw_leds.patch
index d9dba14..4d83287 100644
--- a/target/linux/brcm63xx/patches-2.6.32/140-new_bcm96348gw_leds.patch
+++ b/target/linux/brcm63xx/patches-2.6.32/140-new_bcm96348gw_leds.patch
@@ -79,4 +79,4 @@
 +	struct gpio_led leds[8];
  
  	/* Reset button */
- 	struct gpio_button reset_buttons[1];
+ 	struct gpio_button buttons[1];
diff --git a/target/linux/brcm63xx/patches-2.6.32/150-alice_gate2_leds.patch b/target/linux/brcm63xx/patches-2.6.32/150-alice_gate2_leds.patch
index 7b3f9ff..e464384 100644
--- a/target/linux/brcm63xx/patches-2.6.32/150-alice_gate2_leds.patch
+++ b/target/linux/brcm63xx/patches-2.6.32/150-alice_gate2_leds.patch
@@ -50,7 +50,7 @@
 +		},
 +	},
 +
-+	.reset_buttons = {
++	.buttons = {
 +		{
 +			.desc   = "sw2",
 +			.gpio   = 37,
diff --git a/target/linux/brcm63xx/patches-2.6.32/200-extended-platform-devices.patch b/target/linux/brcm63xx/patches-2.6.32/200-extended-platform-devices.patch
index aec85a3..1076ad4 100644
--- a/target/linux/brcm63xx/patches-2.6.32/200-extended-platform-devices.patch
+++ b/target/linux/brcm63xx/patches-2.6.32/200-extended-platform-devices.patch
@@ -16,7 +16,7 @@
 @@ -59,6 +59,10 @@ struct board_info {
  
  	/* Reset button */
- 	struct gpio_button reset_buttons[2];
+ 	struct gpio_button buttons[2];
 +
 +	/* Additional platform devices */
 +	struct platform_device **devs;
diff --git a/target/linux/brcm63xx/patches-2.6.32/221-board-NB4.patch b/target/linux/brcm63xx/patches-2.6.32/221-board-NB4.patch
index bbd0c62..309e8ad 100644
--- a/target/linux/brcm63xx/patc

Re: [OpenWrt-Devel] [bcm63xx] fix reset_buttons register

2010-04-29 Thread Miguel GAIO
Hi

This is an update of previous patch.

First patch fix gpio buttons device register.
Second patch change reset button KEY code from BTN_0 to KEY_RESTART.
Last patch add WPS button for NB4 devices.

0001-bcm63xx-fix-gpio_button-device-register.patch
0002-bcm63xx-fix-gpio-button-key-code.-Match-button-hotpl.patch
0003-bcm63xx-Add-WPS-button-for-nb4-devices.patch


kind Regards,

Miguel
>From dab1f0f43854b7df161036b4235421b2a3f2bcfb Mon Sep 17 00:00:00 2001
From: Miguel Gaio 
Date: Thu, 29 Apr 2010 10:13:50 +0200
Subject: [PATCH 1/3]  * [bcm63xx] fix gpio_button device register

---
 .../patches-2.6.32/100-reset_buttons.patch |   19 +++
 .../patches-2.6.32/140-new_bcm96348gw_leds.patch   |4 ++--
 .../patches-2.6.33/100-reset_buttons.patch |   19 +++
 .../patches-2.6.33/140-new_bcm96348gw_leds.patch   |4 ++--
 4 files changed, 34 insertions(+), 12 deletions(-)

diff --git a/target/linux/brcm63xx/patches-2.6.32/100-reset_buttons.patch b/target/linux/brcm63xx/patches-2.6.32/100-reset_buttons.patch
index 8c9bcc6..71d8e47 100644
--- a/target/linux/brcm63xx/patches-2.6.32/100-reset_buttons.patch
+++ b/target/linux/brcm63xx/patches-2.6.32/100-reset_buttons.patch
@@ -43,7 +43,7 @@
  };
  
  static struct board_info __initdata board_FAST2404 = {
-@@ -771,6 +793,16 @@ static struct platform_device bcm63xx_gp
+@@ -771,12 +793,23 @@ static struct platform_device bcm63xx_gp
  	.dev.platform_data	= &bcm63xx_led_data,
  };
  
@@ -60,12 +60,23 @@
  /*
   * third stage init callback, register all board devices.
   */
-@@ -826,6 +858,13 @@ int __init board_register_devices(void)
+ int __init board_register_devices(void)
+ {
+ 	u32 val;
++	int button_count = 0;
+ 
+ 	if (board.has_pccard)
+ 		bcm63xx_pcmcia_register();
+@@ -826,6 +859,17 @@ int __init board_register_devices(void)
  
  	platform_device_register(&bcm63xx_gpio_leds);
  
-+	if (board.reset_buttons) {
-+		bcm63xx_gpio_buttons_data.nbuttons = ARRAY_SIZE(board.reset_buttons);
++	/* count number of BUTTONs defined by this device */
++	while (button_count < ARRAY_SIZE(board.reset_buttons) && board.reset_buttons[button_count].desc)
++		button_count++;
++
++	if (button_count) {
++		bcm63xx_gpio_buttons_data.nbuttons = button_count;
 +		bcm63xx_gpio_buttons_data.buttons = board.reset_buttons;
 +
 +		platform_device_register(&bcm63xx_gpio_buttons_device);
diff --git a/target/linux/brcm63xx/patches-2.6.32/140-new_bcm96348gw_leds.patch b/target/linux/brcm63xx/patches-2.6.32/140-new_bcm96348gw_leds.patch
index 3ec4199..d9dba14 100644
--- a/target/linux/brcm63xx/patches-2.6.32/140-new_bcm96348gw_leds.patch
+++ b/target/linux/brcm63xx/patches-2.6.32/140-new_bcm96348gw_leds.patch
@@ -53,10 +53,10 @@
  {
  	u32 val;
 +	int led_count = 0;
+ 	int button_count = 0;
  
  	if (board.has_pccard)
- 		bcm63xx_pcmcia_register();
-@@ -901,7 +917,11 @@ int __init board_register_devices(void)
+@@ -902,7 +918,11 @@ int __init board_register_devices(void)
  
  	platform_device_register_simple("GPIODEV", 0, &gpiodev_resource, 1);
  
diff --git a/target/linux/brcm63xx/patches-2.6.33/100-reset_buttons.patch b/target/linux/brcm63xx/patches-2.6.33/100-reset_buttons.patch
index e1faeee..292e0a7 100644
--- a/target/linux/brcm63xx/patches-2.6.33/100-reset_buttons.patch
+++ b/target/linux/brcm63xx/patches-2.6.33/100-reset_buttons.patch
@@ -43,7 +43,7 @@
  };
  
  static struct board_info __initdata board_FAST2404 = {
-@@ -770,6 +792,16 @@ static struct platform_device bcm63xx_gp
+@@ -770,12 +792,23 @@ static struct platform_device bcm63xx_gp
  	.dev.platform_data	= &bcm63xx_led_data,
  };
  
@@ -60,12 +60,23 @@
  /*
   * third stage init callback, register all board devices.
   */
-@@ -825,6 +857,13 @@ int __init board_register_devices(void)
+ int __init board_register_devices(void)
+ {
+ 	u32 val;
++	int button_count = 0;
+ 
+ 	if (board.has_pccard)
+ 		bcm63xx_pcmcia_register();
+@@ -825,6 +858,17 @@ int __init board_register_devices(void)
  
  	platform_device_register(&bcm63xx_gpio_leds);
  
-+	if (board.reset_buttons) {
-+		bcm63xx_gpio_buttons_data.nbuttons = ARRAY_SIZE(board.reset_buttons);
++	/* count number of BUTTONs defined by this device */
++	while (button_count < ARRAY_SIZE(board.reset_buttons) && board.reset_buttons[button_count].desc)
++		button_count++;
++
++	if (button_count) {
++		bcm63xx_gpio_buttons_data.nbuttons = button_count;
 +		bcm63xx_gpio_buttons_data.buttons = board.reset_buttons;
 +
 +		platform_device_register(&bcm63xx_gpio_buttons_device);
diff --git a/target/linux/brcm63xx/patches-2.6.33/140-new_bcm96348gw_leds.patch b/target/linux/brcm63xx/patches-2.6.33/140-new_bcm96348gw_leds.patch
index f1a66c9..292f196 100644
--- a/target/linux/brcm63xx/patches-2.6.33/140-new_bcm96348gw_leds.patch
+++ b/target/linux/brcm63xx/patches-2.6.33/140-new_bcm96348gw_leds.patch
@@ -53,10 +53,10 @@
  {
  	u32 val;
 +	int led_count = 0;
+ 	int button_count = 0;
  
  	

[OpenWrt-Devel] [bcm63xx] fix reset_buttons register

2010-04-28 Thread Miguel GAIO
Hi,

In preparation of integration of more gpio buttons on NB4 (e.g WPS,
RESET button), this patch fix an issue on reset_button registration
code.

Current code always register gpio_button_device regardless board defined
data or not. 

if (board.reset_buttons) {
bcm63xx_gpio_buttons_data.nbuttons =
ARRAY_SIZE(board.reset_buttons);
bcm63xx_gpio_buttons_data.buttons = board.reset_buttons;

platform_device_register(&bcm63xx_gpio_buttons_device);
}

Indeed, board.reset_buttons array is embedded into struct board.

Fix uses same method as gpio leds array registration.
I'm not happy with it. Open to get other method.

Kind Regards,

Miguel
Index: openwrt.org/target/linux/brcm63xx/patches-2.6.32/100-reset_buttons.patch
===
--- openwrt.org/target/linux/brcm63xx/patches-2.6.32/100-reset_buttons.patch	(revision 21237)
+++ openwrt.org/target/linux/brcm63xx/patches-2.6.32/100-reset_buttons.patch	(working copy)
@@ -43,7 +43,7 @@
  };
  
  static struct board_info __initdata board_FAST2404 = {
-@@ -771,6 +793,16 @@ static struct platform_device bcm63xx_gp
+@@ -771,12 +793,23 @@ static struct platform_device bcm63xx_gp
  	.dev.platform_data	= &bcm63xx_led_data,
  };
  
@@ -60,12 +60,23 @@
  /*
   * third stage init callback, register all board devices.
   */
-@@ -826,6 +858,13 @@ int __init board_register_devices(void)
+ int __init board_register_devices(void)
+ {
+ 	u32 val;
++	int button_count = 0;
  
+ 	if (board.has_pccard)
+ 		bcm63xx_pcmcia_register();
+@@ -826,6 +859,17 @@ int __init board_register_devices(void)
+ 
  	platform_device_register(&bcm63xx_gpio_leds);
  
-+	if (board.reset_buttons) {
-+		bcm63xx_gpio_buttons_data.nbuttons = ARRAY_SIZE(board.reset_buttons);
++	/* count number of BUTTONs defined by this device */
++	while (button_count < ARRAY_SIZE(board.reset_buttons) && board.reset_buttons[button_count].desc)
++		button_count++;
++
++	if (button_count) {
++		bcm63xx_gpio_buttons_data.nbuttons = button_count;
 +		bcm63xx_gpio_buttons_data.buttons = board.reset_buttons;
 +
 +		platform_device_register(&bcm63xx_gpio_buttons_device);
Index: openwrt.org/target/linux/brcm63xx/patches-2.6.32/140-new_bcm96348gw_leds.patch
===
--- openwrt.org/target/linux/brcm63xx/patches-2.6.32/140-new_bcm96348gw_leds.patch	(revision 21237)
+++ openwrt.org/target/linux/brcm63xx/patches-2.6.32/140-new_bcm96348gw_leds.patch	(working copy)
@@ -53,10 +53,10 @@
  {
  	u32 val;
 +	int led_count = 0;
+ 	int button_count = 0;
  
  	if (board.has_pccard)
- 		bcm63xx_pcmcia_register();
-@@ -901,7 +917,11 @@ int __init board_register_devices(void)
+@@ -902,7 +918,11 @@ int __init board_register_devices(void)
  
  	platform_device_register_simple("GPIODEV", 0, &gpiodev_resource, 1);
  
Index: openwrt.org/target/linux/brcm63xx/patches-2.6.33/100-reset_buttons.patch
===
--- openwrt.org/target/linux/brcm63xx/patches-2.6.33/100-reset_buttons.patch	(revision 21237)
+++ openwrt.org/target/linux/brcm63xx/patches-2.6.33/100-reset_buttons.patch	(working copy)
@@ -43,7 +43,7 @@
  };
  
  static struct board_info __initdata board_FAST2404 = {
-@@ -770,6 +792,16 @@ static struct platform_device bcm63xx_gp
+@@ -770,12 +792,23 @@ static struct platform_device bcm63xx_gp
  	.dev.platform_data	= &bcm63xx_led_data,
  };
  
@@ -60,12 +60,23 @@
  /*
   * third stage init callback, register all board devices.
   */
-@@ -825,6 +857,13 @@ int __init board_register_devices(void)
+ int __init board_register_devices(void)
+ {
+ 	u32 val;
++	int button_count = 0;
  
+ 	if (board.has_pccard)
+ 		bcm63xx_pcmcia_register();
+@@ -825,6 +858,17 @@ int __init board_register_devices(void)
+ 
  	platform_device_register(&bcm63xx_gpio_leds);
  
-+	if (board.reset_buttons) {
-+		bcm63xx_gpio_buttons_data.nbuttons = ARRAY_SIZE(board.reset_buttons);
++	/* count number of BUTTONs defined by this device */
++	while (button_count < ARRAY_SIZE(board.reset_buttons) && board.reset_buttons[button_count].desc)
++		button_count++;
++
++	if (button_count) {
++		bcm63xx_gpio_buttons_data.nbuttons = button_count;
 +		bcm63xx_gpio_buttons_data.buttons = board.reset_buttons;
 +
 +		platform_device_register(&bcm63xx_gpio_buttons_device);
Index: openwrt.org/target/linux/brcm63xx/patches-2.6.33/140-new_bcm96348gw_leds.patch
===
--- openwrt.org/target/linux/brcm63xx/patches-2.6.33/140-new_bcm96348gw_leds.patch	(revision 21237)
+++ openwrt.org/target/linux/brcm63xx/patches-2.6.33/140-new_bcm96348gw_leds.patch	(working copy)
@@ -53,10 +53,10 @@
  {
  	u32 val;
 +	int led_count = 0;
+ 	int button_count = 0;
  
  	if (board.has_pccard)
- 		bcm63xx_pcmcia_register();
-@@ -900,7 +916,11 @@ int __init board_register_devices(void)
+@@ -901,7 +917,11 @@ int

[OpenWrt-Devel] [bcm6358] fix enet1 mii clk

2010-04-28 Thread Miguel GAIO
Hi,

The attached patch fixup the setup of MII clock for case enet1 is linked
to external switch for 6358 soc base boards.

Warning! Despite, this improves stability on NB4 and 96358VW boards, it
must be confirmed on other boards.

Kind Regards,

Miguel
Index: openwrt.org/target/linux/brcm63xx/patches-2.6.32/250-6358-enet1-external-mii-clk.patch
===
--- openwrt.org/target/linux/brcm63xx/patches-2.6.32/250-6358-enet1-external-mii-clk.patch	(revision 0)
+++ openwrt.org/target/linux/brcm63xx/patches-2.6.32/250-6358-enet1-external-mii-clk.patch	(revision 0)
@@ -0,0 +1,22 @@
+--- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
 b/arch/mips/bcm63xx/boards/board_bcm963xx.c
+@@ -1308,6 +1308,8 @@ void __init board_prom_init(void)
+ 		if (BCMCPU_IS_6348())
+ 			val |= GPIO_MODE_6348_G3_EXT_MII |
+ GPIO_MODE_6348_G0_EXT_MII;
++		else if (BCMCPU_IS_6358())
++			val |= GPIO_MODE_6358_ENET1_MII_CLK_INV;
+ 	}
+ 
+ 	bcm_gpio_writel(val, GPIO_MODE_REG);
+--- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h
 b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h
+@@ -402,6 +402,8 @@
+ #define GPIO_MODE_6358_EXTRA_SPI_SS	(1 << 7)
+ #define GPIO_MODE_6358_SERIAL_LED	(1 << 10)
+ #define GPIO_MODE_6358_UTOPIA		(1 << 12)
++#define GPIO_MODE_6358_ENET0_MII_CLK_INV (1 << 30)
++#define GPIO_MODE_6358_ENET1_MII_CLK_INV (1 << 31)
+ 
+ 
+ /*
Index: openwrt.org/target/linux/brcm63xx/patches-2.6.33/250-6358-enet1-external-mii-clk.patch
===
--- openwrt.org/target/linux/brcm63xx/patches-2.6.33/250-6358-enet1-external-mii-clk.patch	(revision 0)
+++ openwrt.org/target/linux/brcm63xx/patches-2.6.33/250-6358-enet1-external-mii-clk.patch	(revision 0)
@@ -0,0 +1,22 @@
+--- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
 b/arch/mips/bcm63xx/boards/board_bcm963xx.c
+@@ -1308,6 +1308,8 @@ void __init board_prom_init(void)
+ 		if (BCMCPU_IS_6348())
+ 			val |= GPIO_MODE_6348_G3_EXT_MII |
+ GPIO_MODE_6348_G0_EXT_MII;
++		else if (BCMCPU_IS_6358())
++			val |= GPIO_MODE_6358_ENET1_MII_CLK_INV;
+ 	}
+ 
+ 	bcm_gpio_writel(val, GPIO_MODE_REG);
+--- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h
 b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_regs.h
+@@ -402,6 +402,8 @@
+ #define GPIO_MODE_6358_EXTRA_SPI_SS	(1 << 7)
+ #define GPIO_MODE_6358_SERIAL_LED	(1 << 10)
+ #define GPIO_MODE_6358_UTOPIA		(1 << 12)
++#define GPIO_MODE_6358_ENET0_MII_CLK_INV (1 << 30)
++#define GPIO_MODE_6358_ENET1_MII_CLK_INV (1 << 31)
+ 
+ 
+ /*
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [bcm63xx] WDT driver, dump registers, call trace before reboot

2010-04-27 Thread Miguel GAIO
Hi,

The attached path extends bcm63xx_wdt driver.

It registers TIMER_WDT callback.
Callback calls die(), that dump current context.

This can be usefull for debug purpose.

Kind Regards,

Miguel

Index: openwrt.org/target/linux/brcm63xx/patches-2.6.32/020-watchdog.patch
===
--- openwrt.org/target/linux/brcm63xx/patches-2.6.32/020-watchdog.patch	(revision 21193)
+++ openwrt.org/target/linux/brcm63xx/patches-2.6.32/020-watchdog.patch	(working copy)
@@ -29,7 +29,7 @@
  # POWERPC Architecture
 --- /dev/null
 +++ b/drivers/watchdog/bcm63xx_wdt.c
-@@ -0,0 +1,334 @@
+@@ -0,0 +1,354 @@
 +/*
 + *  Broadcom BCM63xx SoC watchdog driver
 + *
@@ -56,12 +56,15 @@
 +#include 
 +#include 
 +#include 
++#include 
++#include 
 +#include 
 +#include 
 +
 +#include 
 +#include 
 +#include 
++#include 
 +
 +#define PFX KBUILD_MODNAME
 +
@@ -78,7 +81,6 @@
 +} bcm63xx_wdt_device;
 +
 +static int expect_close;
-+static int timeout;
 +
 +static int wdt_time = WDT_DEFAULT_TIME;
 +static int nowayout = WATCHDOG_NOWAYOUT;
@@ -100,6 +102,13 @@
 +	bcm_writel(WDT_STOP_2, bcm63xx_wdt_device.regs + WDT_CTL_REG);
 +}
 +
++static void bcm63xx_wdt_isr(void *data)
++{
++	struct pt_regs *regs = get_irq_regs();
++
++	die(PFX " fire", regs);
++}
++
 +static void bcm63xx_timer_tick(unsigned long unused)
 +{
 +	if (!atomic_dec_and_test(&bcm63xx_wdt_device.ticks)) {
@@ -292,6 +301,13 @@
 +		return -ENXIO;
 +	}
 +
++	ret = bcm63xx_timer_register(TIMER_WDT_ID, bcm63xx_wdt_isr, NULL);
++	if (ret < 0) {
++		printk(KERN_ERR PFX
++			"failed to register wdt timer isr\n");
++		goto unmap;
++	}
++
 +	if (bcm63xx_wdt_settimeout(wdt_time)) {
 +		bcm63xx_wdt_settimeout(WDT_DEFAULT_TIME);
 +		printk(KERN_INFO PFX
@@ -303,22 +319,25 @@
 +	if (ret) {
 +		printk(KERN_ERR PFX
 +			"failed to register reboot_notifier\n");
-+		return ret;
++		goto unregister_timer;
 +	}
 +
 +	ret = misc_register(&bcm63xx_wdt_miscdev);
 +	if (ret < 0) {
 +		printk(KERN_ERR PFX
 +			"failed to register watchdog device\n");
-+		goto unmap;
++		goto unregister_reboot_notifier;
 +	}
 +
 +	printk(KERN_INFO PFX " started, timer margin: %d sec\n", WDT_DEFAULT_TIME);
 +
 +	return 0;
 +
++unregister_reboot_notifier:
++	unregister_reboot_notifier(&bcm63xx_wdt_notifier);
++unregister_timer:
++	bcm63xx_timer_unregister(TIMER_WDT_ID);
 +unmap:
-+	unregister_reboot_notifier(&bcm63xx_wdt_notifier);
 +	iounmap(bcm63xx_wdt_device.regs);
 +	return ret;
 +}
@@ -333,6 +352,7 @@
 +	iounmap(bcm63xx_wdt_device.regs);
 +
 +	unregister_reboot_notifier(&bcm63xx_wdt_notifier);
++	bcm63xx_timer_unregister(TIMER_WDT_ID);
 +
 +	return 0;
 +}
Index: openwrt.org/target/linux/brcm63xx/patches-2.6.33/020-watchdog.patch
===
--- openwrt.org/target/linux/brcm63xx/patches-2.6.33/020-watchdog.patch	(revision 21193)
+++ openwrt.org/target/linux/brcm63xx/patches-2.6.33/020-watchdog.patch	(working copy)
@@ -29,7 +29,7 @@
  # POWERPC Architecture
 --- /dev/null
 +++ b/drivers/watchdog/bcm63xx_wdt.c
-@@ -0,0 +1,334 @@
+@@ -0,0 +1,354 @@
 +/*
 + *  Broadcom BCM63xx SoC watchdog driver
 + *
@@ -56,12 +56,15 @@
 +#include 
 +#include 
 +#include 
++#include 
++#include 
 +#include 
 +#include 
 +
 +#include 
 +#include 
 +#include 
++#include 
 +
 +#define PFX KBUILD_MODNAME
 +
@@ -78,7 +81,6 @@
 +} bcm63xx_wdt_device;
 +
 +static int expect_close;
-+static int timeout;
 +
 +static int wdt_time = WDT_DEFAULT_TIME;
 +static int nowayout = WATCHDOG_NOWAYOUT;
@@ -100,6 +102,13 @@
 +	bcm_writel(WDT_STOP_2, bcm63xx_wdt_device.regs + WDT_CTL_REG);
 +}
 +
++static void bcm63xx_wdt_isr(void *data)
++{
++	struct pt_regs *regs = get_irq_regs();
++
++	die(PFX " fire", regs);
++}
++
 +static void bcm63xx_timer_tick(unsigned long unused)
 +{
 +	if (!atomic_dec_and_test(&bcm63xx_wdt_device.ticks)) {
@@ -292,6 +301,13 @@
 +		return -ENXIO;
 +	}
 +
++	ret = bcm63xx_timer_register(TIMER_WDT_ID, bcm63xx_wdt_isr, NULL);
++	if (ret < 0) {
++		printk(KERN_ERR PFX
++			"failed to register wdt timer isr\n");
++		goto unmap;
++	}
++
 +	if (bcm63xx_wdt_settimeout(wdt_time)) {
 +		bcm63xx_wdt_settimeout(WDT_DEFAULT_TIME);
 +		printk(KERN_INFO PFX
@@ -303,22 +319,25 @@
 +	if (ret) {
 +		printk(KERN_ERR PFX
 +			"failed to register reboot_notifier\n");
-+		return ret;
++		goto unregister_timer;
 +	}
 +
 +	ret = misc_register(&bcm63xx_wdt_miscdev);
 +	if (ret < 0) {
 +		printk(KERN_ERR PFX
 +			"failed to register watchdog device\n");
-+		goto unmap;
++		goto unregister_reboot_notifier;
 +	}
 +
 +	printk(KERN_INFO PFX " started, timer margin: %d sec\n", WDT_DEFAULT_TIME);
 +
 +	return 0;
 +
++unregister_reboot_notifier:
++	unregister_reboot_notifier(&bcm63xx_wdt_notifier);
++unregister_timer:
++	bcm63xx_timer_unregister(TIMER_WDT_ID);
 +unmap:
-+	unregister_reboot_notifier(&bcm63xx_wdt_notifier);
 +	iounmap(bcm63xx_wdt_device.regs);
 +	return ret;
 +}
@@ -333,6 +352,7 @@
 +	iounmap(bcm63xx_wdt_device.regs);
 +
 +	unregister_reboot

Re: [OpenWrt-Devel] [bcm63xx] Add support for neufbox4 boards (French ISP boards)

2010-04-27 Thread Miguel GAIO
On Tue, 2010-04-27 at 11:36 +0200, Florian Fainelli wrote:
> Hi Miguel,
> 
> On Tuesday 27 April 2010 11:10:11 Miguel GAIO wrote:
> > Hi,
> > 
> > The two following patches add preliminary support for neufbox4 boards.
> > Boards are 6358 SoC base.
> > It's support all boards releases from different OEM.
> > 
> > The first patch add support for 74HC164 chip. A 8 pins GPIO output
> > expander. use to control leds.
> > 
> > Second one add support for all supported boardIDs:
> >  - NB4-SER-R0
> >  - NB4-SER-R1
> >  - NB4-SER-R2
> >  - NB4-FXC-R1
> >  - NB4-FXC-R2
> > 
> > All boards provide unique BoardID "96358VW" that conflits with real
> > 96358VW devices.
> > The patch add Board ID fixup to get correct BoardID.
> 
> I think a callback to fixup the board id might be better in the long term. 
> Some 
> other designs got inspired from a reference design but have different LEDs 
> mapping for instance. Right now, this is fine with me, but that will need to 
> evolve to support different matching schemes.

Ok, I updated nb4 patch. add neufbox4_nvram_fixup() callback.

> 
> > 
> > I increase leds count to 9.
> 
> This is fine.
> 
> > 
> > I use the BoardID to register 74HC164 platform device. Maybe, it can be
> > done other ways.
> 
> The board structure might also hold a pointer to an array of struct 
> platform_device to register additionnal platform devices.
> 
I agree, it's provide more flexible interface.

> Do you want to push that upstream too?

Ok, see new patches set.
I also fix a typo on nxp74hc164 patch

> 
> Thank you for your contribution.
> --
> Florian

Thanks you for your review

Regards,

Miguel

Index: openwrt.org/target/linux/brcm63xx/patches-2.6.32/200-extended-platform-devices.patch
===
--- openwrt.org/target/linux/brcm63xx/patches-2.6.32/200-extended-platform-devices.patch	(revision 0)
+++ openwrt.org/target/linux/brcm63xx/patches-2.6.32/200-extended-platform-devices.patch	(revision 0)
@@ -0,0 +1,26 @@
+--- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
 b/arch/mips/bcm63xx/boards/board_bcm963xx.c
+@@ -995,6 +995,10 @@ int __init board_register_devices(void)
+ 		platform_device_register(&bcm63xx_gpio_buttons_device);
+ 	}
+ 
++	if (board.num_devs) {
++		platform_add_devices(board.devs, board.num_devs);
++	}
++
+ 	return 0;
+ }
+ 
+--- a/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h
 b/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h
+@@ -59,6 +59,10 @@ struct board_info {
+ 
+ 	/* Reset button */
+ 	struct gpio_button reset_buttons[1];
++
++	/* Additional platform devices */
++	struct platform_device **devs;
++	unsigned int	num_devs;
+ };
+ 
+ #endif /* ! BOARD_BCM963XX_H_ */
Index: openwrt.org/target/linux/brcm63xx/patches-2.6.33/200-extended-platform-devices.patch
===
--- openwrt.org/target/linux/brcm63xx/patches-2.6.33/200-extended-platform-devices.patch	(revision 0)
+++ openwrt.org/target/linux/brcm63xx/patches-2.6.33/200-extended-platform-devices.patch	(revision 0)
@@ -0,0 +1,26 @@
+--- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
 b/arch/mips/bcm63xx/boards/board_bcm963xx.c
+@@ -995,6 +995,10 @@ int __init board_register_devices(void)
+ 		platform_device_register(&bcm63xx_gpio_buttons_device);
+ 	}
+ 
++	if (board.num_devs) {
++		platform_add_devices(board.devs, board.num_devs);
++	}
++
+ 	return 0;
+ }
+ 
+--- a/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h
 b/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h
+@@ -59,6 +59,10 @@ struct board_info {
+ 
+ 	/* Reset button */
+ 	struct gpio_button reset_buttons[1];
++
++	/* Additional platform devices */
++	struct platform_device **devs;
++	unsigned int	num_devs;
+ };
+ 
+ #endif /* ! BOARD_BCM963XX_H_ */
Index: openwrt.org/target/linux/brcm63xx/config-2.6.32
===
--- openwrt.org/target/linux/brcm63xx/config-2.6.32	(revision 21161)
+++ openwrt.org/target/linux/brcm63xx/config-2.6.32	(working copy)
@@ -82,6 +82,7 @@
 CONFIG_GENERIC_HARDIRQS_NO__DO_IRQ=y
 CONFIG_GPIOLIB=y
 CONFIG_GPIO_DEVICE=y
+CONFIG_GPIO_NXP_74HC164=y
 CONFIG_GPIO_SYSFS=y
 # CONFIG_HAMRADIO is not set
 CONFIG_HARDWARE_WATCHPOINTS=y
Index: openwrt.org/target/linux/brcm63xx/patches-2.6.32/221-board-NB4.patch
===
--- openwrt.org/target/linux/brcm63xx/patches-2.6.32/221-board-NB4.patch	(revision 0)
+++ openwrt.org/target/linux/brcm63xx/patches-2.6.32/221-board-NB4.patch	(revision 0)
@@ -0,0 +1,517 @@
+--- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
 b/arch/mips/bcm63xx/boards/board_bcm963xx.c
+@@ -17,6 +17,7 @@
+ #include 
+ #include 
+ #i

[OpenWrt-Devel] [bcm63xx] Add support for neufbox4 boards (French ISP boards)

2010-04-27 Thread Miguel GAIO
ons_data,
+ };
+ 
++static struct nxp_74hc164_platform_data neufbox4_74hc164_data = {
++	.gpio_base  = NEUFBOX4_EXP_GPIO_BASE,
++	.gpio_pin_data  = NEUFBOX4_GPIO_74HC164_DATA,
++	.gpio_pin_clk   = NEUFBOX4_GPIO_74HC164_CLK,
++
++};
++
++static struct platform_device neufbox4_74hc164_device = {
++	.name   = NXP_74HC164_DRIVER_NAME,
++	.id = -1,
++	.dev = {
++		.platform_data  = &neufbox4_74hc164_data,
++	}
++};
++
+ /*
+  * third stage init callback, register all board devices.
+  */
+@@ -1021,6 +1462,9 @@ int __init board_register_devices(void)
+ 
+ 	platform_device_register(&mtd_dev);
+ 
++	if (BCMCPU_IS_6358() && (!memcmp(board.name, "NB4-", 4)))
++		platform_device_register(&neufbox4_74hc164_device);
++
+ 	platform_device_register_simple("GPIODEV", 0, &gpiodev_resource, 1);
+ 
+ 	/* count number of LEDs defined by this device */
+--- a/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h
 b/arch/mips/include/asm/mach-bcm63xx/board_bcm963xx.h
+@@ -55,7 +55,7 @@ struct board_info {
+ 	struct bcm63xx_dsp_platform_data dsp;
+ 
+ 	/* GPIO LEDs */
+-	struct gpio_led leds[8];
++	struct gpio_led leds[9];
+ 
+ 	/* Reset button */
+ 	struct gpio_button reset_buttons[1];
Index: openwrt.org/target/linux/brcm63xx/patches-2.6.32/211-nxp-74hc164-gpio-chip-driver.patch
=======
--- openwrt.org/target/linux/brcm63xx/patches-2.6.32/211-nxp-74hc164-gpio-chip-driver.patch	(revision 0)
+++ openwrt.org/target/linux/brcm63xx/patches-2.6.32/211-nxp-74hc164-gpio-chip-driver.patch	(revision 0)
@@ -0,0 +1,279 @@
+--- a/drivers/gpio/Kconfig
 b/drivers/gpio/Kconfig
+@@ -230,4 +230,12 @@ config GPIO_UCB1400
+ 	  To compile this driver as a module, choose M here: the
+ 	  module will be called ucb1400_gpio.
+ 
++comment "Other GPIO expanders"
++
++config GPIO_NXP_74HC164
++   tristate "NXP 74HC164 Output expanders"
++   help
++ Platform driver for NXP 74HC164 8-output Expanders. This
++ provides a GPIO interface supporting outputs.
++
+ endif
+--- a/drivers/gpio/Makefile
 b/drivers/gpio/Makefile
+@@ -10,6 +10,7 @@ obj-$(CONFIG_GPIO_MAX7301)	+= max7301.o
+ obj-$(CONFIG_GPIO_MAX732X)	+= max732x.o
+ obj-$(CONFIG_GPIO_MC33880)	+= mc33880.o
+ obj-$(CONFIG_GPIO_MCP23S08)	+= mcp23s08.o
++obj-$(CONFIG_GPIO_NXP_74HC164)	+= nxp_74hc164.o
+ obj-$(CONFIG_GPIO_PCA953X)	+= pca953x.o
+ obj-$(CONFIG_GPIO_PCF857X)	+= pcf857x.o
+ obj-$(CONFIG_GPIO_PL061)	+= pl061.o
+--- /dev/null
 b/drivers/gpio/nxp_74hc164.c
+@@ -0,0 +1,226 @@
++/*
++ *  NXP 74HC164 - output expander  GPIO driver
++ *
++ *  Copyright (C) 2010 Gabor Juhos 
++ *  Copyright (C) 2010 Miguel Gaio 
++ *
++ *  This program is free software; you can redistribute it and/or modify
++ *  it under the terms of the GNU General Public License version 2 as
++ *  published by the Free Software Foundation.
++ *
++ *  Copy from nxp_74hc153.c code
++ */
++
++#include 
++#include 
++#include 
++#include 
++#include 
++#include 
++
++#define NXP_74HC164_NUM_GPIOS	8
++
++struct nxp_74hc164_chip {
++	struct device		*parent;
++	struct gpio_chip	gpio_chip;
++	struct mutex		lock;
++	long			mask;
++};
++
++static void nxp_74hc164_set_value(struct gpio_chip *, unsigned, int);
++
++static struct nxp_74hc164_chip *gpio_to_nxp(struct gpio_chip *gc)
++{
++	return container_of(gc, struct nxp_74hc164_chip, gpio_chip);
++}
++
++static int nxp_74hc164_direction_input(struct gpio_chip *gc, unsigned offset)
++{
++	WARN_ON(1);
++	return -EINVAL;
++}
++
++static int nxp_74hc164_direction_output(struct gpio_chip *gc,
++	unsigned offset, int val)
++{
++	nxp_74hc164_set_value(gc, offset, val);
++	return 0;
++}
++
++static int nxp_74hc164_get_value(struct gpio_chip *gc, unsigned offset)
++{
++	struct nxp_74hc164_chip *nxp = gpio_to_nxp(gc);
++	int ret;
++
++	mutex_lock(&nxp->lock);
++	ret = test_bit(offset, &nxp->mask);
++	mutex_unlock(&nxp->lock);
++
++	return ret;
++}
++
++static void nxp_74hc164_set_value(struct gpio_chip *gc,
++  unsigned offset, int val)
++{
++	struct nxp_74hc164_chip *nxp;
++	struct nxp_74hc164_platform_data *pdata;
++	long mask;
++	int refresh;
++	int i;
++
++	nxp = gpio_to_nxp(gc);
++	pdata = nxp->parent->platform_data;
++
++	mutex_lock(&nxp->lock);
++	if (val)
++		refresh = (test_and_set_bit(offset, &nxp->mask) != val);
++	else
++		refresh = (test_and_clear_bit(offset, &nxp->mask) != val);
++
++	if (refresh) {
++		mask = nxp->mask;
++		for (i = 8; i > 0; --i, mask <<= 1) {
++			gpio_set_value(pdata->gpio_pin_data, mask & 0x80);
++			gpio_set_value(pdata->gpio_pin_clk, 1);
++			gpio_set_value(pdata->gpio_pin_clk, 0);
++		}
++	}
++	mutex_unlock(&nxp->lock);
++}
++
++static int __devinit nxp_74hc164_probe(struct platform_device *pdev)
++{
++	struct nxp_74hc164_platform_data *pdata;
++	struct nxp_74hc164_chip *nxp;
++	struct gpio_chip *gc;
++	int 

[OpenWrt-Devel] neufbox4 board support

2010-03-05 Thread Miguel GAIO
Hi,

The attached patches fix support for neufbox4 boards.
Patches are base on 2.6.32.9 kernel.

First patch brings support for 74HC164 GPIO expander.
It's mainly a copy from
target/linux/ar71xx/files/drivers/gpio/nxp_74hc153.c platform driver.

Second patch fixup buggy board names, using neufbox4 PID offset.
Then declares new boards info:
 - NB4-SER-r0
 - NB4-SER-r1
 - NB4-SER-r2
 - NB4-FXC-r1
 - NB4-FXC-r2.

Eventually, I enable 74HC164 driver in kernel config.


Yours,

Miguel
Index: target/linux/brcm63xx/patches-2.6.32/300-board_neufbox4.patch
===
--- target/linux/brcm63xx/patches-2.6.32/300-board_neufbox4.patch	(revision 0)
+++ target/linux/brcm63xx/patches-2.6.32/300-board_neufbox4.patch	(revision 0)
@@ -0,0 +1,522 @@
+--- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
 b/arch/mips/bcm63xx/boards/board_bcm963xx.c
+@@ -5,6 +5,7 @@
+  *
+  * Copyright (C) 2008 Maxime Bizon 
+  * Copyright (C) 2008 Florian Fainelli 
++ * Copyright (C) 2010 Miguel Gaio 
+  */
+ 
+ #include 
+@@ -17,6 +18,7 @@
+ #include 
+ #include 
+ #include 
++#include 
+ #include 
+ #include 
+ #include 
+@@ -33,6 +35,11 @@
+ 
+ #define PFX	"board_bcm963xx: "
+ 
++#define NEUFBOX4_EXP_GPIO_BASE		64
++#define NEUFBOX4_GPIO_74HC164_DATA	7
++#define NEUFBOX4_GPIO_74HC164_CLK	6
++#define NXP_74HC64_GPIO(X)		(NEUFBOX4_EXP_GPIO_BASE + (X))
++
+ static struct bcm963xx_nvram nvram;
+ static unsigned int mac_addr_used;
+ static struct board_info board;
+@@ -670,6 +677,412 @@ static struct board_info __initdata boar
+ 
+ 	.has_ohci0 = 1,
+ };
++
++static struct board_info __initdata board_nb4_ser_r0 = {
++	.name= "NB4-SER-r0",
++	.expected_cpu_id		= 0x6358,
++
++	.has_enet0			= 1,
++	.has_enet1			= 1,
++	.has_pci			= 1,
++
++	.enet0 = {
++		.has_phy		= 1,
++		.use_internal_phy	= 1,
++	},
++
++	.enet1 = {
++		.force_speed_100	= 1,
++		.force_duplex_full	= 1,
++	},
++
++
++	.has_ohci0 = 1,
++	.has_pccard = 1,
++	.has_ehci0 = 1,
++
++	.has_udc0			= 1,
++
++	.leds = {
++		{
++			.name		= "adsl",
++			.gpio		= NXP_74HC64_GPIO(4),
++			.active_low	= 1,
++		},
++		{
++			.name		= "traffic",
++			.gpio		= 2,
++			.active_low	= 1,
++		},
++		{
++			.name		= "tel",
++			.gpio		= NXP_74HC64_GPIO(3),
++			.active_low	= 1,
++		},
++		{
++			.name		= "tv",
++			.gpio		= NXP_74HC64_GPIO(2),
++			.active_low	= 1,
++		},
++		{
++			.name		= "wifi",
++			.gpio		= 15,
++			.active_low	= 1,
++		},
++		{
++			.name		= "alarm",
++			.gpio		= NXP_74HC64_GPIO(0),
++			.active_low	= 1,
++		},
++		{
++			.name		= "service:red",
++			.gpio		= 29,
++			.active_low	= 1,
++		},
++		{
++			.name		= "service:green",
++			.gpio		= 30,
++			.active_low	= 1,
++		},
++		{
++			.name		= "service:blue",
++			.gpio		= 4,
++			.active_low	= 1,
++		},
++	},
++	.reset_buttons = {
++		{
++			.desc		= "reset",
++			.gpio		= 34,
++			.active_low	= 1,
++			.type		= EV_KEY,
++			.code		= BTN_0,
++			.threshold	= 3,
++		},
++	},
++};
++
++static struct board_info __initdata board_nb4_ser_r1 = {
++	.name= "NB4-SER-r1",
++	.expected_cpu_id		= 0x6358,
++
++	.has_enet0			= 1,
++	.has_enet1			= 1,
++	.has_pci			= 1,
++
++	.enet0 = {
++		.has_phy		= 1,
++		.use_internal_phy	= 1,
++	},
++
++	.enet1 = {
++		.force_speed_100	= 1,
++		.force_duplex_full	= 1,
++	},
++
++
++	.has_ohci0 = 1,
++	.has_pccard = 1,
++	.has_ehci0 = 1,
++
++	.has_udc0			= 1,
++
++	.leds = {
++		{
++			.name		= "adsl",
++			.gpio		= NXP_74HC64_GPIO(4),
++			.active_low	= 1,
++		},
++		{
++			.name		= "traffic",
++			.gpio		= 2,
++			.active_low	= 1,
++		},
++		{
++			.name		= "tel",
++			.gpio		= NXP_74HC64_GPIO(3),
++			.active_low	= 1,
++		},
++		{
++			.name		= "tv",
++			.gpio		= NXP_74HC64_GPIO(2),
++			.active_low	= 1,
++		},
++		{
++			.name		= "wifi",
++			.gpio		= 15,
++			.active_low	= 1,
++		},
++		{
++			.name		= "alarm",
++			.gpio		= NXP_74HC64_GPIO(0),
++			.active_low	= 1,
++		},
++		{
++			.name		= "service:red",
++			.gpio		= 29,
++			.active_low	= 1,
++		},
++		{
++			.name		= "service:green",
++			.gpio		= 30,
++			.active_low	= 1,
++		},
++		{
++			.name		= "service:blue",
++			.gpio		= 4,
++			.active_low	= 1,
++		},
++	},
++	.reset_buttons = {
++		{
++			.desc		= "reset",
++			.gpio		= 34,
++			.active_low	= 1,
++			.type		= EV_KEY,
++			.code		= BTN_0,
++			.threshold	= 3,
++		},
++	},
++};
++
++static struct board_info __initdata board_nb4_ser_r2 = {
++	.name= "NB4-SER-r2",
++	.expected_cpu_id		= 0x6358,
++
++	.has_enet0			= 1,
++	.has_enet1			= 1,
++	.has_pci			= 1,
++
++	.enet0 = {
++		.has_phy		= 1,
++		.use_internal_phy	= 1,
++	},
++
++	.enet1 = {
++		.force_speed_100	= 1,
++		.force_duplex_full	= 1,
++	},
++
++
++	.has_ohci0 = 1,
++	.has_pccard = 1,
++	.has_ehci0 =