[LEDE-DEV] [RFC] brcm63xx: Add NAND flash support

2018-04-13 Thread Daniel Gonzalez Cabanelas
Hi, since the adoption of the Linux kernel 4.9 there are available drivers for 
NAND flash in the brcm63xx target. However these drivers only support brcm NAND 
versions 4.0 and  and up, giving support only for BCM6362 and BCM63268 SoCs

I've made a patch for including the versions present in BCM6328 and BCM6368 
(versions 2.1 and 2.2), basically I just added the required registers. The NAND 
flash detection is ok, formating and mounting jffs2 filesystems also seems to 
be OK. But when writting an remounting the partitions I get plenty of jfss2 
errors.

Probably the ECC in versions 2.1 and 2.2 need additional work, since some bits 
are missing when comparing with version 4.0.

I was testing this stuff using the NAND chip as the secondary flash. Which is 
de default configuration in the DGND3700 v1 (bcm6368), and hardware modded in 
the AD1018 (bcm6328).

Is there any plan to include NAND support?. Not as the main flash chip  but 
secondary for a first approach for further support in the future.

Regards.

diff --git a/target/linux/brcm63xx/config-4.9 b/target/linux/brcm63xx/config-4.9
index f1c3471..7d48ba2 100644
--- a/target/linux/brcm63xx/config-4.9
+++ b/target/linux/brcm63xx/config-4.9
@@ -168,6 +168,9 @@ CONFIG_MTD_CFI_STAA=y
 # CONFIG_MTD_COMPLEX_MAPPINGS is not set
 CONFIG_MTD_JEDECPROBE=y
 CONFIG_MTD_M25P80=y
+CONFIG_MTD_NAND=y
+CONFIG_MTD_NAND_BRCMNAND=y
+CONFIG_MTD_NAND_ECC=y
 CONFIG_MTD_PARSER_IMAGETAG=y
 CONFIG_MTD_PHYSMAP=y
 CONFIG_MTD_REDBOOT_PARTS=y
diff --git a/target/linux/brcm63xx/dts/ad1018-nor.dts 
b/target/linux/brcm63xx/dts/ad1018-nor.dts
index 93862c2..e7fcf7a 100644
--- a/target/linux/brcm63xx/dts/ad1018-nor.dts
+++ b/target/linux/brcm63xx/dts/ad1018-nor.dts
@@ -140,6 +140,26 @@
};
 };
 
+ {
+   status = "ok";
+
+   nandcs@0 {
+   compatible = "brcm,nandcs";
+   #size-cells = <1>;
+   #address-cells = <1>;
+   reg = <0>;
+   nand-ecc-step-size = <512>;
+   nand-ecc-strength = <15>;
+   brcm,nand-oob-sector-size = <64>;
+   //nand-on-flash-bbt;
+
+   nand_flash@0 {
+   label = "nand_flash";
+   reg = <0x000 0x800>;
+   };
+   };
+};
+
  {
status = "ok";
 };
diff --git a/target/linux/brcm63xx/dts/bcm63268.dtsi 
b/target/linux/brcm63xx/dts/bcm63268.dtsi
index 1b4b3e6..938c49f 100644
--- a/target/linux/brcm63xx/dts/bcm63268.dtsi
+++ b/target/linux/brcm63xx/dts/bcm63268.dtsi
@@ -221,6 +221,19 @@
status = "disabled";
};
 
+   nflash: nand@1200 {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   compatible = "brcm,nand-bcm6368", "brcm,brcmnand-v4.0", 
"brcm,brcmnand";
+   reg = <0x1200 0x180>, <0x1600 0x200>, 
<0x10b0 0x10>;
+   reg-names = "nand", "nand-cache", "nand-int-base";
+
+   interrupt-parent = <_intc>;
+   interrupts = <50>;
+
+   status = "disabled";
+   };
+
lsspi: spi@1800 {
#address-cells = <1>;
#size-cells = <0>;
diff --git a/target/linux/brcm63xx/dts/bcm6328.dtsi 
b/target/linux/brcm63xx/dts/bcm6328.dtsi
index d08b6ba..4155329 100644
--- a/target/linux/brcm63xx/dts/bcm6328.dtsi
+++ b/target/linux/brcm63xx/dts/bcm6328.dtsi
@@ -4,6 +4,7 @@
compatible = "brcm,bcm6328";
 
aliases {
+   nflash = 
pinctrl = 
serial0 = 
serial1 = 
@@ -179,6 +180,19 @@
status = "disabled";
};
 
+   nflash: nand@1200 {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   compatible = "brcm,nand-bcm6368", "brcm,brcmnand-v2.1", 
"brcm,brcmnand";
+   reg = <0x1200 0x180>, <0x1400 0x200>, 
<0x1070 0x10>;
+   reg-names = "nand", "nand-cache", "nand-int-base";
+
+   interrupt-parent = <_intc>;
+   interrupts = <0>;
+
+   status = "disabled";
+   };
+
leds: led-controller@1800 {
#address-cells = <1>;
#size-cells = <0>;
diff --git a/target/linux/brcm63xx/dts/bcm6362.dtsi 
b/target/linux/brcm63xx/dts/bcm6362.dtsi
index 2ff5c52..9ead35b 100644
--- a/target/linux/brcm63xx/dts/bcm6362.dtsi
+++ b/target/linux/brcm63xx/dts/bcm6362.dtsi
@@ -265,6 +265,19 @@
status = "disabled";
};
 
+   nflash: nand@1200 {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   compatible = "brcm,nand-bcm6368", "brcm,brcmnand-v4.0", 

[LEDE-DEV] [PATCH] brcm63xx: Tune the network configuration for several routers

2018-02-21 Thread Daniel Gonzalez Cabanelas
- DGND3700v1: fix port numbers, they're in reverse order
- FaST2704n: there is no WAN port identified as such, only 4 LAN
- AD1018: configure the "FIBRE" port as WAN

Signed-off-by: Daniel Gonzalez Cabanelas <dgcb...@gmail.com>
---
 target/linux/brcm63xx/base-files/etc/board.d/02_network | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/target/linux/brcm63xx/base-files/etc/board.d/02_network 
b/target/linux/brcm63xx/base-files/etc/board.d/02_network
index 06b4b6e..a7fd6f5 100755
--- a/target/linux/brcm63xx/base-files/etc/board.d/02_network
+++ b/target/linux/brcm63xx/base-files/etc/board.d/02_network
@@ -98,13 +98,18 @@ vr-3026e)
"0:lan:1" "1:lan:2" "2:lan:3" "3:lan:4" "8t@eth0"
;;
 
-ad1018-nor|\
 ar-5315u |\
+fast2704n |\
 vh4032n)
ucidef_add_switch "switch0" \
"0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "8t@eth0"
;;
 
+ad1018-nor)
+   ucidef_add_switch "switch0" \
+   "1:lan:3" "2:lan:2" "3:lan:1" "0:wan" "8t@eth0"
+   ;;
+
 bcm96368mvwg)
ucidef_add_switch "switch0" \
"1:lan" "2:lan" "4:lan" "5:lan" "8t@eth0"
@@ -115,10 +120,9 @@ wap-5813n)
"0:lan" "1:lan" "2:lan" "3:lan" "4:wan" "5t@eth0"
;;
 
-fast2704n |\
 dgnd3700v1_dgnd3800b)
ucidef_add_switch "switch0" \
-   "1:lan:1" "2:lan:2" "3:lan:3" "4:lan:4" "0:wan" "8t@eth0"
+   "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "0:wan" "8t@eth0"
;;
 
 neufbox6)
-- 
2.6.4



___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


[LEDE-DEV] [PATCH] ar71xx: WNDR4300: use the switch LED trigger on the WAN port

2017-09-03 Thread Daniel Gonzalez Cabanelas
The WAN port on the Netgear WNDR4300 router has two LEDs, 
amber and green. Use the switch LED trigger to behave as the 
rest of the LAN HW controlled LEDs
- Green: 1 Gbps
- Amber: 100/10 Mbps

Signed-off-by: Daniel Gonzalez Cabanelas <dgcb...@gmail.com>
---
 target/linux/ar71xx/base-files/etc/board.d/01_leds | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/target/linux/ar71xx/base-files/etc/board.d/01_leds 
b/target/linux/ar71xx/base-files/etc/board.d/01_leds
index 84b1a7d..4132e91 100755
--- a/target/linux/ar71xx/base-files/etc/board.d/01_leds
+++ b/target/linux/ar71xx/base-files/etc/board.d/01_leds
@@ -823,7 +823,8 @@ r6100)
;;
 wndr3700v4|\
 wndr4300)
-   ucidef_set_led_netdev "wan" "WAN (green)" "netgear:green:wan" "eth0.2"
+   ucidef_set_led_switch "wan-green" "WAN (green)" "netgear:green:wan" 
"switch0" "0x20" "0x08"
+   ucidef_set_led_switch "wan-amber" "WAN (amber)" "netgear:amber:wan" 
"switch0" "0x20" "0x06"
ucidef_set_led_usbdev "usb" "USB" "netgear:green:usb" "1-1"
ucidef_set_led_wlan "wlan2g" "WLAN2G" "netgear:green:wlan2g" "phy0tpt"
ucidef_set_led_wlan "wlan5g" "WLAN5G" "netgear:blue:wlan5g" "phy1tpt"
-- 
2.6.4



___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


[LEDE-DEV] [PATCH v2] brcm63xx: Add Sercomm AD1018 support

2017-08-31 Thread Daniel Gonzalez Cabanelas
Add support for the Sercomm AD1018 router

This a BCM6328 based board, 128 MB RAM, 128 MiB NAND flash,
with an onboard BCM43217 wifi, 4 ethernet ports and 1 USB
host port (not soldered). The board also has an FXS chip (Si32177)
connected via SPI (SS2#), without support in LEDE.

Since NAND flash chips aren't still supported in brcm63xx, the
support is for now added to work only with SPI flash chips. Therefore
hardware modding, soldering a new SPI flash chip, is required
to make the board work with LEDE (tested and working OK).
The flash at dts is intentionally left without partitioning to let 
the user choose a NOR chip of any size (8, 16 or 32 MB).

Signed-off-by: Daniel Gonzalez Cabanelas <dgcb...@gmail.com>
---
Change in v2:
- rename the board at dts for indicating this is a firmware for SPI NOR  
flash chips, and minor changes
- add USB LED
---
 .../linux/brcm63xx/base-files/etc/board.d/01_leds  |   3 +
 .../brcm63xx/base-files/etc/board.d/02_network |   1 +
 target/linux/brcm63xx/base-files/etc/diag.sh   |   3 +
 target/linux/brcm63xx/base-files/lib/brcm63xx.sh   |   3 +
 target/linux/brcm63xx/dts/ad1018-nor.dts   | 136 +
 target/linux/brcm63xx/image/bcm63xx.mk |  12 ++
 .../brcm63xx/patches-4.4/580-board_AD1018.patch|  99 +++
 7 files changed, 257 insertions(+)
 create mode 100644 target/linux/brcm63xx/dts/ad1018-nor.dts
 create mode 100644 target/linux/brcm63xx/patches-4.4/580-board_AD1018.patch

diff --git a/target/linux/brcm63xx/base-files/etc/board.d/01_leds 
b/target/linux/brcm63xx/base-files/etc/board.d/01_leds
index ef70cde..5503328 100755
--- a/target/linux/brcm63xx/base-files/etc/board.d/01_leds
+++ b/target/linux/brcm63xx/base-files/etc/board.d/01_leds
@@ -15,6 +15,9 @@ a4001n1)
 a4001n)
