1 From a2d9c86df8d12646f5bf66920e4f1e6d940cfc62 Mon Sep 17 00:00:00 2001
2 From: Pawel Dembicki <paweldembicki@gmail.com>
3 Date: Fri, 18 Jun 2021 13:25:33 +0200
4 Subject: [PATCH 2/2] power: reset: linkstation-poweroff: add new device
6 This commit introduces support for NETGEAR ReadyNAS Duo v2.
7 This device use bit 4 of LED[2:0] Polarity Control Register to indicate
10 For more details about AC loss detection in NETGEAR ReadyNAS Duo v2,
11 please look at the file:
12 RND_5.3.13_WW.src/u-boot/board/mv_feroceon/mv_hal/usibootup/usibootup.c
13 from Netgear GPL sources.
15 Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
17 drivers/power/reset/linkstation-poweroff.c | 43 ++++++++++++++++++++++
18 1 file changed, 43 insertions(+)
20 --- a/drivers/power/reset/linkstation-poweroff.c
21 +++ b/drivers/power/reset/linkstation-poweroff.c
23 #define MII_MARVELL_PHY_PAGE 22
25 #define MII_PHY_LED_CTRL 16
26 +#define MII_PHY_LED_POL_CTRL 17
27 #define MII_88E1318S_PHY_LED_TCR 18
28 #define MII_88E1318S_PHY_WOL_CTRL 16
29 #define MII_M1011_IEVENT 19
31 #define LED2_FORCE_ON (0x8 << 8)
32 #define LEDMASK GENMASK(11,8)
34 +#define MII_88E1318S_PHY_LED_POL_LED2 BIT(4)
36 struct power_off_cfg {
38 void (*phy_set_reg)(bool restart);
39 @@ -76,11 +79,48 @@ err:
40 dev_err(&phydev->mdio.dev, "Write register failed, %d\n", rc);
43 +static void readynas_mvphy_set_reg(bool restart)
45 + int rc = 0, saved_page;
49 + data = MII_88E1318S_PHY_LED_POL_LED2;
51 + saved_page = phy_select_page(phydev, MII_MARVELL_LED_PAGE);
55 + /* Set the LED[2].0 Polarity bit to the required state */
56 + __phy_modify(phydev, MII_PHY_LED_POL_CTRL,
57 + MII_88E1318S_PHY_LED_POL_LED2, data);
61 + /* If WOL was enabled and a magic packet was received before powering
62 + * off, we won't be able to wake up by sending another magic packet.
65 + __phy_write(phydev, MII_MARVELL_PHY_PAGE, MII_MARVELL_WOL_PAGE);
66 + __phy_set_bits(phydev, MII_88E1318S_PHY_WOL_CTRL,
67 + MII_88E1318S_PHY_WOL_CTRL_CLEAR_WOL_STATUS);
70 + rc = phy_restore_page(phydev, saved_page, rc);
72 + dev_err(&phydev->mdio.dev, "Write register failed, %d\n", rc);
75 static const struct power_off_cfg linkstation_power_off_cfg = {
76 .mdio_node_name = "mdio",
77 .phy_set_reg = linkstation_mvphy_reg_intn,
80 +static const struct power_off_cfg readynas_power_off_cfg = {
81 + .mdio_node_name = "mdio-bus",
82 + .phy_set_reg = readynas_mvphy_set_reg,
85 static int linkstation_reboot_notifier(struct notifier_block *nb,
86 unsigned long action, void *unused)
88 @@ -109,6 +149,9 @@ static const struct of_device_id ls_powe
89 { .compatible = "buffalo,ls421de",
90 .data = &linkstation_power_off_cfg,
92 + { .compatible = "netgear,readynas-duo-v2",
93 + .data = &readynas_power_off_cfg,