From 4e46ae1f69b5ff1cf09b2e2eee69a7c38a00202d Mon Sep 17 00:00:00 2001 From: Pawel Dembicki Date: Sun, 30 Aug 2020 22:26:14 +0200 Subject: kirkwood: add support for NETGEAR ReadyNAS Duo v2 NETGEAR ReadyNAS Duo v2 is a NAS based on Marvell kirkwood SoC. Specification: - Processor Marvell 88F6282 (1.6 GHz) - 256MB RAM - 128MB NAND - 1x GBE LAN port (PHY: Marvell 88E1318) - 1x USB 2.0 - 2x USB 3.0 - 2x SATA - 3x button - 5x leds - serial on J5 connector accessible from rear panel (115200 8N1) (VCC,TX,RX,GND) (3V3 LOGIC!) Installation by USB + serial: - Copy initramfs image to fat32 usb drive - Connect pendrive to USB 2.0 front socket - Connect serial console - Stop booting in u-boot - Do: usb reset setenv bootargs 'console=ttyS0,115200n8 earlyprintk' setenv bootcmd 'nand read.e 0x1200000 0x200000 0x600000;bootm 0x1200000' saveenv fatload usb 0:1 0x1200000 openwrt-kirkwood-netgear_readynas-duo-v2-initramfs-uImage bootm 0x1200000 - copy sysupgrade image via ssh. - run sysupgrade Installation by TFTP + serial: - Setup TFTP server and copy initramfs image - Connect serial console - Stop booting in u-boot - Do: setenv bootargs 'console=ttyS0,115200n8 earlyprintk' setenv bootcmd 'nand read.e 0x1200000 0x200000 0x600000;bootm 0x1200000' saveenv setenv serverip 192.168.1.1 setenv ipaddr 192.168.1.2 tftpboot 0x1200000 openwrt-kirkwood-netgear_readynas-duo-v2-initramfs-uImage bootm 0x1200000 - copy sysupgrade image via ssh. - run sysupgrade Known issues: - Power button and PHY INTn pin are connected to the same GPIO. It causes that every network restart button is pressed in system. As workaround, button is used as regular BTN_1. For more info please look at file: RND_5.3.13_WW.src/u-boot/board/mv_feroceon/mv_hal/usibootup/usibootup.c from Netgear GPL sources. Tested-by: Raylynn Knight Tested-by: Lech Perczak Signed-off-by: Pawel Dembicki --- ...-linkstation-poweroff-prepare-for-new-dev.patch | 106 +++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 target/linux/kirkwood/patches-5.4/800-power-reset-linkstation-poweroff-prepare-for-new-dev.patch (limited to 'target/linux/kirkwood/patches-5.4/800-power-reset-linkstation-poweroff-prepare-for-new-dev.patch') diff --git a/target/linux/kirkwood/patches-5.4/800-power-reset-linkstation-poweroff-prepare-for-new-dev.patch b/target/linux/kirkwood/patches-5.4/800-power-reset-linkstation-poweroff-prepare-for-new-dev.patch new file mode 100644 index 0000000000..03253cfe83 --- /dev/null +++ b/target/linux/kirkwood/patches-5.4/800-power-reset-linkstation-poweroff-prepare-for-new-dev.patch @@ -0,0 +1,106 @@ +From 11cab9f5cd9390cd83747e579957c8f5b807c09c Mon Sep 17 00:00:00 2001 +From: Pawel Dembicki +Date: Fri, 18 Jun 2021 12:37:27 +0200 +Subject: [PATCH 1/2] power: reset: linkstation-poweroff: prepare for new + devices + +This commit prepare driver for another device support. + +New power_off_cfg structure describes two most important things: name of +mdio bus and pointer to register setting function. It allow to add new +device with different mdio bus node and other phy register config. + +Signed-off-by: Pawel Dembicki +--- + drivers/power/reset/linkstation-poweroff.c | 35 ++++++++++++++++++---- + 1 file changed, 29 insertions(+), 6 deletions(-) + +diff --git a/drivers/power/reset/linkstation-poweroff.c b/drivers/power/reset/linkstation-poweroff.c +index f1e843df0e16..8691cf98600d 100644 +--- a/drivers/power/reset/linkstation-poweroff.c ++++ b/drivers/power/reset/linkstation-poweroff.c +@@ -29,11 +29,21 @@ + #define LED2_FORCE_ON (0x8 << 8) + #define LEDMASK GENMASK(11,8) + ++struct power_off_cfg { ++ char *mdio_node_name; ++ void (*phy_set_reg)(bool restart); ++}; ++ + static struct phy_device *phydev; ++static const struct power_off_cfg *cfg; + +-static void mvphy_reg_intn(u16 data) ++static void linkstation_mvphy_reg_intn(bool restart) + { + int rc = 0, saved_page; ++ u16 data = 0; ++ ++ if(restart) ++ data = MII_88E1318S_PHY_LED_TCR_FORCE_INT; + + saved_page = phy_select_page(phydev, MII_MARVELL_LED_PAGE); + if (saved_page < 0) +@@ -66,11 +76,16 @@ static void mvphy_reg_intn(u16 data) + dev_err(&phydev->mdio.dev, "Write register failed, %d\n", rc); + } + ++static const struct power_off_cfg linkstation_power_off_cfg = { ++ .mdio_node_name = "mdio", ++ .phy_set_reg = linkstation_mvphy_reg_intn, ++}; ++ + static int linkstation_reboot_notifier(struct notifier_block *nb, + unsigned long action, void *unused) + { + if (action == SYS_RESTART) +- mvphy_reg_intn(MII_88E1318S_PHY_LED_TCR_FORCE_INT); ++ cfg->phy_set_reg(true); + + return NOTIFY_DONE; + } +@@ -82,14 +97,18 @@ static struct notifier_block linkstation_reboot_nb = { + static void linkstation_poweroff(void) + { + unregister_reboot_notifier(&linkstation_reboot_nb); +- mvphy_reg_intn(0); ++ cfg->phy_set_reg(false); + + kernel_restart("Power off"); + } + + static const struct of_device_id ls_poweroff_of_match[] = { +- { .compatible = "buffalo,ls421d" }, +- { .compatible = "buffalo,ls421de" }, ++ { .compatible = "buffalo,ls421d", ++ .data = &linkstation_power_off_cfg, ++ }, ++ { .compatible = "buffalo,ls421de", ++ .data = &linkstation_power_off_cfg, ++ }, + { }, + }; + +@@ -97,13 +116,17 @@ static int __init linkstation_poweroff_init(void) + { + struct mii_bus *bus; + struct device_node *dn; ++ const struct of_device_id *match; + + dn = of_find_matching_node(NULL, ls_poweroff_of_match); + if (!dn) + return -ENODEV; + of_node_put(dn); + +- dn = of_find_node_by_name(NULL, "mdio"); ++ match = of_match_node(ls_poweroff_of_match, dn); ++ cfg = match->data; ++ ++ dn = of_find_node_by_name(NULL, cfg->mdio_node_name); + if (!dn) + return -ENODEV; + +-- +2.25.1 + -- cgit v1.2.3