All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] leds: bcm63x8: improve read and write functions
@ 2021-02-24 10:11 Álvaro Fernández Rojas
  2021-02-24 10:11 ` [PATCH v2 1/2] leds: bcm6328: improve write and read functions Álvaro Fernández Rojas
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Álvaro Fernández Rojas @ 2021-02-24 10:11 UTC (permalink / raw)
  To: f.fainelli, jonas.gorski, Pavel Machek, Dan Murphy, linux-leds,
	linux-kernel
  Cc: Álvaro Fernández Rojas

This code is proven to work in BMIPS BE/LE and ARM BE/LE.
See bcm2835-rng and bcmgenet.c:
https://github.com/torvalds/linux/blob/3b9cdafb5358eb9f3790de2f728f765fef100731/drivers/char/hw_random/bcm2835-rng.c#L42-L60
https://github.com/torvalds/linux/blob/3b9cdafb5358eb9f3790de2f728f765fef100731/drivers/net/ethernet/broadcom/genet/bcmgenet.c#L71-L88

v2: fix comments style.

Álvaro Fernández Rojas (2):
  leds: bcm6328: improve write and read functions
  leds: bcm6358: improve write and read functions

 drivers/leds/leds-bcm6328.c | 26 ++++++++++++++------------
 drivers/leds/leds-bcm6358.c | 26 ++++++++++++++------------
 2 files changed, 28 insertions(+), 24 deletions(-)

-- 
2.20.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 1/2] leds: bcm6328: improve write and read functions
  2021-02-24 10:11 [PATCH v2 0/2] leds: bcm63x8: improve read and write functions Álvaro Fernández Rojas
@ 2021-02-24 10:11 ` Álvaro Fernández Rojas
  2021-02-24 15:43   ` Florian Fainelli
  2021-02-24 10:11 ` [PATCH v2 2/2] leds: bcm6358: " Álvaro Fernández Rojas
  2021-02-24 15:45 ` [PATCH v2 0/2] leds: bcm63x8: improve read and write functions Florian Fainelli
  2 siblings, 1 reply; 8+ messages in thread
From: Álvaro Fernández Rojas @ 2021-02-24 10:11 UTC (permalink / raw)
  To: f.fainelli, jonas.gorski, Pavel Machek, Dan Murphy, linux-leds,
	linux-kernel
  Cc: Álvaro Fernández Rojas

This is proven to work in BMIPS BE/LE and ARM BE/LE, as used in bcm2835-rng
and bcmgenet drivers.
Both should also be inline functions.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
---
 v2: Fix comment style.

 drivers/leds/leds-bcm6328.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/drivers/leds/leds-bcm6328.c b/drivers/leds/leds-bcm6328.c
index 226d17d253ed..595da15fc505 100644
--- a/drivers/leds/leds-bcm6328.c
+++ b/drivers/leds/leds-bcm6328.c
@@ -75,22 +75,24 @@ struct bcm6328_led {
 	bool active_low;
 };
 
-static void bcm6328_led_write(void __iomem *reg, unsigned long data)
+static inline void bcm6328_led_write(void __iomem *reg, unsigned long data)
 {
-#ifdef CONFIG_CPU_BIG_ENDIAN
-	iowrite32be(data, reg);
-#else
-	writel(data, reg);
-#endif
+	/*
+	 * MIPS chips strapped for BE will automagically configure the
+	 * peripheral registers for CPU-native byte order.
+	 */
+	if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(CONFIG_CPU_BIG_ENDIAN))
+		__raw_writel(data, reg);
+	else
+		writel_relaxed(data, reg);
 }
 
-static unsigned long bcm6328_led_read(void __iomem *reg)
+static inline unsigned long bcm6328_led_read(void __iomem *reg)
 {
-#ifdef CONFIG_CPU_BIG_ENDIAN
-	return ioread32be(reg);
-#else
-	return readl(reg);
-#endif
+	if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(CONFIG_CPU_BIG_ENDIAN))
+		return __raw_readl(reg);
+	else
+		return readl_relaxed(reg);
 }
 
 /**
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 2/2] leds: bcm6358: improve write and read functions
  2021-02-24 10:11 [PATCH v2 0/2] leds: bcm63x8: improve read and write functions Álvaro Fernández Rojas
  2021-02-24 10:11 ` [PATCH v2 1/2] leds: bcm6328: improve write and read functions Álvaro Fernández Rojas
