Re: [RFC] inkscape 1.0 issue

2020-06-02 Thread Antony Pavlov
On Tue, 2 Jun 2020 09:51:28 +0200
Sascha Hauer  wrote:

> Hi Antony,
> 
> On Tue, Jun 02, 2020 at 01:20:35AM +0300, Antony Pavlov wrote:
> > 
> > diff --git a/lib/logo/Makefile b/lib/logo/Makefile
> > index eb7aee080e..8c81447df7 100644
> > --- a/lib/logo/Makefile
> > +++ b/lib/logo/Makefile
> > @@ -1,17 +1,17 @@
> >  
> > -OPTS_barebox-logo-w64.bblogo="-w 64"
> > +OPTS_barebox-logo-w64.bblogo = --export-width=64
> >  bblogo-$(CONFIG_BAREBOX_LOGO_64) += barebox-logo-w64
> 
> according to the man page --export-width=64 is supported by 0.92.4 as
> well, so we could change this part unconditionally.
> 
> > @@ -41,7 +41,8 @@ cmd_logo_S =  
> > \
> >  quiet_cmd_logo = LOGO.S   $@
> >  cmd_logo = \
> >  (  \
> > -   inkscape -z $(OPTS_$(@F)) -e $@ $< > /dev/null; \
> > +   DISPLAY="" inkscape $(OPTS_$(@F)) --export-type=png $< > /dev/null; \
> > +   mv $(patsubst %.svg,%.png,$<) $@; \
> 
> Inkscape-1.0 supports "-o -" and pre Inkscape-1.0 supports "-e -", we
> could use this to do without the mv in both cases.
> 
> DISPLAY="" shouldn't hurt on pre Inkscape-1.0. as well.
> 
> This leaves '-z' and -e vs. --export-type=png. Something like this should 
> work:
> 
> INKSCAPEOPTS += $(call try-run, inkscape -z,-z,)
> INKSCAPEOPTS += $(call try-run, inkscape -e,-e,--export_type=png)
> 

Can we move all inkscape-related stuff into separate svg2bblogo.sh script
and just call script from makefile?

-- 
Best regards,
  Antony Pavlov

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH] ARM: MXS: duckbill: set duart to serial0

2020-06-02 Thread Michael Grzeschik

On Fri, May 29, 2020 at 03:56:53PM +0200, Lucas Stach wrote:

Am Freitag, den 29.05.2020, 14:51 +0200 schrieb Michael Grzeschik:

In the imx28.dtsi the serial0 is set to auart0 which is not the one
used on the duckbill. We set duart to serial0 so the console will be
properly set.


If the aliases are the same in the Barebox and Linux DTs there should
be no need to override the alias numbering in the individual board DTs.

Is the Linux driver ignoring the alias, or what is the issue being
fixed here?


The duart (debugging uart) is completely missing in the aliases list.
The first set serial alias in dts/src/arm/imx28.dtsi is auart0, which
are the application uarts.

mgr


Signed-off-by: Michael Grzeschik 
---
 arch/arm/dts/imx28-duckbill.dts | 4 
 1 file changed, 4 insertions(+)

diff --git a/arch/arm/dts/imx28-duckbill.dts b/arch/arm/dts/imx28-
duckbill.dts
index 2a995a7938..299c33e270 100644
--- a/arch/arm/dts/imx28-duckbill.dts
+++ b/arch/arm/dts/imx28-duckbill.dts
@@ -4,6 +4,10 @@
chosen {
stdout-path = 
};
+
+   aliases {
+   serial0 = 
+   };
 };

  {





--
Pengutronix e.K.   | |
Steuerwalder Str. 21   | http://www.pengutronix.de/  |
31137 Hildesheim, Germany  | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |


signature.asc
Description: PGP signature
___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: Mini UART support for Raspberry Pi CM3 ?

2020-06-02 Thread Ahmad Fatoum
On 6/2/20 11:57 AM, j...@mobius-embedded-systems.co.uk wrote:
> Hi Ahmad
> 
> I have been using v2020.05 but I believe I had enabled all consoles so I'll
> try setting it to none and see how that goes.

This will only fix the use of UART0 as output. To use UART1, you'll need
to set stdout-path =  like ab76f9d09d3b ("ARM: rpi: choose miniuart as
stdout") does.

Cheers
Ahmad

> 
> Thanks
> 
> John
> 
> -Original Message-
> From: barebox  On Behalf Of Ahmad
> Fatoum
> Sent: 02 June 2020 10:55
> To: j...@mobius-embedded-systems.co.uk
> ; barebox@lists.infradead.org
> Subject: Re: Mini UART support for Raspberry Pi CM3 ?
> 
> On 6/2/20 11:43 AM, Ahmad Fatoum wrote:
>> On 6/2/20 11:14 AM, j...@mobius-embedded-systems.co.uk wrote:
>>> Hi
>>>
>>> I have been trying to get the mini UART (UART1) to work in Barebox on 
>>> the RPI Compute Module 3+.  I already have the changes made in 
>>> config.txt and this works fine when I boot into the main Linux code.  
>>> However, in Barebox, the output always comes out on the main UART 
>>> (UART0) and that is wired to the Bluetooth module on my platform.  I have
> tried modifying the device
>>> trees and cannot seem to get any output.   I also ensured that I added
> the
>>> RPI CM3 output target as a config in rpi_defconfig.   
>>>
>>> I've tried turning off the PL011 config option and also changing the 
>>> device tree to reference UART1 and set the chosen stdout-path to 
>>> point to this UART, but when I do this I just get a lack of any serial
> output.
>>>
>>> I am also wanting to use the alternate pins (32 & 33) for UART1, so I 
>>> am thinking that something else needs to be changed.  Has anyone 
>>> managed to get this to work?
>>
>> Which barebox version are you on? v2020.03.0 contains a series for 
>> mini UART support culminating in ab76f9d09d3b ("ARM: rpi: choose 
>> miniuart as stdout"), which sounds like something you will want to have.
> 
> Oh, I see now that this is in since v2019.03.0. I assume you are already on
> a newer version?
> 
>> Also what's you "Console activation strategy"? (Kconfig symbols
>> CONSOLE_ACTIVATE_.*) You'll want to have CONSOLE_ACTIVATE_NONE, so 
>> only the stdout-path from the device tree is activated by default.
>>
>> Cheers
>> Ahmad
>>
>>>
>>> Regards
>>>
>>> John
>>>
>>>
>>> ___
>>> barebox mailing list
>>> barebox@lists.infradead.org
>>> http://lists.infradead.org/mailman/listinfo/barebox
>>>
>>
> 

-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | http://www.pengutronix.de/  |
31137 Hildesheim, Germany  | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


RE: Mini UART support for Raspberry Pi CM3 ?

2020-06-02 Thread j...@mobius-embedded-systems.co.uk
Hi Ahmad

I have been using v2020.05 but I believe I had enabled all consoles so I'll
try setting it to none and see how that goes.

Thanks

John

-Original Message-
From: barebox  On Behalf Of Ahmad
Fatoum
Sent: 02 June 2020 10:55
To: j...@mobius-embedded-systems.co.uk
; barebox@lists.infradead.org
Subject: Re: Mini UART support for Raspberry Pi CM3 ?

On 6/2/20 11:43 AM, Ahmad Fatoum wrote:
> On 6/2/20 11:14 AM, j...@mobius-embedded-systems.co.uk wrote:
>> Hi
>>
>> I have been trying to get the mini UART (UART1) to work in Barebox on 
>> the RPI Compute Module 3+.  I already have the changes made in 
>> config.txt and this works fine when I boot into the main Linux code.  
>> However, in Barebox, the output always comes out on the main UART 
>> (UART0) and that is wired to the Bluetooth module on my platform.  I have
tried modifying the device
>> trees and cannot seem to get any output.   I also ensured that I added
the
>> RPI CM3 output target as a config in rpi_defconfig.   
>>
>> I've tried turning off the PL011 config option and also changing the 
>> device tree to reference UART1 and set the chosen stdout-path to 
>> point to this UART, but when I do this I just get a lack of any serial
output.
>>
>> I am also wanting to use the alternate pins (32 & 33) for UART1, so I 
>> am thinking that something else needs to be changed.  Has anyone 
>> managed to get this to work?
> 
> Which barebox version are you on? v2020.03.0 contains a series for 
> mini UART support culminating in ab76f9d09d3b ("ARM: rpi: choose 
> miniuart as stdout"), which sounds like something you will want to have.

Oh, I see now that this is in since v2019.03.0. I assume you are already on
a newer version?

> Also what's you "Console activation strategy"? (Kconfig symbols
> CONSOLE_ACTIVATE_.*) You'll want to have CONSOLE_ACTIVATE_NONE, so 
> only the stdout-path from the device tree is activated by default.
> 
> Cheers
> Ahmad
> 
>>
>> Regards
>>
>> John
>>
>>
>> ___
>> barebox mailing list
>> barebox@lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/barebox
>>
> 

-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | http://www.pengutronix.de/  |
31137 Hildesheim, Germany  | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: Mini UART support for Raspberry Pi CM3 ?

2020-06-02 Thread Ahmad Fatoum
On 6/2/20 11:43 AM, Ahmad Fatoum wrote:
> On 6/2/20 11:14 AM, j...@mobius-embedded-systems.co.uk wrote:
>> Hi
>>
>> I have been trying to get the mini UART (UART1) to work in Barebox on the
>> RPI Compute Module 3+.  I already have the changes made in config.txt and
>> this works fine when I boot into the main Linux code.  However, in Barebox,
>> the output always comes out on the main UART (UART0) and that is wired to
>> the Bluetooth module on my platform.  I have tried modifying the device
>> trees and cannot seem to get any output.   I also ensured that I added the
>> RPI CM3 output target as a config in rpi_defconfig.   
>>
>> I've tried turning off the PL011 config option and also changing the device
>> tree to reference UART1 and set the chosen stdout-path to point to this
>> UART, but when I do this I just get a lack of any serial output.
>>
>> I am also wanting to use the alternate pins (32 & 33) for UART1, so I am
>> thinking that something else needs to be changed.  Has anyone managed to get
>> this to work?
> 
> Which barebox version are you on? v2020.03.0 contains a series for mini UART
> support culminating in ab76f9d09d3b ("ARM: rpi: choose miniuart as stdout"),
> which sounds like something you will want to have.

Oh, I see now that this is in since v2019.03.0. I assume you are already
on a newer version?

> Also what's you "Console activation strategy"? (Kconfig symbols
> CONSOLE_ACTIVATE_.*) You'll want to have CONSOLE_ACTIVATE_NONE, so only
> the stdout-path from the device tree is activated by default.
> 
> Cheers
> Ahmad
> 
>>
>> Regards
>>
>> John
>>
>>
>> ___
>> barebox mailing list
>> barebox@lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/barebox
>>
> 

-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | http://www.pengutronix.de/  |
31137 Hildesheim, Germany  | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: Mini UART support for Raspberry Pi CM3 ?

2020-06-02 Thread Ahmad Fatoum
On 6/2/20 11:14 AM, j...@mobius-embedded-systems.co.uk wrote:
> Hi
> 
> I have been trying to get the mini UART (UART1) to work in Barebox on the
> RPI Compute Module 3+.  I already have the changes made in config.txt and
> this works fine when I boot into the main Linux code.  However, in Barebox,
> the output always comes out on the main UART (UART0) and that is wired to
> the Bluetooth module on my platform.  I have tried modifying the device
> trees and cannot seem to get any output.   I also ensured that I added the
> RPI CM3 output target as a config in rpi_defconfig.   
> 
> I've tried turning off the PL011 config option and also changing the device
> tree to reference UART1 and set the chosen stdout-path to point to this
> UART, but when I do this I just get a lack of any serial output.
> 
> I am also wanting to use the alternate pins (32 & 33) for UART1, so I am
> thinking that something else needs to be changed.  Has anyone managed to get
> this to work?

Which barebox version are you on? v2020.03.0 contains a series for mini UART
support culminating in ab76f9d09d3b ("ARM: rpi: choose miniuart as stdout"),
which sounds like something you will want to have.

Also what's you "Console activation strategy"? (Kconfig symbols
CONSOLE_ACTIVATE_.*) You'll want to have CONSOLE_ACTIVATE_NONE, so only
the stdout-path from the device tree is activated by default.

