[LEDE-DEV] [PATCH 1/4] mac80211: enable use of GPI9 of ath9k

2017-09-02 Thread hackpascal
GPI9 (input-only pin) is used by Netgear WNDR4500v3 as the wireless button,
but not enabled in ath9k.

This patch enables the pin by adding corresponding bit in the usable gpio
masks.

Signed-off-by: hackpascal 
---
 .../552-ath9k-enable-use-of-wmac-gpi9.patch| 22 ++
 1 file changed, 22 insertions(+)
 create mode 100644 
package/kernel/mac80211/patches/552-ath9k-enable-use-of-wmac-gpi9.patch

diff --git 
a/package/kernel/mac80211/patches/552-ath9k-enable-use-of-wmac-gpi9.patch 
b/package/kernel/mac80211/patches/552-ath9k-enable-use-of-wmac-gpi9.patch
new file mode 100644
index 00..b64006a202
--- /dev/null
+++ b/package/kernel/mac80211/patches/552-ath9k-enable-use-of-wmac-gpi9.patch
@@ -0,0 +1,22 @@
+--- a/drivers/net/wireless/ath/ath9k/reg.h
 b/drivers/net/wireless/ath/ath9k/reg.h
+@@ -1136,8 +1136,8 @@ enum {
+ #define AR9280_GPIO_MASK   0x03FF
+ #define AR9285_GPIO_MASK   0x0FFF
+ #define AR9287_GPIO_MASK   0x03FF
+-#define AR9300_GPIO_MASK   0xF4FF
+-#define AR9330_GPIO_MASK   0xF4FF
++#define AR9300_GPIO_MASK   0xF6FF
++#define AR9330_GPIO_MASK   0xF6FF
+ #define AR9340_GPIO_MASK   0x000F
+ #define AR9462_GPIO_MASK   0x3FFF
+ #define AR9485_GPIO_MASK   0x0FFF
+@@ -1145,7 +1145,7 @@ enum {
+ #define AR9550_GPIO_MASK   0x000F
+ #define AR9561_GPIO_MASK   0x000F
+ #define AR9565_GPIO_MASK   0x3FFF
+-#define AR9580_GPIO_MASK   0xF4FF
++#define AR9580_GPIO_MASK   0xF6FF
+ #define AR7010_GPIO_MASK   0x
+ 
+ #define AR_GPIO_IN_OUT   (AR_SREV_9340(ah) ? 0x4028 : 
0x4048)
-- 
2.11.0


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


[LEDE-DEV] [PATCH 2/4] kernel/4.4: mtdsplit: add kernel cmdline to disable split parsers for rootfs and firmware partitions

2017-09-02 Thread hackpascal
Some firmware have already defined rootfs/rootfs_data partitions and do not 
need extra split operations.

This patch adds two kernel cmdline parameters to disable firmware and rootfs 
parsers separately:
  nofwsplit
  norootfssplit

Signed-off-by: hackpascal 
---
 ...d-kernel-cmdline-to-disable-split-parsers.patch | 56 ++
 1 file changed, 56 insertions(+)
 create mode 100644 
target/linux/generic/pending-4.4/405-mtd-add-kernel-cmdline-to-disable-split-parsers.patch

diff --git 
a/target/linux/generic/pending-4.4/405-mtd-add-kernel-cmdline-to-disable-split-parsers.patch
 
b/target/linux/generic/pending-4.4/405-mtd-add-kernel-cmdline-to-disable-split-parsers.patch
new file mode 100644
index 00..b0a666a401
--- /dev/null
+++ 
b/target/linux/generic/pending-4.4/405-mtd-add-kernel-cmdline-to-disable-split-parsers.patch
@@ -0,0 +1,56 @@
+--- a/drivers/mtd/mtdpart.c
 b/drivers/mtd/mtdpart.c
+@@ -39,6 +39,10 @@
+ 
+ #define MTD_ERASE_PARTIAL 0x8000 /* partition only covers parts of an 
erase block */
+ 
++/* Do not split firmware/rootfs partition */
++static bool no_fw_split_flag = 0;
++static bool no_rootfs_split_flag = 0;
++
+ /* Our partition linked list */
+ static LIST_HEAD(mtd_partitions);
+ static DEFINE_MUTEX(mtd_partitions_mutex);
+@@ -774,6 +778,9 @@ mtd_pad_erasesize(struct mtd_info *mtd,
+ 
+ static void split_firmware(struct mtd_info *master, struct mtd_part *part)
+ {
++  if (no_fw_split_flag)
++  return;
++
+   run_parsers_by_type(part, MTD_PARSER_TYPE_FIRMWARE);
+ }
+ 
+@@ -790,7 +797,8 @@ static void mtd_partition_split(struct m
+   return;
+ 
+   if (!strcmp(part->mtd.name, "rootfs")) {
+-  run_parsers_by_type(part, MTD_PARSER_TYPE_ROOTFS);
++  if (!no_rootfs_split_flag)
++  run_parsers_by_type(part, MTD_PARSER_TYPE_ROOTFS);
+ 
+   rootfs_found = 1;
+   }
+@@ -1092,3 +1100,22 @@ uint64_t mtd_get_device_size(const struc
+   return PART(mtd)->master->size;
+ }
+ EXPORT_SYMBOL_GPL(mtd_get_device_size);
++
++
++static int __init no_fw_split(char *str)
++{
++  no_fw_split_flag = 1;
++
++  return 0;
++}
++
++early_param("nofwsplit", no_fw_split);
++
++static int __init no_rootfs_split(char *str)
++{
++  no_rootfs_split_flag = 1;
++
++  return 0;
++}
++
++early_param("norootfssplit", no_rootfs_split);
-- 
2.11.0


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


[LEDE-DEV] [PATCH 4/4] ar71xx: add netgear wndr4500v3 support

2017-09-02 Thread hackpascal
Netgear WNDR4500v3 uses one SPI-NOR and one SPI-NAND. The bootloader and
caldata are on the SPI-NOR flash, and the firmware is on the SPI-NAND flash.

Hardware specification:
CPU: QCA9563
Switch: QCA8337N
5.8GHz Wifi: AR9580
SPI-NOR: 2MB
SPI-NAND: 128MB
DDR2: 128MB

WNDR4300v2 is similar to WNDR4500v3 but not tested and not included here.

Signed-off-by: hackpascal 
---
 target/linux/ar71xx/base-files/etc/board.d/01_leds |   6 +
 .../linux/ar71xx/base-files/etc/board.d/02_network |   1 +
 target/linux/ar71xx/base-files/etc/diag.sh |   1 +
 target/linux/ar71xx/base-files/lib/ar71xx.sh   |   3 +
 .../ar71xx/base-files/lib/upgrade/platform.sh  |   3 +-
 .../ar71xx/files/arch/mips/ath79/Kconfig.openwrt   |  11 +
 target/linux/ar71xx/files/arch/mips/ath79/Makefile |   1 +
 .../files/arch/mips/ath79/mach-wndr4500-v3.c   | 233 +
 .../linux/ar71xx/files/arch/mips/ath79/machtypes.h |   1 +
 target/linux/ar71xx/image/legacy.mk|   2 +
 target/linux/ar71xx/image/nand.mk  |   6 +
 target/linux/ar71xx/nand/config-default|   3 +
 12 files changed, 270 insertions(+), 1 deletion(-)
 create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-wndr4500-v3.c

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 84b1a7dfd9..b4ebbd6173 100755
--- a/target/linux/ar71xx/base-files/etc/board.d/01_leds
+++ b/target/linux/ar71xx/base-files/etc/board.d/01_leds
@@ -828,6 +828,12 @@ wndr4300)
ucidef_set_led_wlan "wlan2g" "WLAN2G" "netgear:green:wlan2g" "phy0tpt"
ucidef_set_led_wlan "wlan5g" "WLAN5G" "netgear:blue:wlan5g" "phy1tpt"
;;
+wndr4500-v3)
+   ucidef_set_led_netdev "wan" "WAN (green)" "netgear:green:wan" "eth0.2"
+   ucidef_set_led_usbdev "usb1" "USB1" "netgear:green:usb1" "1-1"
+   ucidef_set_led_usbdev "usb2" "USB2" "netgear:green:usb2" "2-1"
+   ucidef_set_led_wlan "wlan2g" "WLAN2G" "netgear:green:wlan2g" "phy0tpt"
+   ;;
 whr-g301n|\
 whr-hp-g300n|\
 whr-hp-gn)
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 ba54d89b8f..d455afad69 100755
--- a/target/linux/ar71xx/base-files/etc/board.d/02_network
+++ b/target/linux/ar71xx/base-files/etc/board.d/02_network
@@ -262,6 +262,7 @@ ar71xx_setup_interfaces()
ucidef_add_switch "switch0" \
"0@eth0" "1:lan:1" "2:lan:4" "3:lan:3" "4:lan:2"
;;
+   wndr4500-v3|\
cr5000|\
dgl-5500-a1|\
dhp-1565-a1|\
diff --git a/target/linux/ar71xx/base-files/etc/diag.sh 
b/target/linux/ar71xx/base-files/etc/diag.sh
index 7753a7156d..6a392e790a 100644
--- a/target/linux/ar71xx/base-files/etc/diag.sh
+++ b/target/linux/ar71xx/base-files/etc/diag.sh
@@ -471,6 +471,7 @@ get_status_led() {
wndr3700|\
wndr3700v4|\
wndr4300|\
+   wndr4500-v3|\
wnr2000|\
wnr2000-v3|\
wnr2200|\
diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh 
b/target/linux/ar71xx/base-files/lib/ar71xx.sh
index 7fd5fb4522..e44fa0d09a 100755
--- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
@@ -1249,6 +1249,9 @@ ar71xx_board_detect() {
*"WNDR4300")
name="wndr4300"
;;
+   *"WNDR4500v3")
+   name="wndr4500-v3"
+   ;;
*"WNR1000 V2")
name="wnr1000-v2"
;;
diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh 
b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
index 05b5634aa5..12e920f46d 100755
--- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
@@ -533,7 +533,8 @@ platform_check_image() {
r6100|\
rambutan|\
wndr3700v4|\
-   wndr4300)
+   wndr4300|\
+   wndr4500-v3)
nand_do_platform_check $board $1
return $?
;;
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt 
b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
index ff9c3037a1..68fdd4db66 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
+++ b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
@@ -1061,6 +1061,17 @@ config ATH79_MACH_WNDR4300
select ATH79_DEV_USB
select ATH79_DEV_WMAC
 