ucidef_set_led_usbdev "usb" "USB" "A4001N:green:usb" "1-1"
;;
+ad1018)
+   ucidef_set_led_netdev "wlan0" "WLAN" "AD1018:green:wifi" "wlan0"
+   ;;
 ar-5315u)
ucidef_set_led_usbdev "usb" "USB" "AR-5315u:green:usb" "1-1"
;;
diff --git a/target/linux/brcm63xx/base-files/etc/board.d/02_network 
b/target/linux/brcm63xx/base-files/etc/board.d/02_network
index 9addba6..826d271 100755
--- a/target/linux/brcm63xx/base-files/etc/board.d/02_network
+++ b/target/linux/brcm63xx/base-files/etc/board.d/02_network
@@ -98,6 +98,7 @@ vr-3026e)
"0:lan:1" "1:lan:2" "2:lan:3" "3:lan:4" "8t@eth0"
;;
 
+ad1018 |\
 ar-5315u |\
 vh4032n)
ucidef_add_switch "switch0" \
diff --git a/target/linux/brcm63xx/base-files/etc/diag.sh 
b/target/linux/brcm63xx/base-files/etc/diag.sh
index 700c9ea..2663a2c 100644
--- a/target/linux/brcm63xx/base-files/etc/diag.sh
+++ b/target/linux/brcm63xx/base-files/etc/diag.sh
@@ -12,6 +12,9 @@ set_state() {
a4001n)
status_led="A4001N:green:power"
;;
+   ad1018)
+   status_led="AD1018:green:power"
+   ;;
ar-5315u)
status_led="AR-5315u:green:power"
;;
diff --git a/target/linux/brcm63xx/base-files/lib/brcm63xx.sh 
b/target/linux/brcm63xx/base-files/lib/brcm63xx.sh
index 3f46633..09a5550 100755
--- a/target/linux/brcm63xx/base-files/lib/brcm63xx.sh
+++ b/target/linux/brcm63xx/base-files/lib/brcm63xx.sh
@@ -228,6 +228,9 @@ brcm63xx_dt_detect() {
"Sagem F@ST2704V2")
board_name="fast2704v2"
;;
+   "Sercomm AD1018 (SPI flash mod)")
+   board_name="ad1018"
+   ;;
"SFR Neuf Box 4"*)
board_name="neufbox4"
;;
diff --git a/target/linux/brcm63xx/dts/ad1018-nor.dts 
b/target/linux/brcm63xx/dts/ad1018-nor.dts
new file mode 100644
index 000..e2f7eed
--- /dev/null
+++ b/target/linux/brcm63xx/dts/ad1018-nor.dts
@@ -0,0 +1,136 @@
+/dts-v1/;
+
+#include "bcm6328.dtsi"
+
+#include 
+
+/ {
+   model = "Sercomm AD1018 (SPI flash mod)";
+   compatible = "sercomm,ad1018", "brcm,bcm6328";
+
+   chosen {
+   bootargs = "root=/dev/mtdblock2 rootfstype=squashfs,jffs2 
noinitrd console=ttyS0,115200";
+   };
+
+   gpio-keys-polled {
+   compatible = "gpio-keys-polled";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   poll-interval = <20>;
+   debounce-interval = <60>;
+
+   wps {
+   label = "wps";
+   gpios = < 24 1>;
+   linux,code = ;
+   };
+   wifi {
+   label = "wifi";
+

[LEDE-DEV] [PATCH v2] brcm63xx: Add Comtrend AR-5315u support

2017-03-19 Thread Daniel Gonzalez Cabanelas
Add support for the Comtrend AR-5315u router

This a BCM6318 based board, 64 MB RAM, 16 MB SPI flash,
with an onboard BCM43217 wifi, 4 ethernet ports and 1
USB host port

Signed-off-by: Daniel Gonzalez Cabanelas <dgcb...@gmail.com>
---
Change in v2:
- add missing comtrend compatible brand for DTS

 .../linux/brcm63xx/base-files/etc/board.d/01_leds  |  3 +
 .../brcm63xx/base-files/etc/board.d/02_network |  1 +
 target/linux/brcm63xx/base-files/etc/diag.sh   |  3 +
 .../base-files/etc/uci-defaults/09_fix_crc |  1 +
 target/linux/brcm63xx/base-files/lib/brcm63xx.sh   |  3 +
 target/linux/brcm63xx/dts/ar-5315u.dts | 67 
 target/linux/brcm63xx/image/bcm63xx.mk | 13 +++
 .../brcm63xx/patches-4.4/578-board_AR-5315u.patch  | 93 ++
 8 files changed, 184 insertions(+)
 create mode 100644 target/linux/brcm63xx/dts/ar-5315u.dts
 create mode 100644 target/linux/brcm63xx/patches-4.4/578-board_AR-5315u.patch

diff --git a/target/linux/brcm63xx/base-files/etc/board.d/01_leds 
b/target/linux/brcm63xx/base-files/etc/board.d/01_leds
index 61f685e..959b1ca 100755
--- a/target/linux/brcm63xx/base-files/etc/board.d/01_leds
+++ b/target/linux/brcm63xx/base-files/etc/board.d/01_leds
@@ -16,6 +16,9 @@ a4001n1)
 a4001n)
ucidef_set_led_usbdev "usb" "USB" "A4001N:green:usb" "1-1"
;;
+ar-5315u)
+   ucidef_set_led_usbdev "usb" "USB" "AR-5315u:green:usb" "1-1"
+   ;;
 av4202n)
ucidef_set_led_netdev "wlan0" "WLAN" "AV4202N:blue:wifi" "wlan0"
;;
diff --git a/target/linux/brcm63xx/base-files/etc/board.d/02_network 
b/target/linux/brcm63xx/base-files/etc/board.d/02_network
index f703dfd..2b6dfe8 100755
--- a/target/linux/brcm63xx/base-files/etc/board.d/02_network
+++ b/target/linux/brcm63xx/base-files/etc/board.d/02_network
@@ -98,6 +98,7 @@ vr-3026e)
"0:lan:1" "1:lan:2" "2:lan:3" "3:lan:4" "8t@eth0"
;;
 
+ar-5315u |\
 vh4032n)
ucidef_add_switch "switch0" \
"0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "8t@eth0"
diff --git a/target/linux/brcm63xx/base-files/etc/diag.sh 
b/target/linux/brcm63xx/base-files/etc/diag.sh
index df1d616..8c74efa 100644
--- a/target/linux/brcm63xx/base-files/etc/diag.sh
+++ b/target/linux/brcm63xx/base-files/etc/diag.sh
@@ -12,6 +12,9 @@ set_state() {
a4001n)
status_led="A4001N:green:power"
;;
+   ar-5315u)
+   status_led="AR-5315u:green:power"
+   ;;
ar-5381u)
status_led="AR-5381u:green:power"
;;
diff --git a/target/linux/brcm63xx/base-files/etc/uci-defaults/09_fix_crc 
b/target/linux/brcm63xx/base-files/etc/uci-defaults/09_fix_crc
index 650db9d..d05926b 100644
--- a/target/linux/brcm63xx/base-files/etc/uci-defaults/09_fix_crc
+++ b/target/linux/brcm63xx/base-files/etc/uci-defaults/09_fix_crc
@@ -13,6 +13,7 @@ do_fixcrc() {
 case "$(brcm63xx_board_name)" in
a4001n |\
a4001n1 |\
+   ar-5315u |\
ar-5381u |\
ar-5387un |\
bcm96328avng |\
diff --git a/target/linux/brcm63xx/base-files/lib/brcm63xx.sh 
b/target/linux/brcm63xx/base-files/lib/brcm63xx.sh
index 4fe33eb..5e75042 100755
--- a/target/linux/brcm63xx/base-files/lib/brcm63xx.sh
+++ b/target/linux/brcm63xx/base-files/lib/brcm63xx.sh
@@ -84,6 +84,9 @@ brcm63xx_dt_detect() {
"BT Voyager V2500V")
board_name="v2500v_bb"
;;
+   "Comtrend AR-5315u")
+   board_name="ar-5315u"
+   ;;
"Comtrend AR-5381u")
board_name="ar-5381u"
;;
diff --git a/target/linux/brcm63xx/dts/ar-5315u.dts 
b/target/linux/brcm63xx/dts/ar-5315u.dts
new file mode 100644
index 000..2ff067a
--- /dev/null
+++ b/target/linux/brcm63xx/dts/ar-5315u.dts
@@ -0,0 +1,67 @@
+/dts-v1/;
+
+#include "bcm6318.dtsi"
+
+#include 
+
+/ {
+   model = "Comtrend AR-5315u";
+   compatible = "comtrend,ar-5315u", "brcm,bcm6318";
+
+   chosen {
+   bootargs = "root=/dev/mtdblock2 rootfstype=squashfs,jffs2 
noinitrd console=ttyS0,115200";
+   };
+
+   gpio-keys-polled {
+   compatible = "gpio-keys-polled";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   poll-interval = <20>;
+   debounce-interval = <60>;
+
+   wps {
+   label = "wps";
+   gpios = < 3 1>;
+   linux,code = ;
+   };
+ 

[LEDE-DEV] [PATCH] brcm63xx: Add Comtrend AR-5315u support

2017-03-01 Thread Daniel Gonzalez Cabanelas
Add support for the Comtrend AR-5315u router

This a BCM6318 based board, 64 MB RAM, 16 MB SPI flash, 
with an onboard BCM43217 wifi, 4 ethernet ports and 1 
USB host port

Signed-off-by: Daniel Gonzalez Cabanelas <dgcb...@gmail.com>
diff --git a/target/linux/brcm63xx/base-files/etc/board.d/01_leds 
b/target/linux/brcm63xx/base-files/etc/board.d/01_leds
index 61f685e..959b1ca 100755
--- a/target/linux/brcm63xx/base-files/etc/board.d/01_leds
+++ b/target/linux/brcm63xx/base-files/etc/board.d/01_leds
@@ -16,6 +16,9 @@ a4001n1)
 a4001n)
ucidef_set_led_usbdev "usb" "USB" "A4001N:green:usb" "1-1"
;;
+ar-5315u)
+   ucidef_set_led_usbdev "usb" "USB" "AR-5315u:green:usb" "1-1"
+   ;;
 av4202n)
ucidef_set_led_netdev "wlan0" "WLAN" "AV4202N:blue:wifi" "wlan0"
;;
diff --git a/target/linux/brcm63xx/base-files/etc/board.d/02_network 
b/target/linux/brcm63xx/base-files/etc/board.d/02_network
index f703dfd..2b6dfe8 100755
--- a/target/linux/brcm63xx/base-files/etc/board.d/02_network
+++ b/target/linux/brcm63xx/base-files/etc/board.d/02_network
@@ -98,6 +98,7 @@ vr-3026e)
"0:lan:1" "1:lan:2" "2:lan:3" "3:lan:4" "8t@eth0"
;;
 
+ar-5315u |\
 vh4032n)
ucidef_add_switch "switch0" \
"0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "8t@eth0"
diff --git a/target/linux/brcm63xx/base-files/etc/diag.sh 
b/target/linux/brcm63xx/base-files/etc/diag.sh
index df1d616..8c74efa 100644
--- a/target/linux/brcm63xx/base-files/etc/diag.sh
+++ b/target/linux/brcm63xx/base-files/etc/diag.sh
@@ -12,6 +12,9 @@ set_state() {
a4001n)
status_led="A4001N:green:power"
;;
+   ar-5315u)
+   status_led="AR-5315u:green:power"
+   ;;
ar-5381u)
status_led="AR-5381u:green:power"
;;
diff --git a/target/linux/brcm63xx/base-files/etc/uci-defaults/09_fix_crc 
b/target/linux/brcm63xx/base-files/etc/uci-defaults/09_fix_crc
index 650db9d..d05926b 100644
--- a/target/linux/brcm63xx/base-files/etc/uci-defaults/09_fix_crc
+++ b/target/linux/brcm63xx/base-files/etc/uci-defaults/09_fix_crc
@@ -13,6 +13,7 @@ do_fixcrc() {
 case "$(brcm63xx_board_name)" in
a4001n |\
a4001n1 |\
+   ar-5315u |\
ar-5381u |\
ar-5387un |\
bcm96328avng |\
diff --git a/target/linux/brcm63xx/base-files/lib/brcm63xx.sh 
b/target/linux/brcm63xx/base-files/lib/brcm63xx.sh
index 4fe33eb..5e75042 100755
--- a/target/linux/brcm63xx/base-files/lib/brcm63xx.sh
+++ b/target/linux/brcm63xx/base-files/lib/brcm63xx.sh
@@ -84,6 +84,9 @@ brcm63xx_dt_detect() {
"BT Voyager V2500V")
board_name="v2500v_bb"
;;
+   "Comtrend AR-5315u")
+   board_name="ar-5315u"
+   ;;
"Comtrend AR-5381u")
board_name="ar-5381u"
;;
diff --git a/target/linux/brcm63xx/dts/ar-5315u.dts 
b/target/linux/brcm63xx/dts/ar-5315u.dts
new file mode 100644
index 000..2ff067a
--- /dev/null
+++ b/target/linux/brcm63xx/dts/ar-5315u.dts
@@ -0,0 +1,67 @@
+/dts-v1/;
+
+#include "bcm6318.dtsi"
+
+#include 
+
+/ {
+   model = "Comtrend AR-5315u";
+   compatible = "comtrend,ar-5315u", "brcm,bcm6318";
+
+   chosen {
+   bootargs = "root=/dev/mtdblock2 rootfstype=squashfs,jffs2 
noinitrd console=ttyS0,115200";
+   };
+
+   gpio-keys-polled {
+   compatible = "gpio-keys-polled";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   poll-interval = <20>;
+   debounce-interval = <60>;
+
+   wps {
+   label = "wps";
+   gpios = < 3 1>;
+   linux,code = ;
+   };
+   reset {
+   label = "reset";
+   gpios = < 1 1>;
+   linux,code = ;
+   };
+   };
+
+   gpio-leds {
+   compatible = "gpio-leds";
+
+   wps_green {
+   label = "AR-5315u:green:wps";
+   gpios = < 0 1>;
+   };
+   power_green {
+   label = "AR-5315u:green:power";
+   gpios = < 1 1>;
+   default-state = "on";
+   };
+   usb_green {
+   label = "AR-5315u:green:usb";
+   gpios = 

Re: [LEDE-DEV] [RFC] AR8327 driver: implementing get_port_stats function

2017-02-27 Thread Daniel Gonzalez Cabanelas
> Fetching the entire port stats only to look up two fields seems rather
> excessive. Please make a function instead that will look up the register
> number and fetch only the relevant registers.
> The lookup can be further simplified by adding an enum for the mib_stats
> array index.
> 
> - Felix

Hi Felix. Could this function be valid?. I'm afraid I cannot make anything more
sophisticated

ar8xxx_sw_get_port_stats(struct switch_dev *dev, int port,
   struct switch_port_stats *stats)
{
struct ar8xxx_priv *priv = swdev_to_ar8xxx(dev);
unsigned int base;
unsigned int rx_offset, tx_offset;

if (port >= dev->ports)
return -EINVAL;

base = priv->chip->reg_port_stats_start +
   priv->chip->reg_port_stats_length * port;

if (priv->chip->num_mibs == ARRAY_SIZE(ar8236_mibs)){
rx_offset = AR8236_STATS_RXGOODBYTE;
tx_offset = AR8236_STATS_TXBYTE;
}

else if (priv->chip->num_mibs == ARRAY_SIZE(ar8216_mibs)){
rx_offset = AR8216_STATS_RXGOODBYTE;
tx_offset = AR8216_STATS_TXBYTE;
}

stats->rx_bytes = ar8xxx_read(priv, base + rx_offset);
stats->tx_bytes = ar8xxx_read(priv, base + tx_offset);

return 0;
}

Also tested and working ok.

Regards
Daniel




___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


[LEDE-DEV] [RFC] AR8327 driver: implementing get_port_stats function

2017-02-25 Thread Daniel Gonzalez Cabanelas
Currently the switch LED trigger only shows link status, but not traffic 
activity by blinking
the LEDs on the AR8316/AR8327 switch. It turns out that the get_port_stats is 
missing.

I've made this patch, which works ok. But I'm not sure if there is any reason 
to not implement this 
function. And probably the function ar8xxx_sw_get_port_stats can be improved.

There are a few boards with an  AR8316/AR8327 switch that need this trigger, 
usually on the WAN port.
As said without get_port_stats the light stays always fixed, like if there 
wasn't traffic activity. We can use 
the netdev trigger but then the light is always on even when the cable is 
unplugged, and there isn't the
possibility of using a second LED trigger on the same port for indicating a 
reduced link speed.

diff --git a/target/linux/generic/files/drivers/net/phy/ar8216.c 
b/target/linux/generic/files/drivers/net/phy/ar8216.c
index 37877d5..ffaa77e 100644
--- a/target/linux/generic/files/drivers/net/phy/ar8216.c
+++ b/target/linux/generic/files/drivers/net/phy/ar8216.c
@@ -1001,6 +1001,41 @@ ar8xxx_sw_get_port_link(struct switch_dev *dev, int port,
return 0;
 }
 
+int
+ar8xxx_sw_get_port_stats(struct switch_dev *dev, int port,
+  struct switch_port_stats *stats)
+{
+   struct ar8xxx_priv *priv = swdev_to_ar8xxx(dev);
+   const struct ar8xxx_chip *chip = priv->chip;
+   u64 *mib_stats, mib_data;
+   const char *mib_name;
+   int i;
+
+   if (!ar8xxx_has_mib_counters(priv))
+   return -EOPNOTSUPP;
+
+   if (port >= dev->ports)
+   return -EINVAL;
+
+   mutex_lock(>mib_lock);
+
+   ar8xxx_mib_fetch_port_stat(priv, port, false);
+
+   mib_stats = >mib_stats[port * chip->num_mibs];
+   for (i = 0; i < chip->num_mibs; i++) {
+   mib_name = chip->mib_decs[i].name;
+   mib_data = mib_stats[i];
+   if (!strcmp(mib_name, "TxByte"))
+   stats->tx_bytes = mib_data;
+   if (!strcmp(mib_name, "RxGoodByte"))
+   stats->rx_bytes = mib_data;
+   }
+
+   mutex_unlock(>mib_lock);
+
+   return 0;
+}
+
 static int
 ar8xxx_sw_get_ports(struct switch_dev *dev, struct switch_val *val)
 {
@@ -1696,6 +1731,7 @@ static const struct switch_dev_ops ar8xxx_sw_ops = {
.apply_config = ar8xxx_sw_hw_apply,
.reset_switch = ar8xxx_sw_reset_switch,
.get_port_link = ar8xxx_sw_get_port_link,
+   .get_port_stats = ar8xxx_sw_get_port_stats,
 };
 
 static const struct ar8xxx_chip ar8216_chip = {
diff --git a/target/linux/generic/files/drivers/net/phy/ar8216.h 
b/target/linux/generic/files/drivers/net/phy/ar8216.h
index d9508b9..8b05cf3 100644
--- a/target/linux/generic/files/drivers/net/phy/ar8216.h
+++ b/target/linux/generic/files/drivers/net/phy/ar8216.h
@@ -538,6 +538,9 @@ int
 ar8xxx_sw_get_port_link(struct switch_dev *dev, int port,
struct switch_port_link *link);
 int
+ar8xxx_sw_get_port_stats(struct switch_dev *dev,
+  int port, struct switch_port_stats *stats);
+int
 ar8xxx_sw_set_port_reset_mib(struct switch_dev *dev,
  const struct switch_attr *attr,
  struct switch_val *val);
diff --git a/target/linux/generic/files/drivers/net/phy/ar8327.c 
b/target/linux/generic/files/drivers/net/phy/ar8327.c
index 9b40cd7..e82563f 100644
--- a/target/linux/generic/files/drivers/net/phy/ar8327.c
+++ b/target/linux/generic/files/drivers/net/phy/ar8327.c
@@ -1372,6 +1372,7 @@ static const struct switch_dev_ops ar8327_sw_ops = {
.apply_config = ar8327_sw_hw_apply,
.reset_switch = ar8xxx_sw_reset_switch,
.get_port_link = ar8xxx_sw_get_port_link,
+   .get_port_stats = ar8xxx_sw_get_port_stats,
 };
 
 const struct ar8xxx_chip ar8327_chip = {


___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


[LEDE-DEV] [PATCH] ar71xx: WNDR4300: Fix switch HW controlled LEDs

2017-02-20 Thread Daniel Gonzalez Cabanelas
The Netgear WNDR4300, equipped with an Atheros AR8327 Gigabit Switch,
has two LEDs on each port for monitoring LAN activity, but it currently 
only uses one. Fix the configuration to use both.

The patch provides this new configuration:
- green LED: 1 Gbps link, 4Hz blink frequency
- amber LED: 10/100 Mbps link. 4Hz for 100Mbps, 2Hz for 10Mbps  

Signed-off-by: Daniel Gonzalez Cabanelas <dgcb...@gmail.com>
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/mach-wndr4300.c 
b/target/linux/ar71xx/files/arch/mips/ath79/mach-wndr4300.c
index 2884c6c..2a00a0e 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/mach-wndr4300.c
+++ b/target/linux/ar71xx/files/arch/mips/ath79/mach-wndr4300.c
@@ -136,11 +136,11 @@ static struct ar8327_pad_cfg wndr4300_ar8327_pad0_cfg = {
 };
 
 static struct ar8327_led_cfg wndr4300_ar8327_led_cfg = {
-   .led_ctrl0 = 0xc737c737,
-   .led_ctrl1 = 0x,
+   .led_ctrl0 = 0xcc35cc35,
+   .led_ctrl1 = 0xcb37cb37,
.led_ctrl2 = 0x,
-   .led_ctrl3 = 0x0030c300,
-   .open_drain = false,
+   .led_ctrl3 = 0x00f3cf00,
+   .open_drain = true,
 };
 
 static struct ar8327_platform_data wndr4300_ar8327_data = {


___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


[LEDE-DEV] [PATCH] ar71xx: WNDR4300: Fix network vlan IDs

2017-02-20 Thread Daniel Gonzalez Cabanelas
The Netgear WNDR4300 has the VLAN IDs flipped in LuCi, fix it.


Signed-off-by: Daniel Gonzalez Cabanelas <dgcb...@gmail.com>
diff --git a/target/linux/ar71xx/base-files/etc/board.d/02_network 
b/target/linux/ar71xx/base-files/etc/board.d/02_network
index e08d7dd..a55e50a 100755
--- a/target/linux/ar71xx/base-files/etc/board.d/02_network
+++ b/target/linux/ar71xx/base-files/etc/board.d/02_network
@@ -254,8 +254,7 @@ ar71xx_setup_interfaces()
esr900|\
mynet-n750|\
sr3200|\
-   wndr3700v4|\
-   wndr4300)
+   wndr3700v4)
ucidef_add_switch "switch0" \
"0@eth0" "1:lan" "2:lan" "3:lan" "4:lan" "5:wan"
;;
@@ -334,7 +333,8 @@ ar71xx_setup_interfaces()
dir-869-a1|\
epg5000|\
esr1750|\
-   tl-wr1043nd-v4)
+   tl-wr1043nd-v4|\
+   wndr4300)
ucidef_add_switch "switch0" \
"0@eth0" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "5:wan"
;;


___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


[LEDE-DEV] [PATCH 4/4] brcm63xx: CPVA642+: add SPROM wifi

2017-02-14 Thread Daniel Gonzalez Cabanelas
Add SPROM wifi to the kernel board data.

After this fix, the wifi won't work anyway due the lack
of RAM memory (16 MB). It will throw a kernel panic
when loading the b43 drivers.

Signed-off-by: Daniel Gonzalez Cabanelas <dgcb...@gmail.com>
diff --git a/target/linux/brcm63xx/patches-4.4/519_board_CPVA502plus.patch 
b/target/linux/brcm63xx/patches-4.4/519_board_CPVA502plus.patch
index a2cdfa9..51222f9 100644
--- a/target/linux/brcm63xx/patches-4.4/519_board_CPVA502plus.patch
+++ b/target/linux/brcm63xx/patches-4.4/519_board_CPVA502plus.patch
@@ -1,6 +1,6 @@
 --- a/arch/mips/bcm63xx/boards/board_bcm963xx.c
 +++ b/arch/mips/bcm63xx/boards/board_bcm963xx.c
-@@ -429,6 +429,27 @@ static struct board_info __initdata boar
+@@ -429,6 +429,34 @@ static struct board_info __initdata boar
},
  };
  
@@ -12,6 +12,7 @@
 +  .has_enet0  = 1,
 +  .has_enet1  = 1,
 +  .has_pci= 1,
++  .use_fallback_sprom = 1,
 +
 +  .enet0 = {
 +  .has_phy= 1,
@@ -24,6 +25,12 @@
 +
 +  .ephy_reset_gpio= 4,
 +  .ephy_reset_gpio_flags  = GPIO_ACTIVE_LOW,
++
++  .fallback_sprom = {
++  .type   = SPROM_BCM4318,
++  .pci_bus= 0,
++  .pci_dev= 1,
++  },
 +};
  
  static struct board_info __initdata board_ct536_ct5621 = {


___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


[LEDE-DEV] [PATCH 3/4] brcm63xx: CPVA642+: fix userspace support

2017-02-14 Thread Daniel Gonzalez Cabanelas
Fix board name typo, fix network configuration and add a led trigger.

Signed-off-by: Daniel Gonzalez Cabanelas <dgcb...@gmail.com>
diff --git a/target/linux/brcm63xx/base-files/etc/board.d/01_leds 
b/target/linux/brcm63xx/base-files/etc/board.d/01_leds
index 7d208cc..61f685e 100755
--- a/target/linux/brcm63xx/base-files/etc/board.d/01_leds
+++ b/target/linux/brcm63xx/base-files/etc/board.d/01_leds
@@ -19,6 +19,9 @@ a4001n)
 av4202n)
