Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Netgear WNR3500L v2 #4874

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -1,6 +1,6 @@
--- broadcom-wl-5.10.56.27.3/driver/wl_linux.c.orig 2018-01-13 18:25:14.944667645 +0100
+++ broadcom-wl-5.10.56.27.3/driver/wl_linux.c 2018-01-13 18:25:25.836667888 +0100
@@ -2762,7 +2762,6 @@
--- a/driver/wl_linux.c
+++ b/driver/wl_linux.c
@@ -2762,7 +2762,6 @@ wl_monitor(wl_info_t *wl, wl_rxsts_t *rx
bcopy(oskb->data + D11_PHY_HDR_LEN, pdata, oskb->len - D11_PHY_HDR_LEN);

skb->dev = wl->monitor;
Expand Down
@@ -1,6 +1,6 @@
--- a/driver/wl_linux.c
+++ b/driver/wl_linux.c
@@ -235,7 +235,11 @@
@@ -235,7 +235,11 @@ struct wl_info {

};

Expand All @@ -12,7 +12,7 @@
static void _wl_timer(wl_timer_t *t);

#ifdef WLC_HIGH_ONLY
@@ -2512,6 +2517,18 @@
@@ -2512,6 +2516,18 @@ wl_timer_task(wl_task_t *task)
}
#endif /* WLC_HIGH_ONLY */

Expand All @@ -31,15 +31,15 @@
static void
wl_timer(ulong data)
{
@@ -2522,6 +2539,7 @@
@@ -2522,6 +2538,7 @@ wl_timer(ulong data)
wl_schedule_task(t->wl, wl_timer_task, t);
#endif /* WLC_HIGH_ONLY */
}
+#endif /* linux >= 4.15.0 */