+config ATH79_MACH_WNDR4500_V3
+   bool "NETGEAR WNDR4300v2/WNDR4500v3 board support"
+   select SOC_QCA956X
+  

[LEDE-DEV] [PATCH 3/4] kernel/4.4: add generic spi-nand framework

2017-09-02 Thread hackpascal
This patch adds generic SPI-NAND framework for linux-4.4.

Files come from patches of target pistachio, but have lots of modifications
to add full support for GD5F series.

Signed-off-by: hackpascal 
---
 target/linux/generic/config-4.4|   2 +
 .../generic/files/drivers/mtd/spi-nand/Kconfig |  17 +
 .../generic/files/drivers/mtd/spi-nand/Makefile|   2 +
 .../files/drivers/mtd/spi-nand/spi-nand-base.c | 588 
 .../files/drivers/mtd/spi-nand/spi-nand-device.c   | 761 +
 .../generic/files/include/linux/mtd/spi-nand.h |  56 ++
 ...length-of-ID-before-reading-bits-per-cell.patch |  33 +
 ...-Add-JEDEC-manufacturer-ID-for-Gigadevice.patch |  35 +
 .../454-mtd-Introduce-SPI-NAND-framework.patch |  20 +
 9 files changed, 1514 insertions(+)
 create mode 100644 target/linux/generic/files/drivers/mtd/spi-nand/Kconfig
 create mode 100644 target/linux/generic/files/drivers/mtd/spi-nand/Makefile
 create mode 100644 
target/linux/generic/files/drivers/mtd/spi-nand/spi-nand-base.c
 create mode 100644 
target/linux/generic/files/drivers/mtd/spi-nand/spi-nand-device.c
 create mode 100644 target/linux/generic/files/include/linux/mtd/spi-nand.h
 create mode 100644 
target/linux/generic/pending-4.4/452-mtd-nand-Check-length-of-ID-before-reading-bits-per-cell.patch
 create mode 100644 
target/linux/generic/pending-4.4/453-mtd-nand-Add-JEDEC-manufacturer-ID-for-Gigadevice.patch
 create mode 100644 
target/linux/generic/pending-4.4/454-mtd-Introduce-SPI-NAND-framework.patch

diff --git a/target/linux/generic/config-4.4 b/target/linux/generic/config-4.4
index 1c0af9597f..0fd7c1d49c 100644
--- a/target/linux/generic/config-4.4
+++ b/target/linux/generic/config-4.4
@@ -2369,6 +2369,8 @@ CONFIG_MTD_ROOTFS_ROOT_DEV=y
 # CONFIG_MTD_SLRAM is not set
 # CONFIG_MTD_SM_COMMON is not set
 # CONFIG_MTD_SPINAND_MT29F is not set
+# CONFIG_MTD_SPI_NAND is not set
+# CONFIG_MTD_SPI_NAND_DEVICES is not set
 # CONFIG_MTD_SPI_NOR is not set
 # CONFIG_MTD_SPI_NOR_USE_4K_SECTORS is not set
 CONFIG_MTD_SPLIT=y