Cheers
Ahmad

> 
> Regards
> 
> John
> 
> 
> ___
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | http://www.pengutronix.de/  |
31137 Hildesheim, Germany  | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Mini UART support for Raspberry Pi CM3 ?

2020-06-02 Thread j...@mobius-embedded-systems.co.uk
Hi

I have been trying to get the mini UART (UART1) to work in Barebox on the
RPI Compute Module 3+.  I already have the changes made in config.txt and
this works fine when I boot into the main Linux code.  However, in Barebox,
the output always comes out on the main UART (UART0) and that is wired to
the Bluetooth module on my platform.  I have tried modifying the device
trees and cannot seem to get any output.   I also ensured that I added the
RPI CM3 output target as a config in rpi_defconfig.   

I've tried turning off the PL011 config option and also changing the device
tree to reference UART1 and set the chosen stdout-path to point to this
UART, but when I do this I just get a lack of any serial output.

I am also wanting to use the alternate pins (32 & 33) for UART1, so I am
thinking that something else needs to be changed.  Has anyone managed to get
this to work?

Regards

John


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2 23/25] commands: test: drop dead assignment

2020-06-02 Thread Ahmad Fatoum
last_expr is set to a different value few lines later. Drop the dead
assignment.

Signed-off-by: Ahmad Fatoum 
---
 commands/test.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/commands/test.c b/commands/test.c
index 505b7c56b1a4..c845cec01789 100644
--- a/commands/test.c
+++ b/commands/test.c
@@ -86,7 +86,6 @@ static int do_test(int argc, char *argv[])
if (argc < 2)
return 1;
 
-   last_expr = 0;
left = argc - 1;
ap = argv + 1;
 
-- 
2.27.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2 21/25] include: bitops: fix dead increment in fls() and ffs()

2020-06-02 Thread Ahmad Fatoum
Static analyzers trip over this dead increment. It arguably
doesn't improve readability, so just drop the dead code.

Signed-off-by: Ahmad Fatoum 
---
 include/asm-generic/bitops/ffs.h | 4 +---
 include/asm-generic/bitops/fls.h | 4 +---
 2 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/include/asm-generic/bitops/ffs.h b/include/asm-generic/bitops/ffs.h
index fbbb43af7dc0..0ff1b8b7c79a 100644
--- a/include/asm-generic/bitops/ffs.h
+++ b/include/asm-generic/bitops/ffs.h
@@ -31,10 +31,8 @@ static inline int ffs(int x)
x >>= 2;
r += 2;
}
-   if (!(x & 1)) {
-   x >>= 1;
+   if (!(x & 1))
r += 1;
-   }
return r;
 }
 
diff --git a/include/asm-generic/bitops/fls.h b/include/asm-generic/bitops/fls.h
index 850859bc5069..cc0d3ca95aaa 100644
--- a/include/asm-generic/bitops/fls.h
+++ b/include/asm-generic/bitops/fls.h
@@ -31,10 +31,8 @@ static inline int fls(int x)
x <<= 2;
r -= 2;
}
-   if (!(x & 0x8000u)) {
-   x <<= 1;
+   if (!(x & 0x8000u))
r -= 1;
-   }
return r;
 }
 
-- 
2.27.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2 20/25] usb: xhci-hcd: replace opencoded non-atomic 64-bit MMIO with lo_hi helper

2020-06-02 Thread Ahmad Fatoum
Commit 3c5317e9046 ("usb: xhci-hcd: Make use of lo_hi_readq/writeq()")
had made use of lo_hi_readq/writeq() to implement xhci_read/write_64(),
like Linux does, but this was removed in commit fddd1c7c51a8
("usb: host: remove xhci driver"). Reinstate it to make code clearer.

No functional change.

[Note: Linux doesn't use any readq/writeq, but does two 32-bit access
 always, even on 64-bit systems]

Signed-off-by: Ahmad Fatoum 
---
 drivers/usb/host/xhci.h | 13 +++--
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 1a3f7e7642bc..9ffbb103d562 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -18,6 +18,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #define MAX_EP_CTX_NUM 31
@@ -1112,10 +1113,7 @@ static inline u64 xhci_readq(__le64 volatile *regs)
 #if BITS_PER_LONG == 64
return readq(regs);
 #else
-   __u32 *ptr = (__u32 *)regs;
-   u64 val_lo = readl(ptr);
-   u64 val_hi = readl(ptr + 1);
-   return val_lo + (val_hi << 32);
+   return lo_hi_readq(regs);
 #endif
 }
 
@@ -1124,12 +1122,7 @@ static inline void xhci_writeq(__le64 volatile *regs, 
const u64 val)
 #if BITS_PER_LONG == 64
writeq(val, regs);
 #else
-   __u32 *ptr = (__u32 *)regs;
-   u32 val_lo = lower_32_bits(val);
-   /* FIXME */
-   u32 val_hi = upper_32_bits(val);
-   writel(val_lo, ptr);
-   writel(val_hi, ptr + 1);
+   lo_hi_writeq(val, regs);
 #endif
 }
 
-- 
2.27.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2 14/25] sandbox: asm: implement stub DMA functions

2020-06-02 Thread Ahmad Fatoum
For compile-testing drivers that use DMA operations under sandbox,
we want stub implementations of these. Provide them.

Signed-off-by: Ahmad Fatoum 
---
 arch/sandbox/include/asm/dma.h | 53 +-
 1 file changed, 52 insertions(+), 1 deletion(-)

diff --git a/arch/sandbox/include/asm/dma.h b/arch/sandbox/include/asm/dma.h
index 459536779e0a..5e72d8e7df2d 100644
--- a/arch/sandbox/include/asm/dma.h
+++ b/arch/sandbox/include/asm/dma.h
@@ -8,6 +8,57 @@
 #ifndef __ASM_DMA_H
 #define __ASM_DMA_H
 
-/* empty*/
+#include 
+#include 
+#include 
+
+#define dma_alloc dma_alloc
+static inline void *dma_alloc(size_t size)
+{
+   return xmemalign(64, ALIGN(size, 64));
+}
+
+static inline void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle)
+{
+   void *ret = xmemalign(4096, size);
+   if (dma_handle)
+   *dma_handle = (dma_addr_t)ret;
+
+   memset(ret, 0, size);
+
+   return ret;
+}
+
+static inline void *dma_alloc_writecombine(size_t size, dma_addr_t *dma_handle)
+{
+   return dma_alloc_coherent(size, dma_handle);
+}
+
+static inline void dma_free_coherent(void *mem, dma_addr_t dma_handle,
+size_t size)
+{
+   free(mem);
+}
+
+static inline dma_addr_t dma_map_single(struct device_d *dev, void *ptr, 
size_t size,
+   enum dma_data_direction dir)
+{
+   return (dma_addr_t)ptr;
+}
+
+static inline void dma_unmap_single(struct device_d *dev, dma_addr_t addr, 
size_t size,
+   enum dma_data_direction dir)
+{
+}
+
+static inline void dma_sync_single_for_cpu(dma_addr_t address, size_t size,
+  enum dma_data_direction dir)
+{
+}
+
+static inline void dma_sync_single_for_device(dma_addr_t address, size_t size,
+ enum dma_data_direction dir)
+{
+}
 
 #endif /* __ASM_DMA_H */
-- 
2.27.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2 19/25] usb: xhci-hcd: remove unused #include

2020-06-02 Thread Ahmad Fatoum
We don't use anything defined within, so drop it.

Signed-off-by: Ahmad Fatoum 
---
 drivers/usb/host/xhci.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h
index 886cbef14c3a..1a3f7e7642bc 100644
--- a/drivers/usb/host/xhci.h
+++ b/drivers/usb/host/xhci.h
@@ -17,7 +17,6 @@
 #define HOST_XHCI_H_
 
 #include 
-#include 
 #include 
 #include 
 
-- 
2.27.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2 11/25] net: fec_imx: depend on HAS_DMA

2020-06-02 Thread Ahmad Fatoum
The driver makes use of dma_alloc_coherent and brethren. Depend on
HAS_DMA to be sure, we don't run into link errors when compile-testing.

Signed-off-by: Ahmad Fatoum 
---
 drivers/net/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 9bb498527557..ee8a716d9a3d 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -155,6 +155,7 @@ config DRIVER_NET_ETHOC
 config DRIVER_NET_FEC_IMX
bool "i.MX FEC Ethernet driver"
depends on ARCH_HAS_FEC_IMX || COMPILE_TEST
+   depends on HAS_DMA
select PHYLIB
 
 config DRIVER_NET_FSL_FMAN
-- 
2.27.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2 06/25] ARM: asm/io.h: fall back to out_be32 and friends

2020-06-02 Thread Ahmad Fatoum
With the generic implementations in place in , we can
drop the now-duplicate ARM definitions.

Signed-off-by: Ahmad Fatoum 
---
 arch/arm/include/asm/io.h | 58 +--
 1 file changed, 1 insertion(+), 57 deletions(-)

diff --git a/arch/arm/include/asm/io.h b/arch/arm/include/asm/io.h
index 56db5463410e..072b47317c03 100644
--- a/arch/arm/include/asm/io.h
+++ b/arch/arm/include/asm/io.h
@@ -4,6 +4,7 @@
 #defineIO_SPACE_LIMIT  0
 
 #include 