ucidef_set_led_netdev "wlan0" "WLAN" "AV4202N:blue:wifi" "wlan0"
;;
+cpva502p)
+   ucidef_set_led_netdev "lan" "LAN" "CPVA502+:amber:link" "eth0"
+   ;;
 dgnd3700v1_dgnd3800b)
ucidef_set_led_netdev "lan" "LAN" "DGND3700v1_3800B:green:lan" "eth0.1"
ucidef_set_led_netdev "wan" "WAN" "DGND3700v1_3800B:green:inet" "eth0.2"
diff --git a/target/linux/brcm63xx/base-files/etc/board.d/02_network 
b/target/linux/brcm63xx/base-files/etc/board.d/02_network
index ff5fc7a..f703dfd 100755
--- a/target/linux/brcm63xx/base-files/etc/board.d/02_network
+++ b/target/linux/brcm63xx/base-files/etc/board.d/02_network
@@ -42,7 +42,6 @@ bcm96348gw-10 |\
 bcm96348gw-11 |\
 bcm96358vw |\
 bcm96358vw2 |\
-cpva502p |\
 dg834gt |\
 dmv-s0 |\
 dsl-2650u |\
@@ -135,6 +134,7 @@ bcm963268bu_p300)
"0:lan" "3:lan" "4:lan" "5:lan" "6:lan" "7:lan" "8t@eth0"
;;
 
+cpva502p |\
 livebox1)
ucidef_set_interfaces_lan_wan "eth0" "eth1"
;;
diff --git a/target/linux/brcm63xx/base-files/lib/brcm63xx.sh 
b/target/linux/brcm63xx/base-files/lib/brcm63xx.sh
index bceba8f..4fe33eb 100755
--- a/target/linux/brcm63xx/base-files/lib/brcm63xx.sh
+++ b/target/linux/brcm63xx/base-files/lib/brcm63xx.sh
@@ -240,7 +240,7 @@ brcm63xx_dt_detect() {
"TECOM GW6200")
board_name="g6200"
;;
-   "Telsey CVPA502+")
+   "Telsey CPVA502+")
board_name="cpva502p"
;;
"Telsey CPVA642-type (CPA-ZNTE60T)")


___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


[LEDE-DEV] [PATCH 2/4] brcm63xx: CPVA642+: fix image generation

2017-02-14 Thread Daniel Gonzalez Cabanelas
Fix typo, erase pointless option and allow to build the image.

Signed-off-by: Daniel Gonzalez Cabanelas <dgcb...@gmail.com>
diff --git a/target/linux/brcm63xx/image/bcm63xx.mk 
b/target/linux/brcm63xx/image/bcm63xx.mk
index 0749c29..969d75f 100644
--- a/target/linux/brcm63xx/image/bcm63xx.mk
+++ b/target/linux/brcm63xx/image/bcm63xx.mk
@@ -1030,18 +1030,17 @@ endef
 TARGET_DEVICES += GW6200
 
 ### Telsey ###
-define Device/CVPA502PLUS
+define Device/CPVA502PLUS
   $(Device/bcm63xx)
-  IMAGES :=
   DEVICE_TITLE := Telsey CPVA502+
   DEVICE_DTS := cpva502plus
   CFE_BOARD_ID := CPVA502+
   CFE_CHIP_ID := 6348
-  CFE_EXTRAS += --signature "Telsey Tlc" --signature2 "99.99.999" 
--second-image-flag "0"
+  CFE_EXTRAS += --signature "Telsey Tlc" --signature2 "99.99.999"
   DEVICE_PACKAGES := \
 $(B43_PACKAGES)
 endef
-TARGET_DEVICES += CVPA502PLUS
+TARGET_DEVICES += CPVA502PLUS
 
 define Device/CPA-ZNTE60T
   $(Device/bcm63xx)


___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


[LEDE-DEV] [PATCH 1/4] brcm63xx: CPVA642+: fix LEDs and buttons at DTS

2017-02-14 Thread Daniel Gonzalez Cabanelas
Leds are wrong and a button is missing, fix them.

Signed-off-by: Daniel Gonzalez Cabanelas <dgcb...@gmail.com>
diff --git a/target/linux/brcm63xx/dts/cpva502plus.dts 
b/target/linux/brcm63xx/dts/cpva502plus.dts
index 6d9b5d3..3ddc459 100644
--- a/target/linux/brcm63xx/dts/cpva502plus.dts
+++ b/target/linux/brcm63xx/dts/cpva502plus.dts
@@ -12,17 +12,31 @@
bootargs = "root=/dev/mtdblock2 rootfstype=squashfs,jffs2 
noinitrd console=ttyS0,115200";
};
 
+   gpio-keys-polled {
+   compatible = "gpio-keys-polled";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   poll-interval = <20>;
+   debounce-interval = <60>;
+
+   reset {
+   label = "reset";
+   gpios = < 4 1>;
+   linux,code = ;
+   };
+   };
+
gpio-leds {
compatible = "gpio-leds";
 
-   power_green {
+   phone_green {
label = "CPVA502+:green:phone";
gpios = < 0 1>;
};
 
-   status {
+   link_amber {
label = "CPVA502+:amber:link";
-   gpios = < 1 1>;
+   gpios = < 5 1>;
};
};
 };


___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


[LEDE-DEV] [PATCH] brcm63xx: fix external IRQ edge type sense

2017-02-07 Thread Daniel Gonzalez Cabanelas
Fix the register for configuring rising/falling edge

Rising should be sense=1, and falling sense=0. 
The old driver used these values, but the new one have
them flipped.

Signed-off-by: Daniel Gonzalez Cabanelas <dgcb...@gmail.com>
diff --git 
a/target/linux/brcm63xx/patches-4.4/321-irqchip-add-support-for-bcm6345-style-external-inter.patch
 
b/target/linux/brcm63xx/patches-4.4/321-irqchip-add-support-for-bcm6345-style-external-inter.patch
index 2526456..0135cb2 100644
--- 
a/target/linux/brcm63xx/patches-4.4/321-irqchip-add-support-for-bcm6345-style-external-inter.patch
+++ 
b/target/linux/brcm63xx/patches-4.4/321-irqchip-add-support-for-bcm6345-style-external-inter.patch
@@ -198,10 +198,10 @@ Signed-off-by: Jonas Gorski <j...@openwrt.org>
 +  break;
 +
 +  case IRQ_TYPE_EDGE_RISING:
++  sense = 1;
 +  break;
 +
 +  case IRQ_TYPE_EDGE_FALLING:
-+  sense = 1;
 +  break;
 +
 +  case IRQ_TYPE_LEVEL_HIGH:


___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


[LEDE-DEV] [PATCH v2] brcm63xx: fix internal net phy interrupt config

2016-12-18 Thread Daniel Gonzalez Cabanelas
The internal phy is using wrong registers for the config interrupt function,
causing incorrect behavior when detecting the link activity. Fix it.

We cannot use the bcm_phy_config_intr function from the bcm-phy-lib.c 
because it uses different registers from brcm63xx. The old function was
right, so go back to it. 

It's worth mentioning that this function matches with the one used
by the Broadcom BCM5241 fast ethernet phy driver (brcm_fet_config_intr 
at broadcom.c). This one uses exactly the same registers as BCM63xx.

---
change in v2:
 use the original defines for focusing only on the bug
 modify the commit log accordingly with the new approach
---
diff --git 
a/target/linux/brcm63xx/patches-4.4/409-bcm63xx_net_phy-fix-config_intr.patch 
b/target/linux/brcm63xx/patches-4.4/409-bcm63xx_net_phy-fix-config_intr.patch
new file mode 100644
index 000..9e5a5d1
--- /dev/null
+++ 
b/target/linux/brcm63xx/patches-4.4/409-bcm63xx_net_phy-fix-config_intr.patch
@@ -0,0 +1,59 @@
+--- a/drivers/net/phy/bcm63xx.c
 b/drivers/net/phy/bcm63xx.c
+@@ -40,38 +40,54 @@
+   MII_BCM63XX_IR_SPEED |
+   MII_BCM63XX_IR_LINK) |
+   MII_BCM63XX_IR_EN;
+   return phy_write(phydev, MII_BCM63XX_IR, reg);
+ }
+ 
++static int bcm63xx_config_intr(struct phy_device *phydev)
++{
++  int reg, err;
++
++  reg = phy_read(phydev, MII_BCM63XX_IR);
++  if (reg < 0)
++  return reg;
++
++  if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
++  reg &= ~MII_BCM63XX_IR_GMASK;
++  else
++  reg |= MII_BCM63XX_IR_GMASK;
++
++  return phy_write(phydev, MII_BCM63XX_IR, reg);
++}
++
+ static struct phy_driver bcm63xx_driver[] = {
+ {
+   .phy_id = 0x00406000,
+   .phy_id_mask= 0xfc00,
+   .name   = "Broadcom BCM63XX (1)",
+   /* ASYM_PAUSE bit is marked RO in datasheet, so don't cheat */
+   .features   = (PHY_BASIC_FEATURES | SUPPORTED_Pause),
+   .flags  = PHY_HAS_INTERRUPT | PHY_IS_INTERNAL,
+   .config_init= bcm63xx_config_init,
+   .config_aneg= genphy_config_aneg,
+   .read_status= genphy_read_status,
+   .ack_interrupt  = bcm_phy_ack_intr,
+-  .config_intr= bcm_phy_config_intr,
++  .config_intr= bcm63xx_config_intr,
+   .driver = { .owner = THIS_MODULE },
+ }, {
+   /* same phy as above, with just a different OUI */
+   .phy_id = 0x002bdc00,
+   .phy_id_mask= 0xfc00,
+   .name   = "Broadcom BCM63XX (2)",
+   .features   = (PHY_BASIC_FEATURES | SUPPORTED_Pause),
+   .flags  = PHY_HAS_INTERRUPT | PHY_IS_INTERNAL,
+   .config_init= bcm63xx_config_init,
+   .config_aneg= genphy_config_aneg,
+   .read_status= genphy_read_status,
+   .ack_interrupt  = bcm_phy_ack_intr,
+-  .config_intr= bcm_phy_config_intr,
++  .config_intr= bcm63xx_config_intr,
+   .driver = { .owner = THIS_MODULE },
+ } };
+ 
+ module_phy_driver(bcm63xx_driver);
+ 
+ static struct mdio_device_id __maybe_unused bcm63xx_tbl[] = {


___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


[LEDE-DEV] [PATCH] brcm63xx: fix internal phy registers

2016-12-17 Thread Daniel Gonzalez Cabanelas
The internal phy is using wrong registers for the config interrupt function,
causing incorrect behavior when detecting the link activity. Fix it.

We cannot use the bcm_phy_config_intr function from the bcm-phy-lib.c 
because it uses different registers from brcm63xx. We need to use
our own function, which matches with the one used by the 
"Broadcom PHY driver" (brcm_fet_config_intr at broadcom.c). 

brcm63xx internal phy uses the same registers as the ones defined in 
brcmphy.h for fast ethernet, use them instead. 

Signed-off-by: Daniel Gonzalez Cabanelas <dgcb...@gmail.com>
diff --git 
a/target/linux/brcm63xx/patches-4.4/409-bcm63xx_net_phy-fix-registers.patch 
b/target/linux/brcm63xx/patches-4.4/409-bcm63xx_net_phy-fix-registers.patch
new file mode 100644
index 000..c53d464
--- /dev/null
+++ b/target/linux/brcm63xx/patches-4.4/409-bcm63xx_net_phy-fix-registers.patch
@@ -0,0 +1,102 @@
+--- a/drivers/net/phy/bcm63xx.c
 b/drivers/net/phy/bcm63xx.c
+@@ -6,44 +6,55 @@
+  *as published by the Free Software Foundation; either version
+  *2 of the License, or (at your option) any later version.
+  */
+ #include "bcm-phy-lib.h"
+ #include 
+ #include 
+-
+-#define MII_BCM63XX_IR0x1a/* interrupt register */
+-#define MII_BCM63XX_IR_EN 0x4000  /* global interrupt enable */
+-#define MII_BCM63XX_IR_DUPLEX 0x0800  /* duplex changed */
+-#define MII_BCM63XX_IR_SPEED  0x0400  /* speed changed */
+-#define MII_BCM63XX_IR_LINK   0x0200  /* link changed */
+-#define MII_BCM63XX_IR_GMASK  0x0100  /* global interrupt mask */
++#include 
+ 
+ MODULE_DESCRIPTION("Broadcom 63xx internal PHY driver");
+ MODULE_AUTHOR("Maxime Bizon <mbi...@freebox.fr>");
+ MODULE_LICENSE("GPL");
+ 
+ static int bcm63xx_config_init(struct phy_device *phydev)
+ {
+   int reg, err;
+ 
+-  reg = phy_read(phydev, MII_BCM63XX_IR);
++  reg = phy_read(phydev, MII_BRCM_FET_INTREG);
+   if (reg < 0)
+   return reg;
+ 
+   /* Mask interrupts globally.  */
+-  reg |= MII_BCM63XX_IR_GMASK;
+-  err = phy_write(phydev, MII_BCM63XX_IR, reg);
++  reg |= MII_BRCM_FET_IR_MASK;
++  err = phy_write(phydev, MII_BRCM_FET_INTREG, reg);
+   if (err < 0)
+   return err;
+ 
+   /* Unmask events we are interested in  */
+-  reg = ~(MII_BCM63XX_IR_DUPLEX |
+-  MII_BCM63XX_IR_SPEED |
+-  MII_BCM63XX_IR_LINK) |
+-  MII_BCM63XX_IR_EN;
+-  return phy_write(phydev, MII_BCM63XX_IR, reg);
++  reg = ~(MII_BRCM_FET_IR_DUPLEX_EN |
++  MII_BRCM_FET_IR_SPEED_EN |
++  MII_BRCM_FET_IR_LINK_EN) |
++  MII_BRCM_FET_IR_ENABLE;
++  return phy_write(phydev, MII_BRCM_FET_INTREG, reg);
++}
++
++static int brcm_fet_config_intr(struct phy_device *phydev)
++{
++  int reg, err;
++
++  reg = phy_read(phydev, MII_BRCM_FET_INTREG);
++  if (reg < 0)
++  return reg;
++
++  if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
++  reg &= ~MII_BRCM_FET_IR_MASK;
++  else
++  reg |= MII_BRCM_FET_IR_MASK;
++
++  err = phy_write(phydev, MII_BRCM_FET_INTREG, reg);
++  return err;
+ }
+ 
+ static struct phy_driver bcm63xx_driver[] = {
+ {
+   .phy_id = 0x00406000,
+   .phy_id_mask= 0xfc00,
+@@ -52,26 +63,26 @@
+   .features   = (PHY_BASIC_FEATURES | SUPPORTED_Pause),
+   .flags  = PHY_HAS_INTERRUPT | PHY_IS_INTERNAL,
+   .config_init= bcm63xx_config_init,
+   .config_aneg= genphy_config_aneg,
+   .read_status= genphy_read_status,
+   .ack_interrupt  = bcm_phy_ack_intr,
+-  .config_intr= bcm_phy_config_intr,
++  .config_intr= brcm_fet_config_intr,
+   .driver = { .owner = THIS_MODULE },
+ }, {
+   /* same phy as above, with just a different OUI */
+   .phy_id = 0x002bdc00,
+   .phy_id_mask= 0xfc00,
+   .name   = "Broadcom BCM63XX (2)",
+   .features   = (PHY_BASIC_FEATURES | SUPPORTED_Pause),
+   .flags  = PHY_HAS_INTERRUPT | PHY_IS_INTERNAL,
+   .config_init= bcm63xx_config_init,
+   .config_aneg= genphy_config_aneg,
+   .read_status= genphy_read_status,
+   .ack_interrupt  = bcm_phy_ack_intr,
+-  .config_intr= bcm_phy_config_intr,
++  .config_intr= brcm_fet_config_intr,
+   .driver = { .owner = THIS_MODULE },
+ } };
+ 
+ module_phy_driver(bcm63xx_driver);
+ 
+ static struct mdio_device_id __maybe_unused bcm63xx_tbl[] = {


___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


[LEDE-DEV] [PATCH v2] brcm63xx: Add Observa VH4032N support

2016-12-03 Thread Daniel Gonzalez Cabanelas
Add support for the Observa Telecom VH4032N router.

This is another BCM6368 router, 128 MB RAM, 32MB flash and 3 USB
host ports. It has an onboard USB hub that needs to be pulled out of
reset via GPIO27. 

The 4 LAN switch LEDs should be controlled via hardware but they don't 
work as with all BCM6368 based boards (known bug, GPIO LAN-LED mux 
is lost at boot time). There is an ongoing patch to fix it in a different 
commit.

The wifi chip is an onboard Broadcom BCM43222.
---
change in v2:
shift order in LAN ports, and rename them to match exactly what
this board has
---
Signed-off-by: Daniel Gonzalez Cabanelas <dgcb...@gmail.com>
diff --git a/target/linux/brcm63xx/base-files/etc/board.d/02_network 
b/target/linux/brcm63xx/base-files/etc/board.d/02_network
index c20caf9..c83aa62 100755
--- a/target/linux/brcm63xx/base-files/etc/board.d/02_network
+++ b/target/linux/brcm63xx/base-files/etc/board.d/02_network
@@ -98,6 +98,11 @@ vr-3026e)
"0:lan:1" "1:lan:2" "2:lan:3" "3:lan:4" "8t@eth0"
;;
 
+vh4032n)
+   ucidef_add_switch "switch0" \
+   "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "8t@eth0"
+   ;;
+
 bcm96368mvwg)
ucidef_add_switch "switch0" \
"1:lan" "2:lan" "4:lan" "5:lan" "8t@eth0"
diff --git a/target/linux/brcm63xx/base-files/etc/diag.sh 
b/target/linux/brcm63xx/base-files/etc/diag.sh
index 852a701..3a858e4 100644
--- a/target/linux/brcm63xx/base-files/etc/diag.sh
+++ b/target/linux/brcm63xx/base-files/etc/diag.sh
@@ -33,6 +33,9 @@ set_state() {
spw303v)
status_led="spw303v:green:power+adsl"
;;
+   vh4032n)
+   status_led="VH4032N:red:power"
+   ;;
vr-3025un)
status_led="VR-3025un:green:power"
;;
diff --git a/target/linux/brcm63xx/base-files/etc/uci-defaults/09_fix_crc 
b/target/linux/brcm63xx/base-files/etc/uci-defaults/09_fix_crc
index 1201168..650db9d 100644
--- a/target/linux/brcm63xx/base-files/etc/uci-defaults/09_fix_crc
+++ b/target/linux/brcm63xx/base-files/etc/uci-defaults/09_fix_crc
@@ -31,6 +31,7 @@ case "$(brcm63xx_board_name)" in
spw303v |\
v2110 |\
v2500v_bb |\
+   vh4032n |\
vr-3025u |\
vr-3025un |\
vr-3026e |\
diff --git a/target/linux/brcm63xx/base-files/lib/brcm63xx.sh 
b/target/linux/brcm63xx/base-files/lib/brcm63xx.sh
index 9cc0b2b..3dce282 100755
--- a/target/linux/brcm63xx/base-files/lib/brcm63xx.sh
+++ b/target/linux/brcm63xx/base-files/lib/brcm63xx.sh
@@ -189,6 +189,9 @@ brcm63xx_dt_detect() {
"NuCom R5010UN v2")
board_name="r5010un_v2"
;;
+   "Observa VH4032N")
+   board_name="vh4032n"
+   ;;
"Pirelli A226G")
board_name="a226g"
;;
diff --git a/target/linux/brcm63xx/dts/vh4032n.dts 
b/target/linux/brcm63xx/dts/vh4032n.dts
new file mode 100644
index 000..d75c636
--- /dev/null
+++ b/target/linux/brcm63xx/dts/vh4032n.dts
@@ -0,0 +1,93 @@
+/dts-v1/;
+
+#include "bcm6368.dtsi"
+
+#include 
+
+/ {
+   model = "Observa VH4032N";
+   compatible = "observa,vh4032n", "brcm,bcm6368";
+
+   chosen {
+   bootargs = "root=/dev/mtdblock2 rootfstype=squashfs,jffs2 
noinitrd console=ttyS0,115200";
+   };
+
+   gpio-keys-polled {
+   compatible = "gpio-keys-polled";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   poll-interval = <20>;
+   debounce-interval = <60>;
+
+   reset {
+   label = "reset";
+   gpios = < 2 1>;
+   linux,code = ;
+   };
+   wps {
+   label = "wps";
+   gpios = < 3 1>;
+   linux,code = ;
+   };
+   };
+
+   gpio-leds {
+   compatible = "gpio-leds";
+
+   dsl_blue {
+   label = "VH4032N:blue:dsl";
+   gpios = < 2 1>;
+   };
+   dsl_red {
+   label = "VH4032N:red:dsl";
+   gpios = < 5 1>;
+   };
+   hspa_blue {
+   label = "VH4032N:blue:hspa";
+   gpios = < 11 1>;
+   };
+   hspa_red {
+   label = "VH4032N:red:hspa";
+   gpios = < 12 1>;
+   

[LEDE-DEV] [PATCH] brcm63xx: fix BCM6368 switch hw LEDs

2016-12-02 Thread Daniel Gonzalez Cabanelas
Prevent from erasing the pinmux of HW ephy LEDs in BCM6368

In BCM6368 CFE configures the HW controled LEDs for the switch
by setting the required GPIO pinmux. But in OpenWrt when the 
peripherals are initialized, the code is erasing the pinmux previously
configured by CFE. 

Just don't erase those bits to let the LEDs blink with LAN activity.

Signed-off-by: Daniel Gonzalez Cabanelas <dgcb...@gmail.com>
diff --git 
a/target/linux/brcm63xx/patches-4.4/805-bcm6368-dont_erase_ephy_ledmux.patch 
b/target/linux/brcm63xx/patches-4.4/805-bcm6368-dont_erase_ephy_ledmux.patch
new file mode 100644
index 000..84208b6
--- /dev/null
+++ b/target/linux/brcm63xx/patches-4.4/805-bcm6368-dont_erase_ephy_ledmux.patch
@@ -0,0 +1,18 @@
+--- a/arch/mips/bcm63xx/boards/board_common.c
 b/arch/mips/bcm63xx/boards/board_common.c
+@@ -81,6 +81,15 @@
+* inside arch_initcall */
+   val = 0;
+ 
++  if (board.has_enetsw && BCMCPU_IS_6368()) {
++  /* Don't erase EPHY LEDmux! */
++  val |= bcm_gpio_readl(GPIO_MODE_REG) & (
++  GPIO_MODE_6368_EPHY0_LED |
++  GPIO_MODE_6368_EPHY1_LED |
++  GPIO_MODE_6368_EPHY2_LED |
++  GPIO_MODE_6368_EPHY3_LED);
++  }
++
+ #ifdef CONFIG_PCI
+   if (board.has_pci) {
+   bcm63xx_pci_enabled = 1;


___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


[LEDE-DEV] [PATCH] brcm63xx: Add Observa VH4032N support

2016-11-30 Thread Daniel Gonzalez Cabanelas
Add support for the Observa Telecom VH4032N router.

This is another BCM6368 router, 128 MB RAM, 32MB flash and 3 USB
host ports. It has an onboard USB hub that needs to be pulled out of
reset via GPIO27. 

The 4 LAN switch LEDs should be controlled via hardware but they don't 
work as with all BCM6368 based boards (known bug, GPIO LAN-LED mux 
is lost at boot time).

The wifi chip is an onboard Broadcom BCM43222.

Signed-off-by: Daniel Gonzalez Cabanelas <dgcb...@gmail.com>
diff --git a/target/linux/brcm63xx/base-files/etc/board.d/02_network 
b/target/linux/brcm63xx/base-files/etc/board.d/02_network
index c20caf9..ab8f5d6 100755
--- a/target/linux/brcm63xx/base-files/etc/board.d/02_network
+++ b/target/linux/brcm63xx/base-files/etc/board.d/02_network
@@ -91,6 +91,7 @@ hg622 |\
 hg655b |\
 p870hw-51a_v2 |\
 r5010un_v2 |\
+vh4032n |\
 vr-3025un |\
 vr-3025u |\
 vr-3026e)
diff --git a/target/linux/brcm63xx/base-files/etc/diag.sh 
b/target/linux/brcm63xx/base-files/etc/diag.sh
index 852a701..3a858e4 100644
--- a/target/linux/brcm63xx/base-files/etc/diag.sh
+++ b/target/linux/brcm63xx/base-files/etc/diag.sh
@@ -33,6 +33,9 @@ set_state() {
spw303v)
status_led="spw303v:green:power+adsl"
;;
+   vh4032n)
+   status_led="VH4032N:red:power"
+   ;;
vr-3025un)
status_led="VR-3025un:green:power"
;;
diff --git a/target/linux/brcm63xx/base-files/etc/uci-defaults/09_fix_crc 
b/target/linux/brcm63xx/base-files/etc/uci-defaults/09_fix_crc
index 1201168..650db9d 100644
--- a/target/linux/brcm63xx/base-files/etc/uci-defaults/09_fix_crc
+++ b/target/linux/brcm63xx/base-files/etc/uci-defaults/09_fix_crc
@@ -31,6 +31,7 @@ case "$(brcm63xx_board_name)" in
spw303v |\
v2110 |\
v2500v_bb |\
+   vh4032n |\
vr-3025u |\
vr-3025un |\
vr-3026e |\
diff --git a/target/linux/brcm63xx/base-files/lib/brcm63xx.sh 
b/target/linux/brcm63xx/base-files/lib/brcm63xx.sh
index 9cc0b2b..3dce282 100755
--- a/target/linux/brcm63xx/base-files/lib/brcm63xx.sh
+++ b/target/linux/brcm63xx/base-files/lib/brcm63xx.sh
@@ -189,6 +189,9 @@ brcm63xx_dt_detect() {
"NuCom R5010UN v2")
board_name="r5010un_v2"
;;
+   "Observa VH4032N")
+   board_name="vh4032n"
+   ;;
"Pirelli A226G")
board_name="a226g"
;;
diff --git a/target/linux/brcm63xx/dts/vh4032n.dts 
b/target/linux/brcm63xx/dts/vh4032n.dts
new file mode 100644
index 000..d75c636
--- /dev/null
+++ b/target/linux/brcm63xx/dts/vh4032n.dts
@@ -0,0 +1,93 @@
+/dts-v1/;
+
+#include "bcm6368.dtsi"
+
+#include 
+
+/ {
+   model = "Observa VH4032N";
+   compatible = "observa,vh4032n", "brcm,bcm6368";
+
+   chosen {
+   bootargs = "root=/dev/mtdblock2 rootfstype=squashfs,jffs2 
noinitrd console=ttyS0,115200";
+   };
+
+   gpio-keys-polled {
+   compatible = "gpio-keys-polled";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   poll-interval = <20>;
+   debounce-interval = <60>;
+
+   reset {
+   label = "reset";
+   gpios = < 2 1>;
+   linux,code = ;
+   };
+   wps {
+   label = "wps";
+   gpios = < 3 1>;
+   linux,code = ;
+   };
+   };
+
+   gpio-leds {
+   compatible = "gpio-leds";
+
+   dsl_blue {
+   label = "VH4032N:blue:dsl";
+   gpios = < 2 1>;
+   };
+   dsl_red {
+   label = "VH4032N:red:dsl";
+   gpios = < 5 1>;
+   };
+   hspa_blue {
+   label = "VH4032N:blue:hspa";
+   gpios = < 11 1>;
+   };
+   hspa_red {
+   label = "VH4032N:red:hspa";
+   gpios = < 12 1>;
+   };
+   power_blue {
+   label = "VH4032N:blue:power";
+   gpios = < 22 0>;
+   };
+   power_red {
+   label = "VH4032N:red:power";
+   gpios = < 24 0>;
+   default-state = "on";
+   };
+   voice_blue {
+   label = "VH4032N:blue:voice";
+   gpios = < 25 1>;
+   };
+   voice_red {

[LEDE-DEV] [PATCH v2 5/5] brcm63xx: fix Livebox 1 support: config files

2016-08-29 Thread Daniel Gonzalez Cabanelas
Fix configuration files for the Livebox 1 routers.
- Add status led
- Set eth0 as the LAN port, for coherence with RedBoot and comfortability.
- Add led triggers

Signed-off-by: Daniel Gonzalez Cabanelas <dgcb...@gmail.com>
---
change in v2:
Split changes in DTS file
---
diff --git a/target/linux/brcm63xx/base-files/etc/board.d/01_leds 
b/target/linux/brcm63xx/base-files/etc/board.d/01_leds
index 4163214..8d8a942 100755
--- a/target/linux/brcm63xx/base-files/etc/board.d/01_leds
+++ b/target/linux/brcm63xx/base-files/etc/board.d/01_leds
@@ -58,6 +58,11 @@ homehub2a)
ucidef_set_led_usbdev "usb1" "USB1" "HOMEHUB2A:blue:phone" "1-1"
ucidef_set_led_usbdev "usb2" "USB2" "HOMEHUB2A:green:phone" "2-1"
;;
+livebox1)
+   ucidef_set_led_netdev "lan" "LAN" "Livebox1:red:traffic" "eth0"
+   ucidef_set_led_netdev "wan" "WAN" "Livebox1:red:adsl" "eth1"
+   ucidef_set_led_netdev "wlan0" "WIFI" "Livebox1:red:wifi" "wlan0"
+   ;;
 r5010un_v2)