@ 2021-02-24 10:11 ` Álvaro Fernández Rojas
  2021-02-24 15:43   ` Florian Fainelli
  2021-02-24 15:45 ` [PATCH v2 0/2] leds: bcm63x8: improve read and write functions Florian Fainelli
  2 siblings, 1 reply; 8+ messages in thread
From: Álvaro Fernández Rojas @ 2021-02-24 10:11 UTC (permalink / raw)
  To: f.fainelli, jonas.gorski, Pavel Machek, Dan Murphy, linux-leds,
	linux-kernel
  Cc: Álvaro Fernández Rojas

This is proven to work in BMIPS BE/LE and ARM BE/LE, as used in bcm2835-rng
and bcmgenet drivers.
Both should also be inline functions.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
---
 v2: Fix comment style.

 drivers/leds/leds-bcm6358.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)

diff --git a/drivers/leds/leds-bcm6358.c b/drivers/leds/leds-bcm6358.c
index 9d2e487fa08a..37d27b7c58a8 100644
--- a/drivers/leds/leds-bcm6358.c
+++ b/drivers/leds/leds-bcm6358.c
@@ -43,22 +43,24 @@ struct bcm6358_led {
 	bool active_low;
 };
 
-static void bcm6358_led_write(void __iomem *reg, unsigned long data)
+static inline void bcm6358_led_write(void __iomem *reg, unsigned long data)
 {
-#ifdef CONFIG_CPU_BIG_ENDIAN
-	iowrite32be(data, reg);
-#else
-	writel(data, reg);
-#endif
+	/*
+	 * MIPS chips strapped for BE will automagically configure the
+	 * peripheral registers for CPU-native byte order.
+	 */
+	if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(CONFIG_CPU_BIG_ENDIAN))
+		__raw_writel(data, reg);
+	else
+		writel_relaxed(data, reg);
 }
 
-static unsigned long bcm6358_led_read(void __iomem *reg)
+static inline unsigned long bcm6358_led_read(void __iomem *reg)
 {
-#ifdef CONFIG_CPU_BIG_ENDIAN
-	return ioread32be(reg);
-#else
-	return readl(reg);
-#endif
+	if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(CONFIG_CPU_BIG_ENDIAN))
+		return __raw_readl(reg);
+	else
+		return readl_relaxed(reg);
 }
 
 static unsigned long bcm6358_led_busy(void __iomem *mem)
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 1/2] leds: bcm6328: improve write and read functions
  2021-02-24 10:11 ` [PATCH v2 1/2] leds: bcm6328: improve write and read functions Álvaro Fernández Rojas
@ 2021-02-24 15:43   ` Florian Fainelli
  0 siblings, 0 replies; 8+ messages in thread
From: Florian Fainelli @ 2021-02-24 15:43 UTC (permalink / raw)
  To: Álvaro Fernández Rojas, jonas.gorski, Pavel Machek,
	Dan Murphy, linux-leds, linux-kernel



On 2/24/2021 2:11 AM, Álvaro Fernández Rojas wrote:
> This is proven to work in BMIPS BE/LE and ARM BE/LE, as used in bcm2835-rng
> and bcmgenet drivers.
> Both should also be inline functions.
> 
> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>

Acked-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 2/2] leds: bcm6358: improve write and read functions
  2021-02-24 10:11 ` [PATCH v2 2/2] leds: bcm6358: " Álvaro Fernández Rojas
@ 2021-02-24 15:43   ` Florian Fainelli
  0 siblings, 0 replies; 8+ messages in thread
From: Florian Fainelli @ 2021-02-24 15:43 UTC (permalink / raw)
  To: Álvaro Fernández Rojas, jonas.gorski, Pavel Machek,
	Dan Murphy, linux-leds, linux-kernel



On 2/24/2021 2:11 AM, Álvaro Fernández Rojas wrote:
> This is proven to work in BMIPS BE/LE and ARM BE/LE, as used in bcm2835-rng
> and bcmgenet drivers.
> Both should also be inline functions.
> 
> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>

Acked-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 0/2] leds: bcm63x8: improve read and write functions
  2021-02-24 10:11 [PATCH v2 0/2] leds: bcm63x8: improve read and write functions Álvaro Fernández Rojas
  2021-02-24 10:11 ` [PATCH v2 1/2] leds: bcm6328: improve write and read functions Álvaro Fernández Rojas
  2021-02-24 10:11 ` [PATCH v2 2/2] leds: bcm6358: " Álvaro Fernández Rojas
@ 2021-02-24 15:45 ` Florian Fainelli
  2021-02-24 15:54   ` Álvaro Fernández Rojas
  2 siblings, 1 reply; 8+ messages in thread
From: Florian Fainelli @ 2021-02-24 15:45 UTC (permalink / raw)
  To: Álvaro Fernández Rojas, jonas.gorski, Pavel Machek,
	Dan Murphy, linux-leds, linux-kernel



On 2/24/2021 2:11 AM, Álvaro Fernández Rojas wrote:
> This code is proven to work in BMIPS BE/LE and ARM BE/LE.
> See bcm2835-rng and bcmgenet.c:
> https://github.com/torvalds/linux/blob/3b9cdafb5358eb9f3790de2f728f765fef100731/drivers/char/hw_random/bcm2835-rng.c#L42-L60
> https://github.com/torvalds/linux/blob/3b9cdafb5358eb9f3790de2f728f765fef100731/drivers/net/ethernet/broadcom/genet/bcmgenet.c#L71-L88

What is the motivation for doing this? bcm2835-rng and bcmgenet are used
across MIPS and ARM platforms therefore they need to be compatible with
both, but these two LEDs drivers are super specialized, are you working
on porting the 6328 LED driver to the newer ARM-based DSL SoCs such as
63138 and 63148?
-- 
Florian

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 0/2] leds: bcm63x8: improve read and write functions
  2021-02-24 15:45 ` [PATCH v2 0/2] leds: bcm63x8: improve read and write functions Florian Fainelli