+#include 
 
 /*
  * String version of IO memory access ops:
@@ -12,63 +13,6 @@ extern void memcpy_fromio(void *, const volatile void 
__iomem *, size_t);
 extern void memcpy_toio(volatile void __iomem *, const void *, size_t);
 extern void memset_io(volatile void __iomem *, int, size_t);
 
-/*
- * Clear and set bits in one shot. These macros can be used to clear and
- * set multiple bits in a register using a single call. These macros can
- * also be used to set a multiple-bit bit pattern using a mask, by
- * specifying the mask in the 'clear' parameter and the new bit pattern
- * in the 'set' parameter.
- */
-
-#define out_arch(type,endian,a,v)  __raw_write##type(cpu_to_##endian(v),a)
-#define in_arch(type,endian,a) endian##_to_cpu(__raw_read##type(a))
-
-#define out_le64(a,v)  out_arch(q,le64,a,v)
-#define out_le32(a,v)  out_arch(l,le32,a,v)
-#define out_le16(a,v)  out_arch(w,le16,a,v)
-
-#define in_le64(a) in_arch(q,le64,a)
-#define in_le32(a) in_arch(l,le32,a)
-#define in_le16(a) in_arch(w,le16,a)
-
-#define out_be32(a,v)  out_arch(l,be32,a,v)
-#define out_be16(a,v)  out_arch(w,be16,a,v)
-
-#define in_be32(a) in_arch(l,be32,a)
-#define in_be16(a) in_arch(w,be16,a)
-
-#define out_8(a,v) __raw_writeb(v,a)
-#define in_8(a)__raw_readb(a)
-
-#define clrbits(type, addr, clear) \
-   out_##type((addr), in_##type(addr) & ~(clear))
-
-#define setbits(type, addr, set) \
-   out_##type((addr), in_##type(addr) | (set))
-
-#define clrsetbits(type, addr, clear, set) \
-   out_##type((addr), (in_##type(addr) & ~(clear)) | (set))
-
-#define clrbits_be32(addr, clear) clrbits(be32, addr, clear)
-#define setbits_be32(addr, set) setbits(be32, addr, set)
-#define clrsetbits_be32(addr, clear, set) clrsetbits(be32, addr, clear, set)
-
-#define clrbits_le32(addr, clear) clrbits(le32, addr, clear)
-#define setbits_le32(addr, set) setbits(le32, addr, set)
-#define clrsetbits_le32(addr, clear, set) clrsetbits(le32, addr, clear, set)
-
-#define clrbits_be16(addr, clear) clrbits(be16, addr, clear)
-#define setbits_be16(addr, set) setbits(be16, addr, set)
-#define clrsetbits_be16(addr, clear, set) clrsetbits(be16, addr, clear, set)
-
-#define clrbits_le16(addr, clear) clrbits(le16, addr, clear)
-#define setbits_le16(addr, set) setbits(le16, addr, set)
-#define clrsetbits_le16(addr, clear, set) clrsetbits(le16, addr, clear, set)
-
-#define clrbits_8(addr, clear) clrbits(8, addr, clear)
-#define setbits_8(addr, set) setbits(8, addr, set)
-#define clrsetbits_8(addr, clear, set) clrsetbits(8, addr, clear, set)
-
 static inline void *phys_to_virt(unsigned long phys)
 {
return (void *)phys;
-- 
2.27.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2 16/25] ARM: atomic.h: move generic implementation to asm-generic

2020-06-02 Thread Ahmad Fatoum
For easier code-sharing, the UBIFS code still uses the Linux atomic
accessors.  Make porting it to sandbox easier, by providing these
functions for all platforms.

Signed-off-by: Ahmad Fatoum 
---
 arch/arm/include/asm/atomic.h | 108 +-
 include/asm-generic/atomic.h  |  99 +++
 2 files changed, 102 insertions(+), 105 deletions(-)
 create mode 100644 include/asm-generic/atomic.h

diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
index 9b79506b594b..cfc359a5ce59 100644
--- a/arch/arm/include/asm/atomic.h
+++ b/arch/arm/include/asm/atomic.h
@@ -1,111 +1,9 @@
-/*
- *  linux/include/asm-arm/atomic.h
- *
- *  Copyright (c) 1996 Russell King.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- *  Changelog:
- *   27-06-1996RMK Created
- *   13-04-1997RMK Made functions atomic!
- *   07-12-1997RMK Upgraded for v2.1.
- *   26-08-1998PJB Added #ifdef __KERNEL__
- */
+// SPDX-License-Identifier: GPL-2.0-only
+
 #ifndef __ASM_ARM_ATOMIC_H
 #define __ASM_ARM_ATOMIC_H
 
-#ifdef CONFIG_SMP
-#error SMP not supported
-#endif
-
-typedef struct { volatile int counter; } atomic_t;
-
-#define ATOMIC_INIT(i) { (i) }
-
-#ifdef __KERNEL__
 #include 
+#include 
 
-#define atomic_read(v) ((v)->counter)
-#define atomic_set(v,i)(((v)->counter) = (i))
-
-static inline void atomic_add(int i, volatile atomic_t *v)
-{
-   unsigned long flags = 0;
-
-   local_irq_save(flags);
-   v->counter += i;
-   local_irq_restore(flags);
-}
-
-static inline void atomic_sub(int i, volatile atomic_t *v)
-{
-   unsigned long flags = 0;
-
-   local_irq_save(flags);
-   v->counter -= i;
-   local_irq_restore(flags);
-}
-
-static inline void atomic_inc(volatile atomic_t *v)
-{
-   unsigned long flags = 0;
-
-   local_irq_save(flags);
-   v->counter += 1;
-   local_irq_restore(flags);
-}
-
-static inline void atomic_dec(volatile atomic_t *v)
-{
-   unsigned long flags = 0;
-
-   local_irq_save(flags);
-   v->counter -= 1;
-   local_irq_restore(flags);
-}
-
-static inline int atomic_dec_and_test(volatile atomic_t *v)
-{
-   unsigned long flags = 0;
-   int val;
-
-   local_irq_save(flags);
-   val = v->counter;
-   v->counter = val -= 1;
-   local_irq_restore(flags);
-
-   return val == 0;
-}
-
-static inline int atomic_add_negative(int i, volatile atomic_t *v)
-{
-   unsigned long flags = 0;
-   int val;
-
-   local_irq_save(flags);
-   val = v->counter;
-   v->counter = val += i;
-   local_irq_restore(flags);
-
-   return val < 0;
-}
-
-static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
-{
-   unsigned long flags = 0;
-
-   local_irq_save(flags);
-   *addr &= ~mask;
-   local_irq_restore(flags);
-}
-
-/* Atomic operations are already serializing on ARM */
-#define smp_mb__before_atomic_dec()barrier()
-#define smp_mb__after_atomic_dec() barrier()
-#define smp_mb__before_atomic_inc()barrier()
-#define smp_mb__after_atomic_inc() barrier()
-
-#endif
 #endif
diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
new file mode 100644
index ..6357b66a5304
--- /dev/null
+++ b/include/asm-generic/atomic.h
@@ -0,0 +1,99 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ *  based on linux/include/asm-arm/atomic.h
+ *
+ *  Copyright (c) 1996 Russell King.
+ */
+
+#ifndef __ASM_GENERIC_ATOMIC_H
+#define __ASM_GENERIC_ATOMIC_H
+
+#ifdef CONFIG_SMP
+#error SMP not supported
+#endif
+
+typedef struct { volatile int counter; } atomic_t;
+
+#define ATOMIC_INIT(i) { (i) }
+
+#define atomic_read(v) ((v)->counter)
+#define atomic_set(v,i)(((v)->counter) = (i))
+
+static inline void atomic_add(int i, volatile atomic_t *v)
+{
+   unsigned long flags = 0;
+
+   local_irq_save(flags);
+   v->counter += i;
+   local_irq_restore(flags);
+}
+
+static inline void atomic_sub(int i, volatile atomic_t *v)
+{
+   unsigned long flags = 0;
+
+   local_irq_save(flags);
+   v->counter -= i;
+   local_irq_restore(flags);
+}
+
+static inline void atomic_inc(volatile atomic_t *v)
+{
+   unsigned long flags = 0;
+
+   local_irq_save(flags);
+   v->counter += 1;
+   local_irq_restore(flags);
+}
+
+static inline void atomic_dec(volatile atomic_t *v)
+{
+   unsigned long flags = 0;
+
+   local_irq_save(flags);
+   v->counter -= 1;
+   local_irq_restore(flags);
+}
+
+static inline int atomic_dec_and_test(volatile atomic_t *v)
+{
+   unsigned long flags = 0;
+   int val;
+
+   local_irq_save(flags);
+   val = v->counter;
+   v->counter = val -= 1;
+   local_irq_restore(flags);
+
+   return val == 0;
+}
+
+static 

[PATCH v2 13/25] sandbox: implement stub physical virtual translation

2020-06-02 Thread Ahmad Fatoum
For compile-testing drivers that use DMA operations under sandbox,
we want stub implementations of these. Provide them.

Signed-off-by: Ahmad Fatoum 
---
 arch/sandbox/include/asm/io.h | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/arch/sandbox/include/asm/io.h b/arch/sandbox/include/asm/io.h
index 0a07627a893d..6a0e77aead42 100644
--- a/arch/sandbox/include/asm/io.h
+++ b/arch/sandbox/include/asm/io.h
@@ -6,4 +6,14 @@
 #include 
 #include 
 
+static inline void *phys_to_virt(unsigned long phys)
+{
+   return (void *)phys;
+}
+
+static inline unsigned long virt_to_phys(volatile void *mem)
+{
+   return (unsigned long)mem;
+}
+
 #endif /* __ASM_SANDBOX_IO_H */
-- 
2.27.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2 10/25] ddr: fsl: depend on ARM

2020-06-02 Thread Ahmad Fatoum
We have inline assembly in the driver, so we can't compile-test it
unmodified on non-ARM. Indicate so in the Kconfig.

Signed-off-by: Ahmad Fatoum 
---
 drivers/ddr/fsl/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/ddr/fsl/Kconfig b/drivers/ddr/fsl/Kconfig
index 09920bb8632e..b12bf8f7776f 100644
--- a/drivers/ddr/fsl/Kconfig
+++ b/drivers/ddr/fsl/Kconfig
@@ -1,5 +1,6 @@
 config DDR_FSL
bool "Freescale DDR support" if COMPILE_TEST
+   depends on ARM
 
 if DDR_FSL
 
-- 
2.27.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2 22/25] commands: tftp: drop unused variable

2020-06-02 Thread Ahmad Fatoum
The flags variables is not used. Drop it.

Signed-off-by: Ahmad Fatoum 
---
 commands/tftp.c | 8 ++--
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/commands/tftp.c b/commands/tftp.c
index 1569819844bf..48ff00c6217c 100644
--- a/commands/tftp.c
+++ b/commands/tftp.c
@@ -20,7 +20,6 @@ static int do_tftpb(int argc, char *argv[])
 {
char *source, *dest, *freep;
int opt;
-   unsigned long flags;
int tftp_push = 0;
int ret;
IPaddr_t ip;
@@ -46,13 +45,10 @@ static int do_tftpb(int argc, char *argv[])
else
dest = argv[optind];
 
-   if (tftp_push) {
+   if (tftp_push)
dest = freep = basprintf("%s/%s", TFTP_MOUNT_PATH, dest);
-   flags = O_RDONLY;
-   } else {
+   else
source = freep = basprintf("%s/%s", TFTP_MOUNT_PATH, source);
-   flags = O_WRONLY | O_CREAT;
-   }
 
if (!freep)
return -ENOMEM;
-- 
2.27.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2 18/25] sandbox: asm: implement

2020-06-02 Thread Ahmad Fatoum
For easier code-sharing, the UBIFS code still uses the Kernel's
atomic accessors. Provide a sandbox  header, so we
can compile-test UBI under sandbox.

Signed-off-by: Ahmad Fatoum 
---
 arch/sandbox/include/asm/atomic.h | 2 ++
 1 file changed, 2 insertions(+)
 create mode 100644 arch/sandbox/include/asm/atomic.h

diff --git a/arch/sandbox/include/asm/atomic.h 
b/arch/sandbox/include/asm/atomic.h
new file mode 100644
index ..af12dee13089
--- /dev/null
+++ b/arch/sandbox/include/asm/atomic.h
@@ -0,0 +1,2 @@
+// SPDX-License-Identifier: GPL-2.0-only
+#include 
-- 
2.27.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2 25/25] mtd: nand: base: fix use of uninitialized struct member

2020-06-02 Thread Ahmad Fatoum
ooblen is read in nand_do_read_ops, despite never having been assigned a
value. Because ooblen is used to indicate how many bytes of oobbuf are
usable and oobbuf is NULL, use 0 as initial value.

