Re: [PATCH] fastboot: Only call the bootm command if it is enabled

2023-02-22 Thread Mattijs Korpershoek
On lun., févr. 20, 2023 at 00:14, Samuel Holland  wrote:

> This fixes an error with trying to link against do_bootm() when
> CONFIG_CMD_BOOTM is disabled.
>
> Signed-off-by: Samuel Holland 

Reviewed-by: Mattijs Korpershoek 

> ---
>
>  drivers/fastboot/fb_common.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/fastboot/fb_common.c b/drivers/fastboot/fb_common.c
> index 57b6182c46a..20aa80838ae 100644
> --- a/drivers/fastboot/fb_common.c
> +++ b/drivers/fastboot/fb_common.c
> @@ -135,7 +135,7 @@ void fastboot_boot(void)
>   s = env_get("fastboot_bootcmd");
>   if (s) {
>   run_command(s, CMD_FLAG_ENV);
> - } else {
> + } else if (IS_ENABLED(CONFIG_CMD_BOOTM)) {
>   static char boot_addr_start[20];
>   static char *const bootm_args[] = {
>   "bootm", boot_addr_start, NULL
> -- 
> 2.39.2


Re: [PATCH] usb: dwc3-meson-g12a: Select PHY instead of imply PHY

2023-02-24 Thread Mattijs Korpershoek
On jeu., févr. 23, 2023 at 17:32, Marek Vasut  wrote:

> Imply means you can turn off the option and expect things to work
> - "it's a good idea to have X enabled" is when to use imply
> - "you must have X for Y to work" is when to use select
>
> Use "select" here.
>
> Signed-off-by: Marek Vasut 

Reviewed-by: Mattijs Korpershoek 

> ---
> Cc: Mattijs Korpershoek 
> Cc: Neil Armstrong 
> Cc: Tom Rini 
> ---
>  drivers/usb/dwc3/Kconfig | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
> index f010291d022..e8373b30bb7 100644
> --- a/drivers/usb/dwc3/Kconfig
> +++ b/drivers/usb/dwc3/Kconfig
> @@ -40,7 +40,7 @@ config SPL_USB_DWC3_GENERIC
>  config USB_DWC3_MESON_G12A
>   bool "Amlogic Meson G12A USB wrapper"
>   depends on DM_USB && USB_DWC3 && ARCH_MESON
> - imply PHY
> + select PHY
>   help
> Select this for Amlogic Meson G12A Platforms.
> This wrapper supports Host and Peripheral operation modes.
> @@ -48,7 +48,7 @@ config USB_DWC3_MESON_G12A
>  config USB_DWC3_MESON_GXL
>   bool "Amlogic Meson GXL USB wrapper"
>   depends on DM_USB && USB_DWC3 && ARCH_MESON
> - imply PHY
> + select PHY
>   help
> Select this for Amlogic Meson GXL and GXM Platforms.
> This wrapper supports Host and Peripheral operation modes.
> -- 
> 2.39.1


Re: [PATCH] lib: sparse: allocate blkcnt instead of arbitrary small number

2023-07-06 Thread Mattijs Korpershoek
On lun., juin 19, 2023 at 10:21, Mattijs Korpershoek 
 wrote:

> Hi Qianfan,
>
> Thank you for your review.
>
> On lun., juin 19, 2023 at 14:19, qianfan  wrote:
>
>> 在 2023/6/16 21:26, Mattijs Korpershoek 写道:
>>> Commit 62649165cb02 ("lib: sparse: Make CHUNK_TYPE_RAW buffer aligned")
>>> fixed cache alignment for systems with a D-CACHE.
>>>
>>> However it introduced some performance regressions [1] on system
>>> flashing huge images, such as Android.
>>>
>>> On AM62x SK EVM, we also observe such performance penalty:
>>> Sending sparse 'super' 1/2 (768793 KB) OKAY [ 23.954s]
>>> Writing 'super'OKAY [ 75.926s]
>>> Sending sparse 'super' 2/2 (629819 KB) OKAY [ 19.641s]
>>> Writing 'super'OKAY [ 62.849s]
>>> Finished. Total time: 182.474s
>>>
>>> The reason for this is that we use an arbitrary small buffer
>>> (info->blksz * 100) for transferring.
>>>
>>> Fix it by using a bigger buffer (info->blksz * blkcnt) as suggested in
>>> the original's patch review [2].
>>>
>>> With this patch, performance impact is mitigated:
>>> Sending sparse 'super' 1/2 (768793 KB) OKAY [ 24.006s]
>>> Writing 'super'OKAY [ 15.920s]
>>> Sending sparse 'super' 2/2 (629819 KB) OKAY [ 19.651s]
>>> Writing 'super'    OKAY [ 14.665s]
>>> Finished. Total time: 74.346s
>>>
>>> [1] 
>>> https://lore.kernel.org/r/20221118121323.4009193-1-gary.bis...@boundarydevices.com
>>> [2] 
>>> https://lore.kernel.org/r/all/43e4c17c-4483-ec8e-f843-9b4c5569b...@seco.com/
>>>
>>> Fixes: 62649165cb02 ("lib: sparse: Make CHUNK_TYPE_RAW buffer aligned")
>>> Signed-off-by: Mattijs Korpershoek 
>>> ---
>>>   lib/image-sparse.c | 2 +-
>>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/lib/image-sparse.c b/lib/image-sparse.c
>>> index 5ec0f94ab3eb..25aed0604192 100644
>>> --- a/lib/image-sparse.c
>>> +++ b/lib/image-sparse.c
>>> @@ -55,7 +55,7 @@ static lbaint_t write_sparse_chunk_raw(struct 
>>> sparse_storage *info,
>>>void *data,
>>>char *response)
>>>   {
>>> -   lbaint_t n = blkcnt, write_blks, blks = 0, aligned_buf_blks = 100;
>>> +   lbaint_t n = blkcnt, write_blks, blks = 0, aligned_buf_blks = blkcnt;
>> Hi:
>>
>> It's a good point that this code report the performance was affected by
>> write large small
>> mmc blks, not memory copy.
>
> I believe memory copy also affects performance, but in my case,
> it has less impact than small mmc blks.
>
> With 62649165cb02 reverted:
> Sending sparse 'super' 1/2 (768793 KB) OKAY [ 23.947s]
> Writing 'super'OKAY [ 12.983s]
> Sending sparse 'super' 2/2 (629819 KB) OKAY [ 19.600s]
> Writing 'super'OKAY [ 12.796s]
> Finished. Total time: 69.430s
>
> With aligned_buf_blks = blkcnt:
> Sending sparse 'super' 1/2 (768793 KB) OKAY [ 24.072s]
> Writing 'super'OKAY [ 16.177s]
> Sending sparse 'super' 2/2 (629819 KB) OKAY [ 19.681s]
> Writing 'super'OKAY [ 14.845s]
> Finished. Total time: 74.919s
>
>>
>> And I can not make sure whether memalign can always alloc such huge
>> memory when we change the
>> aligned_buf_blks to blkcnt.
>
> Could you clarify the concern here? I've dumped blkcnt for my board
> (AM62x SK EVK) and the biggest blkcnt I found was: 131072
>
> With info->blksz = 512, this gives me: 512 * 131072 = 67108864
>
> Which is a memalign (memory alloc) of 64MB. Is 64MB really that big? (I
> don't realize it's that much)
>
>>
>> Could you please set aligned_buf_blks to FASTBOOT_MAX_BLK_WRITE(16384)
>> and test again?
>
> With aligned_buf_blks = FASTBOOT_MAX_BLK_WRITE(16384):
> Sending sparse 'super' 1/2 (768793 KB) OKAY [ 23.912s]
> Writing 'super'OKAY [ 15.780s]
> Sending sparse 'super' 2/2 (629819 KB) OKAY [ 19.581s]
> Writing &#x

Re: [PATCH] lib: sparse: allocate blkcnt instead of arbitrary small number

2023-07-06 Thread Mattijs Korpershoek
On jeu., juil. 06, 2023 at 13:00, Tom Rini  wrote:

> On Thu, Jul 06, 2023 at 11:43:13AM +0200, Mattijs Korpershoek wrote:
>> On lun., juin 19, 2023 at 10:21, Mattijs Korpershoek 
>>  wrote:
>> 
>> > Hi Qianfan,
>> >
>> > Thank you for your review.
>> >
>> > On lun., juin 19, 2023 at 14:19, qianfan  wrote:
>> >
>> >> 在 2023/6/16 21:26, Mattijs Korpershoek 写道:
>> >>> Commit 62649165cb02 ("lib: sparse: Make CHUNK_TYPE_RAW buffer aligned")
>> >>> fixed cache alignment for systems with a D-CACHE.
>> >>>
>> >>> However it introduced some performance regressions [1] on system
>> >>> flashing huge images, such as Android.
>> >>>
>> >>> On AM62x SK EVM, we also observe such performance penalty:
>> >>> Sending sparse 'super' 1/2 (768793 KB) OKAY [ 23.954s]
>> >>> Writing 'super'OKAY [ 75.926s]
>> >>> Sending sparse 'super' 2/2 (629819 KB) OKAY [ 19.641s]
>> >>> Writing 'super'OKAY [ 62.849s]
>> >>> Finished. Total time: 182.474s
>> >>>
>> >>> The reason for this is that we use an arbitrary small buffer
>> >>> (info->blksz * 100) for transferring.
>> >>>
>> >>> Fix it by using a bigger buffer (info->blksz * blkcnt) as suggested in
>> >>> the original's patch review [2].
>> >>>
>> >>> With this patch, performance impact is mitigated:
>> >>> Sending sparse 'super' 1/2 (768793 KB) OKAY [ 24.006s]
>> >>> Writing 'super'OKAY [ 15.920s]
>> >>> Sending sparse 'super' 2/2 (629819 KB) OKAY [ 19.651s]
>> >>> Writing 'super'OKAY [ 14.665s]
>> >>> Finished. Total time: 74.346s
>> >>>
>> >>> [1] 
>> >>> https://lore.kernel.org/r/20221118121323.4009193-1-gary.bis...@boundarydevices.com
>> >>> [2] 
>> >>> https://lore.kernel.org/r/all/43e4c17c-4483-ec8e-f843-9b4c5569b...@seco.com/
>> >>>
>> >>> Fixes: 62649165cb02 ("lib: sparse: Make CHUNK_TYPE_RAW buffer aligned")
>> >>> Signed-off-by: Mattijs Korpershoek 
>> >>> ---
>> >>>   lib/image-sparse.c | 2 +-
>> >>>   1 file changed, 1 insertion(+), 1 deletion(-)
>> >>>
>> >>> diff --git a/lib/image-sparse.c b/lib/image-sparse.c
>> >>> index 5ec0f94ab3eb..25aed0604192 100644
>> >>> --- a/lib/image-sparse.c
>> >>> +++ b/lib/image-sparse.c
>> >>> @@ -55,7 +55,7 @@ static lbaint_t write_sparse_chunk_raw(struct 
>> >>> sparse_storage *info,
>> >>>void *data,
>> >>>char *response)
>> >>>   {
>> >>> -lbaint_t n = blkcnt, write_blks, blks = 0, aligned_buf_blks = 
>> >>> 100;
>> >>> +lbaint_t n = blkcnt, write_blks, blks = 0, aligned_buf_blks = 
>> >>> blkcnt;
>> >> Hi:
>> >>
>> >> It's a good point that this code report the performance was affected by
>> >> write large small
>> >> mmc blks, not memory copy.
>> >
>> > I believe memory copy also affects performance, but in my case,
>> > it has less impact than small mmc blks.
>> >
>> > With 62649165cb02 reverted:
>> > Sending sparse 'super' 1/2 (768793 KB) OKAY [ 23.947s]
>> > Writing 'super'OKAY [ 12.983s]
>> > Sending sparse 'super' 2/2 (629819 KB) OKAY [ 19.600s]
>> > Writing 'super'OKAY [ 12.796s]
>> > Finished. Total time: 69.430s
>> >
>> > With aligned_buf_blks = blkcnt:
>> > Sending sparse 'super' 1/2 (768793 KB) OKAY [ 24.072s]
>> > Writing 'super'OKAY [ 16.177s]
>> > Sending sparse 'super' 2/2 (629819 KB) OKAY [ 19.681s]
>> > Writing 'super'OKAY [ 14.845s]
>> > Finished. Total time: 74.919s
>> >
>> >>
>> >> And I can

[PATCH v2] lib: sparse: allocate FASTBOOT_MAX_BLK_WRITE instead of small number

2023-07-07 Thread Mattijs Korpershoek
Commit 62649165cb02 ("lib: sparse: Make CHUNK_TYPE_RAW buffer aligned")
fixed cache alignment for systems with a D-CACHE.

However it introduced some performance regressions [1] on system
flashing huge images, such as Android.

On AM62x SK EVM, we also observe such performance penalty:
Sending sparse 'super' 1/2 (768793 KB) OKAY [ 23.954s]
Writing 'super'OKAY [ 75.926s]
Sending sparse 'super' 2/2 (629819 KB) OKAY [ 19.641s]
Writing 'super'OKAY [ 62.849s]
Finished. Total time: 182.474s

The reason for this is that we use an arbitrary small buffer
(info->blksz * 100) for transferring.

Fix it by using a bigger buffer (info->blksz * FASTBOOT_MAX_BLK_WRITE)
as suggested in the original's patch review [2].

With this patch, performance impact is mitigated:
Sending sparse 'super' 1/2 (768793 KB) OKAY [ 23.912s]
Writing 'super'OKAY [ 15.780s]
Sending sparse 'super' 2/2 (629819 KB) OKAY [ 19.581s]
Writing 'super'OKAY [ 17.192s]
Finished. Total time: 76.569s

[1] 
https://lore.kernel.org/r/20221118121323.4009193-1-gary.bis...@boundarydevices.com
[2] https://lore.kernel.org/r/all/43e4c17c-4483-ec8e-f843-9b4c5569b...@seco.com/

Fixes: 62649165cb02 ("lib: sparse: Make CHUNK_TYPE_RAW buffer aligned")
Signed-off-by: Mattijs Korpershoek 
---
Changes in v2:
- Use FASTBOOT_MAX_BLK_WRITE instead of blkcnt (Qianfan)
- Link to v1: 
https://lore.kernel.org/r/20230616-sparse-flash-fix-v1-1-6bafeacc5...@baylibre.com
---
 drivers/fastboot/fb_mmc.c | 2 --
 include/image-sparse.h| 2 ++
 lib/image-sparse.c| 3 ++-
 3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/fastboot/fb_mmc.c b/drivers/fastboot/fb_mmc.c
index 9d25c402028a..060918e49109 100644
--- a/drivers/fastboot/fb_mmc.c
+++ b/drivers/fastboot/fb_mmc.c
@@ -19,8 +19,6 @@
 #include 
 #include 
 
-#define FASTBOOT_MAX_BLK_WRITE 16384
-
 #define BOOT_PARTITION_NAME "boot"
 
 struct fb_mmc_sparse {
diff --git a/include/image-sparse.h b/include/image-sparse.h
index 0572dbd0a283..282a0b256498 100644
--- a/include/image-sparse.h
+++ b/include/image-sparse.h
@@ -7,6 +7,8 @@
 #include 
 #include 
 
+#define FASTBOOT_MAX_BLK_WRITE 16384
+
 #define ROUNDUP(x, y)  (((x) + ((y) - 1)) & ~((y) - 1))
 
 struct sparse_storage {
diff --git a/lib/image-sparse.c b/lib/image-sparse.c
index 5ec0f94ab3eb..8f8a67e15804 100644
--- a/lib/image-sparse.c
+++ b/lib/image-sparse.c
@@ -55,7 +55,8 @@ static lbaint_t write_sparse_chunk_raw(struct sparse_storage 
*info,
   void *data,
   char *response)
 {
-   lbaint_t n = blkcnt, write_blks, blks = 0, aligned_buf_blks = 100;
+   lbaint_t n = blkcnt, write_blks, blks = 0;
+   lbaint_t aligned_buf_blks = FASTBOOT_MAX_BLK_WRITE;
uint32_t *aligned_buf = NULL;
 
if (CONFIG_IS_ENABLED(SYS_DCACHE_OFF)) {

---
base-commit: 923de765ee1a5b26310f02cb42dcbad9e2b011c5
change-id: 20230616-sparse-flash-fix-9c2852aa8d16

Best regards,
-- 
Mattijs Korpershoek 



Re: [PATCH v2] lib: sparse: allocate FASTBOOT_MAX_BLK_WRITE instead of small number

2023-07-07 Thread Mattijs Korpershoek
Hi Qianfan,

Thank you for your review.

On ven., juil. 07, 2023 at 18:54, qianfan  wrote:

> 在 2023/7/7 16:13, Mattijs Korpershoek 写道:
>> Commit 62649165cb02 ("lib: sparse: Make CHUNK_TYPE_RAW buffer aligned")
>> fixed cache alignment for systems with a D-CACHE.
>>
>> However it introduced some performance regressions [1] on system
>> flashing huge images, such as Android.
>>
>> On AM62x SK EVM, we also observe such performance penalty:
>> Sending sparse 'super' 1/2 (768793 KB) OKAY [ 23.954s]
>> Writing 'super'OKAY [ 75.926s]
>> Sending sparse 'super' 2/2 (629819 KB) OKAY [ 19.641s]
>> Writing 'super'OKAY [ 62.849s]
>> Finished. Total time: 182.474s
>>
>> The reason for this is that we use an arbitrary small buffer
>> (info->blksz * 100) for transferring.
>>
>> Fix it by using a bigger buffer (info->blksz * FASTBOOT_MAX_BLK_WRITE)
>> as suggested in the original's patch review [2].
>>
>> With this patch, performance impact is mitigated:
>> Sending sparse 'super' 1/2 (768793 KB) OKAY [ 23.912s]
>> Writing 'super'OKAY [ 15.780s]
>> Sending sparse 'super' 2/2 (629819 KB) OKAY [ 19.581s]
>> Writing 'super'OKAY [ 17.192s]
>> Finished. Total time: 76.569s
>>
>> [1] 
>> https://lore.kernel.org/r/20221118121323.4009193-1-gary.bis...@boundarydevices.com
>> [2] 
>> https://lore.kernel.org/r/all/43e4c17c-4483-ec8e-f843-9b4c5569b...@seco.com/
>>
>> Fixes: 62649165cb02 ("lib: sparse: Make CHUNK_TYPE_RAW buffer aligned")
>> Signed-off-by: Mattijs Korpershoek 
>> ---
>> Changes in v2:
>> - Use FASTBOOT_MAX_BLK_WRITE instead of blkcnt (Qianfan)
>> - Link to v1: 
>> https://lore.kernel.org/r/20230616-sparse-flash-fix-v1-1-6bafeacc5...@baylibre.com
>> ---
>>   drivers/fastboot/fb_mmc.c | 2 --
>>   include/image-sparse.h| 2 ++
>>   lib/image-sparse.c| 3 ++-
>>   3 files changed, 4 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/fastboot/fb_mmc.c b/drivers/fastboot/fb_mmc.c
>> index 9d25c402028a..060918e49109 100644
>> --- a/drivers/fastboot/fb_mmc.c
>> +++ b/drivers/fastboot/fb_mmc.c
>> @@ -19,8 +19,6 @@
>>   #include 
>>   #include 
>>   
>> -#define FASTBOOT_MAX_BLK_WRITE 16384
>> -
>>   #define BOOT_PARTITION_NAME "boot"
>>   
>>   struct fb_mmc_sparse {
>> diff --git a/include/image-sparse.h b/include/image-sparse.h
>> index 0572dbd0a283..282a0b256498 100644
>> --- a/include/image-sparse.h
>> +++ b/include/image-sparse.h
>> @@ -7,6 +7,8 @@
>>   #include 
>>   #include 
>>   
>> +#define FASTBOOT_MAX_BLK_WRITE 16384
> Hi:
>
> Just a personal suggestion, define sometings like FASTBOOT_MAX_BLK_WRITE in
> image-sparse.c is very strange.
>
> Or maybe define a marco such as SPARSE_MAX_BLK_WRITE and set a default
> value to 16384, and leave some comments for why we choice this value.

I don't agree with having a duplicating between SPARSE_MAX_BLK_WRITE
and FASTBOOT_MAX_BLK_WRITE. code comments can rot as well.

And FASTBOOT_MAX_BLK_WRITE is used for both sparse and unsparsed image,
which is why I chose to not rename it.

>
> Thanks.
>> +
>>   #define ROUNDUP(x, y)  (((x) + ((y) - 1)) & ~((y) - 1))
>>   
>>   struct sparse_storage {
>> diff --git a/lib/image-sparse.c b/lib/image-sparse.c
>> index 5ec0f94ab3eb..8f8a67e15804 100644
>> --- a/lib/image-sparse.c
>> +++ b/lib/image-sparse.c
>> @@ -55,7 +55,8 @@ static lbaint_t write_sparse_chunk_raw(struct 
>> sparse_storage *info,
>> void *data,
>> char *response)
>>   {
>> -lbaint_t n = blkcnt, write_blks, blks = 0, aligned_buf_blks = 100;
>> +lbaint_t n = blkcnt, write_blks, blks = 0;
>> +lbaint_t aligned_buf_blks = FASTBOOT_MAX_BLK_WRITE;
>>  uint32_t *aligned_buf = NULL;
>>   
>>  if (CONFIG_IS_ENABLED(SYS_DCACHE_OFF)) {
>>
>> ---
>> base-commit: 923de765ee1a5b26310f02cb42dcbad9e2b011c5
>> change-id: 20230616-sparse-flash-fix-9c2852aa8d16
>>
>> Best regards,


Re: [RFC PATCH 3/4] arm: dts: Fix build of am62a7 dtbs

2023-07-13 Thread Mattijs Korpershoek
On jeu., juil. 13, 2023 at 02:20, Nishanth Menon  wrote:

> am62a7 should be built with CONFIG_SOC_K3_AM62A7 not CONFIG_SOC_K3_AM625
>
> Fixes: 6bdfa69155d8 ("arm: dts: introduce am62a7 u-boot dtbs")
> Cc: Bryan Brattlof 
> Cc: Vignesh Raghavendra 
> Cc: Francesco Dolcini 
> Cc: Sjoerd Simons 
> Cc: Wadim Egorov 
> Signed-off-by: Nishanth Menon 
> ---

Reviewed-by: Mattijs Korpershoek 

>
> Found this as i was building and wondering why 62a7 dtbs were building..
>
>  arch/arm/dts/Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
> index 17f506a8fa06..e4b658ae0416 100644
> --- a/arch/arm/dts/Makefile
> +++ b/arch/arm/dts/Makefile
> @@ -1301,7 +1301,7 @@ dtb-$(CONFIG_SOC_K3_AM642) += k3-am642-evm.dtb \
>  dtb-$(CONFIG_SOC_K3_AM625) += k3-am625-sk.dtb \
> k3-am625-r5-sk.dtb
>  
> -dtb-$(CONFIG_SOC_K3_AM625) += k3-am62a7-sk.dtb \
> +dtb-$(CONFIG_SOC_K3_AM62A7) += k3-am62a7-sk.dtb \
> k3-am62a7-r5-sk.dtb
>  
>  dtb-$(CONFIG_ARCH_MEDIATEK) += \
> -- 
> 2.40.0


Re: [PATCH] phy: meson-g12a-usb2: fix ret check on power_domain_get

2023-10-17 Thread Mattijs Korpershoek
On mar., oct. 17, 2023 at 20:57, "Guillaume La Roque"  
wrote:

> Patch which add A1 SoC support create a regression on khadas vim3/vim3l
> boards when we try to use fastboot command:
>
>   => fastboot usb 0
>   failed to get power domain
>   failed to get power domain
>   No USB device found
>   USB init failed: -19
>
> Add ENOENT check on ret in probe function.
>
> Fixes: 5533c883ce10 ("phy: support Amlogic A1 family")
>
> Signed-off-by: Guillaume La Roque 

Tested on vim3 with:

=> fastboot usb 0

Tested-by: Mattijs Korpershoek  # on vim3

> ---
>  drivers/phy/meson-g12a-usb2.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/phy/meson-g12a-usb2.c b/drivers/phy/meson-g12a-usb2.c
> index 4ba3992bda70..3958d2404b85 100644
> --- a/drivers/phy/meson-g12a-usb2.c
> +++ b/drivers/phy/meson-g12a-usb2.c
> @@ -328,12 +328,12 @@ int meson_g12a_usb2_phy_probe(struct udevice *dev)
>  
>  #if CONFIG_IS_ENABLED(POWER_DOMAIN)
>   ret = power_domain_get(dev, &priv->pwrdm);
> - if (ret < 0 && ret != -ENODEV) {
> - pr_err("failed to get power domain\n");
> + if (ret < 0 && ret != -ENODEV && ret != -ENOENT) {
> + pr_err("failed to get power domain : %d\n", ret);
>   return ret;
>   }
>  
> - if (ret != -ENODEV) {
> + if (ret != -ENODEV && ret != -ENOENT) {
>   ret = power_domain_on(&priv->pwrdm);
>   if (ret < 0) {
>   pr_err("failed to enable power domain\n");
> -- 
> 2.34.1
>
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Groups.io Links: You receive all messages sent to this group.
> View/Reply Online (#1773): https://groups.io/g/u-boot-amlogic/message/1773
> Mute This Topic: https://groups.io/mt/102024645/1991006
> Group Owner: u-boot-amlogic+ow...@groups.io
> Unsubscribe: https://groups.io/g/u-boot-amlogic/unsub 
> [mkorpersh...@baylibre.com]
> -=-=-=-=-=-=-=-=-=-=-=-


Re: [PATCH v3 1/3] cmd: Change the dependencies between CMD_BIND and USB_GADGET

2023-10-18 Thread Mattijs Korpershoek
On mar., oct. 10, 2023 at 11:03, Miquel Raynal  
wrote:

> Today CMD_BIND defaults to 'y' when USB_ETHER is enabled. In practice,
> CMD_BIND should default to 'y' when any USB gadget is enabled not only
> USB_ETHER. Let's invert the logic of the dependency and use the weak
> 'imply' keyword to enforce this.
>
> Signed-off-by: Miquel Raynal 

Tested that the bind command exists when building with:
configs/khadas-vim3_android_defconfig

Reviewed-by: Mattijs Korpershoek 
Tested-by: Mattijs Korpershoek  # on vim3

> ---
>  cmd/Kconfig| 1 -
>  drivers/usb/gadget/Kconfig | 1 +
>  2 files changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/cmd/Kconfig b/cmd/Kconfig
> index 43ca10f69cc..6cc3bf6c2d0 100644
> --- a/cmd/Kconfig
> +++ b/cmd/Kconfig
> @@ -996,7 +996,6 @@ config CMD_BCB
>  config CMD_BIND
>   bool "bind/unbind - Bind or unbind a device to/from a driver"
>   depends on DM
> - default y if USB_ETHER
>   help
> Bind or unbind a device to/from a driver from the command line.
> This is useful in situations where a device may be handled by several
> diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
> index 1cfe6022842..44f47a07207 100644
> --- a/drivers/usb/gadget/Kconfig
> +++ b/drivers/usb/gadget/Kconfig
> @@ -17,6 +17,7 @@ menuconfig USB_GADGET
>   bool "USB Gadget Support"
>   depends on DM
>   select DM_USB
> + imply CMD_BIND
>   help
>  USB is a master/slave protocol, organized with one master
>  host (such as a PC) controlling up to 127 peripheral devices.
> -- 
> 2.34.1


Re: [PATCH 0/2] MAINTAINERS: Add Mattijs to USB/fastboot maintainers

2023-10-19 Thread Mattijs Korpershoek
Hi Lukasz, Marek,

On mer., oct. 18, 2023 at 12:52, Lukasz Majewski  wrote:

> Hi Mattijs,
>
>> From discussions with Marek at Kernel Recipes, it seems that the USB
>> subsystem in U-boot need some help.
>> 
>> Since I've been asked and I'm willing to help, I've added myself to
>> the maintainers entry.
>> 
>> I have also added myself for fastboot since I'm interested in keeping
>> that functional as well.
>> 
>> Note that I have no previous (open-source) maintainer experience so I
>> will do my best to learn.
>> 
>
> Thanks for willing to help with maintaining the code. If you need any
> help - then just ask :-)
>
> Acked-by: Lukasz Majewski 

Thank you for acknowledging. I'm both very happy and a bit nervous to
start :)

Do we still use the following custodian tree:
https://source.denx.de/u-boot/custodians/u-boot-dfu ?

If yes, I imagine I would need write access to it.


>
>> Signed-off-by: Mattijs Korpershoek 
>> ---
>> Mattijs Korpershoek (2):
>>   MAINTAINERS: usb gadget: add Mattijs
>>   MAINTAINERS: fastboot: add Mattijs
>> 
>>  MAINTAINERS | 4 +++-
>>  1 file changed, 3 insertions(+), 1 deletion(-)
>> ---
>> base-commit: 65b9b3462bec2966911658836983819ab4e4823e
>> change-id: 20231005-mattijs-usb-6b83dde256f0
>> 
>> Best regards,
>
> Best regards,
>
> Lukasz Majewski
>
> --
>
> DENX Software Engineering GmbH,  Managing Director: Erika Unter
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lu...@denx.de


Re: [PATCH 0/2] MAINTAINERS: Add Mattijs to USB/fastboot maintainers

2023-10-19 Thread Mattijs Korpershoek
On jeu., oct. 19, 2023 at 10:18, Lukasz Majewski  wrote:

> On Thu, 19 Oct 2023 09:40:37 +0200
> Mattijs Korpershoek  wrote:
>
>> Hi Lukasz, Marek,
>> 
>> On mer., oct. 18, 2023 at 12:52, Lukasz Majewski 
>> wrote:
>> 
>> > Hi Mattijs,
>> >  
>> >> From discussions with Marek at Kernel Recipes, it seems that the
>> >> USB subsystem in U-boot need some help.
>> >> 
>> >> Since I've been asked and I'm willing to help, I've added myself to
>> >> the maintainers entry.
>> >> 
>> >> I have also added myself for fastboot since I'm interested in
>> >> keeping that functional as well.
>> >> 
>> >> Note that I have no previous (open-source) maintainer experience
>> >> so I will do my best to learn.
>> >>   
>> >
>> > Thanks for willing to help with maintaining the code. If you need
>> > any help - then just ask :-)
>> >
>> > Acked-by: Lukasz Majewski   
>> 
>> Thank you for acknowledging. I'm both very happy and a bit nervous to
>> start :)
>> 
>> Do we still use the following custodian tree:
>> https://source.denx.de/u-boot/custodians/u-boot-dfu ?
>> 
>
> Yes.
>
>> If yes, I imagine I would need write access to it.
>> 
>
> I think that Tom shall have credentials to add you.

Great!

My account is created and approved already:
https://source.denx.de/mkorpershoek

>
>> 
>> >  
>> >> Signed-off-by: Mattijs Korpershoek 
>> >> ---
>> >> Mattijs Korpershoek (2):
>> >>   MAINTAINERS: usb gadget: add Mattijs
>> >>   MAINTAINERS: fastboot: add Mattijs
>> >> 
>> >>  MAINTAINERS | 4 +++-
>> >>  1 file changed, 3 insertions(+), 1 deletion(-)
>> >> ---
>> >> base-commit: 65b9b3462bec2966911658836983819ab4e4823e
>> >> change-id: 20231005-mattijs-usb-6b83dde256f0
>> >> 
>> >> Best regards,  
>> >
>> > Best regards,
>> >
>> > Lukasz Majewski
>> >
>> > --
>> >
>> > DENX Software Engineering GmbH,  Managing Director: Erika Unter
>> > HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell,
>> > Germany Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email:
>> > lu...@denx.de  
>
>
>
>
> Best regards,
>
> Lukasz Majewski
>
> --
>
> DENX Software Engineering GmbH,  Managing Director: Erika Unter
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lu...@denx.de


Re: [PATCH] doc: Replace dm_dump_all() with dm_dump_tree()

2023-10-20 Thread Mattijs Korpershoek
Hi Dylan,

Thank you for your patch.

On jeu., oct. 19, 2023 at 10:02, Dylan Corrales  wrote:

> Replace dm_dump_all() with dm_dump_tree() in driver model documentation,
> to reflect changes introduced in commit 145287040480 ("dm: core: Rename
> dm_dump_all()").
>
> Signed-off-by: Dylan Corrales 

Reviewed-by: Mattijs Korpershoek 

> ---
>
>  doc/develop/driver-model/debugging.rst | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/doc/develop/driver-model/debugging.rst 
> b/doc/develop/driver-model/debugging.rst
> index bbb2794340..e13abddae6 100644
> --- a/doc/develop/driver-model/debugging.rst
> +++ b/doc/develop/driver-model/debugging.rst
> @@ -49,7 +49,7 @@ to see errors. Common ones are:
>   of_to_plat() method in the driver.
>  
>  If there is no error, you should check if the device is actually bound. Call
> -dm_dump_all() just before you locate the device to make sure it exists.
> +dm_dump_tree() just before you locate the device to make sure it exists.
>  
>  If it does not exist, check your device tree compatible strings match up with
>  what the driver expects (in the struct udevice_id array).
> -- 
> 2.34.1


Re: [PATCH 0/4] ARM: meson: Add boot over DFU RAM as an USB boot step

2023-10-24 Thread Mattijs Korpershoek
Hi Neil,

Thank you for the series.

On lun., oct. 23, 2023 at 14:41, "Neil Armstrong"  
wrote:

> Add boot over DFU RAM as an alternate to running script at
> a fixed address like done today.
>
> The main culprit is that it's not possible to do that
> on G12A/SM1 platforms due to changes in the USB boot protocol.
>
> With this, U-Boot will present a DFU device with a ram slot where
> the Host could write a fitImage or legacy U-Boot image, then with the
> detach command boot will continue trying to boot the uploaded image.
>
> Signed-off-by: Neil Armstrong 

I did a simple boot to aosp/main test on vim3 and also used fastboot to
flash the bootloader.

Tested-by: Mattijs Korpershoek  # on vim3

> ---
> Neil Armstrong (4):
>   ARM: meson: enable FIT with LEGACY_IMAGE_FORMAT on all configs
>   configs: meson64: declare addr out of EXTRA_ENV_SETTINGS
>   configs: meson64: add alternate USB DFU boot target
>   ARM: meson: enable USB DFU + RAM on Amlogic boards with USB Gadget
>
>  configs/ad401_defconfig   |  2 ++
>  configs/bananapi-cm4-cm4io_defconfig  |  6 
>  configs/bananapi-m2-pro_defconfig |  6 
>  configs/bananapi-m2s_defconfig|  6 
>  configs/bananapi-m5_defconfig |  6 
>  configs/beelink-gsking-x_defconfig|  6 
>  configs/beelink-gt1-ultimate_defconfig|  6 
>  configs/beelink-gtking_defconfig  |  6 
>  configs/beelink-gtkingpro_defconfig   |  6 
>  configs/jethub_j100_defconfig |  6 
>  configs/jethub_j80_defconfig  |  6 
>  configs/khadas-vim2_defconfig |  6 
>  configs/khadas-vim3_android_ab_defconfig  |  4 +++
>  configs/khadas-vim3_android_defconfig |  4 +++
>  configs/khadas-vim3_defconfig |  6 
>  configs/khadas-vim3l_android_ab_defconfig |  4 +++
>  configs/khadas-vim3l_android_defconfig|  4 +++
>  configs/khadas-vim3l_defconfig|  6 
>  configs/khadas-vim_defconfig  |  6 
>  configs/libretech-ac_defconfig|  6 
>  configs/libretech-cc_defconfig|  6 
>  configs/libretech-cc_v2_defconfig |  6 
>  configs/libretech-s905d-pc_defconfig  |  6 
>  configs/libretech-s912-pc_defconfig   |  6 
>  configs/nanopi-k2_defconfig   |  4 +++
>  configs/odroid-c2_defconfig   |  4 +++
>  configs/odroid-c4_defconfig   |  6 
>  configs/odroid-go-ultra_defconfig |  6 
>  configs/odroid-hc4_defconfig  |  6 
>  configs/odroid-n2_defconfig   |  6 
>  configs/odroid-n2l_defconfig  |  6 
>  configs/p200_defconfig|  4 +++
>  configs/p201_defconfig|  4 +++
>  configs/p212_defconfig|  4 +++
>  configs/radxa-zero2_defconfig |  6 
>  configs/radxa-zero_defconfig  |  6 
>  configs/s400_defconfig|  6 
>  configs/sei510_defconfig  |  6 
>  configs/sei610_defconfig  |  6 
>  configs/u200_defconfig|  6 
>  configs/videostrong-kii-pro_defconfig |  4 +++
>  configs/wetek-core2_defconfig |  6 
>  configs/wetek-hub_defconfig   |  4 +++
>  configs/wetek-play2_defconfig |  4 +++
>  include/configs/meson64.h | 49 
> ++-
>  45 files changed, 278 insertions(+), 7 deletions(-)
> ---
> base-commit: 9a0cf3993f71043ba08c315572c54622de42d447
> change-id: 20231023-usb-dfu-boot-f47849f9fb34
>
> Best regards,
> -- 
> Neil Armstrong 
>
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Groups.io Links: You receive all messages sent to this group.
> View/Reply Online (#1789): https://groups.io/g/u-boot-amlogic/message/1789
> Mute This Topic: https://groups.io/mt/102134207/1991006
> Group Owner: u-boot-amlogic+ow...@groups.io
> Unsubscribe: 
> https://groups.io/g/u-boot-amlogic/leave/9114030/1991006/1716920881/xyzzy 
> [mkorpersh...@baylibre.com]
> -=-=-=-=-=-=-=-=-=-=-=-


[PATCH] configs: khadas-vim3*_android: fix environment saving

2023-10-26 Thread Mattijs Korpershoek
The environment is used to configure some additional boot features such as:
* extra boot arguments
* enable AVB (Android Verified Boot) verification

Right now, we cannot store it in eMMC:

  Loading Environment from nowhere... OK

Fix it by enabling the appropriate options in the defconfig

Fixes: b749d5ecdc06 ("configs: meson64_android: define raw parts for 
bootloader")
Signed-off-by: Mattijs Korpershoek 
---
 configs/khadas-vim3_android_ab_defconfig  | 4 
 configs/khadas-vim3_android_defconfig | 4 
 configs/khadas-vim3l_android_ab_defconfig | 4 
 configs/khadas-vim3l_android_defconfig| 4 
 4 files changed, 16 insertions(+)

diff --git a/configs/khadas-vim3_android_ab_defconfig 
b/configs/khadas-vim3_android_ab_defconfig
index ccd6f6f8a075..0abccb64ee15 100644
--- a/configs/khadas-vim3_android_ab_defconfig
+++ b/configs/khadas-vim3_android_ab_defconfig
@@ -7,6 +7,7 @@ CONFIG_NR_DRAM_BANKS=1
 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
 CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x2000
 CONFIG_ENV_SIZE=0x1
+CONFIG_ENV_OFFSET=0x0
 CONFIG_DM_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="meson-g12b-a311d-khadas-vim3"
 CONFIG_OF_LIBFDT_OVERLAY=y
@@ -45,7 +46,10 @@ CONFIG_CMD_AB_SELECT=y
 CONFIG_CMD_REGULATOR=y
 CONFIG_CMD_AVB=y
 CONFIG_OF_CONTROL=y
+CONFIG_ENV_IS_IN_MMC=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_SYS_MMC_ENV_DEV=2
+CONFIG_SYS_MMC_ENV_PART=2
 CONFIG_ADC=y
 CONFIG_SARADC_MESON=y
 CONFIG_BUTTON=y
diff --git a/configs/khadas-vim3_android_defconfig 
b/configs/khadas-vim3_android_defconfig
index 5c3d565971d6..33ede5262295 100644
--- a/configs/khadas-vim3_android_defconfig
+++ b/configs/khadas-vim3_android_defconfig
@@ -7,6 +7,7 @@ CONFIG_NR_DRAM_BANKS=1
 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
 CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x2000
 CONFIG_ENV_SIZE=0x1
+CONFIG_ENV_OFFSET=0x0
 CONFIG_DM_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="meson-g12b-a311d-khadas-vim3"
 CONFIG_OF_LIBFDT_OVERLAY=y
@@ -43,7 +44,10 @@ CONFIG_CMD_USB_MASS_STORAGE=y
 CONFIG_CMD_REGULATOR=y
 CONFIG_CMD_AVB=y
 CONFIG_OF_CONTROL=y
+CONFIG_ENV_IS_IN_MMC=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_SYS_MMC_ENV_DEV=2
+CONFIG_SYS_MMC_ENV_PART=2
 CONFIG_ADC=y
 CONFIG_SARADC_MESON=y
 CONFIG_BUTTON=y
diff --git a/configs/khadas-vim3l_android_ab_defconfig 
b/configs/khadas-vim3l_android_ab_defconfig
index 0d6de8001382..8f32f8e8ad5b 100644
--- a/configs/khadas-vim3l_android_ab_defconfig
+++ b/configs/khadas-vim3l_android_ab_defconfig
@@ -7,6 +7,7 @@ CONFIG_NR_DRAM_BANKS=1
 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
 CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x2000
 CONFIG_ENV_SIZE=0x1
+CONFIG_ENV_OFFSET=0x0
 CONFIG_DM_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="meson-sm1-khadas-vim3l"
 CONFIG_OF_LIBFDT_OVERLAY=y
@@ -45,7 +46,10 @@ CONFIG_CMD_AB_SELECT=y
 CONFIG_CMD_REGULATOR=y
 CONFIG_CMD_AVB=y
 CONFIG_OF_CONTROL=y
+CONFIG_ENV_IS_IN_MMC=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_SYS_MMC_ENV_DEV=2
+CONFIG_SYS_MMC_ENV_PART=2
 CONFIG_ADC=y
 CONFIG_SARADC_MESON=y
 CONFIG_BUTTON=y
diff --git a/configs/khadas-vim3l_android_defconfig 
b/configs/khadas-vim3l_android_defconfig
index 827752f24373..443c10aee3d0 100644
--- a/configs/khadas-vim3l_android_defconfig
+++ b/configs/khadas-vim3l_android_defconfig
@@ -7,6 +7,7 @@ CONFIG_NR_DRAM_BANKS=1
 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
 CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0x2000
 CONFIG_ENV_SIZE=0x1
+CONFIG_ENV_OFFSET=0x0
 CONFIG_DM_GPIO=y
 CONFIG_DEFAULT_DEVICE_TREE="meson-sm1-khadas-vim3l"
 CONFIG_OF_LIBFDT_OVERLAY=y
@@ -43,7 +44,10 @@ CONFIG_CMD_USB_MASS_STORAGE=y
 CONFIG_CMD_REGULATOR=y
 CONFIG_CMD_AVB=y
 CONFIG_OF_CONTROL=y
+CONFIG_ENV_IS_IN_MMC=y
 CONFIG_SYS_RELOC_GD_ENV_ADDR=y
+CONFIG_SYS_MMC_ENV_DEV=2
+CONFIG_SYS_MMC_ENV_PART=2
 CONFIG_ADC=y
 CONFIG_SARADC_MESON=y
 CONFIG_BUTTON=y

---
base-commit: 14a21f1a80afc58d52dc72e35f27d3a47d36c082
change-id: 20231026-fix-saveenv-eb5484622282

Best regards,
-- 
Mattijs Korpershoek 



Re: [PATCH] dfu: mmc: Add support for exposing whole mmc device

2023-10-31 Thread Mattijs Korpershoek
On dim., oct. 29, 2023 at 23:37, Marek Vasut  wrote:

> Add support for exposing the whole mmc device by setting the 'size'
> parameter to 0. This can be useful in case it is not clear what the
> total device size is up front. Update the documentation accordingly.
>
> Signed-off-by: Marek Vasut 
> ---
> Cc: Lukasz Majewski 
> Cc: Mattijs Korpershoek 
> Cc: Tom Rini 

Reviewed-by: Mattijs Korpershoek 

> ---
>  doc/usage/dfu.rst |  5 +
>  drivers/dfu/dfu_mmc.c | 10 ++
>  2 files changed, 15 insertions(+)
>
> diff --git a/doc/usage/dfu.rst b/doc/usage/dfu.rst
> index 68cacbbef66..8845a71df36 100644
> --- a/doc/usage/dfu.rst
> +++ b/doc/usage/dfu.rst
> @@ -121,6 +121,11 @@ mmc
>  
>  with
>  
> +offset
> +is the offset in the device (hexadecimal without "0x")
> +size
> +is the size of the access area (hexadecimal without "0x")
> +or 0 which means whole device
>  partid
>  being the GPT or DOS partition index,
>  num
> diff --git a/drivers/dfu/dfu_mmc.c b/drivers/dfu/dfu_mmc.c
> index cdb3c18b01d..12c54e90ef7 100644
> --- a/drivers/dfu/dfu_mmc.c
> +++ b/drivers/dfu/dfu_mmc.c
> @@ -386,6 +386,16 @@ int dfu_fill_entity_mmc(struct dfu_entity *dfu, char 
> *devstr, char **argv, int a
>   dfu->data.mmc.lba_size  = third_arg;
>   dfu->data.mmc.lba_blk_size  = mmc->read_bl_len;
>  
> + /*
> +  * In case the size is zero (i.e. mmc raw 0x10 0),
> +  * assume the user intends to use whole device.
> +  */
> + if (third_arg == 0) {
> + struct blk_desc *blk_dev = mmc_get_blk_desc(mmc);
> +
> + dfu->data.mmc.lba_size = blk_dev->lba;
> + }
> +
>   /*
>* Check for an extra entry at dfu_alt_info env variable
>* specifying the mmc HW defined partition number
> -- 
> 2.42.0


Re: [PATCH] fastboot: fix CRC32 chunk size checking

2023-10-31 Thread Mattijs Korpershoek
Hi,

On Mon, 25 Sep 2023 12:37:15 +0200, Wojciech Nizinski wrote:
> genimage create android-sparse file with CRC32 chunk at end. When
> U-Boot's fastboot receives this chunk it returns error message:
> `Fail Bogus chunk size for chunk type Dont Care`
> 
> According to reference implementation of Android's sparse file format:
> 
>  libsparse/output_file.cpp#513>
> 
> [...]

Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-dfu 
(u-boot-dfu)

[1/1] fastboot: fix CRC32 chunk size checking
  
https://source.denx.de/u-boot/custodians/u-boot-dfu/-/commit/355aab94d1f675ec1118906e1f88dfdf6a3582eb

-- 
Mattijs


Re: [PATCH] dfu: mmc: Add support for exposing whole mmc device

2023-10-31 Thread Mattijs Korpershoek
Hi,

On Sun, 29 Oct 2023 23:37:22 +0100, Marek Vasut wrote:
> Add support for exposing the whole mmc device by setting the 'size'
> parameter to 0. This can be useful in case it is not clear what the
> total device size is up front. Update the documentation accordingly.
> 
> 

Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-dfu 
(u-boot-dfu)

[1/1] dfu: mmc: Add support for exposing whole mmc device
  
https://source.denx.de/u-boot/custodians/u-boot-dfu/-/commit/60d904a494c6e89c323bc13fa9348869e07e86d3

-- 
Mattijs


Re: [PATCH] dfu: add CONFIG_DFU_NAME_MAX_SIZE configuration

2023-10-31 Thread Mattijs Korpershoek
Hi Jaehoon,

Thank you for your patch.

On lun., juin 20, 2022 at 20:13, Jaehoon Chung  wrote:

> Add CONFIG_DFU_NAME_MAX_SIZE to change the proper size.
> If name is longer than default size, it can do wrong behavior during updating
> image. So it need to change the proper maximum size.
>
> This patch is proviced the solution to change value with configuration.
>
> Signed-off-by: Jaehoon Chung 

I could not find a maximum size in the DFU 1.1 spec [1] neither in the
dfu-util codebase.

[1] https://www.usb.org/sites/default/files/DFU_1.1.pdf

Reviewed-by: Mattijs Korpershoek 

> ---
>  drivers/dfu/Kconfig | 9 +
>  include/dfu.h   | 2 +-
>  2 files changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/dfu/Kconfig b/drivers/dfu/Kconfig
> index 8d7f13dcb0b5..a181f0b8d7ba 100644
> --- a/drivers/dfu/Kconfig
> +++ b/drivers/dfu/Kconfig
> @@ -111,5 +111,14 @@ config SYS_DFU_MAX_FILE_SIZE
> the buffer once we've been given the whole file.  Define
> this to the maximum filesize (in bytes) for the buffer.
> If undefined it defaults to the CONFIG_SYS_DFU_DATA_BUF_SIZE.
> +
> +config DFU_NAME_MAX_SIZE
> + int "Size of the name to be added in dfu entity"
> + default 32
> + depends on DFU
> + help
> +   This value is used to maximum size. If name is longer than default 
> size,
> +   we need to change the proper maximum size.
> +
>  endif
>  endmenu
> diff --git a/include/dfu.h b/include/dfu.h
> index dcb9cd9d799a..948596f367d9 100644
> --- a/include/dfu.h
> +++ b/include/dfu.h
> @@ -99,7 +99,7 @@ struct virt_internal_data {
>   int dev_num;
>  };
>  
> -#define DFU_NAME_SIZE32
> +#define DFU_NAME_SIZECONFIG_DFU_NAME_MAX_SIZE
>  #ifndef DFU_DEFAULT_POLL_TIMEOUT
>  #define DFU_DEFAULT_POLL_TIMEOUT 0
>  #endif
> -- 
> 2.25.1


Re: [PATCH] dfu: add CONFIG_DFU_NAME_MAX_SIZE configuration

2023-10-31 Thread Mattijs Korpershoek
Hi,

On Mon, 20 Jun 2022 20:13:54 +0900, Jaehoon Chung wrote:
> Add CONFIG_DFU_NAME_MAX_SIZE to change the proper size.
> If name is longer than default size, it can do wrong behavior during updating
> image. So it need to change the proper maximum size.
> 
> This patch is proviced the solution to change value with configuration.
> 
> 
> [...]

Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-dfu 
(u-boot-dfu-next)

[1/1] dfu: add CONFIG_DFU_NAME_MAX_SIZE configuration
  
https://source.denx.de/u-boot/custodians/u-boot-dfu/-/commit/de9b2e10f10996050a10998a0836abe2f9e425e3

--
Mattijs


Re: [PATCH] dfu: add CONFIG_DFU_NAME_MAX_SIZE configuration

2023-11-02 Thread Mattijs Korpershoek
Hi Jaehoon,

On mar., oct. 31, 2023 at 15:50, Mattijs Korpershoek 
 wrote:

> Hi,
>
> On Mon, 20 Jun 2022 20:13:54 +0900, Jaehoon Chung wrote:
>> Add CONFIG_DFU_NAME_MAX_SIZE to change the proper size.
>> If name is longer than default size, it can do wrong behavior during updating
>> image. So it need to change the proper maximum size.
>> 
>> This patch is proviced the solution to change value with configuration.
>> 
>> 
>> [...]
>
> Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-dfu 
> (u-boot-dfu-next)
>
> [1/1] dfu: add CONFIG_DFU_NAME_MAX_SIZE configuration
>   
> https://source.denx.de/u-boot/custodians/u-boot-dfu/-/commit/de9b2e10f10996050a10998a0836abe2f9e425e3


This patch breaks CI for both arm32 and arm64 platforms:

* https://source.denx.de/u-boot/custodians/u-boot-dfu/-/jobs/725163
* https://source.denx.de/u-boot/custodians/u-boot-dfu/-/jobs/725164

It breaks because multiple boards which include dfu.h without having
CONFIG_DFU being set.

Tom attempted to fix this with:
https://patchwork.ozlabs.org/project/uboot/list/?series=369275

But that had some different issues, see:
https://libera.irclog.whitequark.org/u-boot/2023-10-31#35154532;

I've fixed it up with the following diff:

diff --git a/include/dfu.h b/include/dfu.h
index 4573f753c565..2c3ffa3f9297 100644
--- a/include/dfu.h
+++ b/include/dfu.h
@@ -99,7 +99,12 @@ struct virt_internal_data {
int dev_num;
 };
 
+
+#if defined(CONFIG_DFU_NAME_MAX_SIZE)
 #define DFU_NAME_SIZE  CONFIG_DFU_NAME_MAX_SIZE
+#else
+#define DFU_NAME_SIZE  32
+#endif
 #ifndef DFU_DEFAULT_POLL_TIMEOUT
 #define DFU_DEFAULT_POLL_TIMEOUT 0
 #endif

If you have a better idea to fix this, can you please let me know?
Otherwise, I will squash this to keep CI green.

Thank you

>
> --
> Mattijs


RE: [PATCH] dfu: add CONFIG_DFU_NAME_MAX_SIZE configuration

2023-11-03 Thread Mattijs Korpershoek
Hi Jaehoon,

On ven., nov. 03, 2023 at 10:07, "Jaehoon Chung"  wrote:

> Hi Mathtjjs,
>
>> -Original Message-
>> From: Mattijs Korpershoek 
>> Sent: Thursday, November 2, 2023 6:15 PM
>> To: Jaehoon Chung 
>> Cc: lu...@denx.de; u-boot@lists.denx.de
>> Subject: Re: [PATCH] dfu: add CONFIG_DFU_NAME_MAX_SIZE configuration
>> 
>> Hi Jaehoon,
>> 
>> On mar., oct. 31, 2023 at 15:50, Mattijs Korpershoek 
>>  wrote:
>> 
>> > Hi,
>> >
>> > On Mon, 20 Jun 2022 20:13:54 +0900, Jaehoon Chung wrote:
>> >> Add CONFIG_DFU_NAME_MAX_SIZE to change the proper size.
>> >> If name is longer than default size, it can do wrong behavior during 
>> >> updating
>> >> image. So it need to change the proper maximum size.
>> >>
>> >> This patch is proviced the solution to change value with configuration.
>> >>
>> >>
>> >> [...]
>> >
>> > Thanks, Applied to 
>> > https://protect2.fireeye.com/v1/url?k=195a8ba3-78d19e99-195b00ec-74fe4860008a-
>> e609da47a4bcadff&q=1&e=b6fd9ce6-85b6-46a3-81aa-8aa89d16a9ed&u=https%3A%2F%2Fsource.denx.de%2Fu-
>> boot%2Fcustodians%2Fu-boot-dfu (u-boot-dfu-next)
>> >
>> > [1/1] dfu: add CONFIG_DFU_NAME_MAX_SIZE configuration
>> >   
>> > https://protect2.fireeye.com/v1/url?k=b04b2ae8-d1c03fd2-b04aa1a7-74fe4860008a-
>> d8ec8502221dcca0&q=1&e=b6fd9ce6-85b6-46a3-81aa-8aa89d16a9ed&u=https%3A%2F%2Fsource.denx.de%2Fu-
>> boot%2Fcustodians%2Fu-boot-dfu%2F-%2Fcommit%2Fde9b2e10f10996050a10998a0836abe2f9e425e3
>> 
>> 
>> This patch breaks CI for both arm32 and arm64 platforms:
>> 
>> * 
>> https://protect2.fireeye.com/v1/url?k=3179f7cc-50f2e2f6-31787c83-74fe4860008a-
>> a4f5d2c73833c4d5&q=1&e=b6fd9ce6-85b6-46a3-81aa-8aa89d16a9ed&u=https%3A%2F%2Fsource.denx.de%2Fu-
>> boot%2Fcustodians%2Fu-boot-dfu%2F-%2Fjobs%2F725163
>> * 
>> https://protect2.fireeye.com/v1/url?k=22773f8e-43fc2ab4-2276b4c1-74fe4860008a-
>> f6dc3d75fe9b283a&q=1&e=b6fd9ce6-85b6-46a3-81aa-8aa89d16a9ed&u=https%3A%2F%2Fsource.denx.de%2Fu-
>> boot%2Fcustodians%2Fu-boot-dfu%2F-%2Fjobs%2F725164
>
> I couldn't access the above CI URL.

Sorry about that. CI was not public. That is fixed now.

>
>> 
>> It breaks because multiple boards which include dfu.h without having
>> CONFIG_DFU being set.
>> 
>> Tom attempted to fix this with:
>> https://protect2.fireeye.com/v1/url?k=452a9007-24a1853d-452b1b48-74fe4860008a-
>> a88f870953497071&q=1&e=b6fd9ce6-85b6-46a3-81aa-
>> 8aa89d16a9ed&u=https%3A%2F%2Fpatchwork.ozlabs.org%2Fproject%2Fuboot%2Flist%2F%3Fseries%3D369275
>> 
>> But that had some different issues, see:
>> https://protect2.fireeye.com/v1/url?k=f1c007bd-904b1287-f1c18cf2-74fe4860008a-
>> a305de1bab5bdff1&q=1&e=b6fd9ce6-85b6-46a3-81aa-
>> 8aa89d16a9ed&u=https%3A%2F%2Flibera.irclog.whitequark.org%2Fu-boot%2F2023-10-31%2335154532;
>> 
>> I've fixed it up with the following diff:
>> 
>> diff --git a/include/dfu.h b/include/dfu.h
>> index 4573f753c565..2c3ffa3f9297 100644
>> --- a/include/dfu.h
>> +++ b/include/dfu.h
>> @@ -99,7 +99,12 @@ struct virt_internal_data {
>> int dev_num;
>>  };
>> 
>> +
>> +#if defined(CONFIG_DFU_NAME_MAX_SIZE)
>>  #define DFU_NAME_SIZE  CONFIG_DFU_NAME_MAX_SIZE
>> +#else
>> +#define DFU_NAME_SIZE  32
>> +#endif
>>  #ifndef DFU_DEFAULT_POLL_TIMEOUT
>>  #define DFU_DEFAULT_POLL_TIMEOUT 0
>>  #endif
>> 
>> If you have a better idea to fix this, can you please let me know?
>
> After checking this, let you inform.
>
>> Otherwise, I will squash this to keep CI green.
>> 
>> Thank you
>> 
>> >
>> > --
>> > Mattijs


[GIT PULL] Please pull u-boot-dfu-20231103

2023-11-03 Thread Mattijs Korpershoek
Hi Tom,

Here is my first pull request of u-boot-dfu which includes:

- Fix CRC chunk size in fastboot
- Make size optional for dfu on mmc

The CI job is at 
https://source.denx.de/u-boot/custodians/u-boot-dfu/-/pipelines/18433

Thanks,
Mattijs

The following changes since commit cbba1b7766bd93d74e28202c46e69095ac13760b:

  Merge branch '2023-10-30-assorted-general-updates' (2023-10-30 16:01:54 -0400)

are available in the Git repository at:

  https://source.denx.de/u-boot/custodians/u-boot-dfu.git 
tags/u-boot-dfu-20231103

for you to fetch changes up to 60d904a494c6e89c323bc13fa9348869e07e86d3:

  dfu: mmc: Add support for exposing whole mmc device (2023-10-31 14:53:05 
+0100)


u-boot-dfu-20231103

- Fix CRC chunk size in fastboot
- Make size optional for dfu on mmc


Marek Vasut (1):
  dfu: mmc: Add support for exposing whole mmc device

Wojciech Nizinski (1):
  fastboot: fix CRC32 chunk size checking

 doc/usage/dfu.rst |  5 +
 drivers/dfu/dfu_mmc.c | 10 ++
 lib/image-sparse.c|  4 ++--
 3 files changed, 17 insertions(+), 2 deletions(-)



Re: [PATCH V3 0/4] board: ti: Add support for BeaglePlay

2023-08-22 Thread Mattijs Korpershoek
On mar., août 15, 2023 at 11:44, Nishanth Menon  wrote:

> Add support for BeaglePlay - rev 3
>
> Boot log: https://gist.github.com/nmenon/3e99b44380873263e39ba4d84788db89
>
> Full series(including dependencies) can be found at:
> https://github.com/nmenon/fix-k3-dt-u-boot/commits/beagleplay-v3
>
> Caveats:
> * I have kept networking out of picture for now as it is still in debug
>  (See
>   https://github.com/nmenon/fix-k3-dt-u-boot/commits/beagleplay-v3-enet-debug
>   if anyone is interested)
>
> Changes since V2:
> * I have rebased to latest next branch
>   bdc682437a67 (origin/next) Merge branch 
> '2023-08-14-assorted-general-updates' into next
> * Uses config fragments by default.
> * Updated MAINTAINER file as well
>
> V2: https://lore.kernel.org/u-boot/20230727234446.3651836-1...@ti.com/
> V1: https://lore.kernel.org/all/20230725185253.2123433-1...@ti.com/
>
> Nishanth Menon (3):
>   arm: dts: k3-am625-sk-binman: Add labels for unsigned binary
>   board: ti: am62x: Add am62x_beagleplay_* defconfigs
>   doc: board: ti: Add BeaglePlay documentation
>
> Robert Nelson (1):
>   arm: dts: Add k3-am625-beagleplay

I tried these series on top of next on my beagleplay with the intention of
booting U-Boot from eMMC.

Base commit: 7e6e40c57233 ("Merge tag 'v2023.10-rc3' into next")

I can't get this to boot. Seems to be stuck in the r5 spl.

Boot log is:

U-Boot SPL 2023.10-rc3-01591-ga4f9ddf99438 (Aug 22 2023 - 17:11:47 +0200)
SYSFW ABI: 3.1 (firmware rev 0x0009 '9.0.5--v09.00.05 (Kool Koala)')
SPL initial stack usage: 13400 bytes
Trying to boot from MMC1
mmc_load_image_raw_sector: mmc block read error
Partition 1 invalid on device 0
spl_register_fat_device: fat register err - -1
spl_load_image_fat: error reading image tispl.bin, err - -1
SPL: failed to boot from all boot devices
### ERROR ### Please RESET the board ###

It seems that when we try to find tispl.bin, we read from the mmc0boot0
hw partition instead of from the user partition.

Per my understanding, BeaglePlay has the following (simplified) boot
flow:

1. boot rom loads tiboot3 from mmc0boot0
2. tiboot3 loads tispl.bin from mmc(user), first partition (on a FAT filesystem)
3. tispl loads u-boot.img from mmc(user), first partition (on a FAT filesystem)

With the folllowing diff, I can boot all the way to U-Boot proper:

diff --git a/board/ti/am62x/beagleplay_a53.config 
b/board/ti/am62x/beagleplay_a53.config
index 4889e1bc6f2b..d59a3ca6926e 100644
--- a/board/ti/am62x/beagleplay_a53.config
+++ b/board/ti/am62x/beagleplay_a53.config
@@ -18,3 +18,8 @@ CONFIG_SPI=n
 CONFIG_SPI_FLASH=n
 CONFIG_SPL_DM_SPI_FLASH=n
 CONFIG_SPL_SPI_FLASH_SUPPORT=n
+
+CONFIG_SUPPORT_EMMC_BOOT=y
+CONFIG_SUPPORT_EMMC_BOOT_OVERRIDE_PART_CONFIG=y
+CONFIG_SYS_MMCSD_RAW_MODE_EMMC_BOOT_PARTITION=0
diff --git a/board/ti/am62x/beagleplay_r5.config 
b/board/ti/am62x/beagleplay_r5.config
index ce64561bee92..239d0d6a55bd 100644
--- a/board/ti/am62x/beagleplay_r5.config
+++ b/board/ti/am62x/beagleplay_r5.config
@@ -9,3 +9,8 @@ CONFIG_SPI=n
 CONFIG_SPI_FLASH=n
 CONFIG_SPL_DM_SPI_FLASH=n
 CONFIG_SPL_SPI_FLASH_SUPPORT=n
+
+CONFIG_SUPPORT_EMMC_BOOT=y
+CONFIG_SUPPORT_EMMC_BOOT_OVERRIDE_PART_CONFIG=y
+CONFIG_SYS_MMCSD_RAW_MODE_EMMC_BOOT_PARTITION=0

The above is probably not the proper way of doing things, but it seems
to resolve my booting issue.

>
>  arch/arm/dts/Makefile |2 +
>  .../dts/k3-am625-beagleplay-ddr4-1600MTs.dtsi | 2195 +
>  arch/arm/dts/k3-am625-beagleplay-u-boot.dtsi  |  172 ++
>  arch/arm/dts/k3-am625-beagleplay.dts  |  758 ++
>  arch/arm/dts/k3-am625-r5-beagleplay.dts   |   87 +
>  arch/arm/dts/k3-am625-sk-binman.dtsi  |4 +-
>  board/ti/am62x/MAINTAINERS|7 +
>  board/ti/am62x/beagleplay_a53.config  |   20 +
>  board/ti/am62x/beagleplay_r5.config   |   11 +
>  doc/board/ti/am62x_beagleplay.rst |  121 +
>  doc/board/ti/k3.rst   |1 +
>  11 files changed, 3376 insertions(+), 2 deletions(-)
>  create mode 100644 arch/arm/dts/k3-am625-beagleplay-ddr4-1600MTs.dtsi
>  create mode 100644 arch/arm/dts/k3-am625-beagleplay-u-boot.dtsi
>  create mode 100644 arch/arm/dts/k3-am625-beagleplay.dts
>  create mode 100644 arch/arm/dts/k3-am625-r5-beagleplay.dts
>  create mode 100644 board/ti/am62x/beagleplay_a53.config
>  create mode 100644 board/ti/am62x/beagleplay_r5.config
>  create mode 100644 doc/board/ti/am62x_beagleplay.rst
>
> -- 
> 2.40.0


Re: [PATCH V3 0/4] board: ti: Add support for BeaglePlay

2023-08-22 Thread Mattijs Korpershoek
On mar., août 22, 2023 at 10:40, Nishanth Menon  wrote:

> On 17:33-20230822, Mattijs Korpershoek wrote:
>> On mar., août 15, 2023 at 11:44, Nishanth Menon  wrote:
>> 
>> > Add support for BeaglePlay - rev 3
>> >
>> > Boot log: https://gist.github.com/nmenon/3e99b44380873263e39ba4d84788db89
>> >
>> > Full series(including dependencies) can be found at:
>> > https://github.com/nmenon/fix-k3-dt-u-boot/commits/beagleplay-v3
>> >
>> > Caveats:
>> > * I have kept networking out of picture for now as it is still in debug
>> >  (See
>> >   
>> > https://github.com/nmenon/fix-k3-dt-u-boot/commits/beagleplay-v3-enet-debug
>> >   if anyone is interested)
>> >
>> > Changes since V2:
>> > * I have rebased to latest next branch
>> >   bdc682437a67 (origin/next) Merge branch 
>> > '2023-08-14-assorted-general-updates' into next
>> > * Uses config fragments by default.
>> > * Updated MAINTAINER file as well
>> >
>> > V2: https://lore.kernel.org/u-boot/20230727234446.3651836-1...@ti.com/
>> > V1: https://lore.kernel.org/all/20230725185253.2123433-1...@ti.com/
>> >
>> > Nishanth Menon (3):
>> >   arm: dts: k3-am625-sk-binman: Add labels for unsigned binary
>> >   board: ti: am62x: Add am62x_beagleplay_* defconfigs
>> >   doc: board: ti: Add BeaglePlay documentation
>> >
>> > Robert Nelson (1):
>> >   arm: dts: Add k3-am625-beagleplay
>> 
>> I tried these series on top of next on my beagleplay with the intention of
>> booting U-Boot from eMMC.
>> 
>> Base commit: 7e6e40c57233 ("Merge tag 'v2023.10-rc3' into next")
>> 
>> I can't get this to boot. Seems to be stuck in the r5 spl.
>> 
>> Boot log is:
>> 
>> U-Boot SPL 2023.10-rc3-01591-ga4f9ddf99438 (Aug 22 2023 - 17:11:47 +0200)
>> SYSFW ABI: 3.1 (firmware rev 0x0009 '9.0.5--v09.00.05 (Kool Koala)')
>> SPL initial stack usage: 13400 bytes
>> Trying to boot from MMC1
>> mmc_load_image_raw_sector: mmc block read error
>> Partition 1 invalid on device 0
>> spl_register_fat_device: fat register err - -1
>> spl_load_image_fat: error reading image tispl.bin, err - -1
>> SPL: failed to boot from all boot devices
>> ### ERROR ### Please RESET the board ###
>> 
>> It seems that when we try to find tispl.bin, we read from the mmc0boot0
>> hw partition instead of from the user partition.
>> 
>> Per my understanding, BeaglePlay has the following (simplified) boot
>> flow:
>
> Thanks Mattijs, we have been discussing this in our discord channel, and

Indeed I saw some things on discord around this but wanted to notice a
broader audience (via the U-Boot list) that booting from eMMC was not
working for some folks.

> I have a new version I am working on. will fix it up and send it later
> today - fixing some other pending documentation aspects atm.

Looking forward to give it a try !

If it's not too much to ask, please cc me on the v4 series.

Thank you.

>
> -- 
> Regards,
> Nishanth Menon
> Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 
> 849D 1736 249D


Re: [PATCH 01/17] dm: usb: udc: Factor out plain udevice handler functions

2023-08-22 Thread Mattijs Korpershoek
On sam., août 19, 2023 at 16:23, Marek Vasut  wrote:

> Pull the functionality of UDC uclass that operates on plain udevice
> and does not use this dev_array array into separate functions and
> expose those functions, so that as much code as possible can be
> switched over to these functions and the dev_array can be dropped.
>
> Signed-off-by: Marek Vasut 
> ---
> Cc: Angus Ainslie 
> Cc: Dmitrii Merkurev 
> Cc: Eddie Cai 
> Cc: Kever Yang 
> Cc: Lukasz Majewski 
> Cc: Miquel Raynal 
> Cc: Mattijs Korpershoek 
> Cc: Nishanth Menon 
> Cc: Patrice Chotard 
> Cc: Patrick Delaunay 
> Cc: Philipp Tomsich 
> Cc: Simon Glass 
> Cc: Stefan Roese 
> Cc: ker...@puri.sm
> ---

Reviewed-by: Mattijs Korpershoek 

>  drivers/usb/gadget/udc/Makefile |  2 +-
>  drivers/usb/gadget/udc/udc-uclass.c | 57 +
>  include/linux/usb/gadget.h  | 17 +
>  3 files changed, 68 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/usb/gadget/udc/Makefile b/drivers/usb/gadget/udc/Makefile
> index 95dbf0c82ee..467c566f6d3 100644
> --- a/drivers/usb/gadget/udc/Makefile
> +++ b/drivers/usb/gadget/udc/Makefile
> @@ -7,4 +7,4 @@ obj-$(CONFIG_USB_DWC3_GADGET) += udc-core.o
>  endif
>  
>  obj-$(CONFIG_$(SPL_)DM_USB_GADGET)   += udc-core.o
> -obj-$(CONFIG_$(SPL_)DM) += udc-uclass.o
> +obj-y += udc-uclass.o
> diff --git a/drivers/usb/gadget/udc/udc-uclass.c 
> b/drivers/usb/gadget/udc/udc-uclass.c
> index de8861829c7..b4271b4be9f 100644
> --- a/drivers/usb/gadget/udc/udc-uclass.c
> +++ b/drivers/usb/gadget/udc/udc-uclass.c
> @@ -14,6 +14,37 @@
>  #if CONFIG_IS_ENABLED(DM_USB_GADGET)
>  #define MAX_UDC_DEVICES 4
>  static struct udevice *dev_array[MAX_UDC_DEVICES];
> +
> +int udc_device_get_by_index(int index, struct udevice **udev)
> +{
> + struct udevice *dev = NULL;
> + int ret;
> +
> + ret = uclass_get_device_by_seq(UCLASS_USB_GADGET_GENERIC, index, &dev);
> + if (!ret && dev) {
> + *udev = dev;
> + return 0;
> + }
> +
> + ret = uclass_get_device(UCLASS_USB_GADGET_GENERIC, index, &dev);
> + if (!ret && dev) {
> + *udev = dev;
> + return 0;
> + }
> +
> + pr_err("No USB device found\n");
> + return -ENODEV;
> +}
> +
> +int udc_device_put(struct udevice *udev)
> +{
> +#if CONFIG_IS_ENABLED(DM_DEVICE_REMOVE)
> + return device_remove(udev, DM_REMOVE_NORMAL);
> +#else
> + return -ENOSYS;
> +#endif
> +}
> +
>  int usb_gadget_initialize(int index)
>  {
>   int ret;
> @@ -23,13 +54,10 @@ int usb_gadget_initialize(int index)
>   return -EINVAL;
>   if (dev_array[index])
>   return 0;
> - ret = uclass_get_device_by_seq(UCLASS_USB_GADGET_GENERIC, index, &dev);
> + ret = udc_device_get_by_index(index, &dev);
>   if (!dev || ret) {
> - ret = uclass_get_device(UCLASS_USB_GADGET_GENERIC, index, &dev);
> - if (!dev || ret) {
> - pr_err("No USB device found\n");
> - return -ENODEV;
> - }
> + pr_err("No USB device found\n");
> + return -ENODEV;
>   }
>   dev_array[index] = dev;
>   return 0;
> @@ -42,7 +70,7 @@ int usb_gadget_release(int index)
>   if (index < 0 || index >= ARRAY_SIZE(dev_array))
>   return -EINVAL;
>  
> - ret = device_remove(dev_array[index], DM_REMOVE_NORMAL);
> + ret = device_remove(dev_array[index]);
>   if (!ret)
>   dev_array[index] = NULL;
>   return ret;
> @@ -57,10 +85,25 @@ int usb_gadget_handle_interrupts(int index)
>   return -EINVAL;
>   return dm_usb_gadget_handle_interrupts(dev_array[index]);
>  }
> +#else
> +/* Backwards hardware compatibility -- switch to DM_USB_GADGET */
> +static int legacy_index;
> +int udc_device_get_by_index(int index, struct udevice **udev)
> +{
> + legacy_index = index;
> + return board_usb_init(index, USB_INIT_DEVICE);
> +}
> +
> +int udc_device_put(struct udevice *udev)
> +{
> + return board_usb_cleanup(legacy_index, USB_INIT_DEVICE);
> +}
>  #endif
>  
> +#if CONFIG_IS_ENABLED(DM)
>  UCLASS_DRIVER(usb_gadget_generic) = {
>   .id = UCLASS_USB_GADGET_GENERIC,
>   .name   = "usb",
>   .flags  = DM_UC_FLAG_SEQ_ALIAS,
>  };
> +#endif
> diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
> index 2f694fc25c1..5e9a6513d5b 100644
> --- a/include/linux/usb/gadget.h
> +++ b/include/linux/usb/gadget.h
&g

Re: [PATCH 02/17] usb: sandbox: Add DM_USB_GADGET support

2023-08-22 Thread Mattijs Korpershoek
On sam., août 19, 2023 at 16:23, Marek Vasut  wrote:

> Remove local usb_gadget_register_driver()/usb_gadget_unregister_driver()
> implementation which is implemented in udc-core.c instead if DM_USB_GADGET
> is enabled. Add no-op dm_usb_gadget_handle_interrupts() implementation.
>
> Signed-off-by: Marek Vasut 
> ---
> Cc: Angus Ainslie 
> Cc: Dmitrii Merkurev 
> Cc: Eddie Cai 
> Cc: Kever Yang 
> Cc: Lukasz Majewski 
> Cc: Miquel Raynal 
> Cc: Mattijs Korpershoek 
> Cc: Nishanth Menon 
> Cc: Patrice Chotard 
> Cc: Patrick Delaunay 
> Cc: Philipp Tomsich 
> Cc: Simon Glass 
> Cc: Stefan Roese 
> Cc: ker...@puri.sm
> ---
>  drivers/usb/host/usb-sandbox.c | 7 +++
>  1 file changed, 7 insertions(+)

Reviewed-by: Mattijs Korpershoek 

>
> diff --git a/drivers/usb/host/usb-sandbox.c b/drivers/usb/host/usb-sandbox.c
> index d1103dcb2e9..582f72d00c1 100644
> --- a/drivers/usb/host/usb-sandbox.c
> +++ b/drivers/usb/host/usb-sandbox.c
> @@ -124,6 +124,12 @@ static int sandbox_submit_int(struct udevice *bus, 
> struct usb_device *udev,
>   return ret;
>  }
>  
> +#if CONFIG_IS_ENABLED(DM_USB_GADGET)
> +int dm_usb_gadget_handle_interrupts(struct udevice *dev)
> +{
> + return 0;
> +}
> +#else
>  int usb_gadget_handle_interrupts(int index)
>  {
>   return 0;
> @@ -144,6 +150,7 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver 
> *driver)
>  
>   return 0;
>  }
> +#endif
>  
>  static int sandbox_alloc_device(struct udevice *dev, struct usb_device *udev)
>  {
> -- 
> 2.40.1


Re: [PATCH 03/17] configs: sandbox: Enable DM_USB_GADGET

2023-08-22 Thread Mattijs Korpershoek
On sam., août 19, 2023 at 16:23, Marek Vasut  wrote:

> Switch sandbox to DM_USB_GADGET, DM is the future.
>
> Signed-off-by: Marek Vasut 
> ---
> Cc: Angus Ainslie 
> Cc: Dmitrii Merkurev 
> Cc: Eddie Cai 
> Cc: Kever Yang 
> Cc: Lukasz Majewski 
> Cc: Miquel Raynal 
> Cc: Mattijs Korpershoek 
> Cc: Nishanth Menon 
> Cc: Patrice Chotard 
> Cc: Patrick Delaunay 
> Cc: Philipp Tomsich 
> Cc: Simon Glass 
> Cc: Stefan Roese 
> Cc: ker...@puri.sm
> ---
>  configs/sandbox64_defconfig| 1 +
>  configs/sandbox_defconfig  | 1 +
>  configs/sandbox_flattree_defconfig | 1 +
>  configs/sandbox_noinst_defconfig   | 1 +
>  configs/sandbox_spl_defconfig  | 1 +
>  configs/sandbox_vpl_defconfig  | 1 +
>  6 files changed, 6 insertions(+)

Reviewed-by: Mattijs Korpershoek 

>
> diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig
> index 69e5efe8748..72452695cdc 100644
> --- a/configs/sandbox64_defconfig
> +++ b/configs/sandbox64_defconfig
> @@ -230,6 +230,7 @@ CONFIG_TIMER=y
>  CONFIG_TIMER_EARLY=y
>  CONFIG_SANDBOX_TIMER=y
>  CONFIG_USB=y
> +CONFIG_DM_USB_GADGET=y
>  CONFIG_USB_EMUL=y
>  CONFIG_USB_KEYBOARD=y
>  CONFIG_VIDEO=y
> diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
> index 1cd1c2ed7cd..9f8b81f5fe6 100644
> --- a/configs/sandbox_defconfig
> +++ b/configs/sandbox_defconfig
> @@ -298,6 +298,7 @@ CONFIG_TIMER=y
>  CONFIG_TIMER_EARLY=y
>  CONFIG_SANDBOX_TIMER=y
>  CONFIG_USB=y
> +CONFIG_DM_USB_GADGET=y
>  CONFIG_USB_EMUL=y
>  CONFIG_USB_KEYBOARD=y
>  CONFIG_USB_GADGET=y
> diff --git a/configs/sandbox_flattree_defconfig 
> b/configs/sandbox_flattree_defconfig
> index 8aa295686dc..cedae60d3cf 100644
> --- a/configs/sandbox_flattree_defconfig
> +++ b/configs/sandbox_flattree_defconfig
> @@ -204,6 +204,7 @@ CONFIG_TIMER=y
>  CONFIG_TIMER_EARLY=y
>  CONFIG_SANDBOX_TIMER=y
>  CONFIG_USB=y
> +CONFIG_DM_USB_GADGET=y
>  CONFIG_USB_EMUL=y
>  CONFIG_USB_KEYBOARD=y
>  CONFIG_VIDEO=y
> diff --git a/configs/sandbox_noinst_defconfig 
> b/configs/sandbox_noinst_defconfig
> index 2c6aab6c859..360686b9682 100644
> --- a/configs/sandbox_noinst_defconfig
> +++ b/configs/sandbox_noinst_defconfig
> @@ -218,6 +218,7 @@ CONFIG_TIMER=y
>  CONFIG_TIMER_EARLY=y
>  CONFIG_SANDBOX_TIMER=y
>  CONFIG_USB=y
> +CONFIG_DM_USB_GADGET=y
>  CONFIG_USB_EMUL=y
>  CONFIG_USB_KEYBOARD=y
>  CONFIG_VIDEO=y
> diff --git a/configs/sandbox_spl_defconfig b/configs/sandbox_spl_defconfig
> index 8d50162b274..bc79adfcd8f 100644
> --- a/configs/sandbox_spl_defconfig
> +++ b/configs/sandbox_spl_defconfig
> @@ -224,6 +224,7 @@ CONFIG_TIMER=y
>  CONFIG_TIMER_EARLY=y
>  CONFIG_SANDBOX_TIMER=y
>  CONFIG_USB=y
> +CONFIG_DM_USB_GADGET=y
>  CONFIG_USB_EMUL=y
>  CONFIG_USB_KEYBOARD=y
>  CONFIG_VIDEO=y
> diff --git a/configs/sandbox_vpl_defconfig b/configs/sandbox_vpl_defconfig
> index f3a0fd19a96..2c817b3847d 100644
> --- a/configs/sandbox_vpl_defconfig
> +++ b/configs/sandbox_vpl_defconfig
> @@ -237,6 +237,7 @@ CONFIG_VPL_TIMER=y
>  CONFIG_TIMER_EARLY=y
>  CONFIG_SANDBOX_TIMER=y
>  CONFIG_USB=y
> +CONFIG_DM_USB_GADGET=y
>  CONFIG_USB_EMUL=y
>  CONFIG_USB_KEYBOARD=y
>  CONFIG_VIDEO=y
> -- 
> 2.40.1


Re: [PATCH 04/17] cmd: fastboot: Use plain udevice for UDC controller interaction

2023-08-22 Thread Mattijs Korpershoek
On sam., août 19, 2023 at 16:23, Marek Vasut  wrote:

> Convert to plain udevice interaction with UDC controller
> device, avoid the use of UDC uclass dev_array .
>
> Signed-off-by: Marek Vasut 
> ---
> Cc: Angus Ainslie 
> Cc: Dmitrii Merkurev 
> Cc: Eddie Cai 
> Cc: Kever Yang 
> Cc: Lukasz Majewski 
> Cc: Miquel Raynal 
> Cc: Mattijs Korpershoek 
> Cc: Nishanth Menon 
> Cc: Patrice Chotard 
> Cc: Patrick Delaunay 
> Cc: Philipp Tomsich 
> Cc: Simon Glass 
> Cc: Stefan Roese 
> Cc: ker...@puri.sm
> ---
>  cmd/fastboot.c | 7 ---
>  1 file changed, 4 insertions(+), 3 deletions(-)

Tested that I could reflash the bootloader (raw) partition with:

$ fastboot flash bootloader u-boot_kvim3_noab.bin

Works fine!

Reviewed-by: Mattijs Korpershoek 
Tested-by: Mattijs Korpershoek  # on khadas vim3

Based on: 2023.10-rc3

>
> diff --git a/cmd/fastboot.c b/cmd/fastboot.c
> index 3d5ff951eb6..17fb0a0aa7b 100644
> --- a/cmd/fastboot.c
> +++ b/cmd/fastboot.c
> @@ -61,6 +61,7 @@ static int do_fastboot_usb(int argc, char *const argv[],
>  {
>   int controller_index;
>   char *usb_controller;
> + struct udevice *udc;
>   char *endp;
>   int ret;
>  
> @@ -79,7 +80,7 @@ static int do_fastboot_usb(int argc, char *const argv[],
>   return CMD_RET_FAILURE;
>   }
>  
> - ret = usb_gadget_initialize(controller_index);
> + ret = udc_device_get_by_index(controller_index, &udc);
>   if (ret) {
>   pr_err("USB init failed: %d\n", ret);
>   return CMD_RET_FAILURE;
> @@ -103,13 +104,13 @@ static int do_fastboot_usb(int argc, char *const argv[],
>   if (ctrlc())
>   break;
>   schedule();
> - usb_gadget_handle_interrupts(controller_index);
> + dm_usb_gadget_handle_interrupts(udc);
>   }
>  
>   ret = CMD_RET_SUCCESS;
>  
>  exit:
> - usb_gadget_release(controller_index);
> + udc_device_put(udc);
>   g_dnl_unregister();
>   g_dnl_clear_detach();
>  
> -- 
> 2.40.1


Re: [PATCH 06/17] cmd: sdp: Reorder variable declaration

2023-08-22 Thread Mattijs Korpershoek
On sam., août 19, 2023 at 16:23, Marek Vasut  wrote:

> Move the variable declaration around to improve code readability.
> No functional change.
>
> Signed-off-by: Marek Vasut 
> ---
> Cc: Angus Ainslie 
> Cc: Dmitrii Merkurev 
> Cc: Eddie Cai 
> Cc: Kever Yang 
> Cc: Lukasz Majewski 
> Cc: Miquel Raynal 
> Cc: Mattijs Korpershoek 
> Cc: Nishanth Menon 
> Cc: Patrice Chotard 
> Cc: Patrick Delaunay 
> Cc: Philipp Tomsich 
> Cc: Simon Glass 
> Cc: Stefan Roese 
> Cc: ker...@puri.sm
> ---
>  cmd/usb_gadget_sdp.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Mattijs Korpershoek 

>
> diff --git a/cmd/usb_gadget_sdp.c b/cmd/usb_gadget_sdp.c
> index 1af82e11366..784d1b49768 100644
> --- a/cmd/usb_gadget_sdp.c
> +++ b/cmd/usb_gadget_sdp.c
> @@ -14,13 +14,13 @@
>  
>  static int do_sdp(struct cmd_tbl *cmdtp, int flag, int argc, char *const 
> argv[])
>  {
> + int controller_index;
>   int ret;
>  
>   if (argc < 2)
>   return CMD_RET_USAGE;
>  
> - char *usb_controller = argv[1];
> - int controller_index = simple_strtoul(usb_controller, NULL, 0);
> + controller_index = simple_strtoul(argv[1], NULL, 0);
>   usb_gadget_initialize(controller_index);
>  
>   g_dnl_clear_detach();
> -- 
> 2.40.1


Re: [PATCH 08/17] cmd: ums: Use plain udevice for UDC controller interaction

2023-08-22 Thread Mattijs Korpershoek
On sam., août 19, 2023 at 16:23, Marek Vasut  wrote:

> Convert to plain udevice interaction with UDC controller
> device, avoid the use of UDC uclass dev_array .
>
> Signed-off-by: Marek Vasut 
> ---
> Cc: Angus Ainslie 
> Cc: Dmitrii Merkurev 
> Cc: Eddie Cai 
> Cc: Kever Yang 
> Cc: Lukasz Majewski 
> Cc: Miquel Raynal 
> Cc: Mattijs Korpershoek 
> Cc: Nishanth Menon 
> Cc: Patrice Chotard 
> Cc: Patrick Delaunay 
> Cc: Philipp Tomsich 
> Cc: Simon Glass 
> Cc: Stefan Roese 
> Cc: ker...@puri.sm
> ---
>  cmd/usb_mass_storage.c  | 10 ++
>  drivers/usb/gadget/f_mass_storage.c |  8 
>  include/usb_mass_storage.h  |  2 +-
>  3 files changed, 11 insertions(+), 9 deletions(-)

Tested on vim3 with:
=> ums 0 mmc 2

Tested that I could read some files from the android data partition.

Reviewed-by: Mattijs Korpershoek 
Tested-by: Mattijs Korpershoek  # on khadas vim3

>
> diff --git a/cmd/usb_mass_storage.c b/cmd/usb_mass_storage.c
> index c3cc1975f9d..9c51ae0967f 100644
> --- a/cmd/usb_mass_storage.c
> +++ b/cmd/usb_mass_storage.c
> @@ -143,6 +143,7 @@ static int do_usb_mass_storage(struct cmd_tbl *cmdtp, int 
> flag,
>   const char *devtype;
>   const char *devnum;
>   unsigned int controller_index;
> + struct udevice *udc;
>   int rc;
>   int cable_ready_timeout __maybe_unused;
>  
> @@ -164,13 +165,14 @@ static int do_usb_mass_storage(struct cmd_tbl *cmdtp, 
> int flag,
>  
>   controller_index = (unsigned int)(simple_strtoul(
>   usb_controller, NULL, 0));
> - if (usb_gadget_initialize(controller_index)) {
> + rc = udc_device_get_by_index(controller_index, &udc);
> + if (rc) {
>   pr_err("Couldn't init USB controller.\n");
>   rc = CMD_RET_FAILURE;
>   goto cleanup_ums_init;
>   }
>  
> - rc = fsg_init(ums, ums_count, controller_index);
> + rc = fsg_init(ums, ums_count, udc);
>   if (rc) {
>   pr_err("fsg_init failed\n");
>   rc = CMD_RET_FAILURE;
> @@ -215,7 +217,7 @@ static int do_usb_mass_storage(struct cmd_tbl *cmdtp, int 
> flag,
>   }
>  
>   while (1) {
> - usb_gadget_handle_interrupts(controller_index);
> + dm_usb_gadget_handle_interrupts(udc);
>  
>   rc = fsg_main_thread(NULL);
>   if (rc) {
> @@ -247,7 +249,7 @@ static int do_usb_mass_storage(struct cmd_tbl *cmdtp, int 
> flag,
>  cleanup_register:
>   g_dnl_unregister();
>  cleanup_board:
> - usb_gadget_release(controller_index);
> + udc_device_put(udc);
>  cleanup_ums_init:
>   ums_fini();
>  
> diff --git a/drivers/usb/gadget/f_mass_storage.c 
> b/drivers/usb/gadget/f_mass_storage.c
> index f46829eb7ad..1d17331cb03 100644
> --- a/drivers/usb/gadget/f_mass_storage.c
> +++ b/drivers/usb/gadget/f_mass_storage.c
> @@ -435,7 +435,7 @@ static void set_bulk_out_req_length(struct fsg_common 
> *common,
>  static struct ums *ums;
>  static int ums_count;
>  static struct fsg_common *the_fsg_common;
> -static unsigned int controller_index;
> +static struct udevice *udcdev;
>  
>  static int fsg_set_halt(struct fsg_dev *fsg, struct usb_ep *ep)
>  {
> @@ -680,7 +680,7 @@ static int sleep_thread(struct fsg_common *common)
>   k = 0;
>   }
>  
> - usb_gadget_handle_interrupts(controller_index);
> + dm_usb_gadget_handle_interrupts(udcdev);
>   }
>   common->thread_wakeup_needed = 0;
>   return rc;
> @@ -2764,11 +2764,11 @@ int fsg_add(struct usb_configuration *c)
>   return fsg_bind_config(c->cdev, c, fsg_common);
>  }
>  
> -int fsg_init(struct ums *ums_devs, int count, unsigned int controller_idx)
> +int fsg_init(struct ums *ums_devs, int count, struct udevice *udc)
>  {
>   ums = ums_devs;
>   ums_count = count;
> - controller_index = controller_idx;
> + udcdev = udc;
>  
>   return 0;
>  }
> diff --git a/include/usb_mass_storage.h b/include/usb_mass_storage.h
> index 08ccc97cf22..83ab93b530d 100644
> --- a/include/usb_mass_storage.h
> +++ b/include/usb_mass_storage.h
> @@ -25,7 +25,7 @@ struct ums {
>   struct blk_desc block_dev;
>  };
>  
> -int fsg_init(struct ums *ums_devs, int count, unsigned int controller_idx);
> +int fsg_init(struct ums *ums_devs, int count, struct udevice *udc);
>  void fsg_cleanup(void);
>  int fsg_main_thread(void *);
>  int fsg_add(struct usb_configuration *c);
> -- 
> 2.40.1


Re: [PATCH 09/17] dfu: Detach the controller on error

2023-08-22 Thread Mattijs Korpershoek
On sam., août 19, 2023 at 16:23, Marek Vasut  wrote:

> In case anything errors out during the DFU registration, detach
> the controller instead of bailing out right away. This way, the
> controller can be reattached on next attempt.
>
> Signed-off-by: Marek Vasut 
> ---
> Cc: Angus Ainslie 
> Cc: Dmitrii Merkurev 
> Cc: Eddie Cai 
> Cc: Kever Yang 
> Cc: Lukasz Majewski 
> Cc: Miquel Raynal 
> Cc: Mattijs Korpershoek 
> Cc: Nishanth Menon 
> Cc: Patrice Chotard 
> Cc: Patrick Delaunay 
> Cc: Philipp Tomsich 
> Cc: Simon Glass 
> Cc: Stefan Roese 
> Cc: ker...@puri.sm
> ---
>  common/dfu.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Reviewed-by: Mattijs Korpershoek 

>
> diff --git a/common/dfu.c b/common/dfu.c
> index 96190889ab7..32fba84da16 100644
> --- a/common/dfu.c
> +++ b/common/dfu.c
> @@ -34,7 +34,8 @@ int run_usb_dnl_gadget(int usbctrl_index, char 
> *usb_dnl_gadget)
>   ret = g_dnl_register(usb_dnl_gadget);
>   if (ret) {
>   pr_err("g_dnl_register failed");
> - return CMD_RET_FAILURE;
> + ret = CMD_RET_FAILURE;
> + goto err_detach;
>   }
>  
>  #ifdef CONFIG_DFU_TIMEOUT
> @@ -106,6 +107,7 @@ int run_usb_dnl_gadget(int usbctrl_index, char 
> *usb_dnl_gadget)
>   }
>  exit:
>   g_dnl_unregister();
> +err_detach:
>   usb_gadget_release(usbctrl_index);
>  
>   if (dfu_reset)
> -- 
> 2.40.1


Re: [PATCH 10/17] dfu: Use plain udevice for UDC controller interaction

2023-08-22 Thread Mattijs Korpershoek
On sam., août 19, 2023 at 16:24, Marek Vasut  wrote:

> Convert to plain udevice interaction with UDC controller
> device, avoid the use of UDC uclass dev_array .
>
> Signed-off-by: Marek Vasut 
> ---
> Cc: Angus Ainslie 
> Cc: Dmitrii Merkurev 
> Cc: Eddie Cai 
> Cc: Kever Yang 
> Cc: Lukasz Majewski 
> Cc: Miquel Raynal 
> Cc: Mattijs Korpershoek 
> Cc: Nishanth Menon 
> Cc: Patrice Chotard 
> Cc: Patrick Delaunay 
> Cc: Philipp Tomsich 
> Cc: Simon Glass 
> Cc: Stefan Roese 
> Cc: ker...@puri.sm
> ---
>  common/dfu.c | 15 ---
>  1 file changed, 8 insertions(+), 7 deletions(-)

Reviewed-by: Mattijs Korpershoek 

>
> diff --git a/common/dfu.c b/common/dfu.c
> index 32fba84da16..45206b9e225 100644
> --- a/common/dfu.c
> +++ b/common/dfu.c
> @@ -23,11 +23,12 @@
>  int run_usb_dnl_gadget(int usbctrl_index, char *usb_dnl_gadget)
>  {
>   bool dfu_reset = false;
> + struct udevice *udc;
>   int ret, i = 0;
>  
> - ret = usb_gadget_initialize(usbctrl_index);
> + ret = udc_device_get_by_index(usbctrl_index, &udc);
>   if (ret) {
> - pr_err("usb_gadget_initialize failed\n");
> + pr_err("udc_device_get_by_index failed\n");
>   return CMD_RET_FAILURE;
>   }
>   g_dnl_clear_detach();
> @@ -55,7 +56,7 @@ int run_usb_dnl_gadget(int usbctrl_index, char 
> *usb_dnl_gadget)
>   }
>  
>   /*
> -  * This extra number of usb_gadget_handle_interrupts()
> +  * This extra number of 
> dm_usb_gadget_handle_interrupts()
>* calls is necessary to assure correct transmission
>* completion with dfu-util
>*/
> @@ -68,7 +69,7 @@ int run_usb_dnl_gadget(int usbctrl_index, char 
> *usb_dnl_gadget)
>  
>   if (dfu_get_defer_flush()) {
>   /*
> -  * Call to usb_gadget_handle_interrupts() is necessary
> +  * Call to dm_usb_gadget_handle_interrupts() is 
> necessary
>* to act on ZLP OUT transaction from HOST PC after
>* transmitting the whole file.
>*
> @@ -77,7 +78,7 @@ int run_usb_dnl_gadget(int usbctrl_index, char 
> *usb_dnl_gadget)
>* 5 seconds). In such situation the dfu-util program
>* exits with error message.
>*/
> - usb_gadget_handle_interrupts(usbctrl_index);
> + dm_usb_gadget_handle_interrupts(udc);
>   ret = dfu_flush(dfu_get_defer_flush(), NULL, 0, 0);
>   dfu_set_defer_flush(NULL);
>   if (ret) {
> @@ -103,12 +104,12 @@ int run_usb_dnl_gadget(int usbctrl_index, char 
> *usb_dnl_gadget)
>   goto exit;
>  
>   schedule();
> - usb_gadget_handle_interrupts(usbctrl_index);
> + dm_usb_gadget_handle_interrupts(udc);
>   }
>  exit:
>   g_dnl_unregister();
>  err_detach:
> - usb_gadget_release(usbctrl_index);
> + udc_device_put(udc);
>  
>   if (dfu_reset)
>   do_reset(NULL, 0, 0, NULL);
> -- 
> 2.40.1


Re: [PATCH 11/17] spl: sdp: Detach the controller on error

2023-08-22 Thread Mattijs Korpershoek
On sam., août 19, 2023 at 16:24, Marek Vasut  wrote:

> In case anything errors out during the SDP transfer, detach
> the controller instead of bailing out right away. This way,
> the controller can be reattached on next attempt.
>
> Signed-off-by: Marek Vasut 
> ---
> Cc: Angus Ainslie 
> Cc: Dmitrii Merkurev 
> Cc: Eddie Cai 
> Cc: Kever Yang 
> Cc: Lukasz Majewski 
> Cc: Miquel Raynal 
> Cc: Mattijs Korpershoek 
> Cc: Nishanth Menon 
> Cc: Patrice Chotard 
> Cc: Patrick Delaunay 
> Cc: Philipp Tomsich 
> Cc: Simon Glass 
> Cc: Stefan Roese 
> Cc: ker...@puri.sm
> ---

Reviewed-by: Mattijs Korpershoek 

Nitpick/question below

>  common/spl/spl_sdp.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/common/spl/spl_sdp.c b/common/spl/spl_sdp.c
> index cc4fb4f7cca..f6b99c1af5a 100644
> --- a/common/spl/spl_sdp.c
> +++ b/common/spl/spl_sdp.c
> @@ -25,13 +25,13 @@ static int spl_sdp_load_image(struct spl_image_info 
> *spl_image,
>   ret = g_dnl_register("usb_dnl_sdp");
>   if (ret) {
>   pr_err("SDP dnl register failed: %d\n", ret);
> - return ret;
> + goto err_detach;
>   }
>  
>   ret = sdp_init(controller_index);
>   if (ret) {
>   pr_err("SDP init failed: %d\n", ret);
> - return -ENODEV;
> + goto err_detach;

Shouldn't we call g_dnl_unregister(); here since g_dnl_register() was
sucessfully called before?

This would match what's done in common/dfu.c

>   }
>  
>   /*
> @@ -42,6 +42,7 @@ static int spl_sdp_load_image(struct spl_image_info 
> *spl_image,
>   ret = spl_sdp_handle(controller_index, spl_image, bootdev);
>   debug("SDP ended\n");
>  
> +err_detach:
>   usb_gadget_release(controller_index);
>   return ret;
>  }
> -- 
> 2.40.1


Re: [PATCH 12/17] sdp: Use plain udevice for UDC controller interaction

2023-08-22 Thread Mattijs Korpershoek
On sam., août 19, 2023 at 16:24, Marek Vasut  wrote:

> Convert to plain udevice interaction with UDC controller
> device, avoid the use of UDC uclass dev_array .
>
> Signed-off-by: Marek Vasut 
> ---
> Cc: Angus Ainslie 
> Cc: Dmitrii Merkurev 
> Cc: Eddie Cai 
> Cc: Kever Yang 
> Cc: Lukasz Majewski 
> Cc: Miquel Raynal 
> Cc: Mattijs Korpershoek 
> Cc: Nishanth Menon 
> Cc: Patrice Chotard 
> Cc: Patrick Delaunay 
> Cc: Philipp Tomsich 
> Cc: Simon Glass 
> Cc: Stefan Roese 
> Cc: ker...@puri.sm
> ---
>  cmd/usb_gadget_sdp.c   | 11 +++
>  common/spl/spl_sdp.c   | 13 -
>  drivers/usb/gadget/f_sdp.c | 10 +-
>  include/sdp.h  |  6 +++---
>  4 files changed, 23 insertions(+), 17 deletions(-)

Reviewed-by: Mattijs Korpershoek 

>
> diff --git a/cmd/usb_gadget_sdp.c b/cmd/usb_gadget_sdp.c
> index 784d1b49768..748aa0a7488 100644
> --- a/cmd/usb_gadget_sdp.c
> +++ b/cmd/usb_gadget_sdp.c
> @@ -15,13 +15,16 @@
>  static int do_sdp(struct cmd_tbl *cmdtp, int flag, int argc, char *const 
> argv[])
>  {
>   int controller_index;
> + struct udevice *udc;
>   int ret;
>  
>   if (argc < 2)
>   return CMD_RET_USAGE;
>  
>   controller_index = simple_strtoul(argv[1], NULL, 0);
> - usb_gadget_initialize(controller_index);
> + ret = udc_device_get_by_index(controller_index, &udc);
> + if (ret)
> + return ret;
>  
>   g_dnl_clear_detach();
>   ret = g_dnl_register("usb_dnl_sdp");
> @@ -30,20 +33,20 @@ static int do_sdp(struct cmd_tbl *cmdtp, int flag, int 
> argc, char *const argv[])
>   goto exit_register;
>   }
>  
> - ret = sdp_init(controller_index);
> + ret = sdp_init(udc);
>   if (ret) {
>   pr_err("SDP init failed: %d\n", ret);
>   goto exit;
>   }
>  
>   /* This command typically does not return but jumps to an image */
> - sdp_handle(controller_index);
> + sdp_handle(udc);
>   pr_err("SDP ended\n");
>  
>  exit:
>   g_dnl_unregister();
>  exit_register:
> - usb_gadget_release(controller_index);
> + udc_device_put(udc);
>  
>   return CMD_RET_FAILURE;
>  }
> diff --git a/common/spl/spl_sdp.c b/common/spl/spl_sdp.c
> index f6b99c1af5a..83585cf82d3 100644
> --- a/common/spl/spl_sdp.c
> +++ b/common/spl/spl_sdp.c
> @@ -14,10 +14,13 @@
>  static int spl_sdp_load_image(struct spl_image_info *spl_image,
> struct spl_boot_device *bootdev)
>  {
> - int ret;
>   const int controller_index = CONFIG_SPL_SDP_USB_DEV;
> + struct udevice *udc;
> + int ret;
>  
> - usb_gadget_initialize(controller_index);
> + ret = udc_device_get_by_index(controller_index, &udc);
> + if (ret)
> + return ret;
>  
>   board_usb_init(controller_index, USB_INIT_DEVICE);
>  
> @@ -28,7 +31,7 @@ static int spl_sdp_load_image(struct spl_image_info 
> *spl_image,
>   goto err_detach;
>   }
>  
> - ret = sdp_init(controller_index);
> + ret = sdp_init(udc);
>   if (ret) {
>   pr_err("SDP init failed: %d\n", ret);
>   goto err_detach;
> @@ -39,11 +42,11 @@ static int spl_sdp_load_image(struct spl_image_info 
> *spl_image,
>* or it loads a FIT image and returns it to be handled by the SPL
>* code.
>*/
> - ret = spl_sdp_handle(controller_index, spl_image, bootdev);
> + ret = spl_sdp_handle(udc, spl_image, bootdev);
>   debug("SDP ended\n");
>  
>  err_detach:
> - usb_gadget_release(controller_index);
> + udc_device_put(udc);
>   return ret;
>  }
>  SPL_LOAD_IMAGE_METHOD("USB SDP", 0, BOOT_DEVICE_BOARD, spl_sdp_load_image);
> diff --git a/drivers/usb/gadget/f_sdp.c b/drivers/usb/gadget/f_sdp.c
> index 4da5a160a09..37f6281abfb 100644
> --- a/drivers/usb/gadget/f_sdp.c
> +++ b/drivers/usb/gadget/f_sdp.c
> @@ -702,7 +702,7 @@ static int sdp_bind_config(struct usb_configuration *c)
>   return status;
>  }
>  
> -int sdp_init(int controller_index)
> +int sdp_init(struct udevice *udc)
>  {
>   printf("SDP: initialize...\n");
>   while (!sdp_func->configuration_done) {
> @@ -712,7 +712,7 @@ int sdp_init(int controller_index)
>   }
>  
>   schedule();
> - usb_gadget_handle_interrupts(controller_index);
> + dm_usb_gadget_handle_interrupts(udc);
>   }
>  
>   return 0;
> @@ -911,9 +911,9 @@ static void sdp_handle_out_ep(void)

Re: [PATCH 16/17] dm: usb: udc: Drop legacy udevice handler functions

2023-08-22 Thread Mattijs Korpershoek
On sam., août 19, 2023 at 16:24, Marek Vasut  wrote:

> Remove legacy functions limited by the dev_array array,
> those are no longer used anywhere, all the code uses
> plain udevice based access now.
>
> The usb_gadget_handle_interrupts() is doing udevice look up
> until all call sites use dm_usb_gadget_handle_interrupts().
>
> Signed-off-by: Marek Vasut 
> ---
> Cc: Angus Ainslie 
> Cc: Dmitrii Merkurev 
> Cc: Eddie Cai 
> Cc: Kever Yang 
> Cc: Lukasz Majewski 
> Cc: Miquel Raynal 
> Cc: Mattijs Korpershoek 
> Cc: Nishanth Menon 
> Cc: Patrice Chotard 
> Cc: Patrick Delaunay 
> Cc: Philipp Tomsich 
> Cc: Simon Glass 
> Cc: Stefan Roese 
> Cc: ker...@puri.sm
> ---
>  drivers/usb/gadget/udc/udc-uclass.c | 44 -
>  include/linux/usb/gadget.h  | 17 -------
>  2 files changed, 6 insertions(+), 55 deletions(-)

Reviewed-by: Mattijs Korpershoek 

>
> diff --git a/drivers/usb/gadget/udc/udc-uclass.c 
> b/drivers/usb/gadget/udc/udc-uclass.c
> index b4271b4be9f..7f54a3b00cb 100644
> --- a/drivers/usb/gadget/udc/udc-uclass.c
> +++ b/drivers/usb/gadget/udc/udc-uclass.c
> @@ -12,9 +12,6 @@
>  #include 
>  
>  #if CONFIG_IS_ENABLED(DM_USB_GADGET)
> -#define MAX_UDC_DEVICES 4
> -static struct udevice *dev_array[MAX_UDC_DEVICES];
> -
>  int udc_device_get_by_index(int index, struct udevice **udev)
>  {
>   struct udevice *dev = NULL;
> @@ -45,45 +42,16 @@ int udc_device_put(struct udevice *udev)
>  #endif
>  }
>  
> -int usb_gadget_initialize(int index)
> -{
> - int ret;
> - struct udevice *dev = NULL;
> -
> - if (index < 0 || index >= ARRAY_SIZE(dev_array))
> - return -EINVAL;
> - if (dev_array[index])
> - return 0;
> - ret = udc_device_get_by_index(index, &dev);
> - if (!dev || ret) {
> - pr_err("No USB device found\n");
> - return -ENODEV;
> - }
> - dev_array[index] = dev;
> - return 0;
> -}
> -
> -int usb_gadget_release(int index)
> +int usb_gadget_handle_interrupts(int index)
>  {
> -#if CONFIG_IS_ENABLED(DM_DEVICE_REMOVE)
> + struct udevice *udc;
>   int ret;
> - if (index < 0 || index >= ARRAY_SIZE(dev_array))
> - return -EINVAL;
>  
> - ret = device_remove(dev_array[index]);
> - if (!ret)
> - dev_array[index] = NULL;
> - return ret;
> -#else
> - return -ENOSYS;
> -#endif
> -}
> + ret = udc_device_get_by_index(index, &udc);
> + if (ret)
> + return ret;
>  
> -int usb_gadget_handle_interrupts(int index)
> -{
> - if (index < 0 || index >= ARRAY_SIZE(dev_array))
> - return -EINVAL;
> - return dm_usb_gadget_handle_interrupts(dev_array[index]);
> + return dm_usb_gadget_handle_interrupts(udc);
>  }
>  #else
>  /* Backwards hardware compatibility -- switch to DM_USB_GADGET */
> diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h
> index 5e9a6513d5b..54875d2716e 100644
> --- a/include/linux/usb/gadget.h
> +++ b/include/linux/usb/gadget.h
> @@ -1023,21 +1023,4 @@ int udc_device_get_by_index(int index, struct udevice 
> **udev);
>   */
>  int udc_device_put(struct udevice *udev);
>  
> -#if CONFIG_IS_ENABLED(DM_USB_GADGET)
> -int usb_gadget_initialize(int index);
> -int usb_gadget_release(int index);
> -int dm_usb_gadget_handle_interrupts(struct udevice *dev);
> -#else
> -#include 
> -static inline int usb_gadget_initialize(int index)
> -{
> - return board_usb_init(index, USB_INIT_DEVICE);
> -}
> -
> -static inline int usb_gadget_release(int index)
> -{
> - return board_usb_cleanup(index, USB_INIT_DEVICE);
> -}
> -#endif
> -
>  #endif   /* __LINUX_USB_GADGET_H */
> -- 
> 2.40.1


Re: [PATCH 17/17] board: usb: Replace legacy usb_gadget_handle_interrupts()

2023-08-22 Thread Mattijs Korpershoek
On sam., août 19, 2023 at 16:24, Marek Vasut  wrote:

> The usb_gadget_handle_interrupts() is no longer used anywhere,
> replace the remaining uses with dm_usb_gadget_handle_interrupts()
> which takes udevice as a parameter.
>
> Some of the UDC drivers currently ignore the index parameter altogether,
> those also ignore the udevice and have to be reworked. Other like the
> dwc3_uboot_handle_interrupt() had to be switched from index to udevice
> look up to avoid breakage.
>
> Signed-off-by: Marek Vasut 
> ---
> NOTE: Next step, get rid of dwc3_uboot_init()/dwc3_uboot_exit()
> ---
> Cc: Angus Ainslie 
> Cc: Dmitrii Merkurev 
> Cc: Eddie Cai 
> Cc: Kever Yang 
> Cc: Lukasz Majewski 
> Cc: Miquel Raynal 
> Cc: Mattijs Korpershoek 
> Cc: Nishanth Menon 
> Cc: Patrice Chotard 
> Cc: Patrick Delaunay 
> Cc: Philipp Tomsich 
> Cc: Simon Glass 
> Cc: Stefan Roese 
> Cc: ker...@puri.sm
> ---
>  arch/arm/mach-rockchip/board.c  |  4 ++--
>  board/purism/librem5/spl.c  |  4 ++--
>  board/samsung/common/exynos5-dt.c   |  4 ++--
>  board/st/stih410-b2260/board.c  |  4 ++--
>  board/ti/am43xx/board.c |  6 +++---
>  drivers/usb/dwc3/core.c |  6 +++---
>  drivers/usb/dwc3/dwc3-omap.c|  8 
>  drivers/usb/gadget/at91_udc.c   |  2 +-
>  drivers/usb/gadget/atmel_usba_udc.c |  3 +--
>  drivers/usb/gadget/ci_udc.c |  4 ++--
>  drivers/usb/gadget/dwc2_udc_otg.c   | 12 ++--
>  drivers/usb/gadget/udc/udc-uclass.c | 12 
>  drivers/usb/host/usb-sandbox.c  |  5 -
>  drivers/usb/musb-new/musb_uboot.c   |  2 +-
>  include/dwc3-omap-uboot.h   |  2 +-
>  include/dwc3-uboot.h|  2 +-
>  include/linux/usb/gadget.h  |  2 +-
>  17 files changed, 28 insertions(+), 54 deletions(-)

Tested that I could reflash the vim3 bootloader (on mmc2boot0)

Reviewed-by: Mattijs Korpershoek 
Tested-by: Mattijs Korpershoek  # on khadas vim3

>
> diff --git a/arch/arm/mach-rockchip/board.c b/arch/arm/mach-rockchip/board.c
> index 8d7b39ba157..57f08e0be0e 100644
> --- a/arch/arm/mach-rockchip/board.c
> +++ b/arch/arm/mach-rockchip/board.c
> @@ -299,9 +299,9 @@ static struct dwc3_device dwc3_device_data = {
>   .hsphy_mode = USBPHY_INTERFACE_MODE_UTMIW,
>  };
>  
> -int usb_gadget_handle_interrupts(int index)
> +int dm_usb_gadget_handle_interrupts(struct udevice *dev)
>  {
> - dwc3_uboot_handle_interrupt(0);
> + dwc3_uboot_handle_interrupt(dev);
>   return 0;
>  }
>  
> diff --git a/board/purism/librem5/spl.c b/board/purism/librem5/spl.c
> index 90f1fcf415f..581f0929662 100644
> --- a/board/purism/librem5/spl.c
> +++ b/board/purism/librem5/spl.c
> @@ -418,9 +418,9 @@ out:
>   return rv;
>  }
>  
> -int usb_gadget_handle_interrupts(int index)
> +int dm_usb_gadget_handle_interrupts(struct udevice *dev)
>  {
> - dwc3_uboot_handle_interrupt(0);
> + dwc3_uboot_handle_interrupt(dev);
>   return 0;
>  }
>  
> diff --git a/board/samsung/common/exynos5-dt.c 
> b/board/samsung/common/exynos5-dt.c
> index cde77d79a0f..726b7f0667a 100644
> --- a/board/samsung/common/exynos5-dt.c
> +++ b/board/samsung/common/exynos5-dt.c
> @@ -126,9 +126,9 @@ static struct dwc3_device dwc3_device_data = {
>   .index = 0,
>  };
>  
> -int usb_gadget_handle_interrupts(int index)
> +int dm_usb_gadget_handle_interrupts(struct udevice *dev)
>  {
> - dwc3_uboot_handle_interrupt(0);
> + dwc3_uboot_handle_interrupt(dev);
>   return 0;
>  }
>  
> diff --git a/board/st/stih410-b2260/board.c b/board/st/stih410-b2260/board.c
> index cd3a7dc51a2..e21cbc270e9 100644
> --- a/board/st/stih410-b2260/board.c
> +++ b/board/st/stih410-b2260/board.c
> @@ -50,9 +50,9 @@ static struct dwc3_device dwc3_device_data = {
>   .index = 0,
>  };
>  
> -int usb_gadget_handle_interrupts(int index)
> +int dm_usb_gadget_handle_interrupts(struct udevice *dev)
>  {
> - dwc3_uboot_handle_interrupt(index);
> + dwc3_uboot_handle_interrupt(dev);
>   return 0;
>  }
>  
> diff --git a/board/ti/am43xx/board.c b/board/ti/am43xx/board.c
> index 87e552a4701..58bfe7cd455 100644
> --- a/board/ti/am43xx/board.c
> +++ b/board/ti/am43xx/board.c
> @@ -760,13 +760,13 @@ static struct ti_usb_phy_device usb_phy2_device = {
>   .index = 1,
>  };
>  
> -int usb_gadget_handle_interrupts(int index)
> +int dm_usb_gadget_handle_interrupts(struct udevice *dev)
>  {
>   u32 status;
>  
> - status = dwc3_omap_uboot_interrupt_status(index);
> + status = dwc3_omap_uboot_interrupt_status(dev);
>   if (status)
> - dwc3_uboot_handle_interrupt(index);
> +  

Re: [PATCH V4 0/8] board: ti: Add support for BeaglePlay

2023-08-23 Thread Mattijs Korpershoek
Hi Nishanth,

On mar., août 22, 2023 at 13:41, Nishanth Menon  wrote:

> Hi,
>
> Add support for BeaglePlay - rev 4
>
> Full series: 
> https://github.com/nmenon/fix-k3-dt-u-boot/commits/beagleplay-v4.2
>
> Caveats:
> * networking: pending 
> https://lore.kernel.org/all/20230822121350.51324-1-rog...@kernel.org/
> * 32kclk and usb: pending:
>   https://lore.kernel.org/u-boot/20230725185253.2123433-4...@ti.com/
>   OR 
> https://github.com/nmenon/fix-k3-dt-u-boot/commit/853b29d63c1ca642be316f1afb0fb778610dec46
>   being properly resolved (NOTE: without this patch, wlan is broken in
>   Linux as the 32kclk from SoC is incorrectly supplied to wlan as 25MHz)
> * There seems to be a bug in Linux kernel with sdhci that seems to
>   depend on u-boot initialization of sdhci for functionality.
>
> Changes since V3:
> * GPIO, LEDs, PMIC enabled at u-boot level.
> * eMMC boot fixed in a manner not to break existing SK and other EVM
>   solutions. UDA FS solution similar to commit 5019170970ad
>   ("arch: arm: mach-k3: j721e: add support for UDA FS") introduced.
> * env file for beagleplay introduced to keep things consistent with the
>   behavior expected on BeaglePlay
> * Documentation updates to fixup alt, references, added OpenOCD debug
>   info etc.
> * New patch to ensure env files have priority over header included env
>   variables.
>
> Bootlog:
> emmc with no SD: 
> https://gist.github.com/nmenon/5755228ff424c55245f4534548827ab9
> emmc with SD: https://gist.github.com/nmenon/8571dba9e942e77e48e52fe59cf71aac
> SD boot: https://gist.github.com/nmenon/1cc850c37469fe7c86b26842fe0910f8
>
> Baseline: 7e6e40c57233 (origin/next) Merge tag 'v2023.10-rc3' into next
>
> V3: https://lore.kernel.org/all/20230815164440.2713726-1...@ti.com/
> V2: https://lore.kernel.org/u-boot/20230727234446.3651836-1...@ti.com/
> V1: https://lore.kernel.org/all/20230725185253.2123433-1...@ti.com/
>
> Nishanth Menon (6):
>   env_default: Allow CONFIG_EXTRA_ENV_TEXT to override
> CFG_EXTRA_ENV_SETTINGS
>   configs: am62x_evm*: Enable EMMC_BOOT configuration
>   arm: mach-k3: am625: Add support for UDA FS
>   arm: dts: k3-am625-sk-binman: Add labels for unsigned binary
>   board: ti: am62x: Add am62x_beagleplay_* defconfigs and env file
>   doc: board: ti: Add BeaglePlay documentation
>
> Nitin Yadav (1):
>   drivers: mmc: am654_sdhci: Update OTAP/ITAP delay
>
> Robert Nelson (1):
>   arm: dts: Add k3-am625-beagleplay

Using baseline 7e6e40c57233 ("Merge tag 'v2023.10-rc3' into next"), I
could boot all the way to U-boot proper shell.

And the LEDs work for me as well with:

  => led led-0 toggle

So for the whole series:

Tested-by: Mattijs Korpershoek 

>
>  arch/arm/dts/Makefile |2 +
>  .../dts/k3-am625-beagleplay-ddr4-1600MTs.dtsi | 2195 +
>  arch/arm/dts/k3-am625-beagleplay-u-boot.dtsi  |  196 ++
>  arch/arm/dts/k3-am625-beagleplay.dts  |  758 ++
>  arch/arm/dts/k3-am625-r5-beagleplay.dts   |   87 +
>  arch/arm/dts/k3-am625-sk-binman.dtsi  |4 +-
>  arch/arm/mach-k3/am625_init.c |6 +
>  board/ti/am62x/MAINTAINERS|7 +
>  board/ti/am62x/beagleplay.env |   23 +
>  board/ti/am62x/beagleplay_a53.config  |   55 +
>  board/ti/am62x/beagleplay_r5.config   |   15 +
>  configs/am62x_evm_a53_defconfig   |1 +
>  configs/am62x_evm_r5_defconfig|1 +
>  doc/board/ti/am62x_beagleplay.rst |  256 ++
>  doc/board/ti/img/beagleplay_emmc.svg  |  697 ++
>  doc/board/ti/k3.rst   |1 +
>  drivers/mmc/am654_sdhci.c |   14 +-
>  include/env_default.h |6 +-
>  18 files changed, 4315 insertions(+), 9 deletions(-)
>  create mode 100644 arch/arm/dts/k3-am625-beagleplay-ddr4-1600MTs.dtsi
>  create mode 100644 arch/arm/dts/k3-am625-beagleplay-u-boot.dtsi
>  create mode 100644 arch/arm/dts/k3-am625-beagleplay.dts
>  create mode 100644 arch/arm/dts/k3-am625-r5-beagleplay.dts
>  create mode 100644 board/ti/am62x/beagleplay.env
>  create mode 100644 board/ti/am62x/beagleplay_a53.config
>  create mode 100644 board/ti/am62x/beagleplay_r5.config
>  create mode 100644 doc/board/ti/am62x_beagleplay.rst
>  create mode 100644 doc/board/ti/img/beagleplay_emmc.svg
>
> -- 
> 2.40.0


Re: [PATCH V4 1/8] env_default: Allow CONFIG_EXTRA_ENV_TEXT to override CFG_EXTRA_ENV_SETTINGS

2023-08-23 Thread Mattijs Korpershoek
On mar., août 22, 2023 at 13:41, Nishanth Menon  wrote:

> CFG_EXTRA_ENV_SETTINGS is set in common board config files, This allows
> for majority of the settings to be set in a common manner. However, the
> minor variations between various board can be addressed by the board.env
> files. The board.env files are converted into CONFIG_EXTRA_ENV_TEXT.
>
> However, this creates a minor problem. For example:
> distro_bootcmd.h and used by ti_armv7_common.h uses it as:
>  #define BOOT_TARGET_DEVICES(func) \
>   func(MMC, mmc, 0) \
>   func(MMC, mmc, 1)
>
> Which in turn generates:
> boot_targets=mmc0 mmc1
>
> And this probably works fine for most boards, However when the
> boot_targets need to be reversed, the preferred behavior would have been
> to define it in board.env file as:
> boot_targets=mmc1 mmc0
>
> By changing the order of the inclusion, we allow for the
> CONFIG_EXTRA_ENV_TEXT to have a higher priority in the definition.
>
> Signed-off-by: Nishanth Menon 

Reviewed-by: Mattijs Korpershoek 

> ---
> Cc: Simon Glass 
>
> New patch
>
>  include/env_default.h | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/include/env_default.h b/include/env_default.h
> index b16c22d5a28c..714dfa9e845e 100644
> --- a/include/env_default.h
> +++ b/include/env_default.h
> @@ -112,12 +112,12 @@ const char default_environment[] = {
>  #ifdef CONFIG_MTDPARTS_DEFAULT
>   "mtdparts=" CONFIG_MTDPARTS_DEFAULT "\0"
>  #endif
> +#ifdef   CFG_EXTRA_ENV_SETTINGS
> + CFG_EXTRA_ENV_SETTINGS
> +#endif
>  #ifdef CONFIG_EXTRA_ENV_TEXT
>   /* This is created in the Makefile */
>   CONFIG_EXTRA_ENV_TEXT
> -#endif
> -#ifdef   CFG_EXTRA_ENV_SETTINGS
> - CFG_EXTRA_ENV_SETTINGS
>  #endif
>   "\0"
>  #else /* CONFIG_USE_DEFAULT_ENV_FILE */
> -- 
> 2.40.0


Re: [PATCH V4 2/8] configs: am62x_evm*: Enable EMMC_BOOT configuration

2023-08-23 Thread Mattijs Korpershoek
On mar., août 22, 2023 at 13:41, Nishanth Menon  wrote:

> Enable EMMC boot support for AM62x evm base configuration.
>
> Signed-off-by: Nishanth Menon 

Reviewed-by: Mattijs Korpershoek 

> ---
> New patch
>
>  configs/am62x_evm_a53_defconfig | 1 +
>  configs/am62x_evm_r5_defconfig  | 1 +
>  2 files changed, 2 insertions(+)
>
> diff --git a/configs/am62x_evm_a53_defconfig b/configs/am62x_evm_a53_defconfig
> index d55caabe22c9..824a99b9b6cc 100644
> --- a/configs/am62x_evm_a53_defconfig
> +++ b/configs/am62x_evm_a53_defconfig
> @@ -69,6 +69,7 @@ CONFIG_TI_K3_NAVSS_UDMA=y
>  CONFIG_TI_SCI_PROTOCOL=y
>  CONFIG_DM_MAILBOX=y
>  CONFIG_K3_SEC_PROXY=y
> +CONFIG_SUPPORT_EMMC_BOOT=y
>  CONFIG_MMC_SDHCI=y
>  CONFIG_MMC_SDHCI_ADMA=y
>  CONFIG_SPL_MMC_SDHCI_ADMA=y
> diff --git a/configs/am62x_evm_r5_defconfig b/configs/am62x_evm_r5_defconfig
> index 3c5f36729842..489ee943fe31 100644
> --- a/configs/am62x_evm_r5_defconfig
> +++ b/configs/am62x_evm_r5_defconfig
> @@ -92,6 +92,7 @@ CONFIG_DM_MAILBOX=y
>  CONFIG_K3_SEC_PROXY=y
>  CONFIG_SPL_MISC=y
>  CONFIG_ESM_K3=y
> +CONFIG_SUPPORT_EMMC_BOOT=y
>  CONFIG_MMC_SDHCI=y
>  CONFIG_MMC_SDHCI_ADMA=y
>  CONFIG_SPL_MMC_SDHCI_ADMA=y
> -- 
> 2.40.0


Re: [PATCH V4 3/8] arm: mach-k3: am625: Add support for UDA FS

2023-08-23 Thread Mattijs Korpershoek
On mar., août 22, 2023 at 13:41, Nishanth Menon  wrote:

> While boot partition support with EMMC boot is useful, it is
> constrained by the size of boot hardware partition itself.
>
> In the case of K3 devices, tispl images can contain OP-TEE images that
> can substantially vary in size and the u-boot image itself can vary over
> time as we enable various features.
>
> So use the CSD information in the case of EMMC_BOOT configuration being
> enabled to pick boot partition or UDA FS mode operation to pick.
>
> If EMMC_BOOT is disabled, then depend on filesystem configuration to
> pick data from UDA.
>
> Signed-off-by: Nishanth Menon 

Reviewed-by: Mattijs Korpershoek 

> ---
> New patch
>  arch/arm/mach-k3/am625_init.c | 6 ++
>  1 file changed, 6 insertions(+)
>
> diff --git a/arch/arm/mach-k3/am625_init.c b/arch/arm/mach-k3/am625_init.c
> index 0e5d44269ebf..ad61030a56fa 100644
> --- a/arch/arm/mach-k3/am625_init.c
> +++ b/arch/arm/mach-k3/am625_init.c
> @@ -228,7 +228,13 @@ u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 
> boot_device)
>  
>   switch (bootmode) {
>   case BOOT_DEVICE_EMMC:
> +#if CONFIG_IS_ENABLED(SUPPORT_EMMC_BOOT)
> + return (spl_mmc_emmc_boot_partition(mmc) ? MMCSD_MODE_EMMCBOOT 
> : MMCSD_MODE_FS);
> +#elif defined(CONFIG_SPL_FS_FAT) || defined(CONFIG_SPL_FS_EXT4)
> + return MMCSD_MODE_FS;
> +#else
>   return MMCSD_MODE_EMMCBOOT;
> +#endif
>   case BOOT_DEVICE_MMC:
>   if (bootmode_cfg & MAIN_DEVSTAT_PRIMARY_MMC_FS_RAW_MASK)
>   return MMCSD_MODE_RAW;
> -- 
> 2.40.0


Re: [PATCH V4 4/8] drivers: mmc: am654_sdhci: Update OTAP/ITAP delay

2023-08-23 Thread Mattijs Korpershoek
On mar., août 22, 2023 at 13:41, Nishanth Menon  wrote:

> From: Nitin Yadav 
>
> U-Boot is fail to boot class U1 UHS SD cards (such as microcenter)
> due to incorrect OTAP and ITAP delay select values. Update OTAP and
> ITAP delay select values based on recommeded RIOT values to fix boot
> issue.

nitpick: recommeded -> recommended

>
> Signed-off-by: Nitin Yadav 
> Signed-off-by: Nishanth Menon 
> ---
> Picked up from TI u-boot
> New patch in the series
>
>  drivers/mmc/am654_sdhci.c | 14 ++
>  1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/mmc/am654_sdhci.c b/drivers/mmc/am654_sdhci.c
> index fd667aeafdaa..d0b51c0707d4 100644
> --- a/drivers/mmc/am654_sdhci.c
> +++ b/drivers/mmc/am654_sdhci.c
> @@ -442,12 +442,18 @@ static int j721e_4bit_sdhci_set_ios_post(struct 
> sdhci_host *host)
>  {
>   struct udevice *dev = host->mmc->dev;
>   struct am654_sdhci_plat *plat = dev_get_plat(dev);
> - u32 otap_del_sel, mask, val;
> + u32 otap_del_sel, itap_del_sel, mask, val;
>  
>   otap_del_sel = plat->otap_del_sel[host->mmc->selected_mode];
> - mask = OTAPDLYENA_MASK | OTAPDLYSEL_MASK;
> - val = (1 << OTAPDLYENA_SHIFT) | (otap_del_sel << OTAPDLYSEL_SHIFT);
> + itap_del_sel = plat->itap_del_sel[host->mmc->selected_mode];
> + mask = OTAPDLYENA_MASK | OTAPDLYSEL_MASK | ITAPDLYSEL_MASK |
> + ITAPDLYENA_MASK;
> + val = (1 << OTAPDLYENA_SHIFT) | (otap_del_sel << OTAPDLYSEL_SHIFT) |
> + (1 << ITAPDLYENA_SHIFT) | (itap_del_sel << ITAPDLYSEL_SHIFT);
> + regmap_update_bits(plat->base, PHY_CTRL4, ITAPCHGWIN_MASK,
> +1 << ITAPCHGWIN_SHIFT);
>   regmap_update_bits(plat->base, PHY_CTRL4, mask, val);
> + regmap_update_bits(plat->base, PHY_CTRL4, ITAPCHGWIN_MASK, 0);
>  
>   regmap_update_bits(plat->base, PHY_CTRL5, CLKBUFSEL_MASK,
>  plat->clkbuf_sel);
> @@ -501,7 +507,7 @@ static int sdhci_am654_get_otap_delay(struct udevice *dev,
>* Remove the corresponding capability if an otap-del-sel
>* value is not found
>*/
> - for (i = MMC_HS; i <= MMC_HS_400; i++) {
> + for (i = MMC_LEGACY; i <= MMC_HS_400; i++) {

I'm not super familiar with mmc drivers in general, but it feels like
this bit does not really belong in this patch.

Is this another bugfix for removing otap-del-sel for MMC_LEGACY devices
or does U1 UHS SD cards are considered to be of MMC_LEGACY type ?

>   ret = dev_read_u32(dev, td[i].otap_binding,
>  &plat->otap_del_sel[i]);
>   if (ret) {
> -- 
> 2.40.0


Re: [PATCH V4 5/8] arm: dts: k3-am625-sk-binman: Add labels for unsigned binary

2023-08-23 Thread Mattijs Korpershoek
On mar., août 22, 2023 at 13:41, Nishanth Menon  wrote:

> Add labels for unsigned binary to permit over-ride.
>
> Signed-off-by: Nishanth Menon 

Reviewed-by: Mattijs Korpershoek 

> ---
> Cc: Simon Glass 
>
> Changes since V3: None
>
> V3: https://lore.kernel.org/all/20230815164440.2713726-2...@ti.com/
> V2: https://lore.kernel.org/u-boot/20230727234446.3651836-2...@ti.com/
> V1: https://lore.kernel.org/all/20230725185253.2123433-3...@ti.com/
>  arch/arm/dts/k3-am625-sk-binman.dtsi | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/dts/k3-am625-sk-binman.dtsi 
> b/arch/arm/dts/k3-am625-sk-binman.dtsi
> index a35d6418c25f..41277bf4bfdb 100644
> --- a/arch/arm/dts/k3-am625-sk-binman.dtsi
> +++ b/arch/arm/dts/k3-am625-sk-binman.dtsi
> @@ -389,7 +389,7 @@
>   type = "flat_dt";
>   arch = "arm";
>   compression = "none";
> - blob {
> + spl_am625_sk_dtb_unsigned: blob {
>   filename = SPL_AM625_SK_DTB;
>   };
>   };
> @@ -438,7 +438,7 @@
>   type = "flat_dt";
>   arch = "arm";
>   compression = "none";
> - blob {
> + am625_sk_dtb_unsigned: blob {
>   filename = AM625_SK_DTB;
>   };
>   hash {
> -- 
> 2.40.0


Re: [PATCH V4 7/8] board: ti: am62x: Add am62x_beagleplay_* defconfigs and env file

2023-08-23 Thread Mattijs Korpershoek
On mar., août 22, 2023 at 13:41, Nishanth Menon  wrote:

> Add defconfig fragments for am625 based beagleplay and corresponding
> customized environment file for beagleplay.
>
> Signed-off-by: Nishanth Menon 

Reviewed-by: Mattijs Korpershoek 

> ---
> Changes:
> * new env file to override boot targets, led sequence etc.
> * config files updates for GPIO, I2C etc for A53.
> * Speed up of A53 mmc support.
>
> V3: https://lore.kernel.org/all/20230815164440.2713726-4...@ti.com/
> V2: https://lore.kernel.org/u-boot/20230727234446.3651836-4...@ti.com/
> V1: https://lore.kernel.org/all/20230725185253.2123433-6...@ti.com/
>  board/ti/am62x/beagleplay.env| 23 
>  board/ti/am62x/beagleplay_a53.config | 55 
>  board/ti/am62x/beagleplay_r5.config  | 15 
>  3 files changed, 93 insertions(+)
>  create mode 100644 board/ti/am62x/beagleplay.env
>  create mode 100644 board/ti/am62x/beagleplay_a53.config
>  create mode 100644 board/ti/am62x/beagleplay_r5.config
>
> diff --git a/board/ti/am62x/beagleplay.env b/board/ti/am62x/beagleplay.env
> new file mode 100644
> index ..8f39fb214333
> --- /dev/null
> +++ b/board/ti/am62x/beagleplay.env
> @@ -0,0 +1,23 @@
> +#include 
> +#include 
> +
> +default_device_tree=ti/k3-am625-beagleplay.dtb
> +findfdt=
> + setenv name_fdt ${default_device_tree};
> + setenv fdtfile ${name_fdt}
> +name_kern=Image
> +console=ttyS2,115200n8
> +args_all=setenv optargs ${optargs} earlycon=ns16550a,mmio32,0x0280
> + ${mtdparts}
> +run_kern=booti ${loadaddr} ${rd_spec} ${fdtaddr}
> +set_led_state_fail_load= led led-0 off; led led-1 on;
> + led led-2 off; led led-3 on; led led-4 off
> +set_led_state_start_load=led led-0 on; led led-1 off;
> + led led-2 on; led led-3 off; led led-4 on
> +boot=mmc
> +mmcdev=1
> +bootpart=1:1
> +bootdir=/boot
> +boot_targets=mmc1 mmc0 usb pxe
> +bootmeths=extlinux efi
> +rd_spec=-
> diff --git a/board/ti/am62x/beagleplay_a53.config 
> b/board/ti/am62x/beagleplay_a53.config
> new file mode 100644
> index ..967f794446dd
> --- /dev/null
> +++ b/board/ti/am62x/beagleplay_a53.config
> @@ -0,0 +1,55 @@
> +# Defconfig fragment to apply on top of am62x_evm_a53_defconfig
> +
> +CONFIG_DEFAULT_DEVICE_TREE="k3-am625-beagleplay"
> +CONFIG_OF_LIST="k3-am625-beagleplay"
> +CONFIG_SPL_OF_LIST="k3-am625-beagleplay"
> +CONFIG_BOOTCOMMAND="run set_led_state_start_load;run findfdt; run envboot; 
> run distro_bootcmd;run set_led_state_fail_load"
> +CONFIG_EXT4_WRITE=y
> +CONFIG_LZO=y
> +CONFIG_AUTOBOOT_KEYED=y
> +CONFIG_AUTOBOOT_PROMPT="Press SPACE to abort autoboot in %d seconds\n"
> +CONFIG_AUTOBOOT_DELAY_STR="d"
> +CONFIG_AUTOBOOT_STOP_STR=" "
> +# Use the Beagleplay env file
> +CONFIG_ENV_SOURCE_FILE="beagleplay"
> +# Do not use emmc boot - we will use FS only
> +CONFIG_SUPPORT_EMMC_BOOT=n
> +CONFIG_MMC_IO_VOLTAGE=y
> +# CONFIG_SPL_MMC_IO_VOLTAGE is not set
> +CONFIG_MMC_UHS_SUPPORT=y
> +# CONFIG_SPL_MMC_UHS_SUPPORT is not set
> +CONFIG_MMC_HS200_SUPPORT=y
> +# CONFIG_SPL_MMC_HS200_SUPPORT is not set
> +# Enable GPIO control
> +CONFIG_DM_GPIO=y
> +CONFIG_SPL_GPIO=y
> +CONFIG_DA8XX_GPIO=y
> +CONFIG_CMD_GPIO=y
> +CONFIG_CMD_GPIO_READ=y
> +# Enable LEDs
> +CONFIG_LED=y
> +CONFIG_LED_GPIO=y
> +CONFIG_SPL_LED=y
> +CONFIG_SPL_LED_GPIO=y
> +# Enable I2C bus
> +CONFIG_SPL_I2C=y
> +CONFIG_DM_I2C=y
> +CONFIG_SYS_I2C_OMAP24XX=y
> +CONFIG_CMD_I2C=y
> +# Regulator
> +CONFIG_DM_REGULATOR=y
> +CONFIG_DM_REGULATOR_FIXED=y
> +CONFIG_DM_REGULATOR_GPIO=y
> +CONFIG_CMD_REGULATOR=y
> +CONFIG_DM_REGULATOR_TPS65219=y
> +CONFIG_DM_PMIC=y
> +CONFIG_PMIC_TPS65219=y
> +CONFIG_CMD_PMIC=y
> +# Uses Realtek phy rather than TI phy
> +CONFIG_PHY_TI_DP83867=n
> +CONFIG_PHY_REALTEK=y
> +# No SPI flash on Beagleplay
> +CONFIG_SPI=n
> +CONFIG_SPI_FLASH=n
> +CONFIG_SPL_DM_SPI_FLASH=n
> +CONFIG_SPL_SPI_FLASH_SUPPORT=n
> diff --git a/board/ti/am62x/beagleplay_r5.config 
> b/board/ti/am62x/beagleplay_r5.config
> new file mode 100644
> index ..4ee0375a2a1d
> --- /dev/null
> +++ b/board/ti/am62x/beagleplay_r5.config
> @@ -0,0 +1,15 @@
> +# Defconfig fragment to apply on top of:
> +# am62x_evm_r5_defconfig
> +#
> +CONFIG_DEFAULT_DEVICE_TREE="k3-am625-r5-beagleplay"
> +CONFIG_OF_LIST="k3-am625-r5-beagleplay"
> +CONFIG_SPL_OF_LIST="k3-am625-r5-beagleplay"
> +# Do spl board init
> +CONFIG_SPL_BOARD_INIT=y
> +# Do not use emmc boot - we will use FS only
> +CONFIG_SUPPORT_EMMC_BOOT=n
> +# No SPI flash on Beagleplay
> +CONFIG_SPI=n
> +CONFIG_SPI_FLASH=n
> +CONFIG_SPL_DM_SPI_FLASH=n
> +CONFIG_SPL_SPI_FLASH_SUPPORT=n
> -- 
> 2.40.0


Re: [PATCH V4 8/8] doc: board: ti: Add BeaglePlay documentation

2023-08-23 Thread Mattijs Korpershoek
Hi Nishanth,

On mar., août 22, 2023 at 13:41, Nishanth Menon  wrote:

> Add base documentation for BeaglePlay
>
> Signed-off-by: Nishanth Menon 

This is great! Thanks a lot for the documentation update, especially the
"Flash to eMMC" section.

Reviewed-by: Mattijs Korpershoek 

> ---
> Cc: Heinrich Schuchardt 
>
> Changes Since V3:
> * Updated documentation to give a more clear overview of MMC partitions
>   and flashing information.
> * Added OpenOCD debug documentation
> * Added LED status information and indication of various boot stages
>
> V3: https://lore.kernel.org/all/20230815164440.2713726-5...@ti.com/
> V2: https://lore.kernel.org/u-boot/20230727234446.3651836-5...@ti.com/
> V1: https://lore.kernel.org/all/20230725185253.2123433-7...@ti.com/
>
>  doc/board/ti/am62x_beagleplay.rst| 256 ++
>  doc/board/ti/img/beagleplay_emmc.svg | 697 +++
>  doc/board/ti/k3.rst  |   1 +
>  3 files changed, 954 insertions(+)
>  create mode 100644 doc/board/ti/am62x_beagleplay.rst
>  create mode 100644 doc/board/ti/img/beagleplay_emmc.svg
>
> diff --git a/doc/board/ti/am62x_beagleplay.rst 
> b/doc/board/ti/am62x_beagleplay.rst
> new file mode 100644
> index ..5adb7b4c9ace
> --- /dev/null
> +++ b/doc/board/ti/am62x_beagleplay.rst
> @@ -0,0 +1,256 @@
> +.. SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
> +.. sectionauthor:: Nishanth Menon 
> +
> +AM62x Beagleboard.org Beagleplay
> +
> +
> +Introduction:
> +-
> +
> +BeagleBoard.org BeaglePlay is an easy to use, affordable open source
> +hardware single board computer based on the Texas Instruments AM625
> +SoC that allows you to create connected devices that work even at long
> +distances using IEEE 802.15.4g LR-WPAN and IEEE 802.3cg 10Base-T1L.
> +Expansion is provided over open standards based mikroBUS, Grove and
> +QWIIC headers among other interfaces.
> +
> +Further information can be found at:
> +
> +* Product Page: https://beagleplay.org/
> +* Hardware documentation: https://git.beagleboard.org/beagleplay/beagleplay
> +
> +Boot Flow:
> +--
> +Below is the pictorial representation of boot flow:
> +
> +.. image:: img/boot_diagram_k3_current.svg
> +  :alt: Boot flow diagram
> +
> +- On this platform, 'TI Foundational Security' (TIFS) functions as the
> +  security enclave master while 'Device Manager' (DM), also known as the
> +  'TISCI server' in "TI terminology", offers all the essential services.
> +  The A53/M4F (Aux core) sends requests to TIFS/DM to accomplish these
> +  services, as illustrated in the diagram above.
> +
> +Sources:
> +
> +.. include::  k3.rst
> +:start-after: .. k3_rst_include_start_boot_sources
> +:end-before: .. k3_rst_include_end_boot_sources
> +
> +Build procedure:
> +
> +0. Setup the environment variables:
> +
> +.. include::  k3.rst
> +:start-after: .. k3_rst_include_start_common_env_vars_desc
> +:end-before: .. k3_rst_include_end_common_env_vars_desc
> +
> +.. include::  k3.rst
> +:start-after: .. k3_rst_include_start_board_env_vars_desc
> +:end-before: .. k3_rst_include_end_board_env_vars_desc
> +
> +Set the variables corresponding to this platform:
> +
> +.. include::  k3.rst
> +:start-after: .. k3_rst_include_start_common_env_vars_defn
> +:end-before: .. k3_rst_include_end_common_env_vars_defn
> +.. code-block:: bash
> +
> + $ export UBOOT_CFG_CORTEXR="am62x_evm_r5_defconfig beagleplay_r5.config"
> + $ export UBOOT_CFG_CORTEXA="am62x_evm_a53_defconfig beagleplay_a53.config"
> + $ export TFA_BOARD=lite
> + $ # we dont use any extra TFA parameters
> + $ unset TFA_EXTRA_ARGS
> + $ export OPTEE_PLATFORM=k3-am62x
> + $ export OPTEE_EXTRA_ARGS="CFG_WITH_SOFTWARE_PRNG=y"
> +
> +.. include::  am62x_sk.rst
> +:start-after: .. am62x_evm_rst_include_start_build_steps
> +:end-before: .. am62x_evm_rst_include_end_build_steps
> +
> +Target Images
> +--
> +Copy the below images to an SD card and boot:
> +
> +* tiboot3-am62x-gp-evm.bin from R5 build as tiboot3.bin
> +* tispl.bin_unsigned from Cortex-A build as tispl.bin
> +* u-boot.img_unsigned from Cortex-A build as uboot.img
> +
> +Image formats:
> +--
> +
> +- tiboot3.bin
> +
> +.. image:: img/multi_cert_tiboot3.bin.svg
> +  :alt: tiboot3.bin image format
> +
> +- tispl.bin
> +
> +.. image:: img/dm_tispl.bin.svg
> +  :alt: tispl.bin image format
> +
> +Flash to eMMC
> +-
> +
> +The eMMC layout selected is user-frie

Re: [PATCH V4 6/8] arm: dts: Add k3-am625-beagleplay

2023-08-23 Thread Mattijs Korpershoek
On mar., août 22, 2023 at 13:41, Nishanth Menon  wrote:

> From: Robert Nelson 
>
> BeagleBoard.org BeaglePlay is an easy to use, affordable open source
> hardware single board computer based on the Texas Instruments AM625
> SoC that allows you to create connected devices that work even at long
> distances using IEEE 802.15.4g LR-WPAN and IEEE 802.3cg 10Base-T1L.
> Expansion is provided over open standards based mikroBUS, Grove and
> QWIIC headers among other interfaces.
>
> This board family can be identified by the 24c32 eeprom:
>
> [aa 55 33 ee 01 37 00 10  2e 00 42 45 41 47 4c 45  |.U3..7BEAGLE|]
> [50 4c 41 59 2d 41 30 2d  00 00 30 32 30 30 37 38  |PLAY-A0-..020078|]
>
> https://beagleplay.org/
> https://git.beagleboard.org/beagleplay/beagleplay
>
> baseline of base device tree is v6.5-rc1.
>
> Reviewed-by: Tom Rini 
> Signed-off-by: Robert Nelson 
> Co-developed-by: Nishanth Menon 
> Signed-off-by: Nishanth Menon 

Reviewed-by: Mattijs Korpershoek 

> ---
> Changes since V3:
> * Added LEDs to u-boot.dtsi boot phase properties and default to be on.
> * Dropped the slowing down of emmc and sd
> * Retaining Tom's reviewed-by unless there is a concern.
>
> V3: https://lore.kernel.org/all/20230815164440.2713726-3...@ti.com/
> V2: https://lore.kernel.org/u-boot/20230727234446.3651836-3...@ti.com/
> V1: https://lore.kernel.org/all/20230725185253.2123433-5...@ti.com/
>  arch/arm/dts/Makefile |2 +
>  .../dts/k3-am625-beagleplay-ddr4-1600MTs.dtsi | 2195 +
>  arch/arm/dts/k3-am625-beagleplay-u-boot.dtsi  |  196 ++
>  arch/arm/dts/k3-am625-beagleplay.dts  |  758 ++
>  arch/arm/dts/k3-am625-r5-beagleplay.dts   |   87 +
>  board/ti/am62x/MAINTAINERS|7 +
>  6 files changed, 3245 insertions(+)
>  create mode 100644 arch/arm/dts/k3-am625-beagleplay-ddr4-1600MTs.dtsi
>  create mode 100644 arch/arm/dts/k3-am625-beagleplay-u-boot.dtsi
>  create mode 100644 arch/arm/dts/k3-am625-beagleplay.dts
>  create mode 100644 arch/arm/dts/k3-am625-r5-beagleplay.dts
>
> diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
> index 85fd5b1157b1..bd61a3527082 100644
> --- a/arch/arm/dts/Makefile
> +++ b/arch/arm/dts/Makefile
> @@ -1334,6 +1334,8 @@ dtb-$(CONFIG_SOC_K3_AM642) += k3-am642-evm.dtb \
>  
>  dtb-$(CONFIG_SOC_K3_AM625) += k3-am625-sk.dtb \
> k3-am625-r5-sk.dtb \
> +   k3-am625-beagleplay.dtb \
> +   k3-am625-r5-beagleplay.dtb \
> k3-am625-verdin-wifi-dev.dtb \
> k3-am625-verdin-r5.dtb
>  
> diff --git a/arch/arm/dts/k3-am625-beagleplay-ddr4-1600MTs.dtsi 
> b/arch/arm/dts/k3-am625-beagleplay-ddr4-1600MTs.dtsi
> new file mode 100644
> index ..3d7a41c27d7e
> --- /dev/null
> +++ b/arch/arm/dts/k3-am625-beagleplay-ddr4-1600MTs.dtsi
> @@ -0,0 +1,2195 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * https://beagleboard.org/play
> + *
> + * Copyright (C) 2022-2023 Texas Instruments Incorporated - 
> https://www.ti.com/
> + * Copyright (C) 2022-2023 Robert Nelson, BeagleBoard.org Foundation
> + *
> + * This file was generated with the
> + * AM62x SysConfig DDR Subsystem Register Configuration Tool v0.09.06
> + * Thu Feb 09 2023 11:57:18 GMT-0600 (Central Standard Time)
> + * DDR Part number: K4AAG165WA-BCWE K4A4G165WF-BCTD
> + * DDR Type: DDR4
> + * Frequency = 800MHz (1600MTs)
> + * Density: 16Gb
> + * Number of Ranks: 1
> + */
> +
> +#define DDRSS_PLL_FHS_CNT 6
> +#define DDRSS_PLL_FREQUENCY_1 4
> +#define DDRSS_PLL_FREQUENCY_2 4
> +
> +#define DDRSS_CTL_0_DATA 0x0A00
> +#define DDRSS_CTL_1_DATA 0x
> +#define DDRSS_CTL_2_DATA 0x
> +#define DDRSS_CTL_3_DATA 0x
> +#define DDRSS_CTL_4_DATA 0x
> +#define DDRSS_CTL_5_DATA 0x
> +#define DDRSS_CTL_6_DATA 0x
> +#define DDRSS_CTL_7_DATA 0x000890B8
> +#define DDRSS_CTL_8_DATA 0x
> +#define DDRSS_CTL_9_DATA 0x
> +#define DDRSS_CTL_10_DATA 0x
> +#define DDRSS_CTL_11_DATA 0x000890B8
> +#define DDRSS_CTL_12_DATA 0x
> +#define DDRSS_CTL_13_DATA 0x
> +#define DDRSS_CTL_14_DATA 0x
> +#define DDRSS_CTL_15_DATA 0x000890B8
> +#define DDRSS_CTL_16_DATA 0x
> +#define DDRSS_CTL_17_DATA 0x
> +#define DDRSS_CTL_18_DATA 0x
> +#define DDRSS_CTL_19_DATA 0x01010100
> +#define DDRSS_CTL_20_DATA 0x01000100
> +#define DDRSS_CTL_21_DATA 0x01000110
> +#define DDRSS_CTL_22_DATA 0x02010002
> +#define DDRSS_CTL_23_DATA 0x00027100
> +#define DDRSS_CTL_24_DATA 0x00061A80
> +#define DDRSS_CTL_25_DATA 

Re: [PATCH V5 00/17] board: ti: Add support for BeaglePlay

2023-08-24 Thread Mattijs Korpershoek
On mer., août 23, 2023 at 22:10, Nishanth Menon  wrote:

> Add support for BeaglePlay - rev 5
>
> Full series: 
> https://github.com/nmenon/fix-k3-dt-u-boot/commits/beagleplay-v4.2
>
> Caveats:
> * networking: pending 
> https://lore.kernel.org/all/20230822121350.51324-1-rog...@kernel.org/
> * 32kclk and usb: pending:
>   https://lore.kernel.org/u-boot/20230725185253.2123433-4...@ti.com/
>   OR 
> https://github.com/nmenon/fix-k3-dt-u-boot/commit/853b29d63c1ca642be316f1afb0fb778610dec46
>   being properly resolved (NOTE: without this patch, wlan is broken in
>   Linux as the 32kclk from SoC is incorrectly supplied to wlan as 25MHz)
> * There seems to be a bug in Linux kernel with sdhci that seems to
>   depend on u-boot initialization of sdhci for functionality.
>
> CI loop check: https://github.com/u-boot/u-boot/pull/425 (whenever that
> gets done I guess).
>
> Bootlogs:
> SD Boot: https://gist.github.com/nmenon/c74acb3a895053e05623e886df77c8fe
> eMMC, no SD boot: 
> https://gist.github.com/nmenon/16df3b8fc0e9102f29ebb7836b950a08
> eMMC with SD card: 
> https://gist.github.com/nmenon/042dbe7c08589e7bfe1919da1fedc545
>
> Complete code (with the tmp patch) can be found at:
> https://github.com/nmenon/fix-k3-dt-u-boot/tree/beagleplay-v5
>
> Baseline: 97841de68043 (origin/next) Merge branch 
> '2023-08-22-assorted-code-cleanups' into next
>
> Changes since V4:
> * Switched boot from distro_boot to bootstd - AM62 as a start will rely
>   on txt env file.
> * Cleanups around am625_init.c (new patches)
> * Review comment fixups for documentation
> * I have'nt picked up Mattijs's tested by since this is a different
>   approach (bootstd Vs distro_bootcmd)
> * Dropped the sdhci patches AND CFG_EXTRA_ENV_SETTINGS (Instead, we
>   switch entirely to bootstd and move am62x-sk to bootstd along with
>   it).
>
> V4: https://lore.kernel.org/all/20230822184135.2328409-1...@ti.com/
> V3: https://lore.kernel.org/all/20230815164440.2713726-1...@ti.com/
> V2: https://lore.kernel.org/u-boot/20230727234446.3651836-1...@ti.com/
> V1: https://lore.kernel.org/all/20230725185253.2123433-1...@ti.com/
>
> Nishanth Menon (16):
>   include: configs: ti_armv7_common: Add documentation for protected
> section
>   include: configs: am62x_evm: Drop unused SDRAM address
>   include: configs: am62x_evm: Wrap distroboot with
> CONFIG_DISTRO_DEFAULTS
>   board: ti: am62x: am62x.env: Add explicit boot_targets
>   configs: am62x_evm_a53_defconfig: Switch to bootstd
>   include: configs: am62x_evm: Drop distro_bootcmd usage
>   include: env: ti: ti_armv7_common.env: Rename to ti_common.env
>   include: env: ti: ti_common: Add a generic findfdt
>   board: ti: am62x: am62x.env: Use default findfdt
>   arm: mach-k3: am625_init: Use IS_ENABLED()
>   arm: mach-k3: am625_init: Convert rtc_erratumi2327_init to static
>   configs: am62x_evm*: Enable EMMC_BOOT configuration
>   arm: mach-k3: am625: Add support for UDA FS
>   arm: dts: k3-am625-sk-binman: Add labels for unsigned binary
>   board: ti: am62x: Add am62x_beagleplay_* defconfigs and env file
>   doc: board: ti: Add BeaglePlay documentation
>
> Robert Nelson (1):
>   arm: dts: Add k3-am625-beagleplay

I re-tested v5.

Using baseline 97841de68043 ("Merge branch '2023-08-22-assorted-code-cleanups' 
into next")
I could boot all the way to U-boot proper shell.

And the LEDs work for me as well with:

=> led led-0 toggle

So for the whole series:

Tested-by: Mattijs Korpershoek 

Note that I did not tried any boot related commands since I mostly work
on Android booting and I have not rebased my wip-branch yet.

>
>  arch/arm/dts/Makefile |2 +
>  .../dts/k3-am625-beagleplay-ddr4-1600MTs.dtsi | 2195 +
>  arch/arm/dts/k3-am625-beagleplay-u-boot.dtsi  |  195 ++
>  arch/arm/dts/k3-am625-beagleplay.dts  |  758 ++
>  arch/arm/dts/k3-am625-r5-beagleplay.dts   |   86 +
>  arch/arm/dts/k3-am625-sk-binman.dtsi  |4 +-
>  arch/arm/mach-k3/am625_init.c |   49 +-
>  board/siemens/iot2050/iot2050.env |2 +-
>  board/ti/am62ax/am62ax.env|2 +-
>  board/ti/am62x/MAINTAINERS|7 +
>  board/ti/am62x/am62x.env  |7 +-
>  board/ti/am62x/beagleplay.env |   18 +
>  board/ti/am62x/beagleplay_a53.config  |   55 +
>  board/ti/am62x/beagleplay_r5.config   |   15 +
>  board/ti/am64x/am64x.env  |2 +-
>  board/ti/am65x/am65x.env  |2 +-
>  board/ti/j721e/j721e.env  |2 +-
>  board/ti/j721s2/j721s2.env|2 +-
>  board/ti/

Re: [PATCH V5 01/17] include: configs: ti_armv7_common: Add documentation for protected section

2023-08-24 Thread Mattijs Korpershoek
On mer., août 23, 2023 at 22:10, Nishanth Menon  wrote:

> Make the section protected by CONFIG_DISTRO_DEFAULTS macro clear.
>
> Signed-off-by: Nishanth Menon 

Reviewed-by: Mattijs Korpershoek 

> ---
>
> New patch (part of bootstd transition)
>
>  include/configs/ti_armv7_common.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/configs/ti_armv7_common.h 
> b/include/configs/ti_armv7_common.h
> index dbbeff34ba82..4e30d0d2ddf8 100644
> --- a/include/configs/ti_armv7_common.h
> +++ b/include/configs/ti_armv7_common.h
> @@ -200,7 +200,7 @@
>  #define CFG_EXTRA_ENV_SETTINGS   \
>   BOOTENV
>  
> -#endif
> +#endif /* CONFIG_DISTRO_DEFAULTS */
>  
>  #endif /* CONFIG_ARM64 */
>  
> -- 
> 2.40.0


Re: [PATCH V5 02/17] include: configs: am62x_evm: Drop unused SDRAM address

2023-08-24 Thread Mattijs Korpershoek
Hi Nishanth,

On mer., août 23, 2023 at 22:10, Nishanth Menon  wrote:

> Drop unused macro. This was meant for a second region of DDR which we
> do not need for AM62x evm configurations.
>
> Signed-off-by: Nishanth Menon 
> ---
> New patch (part of bootstd transition)
>
>  include/configs/am62x_evm.h | 3 ---
>  1 file changed, 3 deletions(-)

What about include/configs/verdin-am62.h ?

It seems that that board, which is am62x based, also has the un-needed
include.

Since i'm not 100% sure, I have added Marcel (who posted the verdin am62
support) here.

>
> diff --git a/include/configs/am62x_evm.h b/include/configs/am62x_evm.h
> index 44180dc7687b..379e0c13a395 100644
> --- a/include/configs/am62x_evm.h
> +++ b/include/configs/am62x_evm.h
> @@ -12,9 +12,6 @@
>  #include 
>  #include 
>  
> -/* DDR Configuration */
> -#define CFG_SYS_SDRAM_BASE1  0x88000
> -
>  /* Now for the remaining common defines */
>  #include 
>  
> -- 
> 2.40.0


Re: [PATCH V4 8/8] doc: board: ti: Add BeaglePlay documentation

2023-08-24 Thread Mattijs Korpershoek
On mer., août 23, 2023 at 22:27, Nishanth Menon  wrote:

> On 21:01-20230823, Simon Glass wrote:
>> Hi Nishanth,
>> 
>> On Wed, 23 Aug 2023 at 18:18, Nishanth Menon  wrote:
>> >
>> > On 17:57-20230823, Simon Glass wrote:
>> > [...]
>> > > > This is how we have a common bit of rST for how to build N boards,
>> > > > without having to do a literal copy and paste N times.
>> > >
>> > > How about using this?
>> > >
>> > > https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#substitution-definitions
>> >
>> > I was not able to succeed with complex includes such as:
>> > https://github.com/u-boot/u-boot/blob/master/doc/board/ti/am62x_sk.rst?plain=1#L89
>> >
>> > am62x complete build procedure defined once and reused in other am62x
>> > platforms.. But the am62x build procedure itself is reused from common
>> > k3 build steps.
>> 
>> I followed through these instructions. I find the env vars quite
>> confusing, since I don't really know what it is doing. It feels like a
>> script:
>> 
>> do $a $b $c
>> do $f $e
>> 
>> it is pretty hard to follow. I think it would be better to write
>> everything out in full for each board, like rockchip does.
>
> Unfortunately, this is a few major steps that is repeated for
> (currently):
>   AM62x SK
>   Toradex Verdin
>   (pending: beagleplay - )
>   (once all the dust clears up, hopefully phytec)
>   SK-LP
>   
>
> I have no reasonable way to offer to keep them all in sync.
>   https://libera.irclog.whitequark.org/u-boot/2023-07-26#34662854;
> is kind of why I went down this path.S
>
>> 
>> Some other minor feedback:
>> 
>> - The 'make' lines should really have -j $(nproc) added
>
> Different styles of shells..
>
>> - The $ signs at the start of each command in the docs are a pain
>> since it stops me copying the commands into the terminal - can you
>> remove them?
>
> hehe.. "dont" let people blindly copy paste without understanding what is
> going on argument?
>
> If folks are OK, I sure can send a different patch series for that.. (or
> maybe motivate someone to do that instead of me ;))

Have we considered using the .. prompt:: extension ?

https://pypi.org/project/sphinx-prompt/

The prompt extension automatically adds a prompt (like $) in front of
each line and disallows copying it when copying from the html generated page.

>
>
>> - It doesn't build for me:
>> 
>>   BINMAN  .binman_stamp
>> Image 'ti-dm' is missing external blobs and is non-functional: blob-ext
>> 
>> /binman/ti-dm/blob-ext 
>> (ti-dm/am62xx/ipc_echo_testb_mcu1_0_release_strip.xer5f):
>>Missing blob
>> 
>> Some images are invalid
>> make[1]: *** 
>> [/scratch/sglass/cosarm/src/third_party/u-boot/files/Makefile:1115:
>> .binman_stamp] Error 103
>> make[1]: Leaving directory '/tmp/b/play'
>> make: *** [Makefile:177: sub-make] Error 2
>
>
> ^^ Neha: This is what I was complaining about.
>
> https://u-boot.readthedocs.io/en/latest/board/ti/am62x_sk.html?highlight=am62#sources
>
> source: https://git.ti.com/git/processor-firmware/ti-linux-firmware.git
> is missing, we never used to break build previously binman converted now does.
>
> I am wondering if I need to explicitly call out git clone instructions
> out..
>
> -- 
> Regards,
> Nishanth Menon
> Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3  1A34 DDB5 
> 849D 1736 249D


Re: [PATCH V5 07/17] include: env: ti: ti_armv7_common.env: Rename to ti_common.env

2023-08-24 Thread Mattijs Korpershoek
On mer., août 23, 2023 at 22:10, Nishanth Menon  wrote:

> ti_armv7_common does not make any more sense as it is used by armv7
> and armv8 TI based platforms.
>
> Reported-by: Tom Rini 
> Signed-off-by: Nishanth Menon 

Reviewed-by: Mattijs Korpershoek 

> ---
> New patch review comment from:
> https://lore.kernel.org/all/20230823144257.GG3953269@bill-the-cat/
>
> ti_common.h does'nt need any header file support if we switch to
> bootstd.
>
>  board/siemens/iot2050/iot2050.env | 2 +-
>  board/ti/am62ax/am62ax.env| 2 +-
>  board/ti/am62x/am62x.env  | 2 +-
>  board/ti/am64x/am64x.env  | 2 +-
>  board/ti/am65x/am65x.env  | 2 +-
>  board/ti/j721e/j721e.env  | 2 +-
>  board/ti/j721s2/j721s2.env| 2 +-
>  board/ti/ks2_evm/k2e_evm.env  | 2 +-
>  board/ti/ks2_evm/k2g_evm.env  | 2 +-
>  board/ti/ks2_evm/k2hk_evm.env | 2 +-
>  board/ti/ks2_evm/k2l_evm.env  | 2 +-
>  include/env/ti/{ti_armv7_common.env => ti_common.env} | 0
>  12 files changed, 11 insertions(+), 11 deletions(-)
>  rename include/env/ti/{ti_armv7_common.env => ti_common.env} (100%)
>
> diff --git a/board/siemens/iot2050/iot2050.env 
> b/board/siemens/iot2050/iot2050.env
> index caa9f80e3fca..8bbd7abe98f0 100644
> --- a/board/siemens/iot2050/iot2050.env
> +++ b/board/siemens/iot2050/iot2050.env
> @@ -6,7 +6,7 @@
>   *   Jan Kiszka 
>   */
>  
> -#include 
> +#include 
>  
>  usb_pgood_delay=900
>  
> diff --git a/board/ti/am62ax/am62ax.env b/board/ti/am62ax/am62ax.env
> index 3f7c333fa404..bfed7f360844 100644
> --- a/board/ti/am62ax/am62ax.env
> +++ b/board/ti/am62ax/am62ax.env
> @@ -1,4 +1,4 @@
> -#include 
> +#include 
>  #include 
>  
>  default_device_tree=ti/k3-am62a7-sk.dtb
> diff --git a/board/ti/am62x/am62x.env b/board/ti/am62x/am62x.env
> index 1cf56dbd8128..1ef948df83d7 100644
> --- a/board/ti/am62x/am62x.env
> +++ b/board/ti/am62x/am62x.env
> @@ -1,4 +1,4 @@
> -#include 
> +#include 
>  #include 
>  
>  default_device_tree=ti/k3-am625-sk.dtb
> diff --git a/board/ti/am64x/am64x.env b/board/ti/am64x/am64x.env
> index 1567907fcbdc..68e4b7f1 100644
> --- a/board/ti/am64x/am64x.env
> +++ b/board/ti/am64x/am64x.env
> @@ -1,4 +1,4 @@
> -#include 
> +#include 
>  #include 
>  #include 
>  
> diff --git a/board/ti/am65x/am65x.env b/board/ti/am65x/am65x.env
> index 755bff2707c8..286b9c300c05 100644
> --- a/board/ti/am65x/am65x.env
> +++ b/board/ti/am65x/am65x.env
> @@ -1,4 +1,4 @@
> -#include 
> +#include 
>  #include 
>  #include 
>  #if CONFIG_CMD_REMOTEPROC
> diff --git a/board/ti/j721e/j721e.env b/board/ti/j721e/j721e.env
> index 2f2fb0591279..8cc8232fc131 100644
> --- a/board/ti/j721e/j721e.env
> +++ b/board/ti/j721e/j721e.env
> @@ -1,4 +1,4 @@
> -#include 
> +#include 
>  #include 
>  #include 
>  #include 
> diff --git a/board/ti/j721s2/j721s2.env b/board/ti/j721s2/j721s2.env
> index 6825b1469854..64e3d9da85f0 100644
> --- a/board/ti/j721s2/j721s2.env
> +++ b/board/ti/j721s2/j721s2.env
> @@ -1,4 +1,4 @@
> -#include 
> +#include 
>  #include 
>  #include 
>  #include 
> diff --git a/board/ti/ks2_evm/k2e_evm.env b/board/ti/ks2_evm/k2e_evm.env
> index a145db53e5fa..3dbb7934c59a 100644
> --- a/board/ti/ks2_evm/k2e_evm.env
> +++ b/board/ti/ks2_evm/k2e_evm.env
> @@ -1,4 +1,4 @@
> -#include 
> +#include 
>  #include 
>  
>  findfdt=setenv fdtfile ${name_fdt}
> diff --git a/board/ti/ks2_evm/k2g_evm.env b/board/ti/ks2_evm/k2g_evm.env
> index 4f4941dd0907..2b500fc6edf6 100644
> --- a/board/ti/ks2_evm/k2g_evm.env
> +++ b/board/ti/ks2_evm/k2g_evm.env
> @@ -1,4 +1,4 @@
> -#include 
> +#include 
>  #include 
>  #include 
>  
> diff --git a/board/ti/ks2_evm/k2hk_evm.env b/board/ti/ks2_evm/k2hk_evm.env
> index 0714a51090ef..9991b76f8fcc 100644
> --- a/board/ti/ks2_evm/k2hk_evm.env
> +++ b/board/ti/ks2_evm/k2hk_evm.env
> @@ -1,4 +1,4 @@
> -#include 
> +#include 
>  #include 
>  
>  findfdt=setenv fdtfile ${name_fdt}
> diff --git a/board/ti/ks2_evm/k2l_evm.env b/board/ti/ks2_evm/k2l_evm.env
> index e8a803a4ed76..4e2debca4bde 100644
> --- a/board/ti/ks2_evm/k2l_evm.env
> +++ b/board/ti/ks2_evm/k2l_evm.env
> @@ -1,4 +1,4 @@
> -#include 
> +#include 
>  #include 
>  
>  findfdt=setenv fdtfile ${name_fdt}
> diff --git a/include/env/ti/ti_armv7_common.env b/include/env/ti/ti_common.env
> similarity index 100%
> rename from include/env/ti/ti_armv7_common.env
> rename to include/env/ti/ti_common.env
> -- 
> 2.40.0


Re: [PATCH V5 10/17] arm: mach-k3: am625_init: Use IS_ENABLED()

2023-08-24 Thread Mattijs Korpershoek
On mer., août 23, 2023 at 22:10, Nishanth Menon  wrote:

> Drop the #ifdeffery and use IS_ENABLED() inline check and let the compiler
> do it's thing.
>
> Signed-off-by: Nishanth Menon 

Reviewed-by: Mattijs Korpershoek 

> ---
> new patch (cleanup before modifying for adding UDA-FS)
>
>  arch/arm/mach-k3/am625_init.c | 35 +--
>  1 file changed, 17 insertions(+), 18 deletions(-)
>
> diff --git a/arch/arm/mach-k3/am625_init.c b/arch/arm/mach-k3/am625_init.c
> index 0e5d44269ebf..165bca6885ef 100644
> --- a/arch/arm/mach-k3/am625_init.c
> +++ b/arch/arm/mach-k3/am625_init.c
> @@ -121,10 +121,10 @@ void board_init_f(ulong dummy)
>   struct udevice *dev;
>   int ret;
>  
> -#if defined(CONFIG_CPU_V7R)
> - setup_k3_mpu_regions();
> - rtc_erratumi2327_init();
> -#endif
> + if (IS_ENABLED(CONFIG_CPU_V7R)) {
> + setup_k3_mpu_regions();
> + rtc_erratumi2327_init();
> + }
>  
>   /*
>* Cannot delay this further as there is a chance that
> @@ -156,29 +156,28 @@ void board_init_f(ulong dummy)
>  
>   preloader_console_init();
>  
> -#ifdef CONFIG_K3_EARLY_CONS
>   /*
>* Allow establishing an early console as required for example when
>* doing a UART-based boot. Note that this console may not "survive"
>* through a SYSFW PM-init step and will need a re-init in some way
>* due to changing module clock frequencies.
>*/
> - early_console_init();
> -#endif
> + if (IS_ENABLED(CONFIG_K3_EARLY_CONS))
> + early_console_init();
>  
> -#if defined(CONFIG_K3_LOAD_SYSFW)
>   /*
>* Configure and start up system controller firmware. Provide
>* the U-Boot console init function to the SYSFW post-PM configuration
>* callback hook, effectively switching on (or over) the console
>* output.
>*/
> - ret = is_rom_loaded_sysfw(&bootdata);
> - if (!ret)
> - panic("ROM has not loaded TIFS firmware\n");
> + if (IS_ENABLED(CONFIG_K3_LOAD_SYSFW)) {
> + ret = is_rom_loaded_sysfw(&bootdata);
> + if (!ret)
> + panic("ROM has not loaded TIFS firmware\n");
>  
> - k3_sysfw_loader(true, NULL, NULL);
> -#endif
> + k3_sysfw_loader(true, NULL, NULL);
> + }
>  
>   /*
>* Force probe of clk_k3 driver here to ensure basic default clock
> @@ -209,11 +208,11 @@ void board_init_f(ulong dummy)
>   enable_mcu_esm_reset();
>   }
>  
> -#if defined(CONFIG_K3_AM64_DDRSS)
> - ret = uclass_get_device(UCLASS_RAM, 0, &dev);
> - if (ret)
> - panic("DRAM init failed: %d\n", ret);
> -#endif
> + if (IS_ENABLED(CONFIG_K3_AM64_DDRSS)) {
> + ret = uclass_get_device(UCLASS_RAM, 0, &dev);
> + if (ret)
> + panic("DRAM init failed: %d\n", ret);
> + }
>   spl_enable_dcache();
>  }
>  
> -- 
> 2.40.0


Re: [PATCH V5 11/17] arm: mach-k3: am625_init: Convert rtc_erratumi2327_init to static

2023-08-24 Thread Mattijs Korpershoek
On mer., août 23, 2023 at 22:10, Nishanth Menon  wrote:

> The erratum is called locally, make it static, drop the #ifdeffery since
> it will only be called in R5 build and mark it potentially unused to
> stop compiler screaming at us.
>
> While at this, drop the redundant return for a void function.
>
> Signed-off-by: Nishanth Menon 

Reviewed-by: Mattijs Korpershoek 

> ---
> new patch (cleanup before modifying for adding UDA-FS)
>
>  arch/arm/mach-k3/am625_init.c | 6 +-
>  1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/arch/arm/mach-k3/am625_init.c b/arch/arm/mach-k3/am625_init.c
> index 165bca6885ef..499cb57267b9 100644
> --- a/arch/arm/mach-k3/am625_init.c
> +++ b/arch/arm/mach-k3/am625_init.c
> @@ -80,8 +80,6 @@ static __maybe_unused void enable_mcu_esm_reset(void)
>   writel(stat, CTRLMMR_MCU_RST_CTRL);
>  }
>  
> -#if defined(CONFIG_CPU_V7R)
> -
>  /*
>   * RTC Erratum i2327 Workaround for Silicon Revision 1
>   *
> @@ -94,7 +92,7 @@ static __maybe_unused void enable_mcu_esm_reset(void)
>   *
>   * https://www.ti.com/lit/er/sprz487c/sprz487c.pdf
>   */
> -void rtc_erratumi2327_init(void)
> +static __maybe_unused void rtc_erratumi2327_init(void)
>  {
>   u32 counter;
>  
> @@ -112,9 +110,7 @@ void rtc_erratumi2327_init(void)
>*/
>   writel(K3RTC_KICK0_UNLOCK_VALUE, REG_K3RTC_KICK0);
>   writel(K3RTC_KICK1_UNLOCK_VALUE, REG_K3RTC_KICK1);
> - return;
>  }
> -#endif
>  
>  void board_init_f(ulong dummy)
>  {
> -- 
> 2.40.0


Re: [PATCH V5 13/17] arm: mach-k3: am625: Add support for UDA FS

2023-08-24 Thread Mattijs Korpershoek
On mer., août 23, 2023 at 22:10, Nishanth Menon  wrote:

> While boot partition support with EMMC boot is useful, it is
> constrained by the size of boot hardware partition itself.
>
> In the case of K3 devices, tispl images can contain OP-TEE images that
> can substantially vary in size and the u-boot image itself can vary over
> time as we enable various features.
>
> So use the CSD information in the case of EMMC_BOOT configuration being
> enabled to pick boot partition or UDA FS mode operation to pick.
>
> If EMMC_BOOT is disabled, then depend on filesystem configuration to
> pick data from UDA.
>
> While at this, drop the extraneous whitespace.
>
> Signed-off-by: Nishanth Menon 

Reviewed-by: Mattijs Korpershoek 

> ---
> Changes since V4:
> - Did'nt pickup Mattijs' reviewed-by - no more iffdeffery - so might be
> good to relook.
>
> V4: https://lore.kernel.org/r/20230822184135.2328409-4...@ti.com
>
>  arch/arm/mach-k3/am625_init.c | 8 +++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/mach-k3/am625_init.c b/arch/arm/mach-k3/am625_init.c
> index 499cb57267b9..8fa36f7b913e 100644
> --- a/arch/arm/mach-k3/am625_init.c
> +++ b/arch/arm/mach-k3/am625_init.c
> @@ -220,9 +220,15 @@ u32 spl_mmc_boot_mode(struct mmc *mmc, const u32 
> boot_device)
>   u32 bootmode_cfg = (devstat & MAIN_DEVSTAT_PRIMARY_BOOTMODE_CFG_MASK) >>
>   MAIN_DEVSTAT_PRIMARY_BOOTMODE_CFG_SHIFT;
>  
> -
>   switch (bootmode) {
>   case BOOT_DEVICE_EMMC:
> + if (IS_ENABLED(CONFIG_SUPPORT_EMMC_BOOT)) {
> + if (spl_mmc_emmc_boot_partition(mmc))
> + return MMCSD_MODE_EMMCBOOT;
> + return MMCSD_MODE_FS;
> + }
> + if (IS_ENABLED(CONFIG_SPL_FS_FAT) || 
> IS_ENABLED(CONFIG_SPL_FS_EXT4))
> + return MMCSD_MODE_FS;
>   return MMCSD_MODE_EMMCBOOT;
>   case BOOT_DEVICE_MMC:
>   if (bootmode_cfg & MAIN_DEVSTAT_PRIMARY_MMC_FS_RAW_MASK)
> -- 
> 2.40.0


Re: [PATCH V5 16/17] board: ti: am62x: Add am62x_beagleplay_* defconfigs and env file

2023-08-24 Thread Mattijs Korpershoek
On mer., août 23, 2023 at 22:11, Nishanth Menon  wrote:

> Add defconfig fragments for am625 based beagleplay and corresponding
> customized environment file for beagleplay.
>
> Signed-off-by: Nishanth Menon 

Reviewed-by: Mattijs Korpershoek 

> ---
> Changes Since V4:
> * New bootstd baseline
> * have'nt picked up Mattijs's review as a result
>
> V4: https://lore.kernel.org/r/20230822184135.2328409-8...@ti.com
> V3: https://lore.kernel.org/all/20230815164440.2713726-4...@ti.com/
> V2: https://lore.kernel.org/u-boot/20230727234446.3651836-4...@ti.com/
> V1: https://lore.kernel.org/all/20230725185253.2123433-6...@ti.com/
>  board/ti/am62x/beagleplay.env| 18 +
>  board/ti/am62x/beagleplay_a53.config | 55 
>  board/ti/am62x/beagleplay_r5.config  | 15 
>  3 files changed, 88 insertions(+)
>  create mode 100644 board/ti/am62x/beagleplay.env
>  create mode 100644 board/ti/am62x/beagleplay_a53.config
>  create mode 100644 board/ti/am62x/beagleplay_r5.config
>
> diff --git a/board/ti/am62x/beagleplay.env b/board/ti/am62x/beagleplay.env
> new file mode 100644
> index ..73a078b93009
> --- /dev/null
> +++ b/board/ti/am62x/beagleplay.env
> @@ -0,0 +1,18 @@
> +#include 
> +#include 
> +
> +name_kern=Image
> +console=ttyS2,115200n8
> +args_all=setenv optargs ${optargs} earlycon=ns16550a,mmio32,0x0280
> +run_kern=booti ${loadaddr} ${rd_spec} ${fdtaddr}
> +set_led_state_fail_load= led led-0 off; led led-1 on;
> + led led-2 off; led led-3 on; led led-4 off
> +set_led_state_start_load=led led-0 on; led led-1 off;
> + led led-2 on; led led-3 off; led led-4 on
> +boot=mmc
> +mmcdev=1
> +bootpart=1:1
> +bootdir=/boot
> +boot_targets=mmc1 mmc0 usb pxe
> +bootmeths=extlinux efi
> +rd_spec=-
> diff --git a/board/ti/am62x/beagleplay_a53.config 
> b/board/ti/am62x/beagleplay_a53.config
> new file mode 100644
> index ..f0380416cc5e
> --- /dev/null
> +++ b/board/ti/am62x/beagleplay_a53.config
> @@ -0,0 +1,55 @@
> +# Defconfig fragment to apply on top of am62x_evm_a53_defconfig
> +
> +CONFIG_DEFAULT_DEVICE_TREE="k3-am625-beagleplay"
> +CONFIG_OF_LIST="k3-am625-beagleplay"
> +CONFIG_SPL_OF_LIST="k3-am625-beagleplay"
> +CONFIG_BOOTCOMMAND="run set_led_state_start_load;run findfdt; run envboot; 
> bootflow scan -lb;run set_led_state_fail_load"
> +CONFIG_EXT4_WRITE=y
> +CONFIG_LZO=y
> +CONFIG_AUTOBOOT_KEYED=y
> +CONFIG_AUTOBOOT_PROMPT="Press SPACE to abort autoboot in %d seconds\n"
> +CONFIG_AUTOBOOT_DELAY_STR="d"
> +CONFIG_AUTOBOOT_STOP_STR=" "
> +# Use the Beagleplay env file
> +CONFIG_ENV_SOURCE_FILE="beagleplay"
> +# Do not use emmc boot - we will use FS only
> +CONFIG_SUPPORT_EMMC_BOOT=n
> +CONFIG_MMC_IO_VOLTAGE=y
> +# CONFIG_SPL_MMC_IO_VOLTAGE is not set
> +CONFIG_MMC_UHS_SUPPORT=y
> +# CONFIG_SPL_MMC_UHS_SUPPORT is not set
> +CONFIG_MMC_HS200_SUPPORT=y
> +# CONFIG_SPL_MMC_HS200_SUPPORT is not set
> +# Enable GPIO control
> +CONFIG_DM_GPIO=y
> +CONFIG_SPL_GPIO=y
> +CONFIG_DA8XX_GPIO=y
> +CONFIG_CMD_GPIO=y
> +CONFIG_CMD_GPIO_READ=y
> +# Enable LEDs
> +CONFIG_LED=y
> +CONFIG_LED_GPIO=y
> +CONFIG_SPL_LED=y
> +CONFIG_SPL_LED_GPIO=y
> +# Enable I2C bus
> +CONFIG_SPL_I2C=y
> +CONFIG_DM_I2C=y
> +CONFIG_SYS_I2C_OMAP24XX=y
> +CONFIG_CMD_I2C=y
> +# Regulator
> +CONFIG_DM_REGULATOR=y
> +CONFIG_DM_REGULATOR_FIXED=y
> +CONFIG_DM_REGULATOR_GPIO=y
> +CONFIG_CMD_REGULATOR=y
> +CONFIG_DM_REGULATOR_TPS65219=y
> +CONFIG_DM_PMIC=y
> +CONFIG_PMIC_TPS65219=y
> +CONFIG_CMD_PMIC=y
> +# Uses Realtek phy rather than TI phy
> +CONFIG_PHY_TI_DP83867=n
> +CONFIG_PHY_REALTEK=y
> +# No SPI flash on Beagleplay
> +CONFIG_SPI=n
> +CONFIG_SPI_FLASH=n
> +CONFIG_SPL_DM_SPI_FLASH=n
> +CONFIG_SPL_SPI_FLASH_SUPPORT=n
> diff --git a/board/ti/am62x/beagleplay_r5.config 
> b/board/ti/am62x/beagleplay_r5.config
> new file mode 100644
> index ..4ee0375a2a1d
> --- /dev/null
> +++ b/board/ti/am62x/beagleplay_r5.config
> @@ -0,0 +1,15 @@
> +# Defconfig fragment to apply on top of:
> +# am62x_evm_r5_defconfig
> +#
> +CONFIG_DEFAULT_DEVICE_TREE="k3-am625-r5-beagleplay"
> +CONFIG_OF_LIST="k3-am625-r5-beagleplay"
> +CONFIG_SPL_OF_LIST="k3-am625-r5-beagleplay"
> +# Do spl board init
> +CONFIG_SPL_BOARD_INIT=y
> +# Do not use emmc boot - we will use FS only
> +CONFIG_SUPPORT_EMMC_BOOT=n
> +# No SPI flash on Beagleplay
> +CONFIG_SPI=n
> +CONFIG_SPI_FLASH=n
> +CONFIG_SPL_DM_SPI_FLASH=n
> +CONFIG_SPL_SPI_FLASH_SUPPORT=n
> -- 
> 2.40.0


Re: [RFC PATCH 1/2] doc: sphinx: Add sphinx-prompt

2023-08-28 Thread Mattijs Korpershoek
On jeu., août 24, 2023 at 10:40, Nishanth Menon  wrote:

> Sphinx-prompt[1] helps bring-in '.. prompt::' option that allows a
> better rendered documentation, yet be able to copy paste without
> picking up the prompt from rendered documentation.
>
> [1] https://lore.kernel.org/all/87fs48rgto@baylibre.com/
> Suggested-by: Mattijs Korpershoek 
> Signed-off-by: Nishanth Menon 

Reviewed-by: Mattijs Korpershoek 

> ---
> Version picked is the best that works with Sphinx 3.4.3
>
>  doc/conf.py | 2 +-
>  doc/sphinx/requirements.txt | 1 +
>  2 files changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/doc/conf.py b/doc/conf.py
> index 00f241366477..5e2ff1c8f5e2 100644
> --- a/doc/conf.py
> +++ b/doc/conf.py
> @@ -39,7 +39,7 @@ needs_sphinx = '2.4.4'
>  extensions = ['kerneldoc', 'rstFlatTable', 'kernel_include',
>'kfigure', 'sphinx.ext.ifconfig', # 'automarkup',
>'maintainers_include', 'sphinx.ext.autosectionlabel',
> -  'kernel_abi', 'kernel_feat']
> +  'kernel_abi', 'kernel_feat', 'sphinx-prompt']
>  
>  #
>  # cdomain is badly broken in Sphinx 3+.  Leaving it out generates *most*
> diff --git a/doc/sphinx/requirements.txt b/doc/sphinx/requirements.txt
> index 4f411f78d030..6ccbe527ee79 100644
> --- a/doc/sphinx/requirements.txt
> +++ b/doc/sphinx/requirements.txt
> @@ -15,6 +15,7 @@ requests==2.31.0
>  six==1.16.0
>  snowballstemmer==2.2.0
>  Sphinx==3.4.3
> +sphinx-prompt==1.5.0
>  sphinx-rtd-theme==1.0.0
>  sphinxcontrib-applehelp==1.0.2
>  sphinxcontrib-devhelp==1.0.2
> -- 
> 2.40.0


Re: [RFC PATCH 2/2] doc: board: ti: k3: Convert to sphinx-prompt

2023-08-28 Thread Mattijs Korpershoek
On jeu., août 24, 2023 at 10:40, Nishanth Menon  wrote:

> Sphinx-prompt provides a handy scheme to provide documentation that
> renders nicely and yet provides a scheme to copy paste for users without
> having to hand-edit the copied text as is the result of code-block
>
> [1] https://lore.kernel.org/all/87fs48rgto@baylibre.com/
> Reported-by: Simon Glass 
> Suggested-by: Mattijs Korpershoek 
> Signed-off-by: Nishanth Menon 

Reviewed-by: Mattijs Korpershoek 

Small nitpick below, which is probably a matter of preference

> ---
>  doc/board/ti/k3.rst | 112 ++--
>  1 file changed, 57 insertions(+), 55 deletions(-)
>
> diff --git a/doc/board/ti/k3.rst b/doc/board/ti/k3.rst
> index 1175b776ad48..ec447358ac39 100644
> --- a/doc/board/ti/k3.rst
> +++ b/doc/board/ti/k3.rst
> @@ -194,13 +194,13 @@ All of that to say you will need both a 32bit and 64bit 
> cross compiler
>  .. k3_rst_include_end_common_env_vars_desc
>  
>  .. k3_rst_include_start_common_env_vars_defn
> -.. code-block:: bash
> +.. prompt:: bash
>  
> - $ export CC32=arm-linux-gnueabihf-
> - $ export CC64=aarch64-linux-gnu-
> - $ export LNX_FW_PATH=path/to/ti-linux-firmware
> - $ export TFA_PATH=path/to/trusted-firmware-a
> - $ export OPTEE_PATH=path/to/optee_os
> + export CC32=arm-linux-gnueabihf-
> + export CC64=aarch64-linux-gnu-
> + export LNX_FW_PATH=path/to/ti-linux-firmware
> + export TFA_PATH=path/to/trusted-firmware-a
> + export OPTEE_PATH=path/to/optee_os
>  .. k3_rst_include_end_common_env_vars_defn
>  
>  We will also need some common environment variables set up for the various
> @@ -244,11 +244,11 @@ Building tiboot3.bin
> uses the split binary flow)
>  
>  .. k3_rst_include_start_build_steps_spl_r5
> -.. code-block:: bash
> +.. prompt:: bash
>  
> - $ # inside u-boot source
> - $ make $UBOOT_CFG_CORTEXR
> - $ make CROSS_COMPILE=$CC32 BINMAN_INDIRS=$LNX_FW_PATH
> + # inside u-boot source
> + make $UBOOT_CFG_CORTEXR
> + make CROSS_COMPILE=$CC32 BINMAN_INDIRS=$LNX_FW_PATH
>  .. k3_rst_include_end_build_steps_spl_r5
>  
>  At this point you should have all the needed binaries to boot the wakeup
> @@ -280,11 +280,11 @@ firmware if your device using a split firmware.
> application cores on the main domain.
>  
>  .. k3_rst_include_start_build_steps_tfa
> -.. code-block:: bash
> +.. prompt:: bash
>  
> - $ # inside trusted-firmware-a source
> - $ make CROSS_COMPILE=$CC64 ARCH=aarch64 PLAT=k3 SPD=opteed $TFA_EXTRA_ARGS \
> -TARGET_BOARD=$TFA_BOARD
> + # inside trusted-firmware-a source
> + make CROSS_COMPILE=$CC64 ARCH=aarch64 PLAT=k3 SPD=opteed $TFA_EXTRA_ARGS \
> +  TARGET_BOARD=$TFA_BOARD
>  .. k3_rst_include_end_build_steps_tfa
>  
>  Typically all `j7*` devices will use `TARGET_BOARD=generic` or `TARGET_BOARD
> @@ -296,11 +296,11 @@ use the `lite` option.
> using the TrustZone technology built into the core.
>  
>  .. k3_rst_include_start_build_steps_optee
> -.. code-block:: bash
> +.. prompt:: bash
>  
> - $ # inside optee_os source
> - $ make CROSS_COMPILE=$CC32 CROSS_COMPILE64=$CC64 CFG_ARM64_core=y 
> $OPTEE_EXTRA_ARGS \
> - PLATFORM=$OPTEE_PLATFORM
> + # inside optee_os source
> + make CROSS_COMPILE=$CC32 CROSS_COMPILE64=$CC64 CFG_ARM64_core=y 
> $OPTEE_EXTRA_ARGS \
> +   PLATFORM=$OPTEE_PLATFORM
>  .. k3_rst_include_end_build_steps_optee
>  
>  4. Finally, after TF-A has initialized the main domain and OP-TEE has
> @@ -308,11 +308,11 @@ use the `lite` option.
> 64bit core in the main domain.
>  
>  .. k3_rst_include_start_build_steps_uboot
> -.. code-block:: bash
> +.. prompt:: bash
>  
> - $ # inside u-boot source
> - $ make $UBOOT_CFG_CORTEXA
> - $ make CROSS_COMPILE=$CC64 BINMAN_INDIRS=$LNX_FW_PATH \
> + # inside u-boot source
> + make $UBOOT_CFG_CORTEXA
> + make CROSS_COMPILE=$CC64 BINMAN_INDIRS=$LNX_FW_PATH \
>  BL31=$TFA_PATH/build/k3/$TFA_BOARD/release/bl31.bin \
>  TEE=$OPTEE_PATH/out/arm-plat-k3/core/tee-raw.bin
>  .. k3_rst_include_end_build_steps_uboot
> @@ -407,14 +407,14 @@ and the same can be extended to other platforms
>be passing to mkimage for signing the fitImage and embedding the key in
>the u-boot dtb.
>  
> -  .. code-block:: bash
> +  .. prompt:: bash
>  
>  mkimage -r -f fitImage.its -k $UBOOT_PATH/board/ti/keys -K
>  $UBOOT_PATH/build/a72/dts/dt.dtb
>  
>For signing a secondary platform, pass the -K parameter to that DTB
>  
> -  .. code-block:: bash
> +  .. prompt:: bash
>  
>  mkimage -f fitImage.its -k $UBOOT_PATH/board/ti/keys -K
>  $UBOOT_PATH/build/a72/arch/arm/dts/k3-j721e-sk.dtb
> @@ -473,10 +473,11 @@ then the 

Re: [PATCH V6 00/20] board: ti: Add support for BeaglePlay

2023-08-28 Thread Mattijs Korpershoek
gned binary
>   board: ti: am62x: Add am62x_beagleplay_* defconfigs and env file
>   doc: board: ti: Add BeaglePlay documentation
>
> Robert Nelson (1):
>   arm: dts: Add k3-am625-beagleplay

I re-tested v6.

Using baseline 11cf91f755c7 ("Merge branch 
'2023-08-26-bootstd-chromeos-impreovements-and-move-to-gcc-13.2' into next")
I could boot all the way to U-boot proper shell.

And the LEDs work for me as well with:

=> led led-0 toggle

So for the whole series:

Tested-by: Mattijs Korpershoek 

Note that I did not tried any boot related commands since I mostly work
on Android booting and I have not rebased my wip-branch yet.

>
>  arch/arm/dts/Makefile |2 +
>  .../dts/k3-am625-beagleplay-ddr4-1600MTs.dtsi | 2195 +
>  arch/arm/dts/k3-am625-beagleplay-u-boot.dtsi  |  195 ++
>  arch/arm/dts/k3-am625-beagleplay.dts  |  758 ++
>  arch/arm/dts/k3-am625-r5-beagleplay.dts   |   86 +
>  arch/arm/dts/k3-am625-sk-binman.dtsi  |4 +-
>  arch/arm/mach-k3/am625_init.c |   49 +-
>  board/siemens/iot2050/iot2050.env |2 +-
>  board/ti/am62ax/am62ax.env|2 +-
>  board/ti/am62x/MAINTAINERS|7 +
>  board/ti/am62x/am62x.env  |8 +-
>  board/ti/am62x/beagleplay.env |   19 +
>  board/ti/am62x/beagleplay_a53.config  |   55 +
>  board/ti/am62x/beagleplay_r5.config   |   15 +
>  board/ti/am64x/am64x.env  |2 +-
>  board/ti/am65x/am65x.env  |2 +-
>  board/ti/j721e/j721e.env  |2 +-
>  board/ti/j721s2/j721s2.env|2 +-
>  board/ti/ks2_evm/k2e_evm.env  |2 +-
>  board/ti/ks2_evm/k2g_evm.env  |2 +-
>  board/ti/ks2_evm/k2hk_evm.env |2 +-
>  board/ti/ks2_evm/k2l_evm.env  |2 +-
>  configs/am62x_evm_a53_defconfig   |7 +-
>  configs/am62x_evm_r5_defconfig|1 +
>  doc/board/ti/am62x_beagleplay.rst |  322 +++
>  doc/board/ti/img/beagleplay_emmc.svg  |  697 ++
>  doc/board/ti/k3.rst   |1 +
>  include/configs/am62x_evm.h   |6 -
>  include/configs/ti_armv7_common.h |2 +-
>  include/env/ti/default_findfdt.env|   12 +
>  include/env/ti/mmc.env|   12 +-
>  .../ti/{ti_armv7_common.env => ti_common.env} |0
>  32 files changed, 4419 insertions(+), 54 deletions(-)
>  create mode 100644 arch/arm/dts/k3-am625-beagleplay-ddr4-1600MTs.dtsi
>  create mode 100644 arch/arm/dts/k3-am625-beagleplay-u-boot.dtsi
>  create mode 100644 arch/arm/dts/k3-am625-beagleplay.dts
>  create mode 100644 arch/arm/dts/k3-am625-r5-beagleplay.dts
>  create mode 100644 board/ti/am62x/beagleplay.env
>  create mode 100644 board/ti/am62x/beagleplay_a53.config
>  create mode 100644 board/ti/am62x/beagleplay_r5.config
>  create mode 100644 doc/board/ti/am62x_beagleplay.rst
>  create mode 100644 doc/board/ti/img/beagleplay_emmc.svg
>  create mode 100644 include/env/ti/default_findfdt.env
>  rename include/env/ti/{ti_armv7_common.env => ti_common.env} (100%)
>
> [1] https://lore.kernel.org/all/c93b19ed-43fe-44a2-9726-371fb9d2f...@web.de/
> -- 
> 2.40.0


Re: [PATCH V6 01/20] include: env: ti: mmc: envboot/mmcboot: Check result of mmc dev before proceeding

2023-08-28 Thread Mattijs Korpershoek
On ven., août 25, 2023 at 13:02, Nishanth Menon  wrote:

> If mmc dev reports that the device is not present, there is no point in
> proceeding further to attempt to load the files.
>
> Signed-off-by: Nishanth Menon 

Reviewed-by: Mattijs Korpershoek 

> ---
> new patch -  noticed a series of 'MMC: no card present' in boot log
> and was wondering why, now I know - shaves off 2 seconds or so into boot
> process.
>
>  include/env/ti/mmc.env | 8 +---
>  1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/include/env/ti/mmc.env b/include/env/ti/mmc.env
> index 6fb47fb26673..b8eb51ca1744 100644
> --- a/include/env/ti/mmc.env
> +++ b/include/env/ti/mmc.env
> @@ -15,7 +15,7 @@ loadbootenv=fatload mmc ${mmcdev} ${loadaddr} ${bootenvfile}
>  loadimage=load ${devtype} ${bootpart} ${loadaddr} ${bootdir}/${bootfile}
>  loadfdt=load ${devtype} ${bootpart} ${fdtaddr} ${bootdir}/dtb/${fdtfile}
>  get_fdt_mmc=load mmc ${bootpart} ${fdtaddr} ${bootdir}/dtb/${name_fdt}
> -envboot=mmc dev ${mmcdev};
> +envboot=if mmc dev ${mmcdev}; then
>   if mmc rescan; then
>   echo SD/MMC found on device ${mmcdev};
>   if run loadbootscript; then
> @@ -31,6 +31,7 @@ envboot=mmc dev ${mmcdev};
>   fi;
>   fi;
>   fi;
> +  fi;
>  mmcloados=
>   if test ${boot_fdt} = yes || test ${boot_fdt} = try; then
>   if run get_fdt_mmc; then
> @@ -45,7 +46,7 @@ mmcloados=
>   else
>   bootz;
>   fi;
> -mmcboot=mmc dev ${mmcdev};
> +mmcboot=if mmc dev ${mmcdev}; then
>   devnum=${mmcdev};
>   devtype=mmc;
>   if mmc rescan; then
> @@ -58,7 +59,8 @@ mmcboot=mmc dev ${mmcdev};
>   run mmcloados;
>   fi;
>   fi;
> -fi;
> + fi;
> +  fi;
>  
>  init_mmc=run args_all args_mmc
>  get_overlay_mmc=
> -- 
> 2.40.0


Re: [PATCH V6 02/20] include: env: ti: mmc: envboot: Only attempt boot.scr if BOOTSTD is not enabled

2023-08-28 Thread Mattijs Korpershoek
On ven., août 25, 2023 at 13:02, Nishanth Menon  wrote:

> 'script' bootmethod that should be used with CONFIG_BOOTSTD.
>
> Signed-off-by: Nishanth Menon 

Reviewed-by: Mattijs Korpershoek 

> ---
>
> Since Simon educated me to realize that the published documentation can
> be stale and bootmeths=script does indeed work for some time despite
> what the docs say..
>
>  include/env/ti/mmc.env | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/include/env/ti/mmc.env b/include/env/ti/mmc.env
> index b8eb51ca1744..0256a2d2aaca 100644
> --- a/include/env/ti/mmc.env
> +++ b/include/env/ti/mmc.env
> @@ -5,7 +5,9 @@ args_mmc=run finduuid;setenv bootargs console=${console}
>   ${optargs}
>   root=PARTUUID=${uuid} rw
>   rootfstype=${mmcrootfstype}
> +#ifndef CONFIG_BOOTSTD
>  loadbootscript=load mmc ${mmcdev} ${loadaddr} boot.scr
> +#endif
>  bootscript=echo Running bootscript from mmc${mmcdev} ...;
>   source ${loadaddr}
>  bootenvfile=uEnv.txt
> @@ -18,7 +20,7 @@ get_fdt_mmc=load mmc ${bootpart} ${fdtaddr} 
> ${bootdir}/dtb/${name_fdt}
>  envboot=if mmc dev ${mmcdev}; then
>   if mmc rescan; then
>   echo SD/MMC found on device ${mmcdev};
> - if run loadbootscript; then
> + if test -n "${loadbootscript}" && run loadbootscript; then
>   run bootscript;
>   else
>   if run loadbootenv; then
> -- 
> 2.40.0


Re: [PATCH V6 04/20] include: configs: am62x_evm: Drop unused SDRAM address

2023-08-28 Thread Mattijs Korpershoek
On ven., août 25, 2023 at 13:02, Nishanth Menon  wrote:

> Drop unused macro. This was meant for a second region of DDR which we
> do not need for AM62x evm configurations.
>
> Tested-by: Mattijs Korpershoek 
> Signed-off-by: Nishanth Menon 

Reviewed-by: Mattijs Korpershoek 

> ---
> No change other than picking up reviews, tested tags along the way.
>
> V5: https://lore.kernel.org/r/20230824031101.3460411-3...@ti.com
>  include/configs/am62x_evm.h | 3 ---
>  1 file changed, 3 deletions(-)
>
> diff --git a/include/configs/am62x_evm.h b/include/configs/am62x_evm.h
> index 44180dc7687b..379e0c13a395 100644
> --- a/include/configs/am62x_evm.h
> +++ b/include/configs/am62x_evm.h
> @@ -12,9 +12,6 @@
>  #include 
>  #include 
>  
> -/* DDR Configuration */
> -#define CFG_SYS_SDRAM_BASE1  0x88000
> -
>  /* Now for the remaining common defines */
>  #include 
>  
> -- 
> 2.40.0


Re: [PATCH V6 05/20] include: configs: am62x_evm: Wrap distroboot with CONFIG_DISTRO_DEFAULTS

2023-08-28 Thread Mattijs Korpershoek
On ven., août 25, 2023 at 13:02, Nishanth Menon  wrote:

> Wrap the distro_boot options with CONFIG_DISTRO_DEFAULTS.
>
> This is an intermediate step for us to switch over to
> CONFIG_BOOTSTD_DEFAULTS and drop this section in follow on patches.
>
> Reviewed-by: Tom Rini 
> Tested-by: Mattijs Korpershoek 
> Signed-off-by: Nishanth Menon 

Reviewed-by: Mattijs Korpershoek 

> ---
> No change other than picking up reviews, tested tags along the way.
>
> V5: https://lore.kernel.org/r/20230824031101.3460411-4...@ti.com
>
>  include/configs/am62x_evm.h | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/include/configs/am62x_evm.h b/include/configs/am62x_evm.h
> index 379e0c13a395..81d7658cdb0d 100644
> --- a/include/configs/am62x_evm.h
> +++ b/include/configs/am62x_evm.h
> @@ -9,8 +9,10 @@
>  #ifndef __CONFIG_AM625_EVM_H
>  #define __CONFIG_AM625_EVM_H
>  
> +#ifdef CONFIG_DISTRO_DEFAULTS
>  #include 
>  #include 
> +#endif
>  
>  /* Now for the remaining common defines */
>  #include 
> -- 
> 2.40.0


Re: [PATCH V6 06/20] board: ti: am62x: am62x.env: Add explicit boot_targets

2023-08-28 Thread Mattijs Korpershoek
On ven., août 25, 2023 at 13:02, Nishanth Menon  wrote:

> Add explicit boot_targets to indicate the specific boot sequence to
> follow.
>
> NOTE: The non-standard ti_mmc emulates what is done for distro_boot.
> With bootstd, this will eventually need to be replaced by equivalent
> class.
>
> Tested-by: Mattijs Korpershoek 
> Signed-off-by: Nishanth Menon 

Reviewed-by: Mattijs Korpershoek 

> ---
> No change other than picking up reviews, tested tags along the way.
>
> V5: https://lore.kernel.org/r/20230824031101.3460411-5...@ti.com
>  board/ti/am62x/am62x.env | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/board/ti/am62x/am62x.env b/board/ti/am62x/am62x.env
> index f2dc87893a92..1cf56dbd8128 100644
> --- a/board/ti/am62x/am62x.env
> +++ b/board/ti/am62x/am62x.env
> @@ -11,6 +11,7 @@ args_all=setenv optargs ${optargs} 
> earlycon=ns16550a,mmio32,0x0280
>   ${mtdparts}
>  run_kern=booti ${loadaddr} ${rd_spec} ${fdtaddr}
>  
> +boot_targets=ti_mmc mmc0 mmc1 usb pxe dhcp
>  boot=mmc
>  mmcdev=1
>  bootpart=1:2
> -- 
> 2.40.0


Re: [PATCH V6 07/20] configs: am62x_evm_a53_defconfig: Switch to bootstd

2023-08-28 Thread Mattijs Korpershoek
On ven., août 25, 2023 at 13:02, Nishanth Menon  wrote:

> Switch to using bootstd. Note with this change, we will stop using
> distro_bootcmd and instead depend entirely on bootflow method of
> starting the system up.
>
> Suggested-by: Tom Rini 
> Suggested-by: Simon Glass 
> Reviewed-by: Tom Rini 
> Tested-by: Mattijs Korpershoek 
> Signed-off-by: Nishanth Menon 

Reviewed-by: Mattijs Korpershoek 

> ---
> No change other than picking up reviews, tested tags along the way.
> V5: https://lore.kernel.org/r/20230824031101.3460411-6...@ti.com
>  configs/am62x_evm_a53_defconfig | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/configs/am62x_evm_a53_defconfig b/configs/am62x_evm_a53_defconfig
> index d55caabe22c9..1807df8bbee9 100644
> --- a/configs/am62x_evm_a53_defconfig
> +++ b/configs/am62x_evm_a53_defconfig
> @@ -28,8 +28,9 @@ CONFIG_SPL_SPI=y
>  # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
>  CONFIG_SPL_LOAD_FIT=y
>  CONFIG_SPL_LOAD_FIT_ADDRESS=0x8100
> -CONFIG_DISTRO_DEFAULTS=y
> -CONFIG_BOOTCOMMAND="run envboot; run distro_bootcmd;"
> +CONFIG_BOOTSTD_FULL=y
> +CONFIG_BOOTSTD_DEFAULTS=y
> +CONFIG_BOOTCOMMAND="run envboot; bootflow scan -lb"
>  CONFIG_SPL_MAX_SIZE=0x58000
>  CONFIG_SPL_HAS_BSS_LINKER_SECTION=y
>  CONFIG_SPL_BSS_START_ADDR=0x80c8
> -- 
> 2.40.0


Re: [PATCH V6 08/20] include: configs: am62x_evm: Drop distro_bootcmd usage

2023-08-28 Thread Mattijs Korpershoek
On ven., août 25, 2023 at 13:02, Nishanth Menon  wrote:

> Now that BOOTSTD is used by default, drop un-used header file
> inclusion.
>
> Reviewed-by: Tom Rini 
> Tested-by: Mattijs Korpershoek 
> Signed-off-by: Nishanth Menon 

Reviewed-by: Mattijs Korpershoek 

> ---
> No change other than picking up reviews, tested tags along the way.
> V5: https://lore.kernel.org/r/20230824031101.3460411-7...@ti.com
>  include/configs/am62x_evm.h | 5 -
>  1 file changed, 5 deletions(-)
>
> diff --git a/include/configs/am62x_evm.h b/include/configs/am62x_evm.h
> index 81d7658cdb0d..c8fe59b75313 100644
> --- a/include/configs/am62x_evm.h
> +++ b/include/configs/am62x_evm.h
> @@ -9,11 +9,6 @@
>  #ifndef __CONFIG_AM625_EVM_H
>  #define __CONFIG_AM625_EVM_H
>  
> -#ifdef CONFIG_DISTRO_DEFAULTS
> -#include 
> -#include 
> -#endif
> -
>  /* Now for the remaining common defines */
>  #include 
>  
> -- 
> 2.40.0


Re: [PATCH V6 10/20] include: env: ti: Add a generic default_findfdt.env

2023-08-28 Thread Mattijs Korpershoek
On ven., août 25, 2023 at 13:02, Nishanth Menon  wrote:

> ti_mmc bootmethod uses a findfdt routine that is expected to be
> implemented by all platforms.
>
> Define a default findfdt based on configured DEFAULT_DEVICE_TREE option
> for u-boot. This saves duplication across multiple boards and handles
> architecture folder location changes centrally.
>
> TI ARMV7 platforms will need to override default_device_tree_subarch
> in the env file to point to the appropriate platform. Note: default
> "omap" is used to cater to "most common" default.
>
> Tested-by: Mattijs Korpershoek 
> Signed-off-by: Nishanth Menon 

Reviewed-by: Mattijs Korpershoek 

> ---
> Changes:
> * Made it as default_findfdt as discussed in review.
>
> V5: https://lore.kernel.org/r/20230824031101.3460411-9...@ti.com
>  include/env/ti/default_findfdt.env | 12 
>  1 file changed, 12 insertions(+)
>  create mode 100644 include/env/ti/default_findfdt.env
>
> diff --git a/include/env/ti/default_findfdt.env 
> b/include/env/ti/default_findfdt.env
> new file mode 100644
> index ..a2b51dd923bb
> --- /dev/null
> +++ b/include/env/ti/default_findfdt.env
> @@ -0,0 +1,12 @@
> +default_device_tree=CONFIG_DEFAULT_DEVICE_TREE
> +default_device_tree_arch=ti
> +#ifdef CONFIG_ARM64
> +findfdt=
> + setenv name_fdt ${default_device_tree_arch}/${default_device_tree}.dtb;
> + setenv fdtfile ${name_fdt}
> +#else
> +default_device_tree_subarch=omap
> +findfdt=
> + setenv name_fdt 
> ${default_device_tree_arch}/${default_device_tree_subarch}/${default_device_tree}.dtb;
> + setenv fdtfile ${name_fdt}
> +#endif
> -- 
> 2.40.0


Re: [PATCH V6 11/20] board: ti: am62x: am62x.env: Use default findfdt

2023-08-28 Thread Mattijs Korpershoek
On ven., août 25, 2023 at 13:02, Nishanth Menon  wrote:

> Use the default findfdt using CONFIG_DEFAULT_DEVICE_TREE
>
> Reviewed-by: Tom Rini 
> Tested-by: Mattijs Korpershoek 
> Signed-off-by: Nishanth Menon 

Reviewed-by: Mattijs Korpershoek 

> ---
> No change that picking up Review, tested by and using new include file.
>
> V5: https://lore.kernel.org/r/20230824031101.3460411-10...@ti.com
>  board/ti/am62x/am62x.env | 5 +
>  1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/board/ti/am62x/am62x.env b/board/ti/am62x/am62x.env
> index 1ef948df83d7..3b79ae1b3f0d 100644
> --- a/board/ti/am62x/am62x.env
> +++ b/board/ti/am62x/am62x.env
> @@ -1,10 +1,7 @@
>  #include 
> +#include 
>  #include 
>  
> -default_device_tree=ti/k3-am625-sk.dtb
> -findfdt=
> - setenv name_fdt ${default_device_tree};
> - setenv fdtfile ${name_fdt}
>  name_kern=Image
>  console=ttyS2,115200n8
>  args_all=setenv optargs ${optargs} earlycon=ns16550a,mmio32,0x0280
> -- 
> 2.40.0


Re: [PATCH V6 16/20] configs: am62x_evm_a53_defconfig: Disable semi-functional PSCI reset support

2023-08-28 Thread Mattijs Korpershoek
On ven., août 25, 2023 at 13:03, Nishanth Menon  wrote:

> From: Jan Kiszka 
>
> At this point, system shutdown is not supported by the DM firmware
> that TF-A calls. As we can't de-select only this feature[1], declare
> complete PSCI reset support as non-functional so that we don't signal
> incomplete support to the OS via EFI runtime services. This makes
> power-off under Linux work again when booting via EFI.
>
> [1] 
> https://uefi.org/specs/UEFI/2.9_A/08_Services_Runtime_Services.html?highlight=efiresetshutdown#resetsystem
> Signed-off-by: Jan Kiszka 
> Signed-off-by: Nishanth Menon 

Reviewed-by: Mattijs Korpershoek 

> ---
> New patch picked from Jan
> https://lore.kernel.org/all/c93b19ed-43fe-44a2-9726-371fb9d2f...@web.de/
> Changes:
> - modify am62x_evm as common change.
> - slight update to $subject and commit message
>
>  configs/am62x_evm_a53_defconfig | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/configs/am62x_evm_a53_defconfig b/configs/am62x_evm_a53_defconfig
> index 112125673699..a2729c1d0e36 100644
> --- a/configs/am62x_evm_a53_defconfig
> +++ b/configs/am62x_evm_a53_defconfig
> @@ -25,6 +25,7 @@ CONFIG_SPL_FS_FAT=y
>  CONFIG_SPL_LIBDISK_SUPPORT=y
>  CONFIG_SPL_SPI_FLASH_SUPPORT=y
>  CONFIG_SPL_SPI=y
> +# CONFIG_PSCI_RESET is not set
>  # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
>  CONFIG_SPL_LOAD_FIT=y
>  CONFIG_SPL_LOAD_FIT_ADDRESS=0x8100
> -- 
> 2.40.0


Re: [PATCH v1] include: configs: verdin-am62: drop unused sdram address

2023-08-29 Thread Mattijs Korpershoek
Hi Marcel,

Thank you for following up this quickly on this.

On lun., août 28, 2023 at 23:50, Marcel Ziswiler  wrote:

> From: Marcel Ziswiler 
>
> Drop unused macro. This was copied straight from the AM62x EVM but while
> meant for a second region of DDR this is not even needed for the AM62x
> EVM configurations and has meanwhile also been dropped there.
>
> Note that on the Verdin AM62, we do auto-detect the amount of SDRAM.
>
> While at it also update the comment noting that CFG_SYS_SDRAM_SIZE is
> the maximum which is only used for such auto-detection.
>
> Signed-off-by: Marcel Ziswiler 

Reviewed-by: Mattijs Korpershoek 

>
> ---
>
>  include/configs/verdin-am62.h | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/include/configs/verdin-am62.h b/include/configs/verdin-am62.h
> index 7990ea83102..e1a5f5ad44b 100644
> --- a/include/configs/verdin-am62.h
> +++ b/include/configs/verdin-am62.h
> @@ -13,8 +13,7 @@
>  
>  /* DDR Configuration */
>  #define CFG_SYS_SDRAM_BASE   0x8000
> -#define CFG_SYS_SDRAM_BASE1  0x88000
> -#define CFG_SYS_SDRAM_SIZE   SZ_2G /* Maximum supported size */
> +#define CFG_SYS_SDRAM_SIZE   SZ_2G /* Maximum supported size, auto-detection 
> is used */
>  
>  #define MEM_LAYOUT_ENV_SETTINGS \
>   "fdt_addr_r=0x9020\0" \
> -- 
> 2.36.1


Re: [PATCH v2 05/17] cmd: rockusb: Use plain udevice for UDC controller interaction

2023-09-04 Thread Mattijs Korpershoek
On ven., sept. 01, 2023 at 11:49, Marek Vasut  wrote:

> Convert to plain udevice interaction with UDC controller
> device, avoid the use of UDC uclass dev_array .
>
> Signed-off-by: Marek Vasut 

Reviewed-by: Mattijs Korpershoek 

> ---
> Cc: Angus Ainslie 
> Cc: Dmitrii Merkurev 
> Cc: Eddie Cai 
> Cc: Kever Yang 
> Cc: Lukasz Majewski 
> Cc: Miquel Raynal 
> Cc: Mattijs Korpershoek 
> Cc: Nishanth Menon 
> Cc: Patrice Chotard 
> Cc: Patrick Delaunay 
> Cc: Philipp Tomsich 
> Cc: Simon Glass 
> Cc: Stefan Roese 
> Cc: ker...@puri.sm
> ---
> V2: No change
> ---
>  cmd/rockusb.c | 7 ---
>  1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/cmd/rockusb.c b/cmd/rockusb.c
> index f181ec61119..07088564a10 100644
> --- a/cmd/rockusb.c
> +++ b/cmd/rockusb.c
> @@ -15,6 +15,7 @@ static int do_rockusb(struct cmd_tbl *cmdtp, int flag, int 
> argc,
>  {
>   int controller_index, dev_index;
>   char *usb_controller;
> + struct udevice *udc;
>   char *devtype;
>   char *devnum;
>   int ret;
> @@ -34,7 +35,7 @@ static int do_rockusb(struct cmd_tbl *cmdtp, int flag, int 
> argc,
>   dev_index = simple_strtoul(devnum, NULL, 0);
>   rockusb_dev_init(devtype, dev_index);
>  
> - ret = usb_gadget_initialize(controller_index);
> + ret = udc_device_get_by_index(controller_index, &udc);
>   if (ret) {
>   printf("USB init failed: %d\n", ret);
>   return CMD_RET_FAILURE;
> @@ -56,14 +57,14 @@ static int do_rockusb(struct cmd_tbl *cmdtp, int flag, 
> int argc,
>   break;
>   if (ctrlc())
>   break;
> - usb_gadget_handle_interrupts(controller_index);
> + dm_usb_gadget_handle_interrupts(udc);
>   }
>   ret = CMD_RET_SUCCESS;
>  
>  exit:
>   g_dnl_unregister();
>   g_dnl_clear_detach();
> - usb_gadget_release(controller_index);
> + udc_device_put(udc);
>  
>   return ret;
>  }
> -- 
> 2.40.1


Re: [PATCH v2 07/17] cmd: thordown: Reorder variable declaration

2023-09-04 Thread Mattijs Korpershoek
On ven., sept. 01, 2023 at 11:49, Marek Vasut  wrote:

> Move the variable declaration around to improve code readability.
> No functional change.
>
> Signed-off-by: Marek Vasut 

Reviewed-by: Mattijs Korpershoek 

> ---
> Cc: Angus Ainslie 
> Cc: Dmitrii Merkurev 
> Cc: Eddie Cai 
> Cc: Kever Yang 
> Cc: Lukasz Majewski 
> Cc: Miquel Raynal 
> Cc: Mattijs Korpershoek 
> Cc: Nishanth Menon 
> Cc: Patrice Chotard 
> Cc: Patrick Delaunay 
> Cc: Philipp Tomsich 
> Cc: Simon Glass 
> Cc: Stefan Roese 
> Cc: ker...@puri.sm
> ---
> V2: No change
> ---
>  cmd/thordown.c | 15 ---
>  1 file changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/cmd/thordown.c b/cmd/thordown.c
> index 838764ccef7..0d8dcee5314 100644
> --- a/cmd/thordown.c
> +++ b/cmd/thordown.c
> @@ -15,22 +15,23 @@
>  
>  int do_thor_down(struct cmd_tbl *cmdtp, int flag, int argc, char *const 
> argv[])
>  {
> + char *interface, *devstring;
> + int controller_index;
> + int ret;
> +
>   if (argc < 4)
>   return CMD_RET_USAGE;
>  
> - char *usb_controller = argv[1];
> - char *interface = argv[2];
> - char *devstring = argv[3];
> -
> - int ret;
> -
>   puts("TIZEN \"THOR\" Downloader\n");
>  
> + interface = argv[2];
> + devstring = argv[3];
> +
>   ret = dfu_init_env_entities(interface, devstring);
>   if (ret)
>   goto done;
>  
> - int controller_index = simple_strtoul(usb_controller, NULL, 0);
> + controller_index = simple_strtoul(argv[1], NULL, 0);
>   ret = usb_gadget_initialize(controller_index);
>   if (ret) {
>   pr_err("USB init failed: %d\n", ret);
> -- 
> 2.40.1


Re: [PATCH v2 13/17] thordown: Use plain udevice for UDC controller interaction

2023-09-04 Thread Mattijs Korpershoek
On ven., sept. 01, 2023 at 11:49, Marek Vasut  wrote:

> Convert to plain udevice interaction with UDC controller
> device, avoid the use of UDC uclass dev_array .
>
> Signed-off-by: Marek Vasut 
> ---
> Cc: Angus Ainslie 
> Cc: Dmitrii Merkurev 
> Cc: Eddie Cai 
> Cc: Kever Yang 
> Cc: Lukasz Majewski 
> Cc: Miquel Raynal 
> Cc: Mattijs Korpershoek 
> Cc: Nishanth Menon 
> Cc: Patrice Chotard 
> Cc: Patrick Delaunay 
> Cc: Philipp Tomsich 
> Cc: Simon Glass 
> Cc: Stefan Roese 
> Cc: ker...@puri.sm

Reviewed-by: Mattijs Korpershoek 

> ---
> V2: No change
> ---
>  cmd/thordown.c  |  9 +++--
>  drivers/usb/gadget/f_thor.c | 74 +++--
>  include/thor.h  |  4 +-
>  3 files changed, 45 insertions(+), 42 deletions(-)
>
> diff --git a/cmd/thordown.c b/cmd/thordown.c
> index 0d8dcee5314..fcfd38f523c 100644
> --- a/cmd/thordown.c
> +++ b/cmd/thordown.c
> @@ -17,6 +17,7 @@ int do_thor_down(struct cmd_tbl *cmdtp, int flag, int argc, 
> char *const argv[])
>  {
>   char *interface, *devstring;
>   int controller_index;
> + struct udevice *udc;
>   int ret;
>  
>   if (argc < 4)
> @@ -32,7 +33,7 @@ int do_thor_down(struct cmd_tbl *cmdtp, int flag, int argc, 
> char *const argv[])
>   goto done;
>  
>   controller_index = simple_strtoul(argv[1], NULL, 0);
> - ret = usb_gadget_initialize(controller_index);
> + ret = udc_device_get_by_index(controller_index, &udc);
>   if (ret) {
>   pr_err("USB init failed: %d\n", ret);
>   ret = CMD_RET_FAILURE;
> @@ -46,7 +47,7 @@ int do_thor_down(struct cmd_tbl *cmdtp, int flag, int argc, 
> char *const argv[])
>   goto exit;
>   }
>  
> - ret = thor_init();
> + ret = thor_init(udc);
>   if (ret) {
>   pr_err("THOR DOWNLOAD failed: %d\n", ret);
>   ret = CMD_RET_FAILURE;
> @@ -54,7 +55,7 @@ int do_thor_down(struct cmd_tbl *cmdtp, int flag, int argc, 
> char *const argv[])
>   }
>  
>   do {
> - ret = thor_handle();
> + ret = thor_handle(udc);
>   if (ret == THOR_DFU_REINIT_NEEDED) {
>   dfu_free_entities();
>   ret = dfu_init_env_entities(interface, devstring);
> @@ -67,7 +68,7 @@ int do_thor_down(struct cmd_tbl *cmdtp, int flag, int argc, 
> char *const argv[])
>   } while (ret == 0);
>  exit:
>   g_dnl_unregister();
> - usb_gadget_release(controller_index);
> + udc_device_put(udc);
>  done:
>   dfu_free_entities();
>  
> diff --git a/drivers/usb/gadget/f_thor.c b/drivers/usb/gadget/f_thor.c
> index 47ef55b2fd3..3caa4c36387 100644
> --- a/drivers/usb/gadget/f_thor.c
> +++ b/drivers/usb/gadget/f_thor.c
> @@ -15,9 +15,10 @@
>   */
>  
>  #include 
> -#include 
>  #include 
>  #include 
> +#include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -34,9 +35,9 @@
>  
>  #include "f_thor.h"
>  
> -static void thor_tx_data(unsigned char *data, int len);
> +static void thor_tx_data(struct udevice *udc, unsigned char *data, int len);
>  static void thor_set_dma(void *addr, int len);
> -static int thor_rx_data(void);
> +static int thor_rx_data(struct udevice *udc);
>  
>  static struct f_thor *thor_func;
>  static inline struct f_thor *func_to_thor(struct usb_function *f)
> @@ -56,15 +57,15 @@ DEFINE_CACHE_ALIGN_BUFFER(char, f_name, F_NAME_BUF_SIZE + 
> 1);
>  static unsigned long long int thor_file_size;
>  static int alt_setting_num;
>  
> -static void send_rsp(const struct rsp_box *rsp)
> +static void send_rsp(struct udevice *udc, const struct rsp_box *rsp)
>  {
>   memcpy(thor_tx_data_buf, rsp, sizeof(struct rsp_box));
> - thor_tx_data(thor_tx_data_buf, sizeof(struct rsp_box));
> + thor_tx_data(udc, thor_tx_data_buf, sizeof(struct rsp_box));
>  
>   debug("-RSP: %d, %d\n", rsp->rsp, rsp->rsp_data);
>  }
>  
> -static void send_data_rsp(s32 ack, s32 count)
> +static void send_data_rsp(struct udevice *udc, s32 ack, s32 count)
>  {
>   ALLOC_CACHE_ALIGN_BUFFER(struct data_rsp_box, rsp,
>sizeof(struct data_rsp_box));
> @@ -73,12 +74,12 @@ static void send_data_rsp(s32 ack, s32 count)
>   rsp->count = count;
>  
>   memcpy(thor_tx_data_buf, rsp, sizeof(struct data_rsp_box));
> - thor_tx_data(thor_tx_data_buf, sizeof(struct data_rsp_box));
> + thor_tx_data(udc, thor_tx_data_buf, sizeof(struct data_rsp_box));
>  
>   debug("-DATA RSP: %d, %d\n", ack, count);

Re: [PATCH v2 14/17] usb: gadget: acm: Use plain udevice for UDC controller interaction

2023-09-04 Thread Mattijs Korpershoek
On ven., sept. 01, 2023 at 11:50, Marek Vasut  wrote:

> Convert to plain udevice interaction with UDC controller
> device, avoid the use of UDC uclass dev_array .
>
> Signed-off-by: Marek Vasut 

Reviewed-by: Mattijs Korpershoek 

> ---
> Cc: Angus Ainslie 
> Cc: Dmitrii Merkurev 
> Cc: Eddie Cai 
> Cc: Kever Yang 
> Cc: Lukasz Majewski 
> Cc: Miquel Raynal 
> Cc: Mattijs Korpershoek 
> Cc: Nishanth Menon 
> Cc: Patrice Chotard 
> Cc: Patrick Delaunay 
> Cc: Philipp Tomsich 
> Cc: Simon Glass 
> Cc: Stefan Roese 
> Cc: ker...@puri.sm
> ---
> V2: No change
> ---
>  drivers/usb/gadget/f_acm.c | 13 -
>  1 file changed, 8 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/usb/gadget/f_acm.c b/drivers/usb/gadget/f_acm.c
> index b2ddd1ada8b..de42e0189e8 100644
> --- a/drivers/usb/gadget/f_acm.c
> +++ b/drivers/usb/gadget/f_acm.c
> @@ -51,7 +51,7 @@ struct f_acm {
>  #define ACM_CTRL_RTS BIT(1)  /* unused with full duplex */
>  #define ACM_CTRL_DTR BIT(0)  /* host is ready for data r/w */
>  
> - int controller_index;
> + struct udevice *udc;
>  };
>  
>  static struct f_acm *default_acm_function;
> @@ -489,7 +489,7 @@ static void __acm_tx(struct f_acm *f_acm)
>   int len, ret;
>  
>   do {
> - usb_gadget_handle_interrupts(f_acm->controller_index);
> + dm_usb_gadget_handle_interrupts(f_acm->udc);
>  
>   if (!(f_acm->handshake_bits & ACM_CTRL_DTR))
>   break;
> @@ -520,7 +520,7 @@ static bool acm_connected(struct stdio_dev *dev)
>   struct f_acm *f_acm = stdio_to_acm(dev);
>  
>   /* give a chance to process udc irq */
> - usb_gadget_handle_interrupts(f_acm->controller_index);
> + dm_usb_gadget_handle_interrupts(f_acm->udc);
>  
>   return f_acm->connected;
>  }
> @@ -543,7 +543,10 @@ static int acm_add(struct usb_configuration *c)
>   f_acm->usb_function.descriptors = acm_fs_function;
>   f_acm->usb_function.hs_descriptors = acm_hs_function;
>   f_acm->usb_function.setup = acm_setup;
> - f_acm->controller_index = 0;
> +
> + status = udc_device_get_by_index(0, &f_acm->udc);
> + if (status)
> + return status;
>  
>   status = usb_add_function(c, &f_acm->usb_function);
>   if (status) {
> @@ -567,7 +570,7 @@ static int acm_stdio_tstc(struct stdio_dev *dev)
>  {
>   struct f_acm *f_acm = stdio_to_acm(dev);
>  
> - usb_gadget_handle_interrupts(f_acm->controller_index);
> + dm_usb_gadget_handle_interrupts(f_acm->udc);
>  
>   return (f_acm->rx_buf.size > 0);
>  }
> -- 
> 2.40.1


Re: [PATCH v2 15/17] usb: gadget: ether: Use plain udevice for UDC controller interaction

2023-09-04 Thread Mattijs Korpershoek
On ven., sept. 01, 2023 at 11:50, Marek Vasut  wrote:

> Convert to plain udevice interaction with UDC controller
> device, avoid the use of UDC uclass dev_array .
>
> Signed-off-by: Marek Vasut 
> ---
> Cc: Angus Ainslie 
> Cc: Dmitrii Merkurev 
> Cc: Eddie Cai 
> Cc: Kever Yang 
> Cc: Lukasz Majewski 
> Cc: Miquel Raynal 
> Cc: Mattijs Korpershoek 
> Cc: Nishanth Menon 
> Cc: Patrice Chotard 
> Cc: Patrick Delaunay 
> Cc: Philipp Tomsich 
> Cc: Simon Glass 
> Cc: Stefan Roese 
> Cc: ker...@puri.sm
> ---
> V2: Use udev->parent for UDC access
> ---
>  drivers/usb/gadget/ether.c | 20 +++-
>  1 file changed, 11 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
> index 5ff06d3814b..11b1a6221b3 100644
> --- a/drivers/usb/gadget/ether.c
> +++ b/drivers/usb/gadget/ether.c
> @@ -1880,8 +1880,10 @@ static void eth_start(struct eth_dev *dev, gfp_t 
> gfp_flags)
>   }
>  }
>  
> -static int eth_stop(struct eth_dev *dev)
> +static int eth_stop(struct udevice *udev)
>  {
> + struct ether_priv *priv = dev_get_priv(udev);
> + struct eth_dev *dev = &priv->ethdev;
>  #ifdef RNDIS_COMPLETE_SIGNAL_DISCONNECT
>   unsigned long ts;
>   unsigned long timeout = CONFIG_SYS_HZ; /* 1 sec to stop RNDIS */
> @@ -1895,7 +1897,7 @@ static int eth_stop(struct eth_dev *dev)
>   /* Wait until host receives OID_GEN_MEDIA_CONNECT_STATUS */
>   ts = get_timer(0);
>   while (get_timer(ts) < timeout)
> - usb_gadget_handle_interrupts(0);
> + dm_usb_gadget_handle_interrupts(udev->parent);
>  #endif
>  
>   rndis_uninit(dev->rndis_config);
> @@ -2300,7 +2302,7 @@ static int usb_eth_start(struct udevice *udev)
>   pr_err("The remote end did not respond in time.");
>   goto fail;
>   }
> - usb_gadget_handle_interrupts(0);
> + dm_usb_gadget_handle_interrupts(udev->parent);
>   }
>  
>   packet_received = 0;
> @@ -2370,7 +2372,7 @@ static int usb_eth_send(struct udevice *udev, void 
> *packet, int length)
>   printf("timeout sending packets to usb ethernet\n");
>   return -1;
>   }
> - usb_gadget_handle_interrupts(0);
> + dm_usb_gadget_handle_interrupts(udev->parent);
>   }
>   free(rndis_pkt);
>  
> @@ -2400,13 +2402,13 @@ static void usb_eth_stop(struct udevice *udev)
>* 2) 'pullup' callback in your UDC driver can be improved to perform
>* this deinitialization.
>*/
> - eth_stop(dev);
> + eth_stop(udev);
>  
>   usb_gadget_disconnect(dev->gadget);
>  
>   /* Clear pending interrupt */
>   if (dev->network_started) {
> - usb_gadget_handle_interrupts(0);
> + dm_usb_gadget_handle_interrupts(udev->parent);
>   dev->network_started = 0;
>   }
>  }
> @@ -2416,7 +2418,7 @@ static int usb_eth_recv(struct udevice *dev, int flags, 
> uchar **packetp)
>   struct ether_priv *priv = dev_get_priv(dev);
>   struct eth_dev *ethdev = &priv->ethdev;
>  
> - usb_gadget_handle_interrupts(0);
> + dm_usb_gadget_handle_interrupts(dev->parent);
>  
>   if (packet_received) {
>   if (ethdev->rx_req) {
> @@ -2467,7 +2469,7 @@ int usb_ether_init(void)
>   return ret;
>   }
>  
> - return usb_gadget_initialize(0);
> + return 0;

No udc_device_get() here?

This looks a little suspicious, because in the unbind() we call
udc_device_put().

>  }
>  
>  static int usb_eth_probe(struct udevice *dev)
> @@ -2528,7 +2530,7 @@ static int usb_eth_remove(struct udevice *dev)
>  
>  static int usb_eth_unbind(struct udevice *dev)
>  {
> - usb_gadget_release(0);
> + udc_device_put(dev->parent);
>  
>   return 0;
>  }
> -- 
> 2.40.1


Re: [PATCH v2 15/17] usb: gadget: ether: Use plain udevice for UDC controller interaction

2023-09-04 Thread Mattijs Korpershoek
On lun., sept. 04, 2023 at 11:10, Marek Vasut  wrote:

> On 9/4/23 09:56, Mattijs Korpershoek wrote:
>> On ven., sept. 01, 2023 at 11:50, Marek Vasut  wrote:
>> 
>>> Convert to plain udevice interaction with UDC controller
>>> device, avoid the use of UDC uclass dev_array .
>>>
>>> Signed-off-by: Marek Vasut 
>>> ---
>>> Cc: Angus Ainslie 
>>> Cc: Dmitrii Merkurev 
>>> Cc: Eddie Cai 
>>> Cc: Kever Yang 
>>> Cc: Lukasz Majewski 
>>> Cc: Miquel Raynal 
>>> Cc: Mattijs Korpershoek 
>>> Cc: Nishanth Menon 
>>> Cc: Patrice Chotard 
>>> Cc: Patrick Delaunay 
>>> Cc: Philipp Tomsich 
>>> Cc: Simon Glass 
>>> Cc: Stefan Roese 
>>> Cc: ker...@puri.sm
>>> ---
>>> V2: Use udev->parent for UDC access
>>> ---
>>>   drivers/usb/gadget/ether.c | 20 +++-
>>>   1 file changed, 11 insertions(+), 9 deletions(-)
>>>
>>> diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c
>>> index 5ff06d3814b..11b1a6221b3 100644
>>> --- a/drivers/usb/gadget/ether.c
>>> +++ b/drivers/usb/gadget/ether.c
>>> @@ -1880,8 +1880,10 @@ static void eth_start(struct eth_dev *dev, gfp_t 
>>> gfp_flags)
>>> }
>>>   }
>>>   
>>> -static int eth_stop(struct eth_dev *dev)
>>> +static int eth_stop(struct udevice *udev)
>>>   {
>>> +   struct ether_priv *priv = dev_get_priv(udev);
>>> +   struct eth_dev *dev = &priv->ethdev;
>>>   #ifdef RNDIS_COMPLETE_SIGNAL_DISCONNECT
>>> unsigned long ts;
>>> unsigned long timeout = CONFIG_SYS_HZ; /* 1 sec to stop RNDIS */
>>> @@ -1895,7 +1897,7 @@ static int eth_stop(struct eth_dev *dev)
>>> /* Wait until host receives OID_GEN_MEDIA_CONNECT_STATUS */
>>> ts = get_timer(0);
>>> while (get_timer(ts) < timeout)
>>> -   usb_gadget_handle_interrupts(0);
>>> +   dm_usb_gadget_handle_interrupts(udev->parent);
>>>   #endif
>>>   
>>> rndis_uninit(dev->rndis_config);
>>> @@ -2300,7 +2302,7 @@ static int usb_eth_start(struct udevice *udev)
>>> pr_err("The remote end did not respond in time.");
>>> goto fail;
>>> }
>>> -   usb_gadget_handle_interrupts(0);
>>> +   dm_usb_gadget_handle_interrupts(udev->parent);
>>> }
>>>   
>>> packet_received = 0;
>>> @@ -2370,7 +2372,7 @@ static int usb_eth_send(struct udevice *udev, void 
>>> *packet, int length)
>>> printf("timeout sending packets to usb ethernet\n");
>>> return -1;
>>> }
>>> -   usb_gadget_handle_interrupts(0);
>>> +   dm_usb_gadget_handle_interrupts(udev->parent);
>>> }
>>> free(rndis_pkt);
>>>   
>>> @@ -2400,13 +2402,13 @@ static void usb_eth_stop(struct udevice *udev)
>>>  * 2) 'pullup' callback in your UDC driver can be improved to perform
>>>  * this deinitialization.
>>>  */
>>> -   eth_stop(dev);
>>> +   eth_stop(udev);
>>>   
>>> usb_gadget_disconnect(dev->gadget);
>>>   
>>> /* Clear pending interrupt */
>>> if (dev->network_started) {
>>> -   usb_gadget_handle_interrupts(0);
>>> +   dm_usb_gadget_handle_interrupts(udev->parent);
>>> dev->network_started = 0;
>>> }
>>>   }
>>> @@ -2416,7 +2418,7 @@ static int usb_eth_recv(struct udevice *dev, int 
>>> flags, uchar **packetp)
>>> struct ether_priv *priv = dev_get_priv(dev);
>>> struct eth_dev *ethdev = &priv->ethdev;
>>>   
>>> -   usb_gadget_handle_interrupts(0);
>>> +   dm_usb_gadget_handle_interrupts(dev->parent);
>>>   
>>> if (packet_received) {
>>> if (ethdev->rx_req) {
>>> @@ -2467,7 +2469,7 @@ int usb_ether_init(void)
>>> return ret;
>>> }
>>>   
>>> -   return usb_gadget_initialize(0);
>>> +   return 0;
>> 
>> No udc_device_get() here?
>> 
>> This looks a little suspicious, because in the unbind() we call
>> udc_device_put().
>
> Look at how udc_device_get_by_index() is implemented and what it does, 
> compared to what usb_ether_init() does (hint: they are basically doing 
> the same thing). This udc_device_put() here is only a workaround for 
> platforms which are not using the bind command to bind USB ethernet yet.

Oh right. Thank you for explaining.

Reviewed-by: Mattijs Korpershoek 


Re: [PATCH 1/2] arm: dts: k3-pinctrl: Sync with kernel v6.6-rc1

2023-09-12 Thread Mattijs Korpershoek
On lun., sept. 11, 2023 at 09:02, Nishanth Menon  wrote:

> Sync pinctrl header with v6.6-rc1
>
> Signed-off-by: Nishanth Menon 

Reviewed-by: Mattijs Korpershoek 

> ---
>  arch/arm/dts/k3-pinctrl.h | 12 
>  1 file changed, 12 insertions(+)
>
> diff --git a/arch/arm/dts/k3-pinctrl.h b/arch/arm/dts/k3-pinctrl.h
> index c97548a3f42d..2a4e0e084d69 100644
> --- a/arch/arm/dts/k3-pinctrl.h
> +++ b/arch/arm/dts/k3-pinctrl.h
> @@ -11,6 +11,7 @@
>  #define PULLUDEN_SHIFT   (16)
>  #define PULLTYPESEL_SHIFT(17)
>  #define RXACTIVE_SHIFT   (18)
> +#define DEBOUNCE_SHIFT   (11)
>  
>  #define PULL_DISABLE (1 << PULLUDEN_SHIFT)
>  #define PULL_ENABLE  (0 << PULLUDEN_SHIFT)
> @@ -29,9 +30,20 @@
>  #define PIN_INPUT_PULLUP (INPUT_EN | PULL_UP)
>  #define PIN_INPUT_PULLDOWN   (INPUT_EN | PULL_DOWN)
>  
> +#define PIN_DEBOUNCE_DISABLE (0 << DEBOUNCE_SHIFT)
> +#define PIN_DEBOUNCE_CONF1   (1 << DEBOUNCE_SHIFT)
> +#define PIN_DEBOUNCE_CONF2   (2 << DEBOUNCE_SHIFT)
> +#define PIN_DEBOUNCE_CONF3   (3 << DEBOUNCE_SHIFT)
> +#define PIN_DEBOUNCE_CONF4   (4 << DEBOUNCE_SHIFT)
> +#define PIN_DEBOUNCE_CONF5   (5 << DEBOUNCE_SHIFT)
> +#define PIN_DEBOUNCE_CONF6   (6 << DEBOUNCE_SHIFT)
> +
>  #define AM62AX_IOPAD(pa, val, muxmode)   (((pa) & 0x1fff)) 
> ((val) | (muxmode))
>  #define AM62AX_MCU_IOPAD(pa, val, muxmode)   (((pa) & 0x1fff)) ((val) | 
> (muxmode))
>  
> +#define AM62PX_IOPAD(pa, val, muxmode)   (((pa) & 0x1fff)) 
> ((val) | (muxmode))
> +#define AM62PX_MCU_IOPAD(pa, val, muxmode)   (((pa) & 0x1fff)) ((val) | 
> (muxmode))
> +
>  #define AM62X_IOPAD(pa, val, muxmode)(((pa) & 0x1fff)) 
> ((val) | (muxmode))
>  #define AM62X_MCU_IOPAD(pa, val, muxmode)(((pa) & 0x1fff)) ((val) | 
> (muxmode))
>  
> -- 
> 2.40.0


Re: [PATCH 2/2] arm: dts: k3-am625: Sync with kernel v6.6-rc1

2023-09-12 Thread Mattijs Korpershoek
On lun., sept. 11, 2023 at 09:02, Nishanth Menon  wrote:

> Sync device tree with v6.6-rc1
>
> Signed-off-by: Nishanth Menon 

Reviewed-by: Mattijs Korpershoek 

> ---
>  arch/arm/dts/k3-am62-main.dtsi   |  52 -
>  arch/arm/dts/k3-am62-mcu.dtsi|  24 +
>  arch/arm/dts/k3-am62-verdin-dev.dtsi |  50 +
>  arch/arm/dts/k3-am62-verdin.dtsi |  45 +++-
>  arch/arm/dts/k3-am62.dtsi|   8 ++
>  arch/arm/dts/k3-am625-beagleplay.dts | 154 ++-
>  arch/arm/dts/k3-am625-sk.dts |   2 +-
>  7 files changed, 325 insertions(+), 10 deletions(-)
>
> diff --git a/arch/arm/dts/k3-am62-main.dtsi b/arch/arm/dts/k3-am62-main.dtsi
> index 2488e3a537fe..284b90c94da8 100644
> --- a/arch/arm/dts/k3-am62-main.dtsi
> +++ b/arch/arm/dts/k3-am62-main.dtsi
> @@ -55,11 +55,29 @@
>   #phy-cells = <1>;
>   };
>  
> - epwm_tbclk: clock@4130 {
> - compatible = "ti,am62-epwm-tbclk", "syscon";
> + epwm_tbclk: clock-controller@4130 {
> + compatible = "ti,am62-epwm-tbclk";
>   reg = <0x4130 0x4>;
>   #clock-cells = <1>;
>   };
> +
> + audio_refclk0: clock-controller@82e0 {
> + compatible = "ti,am62-audio-refclk";
> + reg = <0x82e0 0x4>;
> + clocks = <&k3_clks 157 0>;
> + assigned-clocks = <&k3_clks 157 0>;
> + assigned-clock-parents = <&k3_clks 157 8>;
> + #clock-cells = <0>;
> + };
> +
> + audio_refclk1: clock-controller@82e4 {
> + compatible = "ti,am62-audio-refclk";
> + reg = <0x82e4 0x4>;
> + clocks = <&k3_clks 157 10>;
> + assigned-clocks = <&k3_clks 157 10>;
> + assigned-clock-parents = <&k3_clks 157 18>;
> + #clock-cells = <0>;
> + };
>   };
>  
>   dmss: bus@4800 {
> @@ -174,7 +192,6 @@
>   crypto: crypto@4090 {
>   compatible = "ti,am62-sa3ul";
>   reg = <0x00 0x4090 0x00 0x1200>;
> - power-domains = <&k3_pds 70 TI_SCI_PD_SHARED>;
>   #address-cells = <2>;
>   #size-cells = <2>;
>   ranges = <0x00 0x4090 0x00 0x4090 0x00 0x3>;
> @@ -590,7 +607,7 @@
>  
>   usb0: usb@3100 {
>   compatible = "snps,dwc3";
> - reg =<0x00 0x3100 0x00 0x5>;
> + reg = <0x00 0x3100 0x00 0x5>;
>   interrupts = , /* 
> irq.0 */
>; /* 
> irq.0 */
>   interrupt-names = "host", "peripheral";
> @@ -613,7 +630,7 @@
>  
>   usb1: usb@3110 {
>   compatible = "snps,dwc3";
> - reg =<0x00 0x3110 0x00 0x5>;
> + reg = <0x00 0x3110 0x00 0x5>;
>   interrupts = , /* 
> irq.0 */
>; /* 
> irq.0 */
>   interrupt-names = "host", "peripheral";
> @@ -718,6 +735,31 @@
>   };
>   };
>  
> + dss: dss@3020 {
> + compatible = "ti,am625-dss";
> + reg = <0x00 0x3020 0x00 0x1000>, /* common */
> +   <0x00 0x30202000 0x00 0x1000>, /* vidl1 */
> +   <0x00 0x30206000 0x00 0x1000>, /* vid */
> +   <0x00 0x30207000 0x00 0x1000>, /* ovr1 */
> +   <0x00 0x30208000 0x00 0x1000>, /* ovr2 */
> +   <0x00 0x3020a000 0x00 0x1000>, /* vp1: Used for OLDI */
> +   <0x00 0x3020b000 0x00 0x1000>; /* vp2: Used as DPI Out */
> + reg-names = "common", "vidl1", "vid",
> + "ovr1", "ovr2", "vp1", "vp2";
> + power-domains = <&k3_pds 186 TI_SCI_PD_EXCLUSIVE>;
> + clocks = <&k3_clks 186 6>,
> +  <&dss_vp1_clk>,
> +  <&k3_clks 186 2>;
> + clock-names = "fck", "vp1", "vp2&q

Re: [PATCH v5 10/21] boot: Rename Android-boot text

2023-09-15 Thread Mattijs Korpershoek
On jeu., sept. 14, 2023 at 10:55, Simon Glass  wrote:

> Phrases like 'Enable support for' are pointless since this is an option
> which enables things. Drop that part so it is easier to follow.
>
> Signed-off-by: Simon Glass 

Reviewed-by: Mattijs Korpershoek 

> ---
>
> (no changes since v1)
>
>  boot/Kconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/boot/Kconfig b/boot/Kconfig
> index f8b8d608951..017f7117d57 100644
> --- a/boot/Kconfig
> +++ b/boot/Kconfig
> @@ -3,7 +3,7 @@ menu "Boot options"
>  menu "Boot images"
>  
>  config ANDROID_BOOT_IMAGE
> - bool "Enable support for Android Boot Images"
> + bool "Android Boot Images"
>   default y if FASTBOOT
>   help
> This enables support for booting images which use the Android
> -- 
> 2.42.0.459.ge4e396fd5e-goog


[PATCH v2 0/2] fastboot/mach-meson: release usb_gadget on reboot commands

2022-10-07 Thread Mattijs Korpershoek
When host issues "fastboot reboot fastboot", it's expected that the
board drops the USB connection before resetting.

On some boards, such as Khadas VIM3L and SEI610, this is not the case.

We observe the following error:
$ fastboot reboot fastboot
Rebooting into fastbootOKAY [  0.004s]
fastboot: error: Failed to boot into userspace fastboot; one or more components 
might be unbootable.

This does not happen when we use the RST button on the board.
It can be reproduced in linux with:
$ echo b > /proc/sysrq-trigger

In this case, we hit a undefined hardware behavior, where D+ and D-
are in an unknown state. Therefore the host can't detect usb
disconnection.

This series proposes 2 approaches for this problem:
* generic fix, which ensures that usb_gadget_disconnect() is called
  when the board receives any "fastboot reboot" commands
* platform specific reset implementation for g12a to ensure
  that the usb controller gets properly reset.

Changes in v2:
* Transformed into a series to provide both generic and platform
  specific fix (Marek)
* Simplified generic fix via g_dnl_trigger_detach() (Marek)
* Link to v1: 
https://lore.kernel.org/r/20220721135955.360195-1-mkorpersh...@baylibre.com

Signed-off-by: Mattijs Korpershoek 

---
Mattijs Korpershoek (2):
  usb: gadget: fastboot: detach usb on reboot commands
  mach-meson: g12a: reset usb controller in reset_misc()

 arch/arm/mach-meson/board-g12a.c  | 14 ++
 cmd/fastboot.c|  2 +-
 configs/bananapi-m5_defconfig |  2 ++
 configs/beelink-gsking-x_defconfig|  2 ++
 configs/beelink-gtking_defconfig  |  2 ++
 configs/beelink-gtkingpro_defconfig   |  2 ++
 configs/khadas-vim3_android_ab_defconfig  |  2 ++
 configs/khadas-vim3_android_defconfig |  2 ++
 configs/khadas-vim3_defconfig |  2 ++
 configs/khadas-vim3l_android_ab_defconfig |  2 ++
 configs/khadas-vim3l_android_defconfig|  2 ++
 configs/khadas-vim3l_defconfig|  2 ++
 configs/odroid-c4_defconfig   |  2 ++
 configs/odroid-hc4_defconfig  |  2 ++
 configs/odroid-n2_defconfig   |  2 ++
 configs/radxa-zero_defconfig  |  2 ++
 configs/u200_defconfig|  2 ++
 drivers/usb/gadget/f_fastboot.c   |  1 +
 18 files changed, 46 insertions(+), 1 deletion(-)
---
base-commit: 2d4591353452638132d711551fec3495b7644731
change-id: 20220728-reset-usb-controller-1b54be54b9d8

Best regards,
-- 
Mattijs Korpershoek 


[PATCH v2 1/2] usb: gadget: fastboot: detach usb on reboot commands

2022-10-07 Thread Mattijs Korpershoek
When host issues "fastboot reboot fastboot", it's expected that the
board drops the USB connection before resetting.

On some boards, such as Khadas VIM3L and SEI610, this is not the case.

We observe the following error:
$ fastboot reboot fastboot
Rebooting into fastbootOKAY [  0.004s]
fastboot: error: Failed to boot into userspace fastboot; one or more components 
might be unbootable.

This does not happen when we use the RST button on the board.
It can be reproduced in linux with:
  # echo b > /proc/sysrq-trigger

In this case, we hit a undefined hardware behavior, where D+ and D-
are in an unknown state. Therefore the host can't detect usb
disconnection.

Make sure we always call usb_gadget_release() when a "fastboot reboot"
command is issued.

Note: usb_gadget_release() should be called before g_dnl_unregister()
because g_dnl_unregister() triggers a complete() call on each
endpoint (thus calling do_reset()).

Signed-off-by: Mattijs Korpershoek 
---
 cmd/fastboot.c  | 2 +-
 drivers/usb/gadget/f_fastboot.c | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/cmd/fastboot.c b/cmd/fastboot.c
index dd223b1554da..b498e4b22bb3 100644
--- a/cmd/fastboot.c
+++ b/cmd/fastboot.c
@@ -83,9 +83,9 @@ static int do_fastboot_usb(int argc, char *const argv[],
ret = CMD_RET_SUCCESS;
 
 exit:
+   usb_gadget_release(controller_index);
g_dnl_unregister();
g_dnl_clear_detach();
-   usb_gadget_release(controller_index);
 
return ret;
 #else
diff --git a/drivers/usb/gadget/f_fastboot.c b/drivers/usb/gadget/f_fastboot.c
index d0e92c7a071f..07b1681c8a9a 100644
--- a/drivers/usb/gadget/f_fastboot.c
+++ b/drivers/usb/gadget/f_fastboot.c
@@ -544,6 +544,7 @@ static void rx_handler_command(struct usb_ep *ep, struct 
usb_request *req)
case FASTBOOT_COMMAND_REBOOT_FASTBOOTD:
case FASTBOOT_COMMAND_REBOOT_RECOVERY:
fastboot_func->in_req->complete = compl_do_reset;
+   g_dnl_trigger_detach();
break;
 #if CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT)
case FASTBOOT_COMMAND_ACMD:

-- 
b4 0.11.0-dev-5166b


[PATCH v2 2/2] mach-meson: g12a: reset usb controller in reset_misc()

2022-10-07 Thread Mattijs Korpershoek
On some g12a boards like the VIM3L and the SEI610, with some
USB cables/hosts, there is a long (5s) delay before
between "fastboot reboot" and the host detecting a USB reset.

This breaks tools relying on "fastboot reboot fastboot" which assume
that 1s after the command send, the board should disconnect on usb.

To reproduce, enable fastboot in U-Boot console:
=> fastboot usb 0

Then, on the host, run:
  # echo "running fastboot reboot bootloader" > /dev/kmsg && fastboot reboot 
bootloader
  Rebooting into bootloader  OKAY [  0.003s]
  Finished. Total time: 3.033s

  [54074.251551] running fastboot reboot bootloader
  ... there is a delay of 5s before we detect a disconnection ...
  [54079.041238] usb 1-7.4: USB disconnect, device number 72
  [54079.239625] usb 1-7.4: new high-speed USB device number 73 using xhci_hcd
  [54079.359103] usb 1-7.4: New USB device found, idVendor=1b8e, 
idProduct=fada, bcdDevice= 2.27
  [54079.359110] usb 1-7.4: New USB device strings: Mfr=1, Product=2, 
SerialNumber=3
  [54079.359112] usb 1-7.4: Product: USB download gadget
  [54079.359114] usb 1-7.4: Manufacturer: U-Boot
  [54079.359116] usb 1-7.4: SerialNumber: C8631470CC41

Note: this does not happen when we use the RST button on the board.

To fix this, re-implement a platform reset which calls
board_usb_cleanup() before resetting the board.

Signed-off-by: Mattijs Korpershoek 
---
 arch/arm/mach-meson/board-g12a.c  | 14 ++
 configs/bananapi-m5_defconfig |  2 ++
 configs/beelink-gsking-x_defconfig|  2 ++
 configs/beelink-gtking_defconfig  |  2 ++
 configs/beelink-gtkingpro_defconfig   |  2 ++
 configs/khadas-vim3_android_ab_defconfig  |  2 ++
 configs/khadas-vim3_android_defconfig |  2 ++
 configs/khadas-vim3_defconfig |  2 ++
 configs/khadas-vim3l_android_ab_defconfig |  2 ++
 configs/khadas-vim3l_android_defconfig|  2 ++
 configs/khadas-vim3l_defconfig|  2 ++
 configs/odroid-c4_defconfig   |  2 ++
 configs/odroid-hc4_defconfig  |  2 ++
 configs/odroid-n2_defconfig   |  2 ++
 configs/radxa-zero_defconfig  |  2 ++
 configs/u200_defconfig|  2 ++
 16 files changed, 44 insertions(+)

diff --git a/arch/arm/mach-meson/board-g12a.c b/arch/arm/mach-meson/board-g12a.c
index 2e59eee8f792..df7d1959aa74 100644
--- a/arch/arm/mach-meson/board-g12a.c
+++ b/arch/arm/mach-meson/board-g12a.c
@@ -17,7 +17,9 @@
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -217,3 +219,15 @@ int board_usb_cleanup(int index, enum usb_init_type init)
return 0;
 }
 #endif
+
+#if !CONFIG_IS_ENABLED(PSCI_RESET)
+void reset_misc(void)
+{
+   struct udevice *dev;
+
+   board_usb_cleanup(0, USB_INIT_UNKNOWN);
+
+   uclass_get_device_by_name(UCLASS_FIRMWARE, "psci", &dev);
+   invoke_psci_fn(PSCI_0_2_FN_SYSTEM_RESET, 0, 0, 0);
+}
+#endif
diff --git a/configs/bananapi-m5_defconfig b/configs/bananapi-m5_defconfig
index 6ab2d8ef0c44..df4fbb292a61 100644
--- a/configs/bananapi-m5_defconfig
+++ b/configs/bananapi-m5_defconfig
@@ -1,4 +1,5 @@
 CONFIG_ARM=y
+CONFIG_ARM_SMCCC=y
 CONFIG_ARCH_MESON=y
 CONFIG_SYS_TEXT_BASE=0x0100
 CONFIG_NR_DRAM_BANKS=1
@@ -9,6 +10,7 @@ CONFIG_MESON_G12A=y
 CONFIG_DEBUG_UART_BASE=0xff803000
 CONFIG_DEBUG_UART_CLOCK=2400
 CONFIG_IDENT_STRING="bpi-m5"
+# CONFIG_PSCI_RESET is not set
 CONFIG_SYS_LOAD_ADDR=0x100
 CONFIG_DEBUG_UART=y
 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
diff --git a/configs/beelink-gsking-x_defconfig 
b/configs/beelink-gsking-x_defconfig
index 2c8c642dcb2d..aa90e49f715e 100644
--- a/configs/beelink-gsking-x_defconfig
+++ b/configs/beelink-gsking-x_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SYS_BOARD="beelink-s922x"
+CONFIG_ARM_SMCCC=y
 CONFIG_ARCH_MESON=y
 CONFIG_SYS_TEXT_BASE=0x0100
 CONFIG_NR_DRAM_BANKS=1
@@ -10,6 +11,7 @@ CONFIG_MESON_G12A=y
 CONFIG_DEBUG_UART_BASE=0xff803000
 CONFIG_DEBUG_UART_CLOCK=2400
 CONFIG_IDENT_STRING=" beelink"
+# CONFIG_PSCI_RESET is not set
 CONFIG_SYS_LOAD_ADDR=0x100
 CONFIG_DEBUG_UART=y
 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
diff --git a/configs/beelink-gtking_defconfig b/configs/beelink-gtking_defconfig
index 9848252e7e95..c5ff7821997e 100644
--- a/configs/beelink-gtking_defconfig
+++ b/configs/beelink-gtking_defconfig
@@ -1,5 +1,6 @@
 CONFIG_ARM=y
 CONFIG_SYS_BOARD="beelink-s922x"
+CONFIG_ARM_SMCCC=y
 CONFIG_ARCH_MESON=y
 CONFIG_SYS_TEXT_BASE=0x0100
 CONFIG_NR_DRAM_BANKS=1
@@ -10,6 +11,7 @@ CONFIG_MESON_G12A=y
 CONFIG_DEBUG_UART_BASE=0xff803000
 CONFIG_DEBUG_UART_CLOCK=2400
 CONFIG_IDENT_STRING=" beelink"
+# CONFIG_PSCI_RESET is not set
 CONFIG_SYS_LOAD_ADDR=0x100
 CONFIG_DEBUG_UART=y
 CONFIG_HAS_CUSTOM_SYS_INIT_SP_ADDR=y
diff --git a/configs/beelink-gtkingpro_defconfig 
b/configs/beelink-gtkingp

Re: [PATCH 16/30] ide: Avoid preprocessor for CONFIG_LBA48

2023-03-28 Thread Mattijs Korpershoek
evice, ATA_COMMAND, ATA_CMD_PIO_READ);
> @@ -914,15 +905,12 @@ static ulong ide_write(struct udevice *dev, lbaint_t 
> blknr, lbaint_t blkcnt,
>   int device = block_dev->devnum;
>   ulong n = 0;
>   unsigned char c;
> + bool lba48 = false;
>  
> -#ifdef CONFIG_LBA48
> - unsigned char lba48 = 0;
> -
> - if (blknr & 0xf000ULL) {
> + if (IS_ENABLED(CONFIG_LBA48) && (blknr & 0xf000ULL)) {
>   /* more than 28 bits used, use 48bit mode */
> - lba48 = 1;
> + lba48 = true;
>   }
> -#endif
>  
>   /* Select device
>*/
> @@ -935,8 +923,7 @@ static ulong ide_write(struct udevice *dev, lbaint_t 
> blknr, lbaint_t blkcnt,
>   printf("IDE read: device %d not ready\n", device);
>   goto WR_OUT;
>   }
> -#ifdef CONFIG_LBA48
> - if (lba48) {
> + if (IS_ENABLED(CONFIG_LBA48) && lba48) {
>   /* write high bits */
>   ide_outb(device, ATA_SECT_CNT, 0);
>   ide_outb(device, ATA_LBA_LOW, (blknr >> 24) & 0xFF);
> @@ -948,21 +935,17 @@ static ulong ide_write(struct udevice *dev, lbaint_t 
> blknr, lbaint_t blkcnt,
>   ide_outb(device, ATA_LBA_HIGH, 0);
>  #endif
>   }
> -#endif
>   ide_outb(device, ATA_SECT_CNT, 1);
>   ide_outb(device, ATA_LBA_LOW, (blknr >> 0) & 0xFF);
>   ide_outb(device, ATA_LBA_MID, (blknr >> 8) & 0xFF);
>   ide_outb(device, ATA_LBA_HIGH, (blknr >> 16) & 0xFF);
>  
> -#ifdef CONFIG_LBA48
> - if (lba48) {
> + if (IS_ENABLED(CONFIG_LBA48) && lba48) {
>   ide_outb(device, ATA_DEV_HD,
>ATA_LBA | ATA_DEVICE(device));
>   ide_outb(device, ATA_COMMAND, ATA_CMD_PIO_WRITE_EXT);
>  
> - } else
> -#endif
> - {
> + } else {
>   ide_outb(device, ATA_DEV_HD, ATA_LBA |
>    ATA_DEVICE(device) | ((blknr >> 24) & 0xF));
>   ide_outb(device, ATA_COMMAND, ATA_CMD_PIO_WRITE);
> diff --git a/include/blk.h b/include/blk.h
> index 871922dcde07..2c9c7985a885 100644
> --- a/include/blk.h
> +++ b/include/blk.h
> @@ -62,10 +62,8 @@ struct blk_desc {
>   unsigned char   hwpart; /* HW partition, e.g. for eMMC */
>   unsigned char   type;   /* device type */
>   unsigned char   removable;  /* removable device */
> -#ifdef CONFIG_LBA48
>   /* device can use 48bit addr (ATA/ATAPI v7) */
> - unsigned char   lba48;
> -#endif
> + boollba48;

nitpick Is there a reason for having dropped this comment?
/* device can use 48bit addr (ATA/ATAPI v7) */

In any case:

Reviewed-by: Mattijs Korpershoek 

>   unsigned char   atapi;  /* Use ATAPI protocol */
>   lbaint_tlba;/* number of blocks */
>   unsigned long   blksz;  /* block size */
> -- 
> 2.40.0.348.gf938b09366-goog


Re: [PATCH 10/30] ide: Correct use of ATAPI

2023-03-28 Thread Mattijs Korpershoek
On mar., mars 28, 2023 at 08:06, Simon Glass  wrote:

> The use of atapi_read() was incorrect dropped. Fix this so that it will
> be used when needed. Use a udevice for the first argument of atapi_read()
> so it is consistent with ide_read().
>
> This requires much of the ATAPI code to be brought out from behind the
> existing #ifdef. It will still be removed by the compiler if it is not
> needed.
>
> Add an atapi flag to struct blk_desc so the information can be retained.
>
> Fixes: 145df842b44 ("dm: ide: Add support for driver-model block devices")
> Fixes: d0075059e4d ("ide: Drop non-DM code for BLK")
>
> Signed-off-by: Simon Glass 

Reviewed-by: Mattijs Korpershoek 

> ---
>
>  drivers/block/ide.c | 20 +---
>  include/blk.h   |  1 +
>  2 files changed, 18 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/block/ide.c b/drivers/block/ide.c
> index fa5f68ffeb01..875192cba163 100644
> --- a/drivers/block/ide.c
> +++ b/drivers/block/ide.c
> @@ -155,7 +155,6 @@ OUT:
>   *last = '\0';
>  }
>  
> -#ifdef CONFIG_ATAPI
>  /
>   * ATAPI Support
>   */
> @@ -422,9 +421,10 @@ error:
>  #define ATAPI_READ_BLOCK_SIZE2048/* assuming CD part */
>  #define ATAPI_READ_MAX_BLOCK (ATAPI_READ_MAX_BYTES/ATAPI_READ_BLOCK_SIZE)
>  
> -ulong atapi_read(struct blk_desc *block_dev, lbaint_t blknr, lbaint_t blkcnt,
> +ulong atapi_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt,
>void *buffer)
>  {
> + struct blk_desc *block_dev = dev_get_uclass_plat(dev);
>   int device = block_dev->devnum;
>   ulong n = 0;
>   unsigned char ccb[12];  /* Command descriptor block */
> @@ -466,6 +466,8 @@ ulong atapi_read(struct blk_desc *block_dev, lbaint_t 
> blknr, lbaint_t blkcnt,
>   return n;
>  }
>  
> +#ifdef CONFIG_ATAPI
> +
>  static void atapi_inquiry(struct blk_desc *dev_desc)
>  {
>   unsigned char ccb[12];  /* Command descriptor block */
> @@ -653,6 +655,7 @@ static void ide_ident(struct blk_desc *dev_desc)
>  
>  #ifdef CONFIG_ATAPI
>   if (is_atapi) {
> + dev_desc->atapi = true;
>   atapi_inquiry(dev_desc);
>   return;
>   }
> @@ -1010,6 +1013,17 @@ WR_OUT:
>   return n;
>  }
>  
> +ulong ide_or_atapi_read(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt,
> + void *buffer)
> +{
> + struct blk_desc *desc = dev_get_uclass_plat(dev);
> +
> + if (IS_ENABLED(CONFIG_ATAPI) && desc->atapi)
> + return atapi_read(dev, blknr, blkcnt, buffer);
> +
> + return ide_read(dev, blknr, blkcnt, buffer);
> +}
> +
>  static int ide_blk_probe(struct udevice *udev)
>  {
>   struct blk_desc *desc = dev_get_uclass_plat(udev);
> @@ -1029,7 +1043,7 @@ static int ide_blk_probe(struct udevice *udev)
>  }
>  
>  static const struct blk_ops ide_blk_ops = {
> - .read   = ide_read,
> + .read   = ide_or_atapi_read,
>   .write  = ide_write,
>  };
>  
> diff --git a/include/blk.h b/include/blk.h
> index 1db203c1baba..871922dcde07 100644
> --- a/include/blk.h
> +++ b/include/blk.h
> @@ -66,6 +66,7 @@ struct blk_desc {
>   /* device can use 48bit addr (ATA/ATAPI v7) */
>   unsigned char   lba48;
>  #endif
> + unsigned char   atapi;  /* Use ATAPI protocol */
>   lbaint_tlba;/* number of blocks */
>   unsigned long   blksz;  /* block size */
>   int log2blksz;  /* for convenience: log2(blksz) */
> -- 
> 2.40.0.348.gf938b09366-goog


Re: [PATCH v3 11/19] android: boot: ramdisk: support vendor ramdisk

2023-04-07 Thread Mattijs Korpershoek
Hi Roman,

On ven., avril 07, 2023 at 11:56, Roman Stratiienko  
wrote:

> Hi guys,
>
> I rebased on uboot/master and all is working for me except for the

Thanks a lot for confirming that things work for you.

> boot image ramdisk concatenation.
> Current memcpy logic overwrites its context. Please find a fix that
> works for me here:
> https://github.com/GloDroidCommunity/raspberry-pi/blob/151fae1c7ddb7d347034dd135631f8f7075c7968/patches-aosp/glodroid/bootloader/u-boot/0006-android-Fix-ramdisk-loading-for-bootimage-v3.patch

Thanks as well for reporting this problem. I did not observe any
problems with the ramdisk concatenation when I tested on a TI AM62x evk board 
with these:

* 
https://gitlab.baylibre.com/baylibre/ti/android/aosp/device/ti/am62x/-/merge_requests/29
* https://gitlab.baylibre.com/baylibre/ti/ti-u-boot/-/merge_requests/7
* https://gitlab.baylibre.com/baylibre/ti/ti-linux-kernel/-/merge_requests/75

Note that it's a bit of unfortunate timing for me. I am leaving my office for a
month of break. I will have a look at this when I come back after my vacation.

Regards,
Mattijs

>
> чт, 9 февр. 2023 г. в 16:35, Mattijs Korpershoek :
>>
>> On Mon, Feb 06, 2023 at 00:50, Safae Ouajih  wrote:
>>
>> > Version 3 and 4 of boot image header introduced
>> > vendor boot ramdisk: Please check include/android_image.h
>> > for details.
>> >
>> > The ramdisk is now split into a generic ramdisk in boot image
>> > and a vendor ramdisk in vendor boot image.
>> >
>> > Support the new vendor ramdisk.
>> >
>> > Signed-off-by: Safae Ouajih 
>> > Reviewed-by: Simon Glass 
>>
>> Reviewed-by: Mattijs Korpershoek 
>>
>> > ---
>> >  boot/image-android.c | 13 +++--
>> >  include/image.h  |  4 ++--
>> >  2 files changed, 13 insertions(+), 4 deletions(-)
>> >
>> > diff --git a/boot/image-android.c b/boot/image-android.c
>> > index 712d437766..35243fd5b1 100644
>> > --- a/boot/image-android.c
>> > +++ b/boot/image-android.c
>> > @@ -25,6 +25,7 @@ static void android_boot_image_v3_v4_parse_hdr(const 
>> > struct andr_boot_img_hdr_v3
>> >
>> >   data->kcmdline = hdr->cmdline;
>> >   data->header_version = hdr->header_version;
>> > + data->ramdisk_ptr = env_get_ulong("ramdisk_addr_r", 16, 0);
>> >
>> >   /*
>> >* The header takes a full page, the remaining components are aligned
>> > @@ -322,10 +323,11 @@ ulong android_image_get_kcomp(const struct 
>> > andr_boot_img_hdr_v0 *hdr,
>> >   return image_decomp_type(p, sizeof(u32));
>> >  }
>> >
>> > -int android_image_get_ramdisk(const struct andr_boot_img_hdr_v0 *hdr,
>> > -   const void *vendor_boot_img, ulong *rd_data, 
>> > ulong *rd_len)
>> > +int android_image_get_ramdisk(const void *hdr, const void 
>> > *vendor_boot_img,
>> > +   ulong *rd_data, ulong *rd_len)
>> >  {
>> >   struct andr_image_data img_data = {0};
>> > + ulong ramdisk_ptr;
>> >
>> >   if (!android_image_get_data(hdr, vendor_boot_img, &img_data))
>> >   return -EINVAL;
>> > @@ -334,6 +336,13 @@ int android_image_get_ramdisk(const struct 
>> > andr_boot_img_hdr_v0 *hdr,
>> >   *rd_data = *rd_len = 0;
>> >   return -1;
>> >   }
>> > + if (img_data.header_version > 2) {
>> > + ramdisk_ptr = img_data.ramdisk_ptr;
>> > + memcpy((void *)(ramdisk_ptr), (void 
>> > *)img_data.vendor_ramdisk_ptr,
>> > +img_data.vendor_ramdisk_size);
>> > + memcpy((void *)(ramdisk_ptr + img_data.vendor_ramdisk_size),
>> > +(void *)img_data.ramdisk_ptr, 
>> > img_data.boot_ramdisk_size);
>> > + }
>> >
>> >   printf("RAM disk load addr 0x%08lx size %u KiB\n",
>> >  img_data.ramdisk_ptr, DIV_ROUND_UP(img_data.ramdisk_size, 
>> > 1024));
>> > diff --git a/include/image.h b/include/image.h
>> > index c2e751c136..c4d9b1c575 100644
>> > --- a/include/image.h
>> > +++ b/include/image.h
>> > @@ -1782,8 +1782,8 @@ int android_image_get_kernel(const struct 
>> > andr_boot_img_hdr_v0 *hdr,
>> >   * @rd_len:  Pointer to a ulong variable, will hold ramdisk length
>> >   * Return: 0 if succeeded, -1 if ramdisk size is 0
>> >   */
>> > -int android_image_get_ramdisk(const struct andr_boot_img_hdr_v0 *hdr,
>> > -   const void *vendor_boot_img, ulong *rd_data, 
>> > ulong *rd_len);
>> > +int android_image_get_ramdisk(const void *hdr, const void 
>> > *vendor_boot_img,
>> > +   ulong *rd_data, ulong *rd_len);
>> >
>> >  /**
>> >   * android_image_get_second() - Extracts the secondary bootloader address
>> > --
>> > 2.34.1


Re: [PATCH v2 5/8] usb: dwc3: Add dwc3 glue driver for am62

2023-04-07 Thread Mattijs Korpershoek
On jeu., avril 06, 2023 at 20:55, Sjoerd Simons  wrote:

> Add glue code for TI AM62 to the dwc3 driver; Most code adopted from
> TI vendor u-boot code.
>
> Signed-off-by: Sjoerd Simons 

Reviewed-by: Mattijs Korpershoek 

nitpick (comment typo) below

>
> ---
>
> Changes in v2:
> - Switch dwc3 glue to a seperate driver rather then in dwc-generic
>
>  drivers/usb/dwc3/Kconfig |  14 
>  drivers/usb/dwc3/Makefile|   1 +
>  drivers/usb/dwc3/dwc3-am62.c | 127 +++
>  3 files changed, 142 insertions(+)
>  create mode 100644 drivers/usb/dwc3/dwc3-am62.c
>
> diff --git a/drivers/usb/dwc3/Kconfig b/drivers/usb/dwc3/Kconfig
> index c0c8c16fd9c..26a1e1770c5 100644
> --- a/drivers/usb/dwc3/Kconfig
> +++ b/drivers/usb/dwc3/Kconfig
> @@ -37,6 +37,20 @@ config SPL_USB_DWC3_GENERIC
> Select this for Xilinx ZynqMP and similar Platforms.
> This wrapper supports Host and Peripheral operation modes.
>  
> +config SPL_USB_DWC3_AM62
> + bool "TI AM62 USB wrapper"
> + depends on SPL_DM_USB && SPL_USB_DWC3_GENERIC
> + help
> +   Select this for TI AM62 Platforms.
> +   This wrapper supports Host and Peripheral operation modes.
> +
> +config USB_DWC3_AM62
> + bool "TI AM62 USB wrapper"
> + depends on DM_USB && USB_DWC3_GENERIC
> + help
> +   Select this for TI AM62 Platforms.
> +   This wrapper supports Host and Peripheral operation modes.
> +
>  config USB_DWC3_MESON_G12A
>   bool "Amlogic Meson G12A USB wrapper"
>   depends on DM_USB && USB_DWC3 && ARCH_MESON
> diff --git a/drivers/usb/dwc3/Makefile b/drivers/usb/dwc3/Makefile
> index 97b4f7191ca..a46b6824ab7 100644
> --- a/drivers/usb/dwc3/Makefile
> +++ b/drivers/usb/dwc3/Makefile
> @@ -6,6 +6,7 @@ dwc3-y:= core.o
>  
>  obj-$(CONFIG_USB_DWC3_GADGET)+= gadget.o ep0.o
>  
> +obj-$(CONFIG_$(SPL_)USB_DWC3_AM62)   += dwc3-am62.o
>  obj-$(CONFIG_USB_DWC3_OMAP)  += dwc3-omap.o
>  obj-$(CONFIG_USB_DWC3_MESON_G12A)+= dwc3-meson-g12a.o
>  obj-$(CONFIG_USB_DWC3_MESON_GXL) += dwc3-meson-gxl.o
> diff --git a/drivers/usb/dwc3/dwc3-am62.c b/drivers/usb/dwc3/dwc3-am62.c
> new file mode 100644
> index 000..20d99758b4f
> --- /dev/null
> +++ b/drivers/usb/dwc3/dwc3-am62.c
> @@ -0,0 +1,127 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * TI AM62 specific glue layer for DWC3
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "dwc3-generic.h"
> +
> +void dwc3_ti_am62_glue_configure(struct udevice *dev, int index,
> +  enum usb_dr_mode mode)
> +{
> +#define USBSS_MODE_CONTROL   0x1c
> +#define USBSS_PHY_CONFIG 0x8
> +#define USBSS_PHY_VBUS_SEL_MASK  GENMASK(2, 1)
> +#define USBSS_PHY_VBUS_SEL_SHIFT 1
> +#define USBSS_MODE_VALID BIT(0)
> +#define PHY_PLL_REFCLK_MASK  GENMASK(3, 0)
> +static const int dwc3_ti_am62_rate_table[] = {   /* in KHZ */
> + 9600,
> + 1,
> + 12000,
> + 19200,
> + 2,
> + 24000,
> + 25000,
> + 26000,
> + 38400,
> + 4,
> + 58000,
> + 5,
> + 52000,
> +};
> +
> + struct clk usb2_refclk;
> + int rate_code, i, ret;
> + unsigned long rate;
> + u32 reg;
> + void *usbss;
> + bool vbus_divider;
> + struct regmap *syscon;
> + struct ofnode_phandle_args args;
> +
> + usbss = dev_remap_addr_index(dev, 0);
> + if (IS_ERR(usbss)) {
> + dev_err(dev, "can't map IOMEM resource\n");
> + return;
> + }
> +
> + ret = clk_get_by_name(dev, "ref", &usb2_refclk);
> + if (ret) {
> + dev_err(dev, "can't get usb2_refclk\n");
> + return;
> + }
> +
> + /* Calcuate the rate code */

s/Calcuate/Calculate

> + rate = clk_get_rate(&usb2_refclk);
> + rate /= 1000;   /* To KHz */
> + for (i = 0; i < ARRAY_SIZE(dwc3_ti_am62_rate_table); i++) {
> + if (dwc3_ti_am62_rate_table[i] == rate)
> + break;
> + }
> +
> + if (i == ARRAY_SIZE(dwc3_ti_am62_rate_table)) {
> + dev_err(dev, "unsupported usb2_refclk rate: %lu KHz\n", rate);
> + return;
> + }
> +
> + rate_code = i;
> +
> + /* Read the syscon property */
> + syscon = syscon_regmap_lookup_by_phandle(dev, 
> "ti,syscon-phy-pll-refclk");
> + 

Re: [PATCH v2 4/4] usb: Avoid unbinding devices in use by bootflows

2023-09-23 Thread Mattijs Korpershoek
Hi Simon,

Thank you for your patch.

On ven., sept. 22, 2023 at 15:38, Simon Glass  wrote:

> When a USB device is unbound, it causes any bootflows attached to it to
> be removed, via a call to bootdev_clear_bootflows() from
> bootdev_pre_unbind(). This obviously makes it impossible to boot the
> bootflow.
>
> However, when booting a bootflow that relies on USB, usb_stop() is
> called, which unbinds the device. For EFI, this happens in
> efi_exit_boot_services() which means that the bootflow disappears
> before it is finished with.
>
> There is no need to unbind all the USB devices just to quiesce them.
> Add a new usb_pause() call which removes them but leaves them bound.
>
> This resolves a hang on x86 when booting a distro from USB. This was
> found using a device with 4 bootflows, the last of which was USB.
>
> Signed-off-by: Simon Glass 
> ---
>
> Changes in v2:
> - Add new patch to avoid unbinding devices in use by bootflows
>
>  boot/bootm.c  |  2 +-
>  common/usb.c  |  7 ++-
>  drivers/usb/host/usb-uclass.c | 14 --
>  include/usb.h | 15 ++-
>  4 files changed, 33 insertions(+), 5 deletions(-)
>
> diff --git a/boot/bootm.c b/boot/bootm.c
> index b1c3afe0a3a..5c9ba083e64 100644
> --- a/boot/bootm.c
> +++ b/boot/bootm.c
> @@ -501,7 +501,7 @@ ulong bootm_disable_interrupts(void)
>* updated every 1 ms within the HCCA structure in SDRAM! For more
>* details see the OpenHCI specification.
>*/
> - usb_stop();
> + usb_pause();
>  #endif
>   return iflag;
>  }
> diff --git a/common/usb.c b/common/usb.c
> index 836506dcd9e..4d6ac69111e 100644
> --- a/common/usb.c
> +++ b/common/usb.c
> @@ -126,7 +126,7 @@ int usb_init(void)
>  
> /**
>   * Stop USB this stops the LowLevel Part and deregisters USB devices.
>   */
> -int usb_stop(void)
> +int usb_pause(void)

nit: I know this is the "legacy" (pre-DM) stuff, but isn't renaming the above
function making the comment wrong?

Can't we keep this function usb_stop() and create another one named
usb_pause() which calls usb_stop() ?

>  {
>   int i;
>  
> @@ -144,6 +144,11 @@ int usb_stop(void)
>   return 0;
>  }
>  
> +int usb_stop(void)
> +{
> + return usb_pause();
> +}
> +
>  
> /**
>   * Detect if a USB device has been plugged or unplugged.
>   */
> diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c
> index a1cd0ad2d66..c26c65d7986 100644
> --- a/drivers/usb/host/usb-uclass.c
> +++ b/drivers/usb/host/usb-uclass.c
> @@ -173,7 +173,7 @@ int usb_get_max_xfer_size(struct usb_device *udev, size_t 
> *size)
>   return ops->get_max_xfer_size(bus, size);
>  }
>  
> -int usb_stop(void)
> +static int usb_finish(bool unbind_all)
>  {
>   struct udevice *bus;
>   struct udevice *rh;
> @@ -195,7 +195,7 @@ int usb_stop(void)
>  
>   /* Locate root hub device */
>   device_find_first_child(bus, &rh);
> - if (rh) {
> + if (rh && unbind_all) {
>   /*
>* All USB devices are children of root hub.
>* Unbinding root hub will unbind all of its children.
> @@ -222,6 +222,16 @@ int usb_stop(void)
>   return err;
>  }
>  
> +int usb_stop(void)
> +{
> + return usb_finish(true);
> +}
> +
> +int usb_pause(void)
> +{
> + return usb_finish(false);
> +}

What happens if someone calls usb_pause() followed by usb_init() on a
root hub ?

I think it behaves properly because usb_init() calls
remove_inactive_children().

> +
>  static void usb_scan_bus(struct udevice *bus, bool recurse)
>  {
>   struct usb_bus_priv *priv;
> diff --git a/include/usb.h b/include/usb.h
> index 09e3f0cb309..ad39b09a6e4 100644
> --- a/include/usb.h
> +++ b/include/usb.h
> @@ -265,7 +265,20 @@ int usb_kbd_deregister(int force);
>   */
>  int usb_init(void);
>  
> -int usb_stop(void); /* stop the USB Controller */
> +/**
> + * usb_stop() - stop the USB Controller and unbind all USB 
> controllers/devices
> + *
> + * Return: 0 if OK, -ve on error
> + */
> +int usb_stop(void);
> +
> +/**
> + * usb_pause() - stop the USB Controller DMA, etc.
> + *
> + * Return: 0 if OK, -ve on error
> + */
> +int usb_pause(void);
> +
>  int usb_detect_change(void); /* detect if a USB device has been (un)plugged 
> */
>  
>  
> -- 
> 2.42.0.515.g380fc7ccd1-goog


Re: [PATCH v5 39/43] command: Include a required header in command.h

2023-09-30 Thread Mattijs Korpershoek
On mer., sept. 27, 2023 at 08:22, Simon Glass  wrote:

> This uses ARRAY_SIZE() but does not include the header file which declares
> it. Fix this, so that command.h can be included without common.h
>
> Signed-off-by: Simon Glass 

Reviewed-by: Mattijs Korpershoek 

> ---
>
> Changes in v5:
> - Adjust so this builds on azure
>
>  boot/bootm.c  | 2 +-
>  include/command.h | 4 
>  2 files changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/boot/bootm.c b/boot/bootm.c
> index b1c3afe0a3a..8f96a80d425 100644
> --- a/boot/bootm.c
> +++ b/boot/bootm.c
> @@ -8,6 +8,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -29,7 +30,6 @@
>  #include "mkimage.h"
>  #endif
>  
> -#include 
>  #include 
>  #include 
>  
> diff --git a/include/command.h b/include/command.h
> index ae7bb4a30b0..34ea989b39b 100644
> --- a/include/command.h
> +++ b/include/command.h
> @@ -25,6 +25,10 @@
>  #endif
>  
>  #ifndef  __ASSEMBLY__
> +
> +/* For ARRAY_SIZE() */
> +#include 
> +
>  /*
>   * Monitor Command Table
>   */
> -- 
> 2.42.0.515.g380fc7ccd1-goog


Re: [PATCH] fastboot: fix CRC32 chunk size checking

2023-10-02 Thread Mattijs Korpershoek
Hi Wojciech,

Thank you for your patch.

On lun., sept. 25, 2023 at 12:37, Wojciech Nizinski  wrote:

> genimage create android-sparse file with CRC32 chunk at end. When
> U-Boot's fastboot receives this chunk it returns error message:
> `Fail Bogus chunk size for chunk type Dont Care`

I could not reproduce this, probably because my sparse images don't have
crc32 chunks.

>
> According to reference implementation of Android's sparse file format:
>
> <https://android.googlesource.com/platform/system/core/+/refs/heads/main/
> libsparse/output_file.cpp#513>
>
> the chunk_header.total_sz is CHUNK_HEADER_LEN + 4 (CRC32 size).
>
> Signed-off-by: Wojciech Nizinski 

However, the change looks fine to me.

Reviewed-by: Mattijs Korpershoek 

I also tested by reflashing a super image from aosp/main on the vim3 board.
Base commit: 2173c4a99066 ("Merge tag 'u-boot-at91-fixes-2023.10-b' of 
https://source.denx.de/u-boot/custodians/u-boot-at91";)

Tested-by: Mattijs Korpershoek  # on vim3

> ---
>
>  lib/image-sparse.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/lib/image-sparse.c b/lib/image-sparse.c
> index 8f8a67e158..323aad981c 100644
> --- a/lib/image-sparse.c
> +++ b/lib/image-sparse.c
> @@ -289,8 +289,8 @@ int write_sparse_image(struct sparse_storage *info,
>  
>   case CHUNK_TYPE_CRC32:
>   if (chunk_header->total_sz !=
> - sparse_header->chunk_hdr_sz) {
> - info->mssg("Bogus chunk size for chunk type 
> Dont Care",
> + sparse_header->chunk_hdr_sz + sizeof(uint32_t)) {
> + info->mssg("Bogus chunk size for chunk type 
> CRC32",
>  response);
>   return -1;
>   }
> -- 
> 2.39.2


Re: [PATCH RESEND v2 1/2] cmd: bind: Try to improve the (un)bind help

2023-10-05 Thread Mattijs Korpershoek
On lun., oct. 02, 2023 at 15:46, Miquel Raynal  
wrote:

> While it may sound totally obvious for the regular U-Boot developer to
> get the parameters of the bind/unbind commands from the output of 'dm
> tree', it did not felt straightforward to me until I was explicitly
> told to look there. And even when I knew the command, I did not make a
> direct link between the arguments of this command and the columns
> returned by 'dm tree'.
>
> Several of us lost a lot of time because of that, I would like to kindly
> help other users by slightly improving this textual line. Unfortunately,
> because of how this string is used (like within the 'help' command) I
> cannot detail much more, but at least the pointer is there.
>
> Signed-off-by: Miquel Raynal 

Reviewed-by: Mattijs Korpershoek 

> ---
> Resend: no change.
>
> Changes in v2:
> * Moved the details in the long text section as suggested by Heinrich.
> * Rephrased the help text as well, not fully following Heinrich
>   suggestion, but taking inspiration from it.
> ---
>  cmd/bind.c | 4 
>  1 file changed, 4 insertions(+)
>
> diff --git a/cmd/bind.c b/cmd/bind.c
> index 4d1b7885e60..be0d4d2a711 100644
> --- a/cmd/bind.c
> +++ b/cmd/bind.c
> @@ -246,6 +246,8 @@ U_BOOT_CMD(
>   "Bind a device to a driver",
>   " \n"
>   "bind   \n"
> + "Use 'dm tree' to list all devices registered in the driver model,\n"
> + "their path, class, index and current driver.\n"
>  );
>  
>  U_BOOT_CMD(
> @@ -254,4 +256,6 @@ U_BOOT_CMD(
>   "\n"
>   "unbind  \n"
>   "unbind   \n"
> + "Use 'dm tree' to list all devices registered in the driver model,\n"
> + "their path, class, index and current driver.\n"
>  );
> -- 
> 2.34.1


Re: [PATCH RESEND v2 2/2] usb: udc: Try to clarify an error message

2023-10-05 Thread Mattijs Korpershoek
On lun., oct. 02, 2023 at 15:46, Miquel Raynal  
wrote:

> At some point when trying to use USB gadgets, two situations may arise
> and lead to a failure. Either the UDC (USB Device Controller) is not
> available at all (not described or not probed) or the UDC is already in
> use. For instance, as the USB Ethernet gadget remains bound to the UDC,
> the use of any other USB gadget (fastboot, dfu, etc) *after* will always
> fail with the "couldn't find an available UDC" error.
>
> Let's give a more helpful message by making a difference between the two
> cases. Let's also hint people who would get this error and grep it into
> the sources a better explanation of what's wrong with their workflow.
>
> Signed-off-by: Miquel Raynal 

Reviewed-by: Mattijs Korpershoek 

> ---
> While doing this I really wanted to add "much more" error comments but I
> faced another reality: often the messages are there but use
> pr_err/log_err which is actually silenced by default with LOGLEVEL=3, so
> I consider this unnecessary, as decreasing the loglevel will make these
> messages appear. I would have expected errors to be displayed, but I
> understand it makes the binaries even bigger.
>
> Resend: no change.
>
> Changes in v2:
> * s/UDC/UDCs/. I kept the sentence as it was as the suggested form did
>   not sound well at all when there is only one UDC.
> ---
>  drivers/usb/gadget/udc/udc-core.c | 13 -
>  1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/gadget/udc/udc-core.c 
> b/drivers/usb/gadget/udc/udc-core.c
> index 7f73926cb3e..8405b03462e 100644
> --- a/drivers/usb/gadget/udc/udc-core.c
> +++ b/drivers/usb/gadget/udc/udc-core.c
> @@ -323,6 +323,7 @@ err1:
>  int usb_gadget_probe_driver(struct usb_gadget_driver *driver)
>  {
>   struct usb_udc  *udc = NULL;
> + unsigned intudc_count = 0;
>   int ret;
>  
>   if (!driver || !driver->bind || !driver->setup)
> @@ -330,12 +331,22 @@ int usb_gadget_probe_driver(struct usb_gadget_driver 
> *driver)
>  
>   mutex_lock(&udc_lock);
>   list_for_each_entry(udc, &udc_list, list) {
> + udc_count++;
> +
>   /* For now we take the first one */
>   if (!udc->driver)
>   goto found;
>   }
>  
> - printf("couldn't find an available UDC\n");
> + if (!udc_count)
> + printf("No UDC available in the system\n");
> + else
> + /* When this happens, users should 'unbind  '
> +  * using the output of 'dm tree' and looking at the line right
> +  * after the USB peripheral/device controller.
> +  */
> + printf("All UDCs in use (%d available), use the unbind 
> command\n",
> +udc_count);
>   mutex_unlock(&udc_lock);
>   return -ENODEV;
>  found:
> -- 
> 2.34.1


[PATCH 0/2] MAINTAINERS: Add Mattijs to USB/fastboot maintainers

2023-10-05 Thread Mattijs Korpershoek
>From discussions with Marek at Kernel Recipes, it seems that the USB
subsystem in U-boot need some help.

Since I've been asked and I'm willing to help, I've added myself to the
maintainers entry.

I have also added myself for fastboot since I'm interested in keeping
that functional as well.

Note that I have no previous (open-source) maintainer experience so I
will do my best to learn.

Signed-off-by: Mattijs Korpershoek 
---
Mattijs Korpershoek (2):
  MAINTAINERS: usb gadget: add Mattijs
  MAINTAINERS: fastboot: add Mattijs

 MAINTAINERS | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
---
base-commit: 65b9b3462bec2966911658836983819ab4e4823e
change-id: 20231005-mattijs-usb-6b83dde256f0

Best regards,
-- 
Mattijs Korpershoek 



[PATCH 1/2] MAINTAINERS: usb gadget: add Mattijs

2023-10-05 Thread Mattijs Korpershoek
It seems that Lukasz and Marek could get some help in maintaining the
usb gadget drivers.

Assign myself as maintainer.

Signed-off-by: Mattijs Korpershoek 
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 4df79254dfe1..008c593f30ee 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -945,6 +945,7 @@ F:  include/cyclic.h
 
 DFU
 M: Lukasz Majewski 
+M: Mattijs Korpershoek 
 S: Maintained
 T: git https://source.denx.de/u-boot/custodians/u-boot-dfu.git
 F: cmd/dfu.c

-- 
2.41.0



[PATCH 2/2] MAINTAINERS: fastboot: add Mattijs

2023-10-05 Thread Mattijs Korpershoek
Fastboot has been marked as orphaned since 2021.
Since I'm interested in maintaining this, assign myself.

Signed-off-by: Mattijs Korpershoek 
---
 MAINTAINERS | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 008c593f30ee..6790f4ddbd45 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1052,7 +1052,8 @@ F:test/common/event.c
 F: test/py/tests/test_event_dump.py
 
 FASTBOOT
-S: Orphaned
+M: Mattijs Korpershoek 
+S: Maintained
 F: cmd/fastboot.c
 F: doc/android/fastboot*.rst
 F: include/fastboot.h

-- 
2.41.0



Re: [PATCH v2 0/8] Add DFU, emmc and usb boot for TI am62x

2023-05-10 Thread Mattijs Korpershoek
Hi Sjoerd,

Thank you for this series.

On jeu., avril 06, 2023 at 20:55, Sjoerd Simons  wrote:

> This series adds more boot sources for the TI am62x. For that the dts'
> are synced from the upstream ti-next git tree (to add usb nodes), some
> dwc3 glue is and finally the default configuration is tuned to add
> support for DFU and USB (host and gadget)
>
>
> Changes in v2:
> - Update dts sync to v6.3-rc5
> - Switch dwc3 glue to a seperate driver rather then in dwc-generic
> - Minimize config changes to just DFU configuration
> - Only enable usb port 0 DFU in SPL
> - Create a seperate defconfig for R5
>
> Sjoerd Simons (8):
>   omap: timer: add ti,am654-timer compatibility
>   arm: mach-k3: am62: Add timer0 id to the dev list
>   arm: dts: k3-am62: Bump dtsi from linux
>   arm: dts: k3-am625-sk: Enable emmc in SPL
>   usb: dwc3: Add dwc3 glue driver for am62
>   configs: am62: Add configs for enabling USB in U-Boot
>   arm: dts: k3-am625-sk: Enable usb ports in u-boot
>   configs: am62x_evm_*: Enable USB and DFU support

I've tested USB support on AM62x SK EVM for this whole series based on a
public TI integration branch:

https://git.ti.com/cgit/ti-u-boot/ti-u-boot/log/?h=ti-u-boot-2023.04-next

I did not test DFU, however with some small config changes I could test
fastboot support using:

=> fastboot usb 0

Then from host:
$ fastboot devices
$ fastboot flash  

Tested-by: Mattijs Korpershoek 

>
>  arch/arm/dts/k3-am62-main.dtsi| 259 +++---
>  arch/arm/dts/k3-am62-mcu.dtsi |  49 +
>  arch/arm/dts/k3-am62-wakeup.dtsi  |   4 +-
>  arch/arm/dts/k3-am625-r5-sk.dts   |   2 +-
>  arch/arm/dts/k3-am625-sk-u-boot.dtsi  |  27 ++-
>  arch/arm/dts/k3-am625-sk.dts  |  95 +-
>  arch/arm/dts/k3-am625.dtsi|  52 ++
>  arch/arm/mach-k3/am62x/dev-data.c |   1 +
>  configs/am62x_evm_a53_defconfig   |  35 +++-
>  configs/am62x_evm_r5_usbdfu_defconfig | 116 
>  drivers/timer/omap-timer.c|   1 +
>  drivers/usb/dwc3/Kconfig  |  14 ++
>  drivers/usb/dwc3/Makefile |   1 +
>  drivers/usb/dwc3/dwc3-am62.c  | 127 +
>  include/configs/am62x_evm.h   |  10 +-
>  15 files changed, 701 insertions(+), 92 deletions(-)
>  create mode 100644 configs/am62x_evm_r5_usbdfu_defconfig
>  create mode 100644 drivers/usb/dwc3/dwc3-am62.c
>
> -- 
> 2.40.0


Re: [PATCH 4/8] bootstd: Correct creating of bootdev sibling

2023-07-28 Thread Mattijs Korpershoek
On jeu., juil. 27, 2023 at 20:37, Simon Glass  wrote:

> Use the correct function here, since there may be multiple IDE devices
> available.
>
> Signed-off-by: Simon Glass 

Reviewed-by: Mattijs Korpershoek 

> ---
>
>  drivers/block/ide.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/block/ide.c b/drivers/block/ide.c
> index 89201dd4d229..c698f9cbd558 100644
> --- a/drivers/block/ide.c
> +++ b/drivers/block/ide.c
> @@ -1059,9 +1059,9 @@ static int ide_probe(struct udevice *udev)
>   desc->lba48 = pdesc.lba48;
>   desc->type = pdesc.type;
>  
> - ret = bootdev_setup_for_dev(udev, "ide_bootdev");
> + ret = bootdev_setup_for_sibling_blk(blk, "ide_bootdev");
>   if (ret)
> - return log_msg_ret("bootdev", ret);
> + return log_msg_ret("bd", ret);
>   }
>  
>   return 0;
> -- 
> 2.41.0.487.g6d72f3e995-goog


Re: [PATCH 3/8] bootstd: Rename bootdev_setup_sibling_blk()

2023-07-28 Thread Mattijs Korpershoek
On jeu., juil. 27, 2023 at 20:37, Simon Glass  wrote:

> This name is a little confusing since it suggests that it sets up the
> sibling block device. In fact it sets up a bootdev for it. Rename the
> function to make this clearer.
>
> Signed-off-by: Simon Glass 
> ---
>
>  boot/bootdev-uclass.c  | 8 +---
>  common/usb_storage.c   | 2 +-
>  doc/develop/bootstd.rst| 4 ++--
>  drivers/mmc/mmc-uclass.c   | 2 +-
>  drivers/nvme/nvme.c| 2 +-
>  drivers/scsi/scsi.c| 2 +-
>  drivers/virtio/virtio-uclass.c | 2 +-
>  include/bootdev.h  | 8 
>  8 files changed, 16 insertions(+), 14 deletions(-)
>
> diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c
> index 9660ff75676d..114853ffb72a 100644
> --- a/boot/bootdev-uclass.c
> +++ b/boot/bootdev-uclass.c
> @@ -262,7 +262,7 @@ static int bootdev_get_suffix_start(struct udevice *dev, 
> const char *suffix)
>   return len;
>  }
>  
> -int bootdev_setup_sibling_blk(struct udevice *blk, const char *drv_name)
> +int bootdev_setup_for_sibling_blk(struct udevice *blk, const char *drv_name)
>  {
>   struct udevice *parent, *dev;
>   char dev_name[50];
> @@ -305,7 +305,9 @@ int bootdev_get_sibling_blk(struct udevice *dev, struct 
> udevice **blkp)
>   if (device_get_uclass_id(dev) != UCLASS_BOOTDEV)
>   return -EINVAL;
>  
> - /* This should always work if bootdev_setup_sibling_blk() was used */
> + /*
> +  * This should always work if bootdev_setup_for_sibling_blk() was used
> +  */
>   len = bootdev_get_suffix_start(dev, ".bootdev");
>   ret = device_find_child_by_namelen(parent, dev->name, len, &blk);
>   if (ret) {
> @@ -335,7 +337,7 @@ static int bootdev_get_from_blk(struct udevice *blk, 
> struct udevice **bootdevp)
>   if (device_get_uclass_id(blk) != UCLASS_BLK)
>   return -EINVAL;
>  
> - /* This should always work if bootdev_setup_sibling_blk() was used */
> + /* This should always work if bootdev_setup_for_sibling_blk() was used 
> */
>   len = bootdev_get_suffix_start(blk, ".blk");
>   snprintf(dev_name, sizeof(dev_name), "%.*s.%s", len, blk->name,
>"bootdev");
> diff --git a/common/usb_storage.c b/common/usb_storage.c
> index ac6427577379..85774220ef2a 100644
> --- a/common/usb_storage.c
> +++ b/common/usb_storage.c
> @@ -246,7 +246,7 @@ static int usb_stor_probe_device(struct usb_device *udev)
>   if (ret)
>   return ret;
>  
> - ret = bootdev_setup_sibling_blk(dev, "usb_bootdev");
> + ret = bootdev_setup_for_sibling_blk(dev, "usb_bootdev");
>   if (ret) {
>   int ret2;
>  
> diff --git a/doc/develop/bootstd.rst b/doc/develop/bootstd.rst
> index 7a2a69fdfcec..ec3136535783 100644
> --- a/doc/develop/bootstd.rst
> +++ b/doc/develop/bootstd.rst
> @@ -306,7 +306,7 @@ media device::
>  
>  The bootdev device is typically created automatically in the media uclass'
>  `post_bind()` method by calling `bootdev_setup_for_dev()` or
> -`bootdev_setup_sibling_blk()`. The code typically something like this::
> +`bootdev_setup_for_sibling_blk()`. The code typically something like this::
>  
>  /* dev is the Ethernet device */
>  ret = bootdev_setup_for_dev(dev, "eth_bootdev");
> @@ -316,7 +316,7 @@ The bootdev device is typically created automatically in 
> the media uclass'
>  or::
>  
>  /* blk is the block device (child of MMC device)
> -ret = bootdev_setup_sibling_blk(blk, "mmc_bootdev");
> +ret = bootdev_setup_for_sibling_blk(blk, "mmc_bootdev");
>  if (ret)
>  return log_msg_ret("bootdev", ret);
>  
> diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c
> index 01d9b0201f2c..0e157672eae0 100644
> --- a/drivers/mmc/mmc-uclass.c
> +++ b/drivers/mmc/mmc-uclass.c
> @@ -421,7 +421,7 @@ int mmc_bind(struct udevice *dev, struct mmc *mmc, const 
> struct mmc_config *cfg)
>   mmc->cfg = cfg;
>   mmc->priv = dev;
>  
> - ret = bootdev_setup_sibling_blk(bdev, "mmc_bootdev");
> + ret = bootdev_setup_for_sibling_blk(bdev, "mmc_bootdev");
>   if (ret)
>   return log_msg_ret("bootdev", ret);
>  
> diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c
> index a7add66ab4d1..20dc910d8a33 100644
> --- a/drivers/nvme/nvme.c
> +++ b/drivers/nvme/nvme.c
> @@ -910,7 +910,7 @@ int nvme_init(struct udevice *udev)
>   if (ret)
>   goto free_id;
>  
> - ret = bootdev_setup_sibling_blk(ns_udev, "nvme_bootdev");
> + ret = bootdev_setup_for_sibling_blk(ns_udev, "nvme_bootdev");
>   if (ret)
>   return log_msg_ret("bootdev", ret);
>  
> diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
> index 6caeb3fcdd0d..0a3420b7fbc2 100644
> --- a/drivers/scsi/scsi.c
> +++ b/drivers/scsi/scsi.c
> @@ -607,7 +607,7 @@ static int do_scsi_scan_one(struct udevice *dev, int id, 
> int lun

Re: [PATCH v2 4/9] bootstd: Rename bootdev_setup_sibling_blk()

2023-07-31 Thread Mattijs Korpershoek
On dim., juil. 30, 2023 at 11:15, Simon Glass  wrote:

> This name is a little confusing since it suggests that it sets up the
> sibling block device. In fact it sets up a bootdev for it. Rename the
> function to make this clearer.
>
> Signed-off-by: Simon Glass 

Reviewed-by: Mattijs Korpershoek 

> ---
>
> Changes in v2:
> - Fix the function name in the header as well
>
>  boot/bootdev-uclass.c  |  8 +---
>  common/usb_storage.c   |  2 +-
>  doc/develop/bootstd.rst|  4 ++--
>  drivers/mmc/mmc-uclass.c   |  2 +-
>  drivers/nvme/nvme.c|  2 +-
>  drivers/scsi/scsi.c|  2 +-
>  drivers/virtio/virtio-uclass.c |  2 +-
>  include/bootdev.h  | 10 +-
>  8 files changed, 17 insertions(+), 15 deletions(-)
>
> diff --git a/boot/bootdev-uclass.c b/boot/bootdev-uclass.c
> index 9660ff75676d..114853ffb72a 100644
> --- a/boot/bootdev-uclass.c
> +++ b/boot/bootdev-uclass.c
> @@ -262,7 +262,7 @@ static int bootdev_get_suffix_start(struct udevice *dev, 
> const char *suffix)
>   return len;
>  }
>  
> -int bootdev_setup_sibling_blk(struct udevice *blk, const char *drv_name)
> +int bootdev_setup_for_sibling_blk(struct udevice *blk, const char *drv_name)
>  {
>   struct udevice *parent, *dev;
>   char dev_name[50];
> @@ -305,7 +305,9 @@ int bootdev_get_sibling_blk(struct udevice *dev, struct 
> udevice **blkp)
>   if (device_get_uclass_id(dev) != UCLASS_BOOTDEV)
>   return -EINVAL;
>  
> - /* This should always work if bootdev_setup_sibling_blk() was used */
> + /*
> +  * This should always work if bootdev_setup_for_sibling_blk() was used
> +  */
>   len = bootdev_get_suffix_start(dev, ".bootdev");
>   ret = device_find_child_by_namelen(parent, dev->name, len, &blk);
>   if (ret) {
> @@ -335,7 +337,7 @@ static int bootdev_get_from_blk(struct udevice *blk, 
> struct udevice **bootdevp)
>   if (device_get_uclass_id(blk) != UCLASS_BLK)
>   return -EINVAL;
>  
> - /* This should always work if bootdev_setup_sibling_blk() was used */
> + /* This should always work if bootdev_setup_for_sibling_blk() was used 
> */
>   len = bootdev_get_suffix_start(blk, ".blk");
>   snprintf(dev_name, sizeof(dev_name), "%.*s.%s", len, blk->name,
>"bootdev");
> diff --git a/common/usb_storage.c b/common/usb_storage.c
> index ac6427577379..85774220ef2a 100644
> --- a/common/usb_storage.c
> +++ b/common/usb_storage.c
> @@ -246,7 +246,7 @@ static int usb_stor_probe_device(struct usb_device *udev)
>   if (ret)
>   return ret;
>  
> - ret = bootdev_setup_sibling_blk(dev, "usb_bootdev");
> + ret = bootdev_setup_for_sibling_blk(dev, "usb_bootdev");
>   if (ret) {
>   int ret2;
>  
> diff --git a/doc/develop/bootstd.rst b/doc/develop/bootstd.rst
> index 7a2a69fdfcec..ec3136535783 100644
> --- a/doc/develop/bootstd.rst
> +++ b/doc/develop/bootstd.rst
> @@ -306,7 +306,7 @@ media device::
>  
>  The bootdev device is typically created automatically in the media uclass'
>  `post_bind()` method by calling `bootdev_setup_for_dev()` or
> -`bootdev_setup_sibling_blk()`. The code typically something like this::
> +`bootdev_setup_for_sibling_blk()`. The code typically something like this::
>  
>  /* dev is the Ethernet device */
>  ret = bootdev_setup_for_dev(dev, "eth_bootdev");
> @@ -316,7 +316,7 @@ The bootdev device is typically created automatically in 
> the media uclass'
>  or::
>  
>  /* blk is the block device (child of MMC device)
> -ret = bootdev_setup_sibling_blk(blk, "mmc_bootdev");
> +ret = bootdev_setup_for_sibling_blk(blk, "mmc_bootdev");
>  if (ret)
>  return log_msg_ret("bootdev", ret);
>  
> diff --git a/drivers/mmc/mmc-uclass.c b/drivers/mmc/mmc-uclass.c
> index 01d9b0201f2c..0e157672eae0 100644
> --- a/drivers/mmc/mmc-uclass.c
> +++ b/drivers/mmc/mmc-uclass.c
> @@ -421,7 +421,7 @@ int mmc_bind(struct udevice *dev, struct mmc *mmc, const 
> struct mmc_config *cfg)
>   mmc->cfg = cfg;
>   mmc->priv = dev;
>  
> - ret = bootdev_setup_sibling_blk(bdev, "mmc_bootdev");
> + ret = bootdev_setup_for_sibling_blk(bdev, "mmc_bootdev");
>   if (ret)
>   return log_msg_ret("bootdev", ret);
>  
> diff --git a/drivers/nvme/nvme.c b/drivers/nvme/nvme.c
> index a7add66ab4d1..20dc910d8a33 100644
> --- a/drivers/nvme/nvme.c
> +++ b/drivers/nvme/nvme.c
>

Re: [PATCH v2 2/3] arm/mach-meson: move smc commands in cmd/meson

2022-12-14 Thread Mattijs Korpershoek
[2], NULL, 0);
> -
> -address = simple_strtoul(argv[3], NULL, 0);
> -
> - ret = meson_sm_write_efuse(offset, (void *)address, size);
> - if (ret != size)
> - return CMD_RET_FAILURE;
> -
> - return CMD_RET_SUCCESS;
> -}
> -
> -static struct cmd_tbl cmd_sm_sub[] = {
> - U_BOOT_CMD_MKENT(serial, 2, 1, do_sm_serial, "", ""),
> - U_BOOT_CMD_MKENT(reboot_reason, 1, 1, do_sm_reboot_reason, "", ""),
> - U_BOOT_CMD_MKENT(efuseread, 4, 1, do_efuse_read, "", ""),
> - U_BOOT_CMD_MKENT(efusewrite, 4, 0, do_efuse_write, "", ""),
> -};
> -
> -static int do_sm(struct cmd_tbl *cmdtp, int flag, int argc,
> -  char *const argv[])
> -{
> - struct cmd_tbl *c;
> -
> - if (argc < 2)
> - return CMD_RET_USAGE;
> -
> - /* Strip off leading 'sm' command argument */
> - argc--;
> - argv++;
> -
> - c = find_cmd_tbl(argv[0], &cmd_sm_sub[0], ARRAY_SIZE(cmd_sm_sub));
> -
> - if (c)
> - return c->cmd(cmdtp, flag, argc, argv);
> - else
> - return CMD_RET_USAGE;
> -}
> -
> -U_BOOT_CMD(
> - sm, 5, 0, do_sm,
> - "Secure Monitor Control",
> - "serial  - read chip unique id to memory address\n"
> - "sm reboot_reason [name] - get reboot reason and store to to 
> environment\n"
> - "sm efuseread- read efuse to memory 
> address\n"
> - "sm efusewrite- write into efuse from memory 
> address"
> -);
> diff --git a/cmd/Kconfig b/cmd/Kconfig
> index 09193b61b95..07833f958e7 100644
> --- a/cmd/Kconfig
> +++ b/cmd/Kconfig
> @@ -2565,4 +2565,11 @@ config MMC_SPEED_MODE_SET
> and is indicated using the index from enum bus_mode in
> include/mmc.h. A speed mode can be set only if it has already
> been enabled in the device tree.
> +
> +config CMD_MESON
> + bool "Amlogic Meson commands"
> + depends on ARCH_MESON
> + default y
> + help
> +   Enable useful commands for the Meson Soc family developed by Amlogic 
> Inc.
>  endmenu
> diff --git a/cmd/Makefile b/cmd/Makefile
> index 5e43a1e022e..146c5ebb227 100644
> --- a/cmd/Makefile
> +++ b/cmd/Makefile
> @@ -210,6 +210,9 @@ obj-$(CONFIG_RISCV) += riscv/
>  obj-$(CONFIG_SANDBOX) += sandbox/
>  obj-$(CONFIG_X86) += x86/
>  
> +# Meson
> +obj-$(CONFIG_CMD_MESON) += meson/
> +
>  obj-$(CONFIG_ARCH_MVEBU) += mvebu/
>  endif # !CONFIG_SPL_BUILD
>  
> diff --git a/cmd/meson/Makefile b/cmd/meson/Makefile
> new file mode 100644
> index 000..ee26c175cfe
> --- /dev/null
> +++ b/cmd/meson/Makefile
> @@ -0,0 +1,5 @@
> +# SPDX-License-Identifier: GPL-2.0+
> +#
> +# Copyright (c) 2022, SberDevices. All rights reserved.
> +
> +obj-y += sm.o
> diff --git a/cmd/meson/sm.c b/cmd/meson/sm.c
> new file mode 100644
> index 000..1a3a2c7920a
> --- /dev/null
> +++ b/cmd/meson/sm.c
> @@ -0,0 +1,154 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright (c) 2022, SberDevices. All rights reserved.
> + *
> + * Author: Alexey Romanov 

Sorry to be pedantic, but since we moved a lot of code from
arch/arm/mach-meson/ here, shouldn't we keep the copyright from that
file as well?

In other words, keep the following line:

(C) Copyright 2016 Beniamino Galvani 

With that, please add

Reviewed-by: Mattijs Korpershoek 

> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +static int do_sm_serial(struct cmd_tbl *cmdtp, int flag, int argc,
> + char *const argv[])
> +{
> + ulong address;
> + int ret;
> +
> + if (argc < 2)
> + return CMD_RET_USAGE;
> +
> + address = simple_strtoul(argv[1], NULL, 0);
> +
> + ret = meson_sm_get_serial((void *)address, SM_SERIAL_SIZE);
> + if (ret)
> + return CMD_RET_FAILURE;
> +
> + return CMD_RET_SUCCESS;
> +}
> +
> +#define MAX_REBOOT_REASONS 14
> +
> +static const char *reboot_reasons[MAX_REBOOT_REASONS] = {
> + [REBOOT_REASON_COLD] = "cold_boot",
> + [REBOOT_REASON_NORMAL] = "normal",
> + [REBOOT_REASON_RECOVERY] = "recovery",
> + [REBOOT_REASON_UPDATE] = "update",
> + [REBOOT_REASON_FASTBOOT] = "fastboot",
> + [REBOOT_REASON_SUSPEND_OFF] = "suspend_off",
> + [REBOOT_REASON_HIBERNATE] = "hibernate",
> + [REBOOT_REASON_BOOTLOADER] = "bootloader",
> + [REBOOT_REASON_SHUTDOWN_REBOOT] = "shutdown_reboot&q

Re: [PATCH 0/2] mach-meson: port dwc2_otg usage to CONFIG_DM_USB_GADGET=y

2022-12-14 Thread Mattijs Korpershoek
Hi Neil,

On Thu, Nov 24, 2022 at 10:34, Neil Armstrong  wrote:

> Hi Mattijs,
>
> On 23/11/2022 16:42, Mattijs Korpershoek wrote:
>> While working on some USB bugs on the VIM3L board, we stumbled upon the fact
>> that mach-meson still uses legacy board_usb_*() functions instead of using 
>> DM [1]
>> 
>> This series aim to switch the g12a based boards to use CONFIG_DM_USB_GADGET 
>> and
>> removes the board_usb_*() logic.
>> 
>> * The first patch adds mode switching in the dwc3-meson-g12a glue driver 
>> whenever
>>the dwc2 otg driver is probed()/removed().
>> 
>> * The second patch enables the config option and cleans up all board_usb_*().
>> 
>> This has been mainly tested with khadas-vim3l_android_defconfig using 
>> fastboot:
>> 
>> => fastboot usb 0
>> 
>> => # hit Ctrl-c
>> 
>> Other tests:
>> * ums 0 mmc 2 # can list / mount partitions from host
>> * usb start; usb storage # list usb thumb drive
>> * all defconfigs have been build tested
>> 
>> [1] 
>> https://lore.kernel.org/u-boot/938b9439-9014-5ee8-1627-16af508bf...@linaro.org/
>> Signed-off-by: Mattijs Korpershoek 
>
> I'll run some tests on other G12 boards but so far this looks very good, 
> thanks !

I got my hands on an odroid-c4 board and I also tested:
=> fastboot usb 0
=> # hit Ctrl-c
# disconnection is ok

And tested "usb start" and could list a usb thumb drive.

Any other tests you would like me to do?

>
> Neil
>
>> 
>> ---
>> Mattijs Korpershoek (2):
>>usb: dwc3-meson-g12a: force mode on child add/removal
>>ARM: meson: g12a: switch dwc2 otg to DM
>> 
>>   arch/arm/mach-meson/board-g12a.c  | 127 
>> --
>>   configs/bananapi-m5_defconfig |   1 +
>>   configs/beelink-gsking-x_defconfig|   1 +
>>   configs/beelink-gtking_defconfig  |   1 +
>>   configs/beelink-gtkingpro_defconfig   |   1 +
>>   configs/khadas-vim3_android_ab_defconfig  |   1 +
>>   configs/khadas-vim3_android_defconfig |   1 +
>>   configs/khadas-vim3_defconfig |   1 +
>>   configs/khadas-vim3l_android_ab_defconfig |   1 +
>>   configs/khadas-vim3l_android_defconfig|   1 +
>>   configs/khadas-vim3l_defconfig|   1 +
>>   configs/odroid-c4_defconfig   |   1 +
>>   configs/odroid-hc4_defconfig  |   1 +
>>   configs/odroid-n2_defconfig   |   1 +
>>   configs/radxa-zero_defconfig  |   1 +
>>   configs/sei510_defconfig  |   1 +
>>   configs/sei610_defconfig  |   1 +
>>   configs/u200_defconfig|   1 +
>>   drivers/usb/dwc3/dwc3-meson-g12a.c|  18 +
>>   19 files changed, 35 insertions(+), 127 deletions(-)
>> ---
>> base-commit: 7b70f68977578360d9c47bb25d6d1937075153b4
>> change-id: 20221024-meson-dm-usb-60e413696519
>> 
>> Best regards,


Re: [PATCH] fastboot: remove #ifdef CONFIG when it is possible

2022-12-15 Thread Mattijs Korpershoek
On Thu, Dec 15, 2022 at 10:15, Patrick Delaunay  
wrote:

> Much of the fastboot code predates the introduction of Kconfig and
> has quite a few #ifdefs in it which is unnecessary now that we can use
> IS_ENABLED() et al.
>
> Signed-off-by: Patrick Delaunay 

Hi Patrick,

Thank you for this, it's a nice improvement!

I will test this on vim3l tomorrow, but I've already reviewed it:

Reviewed-by: Mattijs Korpershoek 

> ---
>
>  cmd/fastboot.c  |  35 +--
>  drivers/fastboot/fb_command.c   | 104 
>  drivers/fastboot/fb_common.c|  11 ++--
>  drivers/fastboot/fb_getvar.c|  49 ++-
>  drivers/usb/gadget/f_fastboot.c |   7 +--
>  include/fastboot.h  |  13 
>  net/fastboot.c  |   8 +--
>  7 files changed, 82 insertions(+), 145 deletions(-)
>
> diff --git a/cmd/fastboot.c b/cmd/fastboot.c
> index b498e4b22bb3..b94dbd548843 100644
> --- a/cmd/fastboot.c
> +++ b/cmd/fastboot.c
> @@ -19,8 +19,14 @@
>  static int do_fastboot_udp(int argc, char *const argv[],
>  uintptr_t buf_addr, size_t buf_size)
>  {
> -#if CONFIG_IS_ENABLED(UDP_FUNCTION_FASTBOOT)
> - int err = net_loop(FASTBOOT);
> + int err;
> +
> + if (!CONFIG_IS_ENABLED(UDP_FUNCTION_FASTBOOT)) {
> + pr_err("Fastboot UDP not enabled\n");
> + return CMD_RET_FAILURE;
> + }
> +
> + err = net_loop(FASTBOOT);
>  
>   if (err < 0) {
>   printf("fastboot udp error: %d\n", err);
> @@ -28,21 +34,21 @@ static int do_fastboot_udp(int argc, char *const argv[],
>   }
>  
>   return CMD_RET_SUCCESS;
> -#else
> - pr_err("Fastboot UDP not enabled\n");
> - return CMD_RET_FAILURE;
> -#endif
>  }
>  
>  static int do_fastboot_usb(int argc, char *const argv[],
>  uintptr_t buf_addr, size_t buf_size)
>  {
> -#if CONFIG_IS_ENABLED(USB_FUNCTION_FASTBOOT)
>   int controller_index;
>   char *usb_controller;
>   char *endp;
>   int ret;
>  
> + if (!CONFIG_IS_ENABLED(USB_FUNCTION_FASTBOOT)) {
> + pr_err("Fastboot USB not enabled\n");
> + return CMD_RET_FAILURE;
> + }
> +
>   if (argc < 2)
>   return CMD_RET_USAGE;
>  
> @@ -88,10 +94,6 @@ exit:
>   g_dnl_clear_detach();
>  
>   return ret;
> -#else
> - pr_err("Fastboot USB not enabled\n");
> - return CMD_RET_FAILURE;
> -#endif
>  }
>  
>  static int do_fastboot(struct cmd_tbl *cmdtp, int flag, int argc,
> @@ -148,17 +150,12 @@ NXTARG:
>   return do_fastboot_usb(argc, argv, buf_addr, buf_size);
>  }
>  
> -#ifdef CONFIG_SYS_LONGHELP
> -static char fastboot_help_text[] =
> +U_BOOT_CMD(
> + fastboot, CONFIG_SYS_MAXARGS, 1, do_fastboot,
> + "run as a fastboot usb or udp device",
>   "[-l addr] [-s size] usb  | udp\n"
>   "\taddr - address of buffer used during data transfers ("
>   __stringify(CONFIG_FASTBOOT_BUF_ADDR) ")\n"
>   "\tsize - size of buffer used during data transfers ("
>   __stringify(CONFIG_FASTBOOT_BUF_SIZE) ")"
> - ;
> -#endif
> -
> -U_BOOT_CMD(
> - fastboot, CONFIG_SYS_MAXARGS, 1, do_fastboot,
> - "run as a fastboot usb or udp device", fastboot_help_text
>  );
> diff --git a/drivers/fastboot/fb_command.c b/drivers/fastboot/fb_command.c
> index bdfdf262c8a3..f0fd605854da 100644
> --- a/drivers/fastboot/fb_command.c
> +++ b/drivers/fastboot/fb_command.c
> @@ -31,27 +31,16 @@ static u32 fastboot_bytes_expected;
>  static void okay(char *, char *);
>  static void getvar(char *, char *);
>  static void download(char *, char *);
> -#if CONFIG_IS_ENABLED(FASTBOOT_FLASH)
>  static void flash(char *, char *);
>  static void erase(char *, char *);
> -#endif
>  static void reboot_bootloader(char *, char *);
>  static void reboot_fastbootd(char *, char *);
>  static void reboot_recovery(char *, char *);
> -#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_FORMAT)
>  static void oem_format(char *, char *);
> -#endif
> -#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_PARTCONF)
>  static void oem_partconf(char *, char *);
> -#endif
> -#if CONFIG_IS_ENABLED(FASTBOOT_CMD_OEM_BOOTBUS)
>  static void oem_bootbus(char *, char *);
> -#endif
> -
> -#if CONFIG_IS_ENABLED(FASTBOOT_UUU_SUPPORT)
>  static void run_ucmd(char *, char *);
>  static void run_acmd(char *, char *);
> -#endif
>  
>  static const struct {
>   const char *command;
> @@ -65,16 +54,14 @@ static const struct {
>  

Re: [PATCH] fastboot: remove #ifdef CONFIG when it is possible

2022-12-15 Thread Mattijs Korpershoek
On Thu, Dec 15, 2022 at 14:45, Mattijs Korpershoek  
wrote:

> On Thu, Dec 15, 2022 at 10:15, Patrick Delaunay 
>  wrote:
>
>> Much of the fastboot code predates the introduction of Kconfig and
>> has quite a few #ifdefs in it which is unnecessary now that we can use
>> IS_ENABLED() et al.
>>
>> Signed-off-by: Patrick Delaunay 
>
> Hi Patrick,
>
> Thank you for this, it's a nice improvement!
>
> I will test this on vim3l tomorrow, but I've already reviewed it:
>
> Reviewed-by: Mattijs Korpershoek 

Did a bootloader reflash to MMC following commands from [1]

Tested-by: Mattijs Korpershoek  # on vim3l


[1] https://source.android.com/docs/setup/create/devices#vim3-fastboot

>
>> ---
>>
>>  cmd/fastboot.c  |  35 +--
>>  drivers/fastboot/fb_command.c   | 104 
>>  drivers/fastboot/fb_common.c|  11 ++--
>>  drivers/fastboot/fb_getvar.c|  49 ++-
>>  drivers/usb/gadget/f_fastboot.c |   7 +--
>>  include/fastboot.h  |  13 
>>  net/fastboot.c  |   8 +--
>>  7 files changed, 82 insertions(+), 145 deletions(-)
>>
>> diff --git a/cmd/fastboot.c b/cmd/fastboot.c
>> index b498e4b22bb3..b94dbd548843 100644
>> --- a/cmd/fastboot.c
>> +++ b/cmd/fastboot.c
>> @@ -19,8 +19,14 @@
>>  static int do_fastboot_udp(int argc, char *const argv[],
>> uintptr_t buf_addr, size_t buf_size)
>>  {
>> -#if CONFIG_IS_ENABLED(UDP_FUNCTION_FASTBOOT)
>> -int err = net_loop(FASTBOOT);
>> +int err;
>> +
>> +if (!CONFIG_IS_ENABLED(UDP_FUNCTION_FASTBOOT)) {
>> +pr_err("Fastboot UDP not enabled\n");
>> +return CMD_RET_FAILURE;
>> +}
>> +
>> +err = net_loop(FASTBOOT);
>>  
>>  if (err < 0) {
>>  printf("fastboot udp error: %d\n", err);
>> @@ -28,21 +34,21 @@ static int do_fastboot_udp(int argc, char *const argv[],
>>  }
>>  
>>  return CMD_RET_SUCCESS;
>> -#else
>> -pr_err("Fastboot UDP not enabled\n");
>> -return CMD_RET_FAILURE;
>> -#endif
>>  }
>>  
>>  static int do_fastboot_usb(int argc, char *const argv[],
>> uintptr_t buf_addr, size_t buf_size)
>>  {
>> -#if CONFIG_IS_ENABLED(USB_FUNCTION_FASTBOOT)
>>  int controller_index;
>>  char *usb_controller;
>>  char *endp;
>>  int ret;
>>  
>> +if (!CONFIG_IS_ENABLED(USB_FUNCTION_FASTBOOT)) {
>> +pr_err("Fastboot USB not enabled\n");
>> +return CMD_RET_FAILURE;
>> +}
>> +
>>  if (argc < 2)
>>  return CMD_RET_USAGE;
>>  
>> @@ -88,10 +94,6 @@ exit:
>>  g_dnl_clear_detach();
>>  
>>  return ret;
>> -#else
>> -pr_err("Fastboot USB not enabled\n");
>> -return CMD_RET_FAILURE;
>> -#endif
>>  }
>>  
>>  static int do_fastboot(struct cmd_tbl *cmdtp, int flag, int argc,
>> @@ -148,17 +150,12 @@ NXTARG:
>>  return do_fastboot_usb(argc, argv, buf_addr, buf_size);
>>  }
>>  
>> -#ifdef CONFIG_SYS_LONGHELP
>> -static char fastboot_help_text[] =
>> +U_BOOT_CMD(
>> +fastboot, CONFIG_SYS_MAXARGS, 1, do_fastboot,
>> +"run as a fastboot usb or udp device",
>>  "[-l addr] [-s size] usb  | udp\n"
>>  "\taddr - address of buffer used during data transfers ("
>>  __stringify(CONFIG_FASTBOOT_BUF_ADDR) ")\n"
>>  "\tsize - size of buffer used during data transfers ("
>>  __stringify(CONFIG_FASTBOOT_BUF_SIZE) ")"
>> -;
>> -#endif
>> -
>> -U_BOOT_CMD(
>> -fastboot, CONFIG_SYS_MAXARGS, 1, do_fastboot,
>> -"run as a fastboot usb or udp device", fastboot_help_text
>>  );
>> diff --git a/drivers/fastboot/fb_command.c b/drivers/fastboot/fb_command.c
>> index bdfdf262c8a3..f0fd605854da 100644
>> --- a/drivers/fastboot/fb_command.c
>> +++ b/drivers/fastboot/fb_command.c
>> @@ -31,27 +31,16 @@ static u32 fastboot_bytes_expected;
>>  static void okay(char *, char *);
>>  static void getvar(char *, char *);
>>  static void download(char *, char *);
>> -#if CONFIG_IS_ENABLED(FASTBOOT_FLASH)
>>  static void flash(char *, char *);
>>  static void erase(char *, char *);
>> -#endif
>>  static void reboot_bootloader(char *, char *);
>>  static void reboot_fastbootd(ch

  1   2   3   4   5   6   7   8   9   >