@ 2021-02-24 15:54   ` Álvaro Fernández Rojas
  2021-02-24 17:43     ` Florian Fainelli
  0 siblings, 1 reply; 8+ messages in thread
From: Álvaro Fernández Rojas @ 2021-02-24 15:54 UTC (permalink / raw)
  To: Florian Fainelli
  Cc: Jonas Gorski, Pavel Machek, Dan Murphy, linux-leds, linux-kernel

Hi Florian,

> El 24 feb 2021, a las 16:45, Florian Fainelli <f.fainelli@gmail.com> escribió:
> 
> 
> 
> On 2/24/2021 2:11 AM, Álvaro Fernández Rojas wrote:
>> This code is proven to work in BMIPS BE/LE and ARM BE/LE.
>> See bcm2835-rng and bcmgenet.c:
>> https://github.com/torvalds/linux/blob/3b9cdafb5358eb9f3790de2f728f765fef100731/drivers/char/hw_random/bcm2835-rng.c#L42-L60
>> https://github.com/torvalds/linux/blob/3b9cdafb5358eb9f3790de2f728f765fef100731/drivers/net/ethernet/broadcom/genet/bcmgenet.c#L71-L88
> 
> What is the motivation for doing this? bcm2835-rng and bcmgenet are used
> across MIPS and ARM platforms therefore they need to be compatible with
> both, but these two LEDs drivers are super specialized, are you working
> on porting the 6328 LED driver to the newer ARM-based DSL SoCs such as
> 63138 and 63148?

I just wanted to have all bmips drivers in line (at least regarding read/write).
If I remember correctly someone told me that this controller was also present on some little endian SoCs, but you can confirm that :).
Unfortunately I haven’t got any devices with ARM-based DSL SoCs, so the answer is no.

> -- 
> Florian

Best regards,
Álvaro.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 0/2] leds: bcm63x8: improve read and write functions
  2021-02-24 15:54   ` Álvaro Fernández Rojas
@ 2021-02-24 17:43     ` Florian Fainelli
  0 siblings, 0 replies; 8+ messages in thread
From: Florian Fainelli @ 2021-02-24 17:43 UTC (permalink / raw)
  To: Álvaro Fernández Rojas
  Cc: Jonas Gorski, Pavel Machek, Dan Murphy, linux-leds, linux-kernel



On 2/24/2021 7:54 AM, Álvaro Fernández Rojas wrote:
> Hi Florian,
> 
>> El 24 feb 2021, a las 16:45, Florian Fainelli <f.fainelli@gmail.com> escribió:
>>
>>
>>
>> On 2/24/2021 2:11 AM, Álvaro Fernández Rojas wrote:
>>> This code is proven to work in BMIPS BE/LE and ARM BE/LE.
>>> See bcm2835-rng and bcmgenet.c:
>>> https://github.com/torvalds/linux/blob/3b9cdafb5358eb9f3790de2f728f765fef100731/drivers/char/hw_random/bcm2835-rng.c#L42-L60
>>> https://github.com/torvalds/linux/blob/3b9cdafb5358eb9f3790de2f728f765fef100731/drivers/net/ethernet/broadcom/genet/bcmgenet.c#L71-L88
>>
>> What is the motivation for doing this? bcm2835-rng and bcmgenet are used
>> across MIPS and ARM platforms therefore they need to be compatible with
>> both, but these two LEDs drivers are super specialized, are you working
>> on porting the 6328 LED driver to the newer ARM-based DSL SoCs such as
>> 63138 and 63148?
> 
> I just wanted to have all bmips drivers in line (at least regarding read/write).
> If I remember correctly someone told me that this controller was also present on some little endian SoCs, but you can confirm that :).
> Unfortunately I haven’t got any devices with ARM-based DSL SoCs, so the answer is no.

The 6328 LED controller could be utilized on the ARM-based DSL SoCs,
however 6358 will not, so changing the I/O accessors for that driver
sounds like just code churn to me.
-- 
Florian

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-02-24 17:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-24 10:11 [PATCH v2 0/2] leds: bcm63x8: improve read and write functions Álvaro Fernández Rojas
2021-02-24 10:11 ` [PATCH v2 1/2] leds: bcm6328: improve write and read functions Álvaro Fernández Rojas
2021-02-24 15:43   ` Florian Fainelli
2021-02-24 10:11 ` [PATCH v2 2/2] leds: bcm6358: " Álvaro Fernández Rojas
2021-02-24 15:43   ` Florian Fainelli
2021-02-24 15:45 ` [PATCH v2 0/2] leds: bcm63x8: improve read and write functions Florian Fainelli
2021-02-24 15:54   ` Álvaro Fernández Rojas
2021-02-24 17:43     ` Florian Fainelli

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.