Found on ARCH=sandbox using clang-analyzer.

Signed-off-by: Ahmad Fatoum 
---
 drivers/mtd/nand/nand_base.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
index 00f0f7588434..3f4c787f49da 100644
--- a/drivers/mtd/nand/nand_base.c
+++ b/drivers/mtd/nand/nand_base.c
@@ -1688,6 +1688,7 @@ static int nand_read(struct mtd_info *mtd, loff_t from, 
size_t len,
nand_get_device(mtd, FL_READING);
ops.len = len;
ops.datbuf = buf;
+   ops.ooblen = 0;
ops.oobbuf = NULL;
ops.mode = MTD_OPS_PLACE_OOB;
ret = nand_do_read_ops(mtd, from, );
-- 
2.27.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2 08/25] clocksource: arm_global_timer.c: remove unused asm/ header

2020-06-02 Thread Ahmad Fatoum
We don't use the header and dropping it allows us to compile-test the
driver under non-ARM architectures. Do so.

Signed-off-by: Ahmad Fatoum 
---
 drivers/clocksource/arm_global_timer.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/clocksource/arm_global_timer.c 
b/drivers/clocksource/arm_global_timer.c
index 44e3a3c762fb..78cd72d3eb45 100644
--- a/drivers/clocksource/arm_global_timer.c
+++ b/drivers/clocksource/arm_global_timer.c
@@ -20,7 +20,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #define GT_COUNTER00x00
 #define GT_COUNTER10x04
-- 
2.27.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2 12/25] net: macb: depend on HAS_DMA

2020-06-02 Thread Ahmad Fatoum
The driver makes use of dma_alloc_coherent and brethren. Depend on
HAS_DMA to be sure, we don't run into link errors when compile-testing.

Signed-off-by: Ahmad Fatoum 
---
 drivers/net/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index ee8a716d9a3d..76509a52a1c7 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -181,6 +181,7 @@ config DRIVER_NET_KS8851_MLL
 config DRIVER_NET_MACB
bool "macb Ethernet driver"
depends on HAS_MACB || COMPILE_TEST
+   depends on HAS_DMA
select PHYLIB
 
 config DRIVER_NET_MICREL
-- 
2.27.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2 09/25] mtd: nand: orion: depend on ARM

2020-06-02 Thread Ahmad Fatoum
We have inline assembly in the driver, so we can't compile-test it
unmodified on non-ARM. Indicate so in the Kconfig.

Signed-off-by: Ahmad Fatoum 
---
 drivers/mtd/nand/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/mtd/nand/Kconfig b/drivers/mtd/nand/Kconfig
index fff9903d1d35..b81e72d6b773 100644
--- a/drivers/mtd/nand/Kconfig
+++ b/drivers/mtd/nand/Kconfig
@@ -98,7 +98,7 @@ config MTD_NAND_OMAP_ELM
 config NAND_ORION
bool
prompt "Marvell Orion NAND driver"
-   depends on ARCH_KIRKWOOD || COMPILE_TEST
+   depends on ARM && (ARCH_KIRKWOOD || COMPILE_TEST)
help
  Support for the Orion NAND controller, present in Kirkwood SoCs.
 
-- 
2.27.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2 17/25] include: : remove stub IRQ save/restore

2020-06-02 Thread Ahmad Fatoum
For an architecture to use , it must define
local_irq_save() and local_irq_restore(). Instead of having every
platform define duplicate their stub definition, just drop them
altogether, so  can be used freestanding.

Signed-off-by: Ahmad Fatoum 
---
 include/asm-generic/atomic.h | 26 --
 1 file changed, 26 deletions(-)

diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
index 6357b66a5304..449cecaabc74 100644
--- a/include/asm-generic/atomic.h
+++ b/include/asm-generic/atomic.h
@@ -21,73 +21,47 @@ typedef struct { volatile int counter; } atomic_t;
 
 static inline void atomic_add(int i, volatile atomic_t *v)
 {
-   unsigned long flags = 0;
-
-   local_irq_save(flags);
v->counter += i;
-   local_irq_restore(flags);
 }
 
 static inline void atomic_sub(int i, volatile atomic_t *v)
 {
-   unsigned long flags = 0;
-
-   local_irq_save(flags);
v->counter -= i;
-   local_irq_restore(flags);
 }
 
 static inline void atomic_inc(volatile atomic_t *v)
 {
-   unsigned long flags = 0;
-
-   local_irq_save(flags);
v->counter += 1;
-   local_irq_restore(flags);
 }
 
 static inline void atomic_dec(volatile atomic_t *v)
 {
-   unsigned long flags = 0;
-
-   local_irq_save(flags);
v->counter -= 1;
-   local_irq_restore(flags);
 }
 
 static inline int atomic_dec_and_test(volatile atomic_t *v)
 {
-   unsigned long flags = 0;
int val;
 
-   local_irq_save(flags);
val = v->counter;
v->counter = val -= 1;
-   local_irq_restore(flags);
 
return val == 0;
 }
 
 static inline int atomic_add_negative(int i, volatile atomic_t *v)
 {
-   unsigned long flags = 0;
int val;
 
-   local_irq_save(flags);
val = v->counter;
v->counter = val += i;
-   local_irq_restore(flags);
 
return val < 0;
 }
 
 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
 {
-   unsigned long flags = 0;
-
-   local_irq_save(flags);
*addr &= ~mask;
-   local_irq_restore(flags);
 }
 
 /* Atomic operations are already serializing on ARM */
-- 
2.27.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2 15/25] sandbox: select HAS_DMA

2020-06-02 Thread Ahmad Fatoum
With the DMA stubs in place, we can indicate HAS_DMA in good conscience.
Do so.

Signed-off-by: Ahmad Fatoum 
---
 arch/sandbox/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/sandbox/Kconfig b/arch/sandbox/Kconfig
index 789938941dcd..3f10709021a7 100644
--- a/arch/sandbox/Kconfig
+++ b/arch/sandbox/Kconfig
@@ -6,6 +6,7 @@ config SANDBOX
select GPIOLIB
select ARCH_HAS_UBSAN_SANITIZE_ALL
select HAVE_ARCH_KASAN
+   select HAS_DMA
default y
 
 config ARCH_TEXT_BASE
-- 
2.27.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2 24/25] sandbox: os: add_image: fix memory leak

2020-06-02 Thread Ahmad Fatoum
devname is strdup'd few lines later, so remove the earlier strdup.
The pointer isn't stored anywhere persistent in between.

Signed-off-by: Ahmad Fatoum 
---
 arch/sandbox/os/common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/sandbox/os/common.c b/arch/sandbox/os/common.c
index e67ea14138c0..382a92304020 100644
--- a/arch/sandbox/os/common.c
+++ b/arch/sandbox/os/common.c
@@ -236,7 +236,7 @@ static int add_image(char *str, char *devname_template, int 
*devname_number)
filename = devname;
snprintf(tmp, sizeof(tmp),
 devname_template, (*devname_number)++);
-   devname = strdup(tmp);
+   devname = tmp;
}
 
printf("add %s backed by file %s%s\n", devname,
-- 
2.27.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2 02/25] sandbox: define CONFIG_64BIT as appropriate

2020-06-02 Thread Ahmad Fatoum
All 64-bit architectures are supposed to define CONFIG_64BIT to support
the relevant 64-bit MMIO accessors. The sandbox architecture is a bit
of a special case, because barebox uses the toolchain default and
doesn't force a bitness. Add 64BIT as promptless symbol, which reflects
the pointer size of the target platform.

Signed-off-by: Ahmad Fatoum 
---
 arch/sandbox/Kconfig| 9 +
 scripts/gcc-64bitptr.sh | 9 +
 2 files changed, 18 insertions(+)
 create mode 100755 scripts/gcc-64bitptr.sh

diff --git a/arch/sandbox/Kconfig b/arch/sandbox/Kconfig
index 6ec71a99e53f..46cfe8b4b1c8 100644
--- a/arch/sandbox/Kconfig
+++ b/arch/sandbox/Kconfig
@@ -1,3 +1,5 @@
+source "scripts/Kconfig.include"
+
 config SANDBOX
bool
select OFTREE
@@ -20,3 +22,10 @@ config SANDBOX_UNWIND
default y
select ARCH_HAS_STACK_DUMP
depends on UBSAN || KASAN
+
+config CC_IS_64BIT
+   def_bool $(success,$(srctree)/scripts/gcc-64bitptr.sh $(CC))
+
+config 64BIT
+   bool
+   default CC_IS_64BIT
diff --git a/scripts/gcc-64bitptr.sh b/scripts/gcc-64bitptr.sh
new file mode 100755
index ..7fb05703b813
--- /dev/null
+++ b/scripts/gcc-64bitptr.sh
@@ -0,0 +1,9 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-only
+
+cat << "END" | $@ -x c - -c -o /dev/null
+int main(void)
+{
+   return sizeof(struct { int:-!(sizeof(void *) == 8); });
+}
+END
-- 
2.27.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2 07/25] sandbox: : include bitio accessors

2020-06-02 Thread Ahmad Fatoum
ARM  defines the U-Boot style setbits/clrbits helpers.
Have sandbox follow suit to allow more drivers to be compile tested
there.

Signed-off-by: Ahmad Fatoum 
---
 arch/sandbox/include/asm/io.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/sandbox/include/asm/io.h b/arch/sandbox/include/asm/io.h
index cb891df5c8c8..0a07627a893d 100644
--- a/arch/sandbox/include/asm/io.h
+++ b/arch/sandbox/include/asm/io.h
@@ -4,5 +4,6 @@
 #defineIO_SPACE_LIMIT 0
 
 #include 
+#include 
 
 #endif /* __ASM_SANDBOX_IO_H */
-- 
2.27.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2 05/25] include: asm-generic: provide (in|out)_(le|be)(16|32) helpers for all archs

2020-06-02 Thread Ahmad Fatoum
These U-Boot style bitwise operations macros will be needed for
COMPILE_TEST-compiled drivers on platforms except for ARM. Add fallback
definitions there, based on the ARM ones.

Signed-off-by: Ahmad Fatoum 
---
 include/asm-generic/bitio.h | 145 
 1 file changed, 145 insertions(+)
 create mode 100644 include/asm-generic/bitio.h

