netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Fainelli <f.fainelli@gmail.com>
To: "Rafał Miłecki" <zajec5@gmail.com>,
	"Andrew Lunn" <andrew@lunn.ch>,
	"Vivien Didelot" <vivien.didelot@gmail.com>,
	"Vladimir Oltean" <olteanv@gmail.com>,
	"David S . Miller" <davem@davemloft.net>,
	"Jakub Kicinski" <kuba@kernel.org>
Cc: netdev@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com,
	"Rafał Miłecki" <rafal@milecki.pl>
Subject: Re: [PATCH] net: dsa: bcm_sf2: refactor LED regs access
Date: Wed, 29 Dec 2021 08:40:08 -0800	[thread overview]
Message-ID: <097bb80d-a5c5-3884-4ce4-64c9fec1b26a@gmail.com> (raw)
In-Reply-To: <20211228220951.17751-1-zajec5@gmail.com>



On 12/28/2021 2:09 PM, Rafał Miłecki wrote:
> From: Rafał Miłecki <rafal@milecki.pl>
> 
> 1. Define more regs. Some switches (e.g. BCM4908) have up to 6 regs.
> 2. Add helper for handling non-lineral port <-> reg mappings.
> 3. Add support for 12 B LED reg blocks on BCM4908 (different layout)
> 
> Complete support for LEDs setup will be implemented once Linux receives
> a proper design & implementation for "hardware" LEDs.
> 
> Signed-off-by: Rafał Miłecki <rafal@milecki.pl>

This looks good for the most part, just one nit below:

> ---
>   drivers/net/dsa/bcm_sf2.c      | 60 +++++++++++++++++++++++++++----
>   drivers/net/dsa/bcm_sf2.h      | 10 ++++++
>   drivers/net/dsa/bcm_sf2_regs.h | 65 +++++++++++++++++++++++++++++++---
>   3 files changed, 125 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
> index 13aa43b5cffd..c2447de9d441 100644
> --- a/drivers/net/dsa/bcm_sf2.c
> +++ b/drivers/net/dsa/bcm_sf2.c
> @@ -62,6 +62,44 @@ static u16 bcm_sf2_reg_rgmii_cntrl(struct bcm_sf2_priv *priv, int port)
>   	return REG_SWITCH_STATUS;
>   }
>   
> +static u16 bcm_sf2_reg_led_base(struct bcm_sf2_priv *priv, int port)
> +{
> +	switch (priv->type) {
> +	case BCM4908_DEVICE_ID:
> +		switch (port) {
> +		case 0:
> +			return REG_LED_0_CNTRL;
> +		case 1:
> +			return REG_LED_1_CNTRL;
> +		case 2:
> +			return REG_LED_2_CNTRL;

Up until that port count, we have a common path, it is only after port > 
2 that we stop having a common path. Only BCM7445 and BCM7278 have two 
external ports, 63138 (and 63148 when that gets added eventually) as 
well as a 4908 have more ports, so I would do something like this:

switch (port) {
case 0:
	return REG_LED_0_CNTRL;
case 1:
	return REG_LED_1_CNTRL;
case 2:
	return REG_LED_2_CNTRL;
default:
	break;
}

if (priv->type == BCM7445_DEVICE_ID || priv->type == BCM7278_DEVICE_ID)
	goto out;

Also, this LED controller is also present in the GENETv5 adapters, so we 
may have some value in writing a common LED framework driver for it at 
some point.

Thanks!
-- 
Florian

  reply	other threads:[~2021-12-29 16:40 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-28 22:09 [PATCH] net: dsa: bcm_sf2: refactor LED regs access Rafał Miłecki
2021-12-29 16:40 ` Florian Fainelli [this message]
2021-12-29 17:16 ` [PATCH V2] " Rafał Miłecki
2021-12-29 19:55   ` Florian Fainelli
2021-12-31  2:30   ` patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=097bb80d-a5c5-3884-4ce4-64c9fec1b26a@gmail.com \
    --to=f.fainelli@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=rafal@milecki.pl \
    --cc=vivien.didelot@gmail.com \
    --cc=zajec5@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).