static void
_wl_timer(wl_timer_t *t)
@@ -2573,9 +2591,13 @@
@@ -2573,9 +2590,13 @@ wl_init_timer(wl_info_t *wl, void (*fn)(

bzero(t, sizeof(wl_timer_t));

Expand Down
@@ -1,6 +1,6 @@
--- a/driver/wl_iw.c
+++ b/driver/wl_iw.c
@@ -112,10 +112,14 @@
@@ -112,10 +112,14 @@ dev_wlc_ioctl(
ifr.ifr_data = (caddr_t) &ioc;

/* Must be up for virtually all useful ioctls */
Expand Down
@@ -0,0 +1,42 @@
Index: broadcom-wl-5.10.56.27.3/driver/wl_linux.c
===================================================================
--- broadcom-wl-5.10.56.27.3.orig/driver/wl_linux.c
+++ broadcom-wl-5.10.56.27.3/driver/wl_linux.c
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please run:

make package/broadcom-wl/{clean,refresh}

@@ -74,6 +74,10 @@
#error "No support for Kernel Rev <= 2.4.5, As the older kernel revs doesn't support Tasklets"
#endif

+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
+#define ioremap_nocache ioremap
+#endif
+
typedef void wlc_info_t;
typedef void wlc_hw_info_t;
#include <wlc_pub.h>
@@ -1915,7 +1919,11 @@ wl_ioctl(struct net_device *dev, struct
}

/* optimization for direct ioctl calls from kernel */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 9, 0)
if (segment_eq(get_fs(), KERNEL_DS))
+#else
+ if (uaccess_kernel())
+#endif
buf = ioc.buf;

else if (ioc.buf) {
Index: broadcom-wl-5.10.56.27.3/driver/linux_osl.c
===================================================================
--- broadcom-wl-5.10.56.27.3.orig/driver/linux_osl.c
+++ broadcom-wl-5.10.56.27.3/driver/linux_osl.c
@@ -34,6 +34,10 @@
#define OS_HANDLE_MAGIC 0x1234abcd /* Magic # to recognise osh */
#define BCM_MEM_FILENAME_LEN 24 /* Mem. filename length */

+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
+#define ioremap_nocache ioremap
+#endif
+
typedef struct bcm_mem_link {
struct bcm_mem_link *prev;
struct bcm_mem_link *next;
3 changes: 2 additions & 1 deletion target/linux/bcm47xx/base-files/etc/board.d/01_network
Expand Up @@ -172,7 +172,8 @@ configure_by_model() {
"Linksys E3000 V1" | \
"Linksys WRT610N V2" | \
"Netgear WNR3500 V2" | \
"Netgear WNR3500L")
"Netgear WNR3500L" | \
"Netgear WNR3500L V2")
ucidef_add_switch "switch0" \
"0:wan" "1:lan:4" "2:lan:3" "3:lan:2" "4:lan:1" "8@eth0"
;;
Expand Down
5 changes: 4 additions & 1 deletion target/linux/bcm47xx/config-5.10
Expand Up @@ -147,8 +147,11 @@ CONFIG_MIPS_L1_CACHE_SHIFT=5
CONFIG_MODULES_USE_ELF_REL=y
CONFIG_MTD_BCM47XXSFLASH=y
CONFIG_MTD_BCM47XX_PARTS=y
CONFIG_MTD_NAND=y
CONFIG_MTD_NAND_CORE=y
CONFIG_MTD_RAW_NAND=y
CONFIG_MTD_NAND_BCM47XXNFLASH=y
CONFIG_MTD_NAND_BRCMNAND=y
CONFIG_MTD_NAND_BRCMNAND_BCMA=y
CONFIG_MTD_NAND_ECC=y
CONFIG_MTD_PARSER_TRX=y
CONFIG_MTD_PHYSMAP=y
Expand Down
2 changes: 2 additions & 0 deletions target/linux/bcm47xx/image/mips74k.mk
Expand Up @@ -460,6 +460,8 @@ define Device/netgear_wnr3500l-v2
$(Device/netgear)
NETGEAR_BOARD_ID := U12H172T00_NETGEAR
NETGEAR_REGION := 1
KERNEL_NAME = vmlinux-nodictionary.lzma
IMAGE/chk := append-rootfs | trx-without-loader | netgear-chk
endef
TARGET_DEVICES += netgear_wnr3500l-v2

Expand Down
@@ -0,0 +1,111 @@
From a126431d8647ae3bbdc4efe854494aaa2b09eb2b Mon Sep 17 00:00:00 2001
From: Florian Fainelli <f.fainelli@gmail.com>
Date: Mon, 13 Dec 2021 15:57:14 -0800
Subject: [PATCH 100/108] mtd: rawnand: brcmnand: Allow SoC to provide I/O
operations

Allow a brcmnand_soc instance to provide a custom set of I/O operations
which we will require when using this driver on a BCMA bus which is not
directly memory mapped I/O. Update the nand_{read,write}_reg accordingly
to use the SoC operations if provided.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
drivers/mtd/nand/raw/brcmnand/brcmnand.c | 14 ++++++++++++--
drivers/mtd/nand/raw/brcmnand/brcmnand.h | 23 +++++++++++++++++++++++
2 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
index f75929783b94..7a1673b1b1af 100644
--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
+++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
@@ -594,13 +594,18 @@ enum {

static inline u32 nand_readreg(struct brcmnand_controller *ctrl, u32 offs)
{
+ if (brcmnand_soc_has_ops(ctrl->soc))
+ return brcmnand_soc_read(ctrl->soc, offs);
return brcmnand_readl(ctrl->nand_base + offs);
}

static inline void nand_writereg(struct brcmnand_controller *ctrl, u32 offs,
u32 val)
{
- brcmnand_writel(val, ctrl->nand_base + offs);
+ if (brcmnand_soc_has_ops(ctrl->soc))
+ brcmnand_soc_write(ctrl->soc, val, offs);
+ else
+ brcmnand_writel(val, ctrl->nand_base + offs);
}

static int brcmnand_revision_init(struct brcmnand_controller *ctrl)
@@ -766,13 +771,18 @@ static inline void brcmnand_rmw_reg(struct brcmnand_controller *ctrl,

static inline u32 brcmnand_read_fc(struct brcmnand_controller *ctrl, int word)
{
+ if (brcmnand_soc_has_ops(ctrl->soc))
+ return brcmnand_soc_read(ctrl->soc, ~0);
return __raw_readl(ctrl->nand_fc + word * 4);
}

static inline void brcmnand_write_fc(struct brcmnand_controller *ctrl,
int word, u32 val)
{
- __raw_writel(val, ctrl->nand_fc + word * 4);
+ if (brcmnand_soc_has_ops(ctrl->soc))
+ brcmnand_soc_write(ctrl->soc, val, ~0);
+ else
+ __raw_writel(val, ctrl->nand_fc + word * 4);
}

static inline void edu_writel(struct brcmnand_controller *ctrl,
diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.h b/drivers/mtd/nand/raw/brcmnand/brcmnand.h
index eb498fbe505e..a3f2ad5f6572 100644
--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.h
+++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.h
@@ -11,12 +11,19 @@

struct platform_device;
struct dev_pm_ops;
+struct brcmnand_io_ops;

struct brcmnand_soc {
bool (*ctlrdy_ack)(struct brcmnand_soc *soc);
void (*ctlrdy_set_enabled)(struct brcmnand_soc *soc, bool en);
void (*prepare_data_bus)(struct brcmnand_soc *soc, bool prepare,
bool is_param);
+ const struct brcmnand_io_ops *ops;
+};
+
+struct brcmnand_io_ops {
+ u32 (*read_reg)(struct brcmnand_soc *soc, u32 offset);
+ void (*write_reg)(struct brcmnand_soc *soc, u32 val, u32 offset);
};

static inline void brcmnand_soc_data_bus_prepare(struct brcmnand_soc *soc,
@@ -58,6 +65,22 @@ static inline void brcmnand_writel(u32 val, void __iomem *addr)
writel_relaxed(val, addr);
}

+static inline bool brcmnand_soc_has_ops(struct brcmnand_soc *soc)
+{
+ return soc && soc->ops && soc->ops->read_reg && soc->ops->write_reg;
+}
+
+static inline u32 brcmnand_soc_read(struct brcmnand_soc *soc, u32 offset)
+{
+ return soc->ops->read_reg(soc, offset);
+}
+
+static inline void brcmnand_soc_write(struct brcmnand_soc *soc, u32 val,
+ u32 offset)
+{
+ soc->ops->write_reg(soc, val, offset);
+}
+
int brcmnand_probe(struct platform_device *pdev, struct brcmnand_soc *soc);
int brcmnand_remove(struct platform_device *pdev);

--
2.25.1

@@ -0,0 +1,39 @@
From 6e3c0ce00126e4ae9eddb6c6f57de67ccf3e683b Mon Sep 17 00:00:00 2001
From: Florian Fainelli <f.fainelli@gmail.com>
Date: Tue, 14 Dec 2021 15:11:15 -0800
Subject: [PATCH 101/108] mtd: rawnand: brcmnand: Assign soc as early as
possible

In order to key off the brcmnand_probe() code in subsequent changes
depending upon ctlr->soc, assign that variable as early as possible,
instead of much later when we have checked that it is non-NULL.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
drivers/mtd/nand/raw/brcmnand/brcmnand.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
index 7a1673b1b1af..fcea5a7443e8 100644
--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
+++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
@@ -3008,6 +3008,7 @@ int brcmnand_probe(struct platform_device *pdev, struct brcmnand_soc *soc)

dev_set_drvdata(dev, ctrl);
ctrl->dev = dev;
+ ctrl->soc = soc;

init_completion(&ctrl->done);
init_completion(&ctrl->dma_done);
@@ -3148,8 +3149,6 @@ int brcmnand_probe(struct platform_device *pdev, struct brcmnand_soc *soc)
* interesting ways
*/
if (soc) {
- ctrl->soc = soc;
-
ret = devm_request_irq(dev, ctrl->irq, brcmnand_irq, 0,
DRV_NAME, ctrl);

--
2.25.1

@@ -0,0 +1,58 @@
From bc512bc38c4fe4ff8f47bd9de20b367f85238548 Mon Sep 17 00:00:00 2001
From: Florian Fainelli <f.fainelli@gmail.com>
Date: Tue, 14 Dec 2021 15:45:24 -0800
Subject: [PATCH 102/108] mtd: rawnand: brcmnand: Avoid pdev in
brcmnand_init_cs()

In preparation for encapsulation more of what the loop calling
brcmnand_init_cs() does, avoid using platform_device when it is the
device behind platform_device that we are using for printing errors.

No functional change.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
---
drivers/mtd/nand/raw/brcmnand/brcmnand.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/mtd/nand/raw/brcmnand/brcmnand.c b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
index fcea5a7443e8..35f8d8e02d4a 100644
--- a/drivers/mtd/nand/raw/brcmnand/brcmnand.c
+++ b/drivers/mtd/nand/raw/brcmnand/brcmnand.c
@@ -2763,7 +2763,7 @@ static const struct nand_controller_ops brcmnand_controller_ops = {
static int brcmnand_init_cs(struct brcmnand_host *host, struct device_node *dn)
{
struct brcmnand_controller *ctrl = host->ctrl;
- struct platform_device *pdev = host->pdev;
+ struct device *dev = ctrl->dev;
struct mtd_info *mtd;
struct nand_chip *chip;
int ret;
@@ -2771,7 +2771,7 @@ static int brcmnand_init_cs(struct brcmnand_host *host, struct device_node *dn)

ret = of_property_read_u32(dn, "reg", &host->cs);
if (ret) {
- dev_err(&pdev->dev, "can't get chip-select\n");
+ dev_err(dev, "can't get chip-select\n");
return -ENXIO;
}

@@ -2780,13 +2780,13 @@ static int brcmnand_init_cs(struct brcmnand_host *host, struct device_node *dn)

nand_set_flash_node(chip, dn);
nand_set_controller_data(chip, host);
- mtd->name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "brcmnand.%d",
+ mtd->name = devm_kasprintf(dev, GFP_KERNEL, "brcmnand.%d",
host->cs);
if (!mtd->name)
return -ENOMEM;

mtd->owner = THIS_MODULE;
- mtd->dev.parent = &pdev->dev;
+ mtd->dev.parent = dev;

chip->legacy.cmd_ctrl = brcmnand_cmd_ctrl;
chip->legacy.cmdfunc = brcmnand_cmdfunc;
--
2.25.1