da5387dafc3fafcafb889b1d41390cb03982463b
[openwrt/staging/hauke.git] / package / kernel / qca-ssdk / patches / 0001-qca807x-add-a-LED-quirk-for-Xiaomi-AX9000.patch
1 From cdcafa28c857e4d04c9210feb54dc84e427061fe Mon Sep 17 00:00:00 2001
2 From: Robert Marko <robimarko@gmail.com>
3 Date: Tue, 11 Jan 2022 00:28:42 +0100
4 Subject: [PATCH 1/2] qca807x: add a LED quirk for Xiaomi AX9000
5
6 Xiaomi AX9000 has a single LED for each of 4 gigabit ethernet ports that
7 are connected to QCA8075, and that LED is connected to the 100M LED pin.
8
9 So, by default it will only work when in 10 or 100Mbit mode, this is quite
10 annoying and makes no sense(If they have connected it to the 1000Mbit LED
11 pin then it would have worked for 10/100 by default as well).
12
13 So, to solve this add a check for system compatible as we cant parse if
14 from DTS in any other way and set the 100M LED to blink on 1000Base-T
15 as well.
16
17 Signed-off-by: Robert Marko <robimarko@gmail.com>
18 ---
19 include/hsl/phy/malibu_phy.h | 2 ++
20 src/hsl/phy/malibu_phy.c | 11 +++++++++++
21 2 files changed, 13 insertions(+)
22
23 --- a/include/hsl/phy/malibu_phy.h
24 +++ b/include/hsl/phy/malibu_phy.h
25 @@ -94,6 +94,7 @@ extern "C"
26 #define MALIBU_DAC_CTRL_MASK 0x380
27 #define MALIBU_DAC_CTRL_VALUE 0x280
28 #define MALIBU_LED_1000_CTRL1_100_10_MASK 0x30
29 +#define MALIBU_LED_100_CTRL1_1000_MASK 0x40
30
31 #define MALIBU_PHY_EEE_ADV_100M 0x0002
32 #define MALIBU_PHY_EEE_ADV_1000M 0x0004
33 @@ -118,6 +119,7 @@ extern "C"
34 #define MALIBU_PHY_MMD7_EGRESS_COUNTER_HIGH 0x802d
35 #define MALIBU_PHY_MMD7_EGRESS_COUNTER_LOW 0x802e
36 #define MALIBU_PHY_MMD7_EGRESS_ERROR_COUNTER 0x802f
37 +#define MALIBU_PHY_MMD7_LED_100_CTRL1 0x8074
38 #define MALIBU_PHY_MMD7_LED_1000_CTRL1 0x8076
39
40
41 --- a/src/hsl/phy/malibu_phy.c
42 +++ b/src/hsl/phy/malibu_phy.c
43 @@ -15,6 +15,8 @@
44 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
45 */
46
47 +#include <linux/of.h>
48 +
49 #include "sw.h"
50 #include "fal_port_ctrl.h"
51 #include "hsl_api.h"
52 @@ -2716,6 +2718,15 @@ malibu_phy_hw_init(a_uint32_t dev_id, a_
53 led_status |= MALIBU_LED_1000_CTRL1_100_10_MASK;
54 malibu_phy_mmd_write(dev_id, phy_addr, MALIBU_PHY_MMD7_NUM,
55 MALIBU_PHY_MMD7_LED_1000_CTRL1, led_status);
56 + if (of_machine_is_compatible("xiaomi,ax9000")) {
57 + /* add 1000M link LED behavior for Xiaomi AX9000 */
58 + led_status = malibu_phy_mmd_read(dev_id, phy_addr, MALIBU_PHY_MMD7_NUM,
59 + MALIBU_PHY_MMD7_LED_100_CTRL1);
60 + led_status &= ~MALIBU_LED_100_CTRL1_1000_MASK;
61 + led_status |= MALIBU_LED_100_CTRL1_1000_MASK;
62 + malibu_phy_mmd_write(dev_id, phy_addr, MALIBU_PHY_MMD7_NUM,
63 + MALIBU_PHY_MMD7_LED_100_CTRL1, led_status);
64 + }
65 /*disable Extended next page*/
66 phy_data = malibu_phy_reg_read(dev_id, phy_addr, MALIBU_AUTONEG_ADVERT);
67 phy_data &= ~MALIBU_EXTENDED_NEXT_PAGE_EN;