Search Linux Wireless

Re: [PATCH] mt76: mt7615: introduce LED support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2019-12-11 15:21, Lorenzo Bianconi wrote:
> Initialize brightness_set and blink_set callbacks to
> mt7615_led_set_brightness and mt7615_led_set_blink in order to enable
> LED support in mt7615 driver
> 
> Tested-by: Deng Qingfang <dengqf6@xxxxxxxxxxxxxxxxx>
> Signed-off-by: Lorenzo Bianconi <lorenzo@xxxxxxxxxx>
> ---
>  .../net/wireless/mediatek/mt76/mt7615/init.c  | 58 +++++++++++++++++++
>  .../net/wireless/mediatek/mt76/mt7615/regs.h  | 27 +++++++++
>  2 files changed, 85 insertions(+)
> 
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/init.c b/drivers/net/wireless/mediatek/mt76/mt7615/init.c
> index eb7c6b9e3d4d..c25ba5fc3cdc 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7615/init.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt7615/init.c
> @@ -196,6 +196,58 @@ static const struct ieee80211_iface_combination if_comb[] = {
>  	}
>  };
>  
> +static void
> +mt7615_led_set_config(struct led_classdev *led_cdev,
> +		      u8 delay_on, u8 delay_off)
> +{
> +	struct mt7615_dev *dev;
> +	struct mt76_dev *mt76;
> +	u32 val, addr;
> +
> +	mt76 = container_of(led_cdev, struct mt76_dev, led_cdev);
> +	dev = container_of(mt76, struct mt7615_dev, mt76);
> +	val = MT_LED_STATUS_DURATION(0xffff) |
> +	      MT_LED_STATUS_OFF(delay_off) |
> +	      MT_LED_STATUS_ON(delay_on);
> +
> +	addr = mt7615_reg_map(dev, MT_LED_STATUS_0(mt76->led_pin));
> +	mt76_wr(dev, addr, val);
> +	addr = mt7615_reg_map(dev, MT_LED_STATUS_1(mt76->led_pin));
> +	mt76_wr(dev, addr, val);
> +
> +	val = MT_LED_CTRL_REPLAY(mt76->led_pin) |
> +	      MT_LED_CTRL_KICK(mt76->led_pin);
> +	if (mt76->led_al)
> +		val |= MT_LED_CTRL_POLARITY(mt76->led_pin);
> +	addr = mt7615_reg_map(dev, MT_LED_CTRL);
> +	mt76_wr(dev, addr, val);
> +}
> +
> [...]
> diff --git a/drivers/net/wireless/mediatek/mt76/mt7615/regs.h b/drivers/net/wireless/mediatek/mt76/mt7615/regs.h
> index 26d121646787..3234ae0761b8 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt7615/regs.h
> +++ b/drivers/net/wireless/mediatek/mt76/mt7615/regs.h
> @@ -345,6 +345,33 @@
>  
>  #define MT_TX_AGG_CNT(n)		MT_WF_MIB(0xa8 + ((n) << 2))
>  
> +#define MT_LED_BASE_PHYS		0x80024000
> +#define MT_LED_PHYS(_n)			(MT_LED_BASE_PHYS + (_n))
> +
> +#define MT_LED_CTRL			MT_LED_PHYS(0x00)
> +
> +#define MT_LED_CTRL_REPLAY(_n)		BIT(0 + (8 * (_n)))
> +#define MT_LED_CTRL_POLARITY(_n)	BIT(1 + (8 * (_n)))
> +#define MT_LED_CTRL_TX_BLINK_MODE(_n)	BIT(2 + (8 * (_n)))
> +#define MT_LED_CTRL_TX_MANUAL_BLINK(_n)	BIT(3 + (8 * (_n)))
> +#define MT_LED_CTRL_TX_OVER_BLINK(_n)	BIT(5 + (8 * (_n)))
> +#define MT_LED_CTRL_KICK(_n)		BIT(7 + (8 * (_n)))
> +
> +#define MT_LED_STATUS_0(_n)		MT_LED_PHYS(0x10 + ((_n) * 8))
> +#define MT_LED_STATUS_1(_n)		MT_LED_PHYS(0x14 + ((_n) * 8))
> +#define MT_LED_STATUS_OFF_MASK		GENMASK(31, 24)
> +#define MT_LED_STATUS_OFF(_v)		(((_v) << \
> +					  __ffs(MT_LED_STATUS_OFF_MASK)) & \
> +					 MT_LED_STATUS_OFF_MASK)
> +#define MT_LED_STATUS_ON_MASK		GENMASK(23, 16)
> +#define MT_LED_STATUS_ON(_v)		(((_v) << \
> +					  __ffs(MT_LED_STATUS_ON_MASK)) & \
> +					 MT_LED_STATUS_ON_MASK)
> +#define MT_LED_STATUS_DURATION_MASK	GENMASK(15, 0)
> +#define MT_LED_STATUS_DURATION(_v)	(((_v) << \
> +					  __ffs(MT_LED_STATUS_DURATION_MASK)) &\
> +					 MT_LED_STATUS_DURATION_MASK

Why are you using separate _MASK fields and macros using __ffs in
bitshift instead of FIELD_PREP like the rest of the code?

- Felix



[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Wireless Regulations]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux