mediatek: add led polarity select for rtl8221
Signed-off-by: Tianling Shen <cnsztl@immortalwrt.org>
This commit is contained in:
parent
5e320d042c
commit
6222e84b7e
@ -18,7 +18,7 @@ Signed-off-by: Yangyu Chen <cyy@cyyself.name>
|
|||||||
|
|
||||||
--- a/drivers/net/phy/realtek.c
|
--- a/drivers/net/phy/realtek.c
|
||||||
+++ b/drivers/net/phy/realtek.c
|
+++ b/drivers/net/phy/realtek.c
|
||||||
@@ -77,6 +77,11 @@
|
@@ -86,6 +86,12 @@
|
||||||
#define RTL8221B_PHYCR1_ALDPS_EN BIT(2)
|
#define RTL8221B_PHYCR1_ALDPS_EN BIT(2)
|
||||||
#define RTL8221B_PHYCR1_ALDPS_XTAL_OFF_EN BIT(12)
|
#define RTL8221B_PHYCR1_ALDPS_XTAL_OFF_EN BIT(12)
|
||||||
|
|
||||||
@ -26,43 +26,50 @@ Signed-off-by: Yangyu Chen <cyy@cyyself.name>
|
|||||||
+#define RTL8221B_LED_LINK_SELECT 0xd032
|
+#define RTL8221B_LED_LINK_SELECT 0xd032
|
||||||
+#define RTL8221B_LED_LINK_SELECT_OFFSET 0x2
|
+#define RTL8221B_LED_LINK_SELECT_OFFSET 0x2
|
||||||
+#define RTL8221B_LED_ACT_SELECT 0xd040
|
+#define RTL8221B_LED_ACT_SELECT 0xd040
|
||||||
|
+#define RTL8221B_LED_POLARITY_SELECT 0xd044
|
||||||
+
|
+
|
||||||
#define RTL8366RB_POWER_SAVE 0x15
|
#define RTL8366RB_POWER_SAVE 0x15
|
||||||
#define RTL8366RB_POWER_SAVE_ON BIT(12)
|
#define RTL8366RB_POWER_SAVE_ON BIT(12)
|
||||||
|
|
||||||
@@ -683,6 +688,39 @@ static int rtl822x_write_mmd(struct phy_
|
@@ -787,6 +793,45 @@ static int rtl822x_write_mmd(struct phy_
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
+static int rtl8221b_config_led(struct phy_device *phydev) {
|
+static int rtl8221b_config_led(struct phy_device *phydev) {
|
||||||
+ struct device *node = &phydev->mdio.dev;
|
+ struct device *node = &phydev->mdio.dev;
|
||||||
+ u32 link_select[RTL8221B_NR_LEDS];
|
+ u32 link_select[RTL8221B_NR_LEDS];
|
||||||
+ u32 act_select;
|
+ u32 act_select, polarity_select;
|
||||||
+ int i, val;
|
+ int i, val;
|
||||||
+
|
+
|
||||||
+ val = device_property_read_u32_array(node, "realtek,led-link-select",
|
+ val = device_property_read_u32_array(node, "realtek,led-link-select",
|
||||||
+ link_select, RTL8221B_NR_LEDS);
|
+ link_select, RTL8221B_NR_LEDS);
|
||||||
|
+ if (!val) {
|
||||||
|
+ for (i = 0; i < RTL8221B_NR_LEDS; i++) {
|
||||||
|
+ val = phy_write_mmd(phydev, MDIO_MMD_VEND2,
|
||||||
|
+ RTL8221B_LED_LINK_SELECT + i * RTL8221B_LED_LINK_SELECT_OFFSET,
|
||||||
|
+ link_select[i]);
|
||||||
|
+ if (val < 0)
|
||||||
|
+ return val;
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
+
|
+
|
||||||
+ if (val)
|
+ val = device_property_read_u32(node,
|
||||||
+ return 0;
|
+ "realtek,led-act-select", &act_select);
|
||||||
+
|
+ if (!val) {
|
||||||
+ for (i = 0; i < RTL8221B_NR_LEDS; i++) {
|
|
||||||
+ val = phy_write_mmd(phydev, MDIO_MMD_VEND2,
|
+ val = phy_write_mmd(phydev, MDIO_MMD_VEND2,
|
||||||
+ RTL8221B_LED_LINK_SELECT + i * RTL8221B_LED_LINK_SELECT_OFFSET,
|
+ RTL8221B_LED_ACT_SELECT, act_select);
|
||||||
+ link_select[i]);
|
|
||||||
+ if (val < 0)
|
+ if (val < 0)
|
||||||
+ return val;
|
+ return val;
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ val = device_property_read_u32(node,
|
+ val = device_property_read_u32(node,
|
||||||
+ "realtek,led-act-select", &act_select);
|
+ "realtek,led-polarity-select", &polarity_select);
|
||||||
+ if (val)
|
+ if (!val) {
|
||||||
+ return 0;
|
+ val = phy_write_mmd(phydev, MDIO_MMD_VEND2,
|
||||||
+
|
+ RTL8221B_LED_POLARITY_SELECT, polarity_select);
|
||||||
+ val = phy_write_mmd(phydev, MDIO_MMD_VEND2,
|
+ if (val < 0)
|
||||||
+ RTL8221B_LED_ACT_SELECT, act_select);
|
+ return val;
|
||||||
+ if (val < 0)
|
+ }
|
||||||
+ return val;
|
|
||||||
+
|
+
|
||||||
+ return 0;
|
+ return 0;
|
||||||
+}
|
+}
|
||||||
@ -70,7 +77,7 @@ Signed-off-by: Yangyu Chen <cyy@cyyself.name>
|
|||||||
static int rtl822xb_config_init(struct phy_device *phydev)
|
static int rtl822xb_config_init(struct phy_device *phydev)
|
||||||
{
|
{
|
||||||
bool has_2500, has_sgmii;
|
bool has_2500, has_sgmii;
|
||||||
@@ -759,7 +797,7 @@ static int rtl822xb_config_init(struct p
|
@@ -863,7 +908,7 @@ static int rtl822xb_config_init(struct p
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user