diff --git a/include/asm-generic/bitio.h b/include/asm-generic/bitio.h
new file mode 100644
index ..e88dbd7b8527
--- /dev/null
+++ b/include/asm-generic/bitio.h
@@ -0,0 +1,145 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#ifndef __ASM_GENERIC_BITIO_H
+#define __ASM_GENERIC_BITIO_H
+
+#include 
+
+/*
+ * Clear and set bits in one shot. These macros can be used to clear and
+ * set multiple bits in a register using a single call. These macros can
+ * also be used to set a multiple-bit bit pattern using a mask, by
+ * specifying the mask in the 'clear' parameter and the new bit pattern
+ * in the 'set' parameter.
+ */
+
+#ifndef out_arch
+#define out_arch(type,endian,a,v)  __raw_write##type(cpu_to_##endian(v),a)
+#endif
+
+#ifndef in_arch
+#define in_arch(type,endian,a) endian##_to_cpu(__raw_read##type(a))
+#endif
+
+#ifndef out_le64
+#define out_le64(a,v)  out_arch(q,le64,a,v)
+#endif
+
+#ifndef out_le32
+#define out_le32(a,v)  out_arch(l,le32,a,v)
+#endif
+
+#ifndef out_le16
+#define out_le16(a,v)  out_arch(w,le16,a,v)
+#endif
+
+#ifndef in_le64
+#define in_le64(a) in_arch(q,le64,a)
+#endif
+
+#ifndef in_le32
+#define in_le32(a) in_arch(l,le32,a)
+#endif
+
+#ifndef in_le16
+#define in_le16(a) in_arch(w,le16,a)
+#endif
+
+#ifndef out_be32
+#define out_be32(a,v)  out_arch(l,be32,a,v)
+#endif
+
+#ifndef out_be16
+#define out_be16(a,v)  out_arch(w,be16,a,v)
+#endif
+
+#ifndef in_be32
+#define in_be32(a) in_arch(l,be32,a)
+#endif
+
+#ifndef in_be16
+#define in_be16(a) in_arch(w,be16,a)
+#endif
+
+#ifndef out_8
+#define out_8(a,v) __raw_writeb(v,a)
+#endif
+
+#ifndef in_8
+#define in_8(a)__raw_readb(a)
+#endif
+
+#ifndef clrbits
+#define clrbits(type, addr, clear) \
+   out_##type((addr), in_##type(addr) & ~(clear))
+#endif
+
+#ifndef setbits
+#define setbits(type, addr, set) \
+   out_##type((addr), in_##type(addr) | (set))
+#endif
+
+#define clrsetbits(type, addr, clear, set) \
+   out_##type((addr), (in_##type(addr) & ~(clear)) | (set))
+
+#ifndef clrbits_be32
+#define clrbits_be32(addr, clear) clrbits(be32, addr, clear)
+#endif
+
+#ifndef setbits_be32
+#define setbits_be32(addr, set) setbits(be32, addr, set)
+#endif
+
+#ifndef clrsetbits_be32
+#define clrsetbits_be32(addr, clear, set) clrsetbits(be32, addr, clear, set)
+#endif
+
+#ifndef clrbits_le32
+#define clrbits_le32(addr, clear) clrbits(le32, addr, clear)
+#endif
+
+#ifndef setbits_le32
+#define setbits_le32(addr, set) setbits(le32, addr, set)
+#endif
+
+#ifndef clrsetbits_le32
+#define clrsetbits_le32(addr, clear, set) clrsetbits(le32, addr, clear, set)
+#endif
+
+#ifndef clrbits_be16
+#define clrbits_be16(addr, clear) clrbits(be16, addr, clear)
+#endif
+
+#ifndef setbits_be16
+#define setbits_be16(addr, set) setbits(be16, addr, set)
+#endif
+
+#ifndef clrsetbits_be16
+#define clrsetbits_be16(addr, clear, set) clrsetbits(be16, addr, clear, set)
+#endif
+
+#ifndef clrbits_le16
+#define clrbits_le16(addr, clear) clrbits(le16, addr, clear)
+#endif
+
+#ifndef setbits_le16
+#define setbits_le16(addr, set) setbits(le16, addr, set)
+#endif
+
+#ifndef clrsetbits_le16
+#define clrsetbits_le16(addr, clear, set) clrsetbits(le16, addr, clear, set)
+#endif
+
+#ifndef clrbits_8
+#define clrbits_8(addr, clear) clrbits(8, addr, clear)
+#endif
+
+#ifndef setbits_8
+#define setbits_8(addr, set) setbits(8, addr, set)
+#endif
+
+#ifndef clrsetbits_8
+#define clrsetbits_8(addr, clear, set) clrsetbits(8, addr, clear, set)
+#endif
+
+#endif /* __ASM_GENERIC_IO_H */
-- 
2.27.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2 00/25] sandbox: support COMPILE_TESTing drivers

2020-06-02 Thread Ahmad Fatoum
This series adds the last few bells and whistles to COMPILE_TEST
these drivers under sandbox as well.

The five last patches address the first few issues found by
clang-analyzer. There are still hundreds more in need of triage:
http://a3f.at/up/barebox-clang-analyzer/

(Check it out; control flow visualization is pretty! j/k to navigate)

v1 -> v2:
  - Patch stack rebased
  - Added separate  (Sascha)
  - fixed Author/Signed-off-by mismatch (Roland)
  - Drop local_irq_ stubs (Sascha)

Ahmad Fatoum (25):
  scripts: import Linux Kconfig.include
  sandbox: define CONFIG_64BIT as appropriate
  sandbox: asm: bitsperlong.h: detect bitness according to 64BIT symbol
  sandbox: support forcing 32-bit x86
  include: asm-generic: provide (in|out)_(le|be)(16|32) helpers for all
archs
  ARM: asm/io.h: fall back to  out_be32 and friends
  sandbox: : include bitio accessors
  clocksource: arm_global_timer.c: remove unused asm/ header
  mtd: nand: orion: depend on ARM
  ddr: fsl: depend on ARM
  net: fec_imx: depend on HAS_DMA
  net: macb: depend on HAS_DMA
  sandbox: implement stub physical virtual translation
  sandbox: asm: implement stub DMA functions
  sandbox: select HAS_DMA
  ARM: atomic.h: move generic implementation to asm-generic
  include: : remove stub IRQ save/restore
  sandbox: asm: implement 
  usb: xhci-hcd: remove unused #include 
  usb: xhci-hcd: replace opencoded non-atomic 64-bit MMIO with lo_hi
helper
  include: bitops: fix dead increment in fls() and ffs()
  commands: tftp: drop unused variable
  commands: test: drop dead assignment
  sandbox: os: add_image: fix memory leak
  mtd: nand: base: fix use of uninitialized struct member

 arch/arm/include/asm/atomic.h  | 108 +-
 arch/arm/include/asm/io.h  |  58 +-
 arch/sandbox/Kconfig   |  17 +++
 arch/sandbox/Makefile  |  12 +-
 arch/sandbox/include/asm/atomic.h  |   2 +
 arch/sandbox/include/asm/bitsperlong.h |  11 +-
 arch/sandbox/include/asm/dma.h |  53 -
 arch/sandbox/include/asm/io.h  |  11 ++
 arch/sandbox/os/Makefile   |   2 +-
 arch/sandbox/os/common.c   |   2 +-
 commands/test.c|   1 -
 commands/tftp.c|   8 +-
 drivers/clocksource/arm_global_timer.c |   1 -
 drivers/ddr/fsl/Kconfig|   1 +
 drivers/mtd/nand/Kconfig   |   2 +-
 drivers/mtd/nand/nand_base.c   |   1 +
 drivers/net/Kconfig|   2 +
 drivers/usb/host/xhci.h|  14 +--
 include/asm-generic/atomic.h   |  73 +
 include/asm-generic/bitio.h| 145 +
 include/asm-generic/bitops/ffs.h   |   4 +-
 include/asm-generic/bitops/fls.h   |   4 +-
 scripts/Kconfig.include|  53 +
 scripts/gcc-64bitptr.sh|   9 ++
 scripts/gcc-version.sh |  20 
 25 files changed, 412 insertions(+), 202 deletions(-)
 create mode 100644 arch/sandbox/include/asm/atomic.h
 create mode 100644 include/asm-generic/atomic.h
 create mode 100644 include/asm-generic/bitio.h
 create mode 100644 scripts/Kconfig.include
 create mode 100755 scripts/gcc-64bitptr.sh
 create mode 100755 scripts/gcc-version.sh

-- 
2.27.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2 04/25] sandbox: support forcing 32-bit x86

2020-06-02 Thread Ahmad Fatoum
If gcc supports multiple architectures, barebox uses only the default
when compiling for ARCH=sandbox, this is e.g. the case with compilers
that generate both 32- and 64-bit x86 executables.

There can be good reasons to force 32-bit though, e.g. to reduce memory
consumption while fuzzing or to temporarily avoid 32-to-64-bit warnings,
while running the static analyzer. Add an option for this.

Signed-off-by: Ahmad Fatoum 
---
 arch/sandbox/Kconfig |  7 +++
 arch/sandbox/Makefile| 12 +++-
 arch/sandbox/os/Makefile |  2 +-
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/arch/sandbox/Kconfig b/arch/sandbox/Kconfig
index 46cfe8b4b1c8..789938941dcd 100644
--- a/arch/sandbox/Kconfig
+++ b/arch/sandbox/Kconfig
@@ -26,6 +26,13 @@ config SANDBOX_UNWIND
 config CC_IS_64BIT
def_bool $(success,$(srctree)/scripts/gcc-64bitptr.sh $(CC))
 
+config CC_HAS_LINUX_I386_SUPPORT
+   def_bool $(cc-option,-m32) && $(ld-option,-m elf_i386)
+
 config 64BIT
bool
+   default n if SANDBOX_LINUX_I386
default CC_IS_64BIT
+
+config SANDBOX_LINUX_I386
+   bool "32-bit x86 barebox" if CC_HAS_LINUX_I386_SUPPORT
diff --git a/arch/sandbox/Makefile b/arch/sandbox/Makefile
index 3917cade94eb..c08ea0cf83e0 100644
--- a/arch/sandbox/Makefile
+++ b/arch/sandbox/Makefile
@@ -52,11 +52,21 @@ ifeq ($(CONFIG_UBSAN),y)
 SANITIZER_LIBS += -fsanitize=undefined
 endif
 
-cmd_barebox__ = $(CC) -o $@ -Wl,-T,$(BAREBOX_LDS) \
+ifeq ($(CONFIG_SANDBOX_LINUX_I386),y)
+KBUILD_CFLAGS += -m32
+KBUILD_LDFLAGS += -m elf_i386
+KBUILD_AFLAGS += -m32
+BAREBOX_LDFLAGS += -m32
+endif
+
+BAREBOX_LDFLAGS += \
+   -Wl,-T,$(BAREBOX_LDS) \
-Wl,--whole-archive $(BAREBOX_OBJS) -Wl,--no-whole-archive \
-lrt -lpthread $(SDL_LIBS) $(FTDI1_LIBS) \
$(SANITIZER_LIBS)
 
+cmd_barebox__ = $(CC) -o $@ $(BAREBOX_LDFLAGS)
+
 common-y += $(BOARD) arch/sandbox/os/ arch/sandbox/lib/
 
 common-$(CONFIG_OFTREE) += arch/sandbox/dts/
diff --git a/arch/sandbox/os/Makefile b/arch/sandbox/os/Makefile
index c012c9cf0155..ed921443e0fd 100644
--- a/arch/sandbox/os/Makefile
+++ b/arch/sandbox/os/Makefile
@@ -6,7 +6,7 @@ KBUILD_CPPFLAGS = $(patsubst 
%,-I$(srctree)/%include,$(machdirs))
 
 KBUILD_CPPFLAGS += -DCONFIG_MALLOC_SIZE=$(CONFIG_MALLOC_SIZE)
 
-KBUILD_CFLAGS := -Wall
+KBUILD_CFLAGS += -Wall
 NOSTDINC_FLAGS :=
 
 obj-y = common.o tap.o
-- 
2.27.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2 03/25] sandbox: asm: bitsperlong.h: detect bitness according to 64BIT symbol

2020-06-02 Thread Ahmad Fatoum
Now that we have an accurate CONFIG_64BIT describing sandbox bitness,
we don't need to assume everything except __x86_64__ as 32-bit.

This assumes that sizeof(long) == sizeof(void *), which is assumed
anyway throughout the code base.

Signed-off-by: Ahmad Fatoum 
---
 arch/sandbox/include/asm/bitsperlong.h | 11 +--
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/arch/sandbox/include/asm/bitsperlong.h 
b/arch/sandbox/include/asm/bitsperlong.h
index 00c1fc2625b2..6dc0bb0c13b2 100644
--- a/arch/sandbox/include/asm/bitsperlong.h
+++ b/arch/sandbox/include/asm/bitsperlong.h
@@ -1,10 +1 @@
-#ifndef __ASM_BITSPERLONG_H
-#define __ASM_BITSPERLONG_H
-
-#ifdef __x86_64__
-#define BITS_PER_LONG 64
-#else
-#define BITS_PER_LONG 32
-#endif
-
-#endif /* __ASM_BITSPERLONG_H */
+#include 
-- 
2.27.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2 01/25] scripts: import Linux Kconfig.include

2020-06-02 Thread Ahmad Fatoum
With this include, we can have goodies like $(cc-option ...) and
$(success ...) inside our Kconfig files.

gcc-version also now becomes available. While unused for now, it can
allow us to selectively turn on warnings on new GCC versions, which
were previously disabled because of their too high false positive rate.

Signed-off-by: Ahmad Fatoum 
---
 scripts/Kconfig.include | 53 +
 scripts/gcc-version.sh  | 20 
 2 files changed, 73 insertions(+)
 create mode 100644 scripts/Kconfig.include
 create mode 100755 scripts/gcc-version.sh

diff --git a/scripts/Kconfig.include b/scripts/Kconfig.include
new file mode 100644
index ..496d11c92c97
--- /dev/null
+++ b/scripts/Kconfig.include
@@ -0,0 +1,53 @@
+# SPDX-License-Identifier: GPL-2.0-only
+# Kconfig helper macros
+
+# Convenient variables
+comma   := ,
+quote   := "
+squote  := '
+empty   :=
+space   := $(empty) $(empty)
+dollar  := $
+right_paren := )
+left_paren  := (
+
+# $(if-success,,,)
+# Return  if  exits with 0,  otherwise.
+if-success = $(shell,{ $(1); } >/dev/null 2>&1 && echo "$(2)" || echo "$(3)")
+
+# $(success,)
+# Return y if  exits with 0, n otherwise
+success = $(if-success,$(1),y,n)
+
+# $(failure,)
+# Return n if  exits with 0, y otherwise
+failure = $(if-success,$(1),n,y)
+
+# $(cc-option,)
+# Return y if the compiler supports , n otherwise
+cc-option = $(success,$(CC) -Werror $(CLANG_FLAGS) $(1) -S -x c /dev/null -o 
/dev/null)
+
+# $(ld-option,)
+# Return y if the linker supports , n otherwise
+ld-option = $(success,$(LD) -v $(1))
+
+# $(as-instr,)
+# Return y if the assembler supports , n otherwise
+as-instr = $(success,printf "%b\n" "$(1)" | $(CC) $(CLANG_FLAGS) -c -x 
assembler -o /dev/null -)
+
+# check if $(CC) and $(LD) exist
+$(error-if,$(failure,command -v $(CC)),compiler '$(CC)' not found)
+$(error-if,$(failure,command -v $(LD)),linker '$(LD)' not found)
+
+# Fail if the linker is gold as it's not capable of linking the kernel proper
+$(error-if,$(success, $(LD) -v | grep -q gold), gold linker '$(LD)' not 
supported)
+
+# gcc version including patch level
+gcc-version := $(shell,$(srctree)/scripts/gcc-version.sh $(CC))
+
+# machine bit flags
+#  $(m32-flag): -m32 if the compiler supports it, or an empty string otherwise.
+#  $(m64-flag): -m64 if the compiler supports it, or an empty string otherwise.
+cc-option-bit = $(if-success,$(CC) -Werror $(1) -E -x c /dev/null -o 
/dev/null,$(1))
+m32-flag := $(cc-option-bit,-m32)
+m64-flag := $(cc-option-bit,-m64)
diff --git a/scripts/gcc-version.sh b/scripts/gcc-version.sh
new file mode 100755
index ..ae353432539b
--- /dev/null
+++ b/scripts/gcc-version.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+#
+# gcc-version gcc-command
+#
+# Print the gcc version of `gcc-command' in a 5 or 6-digit form
+# such as `29503' for gcc-2.95.3, `30301' for gcc-3.3.1, etc.
+
+compiler="$*"
+
+if [ ${#compiler} -eq 0 ]; then
+   echo "Error: No compiler specified." >&2
+   printf "Usage:\n\t$0 \n" >&2
+   exit 1
+fi
+
+MAJOR=$(echo __GNUC__ | $compiler -E -x c - | tail -n 1)
+MINOR=$(echo __GNUC_MINOR__ | $compiler -E -x c - | tail -n 1)
+PATCHLEVEL=$(echo __GNUC_PATCHLEVEL__ | $compiler -E -x c - | tail -n 1)
+printf "%d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL
-- 
2.27.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH] scripts: .gitignore: ignore mvebuimg binary

2020-06-02 Thread Ahmad Fatoum
If selected, we generate a mvebuimg binary that should be ignored by
version control. Add .gitignore entry to do so.

Signed-off-by: Ahmad Fatoum 
---
 scripts/.gitignore | 1 +
 1 file changed, 1 insertion(+)

diff --git a/scripts/.gitignore b/scripts/.gitignore
index c3ac0b570283..7c9a3f55715f 100644
--- a/scripts/.gitignore
+++ b/scripts/.gitignore
@@ -31,3 +31,4 @@ omap3-usb-loader
 mips-relocs
 rsatoc
 stm32image
+mvebuimg
-- 
2.27.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 3/3] mci: reword MCI_STARTUP text

2020-06-02 Thread Ahmad Fatoum
With the recent addition of a generic device_detect for MCI devices,
the MCI_STARTUP help text is no longer accurate. Reword it, but leave
the option as-is as some boards may be broken if we drop the option
(e.g. because they still depend on a probe order or call
default_environment_path_set, but don't explicitly detect the device).

Signed-off-by: Ahmad Fatoum 
---
 drivers/mci/Kconfig | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/mci/Kconfig b/drivers/mci/Kconfig
index 60c60ceaa527..6ae1e812528c 100644
--- a/drivers/mci/Kconfig
+++ b/drivers/mci/Kconfig
@@ -12,12 +12,12 @@ if MCI
 comment "--- Feature list ---"
 
 config MCI_STARTUP
-   bool "Probe on system start"
+   bool "Force probe on system start"
help
- Say 'y' here if the MCI framework should probe for attached MCI cards
- on system start up. This is required if the card carries barebox's
- environment (for example on systems where the MCI card is the sole
- bootmedia). Otherwise probing run on demand with "mci*.probe=1"
+ Say 'y' here if the MCI framework should always probe for all attached
+ MCI cards on system start up. This may required for some legacy 
boards.
+ When this is 'n', probing happens on demand either with "mci*.probe=1"
+ or with driver/board code calling device_detect.
 
 config MCI_INFO
bool "MCI Info"
-- 
2.27.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 1/3] mci: define fall-back hw_dev->detect for all MCIs

2020-06-02 Thread Ahmad Fatoum
A barebox environment oftree node may reference its storage by a phandle
to a partition node under a MCI node. barebox will then call the
device's detect method to detect the card if this hasn't happened
before. Out of 17 MCI drivers, 8 host drivers already implement
a detect method, which just calls mci_detect_card.

Provide a generic implementation that does the same.

Signed-off-by: Ahmad Fatoum 
---
 drivers/mci/mci-core.c | 22 +++---
 1 file changed, 19 insertions(+), 3 deletions(-)

diff --git a/drivers/mci/mci-core.c b/drivers/mci/mci-core.c
index e8844a3c0007..09e66bad472e 100644
--- a/drivers/mci/mci-core.c
+++ b/drivers/mci/mci-core.c
@@ -1811,6 +1811,18 @@ static int mci_detect(struct device_d *dev)
return mci_detect_card(mci->host);
 }
 