ucidef_set_led_usbdev "usb" "USB" "R5010UNv2:green:usb" "1-1"
;;
diff --git a/target/linux/brcm63xx/base-files/etc/board.d/02_network 
b/target/linux/brcm63xx/base-files/etc/board.d/02_network
index 83367c1..c20caf9 100755
--- a/target/linux/brcm63xx/base-files/etc/board.d/02_network
+++ b/target/linux/brcm63xx/base-files/etc/board.d/02_network
@@ -129,6 +129,10 @@ bcm963268bu_p300)
"0:lan" "3:lan" "4:lan" "5:lan" "6:lan" "7:lan" "8t@eth0"
;;
 
+livebox1)
+   ucidef_set_interfaces_lan_wan "eth0" "eth1"
+   ;;
+
 *)
ucidef_set_interfaces_lan_wan "eth1" "eth0"
;;
diff --git a/target/linux/brcm63xx/base-files/etc/diag.sh 
b/target/linux/brcm63xx/base-files/etc/diag.sh
index 51756ae..852a701 100644
--- a/target/linux/brcm63xx/base-files/etc/diag.sh
+++ b/target/linux/brcm63xx/base-files/etc/diag.sh
@@ -102,6 +102,9 @@ set_state() {
hg655b)
status_led="HW65x:green:power"
;;
+   livebox1)
+   status_led="Livebox1:red:adsl-fail-power"
+   ;;
p870hw-51a_v2)
status_led="P870HW-51a:green:power"
;;

___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


[LEDE-DEV] [PATCH v2 1/5] brcm63xx: fix Livebox 1 support: DTS

2016-08-29 Thread Daniel Gonzalez Cabanelas
Fix the DTS file for the Livebox 1 routers:
- no failsafe button, use button 1 for this purpose

Signed-off-by: Daniel Gonzalez Cabanelas <dgcb...@gmail.com>
---
change in v2:
Split changes in DTS file
Tune button labels
---
diff --git a/target/linux/brcm63xx/dts/livebox-blue-5g.dts 
b/target/linux/brcm63xx/dts/livebox-blue-5g.dts
index 0df5fa8..cb3b019 100644
--- a/target/linux/brcm63xx/dts/livebox-blue-5g.dts
+++ b/target/linux/brcm63xx/dts/livebox-blue-5g.dts
@@ -21,13 +21,13 @@
debounce-interval = <60>;
 
button1 {
-   label = "BTN_1";
+   label = "1";
gpios = < 4 1>;
-   linux,code = ;
+   linux,code = ;
};
 
button2 {
-   label = "BTN_2";
+   label = "2";
gpios = < 7 1>;
linux,code = ;
};


___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


[LEDE-DEV] [PATCH v2 3/5] brcm63xx: fix Livebox 1 support: DTS

2016-08-29 Thread Daniel Gonzalez Cabanelas
Fix the DTS file for the Livebox 1 routers:
- part probe wrong, it should be RedBoot (uppercase matters)

Signed-off-by: Daniel Gonzalez Cabanelas <dgcb...@gmail.com>
---
change in v2:
Split changes in DTS file
---
diff --git a/target/linux/brcm63xx/dts/livebox-blue-5g.dts 
b/target/linux/brcm63xx/dts/livebox-blue-5g.dts
index 0df5fa8..e776652 100644
--- a/target/linux/brcm63xx/dts/livebox-blue-5g.dts
+++ b/target/linux/brcm63xx/dts/livebox-blue-5g.dts
@@ -68,5 +68,5 @@
reg = <0x1e40 0x80>;
status = "ok";
 
-   linux,part-probe = "redboot";
+   linux,part-probe = "RedBoot";
 };


___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


[LEDE-DEV] [PATCH v2 2/5] brcm63xx: fix Livebox 1 support: DTS

2016-08-29 Thread Daniel Gonzalez Cabanelas
Fix the DTS file for the Livebox 1 routers:
- leds are totally wrong, fix them.
Signed-off-by: Daniel Gonzalez Cabanelas <dgcb...@gmail.com>
---
change in v2:
Split changes in DTS file
---
diff --git a/target/linux/brcm63xx/dts/livebox-blue-5g.dts 
b/target/linux/brcm63xx/dts/livebox-blue-5g.dts
index 0df5fa8..c92e9e6 100644
--- a/target/linux/brcm63xx/dts/livebox-blue-5g.dts
+++ b/target/linux/brcm63xx/dts/livebox-blue-5g.dts
@@ -37,28 +37,28 @@
compatible = "gpio-leds";
 
red_adsl_fail {
-   label = "Livebox-blue-5g:red:adsl-fail";
+   label = "Livebox1:red:adsl-fail-power";
gpios = < 0 0>;
default-state = "on";
};
 
red_adsl {
-   label = "Livebox-blue-5g:red:adsl-fail";
+   label = "Livebox1:red:adsl";
gpios = < 1 0>;
};
 
red_traffic {
-   label = "Livebox-blue-5g:red:adsl-fail";
+   label = "Livebox1:red:traffic";
gpios = < 2 0>;
};
 
red_phone {
-   label = "Livebox-blue-5g:red:adsl-fail";
+   label = "Livebox1:red:phone";
gpios = < 3 0>;
};
 
red_wifi {
-   label = "Livebox-blue-5g:red:adsl-fail";
+   label = "Livebox1:red:wifi";
gpios = < 4 0>;
};
};


___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


[LEDE-DEV] [PATCH] brcm63xx: implement gpio to irq

2016-08-18 Thread Daniel Gonzalez Cabanelas
Implement "to_irq" in the GPIO driver.

A few GPIOs in bcm63xx SoCs have IRQs. They are known in this target
as external IRQs. This patch adds the function "to_irq" for allowing to
use the generic GPIO lib function gpio_to_irq(). This function just
returns the IRQ number at the GPIO line.

Signed-off-by: Daniel Gonzalez Cabanelas <dgcb...@gmail.com>
diff --git 
a/target/linux/brcm63xx/patches-4.4/374-gpio-add-a-simple-GPIO-driver-for-bcm63xx.patch
 
b/target/linux/brcm63xx/patches-4.4/374-gpio-add-a-simple-GPIO-driver-for-bcm63xx.patch
index 92b0e71..0d6f8ce 100644
--- 
a/target/linux/brcm63xx/patches-4.4/374-gpio-add-a-simple-GPIO-driver-for-bcm63xx.patch
+++ 
b/target/linux/brcm63xx/patches-4.4/374-gpio-add-a-simple-GPIO-driver-for-bcm63xx.patch
@@ -40,7 +40,7 @@ Signed-off-by: Jonas Gorski <j...@openwrt.org>
  obj-$(CONFIG_GPIO_CLPS711X)   += gpio-clps711x.o
 --- /dev/null
 +++ b/drivers/gpio/gpio-bcm63xx.c