diff --git a/target/linux/generic/files/drivers/mtd/spi-nand/Kconfig 
b/target/linux/generic/files/drivers/mtd/spi-nand/Kconfig
new file mode 100644
index 00..ab6bb6c7fa
--- /dev/null
+++ b/target/linux/generic/files/drivers/mtd/spi-nand/Kconfig
@@ -0,0 +1,17 @@
+menuconfig MTD_SPI_NAND
+   tristate "SPI NAND device support"
+   depends on MTD
+   select MTD_NAND
+   help
+ This is the framework for the SPI NAND.
+
+if MTD_SPI_NAND
+
+config MTD_SPI_NAND_DEVICES
+   tristate "Support for SPI NAND devices"
+   default y
+   depends on MTD_SPI_NAND
+   help
+ Select this option if you require support for SPI NAND devices.
+
+endif # MTD_SPI_NAND
diff --git a/target/linux/generic/files/drivers/mtd/spi-nand/Makefile 
b/target/linux/generic/files/drivers/mtd/spi-nand/Makefile
new file mode 100644
index 00..6e460d1814
--- /dev/null
+++ b/target/linux/generic/files/drivers/mtd/spi-nand/Makefile
@@ -0,0 +1,2 @@
+obj-$(CONFIG_MTD_SPI_NAND) += spi-nand-base.o
+obj-$(CONFIG_MTD_SPI_NAND_DEVICES) += spi-nand-device.o
diff --git a/target/linux/generic/files/drivers/mtd/spi-nand/spi-nand-base.c 
b/target/linux/generic/files/drivers/mtd/spi-nand/spi-nand-base.c
new file mode 100644
index 00..07dad5397a
--- /dev/null
+++ b/target/linux/generic/files/drivers/mtd/spi-nand/spi-nand-base.c
@@ -0,0 +1,588 @@
+/*
+ * Copyright (C) 2014 Imagination Technologies Ltd.
+ *
+ * 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; version 2 of the License.
+ *
+ * Notes:
+ * 1. Erase and program operations need to call write_enable() first,
+ *to clear the enable bit. This bit is cleared automatically after
+ *the erase or program operation.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Registers common to all devices */
+#define SPI_NAND_LOCK_REG  0xa0
+#define SPI_NAND_PROT_UNLOCK_ALL   0x0
+
+#define SPI_NAND_FEATURE_REG   0xb0
+#define SPI_NAND_ECC_ENBIT(4)
+#define SPI_NAND_QUAD_EN   BIT(0)
+
+#define SPI_NAND_STATUS_REG0xc0
+#define SPI_NAND_STATUS_REG_ECC_MASK   0x3
+#define SPI_NAND_STATUS_REG_ECC_SHIFT  4
+#define SPI_NAND_STATUS_REG_PROG_FAIL  BIT(3)
+#define SPI_NAND_STATUS_REG_ERASE_FAIL BIT(2)
+#define SPI_NAND_STATUS_REG_WREN   BIT(1)
+#define SPI_NAND_STATUS_REG_BUSY   BIT(0)
+
+#define SPI_NAND_CMD_BUF_LEN   8
+
+/* Rewind and fill the buffer with 0xff */
+static void spi_nand_clear_buffer(struct spi_nand *snand)
+{
+   snand->buf_start = 0;
+   memset(snand->data_buf, 0xff, snand->buf_size);
+}
+
+static int spi_nand_enable_ecc(struct spi_na

[LEDE-DEV] [PATCHv2 2/4] kernel/4.4: mtdsplit: add kernel cmdline to disable split parsers for rootfs and firmware partitions

2017-09-02 Thread hackpascal
From: Weijie Gao 

Some firmware have already defined rootfs/rootfs_data partitions and do not 
need extra split operations.

This patch adds two kernel cmdline parameters to disable firmware and rootfs 
parsers separately:
  nofwsplit
  norootfssplit

Signed-off-by: Weijie Gao 
---
 ...d-kernel-cmdline-to-disable-split-parsers.patch | 56 ++
 1 file changed, 56 insertions(+)
 create mode 100644 
target/linux/generic/pending-4.4/405-mtd-add-kernel-cmdline-to-disable-split-parsers.patch

diff --git 
a/target/linux/generic/pending-4.4/405-mtd-add-kernel-cmdline-to-disable-split-parsers.patch
 
b/target/linux/generic/pending-4.4/405-mtd-add-kernel-cmdline-to-disable-split-parsers.patch
new file mode 100644
index 00..b0a666a401
--- /dev/null
+++ 
b/target/linux/generic/pending-4.4/405-mtd-add-kernel-cmdline-to-disable-split-parsers.patch
@@ -0,0 +1,56 @@
+--- a/drivers/mtd/mtdpart.c
 b/drivers/mtd/mtdpart.c
+@@ -39,6 +39,10 @@
+ 
+ #define MTD_ERASE_PARTIAL 0x8000 /* partition only covers parts of an 
erase block */
+ 
++/* Do not split firmware/rootfs partition */
++static bool no_fw_split_flag = 0;
++static bool no_rootfs_split_flag = 0;
++
+ /* Our partition linked list */
+ static LIST_HEAD(mtd_partitions);
+ static DEFINE_MUTEX(mtd_partitions_mutex);
+@@ -774,6 +778,9 @@ mtd_pad_erasesize(struct mtd_info *mtd,
+ 
+ static void split_firmware(struct mtd_info *master, struct mtd_part *part)
+ {
++  if (no_fw_split_flag)
++  return;
++
+   run_parsers_by_type(part, MTD_PARSER_TYPE_FIRMWARE);
+ }
+ 
+@@ -790,7 +797,8 @@ static void mtd_partition_split(struct m
+   return;
+ 
+   if (!strcmp(part->mtd.name, "rootfs")) {
+-  run_parsers_by_type(part, MTD_PARSER_TYPE_ROOTFS);
++  if (!no_rootfs_split_flag)
++  run_parsers_by_type(part, MTD_PARSER_TYPE_ROOTFS);
+ 
+   rootfs_found = 1;
+   }
+@@ -1092,3 +1100,22 @@ uint64_t mtd_get_device_size(const struc
+   return PART(mtd)->master->size;
+ }
+ EXPORT_SYMBOL_GPL(mtd_get_device_size);
++
++
++static int __init no_fw_split(char *str)
++{
++  no_fw_split_flag = 1;
++
++  return 0;
++}
++
++early_param("nofwsplit", no_fw_split);
++
++static int __init no_rootfs_split(char *str)
++{
++  no_rootfs_split_flag = 1;
++
++  return 0;
++}
++
++early_param("norootfssplit", no_rootfs_split);
-- 
2.11.0


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


[LEDE-DEV] [PATCHv2 1/4] mac80211: enable use of GPI9 of ath9k

2017-09-02 Thread hackpascal
From: Weijie Gao 

GPI9 (input-only pin) is used by Netgear WNDR4500v3 as the wireless button,
but not enabled in ath9k.

This patch enables the pin by adding corresponding bit in the usable gpio
masks.

Signed-off-by: Weijie Gao 
---
 .../552-ath9k-enable-use-of-wmac-gpi9.patch| 22 ++
 1 file changed, 22 insertions(+)
 create mode 100644 
package/kernel/mac80211/patches/552-ath9k-enable-use-of-wmac-gpi9.patch

diff --git 
a/package/kernel/mac80211/patches/552-ath9k-enable-use-of-wmac-gpi9.patch 
b/package/kernel/mac80211/patches/552-ath9k-enable-use-of-wmac-gpi9.patch
new file mode 100644
index 00..b64006a202
--- /dev/null
+++ b/package/kernel/mac80211/patches/552-ath9k-enable-use-of-wmac-gpi9.patch
@@ -0,0 +1,22 @@
+--- a/drivers/net/wireless/ath/ath9k/reg.h
 b/drivers/net/wireless/ath/ath9k/reg.h
+@@ -1136,8 +1136,8 @@ enum {
+ #define AR9280_GPIO_MASK   0x03FF
+ #define AR9285_GPIO_MASK   0x0FFF
+ #define AR9287_GPIO_MASK   0x03FF
+-#define AR9300_GPIO_MASK   0xF4FF
+-#define AR9330_GPIO_MASK   0xF4FF
++#define AR9300_GPIO_MASK   0xF6FF
++#define AR9330_GPIO_MASK   0xF6FF
+ #define AR9340_GPIO_MASK   0x000F
+ #define AR9462_GPIO_MASK   0x3FFF
+ #define AR9485_GPIO_MASK   0x0FFF
+@@ -1145,7 +1145,7 @@ enum {
+ #define AR9550_GPIO_MASK   0x000F
+ #define AR9561_GPIO_MASK   0x000F
+ #define AR9565_GPIO_MASK   0x3FFF
+-#define AR9580_GPIO_MASK   0xF4FF
++#define AR9580_GPIO_MASK   0xF6FF
+ #define AR7010_GPIO_MASK   0x
+ 
+ #define AR_GPIO_IN_OUT   (AR_SREV_9340(ah) ? 0x4028 : 
0x4048)
-- 
2.11.0


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


[LEDE-DEV] [PATCHv2 4/4] ar71xx: add netgear wndr4500v3 support

2017-09-02 Thread hackpascal
From: Weijie Gao 

Netgear WNDR4500v3 uses one SPI-NOR and one SPI-NAND. The bootloader and
caldata are on the SPI-NOR flash, and the firmware is on the SPI-NAND flash.

Hardware specification:
CPU: QCA9563
Switch: QCA8337N
5.8GHz Wifi: AR9580
SPI-NOR: 2MB
SPI-NAND: 128MB
DDR2: 128MB

WNDR4300v2 is similar to WNDR4500v3 but not tested and not included here.

Signed-off-by: Weijie Gao 
---
 target/linux/ar71xx/base-files/etc/board.d/01_leds |   6 +
 .../linux/ar71xx/base-files/etc/board.d/02_network |   1 +
 target/linux/ar71xx/base-files/etc/diag.sh |   1 +
 target/linux/ar71xx/base-files/lib/ar71xx.sh   |   3 +
 .../ar71xx/base-files/lib/upgrade/platform.sh  |   3 +-
 .../ar71xx/files/arch/mips/ath79/Kconfig.openwrt   |  11 +
 target/linux/ar71xx/files/arch/mips/ath79/Makefile |   1 +
 .../files/arch/mips/ath79/mach-wndr4500-v3.c   | 233 +
 .../linux/ar71xx/files/arch/mips/ath79/machtypes.h |   1 +
 target/linux/ar71xx/image/legacy.mk|   2 +
 target/linux/ar71xx/image/nand.mk  |   6 +
 target/linux/ar71xx/nand/config-default|   3 +
 12 files changed, 270 insertions(+), 1 deletion(-)
 create mode 100644 target/linux/ar71xx/files/arch/mips/ath79/mach-wndr4500-v3.c

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 84b1a7dfd9..b4ebbd6173 100755
--- a/target/linux/ar71xx/base-files/etc/board.d/01_leds
+++ b/target/linux/ar71xx/base-files/etc/board.d/01_leds
@@ -828,6 +828,12 @@ wndr4300)
ucidef_set_led_wlan "wlan2g" "WLAN2G" "netgear:green:wlan2g" "phy0tpt"
ucidef_set_led_wlan "wlan5g" "WLAN5G" "netgear:blue:wlan5g" "phy1tpt"
;;
+wndr4500-v3)
+   ucidef_set_led_netdev "wan" "WAN (green)" "netgear:green:wan" "eth0.2"
+   ucidef_set_led_usbdev "usb1" "USB1" "netgear:green:usb1" "1-1"
+   ucidef_set_led_usbdev "usb2" "USB2" "netgear:green:usb2" "2-1"
+   ucidef_set_led_wlan "wlan2g" "WLAN2G" "netgear:green:wlan2g" "phy0tpt"
+   ;;
 whr-g301n|\
 whr-hp-g300n|\
 whr-hp-gn)
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 ba54d89b8f..d455afad69 100755
--- a/target/linux/ar71xx/base-files/etc/board.d/02_network
+++ b/target/linux/ar71xx/base-files/etc/board.d/02_network
@@ -262,6 +262,7 @@ ar71xx_setup_interfaces()
ucidef_add_switch "switch0" \
"0@eth0" "1:lan:1" "2:lan:4" "3:lan:3" "4:lan:2"
;;
+   wndr4500-v3|\
cr5000|\
dgl-5500-a1|\
dhp-1565-a1|\
diff --git a/target/linux/ar71xx/base-files/etc/diag.sh 
b/target/linux/ar71xx/base-files/etc/diag.sh
index 7753a7156d..6a392e790a 100644
--- a/target/linux/ar71xx/base-files/etc/diag.sh
+++ b/target/linux/ar71xx/base-files/etc/diag.sh
@@ -471,6 +471,7 @@ get_status_led() {
wndr3700|\
wndr3700v4|\
wndr4300|\
+   wndr4500-v3|\
wnr2000|\
wnr2000-v3|\
wnr2200|\
diff --git a/target/linux/ar71xx/base-files/lib/ar71xx.sh 
b/target/linux/ar71xx/base-files/lib/ar71xx.sh
index 7fd5fb4522..e44fa0d09a 100755
--- a/target/linux/ar71xx/base-files/lib/ar71xx.sh
+++ b/target/linux/ar71xx/base-files/lib/ar71xx.sh
@@ -1249,6 +1249,9 @@ ar71xx_board_detect() {
*"WNDR4300")
name="wndr4300"
;;
+   *"WNDR4500v3")
+   name="wndr4500-v3"
+   ;;
*"WNR1000 V2")
name="wnr1000-v2"
;;
diff --git a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh 
b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
index 05b5634aa5..12e920f46d 100755
--- a/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
+++ b/target/linux/ar71xx/base-files/lib/upgrade/platform.sh
@@ -533,7 +533,8 @@ platform_check_image() {
r6100|\
rambutan|\
wndr3700v4|\
-   wndr4300)
+   wndr4300|\
+   wndr4500-v3)
nand_do_platform_check $board $1
return $?
;;
diff --git a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt 
b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
index ff9c3037a1..68fdd4db66 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
+++ b/target/linux/ar71xx/files/arch/mips/ath79/Kconfig.openwrt
@@ -1061,6 +1061,17 @@ config ATH79_MACH_WNDR4300
select ATH79_DEV_USB
select ATH79_DEV_WMAC
 
