diff mbox series

[v2,1/4] dt-bindings: wireless: wilc1000: Document WILC3000 compatible string

Message ID 20240823161131.94305-1-marex@denx.de
State Changes Requested
Headers show
Series [v2,1/4] dt-bindings: wireless: wilc1000: Document WILC3000 compatible string | expand

Checks

Context Check Description
robh/checkpatch success
robh/patch-applied success
robh/dtbs-check warning build log
robh/dt-meta-schema success

Commit Message

Marek Vasut Aug. 23, 2024, 4:08 p.m. UTC
Document compatible string for the WILC3000 chip. The chip is similar
to WILC1000, except that the register layout is slightly different and
it does not support WPA3/SAE.

Signed-off-by: Marek Vasut <marex@denx.de>
---
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Adham Abozaeid <adham.abozaeid@microchip.com>
Cc: Ajay Singh <ajay.kathat@microchip.com>
Cc: Alexis Lothoré <alexis.lothore@bootlin.com>
Cc: Claudiu Beznea <claudiu.beznea@tuxon.dev>
Cc: Conor Dooley <conor+dt@kernel.org>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Kalle Valo <kvalo@kernel.org>
Cc: Krzysztof Kozlowski <krzk+dt@kernel.org>
Cc: Marek Vasut <marex@denx.de>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Rob Herring <robh@kernel.org>
Cc: devicetree@vger.kernel.org
Cc: linux-wireless@vger.kernel.org
Cc: netdev@vger.kernel.org
---
V2: - Use WILC1000 as fallback compatible string for WILC3000
---
 .../bindings/net/wireless/microchip,wilc1000.yaml           | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Simon Horman Aug. 23, 2024, 5:46 p.m. UTC | #1
On Fri, Aug 23, 2024 at 06:08:57PM +0200, Marek Vasut wrote:
> Do not use wilc_get_chipid() outside of wlan.c . Instead, call
> wilc_get_chipid() right after the SDIO/SPI interface has been
> initialized to cache the device chipid, and then use the cached
> chipid throughout the driver. Make wilc_get_chipid() static and
> remove its prototype from wlan.h .
> 
> Signed-off-by: Marek Vasut <marex@denx.de>

...

> diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c

...

> @@ -1535,9 +1537,18 @@ int wilc_wlan_init(struct net_device *dev)
>  	if (!wilc->hif_func->hif_is_init(wilc)) {
>  		acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY);
>  		ret = wilc->hif_func->hif_init(wilc, false);
> +		if (!ret)
> +			chipid = wilc_get_chipid(wilc);
>  		release_bus(wilc, WILC_BUS_RELEASE_ONLY);
>  		if (ret)
>  			goto fail;
> +
> +		if (!is_wilc1000(chipid)) {
> +			netdev_err(dev, "Unsupported chipid: %x\n", chipid);
> +			return -EINVAL;

Hi Marek,

Should this unwind as is the case elsewhere in this function?

			ret = -EINVAL;
			goto fail;

Flagged by Smatch.

> +		}
> +
> +		netdev_dbg(dev, "chipid (%08x)\n", chipid);
>  	}
>  
>  	if (!wilc->vmm_table)