-@@ -0,0 +1,122 @@
+@@ -0,0 +1,178 @@
 +/*
 + * Driver for BCM63XX memory-mapped GPIO controllers, based on
 + * Generic driver for memory-mapped GPIO controllers.
@@ -75,6 +75,58 @@ Signed-off-by: Jonas Gorski <j...@openwrt.org>
 +#include 
 +#include 
 +
++#include 
++
++static int bcm63xx_gpio_to_irq(struct gpio_chip *chip, unsigned gpio)
++{
++  unsigned int i;
++  int irq2gpio[6] = { -1, -1, -1, -1, -1, -1 };
++
++  switch (bcm63xx_get_cpu_id()) {
++  case BCM6328_CPU_ID:
++  irq2gpio[0] = 23;
++  irq2gpio[1] = 24;
++  irq2gpio[2] = 15;
++  irq2gpio[3] = 12;
++  break;
++  case BCM6348_CPU_ID:
++  case BCM63268_CPU_ID:
++  if (chip->ngpio < 32)
++  {
++  irq2gpio[0] = 0;
++  irq2gpio[1] = 1;
++  irq2gpio[2] = 2;
++  irq2gpio[3] = 3;
++  }
++  else
++  return -EINVAL;
++  break;
++  case BCM6358_CPU_ID:
++  case BCM6368_CPU_ID:
++  if (chip->ngpio < 32)
++  {
++  irq2gpio[0] = 2;
++  irq2gpio[1] = 3;
++  irq2gpio[2] = 4;
++  irq2gpio[3] = 5;
++  irq2gpio[4] = 0;
++  irq2gpio[5] = 1;
++  }
++  else
++  return -EINVAL;
++  break;
++  default:
++  return -EINVAL;
++  }
++
++  for (i = 0; i < 6; i++) {
++  if (irq2gpio[i] == gpio)
++  return i + IRQ_EXTERNAL_BASE;
++  }
++
++  return -EINVAL;
++}
++
 +static int bcm63xx_gpio_probe(struct platform_device *pdev)
 +{
 +  struct device *dev = >dev;
@@ -85,6 +137,7 @@ Signed-off-by: Jonas Gorski <j...@openwrt.org>
 +  int err;
 +  struct bgpio_chip *bgc;
 +  struct bgpio_pdata *pdata = dev_get_platdata(dev);
++  struct gpio_chip *chip;
 +
 +  dirout_r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 +  dat_r = platform_get_resource(pdev, IORESOURCE_MEM, 1);
@@ -131,8 +184,11 @@ Signed-off-by: Jonas Gorski <j...@openwrt.org>
 +  if (pdata->ngpio > 0)
 +  bgc->gc.ngpio = pdata->ngpio;
 +  }
++  
++  chip = >gc;
++  chip->to_irq = bcm63xx_gpio_to_irq;
 +
-+  return gpiochip_add(>gc);
++  return gpiochip_add(chip);
 +}
 +
 +static int bcm63xx_gpio_remove(struct platform_device *pdev)


___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


[LEDE-DEV] [PATCH 3/3] brcm63xx: fix Livebox 1 support: config files

2016-08-16 Thread Daniel Gonzalez Cabanelas
Fix configuration files for the Livebox 1 routers.
- Add status led
- Set eth0 as the LAN port, for coherence with RedBoot and comfortability.
- Add led triggers

Signed-off-by: Daniel Gonzalez Cabanelas <dgcb...@gmail.com>
diff --git a/target/linux/brcm63xx/base-files/etc/board.d/01_leds 
b/target/linux/brcm63xx/base-files/etc/board.d/01_leds
index 4163214..8d8a942 100755
--- a/target/linux/brcm63xx/base-files/etc/board.d/01_leds
+++ b/target/linux/brcm63xx/base-files/etc/board.d/01_leds
@@ -58,6 +58,11 @@ homehub2a)
ucidef_set_led_usbdev "usb1" "USB1" "HOMEHUB2A:blue:phone" "1-1"
ucidef_set_led_usbdev "usb2" "USB2" "HOMEHUB2A:green:phone" "2-1"
;;
+livebox1)
+   ucidef_set_led_netdev "lan" "LAN" "Livebox1:red:traffic" "eth0"
+   ucidef_set_led_netdev "wan" "WAN" "Livebox1:red:adsl" "eth1"
+   ucidef_set_led_netdev "wlan0" "WIFI" "Livebox1:red:wifi" "wlan0"
+   ;;
 r5010un_v2)
ucidef_set_led_usbdev "usb" "USB" "R5010UNv2:green:usb" "1-1"
;;
diff --git a/target/linux/brcm63xx/base-files/etc/board.d/02_network 
b/target/linux/brcm63xx/base-files/etc/board.d/02_network
index 83367c1..c20caf9 100755
--- a/target/linux/brcm63xx/base-files/etc/board.d/02_network
+++ b/target/linux/brcm63xx/base-files/etc/board.d/02_network
@@ -129,6 +129,10 @@ bcm963268bu_p300)
"0:lan" "3:lan" "4:lan" "5:lan" "6:lan" "7:lan" "8t@eth0"
;;
 
+livebox1)
+   ucidef_set_interfaces_lan_wan "eth0" "eth1"
+   ;;
+
 *)
ucidef_set_interfaces_lan_wan "eth1" "eth0"
;;
diff --git a/target/linux/brcm63xx/base-files/etc/diag.sh 
b/target/linux/brcm63xx/base-files/etc/diag.sh
index 51756ae..852a701 100644
--- a/target/linux/brcm63xx/base-files/etc/diag.sh
+++ b/target/linux/brcm63xx/base-files/etc/diag.sh
@@ -102,6 +102,9 @@ set_state() {
hg655b)
status_led="HW65x:green:power"
;;
+   livebox1)
+   status_led="Livebox1:red:adsl-fail-power"
+   ;;
p870hw-51a_v2)
status_led="P870HW-51a:green:power"
;;


___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


[LEDE-DEV] [PATCH 2/3] brcm63xx: fix Livebox 1 support: image

2016-08-16 Thread Daniel Gonzalez Cabanelas
Fix Image generation for the Livebox 1
- missing "relocate-kernel", wrong "LOADADDR", fix it

Signed-off-by: Daniel Gonzalez Cabanelas <dgcb...@gmail.com>
diff --git a/target/linux/brcm63xx/image/Makefile 
b/target/linux/brcm63xx/image/Makefile
index f5de673..beed8e9 100644
--- a/target/linux/brcm63xx/image/Makefile
+++ b/target/linux/brcm63xx/image/Makefile
@@ -151,7 +151,7 @@ define Build/redboot-bin
$(TOPDIR)/scripts/redboot-script.pl \
-k $(BIN_DIR)/$(REDBOOT_PREFIX)-vmlinux.gz \
-r $(BIN_DIR)/$(REDBOOT_PREFIX)-$(notdir $(IMAGE_ROOTFS)) \
-   -a $(strip $(LOADADDR)) -f 0xbe43 -l 0x7c \
+   -a $(strip $(LOADER_ENTRY)) -f 0xbe43 -l 0x7c \
-s 0x1000 -t 20 -o $@.redbootscript
dd if="$@.redbootscript" of="$@.redbootscript.padded" bs=4096 conv=sync
cat \
diff --git a/target/linux/brcm63xx/image/bcm63xx.mk 
b/target/linux/brcm63xx/image/bcm63xx.mk
index af14168..34d496e 100644
--- a/target/linux/brcm63xx/image/bcm63xx.mk
+++ b/target/linux/brcm63xx/image/bcm63xx.mk
@@ -44,7 +44,7 @@ DEVICE_VARS += NETGEAR_BOARD_ID NETGEAR_REGION
 
 define Device/bcm63xx_redboot
   FILESYSTEMS := squashfs
-  KERNEL := kernel-bin | append-dtb | gzip
+  KERNEL := kernel-bin | append-dtb | relocate-kernel | gzip
   KERNEL_INITRAMFS := kernel-bin | append-dtb | lzma | loader-lzma elf
   IMAGES := redboot.bin
   IMAGE/redboot.bin := redboot-bin


___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev


[LEDE-DEV] [PATCH 1/3] brcm63xx: fix Livebox 1 support: DTS

2016-08-16 Thread Daniel Gonzalez Cabanelas
Fix the DTS file for the Livebox 1 routers:
- leds are totally wrong, fix them.
- no failsafe button, use button 1 for this purpose
- part probe wrong, it should be RedBoot (uppercase matters)

Signed-off-by: Daniel Gonzalez Cabanelas <dgcb...@gmail.com>
diff --git a/target/linux/brcm63xx/dts/livebox-blue-5g.dts 
b/target/linux/brcm63xx/dts/livebox-blue-5g.dts
index 0df5fa8..6eeba69 100644
--- a/target/linux/brcm63xx/dts/livebox-blue-5g.dts
+++ b/target/linux/brcm63xx/dts/livebox-blue-5g.dts
@@ -23,7 +23,7 @@
button1 {
label = "BTN_1";
gpios = < 4 1>;
-   linux,code = ;
+   linux,code = ;
};
 
button2 {
@@ -37,28 +37,28 @@
compatible = "gpio-leds";
 
red_adsl_fail {
-   label = "Livebox-blue-5g:red:adsl-fail";
+   label = "Livebox1:red:adsl-fail-power";
gpios = < 0 0>;
default-state = "on";
};
 
red_adsl {
-   label = "Livebox-blue-5g:red:adsl-fail";
+   label = "Livebox1:red:adsl";
gpios = < 1 0>;
};
 
red_traffic {
-   label = "Livebox-blue-5g:red:adsl-fail";
+   label = "Livebox1:red:traffic";
gpios = < 2 0>;
};
 
red_phone {
-   label = "Livebox-blue-5g:red:adsl-fail";
+   label = "Livebox1:red:phone";
gpios = < 3 0>;
};
 
red_wifi {
-   label = "Livebox-blue-5g:red:adsl-fail";
+   label = "Livebox1:red:wifi";
gpios = < 4 0>;
};
};
@@ -68,5 +68,5 @@
reg = <0x1e40 0x80>;
status = "ok";
 
-   linux,part-probe = "redboot";
+   linux,part-probe = "RedBoot";
 };


___
Lede-dev mailing list
Lede-dev@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/lede-dev