+config ATH79_MACH_WNDR4500_V3
+   bool "NETGEAR WNDR4300v2/WNDR4500v3 board support"
+   select SOC_QCA956X
+   select ATH79_DEV_AP9X_PCI if PCI
+   select ATH79_DEV_ETH
+   select ATH79_DEV_GPIO_BUTTONS
+   select ATH79_DEV_LEDS_GPIO
+   select ATH79_DEV_USB
+   select ATH79_DEV_M25P80
+   select ATH79_DEV_WMAC
+
 config ATH79_MACH_WNR2000
bool "NETGEAR WNR2000 board support"
select SOC_AR913X
diff --git a/target/linux/ar7

[LEDE-DEV] [PATCHv2 3/4] kernel/4.4: add generic spi-nand framework

2017-09-02 Thread hackpascal
From: Weijie Gao 

This patch adds generic SPI-NAND framework for linux-4.4.

Files come from patches of target pistachio, but have lots of modifications
to add full support for GD5F series.

Signed-off-by: Weijie Gao 
---
 target/linux/generic/config-4.4|   2 +
 .../generic/files/drivers/mtd/spi-nand/Kconfig |  17 +
 .../generic/files/drivers/mtd/spi-nand/Makefile|   2 +
 .../files/drivers/mtd/spi-nand/spi-nand-base.c | 588 
 .../files/drivers/mtd/spi-nand/spi-nand-device.c   | 761 +
 .../generic/files/include/linux/mtd/spi-nand.h |  56 ++
 ...length-of-ID-before-reading-bits-per-cell.patch |  33 +
 ...-Add-JEDEC-manufacturer-ID-for-Gigadevice.patch |  35 +
 .../454-mtd-Introduce-SPI-NAND-framework.patch |  20 +
 9 files changed, 1514 insertions(+)
 create mode 100644 target/linux/generic/files/drivers/mtd/spi-nand/Kconfig
 create mode 100644 target/linux/generic/files/drivers/mtd/spi-nand/Makefile
 create mode 100644 