+static int mci_hw_detect(struct device_d *dev)
+{
+   struct mci *mci;
+
+   list_for_each_entry(mci, _list, list) {
+   if (dev == >dev || dev == mci->host->hw_dev)
+   return mci_detect_card(mci->host);
+   }
+
+   return -ENODEV;
+}
+
 /**
  * Create a new mci device (for convenience)
  * @param host mci_host for this MCI device
@@ -1819,6 +1831,7 @@ static int mci_detect(struct device_d *dev)
 int mci_register(struct mci_host *host)
 {
struct mci *mci;
+   struct device_d *hw_dev;
struct param_d *param_probe;
int ret;
 
@@ -1833,13 +1846,16 @@ int mci_register(struct mci_host *host)
mci->dev.id = DEVICE_ID_DYNAMIC;
}
 
+   hw_dev = host->hw_dev;
mci->dev.platform_data = host;
-   mci->dev.parent = host->hw_dev;
+   mci->dev.parent = hw_dev;
mci->host = host;
host->mci = mci;
mci->dev.detect = mci_detect;
+   if (!hw_dev->detect)
+   hw_dev->detect = mci_hw_detect;
 
-   host->supply = regulator_get(host->hw_dev, "vmmc");
+   host->supply = regulator_get(hw_dev, "vmmc");
if (IS_ERR(host->supply)) {
dev_err(>dev, "Failed to get 'vmmc' regulator.\n");
host->supply = NULL;
@@ -1849,7 +1865,7 @@ int mci_register(struct mci_host *host)
if (ret)
goto err_free;
 
-   dev_info(mci->host->hw_dev, "registered as %s\n", dev_name(>dev));
+   dev_info(hw_dev, "registered as %s\n", dev_name(>dev));
 
param_probe = dev_add_param_bool(>dev, "probe",
mci_set_probe, NULL, >probe, mci);
-- 
2.27.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 2/3] mci: remove now-duplicate dev->detect implementations in host drivers

2020-06-02 Thread Ahmad Fatoum
Previous commit introduced a fall-back MCI hw_dev->detect
implementation. All drivers touched in this commit populate hw_dev, so
lets drop their now-superfluous detect implementations.

Signed-off-by: Ahmad Fatoum 
---
 drivers/mci/bcm2835-sdhost.c | 10 --
 drivers/mci/dove-sdhci.c |  8 
 drivers/mci/dw_mmc.c | 11 ---
 drivers/mci/imx-esdhc.c  | 11 ---
 drivers/mci/mci-bcm2835.c| 10 --
 drivers/mci/mxs.c|  9 -
 drivers/mci/omap_hsmmc.c | 10 --
 drivers/mci/tegra-sdmmc.c| 10 --
 8 files changed, 79 deletions(-)

diff --git a/drivers/mci/bcm2835-sdhost.c b/drivers/mci/bcm2835-sdhost.c
index 1d3a6c096910..f935ed5ea713 100644
--- a/drivers/mci/bcm2835-sdhost.c
+++ b/drivers/mci/bcm2835-sdhost.c
@@ -579,13 +579,6 @@ static void bcm2835_set_ios(struct mci_host *mci, struct 
mci_ios *ios)
writel(hcfg, host->regs + SDHCFG);
 }
 
-static int bcm2835_sdhost_detect(struct device_d *dev)
-{
-   struct bcm2835_host *host = dev->priv;
-
-   return mci_detect_card(>mci);
-}
-
 static int bcm2835_sdhost_probe(struct device_d *dev)
 {
struct bcm2835_host *host;
@@ -617,9 +610,6 @@ static int bcm2835_sdhost_probe(struct device_d *dev)
mci->set_ios = bcm2835_set_ios;
mci->send_cmd = bcm2835_send_cmd;
 
-   dev->priv = host;
-   dev->detect = bcm2835_sdhost_detect,
-
mci_of_parse(mci);
 
return mci_register(mci);
diff --git a/drivers/mci/dove-sdhci.c b/drivers/mci/dove-sdhci.c
index cb052e81b1e4..e09147fff9f7 100644
--- a/drivers/mci/dove-sdhci.c
+++ b/drivers/mci/dove-sdhci.c
@@ -324,12 +324,6 @@ static void dove_sdhci_set_mci_caps(struct dove_sdhci 
*host)
host->mci.host_caps &= ~MMC_CAP_8_BIT_DATA;
 }
 
-static int dove_sdhci_detect(struct device_d *dev)
-{
-   struct dove_sdhci *host = dev->priv;
-   return mci_detect_card(>mci);
-}
-
 static int dove_sdhci_probe(struct device_d *dev)
 {
struct dove_sdhci *host;
@@ -350,8 +344,6 @@ static int dove_sdhci_probe(struct device_d *dev)
host->sdhci.write32 = dove_sdhci_writel;
host->sdhci.write16 = dove_sdhci_writew;
host->sdhci.write8 = dove_sdhci_writeb;
-   dev->priv = host;
-   dev->detect = dove_sdhci_detect;
 
dove_sdhci_set_mci_caps(host);
 
diff --git a/drivers/mci/dw_mmc.c b/drivers/mci/dw_mmc.c
index f035317ef285..ab8270814b86 100644
--- a/drivers/mci/dw_mmc.c
+++ b/drivers/mci/dw_mmc.c
@@ -553,13 +553,6 @@ static int dwmci_init(struct mci_host *mci, struct 
device_d *dev)
return 0;
 }
 
-static int dw_mmc_detect(struct device_d *dev)
-{
-   struct dwmci_host *host = dev->priv;
-
-   return mci_detect_card(>mci);
-}
-
 static int dw_mmc_probe(struct device_d *dev)
 {
struct resource *iores;
@@ -615,8 +608,6 @@ static int dw_mmc_probe(struct device_d *dev)
else
host->pwren_value = 1;
 
-   dev->detect = dw_mmc_detect;
-
host->clkrate = clk_get_rate(host->clk_ciu);
host->mci.f_min = host->clkrate / 510 / host->ciu_div;
if (host->mci.f_min < 20)
@@ -625,8 +616,6 @@ static int dw_mmc_probe(struct device_d *dev)
 
mci_of_parse(>mci);
 
-   dev->priv = host;
-
return mci_register(>mci);
 }
 
diff --git a/drivers/mci/imx-esdhc.c b/drivers/mci/imx-esdhc.c
index bff8dd67ada2..314a2264f952 100644
--- a/drivers/mci/imx-esdhc.c
+++ b/drivers/mci/imx-esdhc.c
@@ -236,13 +236,6 @@ static int esdhc_init(struct mci_host *mci, struct 
device_d *dev)
return ret;
 }
 
-static int fsl_esdhc_detect(struct device_d *dev)
-{
-   struct fsl_esdhc_host *host = dev->priv;
-
-   return mci_detect_card(>mci);
-}
-
 static int fsl_esdhc_probe(struct device_d *dev)
 {
struct resource *iores;
@@ -311,8 +304,6 @@ static int fsl_esdhc_probe(struct device_d *dev)
host->mci.card_present = esdhc_card_present;
host->mci.hw_dev = dev;
 
-   dev->detect = fsl_esdhc_detect;
-
rate = clk_get_rate(host->clk);
host->mci.f_min = rate >> 12;
if (host->mci.f_min < 20)
@@ -325,8 +316,6 @@ static int fsl_esdhc_probe(struct device_d *dev)
 
mci_of_parse(>mci);
 
-   dev->priv = host;
-
ret = mci_register(>mci);
if (ret)
goto err_release_res;
diff --git a/drivers/mci/mci-bcm2835.c b/drivers/mci/mci-bcm2835.c
index b18d681870a5..c463c623e75f 100644
--- a/drivers/mci/mci-bcm2835.c
+++ b/drivers/mci/mci-bcm2835.c
@@ -366,13 +366,6 @@ static int bcm2835_mci_reset(struct mci_host *mci, struct 
device_d *mci_dev)
return bcm2835_mci_wait_command_done(host);
 }
 
-static int bcm2835_mci_detect(struct device_d *dev)
-{
-   struct bcm2835_mci_host *host = dev->priv;
-
-   return mci_detect_card(>mci);
-}
-
 static int bcm2835_mci_probe(struct device_d *hw_dev)
 {
struct resource *iores;
@@ -422,9 +415,6 @@ static int bcm2835_mci_probe(struct device_d 

[PATCH 1/3] common: restart: number unnamed restart handlers

2020-06-02 Thread Ahmad Fatoum
Follow-up commit allows referencing specific restart handler by name.
Restart handlers default to "default" as name when none is given.
Number them sequentially instead.

Signed-off-by: Ahmad Fatoum 
---
 common/restart.c  | 4 +++-
 include/restart.h | 1 -
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/common/restart.c b/common/restart.c
index b19ae54657c0..dd15c8d5c362 100644
--- a/common/restart.c
+++ b/common/restart.c
@@ -19,6 +19,7 @@
 #include 
 
 static LIST_HEAD(restart_handler_list);
+static unsigned resetidx;
 
 /**
  * restart_handler_register() - register a handler for restarting the system
@@ -31,7 +32,7 @@ static LIST_HEAD(restart_handler_list);
 int restart_handler_register(struct restart_handler *rst)
 {
if (!rst->name)
-   rst->name = RESTART_DEFAULT_NAME;
+   rst->name = basprintf("reset%u", resetidx);
if (!rst->priority)
rst->priority = RESTART_DEFAULT_PRIORITY;
 
@@ -40,6 +41,7 @@ int restart_handler_register(struct restart_handler *rst)
pr_debug("registering restart handler \"%s\" with priority %d\n",
rst->name, rst->priority);
 
+   resetidx++;
return 0;
 }
 
diff --git a/include/restart.h b/include/restart.h
index 7ec0910e9404..6880b03b936f 100644
--- a/include/restart.h
+++ b/include/restart.h
@@ -15,7 +15,6 @@ int restart_handler_register(struct restart_handler *);
 int restart_handler_register_fn(void (*restart_fn)(struct restart_handler *));
 
 #define RESTART_DEFAULT_PRIORITY 100
-#define RESTART_DEFAULT_NAME "default"
 
 unsigned int of_get_restart_priority(struct device_node *node);
 
-- 
2.27.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 3/3] commands: reset: allow specifying reset by name

2020-06-02 Thread Ahmad Fatoum
So far, we were fine by using the highest priority restart handler
whenever more than one was available. There are reasons to want to
configure this however:

 - When communicating with BootROM, e.g. to force boot from recovery
   mode: The reset chosen must not cause the reboot mode stored to
   volatile memory to vanish
 - When testing (undocumented) reset behavior, e.g. to analyze how
   the EFI reset behaves

Extend the reset command to support this. When no extra command line
option is supplied, the old behavior is maintained.

Signed-off-by: Ahmad Fatoum 
---
 commands/reset.c  | 27 ---
 common/restart.c  | 28 ++--
 include/restart.h |  2 ++
 3 files changed, 52 insertions(+), 5 deletions(-)

diff --git a/commands/reset.c b/commands/reset.c
index 2b10f1cd183a..fe54e2f9b472 100644
--- a/commands/reset.c
+++ b/commands/reset.c
@@ -11,24 +11,43 @@
 
 static int cmd_reset(int argc, char *argv[])
 {
+   struct restart_handler *rst;
int opt, shutdown_flag;
+   const char *name = NULL;
 
shutdown_flag = 1;
 
-   while ((opt = getopt(argc, argv, "f")) > 0) {
+   while ((opt = getopt(argc, argv, "flr:")) > 0) {
switch (opt) {
case 'f':
shutdown_flag = 0;
break;
+   case 'l':
+   restart_handlers_print();
+   return 0;
+   case 'r':
+   name = optarg;
+   break;
default:
return COMMAND_ERROR_USAGE;
}
}
 
+   rst = restart_handler_get_by_name(name);
+   if (!rst && name) {
+   printf("reset '%s' does not exist\n", name);
+   return COMMAND_ERROR;
+   }
+
if (shutdown_flag)
shutdown_barebox();
 
-   restart_machine();
+   if (rst) {
+   console_flush();
+   rst->restart(rst);
+   }
+
+   hang();
 
/* Not reached */
return 1;
@@ -37,12 +56,14 @@ static int cmd_reset(int argc, char *argv[])
 BAREBOX_CMD_HELP_START(reset)
 BAREBOX_CMD_HELP_TEXT("Options:")
 BAREBOX_CMD_HELP_OPT("-f",  "force RESET, don't call shutdown")
+BAREBOX_CMD_HELP_OPT("-l",  "list reset handlers")
+BAREBOX_CMD_HELP_OPT("-r RESET",  "use reset handler named RESET")
 BAREBOX_CMD_HELP_END
 
 BAREBOX_CMD_START(reset)
.cmd= cmd_reset,
BAREBOX_CMD_DESC("perform RESET of the CPU")
-   BAREBOX_CMD_OPTS("[-f]")
+   BAREBOX_CMD_OPTS("[-flr]")
BAREBOX_CMD_GROUP(CMD_GRP_BOOT)
BAREBOX_CMD_HELP(cmd_reset_help)
BAREBOX_CMD_COMPLETE(empty_complete)
diff --git a/common/restart.c b/common/restart.c
index 66131c262938..dcd0b2959bf4 100644
--- a/common/restart.c
+++ b/common/restart.c
@@ -75,20 +75,33 @@ int restart_handler_register_fn(const char *name,
 }
 
 /**
- * restart_machine() - reset the whole system
+ * restart_handler_get_by_name() - reset the whole system
  */