...
Marek Vasut Aug. 23, 2024, 8:38 p.m. UTC | #2
On 8/23/24 7:46 PM, Simon Horman wrote:
> On Fri, Aug 23, 2024 at 06:08:57PM +0200, Marek Vasut wrote:
>> Do not use wilc_get_chipid() outside of wlan.c . Instead, call
>> wilc_get_chipid() right after the SDIO/SPI interface has been
>> initialized to cache the device chipid, and then use the cached
>> chipid throughout the driver. Make wilc_get_chipid() static and
>> remove its prototype from wlan.h .
>>
>> Signed-off-by: Marek Vasut <marex@denx.de>
> 
> ...
> 
>> diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c
> 
> ...
> 
>> @@ -1535,9 +1537,18 @@ int wilc_wlan_init(struct net_device *dev)
>>   	if (!wilc->hif_func->hif_is_init(wilc)) {
>>   		acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY);
>>   		ret = wilc->hif_func->hif_init(wilc, false);
>> +		if (!ret)
>> +			chipid = wilc_get_chipid(wilc);
>>   		release_bus(wilc, WILC_BUS_RELEASE_ONLY);
>>   		if (ret)
>>   			goto fail;
>> +
>> +		if (!is_wilc1000(chipid)) {
>> +			netdev_err(dev, "Unsupported chipid: %x\n", chipid);
>> +			return -EINVAL;
> 
> Hi Marek,
> 
> Should this unwind as is the case elsewhere in this function?

It should, will fix in V3, thanks.

> 			ret = -EINVAL;
> 			goto fail;
> 
> Flagged by Smatch.

What's the trick here ?
Krzysztof Kozlowski Aug. 24, 2024, 6:22 a.m. UTC | #3
On 23/08/2024 18:08, Marek Vasut wrote:
> Document compatible string for the WILC3000 chip. The chip is similar
> to WILC1000, except that the register layout is slightly different and
> it does not support WPA3/SAE.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> ---
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Adham Abozaeid <adham.abozaeid@microchip.com>
> Cc: Ajay Singh <ajay.kathat@microchip.com>
> Cc: Alexis Lothoré <alexis.lothore@bootlin.com>
> Cc: Claudiu Beznea <claudiu.beznea@tuxon.dev>
> Cc: Conor Dooley <conor+dt@kernel.org>
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: Jakub Kicinski <kuba@kernel.org>
> Cc: Kalle Valo <kvalo@kernel.org>
> Cc: Krzysztof Kozlowski <krzk+dt@kernel.org>
> Cc: Marek Vasut <marex@denx.de>
> Cc: Paolo Abeni <pabeni@redhat.com>
> Cc: Rob Herring <robh@kernel.org>
> Cc: devicetree@vger.kernel.org
> Cc: linux-wireless@vger.kernel.org
> Cc: netdev@vger.kernel.org
> ---
> V2: - Use WILC1000 as fallback compatible string for WILC3000
> ---
>  .../bindings/net/wireless/microchip,wilc1000.yaml           | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/net/wireless/microchip,wilc1000.yaml b/Documentation/devicetree/bindings/net/wireless/microchip,wilc1000.yaml
> index 2460ccc082371..b8ee6cdab3c25 100644
> --- a/Documentation/devicetree/bindings/net/wireless/microchip,wilc1000.yaml
> +++ b/Documentation/devicetree/bindings/net/wireless/microchip,wilc1000.yaml
> @@ -16,7 +16,11 @@ description:
>  
>  properties:
>    compatible:
> -    const: microchip,wilc1000
> +    oneOf:
> +      - items:
> +          - const: microchip,wilc1000
> +          - const: microchip,wilc3000

That's wrong order of compatibles. Fallback is wilc1000, so should be
the last item.

Best regards,
Krzysztof
Simon Horman Aug. 24, 2024, 12:44 p.m. UTC | #4
+ Dan

On Fri, Aug 23, 2024 at 10:38:59PM +0200, Marek Vasut wrote:
> On 8/23/24 7:46 PM, Simon Horman wrote:
> > On Fri, Aug 23, 2024 at 06:08:57PM +0200, Marek Vasut wrote:
> > > Do not use wilc_get_chipid() outside of wlan.c . Instead, call
> > > wilc_get_chipid() right after the SDIO/SPI interface has been
> > > initialized to cache the device chipid, and then use the cached
> > > chipid throughout the driver. Make wilc_get_chipid() static and
> > > remove its prototype from wlan.h .
> > > 
> > > Signed-off-by: Marek Vasut <marex@denx.de>
> > 
> > ...
> > 
> > > diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c
> > 
> > ...
> > 
> > > @@ -1535,9 +1537,18 @@ int wilc_wlan_init(struct net_device *dev)
> > >   	if (!wilc->hif_func->hif_is_init(wilc)) {
> > >   		acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY);
> > >   		ret = wilc->hif_func->hif_init(wilc, false);
> > > +		if (!ret)
> > > +			chipid = wilc_get_chipid(wilc);
> > >   		release_bus(wilc, WILC_BUS_RELEASE_ONLY);
> > >   		if (ret)
> > >   			goto fail;
> > > +
> > > +		if (!is_wilc1000(chipid)) {
> > > +			netdev_err(dev, "Unsupported chipid: %x\n", chipid);
> > > +			return -EINVAL;
> > 
> > Hi Marek,
> > 
> > Should this unwind as is the case elsewhere in this function?
> 
> It should, will fix in V3, thanks.
> 
> > 			ret = -EINVAL;
> > 			goto fail;
> > 
> > Flagged by Smatch.
> 
> What's the trick here ?

Smatch is here. I don't think there is much of a trick other than running it :)

https://github.com/error27/smatch
Marek Vasut Aug. 24, 2024, 9:18 p.m. UTC | #5
On 8/24/24 2:44 PM, Simon Horman wrote:
> + Dan
> 
> On Fri, Aug 23, 2024 at 10:38:59PM +0200, Marek Vasut wrote:
>> On 8/23/24 7:46 PM, Simon Horman wrote:
>>> On Fri, Aug 23, 2024 at 06:08:57PM +0200, Marek Vasut wrote:
>>>> Do not use wilc_get_chipid() outside of wlan.c . Instead, call
>>>> wilc_get_chipid() right after the SDIO/SPI interface has been
>>>> initialized to cache the device chipid, and then use the cached
>>>> chipid throughout the driver. Make wilc_get_chipid() static and
>>>> remove its prototype from wlan.h .
>>>>
>>>> Signed-off-by: Marek Vasut <marex@denx.de>
>>>
>>> ...
>>>
>>>> diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c
>>>
>>> ...
>>>
>>>> @@ -1535,9 +1537,18 @@ int wilc_wlan_init(struct net_device *dev)
>>>>    	if (!wilc->hif_func->hif_is_init(wilc)) {
>>>>    		acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY);
>>>>    		ret = wilc->hif_func->hif_init(wilc, false);
>>>> +		if (!ret)
>>>> +			chipid = wilc_get_chipid(wilc);
>>>>    		release_bus(wilc, WILC_BUS_RELEASE_ONLY);
>>>>    		if (ret)
>>>>    			goto fail;
>>>> +
>>>> +		if (!is_wilc1000(chipid)) {
>>>> +			netdev_err(dev, "Unsupported chipid: %x\n", chipid);
>>>> +			return -EINVAL;
>>>
>>> Hi Marek,
>>>
>>> Should this unwind as is the case elsewhere in this function?
>>
>> It should, will fix in V3, thanks.
>>
>>> 			ret = -EINVAL;
>>> 			goto fail;
>>>
>>> Flagged by Smatch.
>>
>> What's the trick here ?
> 
> Smatch is here. I don't think there is much of a trick other than running it :)
> 
> https://github.com/error27/smatch

Thanks !
Marek Vasut Aug. 24, 2024, 9:21 p.m. UTC | #6
On 8/24/24 8:22 AM, Krzysztof Kozlowski wrote:

Hi,

>> diff --git a/Documentation/devicetree/bindings/net/wireless/microchip,wilc1000.yaml b/Documentation/devicetree/bindings/net/wireless/microchip,wilc1000.yaml
>> index 2460ccc082371..b8ee6cdab3c25 100644
>> --- a/Documentation/devicetree/bindings/net/wireless/microchip,wilc1000.yaml
>> +++ b/Documentation/devicetree/bindings/net/wireless/microchip,wilc1000.yaml
>> @@ -16,7 +16,11 @@ description:
>>   
>>   properties:
>>     compatible:
>> -    const: microchip,wilc1000
>> +    oneOf:
>> +      - items:
>> +          - const: microchip,wilc1000
>> +          - const: microchip,wilc3000
> 
> That's wrong order of compatibles. Fallback is wilc1000, so should be
> the last item.

Right, fixed, thanks.
Alexis Lothoré Aug. 27, 2024, 7:51 a.m. UTC | #7
Hello Marek,

On 8/23/24 18:08, Marek Vasut wrote:
> Do not use wilc_get_chipid() outside of wlan.c . Instead, call
> wilc_get_chipid() right after the SDIO/SPI interface has been
> initialized to cache the device chipid, and then use the cached
> chipid throughout the driver. Make wilc_get_chipid() static and
> remove its prototype from wlan.h .
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> ---
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Adham Abozaeid <adham.abozaeid@microchip.com>
> Cc: Ajay Singh <ajay.kathat@microchip.com>
> Cc: Alexis Lothoré <alexis.lothore@bootlin.com>
> Cc: Claudiu Beznea <claudiu.beznea@tuxon.dev>
> Cc: Conor Dooley <conor+dt@kernel.org>
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: Jakub Kicinski <kuba@kernel.org>
> Cc: Kalle Valo <kvalo@kernel.org>
> Cc: Krzysztof Kozlowski <krzk+dt@kernel.org>
> Cc: Marek Vasut <marex@denx.de>
> Cc: Paolo Abeni <pabeni@redhat.com>
> Cc: Rob Herring <robh@kernel.org>
> Cc: devicetree@vger.kernel.org
> Cc: linux-wireless@vger.kernel.org
> Cc: netdev@vger.kernel.org
> ---
> V2: New patch
> ---

[...]

> +static u32 wilc_get_chipid(struct wilc *wilc)
> +{
> +	u32 chipid = 0;
> +	u32 rfrevid = 0;
> +
> +	if (wilc->chipid == 0) {
> +		wilc->hif_func->hif_read_reg(wilc, WILC_CHIPID, &chipid);
If we search for WILC_CHIPID in the whole driver, there are still two places
manually reading this register. Shouldn't those places also benefit from
wilc_get_chipid ?

> +		wilc->hif_func->hif_read_reg(wilc, WILC_RF_REVISION_ID,
> +					     &rfrevid);
> +		if (!is_wilc1000(chipid)) {
> +			wilc->chipid = 0;

While at it, since you have trimmed the update parameter, it would be nice to
also fix this return value (ie make wilc_getchipid() not return 0 but a real
error code if we can not read the chip id.

Thanks,

Alexis
Alexis Lothoré Aug. 27, 2024, 8:14 a.m. UTC | #8
On 8/23/24 18:08, Marek Vasut wrote:
> Neither chip_allow_sleep()/chip_wakeup() is used outside of wlan.c .
> Make both functions static and remove both the exported symbol and
> entries from wlan.h .
> 
> Make chip_allow_sleep() return error code in preparation for the
> follow up patches.
> 
> Move acquire_bus() and release_bus() to avoid forward declaration
> of chip_allow_sleep()/chip_wakeup().
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> ---
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Adham Abozaeid <adham.abozaeid@microchip.com>
> Cc: Ajay Singh <ajay.kathat@microchip.com>
> Cc: Alexis Lothoré <alexis.lothore@bootlin.com>
> Cc: Claudiu Beznea <claudiu.beznea@tuxon.dev>
> Cc: Conor Dooley <conor+dt@kernel.org>
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: Jakub Kicinski <kuba@kernel.org>
> Cc: Kalle Valo <kvalo@kernel.org>
> Cc: Krzysztof Kozlowski <krzk+dt@kernel.org>
> Cc: Marek Vasut <marex@denx.de>
> Cc: Paolo Abeni <pabeni@redhat.com>
> Cc: Rob Herring <robh@kernel.org>
> Cc: devicetree@vger.kernel.org
> Cc: linux-wireless@vger.kernel.org
> Cc: netdev@vger.kernel.org
> ---
> V2: New patch
> ---
>  .../net/wireless/microchip/wilc1000/wlan.c    | 47 +++++++++----------
>  .../net/wireless/microchip/wilc1000/wlan.h    |  2 -
>  2 files changed, 23 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c
> index 1aab2f2dc159f..5fbba6876bd07 100644
> --- a/drivers/net/wireless/microchip/wilc1000/wlan.c
> +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c
> @@ -12,20 +12,6 @@
>  
>  #define WAKE_UP_TRIAL_RETRY		10000
>  
> -static inline void acquire_bus(struct wilc *wilc, enum bus_acquire acquire)
> -{
> -	mutex_lock(&wilc->hif_cs);
> -	if (acquire == WILC_BUS_ACQUIRE_AND_WAKEUP && wilc->power_save_mode)
> -		chip_wakeup(wilc);
> -}
> -
> -static inline void release_bus(struct wilc *wilc, enum bus_release release)
> -{
> -	if (release == WILC_BUS_RELEASE_ALLOW_SLEEP && wilc->power_save_mode)
> -		chip_allow_sleep(wilc);
> -	mutex_unlock(&wilc->hif_cs);
> -}
> -
>  static void wilc_wlan_txq_remove(struct wilc *wilc, u8 q_num,
>  				 struct txq_entry_t *tqe)
>  {
> @@ -555,7 +541,7 @@ static struct rxq_entry_t *wilc_wlan_rxq_remove(struct wilc *wilc)
>  	return rqe;
>  }
>  
> -void chip_allow_sleep(struct wilc *wilc)
> +static int chip_allow_sleep(struct wilc *wilc)
>  {
>  	u32 reg = 0;
>  	const struct wilc_hif_func *hif_func = wilc->hif_func;
> @@ -584,7 +570,7 @@ void chip_allow_sleep(struct wilc *wilc)
>  	while (--trials) {
>  		ret = hif_func->hif_read_reg(wilc, to_host_from_fw_reg, &reg);
>  		if (ret)
> -			return;
> +			return ret;

Forwarding error codes sounds like a good idea, but neither this patch nor the
next one is reading the return value from any chip_allow_sleep[XXX] function, so
it does not bring much value.

Alexis
Alexis Lothoré Aug. 27, 2024, 8:28 a.m. UTC | #9
On 8/23/24 18:08, Marek Vasut wrote:
> From: Ajay Singh <ajay.kathat@microchip.com>
> 
> Add support for the WILC3000 chip. The chip is similar to WILC1000,
> except that the register layout is slightly different and it does
> not support WPA3/SAE.
> 
> Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
> Signed-off-by: Marek Vasut <marex@denx.de>
> ---
> Note: Squashed and updated from the following downstream patches:
> wifi: wilc1000: wilc3000 support added
> wifi: wilc1000: wilc3000 interrupt handling
> wifi: wilc1000: wilc3000 added chip wake and sleep support
> wifi: wilc1000: wilc3000 FW file sepecific changes
> ---
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Adham Abozaeid <adham.abozaeid@microchip.com>
> Cc: Ajay Singh <ajay.kathat@microchip.com>
> Cc: Alexis Lothoré <alexis.lothore@bootlin.com>
> Cc: Claudiu Beznea <claudiu.beznea@tuxon.dev>
> Cc: Conor Dooley <conor+dt@kernel.org>
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: Jakub Kicinski <kuba@kernel.org>
> Cc: Kalle Valo <kvalo@kernel.org>
> Cc: Krzysztof Kozlowski <krzk+dt@kernel.org>
> Cc: Marek Vasut <marex@denx.de>
> Cc: Paolo Abeni <pabeni@redhat.com>
> Cc: Rob Herring <robh@kernel.org>
> Cc: devicetree@vger.kernel.org
> Cc: linux-wireless@vger.kernel.org
> Cc: netdev@vger.kernel.org
> ---
> V2: - Return -EINVAL in wilc_sdio_init() if chip ID is not supported
>     - Dispose of wilc_chip_type, replace with is_wilc1000()/is_wilc3000()
>     - Remove wilc3000 DT compatible string handling, match on wilc1000 only,
>       the device type can be auto-detected based on chipID
> ---
>  .../wireless/microchip/wilc1000/cfg80211.c    |   7 +
>  .../net/wireless/microchip/wilc1000/netdev.c  |  29 ++-
>  .../net/wireless/microchip/wilc1000/sdio.c    |  62 ++++-
>  drivers/net/wireless/microchip/wilc1000/spi.c |   2 +-
>  .../net/wireless/microchip/wilc1000/wlan.c    | 217 +++++++++++++++---
>  .../net/wireless/microchip/wilc1000/wlan.h    |  43 +++-
>  6 files changed, 298 insertions(+), 62 deletions(-)
> 

[...]

> @@ -1467,6 +1604,20 @@ static int init_chip(struct net_device *dev)
>  		}
>  	}
>  
> +	if (is_wilc3000(wilc->chipid)) {
> +		ret = wilc->hif_func->hif_read_reg(wilc, 0x207ac, &reg);

Some defines would be nice here instead of hardcoded addresses. I have asked
Ajay about those while working on wilc3000, the meaning is roughly the following:
- 0x000207ac: WILC_3000_BOOTROM_STATUS_REGISTER
- 0x004f0000: WILC_3000_CORTUS_BOOT_REGISTER_2
- 0x71: WILC_CORTUS_BOOT_FROM_IRAM

Thanks,

Alexis
Marek Vasut Aug. 27, 2024, 3:34 p.m. UTC | #10
On 8/27/24 9:51 AM, Alexis Lothoré wrote:

Hi,

>> +static u32 wilc_get_chipid(struct wilc *wilc)
>> +{
>> +	u32 chipid = 0;
>> +	u32 rfrevid = 0;
>> +
>> +	if (wilc->chipid == 0) {
>> +		wilc->hif_func->hif_read_reg(wilc, WILC_CHIPID, &chipid);
> If we search for WILC_CHIPID in the whole driver, there are still two places
> manually reading this register. Shouldn't those places also benefit from
> wilc_get_chipid ?

Both the one in wilc_wlan_start() and wilc_validate_chipid() look more 
like some sort of communication check attempt, rather than reading out 
the chipid for any sort of actual chip identification purpose. I could 
simply remove those ?

>> +		wilc->hif_func->hif_read_reg(wilc, WILC_RF_REVISION_ID,
>> +					     &rfrevid);
>> +		if (!is_wilc1000(chipid)) {
>> +			wilc->chipid = 0;
> 
> While at it, since you have trimmed the update parameter, it would be nice to
> also fix this return value (ie make wilc_getchipid() not return 0 but a real
> error code if we can not read the chip id.

Fixed in V3, thanks .
Marek Vasut Aug. 27, 2024, 4:23 p.m. UTC | #11
On 8/27/24 10:14 AM, Alexis Lothoré wrote:
> On 8/23/24 18:08, Marek Vasut wrote:
>> Neither chip_allow_sleep()/chip_wakeup() is used outside of wlan.c .
>> Make both functions static and remove both the exported symbol and
>> entries from wlan.h .
>>
>> Make chip_allow_sleep() return error code in preparation for the
>> follow up patches.
>>
>> Move acquire_bus() and release_bus() to avoid forward declaration
>> of chip_allow_sleep()/chip_wakeup().
>>
>> Signed-off-by: Marek Vasut <marex@denx.de>
>> ---
>> Cc: "David S. Miller" <davem@davemloft.net>
>> Cc: Adham Abozaeid <adham.abozaeid@microchip.com>
>> Cc: Ajay Singh <ajay.kathat@microchip.com>
>> Cc: Alexis Lothoré <alexis.lothore@bootlin.com>
>> Cc: Claudiu Beznea <claudiu.beznea@tuxon.dev>
>> Cc: Conor Dooley <conor+dt@kernel.org>
>> Cc: Eric Dumazet <edumazet@google.com>
>> Cc: Jakub Kicinski <kuba@kernel.org>
>> Cc: Kalle Valo <kvalo@kernel.org>
>> Cc: Krzysztof Kozlowski <krzk+dt@kernel.org>
>> Cc: Marek Vasut <marex@denx.de>
>> Cc: Paolo Abeni <pabeni@redhat.com>
>> Cc: Rob Herring <robh@kernel.org>
>> Cc: devicetree@vger.kernel.org
>> Cc: linux-wireless@vger.kernel.org
>> Cc: netdev@vger.kernel.org
>> ---
>> V2: New patch
>> ---
>>   .../net/wireless/microchip/wilc1000/wlan.c    | 47 +++++++++----------
>>   .../net/wireless/microchip/wilc1000/wlan.h    |  2 -
>>   2 files changed, 23 insertions(+), 26 deletions(-)
>>
>> diff --git a/drivers/net/wireless/microchip/wilc1000/wlan.c b/drivers/net/wireless/microchip/wilc1000/wlan.c
>> index 1aab2f2dc159f..5fbba6876bd07 100644
>> --- a/drivers/net/wireless/microchip/wilc1000/wlan.c
>> +++ b/drivers/net/wireless/microchip/wilc1000/wlan.c
>> @@ -12,20 +12,6 @@
>>   
>>   #define WAKE_UP_TRIAL_RETRY		10000
>>   
>> -static inline void acquire_bus(struct wilc *wilc, enum bus_acquire acquire)
>> -{
>> -	mutex_lock(&wilc->hif_cs);
>> -	if (acquire == WILC_BUS_ACQUIRE_AND_WAKEUP && wilc->power_save_mode)
>> -		chip_wakeup(wilc);
>> -}
>> -
>> -static inline void release_bus(struct wilc *wilc, enum bus_release release)
>> -{
>> -	if (release == WILC_BUS_RELEASE_ALLOW_SLEEP && wilc->power_save_mode)
>> -		chip_allow_sleep(wilc);
>> -	mutex_unlock(&wilc->hif_cs);
>> -}
>> -
>>   static void wilc_wlan_txq_remove(struct wilc *wilc, u8 q_num,
>>   				 struct txq_entry_t *tqe)
>>   {
>> @@ -555,7 +541,7 @@ static struct rxq_entry_t *wilc_wlan_rxq_remove(struct wilc *wilc)
>>   	return rqe;
>>   }
>>   
>> -void chip_allow_sleep(struct wilc *wilc)
>> +static int chip_allow_sleep(struct wilc *wilc)
>>   {
>>   	u32 reg = 0;
>>   	const struct wilc_hif_func *hif_func = wilc->hif_func;
>> @@ -584,7 +570,7 @@ void chip_allow_sleep(struct wilc *wilc)
>>   	while (--trials) {
>>   		ret = hif_func->hif_read_reg(wilc, to_host_from_fw_reg, &reg);
>>   		if (ret)
>> -			return;
>> +			return ret;
> 
> Forwarding error codes sounds like a good idea, but neither this patch nor the
> next one is reading the return value from any chip_allow_sleep[XXX] function, so
> it does not bring much value.

I will add a follow up patch to this one which adds the error handling, 
since there is a lot of it to propagate the errors through. It will be 
in V3.
Marek Vasut Aug. 27, 2024, 4:31 p.m. UTC | #12
On 8/27/24 10:28 AM, Alexis Lothoré wrote:

Hi,

>> @@ -1467,6 +1604,20 @@ static int init_chip(struct net_device *dev)
>>   		}
>>   	}
>>   
>> +	if (is_wilc3000(wilc->chipid)) {
>> +		ret = wilc->hif_func->hif_read_reg(wilc, 0x207ac, &reg);
> 
> Some defines would be nice here instead of hardcoded addresses. I have asked
> Ajay about those while working on wilc3000, the meaning is roughly the following:
> - 0x000207ac: WILC_3000_BOOTROM_STATUS_REGISTER
> - 0x004f0000: WILC_3000_CORTUS_BOOT_REGISTER_2
> - 0x71: WILC_CORTUS_BOOT_FROM_IRAM

Fixed in V3, thanks.
Alexis Lothoré Aug. 28, 2024, 7:48 a.m. UTC | #13
On 8/27/24 17:34, Marek Vasut wrote:
> On 8/27/24 9:51 AM, Alexis Lothoré wrote:
> 
> Hi,
> 
>>> +static u32 wilc_get_chipid(struct wilc *wilc)
>>> +{
>>> +    u32 chipid = 0;
>>> +    u32 rfrevid = 0;
>>> +
>>> +    if (wilc->chipid == 0) {
>>> +        wilc->hif_func->hif_read_reg(wilc, WILC_CHIPID, &chipid);
>> If we search for WILC_CHIPID in the whole driver, there are still two places
>> manually reading this register. Shouldn't those places also benefit from
>> wilc_get_chipid ?
> 
> Both the one in wilc_wlan_start() and wilc_validate_chipid() look more like some
> sort of communication check attempt, rather than reading out the chipid for any
> sort of actual chip identification purpose. I could simply remove those ?

Agree about the purpose of this reading in wilc_wlan_start and wilc_validate_chipid.
And about removing those: I would say why not. wilc_validate_chipid has proven
to be quite useful to diagnose some early communication failure, but I guess
there are enough communications attempts around
(wilc_spi_configure_bus_protocol, wilc_load_mac_from_nv) to still validate than
we are able to communicate with the chip at probe time.
> 
>>> +        wilc->hif_func->hif_read_reg(wilc, WILC_RF_REVISION_ID,
>>> +                         &rfrevid);
>>> +        if (!is_wilc1000(chipid)) {
>>> +            wilc->chipid = 0;
>>
>> While at it, since you have trimmed the update parameter, it would be nice to
>> also fix this return value (ie make wilc_getchipid() not return 0 but a real
>> error code if we can not read the chip id.
> 
> Fixed in V3, thanks .

Great, thanks

Alexis
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/net/wireless/microchip,wilc1000.yaml b/Documentation/devicetree/bindings/net/wireless/microchip,wilc1000.yaml
index 2460ccc082371..b8ee6cdab3c25 100644
--- a/Documentation/devicetree/bindings/net/wireless/microchip,wilc1000.yaml
+++ b/Documentation/devicetree/bindings/net/wireless/microchip,wilc1000.yaml
@@ -16,7 +16,11 @@  description:
 
 properties:
   compatible:
-    const: microchip,wilc1000
+    oneOf:
+      - items:
+          - const: microchip,wilc1000
+          - const: microchip,wilc3000
+      - const: microchip,wilc1000
 
   reg: true