target/linux/generic/files/drivers/mtd/spi-nand/spi-nand-base.c
 create mode 100644 
target/linux/generic/files/drivers/mtd/spi-nand/spi-nand-device.c
 create mode 100644 target/linux/generic/files/include/linux/mtd/spi-nand.h
 create mode 100644 
target/linux/generic/pending-4.4/452-mtd-nand-Check-length-of-ID-before-reading-bits-per-cell.patch
 create mode 100644 
target/linux/generic/pending-4.4/453-mtd-nand-Add-JEDEC-manufacturer-ID-for-Gigadevice.patch
 create mode 100644 
target/linux/generic/pending-4.4/454-mtd-Introduce-SPI-NAND-framework.patch

diff --git a/target/linux/generic/config-4.4 b/target/linux/generic/config-4.4
index 1c0af9597f..0fd7c1d49c 100644
--- a/target/linux/generic/config-4.4
+++ b/target/linux/generic/config-4.4
@@ -2369,6 +2369,8 @@ CONFIG_MTD_ROOTFS_ROOT_DEV=y
 # CONFIG_MTD_SLRAM is not set
 # CONFIG_MTD_SM_COMMON is not set
 # CONFIG_MTD_SPINAND_MT29F is not set
+# CONFIG_MTD_SPI_NAND is not set
+# CONFIG_MTD_SPI_NAND_DEVICES is not set
 # CONFIG_MTD_SPI_NOR is not set
 # CONFIG_MTD_SPI_NOR_USE_4K_SECTORS is not set
 CONFIG_MTD_SPLIT=y
diff --git a/target/linux/generic/files/drivers/mtd/spi-nand/Kconfig 
b/target/linux/generic/files/drivers/mtd/spi-nand/Kconfig
new file mode 100644
index 00..ab6bb6c7fa
--- /dev/null
+++ b/target/linux/generic/files/drivers/mtd/spi-nand/Kconfig
@@ -0,0 +1,17 @@
+menuconfig MTD_SPI_NAND
+   tristate "SPI NAND device support"
+   depends on MTD
+   select MTD_NAND
+   help
+ This is the framework for the SPI NAND.
+
+if MTD_SPI_NAND
+
+config MTD_SPI_NAND_DEVICES
+   tristate "Support for SPI NAND devices"
+   default y
+   depends on MTD_SPI_NAND
+   help
+ Select this option if you require support for SPI NAND devices.
+
+endif # MTD_SPI_NAND
diff --git a/target/linux/generic/files/drivers/mtd/spi-nand/Makefile 
b/target/linux/generic/files/drivers/mtd/spi-nand/Makefile
new file mode 100644
index 00..6e460d1814
--- /dev/null
+++ b/target/linux/generic/files/drivers/mtd/spi-nand/Makefile
@@ -0,0 +1,2 @@
+obj-$(CONFIG_MTD_SPI_NAND) += spi-nand-base.o
+obj-$(CONFIG_MTD_SPI_NAND_DEVICES) += spi-nand-device.o
diff --git a/target/linux/generic/files/drivers/mtd/spi-nand/spi-nand-base.c 
b/target/linux/generic/files/drivers/mtd/spi-nand/spi-nand-base.c
new file mode 100644
index 00..07dad5397a
--- /dev/null
+++ b/target/linux/generic/files/drivers/mtd/spi-nand/spi-nand-base.c
@@ -0,0 +1,588 @@
+/*
+ * Copyright (C) 2014 Imagination Technologies Ltd.
+ *
+ * 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; version 2 of the License.
+ *
+ * Notes:
+ * 1. Erase and program operations need to call write_enable() first,
+ *to clear the enable bit. This bit is cleared automatically after
+ *the erase or program operation.
+ *
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/* Registers common to all devices */
+#define SPI_NAND_LOCK_REG  0xa0
+#define SPI_NAND_PROT_UNLOCK_ALL   0x0
+
+#define SPI_NAND_FEATURE_REG   0xb0
+#define SPI_NAND_ECC_ENBIT(4)
+#define SPI_NAND_QUAD_EN   BIT(0)
+
+#define SPI_NAND_STATUS_REG0xc0
+#define SPI_NAND_STATUS_REG_ECC_MASK   0x3
+#define SPI_NAND_STATUS_REG_ECC_SHIFT  4
+#define SPI_NAND_STATUS_REG_PROG_FAIL  BIT(3)
+#define SPI_NAND_STATUS_REG_ERASE_FAIL BIT(2)
+#define SPI_NAND_STATUS_REG_WREN   BIT(1)
+#define SPI_NAND_STATUS_REG_BUSY   BIT(0)
+
+#define SPI_NAND_CMD_BUF_LEN   8
+
+/* Rewind and fill the buffer with 0xff */
+static void spi_nand_clear_buffer(struct spi_nand *snand)
+{
+   snand->buf_start = 0;
+   memset(snand->data_buf, 0xff, snand->buf_size);
+}
+
+static int spi_nand_enable_ecc(struct spi_nand *snand)
+{
+   in

[LEDE-DEV] [PATCH] ar71xx: fix gmac0 speed function for qca956x

2017-02-17 Thread hackpascal
From: Weijie Gao 

This patch fixed the problem that kernel will crash when WAN port is
linked-up in QCA9561.

When GMAC0 is configured as GMII, it's connected to the internal switch.
In this situation, there's no need to adjust the speed of GMAC0, and the
function ath79_set_speed_dummy should be used.

Prevoiusly this function was incorrectly set to ath79_set_speed_ge0,
which is used for AR71XX/AR91XX. If WAN port is linked-up, this function
will crash the kernel due to incorrect register access.

Signed-off-by: Weijie Gao 
---
 target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c 
b/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c
index a8b19b6..793323d 100644
--- a/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c
+++ b/target/linux/ar71xx/files/arch/mips/ath79/dev-eth.c
@@ -1096,7 +1096,7 @@ void __init ath79_register_eth(unsigned int id)
if (pdata->phy_if_mode == PHY_INTERFACE_MODE_SGMII)
pdata->set_speed = qca956x_set_speed_sgmii;
else
-   pdata->set_speed = ar934x_set_speed_ge0;
+   pdata->set_speed = ath79_set_speed_dummy;
} else {
pdata->reset_bit = QCA955X_RESET_GE1_MAC |
   QCA955X_RESET_GE1_MDIO;
-- 
2.5.0


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