-void __noreturn restart_machine(void)
+struct restart_handler *restart_handler_get_by_name(const char *name)
 {
struct restart_handler *rst = NULL, *tmp;
unsigned int priority = 0;
 
list_for_each_entry(tmp, _handler_list, list) {
+   if (name && tmp->name && strcmp(name, tmp->name))
+   continue;
if (tmp->priority > priority) {
priority = tmp->priority;
rst = tmp;
}
}
 
+   return rst;
+}
+
+/**
+ * restart_machine() - reset the whole system
+ */
+void __noreturn restart_machine(void)
+{
+   struct restart_handler *rst;
+
+   rst = restart_handler_get_by_name(NULL);
if (rst) {
pr_debug("%s: using restart handler %s\n", __func__, rst->name);
console_flush();
@@ -112,3 +125,14 @@ unsigned int of_get_restart_priority(struct device_node 
*node)
 
return priority;
 }
+
+/*
+ * restart_handlers_print - print informations about all restart handlers
+ */
+void restart_handlers_print(void)
+{
+   struct restart_handler *tmp;
+
+   list_for_each_entry(tmp, _handler_list, list)
+   printf("%-20s %6d\n", tmp->name, tmp->priority);
+}
diff --git a/include/restart.h b/include/restart.h
index e7dd1bd2b79c..2d15c7598acc 100644
--- a/include/restart.h
+++ b/include/restart.h
@@ -2,7 +2,9 @@
 #ifndef __INCLUDE_RESTART_H
 #define __INCLUDE_RESTART_H
 
+void restart_handlers_print(void);
 void __noreturn restart_machine(void);
+struct restart_handler *restart_handler_get_by_name(const char *name);
 
 struct restart_handler {
void (*restart)(struct restart_handler *);
-- 
2.27.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 2/3] restart: give all restart handlers a descriptive name

2020-06-02 Thread Ahmad Fatoum
With incoming changes to choose a specific reset method, give all
currently unnamed "default" reset handlers a name:

  - soc reset via SoC-specific means
  - soc-wdt reset via SoC watchdog timer
  - vector  reset via jump to reset vector
  - efi reset via EFI firmware

Signed-off-by: Ahmad Fatoum 
---
 arch/arm/mach-at91/at91rm9200_time.c   | 2 +-
 arch/arm/mach-at91/at91sam9260.c   | 2 +-
 arch/arm/mach-at91/at91sam9261.c   | 2 +-
 arch/arm/mach-at91/at91sam9263.c   | 2 +-
 arch/arm/mach-at91/at91sam9g45.c   | 2 +-
 arch/arm/mach-at91/at91sam9n12.c   | 2 +-
 arch/arm/mach-at91/at91sam9x5.c| 2 +-
 arch/arm/mach-at91/sama5d3.c   | 2 +-
 arch/arm/mach-at91/sama5d4.c   | 2 +-
 arch/arm/mach-clps711x/reset.c | 2 +-
 arch/arm/mach-davinci/time.c   | 2 +-
 arch/arm/mach-ep93xx/clocksource.c | 2 +-
 arch/arm/mach-highbank/reset.c | 2 +-
 arch/arm/mach-mvebu/armada-370-xp.c| 2 +-
 arch/arm/mach-mvebu/dove.c | 2 +-
 arch/arm/mach-mvebu/kirkwood.c | 2 +-
 arch/arm/mach-mxs/soc-imx23.c  | 2 +-
 arch/arm/mach-mxs/soc-imx28.c  | 2 +-
 arch/arm/mach-nomadik/reset.c  | 2 +-
 arch/arm/mach-omap/am33xx_generic.c| 2 +-
 arch/arm/mach-omap/omap3_generic.c | 2 +-
 arch/arm/mach-omap/omap4_generic.c | 2 +-
 arch/arm/mach-pxa/common.c | 2 +-
 arch/arm/mach-rockchip/rk3188.c| 2 +-
 arch/arm/mach-rockchip/rk3288.c| 2 +-
 arch/arm/mach-samsung/generic.c| 2 +-
 arch/arm/mach-socfpga/arria10-generic.c| 2 +-
 arch/arm/mach-socfpga/cyclone5-reset-manager.c | 2 +-
 arch/arm/mach-tegra/tegra20-pmc.c  | 2 +-
 arch/arm/mach-versatile/core.c | 2 +-
 arch/arm/mach-vexpress/reset.c | 2 +-
 arch/arm/mach-zynq/zynq.c  | 2 +-
 arch/kvx/cpu/reset.c   | 2 +-
 arch/mips/mach-ar231x/ar231x_reset.c   | 2 +-
 arch/mips/mach-ath79/reset.c   | 2 +-
 arch/mips/mach-bcm47xx/reset.c | 2 +-
 arch/mips/mach-loongson/loongson1_reset.c  | 2 +-
 arch/mips/mach-malta/reset.c   | 2 +-
 arch/nios2/cpu/cpu.c   | 2 +-
 arch/openrisc/cpu/cpu.c| 2 +-
 arch/powerpc/mach-mpc5xxx/cpu.c| 2 +-
 arch/powerpc/mach-mpc85xx/cpu.c| 2 +-
 common/efi/efi.c   | 2 +-
 common/restart.c   | 5 -
 include/restart.h  | 3 ++-
 45 files changed, 49 insertions(+), 45 deletions(-)

diff --git a/arch/arm/mach-at91/at91rm9200_time.c 
b/arch/arm/mach-at91/at91rm9200_time.c
index 975cd956c986..f89983fe63c6 100644
--- a/arch/arm/mach-at91/at91rm9200_time.c
+++ b/arch/arm/mach-at91/at91rm9200_time.c
@@ -88,7 +88,7 @@ static void __noreturn at91rm9200_restart_soc(struct 
restart_handler *rst)
 
 static int restart_register_feature(void)
 {
-   restart_handler_register_fn(at91rm9200_restart_soc);
+   restart_handler_register_fn("soc-wdt", at91rm9200_restart_soc);
 
return 0;
 }
diff --git a/arch/arm/mach-at91/at91sam9260.c b/arch/arm/mach-at91/at91sam9260.c
index 56327a2c4710..fdd8ea014e9d 100644
--- a/arch/arm/mach-at91/at91sam9260.c
+++ b/arch/arm/mach-at91/at91sam9260.c
@@ -243,7 +243,7 @@ static void at91sam9260_initialize(void)
at91_add_pit(AT91SAM9260_BASE_PIT);
at91_add_sam9_smc(DEVICE_ID_SINGLE, AT91SAM9260_BASE_SMC, 0x200);
 
-   restart_handler_register_fn(at91sam9260_restart);
+   restart_handler_register_fn("soc", at91sam9260_restart);
 }
 
 static int at91sam9260_setup(void)
diff --git a/arch/arm/mach-at91/at91sam9261.c b/arch/arm/mach-at91/at91sam9261.c
index 4abc55635413..0465ed9524df 100644
--- a/arch/arm/mach-at91/at91sam9261.c
+++ b/arch/arm/mach-at91/at91sam9261.c
@@ -235,7 +235,7 @@ static void at91sam9261_initialize(void)
at91_add_pit(AT91SAM9261_BASE_PIT);
at91_add_sam9_smc(DEVICE_ID_SINGLE, AT91SAM9261_BASE_SMC, 0x200);
 
-   restart_handler_register_fn(at91sam9261_restart);
+   restart_handler_register_fn("soc", at91sam9261_restart);
 }
 
 static int at91sam9261_setup(void)
diff --git a/arch/arm/mach-at91/at91sam9263.c b/arch/arm/mach-at91/at91sam9263.c
index 690f8e06bb12..dc5dddfb646a 100644
--- a/arch/arm/mach-at91/at91sam9263.c
+++ b/arch/arm/mach-at91/at91sam9263.c
@@ -256,7 +256,7 @@ static void at91sam9263_initialize(void)
at91_add_sam9_smc(0, AT91SAM9263_BASE_SMC0, 0x200);
at91_add_sam9_smc(1, AT91SAM9263_BASE_SMC1, 0x200);
 
-   restart_handler_register_fn(at91sam9263_restart);
+   restart_handler_register_fn("soc", at91sam9263_restart);
 }
 
 static int at91sam9263_setup(void)
diff 

[PATCH] fixup! blspec: Allow the "options" key to be given multiple times

2020-06-02 Thread Ahmad Fatoum
constness was erroneously cast away. Reinstate const safety.

Signed-off-by: Ahmad Fatoum 
---
 common/blspec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/blspec.c b/common/blspec.c
index 3be26d0a7a14..9e1036c8342c 100644
--- a/common/blspec.c
+++ b/common/blspec.c
@@ -301,7 +301,7 @@ static struct blspec_entry *blspec_entry_open(struct 
bootentries *bootentries,
if (!strcmp(name, "options")) {
/* If there was a previous "options" key given, prepend 
its value
 * (as per spec). */
-   char *prev_val = blspec_entry_var_get(entry, name);
+   const char *prev_val = blspec_entry_var_get(entry, 
name);
if (prev_val) {
char *opts = xasprintf("%s %s", prev_val, val);
blspec_entry_var_set(entry, name, opts);
-- 
2.27.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [RFC] inkscape 1.0 issue

2020-06-02 Thread Sascha Hauer
Hi Antony,

On Tue, Jun 02, 2020 at 01:20:35AM +0300, Antony Pavlov wrote:
> 
> diff --git a/lib/logo/Makefile b/lib/logo/Makefile
> index eb7aee080e..8c81447df7 100644
> --- a/lib/logo/Makefile
> +++ b/lib/logo/Makefile
> @@ -1,17 +1,17 @@
>  
> -OPTS_barebox-logo-w64.bblogo="-w 64"
> +OPTS_barebox-logo-w64.bblogo = --export-width=64
>  bblogo-$(CONFIG_BAREBOX_LOGO_64) += barebox-logo-w64

according to the man page --export-width=64 is supported by 0.92.4 as
well, so we could change this part unconditionally.

> @@ -41,7 +41,8 @@ cmd_logo_S =
> \
>  quiet_cmd_logo = LOGO.S   $@
>  cmd_logo =   \
>  (\
> - inkscape -z $(OPTS_$(@F)) -e $@ $< > /dev/null; \
> + DISPLAY="" inkscape $(OPTS_$(@F)) --export-type=png $< > /dev/null; \
> + mv $(patsubst %.svg,%.png,$<) $@; \

Inkscape-1.0 supports "-o -" and pre Inkscape-1.0 supports "-e -", we
could use this to do without the mv in both cases.

DISPLAY="" shouldn't hurt on pre Inkscape-1.0. as well.

This leaves '-z' and -e vs. --export-type=png. Something like this should work:

INKSCAPEOPTS += $(call try-run, inkscape -z,-z,)
INKSCAPEOPTS += $(call try-run, inkscape -e,-e,--export_type=png)

Regards,
 Sascha

-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | http://www.pengutronix.de/  |
31137 Hildesheim, Germany  | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH] ARM: i.MX: enable Master Identifier Unlock

2020-06-02 Thread Sascha Hauer
On Thu, May 28, 2020 at 02:56:11PM +0200, Rouven Czerwinski wrote:
> By default the HAB locks the Master Identifier (MID) to preconfigured
> values. This is not a problem if Linux is running in the secure world,
> however when running a secure world operating system such as OP-TEE, the
> MID configuration should be done by the secure world operating system.
> 
> This causes no regressions for systems using no secure world operating
> systems, since no MID value indicates that all normal/secure world
> entities can access the peripherals supporting the MID.
> 
> Signed-off-by: Rouven Czerwinski 
> ---
>  arch/arm/mach-imx/include/mach/habv4-imx6-gencsf.h | 2 +-
>  arch/arm/mach-imx/include/mach/habv4-imx8-gencsf.h | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)

Applied, thanks

Sascha

-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | http://www.pengutronix.de/  |
31137 Hildesheim, Germany  | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: configure the mac address of an eth device

2020-06-02 Thread Sascha Hauer
On Tue, May 26, 2020 at 05:54:53PM +0200, Giorgio Dal Molin wrote:
> Hi Sascha,
> 
> thank you for your suggestion about the MAC, the code works now as expected.
> 
> Just another quick question: is there a function like 
> of_eth_register_ethaddr()
> also for a 'serial-number' value ?
> 
> I also have a 'serial number' value from the eeprom and I would like to pass 
> to the kernel.
> Just calling something like:
> 
> of_set_property(of_get_root_node(), "serial-number", s, strlen(s) + 1, 1);
> 
> does not work because it changes only the device tree for barebox but not that
> for the kernel. So I registered an of fixup:
> 
> of_register_fixup(samx7_board_fixup, s);
> 
> for it and it works then but it is a bit more complex.

Yes, you have to do it like that, there is no shortcut for it.

Sascha


-- 
Pengutronix e.K.   | |
Steuerwalder Str. 21   | http://www.pengutronix.de/  |
31137 Hildesheim, Germany  | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox