From e17d730bf2f6ed8c0769da6701d28117f34f2f27 Mon Sep 17 00:00:00 2001 From: MeiChia Chiu Date: Sun, 29 Aug 2021 01:02:38 +0800 Subject: [PATCH] mt76: mt7915: add LED support [update to v3] Initialize brightness_set and blink_set callbacks to enable LED support. The base 0x7c000000 is MCU space so driver can't touch it, and should map the LED base to 0x18000000 host's view. Signed-off-by: MeiChia Chiu Signed-off-by: Ryder Lee Signed-off-by: Money Wang Signed-off-by: Felix Fietkau --- mt7915/init.c | 2 +- mt7915/mmio.c | 3 --- mt7915/regs.h | 28 ++++++++++++++-------------- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/mt7915/init.c b/mt7915/init.c index bcc0ff7b..c07d6243 100644 --- a/mt7915/init.c +++ b/mt7915/init.c @@ -221,7 +221,7 @@ static int mt7915_led_set_blink(struct led_classdev *led_cdev, unsigned long *delay_on, unsigned long *delay_off) { - u16 delta_on, delta_off; + u16 delta_on = 0, delta_off = 0; #define HW_TICK 10 #define TO_HW_TICK(_t) (((_t) > HW_TICK) ? ((_t) / HW_TICK) : HW_TICK) diff --git a/mt7915/mmio.c b/mt7915/mmio.c index 43f92452..7bbb38e7 100644 --- a/mt7915/mmio.c +++ b/mt7915/mmio.c @@ -95,9 +95,6 @@ static u32 __mt7915_reg_addr(struct mt7915_dev *dev, u32 addr) (addr >= 0x70000000 && addr < 0x78000000)) return mt7915_reg_map_l1(dev, addr); - if (addr >= 0x7c000000 && addr < 0x7c400000) - return mt7915_reg_map_l1(dev, addr - 0x64000000); - return mt7915_reg_map_l2(dev, addr); } diff --git a/mt7915/regs.h b/mt7915/regs.h index 97078c13..df5dfffa 100644 --- a/mt7915/regs.h +++ b/mt7915/regs.h @@ -431,6 +431,20 @@ #define MT_SWDEF_ICAP_MODE 1 #define MT_SWDEF_SPECTRUM_MODE 2 +#define MT_LED_TOP_BASE 0x18013000 +#define MT_LED_PHYS(_n) (MT_LED_TOP_BASE + (_n)) + +#define MT_LED_CTRL(_n) MT_LED_PHYS(0x00 + ((_n) * 4)) +#define MT_LED_CTRL_KICK BIT(7) +#define MT_LED_CTRL_BLINK_MODE BIT(2) +#define MT_LED_CTRL_POLARITY BIT(1) + +#define MT_LED_TX_BLINK(_n) MT_LED_PHYS(0x10 + ((_n) * 4)) +#define MT_LED_TX_BLINK_ON_MASK GENMASK(7, 0) +#define MT_LED_TX_BLINK_OFF_MASK GENMASK(15, 8) + +#define MT_LED_EN(_n) MT_LED_PHYS(0x40 + ((_n) * 4)) + #define MT_TOP_BASE 0x18060000 #define MT_TOP(ofs) (MT_TOP_BASE + (ofs)) @@ -458,20 +472,6 @@ #define MT_PCIE_MAC(ofs) (MT_PCIE_MAC_BASE + (ofs)) #define MT_PCIE_MAC_INT_ENABLE MT_PCIE_MAC(0x188) -#define MT_LED_TOP_BASE 0x7c013000 -#define MT_LED_PHYS(_n) (MT_LED_TOP_BASE + (_n)) - -#define MT_LED_CTRL(_n) MT_LED_PHYS(0x00 + ((_n) * 4)) -#define MT_LED_CTRL_KICK BIT(7) -#define MT_LED_CTRL_BLINK_MODE BIT(2) -#define MT_LED_CTRL_POLARITY BIT(1) - -#define MT_LED_TX_BLINK(_n) MT_LED_PHYS(0x10 + ((_n) * 4)) -#define MT_LED_TX_BLINK_ON_MASK GENMASK(7, 0) -#define MT_LED_TX_BLINK_OFF_MASK GENMASK(15, 8) - -#define MT_LED_EN(_n) MT_LED_PHYS(0x40 + ((_n) * 4)) - #define MT_WF_IRPI_BASE 0x83006000 #define MT_WF_IRPI(ofs) (MT_WF_IRPI_BASE + ((ofs) << 16))