Re: [PATCH 1/2] cmd: efidebug: add uri device path

2023-08-27 Thread Masahisa Kojima
Hi Heinrich,

On Sat, 26 Aug 2023 at 11:20, Heinrich Schuchardt  wrote:
>
> On 8/25/23 07:57, Masahisa Kojima wrote:
> > On Thu, 24 Aug 2023 at 09:11, AKASHI Takahiro
> >  wrote:
> >>
> >> Hi Kojima-san,
> >>
> >> On Wed, Aug 23, 2023 at 05:37:19PM +0900, Masahisa Kojima wrote:
> >>> This adds the URI device path option for 'boot add' subcommand.
> >>> User can add the URI load option for downloading ISO image file
> >>> or EFI application through network(e.g. HTTP).
> >>>
> >>> Signed-off-by: Masahisa Kojima 
> >>> ---
> >>>   cmd/efidebug.c | 39 +++
> >>>   1 file changed, 39 insertions(+)
> >>>
> >>> diff --git a/cmd/efidebug.c b/cmd/efidebug.c
> >>> index 0be3af3e76..62f867df2a 100644
> >>> --- a/cmd/efidebug.c
> >>> +++ b/cmd/efidebug.c
> >>> @@ -829,6 +829,44 @@ static int do_efi_boot_add(struct cmd_tbl *cmdtp, 
> >>> int flag,
> >>>argc -= 1;
> >>>argv += 1;
> >>>break;
> >>> + case 'u':
> >>> + {
> >>> + char *pos;
> >>> + int uridp_len;
> >>> + struct efi_device_path_uri *uridp;
> >>> +
> >>> + if (argc <  3 || lo.label) {
> >>> + r = CMD_RET_USAGE;
> >>> + goto out;
> >>> + }
> >>> + id = (int)hextoul(argv[1], &endp);
> >>> + if (*endp != '\0' || id > 0x)
> >>> + return CMD_RET_USAGE;
> >>> +
> >>> + efi_create_indexed_name(var_name16, 
> >>> sizeof(var_name16),
> >>> + "Boot", id);
> >>> +
> >>> + label = efi_convert_string(argv[2]);
> >>> + if (!label)
> >>> + return CMD_RET_FAILURE;
> >>> + lo.label = label;
> >>> +
> >>> + uridp_len = sizeof(struct efi_device_path) + 
> >>> strlen(argv[3]) + 1;
> >>> + fp_free = efi_alloc(uridp_len + sizeof(END));
> >>> + uridp = (struct efi_device_path_uri *)fp_free;
> >>> + uridp->dp.type = DEVICE_PATH_TYPE_MESSAGING_DEVICE;
> >>> + uridp->dp.sub_type = DEVICE_PATH_SUB_TYPE_MSG_URI;
> >>> + uridp->dp.length = uridp_len;
> >>> + strcpy(uridp->uri, argv[3]);
> >>> + pos = (char *)uridp + uridp_len;
> >>> + memcpy(pos, &END, sizeof(END));
> >>> + fp_size += uridp_len + sizeof(END);
> >>> + file_path = (struct efi_device_path *)uridp;
> >>> + argc -= 3;
> >>> + argv += 3;
> >>> + break;
> >>> + }
> >>> +
> >>>default:
> >>>r = CMD_RET_USAGE;
> >>>goto out;
> >>> @@ -1492,6 +1530,7 @@ static char efidebug_help_text[] =
> >>>"  -b|-B[:]  >>> path>\n"
> >>>"  -i|-I  [:] \n"
> >>>"  (-b, -i for short form device path)\n"
> >>> + "  -u   \n"
> >>
> >> It might be a matter of personal preference, but
> >> since the current syntax of efidebug is already much complex,
> >> I don't want to add more options unless it's necessary.
> >> How about re-using "-B" option, say
> >> => efidebug -B 3 debian-netinst uri - https://foo.com/baa
>
> You just replace one set of alternatives (-B -b -u) against another
> (mmc, nvme, uri, ...). I cannot see that this reduces complexity.
>
> >
> > I understand your concern. OK, I will add uri in -b|B and also update
> > documentation.
>
> It is unclear to me what the difference between -b and -B shall be for
> URIs. Would -B be with the device path of the network device
> (/VenHw()/MAC()/URI()) and -b without (/URI())?

Differentiating -b and -B for URI is not mandatory, I think.
To keep implementation simple, I would like to add '-u' option as the
original patch does.

Thanks,
Masahisa Kojima

>
> Best regards
>
> Heinrich
>
> >
> > Thanks,
> > Masahisa Kojima
> >
> >>
> >> BTW, I think that  and  should have been moved out of "-b|B"
> >> when Ilias introduced this new syntax.
> >>
> >> -Takahiro Akashi
> >>
> >>
> >>>"  -s ''\n"
> >>>"efidebug boot rm  [ [ [...]]]\n"
> >>>"  - delete UEFI Boot variables\n"
> >>> --
> >>> 2.34.1
> >>>
>


Re: [PATCH v2 0/4] support for booting the compressed U-boot binary on Rockchip based ARM64 SOC's

2023-08-27 Thread Manoj Sai
On Thu, Jul 27, 2023 at 4:51 PM Jonas Karlman  wrote:
>
> On 2023-07-25 05:50, Manoj Sai wrote:
> > This patchset adds the support on Rockchip based ARM64 SOC's that  compress 
> > the U-BOOT proper along with dtb
> > and ATF in FIT image format.Second stage bootloader(SPL) loads the 
> > compressed binaries, uncompress
> > them and  handover control to the next stage.
> >
> > Changes for V2 :-
> >
> > - Removed the need to create gzip and lzma compressed U-boot-nodtb files 
> > using Makefile  and added a changeset
> > that "compress" field to u-boot-nodtb node and "compression" field to  
> > u-boot Node in the FIT image, with the help
> > of this change binman will create the compressed Binaries.
> >
> > Size Comparision between compressed and uncompressed binaries :-
> >
> >   size of uncompressed binary :- 9.4 MB (94,26,432 bytes)
> >  manoj:u-boot$ ls -lb u-boot-rockchip.bin
> > -rw-rw-r-- 1 manoj manoj 9426432 Jul 25 07:42 u-boot-rockchip.bin
> >
> >size of GZIP compressed binary :- 9.0 MB (89,85,088 bytes)
> >  manoj:u-boot$ ls -lb u-boot-rockchip.bin
> >  -rw-rw-r-- 1 manoj manoj 8985088 Jul 25 07:42 u-boot-rockchip.bin
> >
> >size of LZMA compressed binary :- 9.0 MB (90,06,080 bytes)
> >  manoj:u-boot$ ls -lb u-boot-rockchip.bin
> >  -rw-rw-r-- 1 manoj manoj 9006080 Jul 25 07:47 u-boot-rockchip.bin
> >
> > - modified to use the CONFIG_SYS_LOAD_ADDR as the source RAM address to 
> > store the  compressed U-Boot binary which
> > will be defined in the machine defconfig file in place of creating a new 
> > RAM address for a specific board using Kconfig.
> > so patchset related to adding a new RAM address to store compressed binary 
> > has been removed in V2 patchset.
> >
> > - Removed the patchset related to adding  the u-boot-nodtb.bin.gz and 
> > u-boot-nodtb.bin.lzma as input binary to binman.
> >
> >
> > -- Test results of  Booting time using bootstage command in Uboot command 
> > prompt on roc-rk3399-pc board :-
> >
> > 1) Uncompressed U-BOOT : Total boot time ≈ 12.3 seconds
> > => bootstage  report
> > Timer summary in microseconds (10 records):
> >MarkElapsed  Stage
> >   0  0  reset
> >   1,824,330  1,824,330  board_init_f
> >   2,921,678  1,097,348  board_init_r
> >   5,179,369  2,257,691  eth_common_init
> >   5,478,307298,938  eth_initialize
> >   5,478,484177  main_loop
> >   5,478,641157  usb_start
> >  12,017,936  6,539,295  cli_loop
> >
> > Accumulated time:
> > 15,899  dm_r
> >694,371  dm_f
> >
> > 2) GZIP Compressed U-BOOT : Total boot time ≈ 13.5 seconds
> > =>  bootstage  report
> > Timer summary in microseconds (10 records):
> >MarkElapsed  Stage
> >   0  0  reset
> >   2,591,355  2,591,355  board_init_f
> >   3,689,407  1,098,052  board_init_r
> >   5,947,314  2,257,907  eth_common_init
> >   6,246,250298,936  eth_initialize
> >   6,246,427177  main_loop
> >   6,246,585158  usb_start
> >  12,785,936  6,539,351  cli_loop
> >
> > Accumulated time:
> > 15,902  dm_r
> >694,779  dm_f
> >
> > 2) LZMA Compressed U-BOOT : Total boot time ≈ 23.5 seconds
> > => bootstage report
> > Timer summary in microseconds (10 records):
> >MarkElapsed  Stage
> >   0  0  reset
> >   6,376,405  6,376,405  board_init_f
> >   7,471,967  1,095,562  board_init_r
> >   9,726,257  2,254,290  eth_common_init
> >  10,024,873298,616  eth_initialize
> >  10,025,049176  main_loop
> >  10,025,208159  usb_start
> >  16,564,906  6,539,698  cli_loop
> >
> > Accumulated time:
> > 15,851  dm_r
> >693,323  dm_f
> >
> >
> > Patch 1/4  generate a GZIP-compressed U-boot binary using binman if 
> > CONFIG_SPL_GZIP selected
> > Patch 2/4  generate a LZMA-compressed U-boot binary using binman if 
> > CONFIG_SPL_LZMA selected
> > Patch 3/4  uncompress the gzip U-BOOT binary and load the binaries if gzip 
> > compression supoort is enabled
> > Patch 4/4  uncompress the lzma U-BOOT binary and load the binaries if lzma 
> > compression supoort is enabled
>
> Boot times seem very slow with compression enabled, please try with
> caches enabled, see RFC patch at [1]. Enable caches have a huge impact
> for FIT checksum validation using CONFIG_SPL_FIT_SIGNATURE=y.
>
> Possible to also include ZSTD support?
>

Hi Jonas ,
Enabled zstd support , facing build issues related to zstd . Had you
faced this build error , pasted below :

aarch64-linux-gnu-ld.bfd: lib/zstd/decompress/zstd_decompress.o: in
function `ZSTD_DDictHashSet_getIndex':
/media/manoj/7d4c36e9-ddbb-4e7a-bd1e-cb96766bde37/ssd-Workspace/libreCompTask/tasks/compression-Task/mainline-apply-Uboot-cmp-2023/testfldr/u-boot/lib/zstd/decompress/zstd_decompress.c:88:
undefined reference to `xxh64'
aarch64-linux-gnu-ld.bfd: lib/zstd/decompress/zstd_decompress.o: in
function `ZSTD_

Re: [PATCH v2 5/6] docs: ti: j721s2_evm: Create documentation from J7200 docs

2023-08-27 Thread Neha Malcom Francis

Hi Manorit

On 25/08/23 16:47, Manorit Chawdhry wrote:

The documentation is based off J7200 documentation tailored for J721S2.

TRM for J721S2: https://www.ti.com/lit/pdf/spruj28
Product Page: https://www.ti.com/product/TDA4AL-Q1

Signed-off-by: Manorit Chawdhry 
---
  doc/board/ti/j721s2_evm.rst | 263 
  doc/board/ti/k3.rst |   1 +
  2 files changed, 264 insertions(+)



Reviewed-by: Neha Malcom Francis 

--
Thanking You
Neha Malcom Francis


Re: [PATCH v2 4/6] k3-am68: Sync from Linux tag v6.5-rc1

2023-08-27 Thread Neha Malcom Francis

Hi Manorit

On 25/08/23 16:47, Manorit Chawdhry wrote:

The following commit syncs the device tree from Linux tag
v6.5-rc1 to U-boot and fixes the following to be compatible with
the future syncs -

- Include k3-am68-sk-base-board.dts file

 Remove the duplicated pinmuxes from r5 and -u-boot.dtsi files and
 include k3-am68-sk-base-board.dts for Linux fixes to propagate
 to U-boot.

- Fixing the mcu_timer0

 Remove timer0 and use the mcu_timer0 defined in mcu-wakeup.dtsi

 The device manager is not functional at this point so we can't
 configure the clocks for the mcu_timer0, delete the properties
 that enable the clocks and power domains for it.

- Fixing secure proxy nodes

 Linux DT now have these nodes defined so remove them and rename to
 use the Linux DT ones.

- Remove cpsw node

 The compatible is now fixed and the node is not required in
 -u-boot specifically

- Remove aliases and chosen node

 Use these from Linux and don't override when not required.

- Remove /delete-property/ from sdhci nodes

 We have the necessary clock and dev data so remove these.

- Remove dummy_clocks and fs_loader0

 These weren't being used anywhere so remove it.

All these have been put in a single commit to not break the
bisectability.

Signed-off-by: Manorit Chawdhry 
---
  arch/arm/dts/k3-am68-sk-base-board-u-boot.dtsi |  69 ++---
  arch/arm/dts/k3-am68-sk-base-board.dts | 389 +++--
  arch/arm/dts/k3-am68-sk-r5-base-board.dts  | 143 ++---
  arch/arm/dts/k3-am68-sk-som.dtsi   | 112 ++-
  4 files changed, 300 insertions(+), 413 deletions(-)



Reviewed-by: Neha Malcom Francis 

--
Thanking You
Neha Malcom Francis


Re: [PATCH v2 3/6] k3-j721s2: Sync from Linux tag v6.5-rc1

2023-08-27 Thread Neha Malcom Francis

Hi Manorit

On 25/08/23 16:47, Manorit Chawdhry wrote:

The following commit syncs the device tree from Linux tag
v6.5-rc1 to U-boot and fixes the following to be compatible with
the future syncs -

- Include k3-j721s2-common-proc-board.dts file

 Remove the duplicated pinmuxes from r5 and -u-boot.dtsi files and
 include k3-j721s2-common-proc-board.dts for Linux fixes to propagate
 to U-boot.

- Fixing the mcu_timer0

 Remove timer0 and use the mcu_timer0 defined in mcu-wakeup.dtsi

 The device manager is not functional at this point so we can't
 configure the clocks for the mcu_timer0, delete the properties
 that enable the clocks and power domains for it.

- Fixing secure proxy nodes

 Linux DT now have these nodes defined so remove them and rename to
 use the Linux DT ones.

- Remove cpsw node

 The compatible is now fixed and the node is not required in
 -u-boot specifically

- Remove aliases and chosen node

 Use these from Linux and don't override when not required.

- Remove /delete-property/ from sdhci nodes

 We have the necessary clock and dev data so remove these.

- Remove dummy_clocks and fs_loader0

 These weren't being used anywhere so remove it.

All these have been put in a single commit to not break the
bisectability.

Signed-off-by: Manorit Chawdhry 
---
  .../dts/k3-j721s2-common-proc-board-u-boot.dtsi|  60 +--
  arch/arm/dts/k3-j721s2-common-proc-board.dts   | 330 ++--
  arch/arm/dts/k3-j721s2-main.dtsi   | 585 -
  arch/arm/dts/k3-j721s2-mcu-wakeup.dtsi | 365 -
  arch/arm/dts/k3-j721s2-r5-common-proc-board.dts| 151 +-
  arch/arm/dts/k3-j721s2-som-p0.dtsi | 165 +++---
  arch/arm/dts/k3-j721s2-thermal.dtsi| 101 
  arch/arm/dts/k3-j721s2.dtsi|  12 +-
  8 files changed, 1339 insertions(+), 430 deletions(-)



This LGTM,
Reviewed-by: Neha Malcom Francis 

--
Thanking You
Neha Malcom Francis


Re: [PATCH v2 2/6] arm: mach-k3: j721s2: Add mcu_timer0 id to the dev list

2023-08-27 Thread Neha Malcom Francis

Hi Manorit

On 25/08/23 16:47, Manorit Chawdhry wrote:

mcu_timer0 is used by u-boot as the tick-timer. Add it to the soc
devices lsit so it an be enabled via the k3 power controller.

Signed-off-by: Manorit Chawdhry 
---
  arch/arm/mach-k3/j721s2/dev-data.c | 1 +
  1 file changed, 1 insertion(+)

diff --git a/arch/arm/mach-k3/j721s2/dev-data.c 
b/arch/arm/mach-k3/j721s2/dev-data.c
index 8c999a3c5a8b..df70c5e5d7c0 100644
--- a/arch/arm/mach-k3/j721s2/dev-data.c
+++ b/arch/arm/mach-k3/j721s2/dev-data.c
@@ -47,6 +47,7 @@ static struct ti_lpsc soc_lpsc_list[] = {
  };
  
  static struct ti_dev soc_dev_list[] = {

+   PSC_DEV(35, &soc_lpsc_list[0]),
PSC_DEV(108, &soc_lpsc_list[0]),
PSC_DEV(109, &soc_lpsc_list[0]),
PSC_DEV(110, &soc_lpsc_list[0]),



Reviewed-by: Neha Malcom Francis 

--
Thanking You
Neha Malcom Francis


RE: [PATCH] fpga: define dummy fpga_load function for debug build

2023-08-27 Thread Chanho Park
Hi,

> -Original Message-
> From: Michal Simek 
> Sent: Friday, August 25, 2023 4:23 PM
> To: Chanho Park ; u-boot@lists.denx.de
> Subject: Re: [PATCH] fpga: define dummy fpga_load function for debug build
> 
> Hi,
> 
> On 8/16/23 08:54, Chanho Park wrote:
> > This fixes below build error when CC_OPTIMIZE_FOR_DEBUG is enabled and
> > CONFIG_SPL_FPGA is not enabled.
> >
> > ../common/spl/spl_fit.c:591: undefined reference to `fpga_load'
> > collect2: error: ld returned 1 exit status
> >
> > Signed-off-by: Chanho Park 
> > ---
> >   include/fpga.h | 8 
> >   1 file changed, 8 insertions(+)
> >
> > diff --git a/include/fpga.h b/include/fpga.h index
> > ed688cc0fa3b..44f2755a3f10 100644
> > --- a/include/fpga.h
> > +++ b/include/fpga.h
> > @@ -60,8 +60,16 @@ int fpga_add(fpga_type devtype, void *desc);
> >   int fpga_count(void);
> >   const fpga_desc *const fpga_get_desc(int devnum);
> >   int fpga_is_partial_data(int devnum, size_t img_len);
> > +#if CONFIG_IS_ENABLED(FPGA)
> >   int fpga_load(int devnum, const void *buf, size_t bsize,
> >   bitstream_type bstype, int flags);
> > +#else
> > +static inline int fpga_load(int devnum, const void *buf, size_t bsize,
> > + bitstream_type bstype, int flags) {
> > +   return FPGA_FAIL;
> > +}
> > +#endif
> >   int fpga_fsload(int devnum, const void *buf, size_t size,
> > fpga_fs_info *fpga_fsinfo);
> >   int fpga_loads(int devnum, const void *buf, size_t size,
> 
> There is another patch targeting the same code.
> Please take a look at
> https://lore.kernel.org/r/20230808102227.34233-1-
> eugen.hris...@collabora.com

I wasn't aware that there was an attempt to fix the issue. If I knew it, I 
would reply the patch...

> 
> and work together to come up with the patch which covers both cases.

Yes. I also tried to make the patch with CONFIG_CC_OPTIMIZE_FOR_DEBUG guard but 
I couldn't find any codes that uses the guard.
And I was also worried about the CC_OPTIMIZE_FOR_DEBUG's behavior. It could be 
related with the optimization level of the compiler.
That's why I put the guard with #if CONFIG_IS_ENABLED(FPGA).

Best Regards,
Chanho Park



Re: Pull request efi-2023-10-rc4

2023-08-27 Thread Tom Rini
On Sun, Aug 27, 2023 at 09:55:17AM +0200, Heinrich Schuchardt wrote:

> Dear Tom,
> 
> The following changes since commit e508b930021168c788f14977fc101ccc1151b3c8:
> 
>   Merge https://source.denx.de/u-boot/custodians/u-boot-usb (2023-08-25
> 10:52:39 -0400)
> 
> are available in the Git repository at:
> 
>   https://source.denx.de/u-boot/custodians/u-boot-efi.git
> tags/efi-2023-10-rc4
> 
> for you to fetch changes up to cc889bd0754e50a3cd50e8ed3094388480fbec86:
> 
>   efi_loader: delete handle from events when a protocol is uninstalled
> (2023-08-27 08:21:08 +0200)
> 
> Gitlab CI showed no issues:
> https://source.denx.de/u-boot/custodians/u-boot-efi/-/pipelines/17537
> 

Applied to u-boot/master, thanks!

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 0/6] Attempt to enforce standard extensions for build output

2023-08-27 Thread Alper Nebi Yasak
On 2023-08-24 06:02 +03:00, Simon Glass wrote:
> In this early stage of using binman to produce output files, we are mostly
> seeing people using common extensions such as '.bin' and '.rom'
> 
> But unusual extensions appear in some places.
> 
> We would like 'buildman -k' to keep the build outputs, but this is hard if
> there is no consistency as to the extension used.
> 
> This series adjusts binman to enforce just 4 extensions for output images:
> 
>.bin
>.rom
>.itb
>.img
> 
> Other extensions will produce an error. With this rule observed, buildman
> can keep the required files.

I dislike this limitation. We know what files we will generate, they are
listed in binman dtb, so we can add something like `binman build --ls`
to print their names/paths for buildman to preserve them.

Regarding the output directory suggestion, I think the binman outputs
(not temporary/intermediate files) should be in the same directory as
make outputs, and the Makefile should default to O=build to achieve the
"output dir". I'm not sure if that's going to happen.


Re: [PATCH] efi: Correct handling of frame buffer

2023-08-27 Thread Alper Nebi Yasak
On 2023-08-27 19:32 +03:00, Heinrich Schuchardt wrote:
> Am 27. August 2023 16:56:51 MESZ schrieb Alper Nebi Yasak 
> :
>> On 2023-08-25 22:28 +03:00, Simon Glass wrote:
>>> so we must allow EFI to write directly to the hardware framebuffer.
>>
>> If you want a fix independent of that series, I think the proper
>> approach here is having EFI draw to fb as it already does, then copying
>> from that to copy_fb at the end of gop_blt_int().
> 
> An EFI app can write directly to the framebuffer and mix that with API calls.

Ack. Can EFI apps write to framebuffer without informing U-Boot at all?
What I meant is, copying whenever EFI asks us to modify something or
tells us it modified something.

If it can write without telling us, how are cache flushes and hardware
syncs handled? Asking these because I'm doing some weird experiments
with video damage and cyclic video_sync() calls and VIDEO_COPY...

> blt functions causing a full copy would be much slower than what you get when 
> eliminating the copy fb.

When we expose copy_fb to EFI, don't we need to keep fb up to date,
incurring the same cost? The VIDEO_COPY description mentions "reading
from the frame buffer is slow", so whatever code is "reading" would use
fb and would get bad data otherwise. But I can't exactly point to any
examples other than the video damage series copying fb onto copy_fb.


Re: [PATCH] efi: Correct handling of frame buffer

2023-08-27 Thread Heinrich Schuchardt



Am 27. August 2023 16:56:51 MESZ schrieb Alper Nebi Yasak 
:
>On 2023-08-25 22:28 +03:00, Simon Glass wrote:
>> The efi_gop driver uses private fields from the video uclass to obtain a
>> pointer to the frame buffer. Use the platform data instead.
>> 
>> Check the VIDEO_COPY setting to determine which frame buffer to use. Once
>> the next stage is running (and making use of U-Boot's EFI boot services)
>> U-Boot does not handle copying from priv->fb to the hardware framebuffer,
>
>So far this copying seems to be done case-by-case like calling
>vidconsole_sync_copy() any time vidconsole does something, but the video
>damage tracking series moves that to video_sync(), so this change is
>incompatible with that (it will keep overwriting copy_fb with fb).
>
>> so we must allow EFI to write directly to the hardware framebuffer.
>
>If you want a fix independent of that series, I think the proper
>approach here is having EFI draw to fb as it already does, then copying
>from that to copy_fb at the end of gop_blt_int().

An EFI app can write directly to the framebuffer and mix that with API calls.

blt functions causing a full copy would be much slower than what you get when 
eliminating the copy fb.

Best regards

Heinrich


>
>> Signed-off-by: Simon Glass 
>> ---
>> 
>>  lib/efi_loader/efi_gop.c | 12 +++-
>>  1 file changed, 7 insertions(+), 5 deletions(-)
>> 
>> diff --git a/lib/efi_loader/efi_gop.c b/lib/efi_loader/efi_gop.c
>> index 778b693f983..a09db31eb46 100644
>> --- a/lib/efi_loader/efi_gop.c
>> +++ b/lib/efi_loader/efi_gop.c
>> @@ -10,6 +10,7 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>>  #include 
>>  #include 
>>  
>> @@ -467,10 +468,10 @@ efi_status_t efi_gop_register(void)
>>  struct efi_gop_obj *gopobj;
>>  u32 bpix, format, col, row;
>>  u64 fb_base, fb_size;
>> -void *fb;
>>  efi_status_t ret;
>>  struct udevice *vdev;
>>  struct video_priv *priv;
>> +struct video_uc_plat *plat;
>>  
>>  /* We only support a single video output device for now */
>>  if (uclass_first_device_err(UCLASS_VIDEO, &vdev)) {
>> @@ -483,9 +484,10 @@ efi_status_t efi_gop_register(void)
>>  format = priv->format;
>>  col = video_get_xsize(vdev);
>>  row = video_get_ysize(vdev);
>> -fb_base = (uintptr_t)priv->fb;
>> -fb_size = priv->fb_size;
>> -fb = priv->fb;
>> +
>> +plat = dev_get_uclass_plat(vdev);
>> +fb_base = IS_ENABLED(CONFIG_VIDEO_COPY) ? plat->copy_base : plat->base;
>> +fb_size = plat->size;
>>  
>>  switch (bpix) {
>>  case VIDEO_BPP16:
>> @@ -547,7 +549,7 @@ efi_status_t efi_gop_register(void)
>>  }
>>  gopobj->info.pixels_per_scanline = col;
>>  gopobj->bpix = bpix;
>> -gopobj->fb = fb;
>> +gopobj->fb = map_sysmem(fb_base, fb_size);
>>  
>>  return EFI_SUCCESS;
>>  }


Re: [PATCH v2 4/4] doc: qemu: arm: Add a section on booting Linux distros

2023-08-27 Thread Alper Nebi Yasak
On 2023-08-15 01:43 +03:00, Simon Glass wrote:
> Hi Alper,
> 
> On Mon, 14 Aug 2023 at 11:40, Alper Nebi Yasak  
> wrote:
>> I actually want to put the root.img device first so that the VM can boot
>> into the installed system when it reboots, but U-Boot can't find the
>> bootflow on the second drive. I tried e.g. `bootdev list -p; bootflow
>> scan -lab`, but it seems to only ever search the first virtio-blk.
>> However, `eficonfig; bootefi bootmgr` makes it boot somehow.
> 
> Yes, this is annoying.
> 
> The problem is that the scanning is getting so complicated. The
> boot_targets var lists things which can either be a uclass, or a
> uclass with a device number. The currently implementation sees
> "virtio" and moves on to the next thing in boot_targets once it has
> processed one virtio device. That is obviously not correct, but...
> 
> Would it be possible to just drop the 'boot_targets' var? That is what
> is stuffing it up, but we don't actually need it now. The defaults end
> up doing the same thing, apart (perhaps) from the strangeness of
> virtio which can be both a network and a blk device.
> 
> I believe it is possible to do the right thing, but I'll need to
> create a better test mechanism to handle all the cases.

I think some kind of a "priority score" could help -- iterate over
boot_targets first just to generate bootdev priorities, then carry them
over as bootflows are discovered (adjusted for bootmeth order), then use
those scores as the order to boot / to show a sorted menu / to test?


Re: [PATCH] efi: Correct handling of frame buffer

2023-08-27 Thread Alper Nebi Yasak
On 2023-08-25 22:28 +03:00, Simon Glass wrote:
> The efi_gop driver uses private fields from the video uclass to obtain a
> pointer to the frame buffer. Use the platform data instead.
> 
> Check the VIDEO_COPY setting to determine which frame buffer to use. Once
> the next stage is running (and making use of U-Boot's EFI boot services)
> U-Boot does not handle copying from priv->fb to the hardware framebuffer,

So far this copying seems to be done case-by-case like calling
vidconsole_sync_copy() any time vidconsole does something, but the video
damage tracking series moves that to video_sync(), so this change is
incompatible with that (it will keep overwriting copy_fb with fb).

> so we must allow EFI to write directly to the hardware framebuffer.

If you want a fix independent of that series, I think the proper
approach here is having EFI draw to fb as it already does, then copying
from that to copy_fb at the end of gop_blt_int().

> Signed-off-by: Simon Glass 
> ---
> 
>  lib/efi_loader/efi_gop.c | 12 +++-
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/lib/efi_loader/efi_gop.c b/lib/efi_loader/efi_gop.c
> index 778b693f983..a09db31eb46 100644
> --- a/lib/efi_loader/efi_gop.c
> +++ b/lib/efi_loader/efi_gop.c
> @@ -10,6 +10,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  
> @@ -467,10 +468,10 @@ efi_status_t efi_gop_register(void)
>   struct efi_gop_obj *gopobj;
>   u32 bpix, format, col, row;
>   u64 fb_base, fb_size;
> - void *fb;
>   efi_status_t ret;
>   struct udevice *vdev;
>   struct video_priv *priv;
> + struct video_uc_plat *plat;
>  
>   /* We only support a single video output device for now */
>   if (uclass_first_device_err(UCLASS_VIDEO, &vdev)) {
> @@ -483,9 +484,10 @@ efi_status_t efi_gop_register(void)
>   format = priv->format;
>   col = video_get_xsize(vdev);
>   row = video_get_ysize(vdev);
> - fb_base = (uintptr_t)priv->fb;
> - fb_size = priv->fb_size;
> - fb = priv->fb;
> +
> + plat = dev_get_uclass_plat(vdev);
> + fb_base = IS_ENABLED(CONFIG_VIDEO_COPY) ? plat->copy_base : plat->base;
> + fb_size = plat->size;
>  
>   switch (bpix) {
>   case VIDEO_BPP16:
> @@ -547,7 +549,7 @@ efi_status_t efi_gop_register(void)
>   }
>   gopobj->info.pixels_per_scanline = col;
>   gopobj->bpix = bpix;
> - gopobj->fb = fb;
> + gopobj->fb = map_sysmem(fb_base, fb_size);
>  
>   return EFI_SUCCESS;
>  }


[PATCH v2 6/6] sysreset: implement PALMAS sysreset functions

2023-08-27 Thread Svyatoslav Ryhel
PALMAS PMIC family has embedded poweroff function used by some
device to initiane device power off. Implement it as sysreset
driver.

Signed-off-by: Svyatoslav Ryhel 
---
 drivers/power/pmic/palmas.c| 33 +--
 drivers/sysreset/Kconfig   |  7 
 drivers/sysreset/Makefile  |  1 +
 drivers/sysreset/sysreset_palmas.c | 53 ++
 include/power/palmas.h | 11 +++
 5 files changed, 103 insertions(+), 2 deletions(-)
 create mode 100644 drivers/sysreset/sysreset_palmas.c

diff --git a/drivers/power/pmic/palmas.c b/drivers/power/pmic/palmas.c
index d6eb9cb433..eaa323ef8f 100644
--- a/drivers/power/pmic/palmas.c
+++ b/drivers/power/pmic/palmas.c
@@ -10,10 +10,10 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
-#include 
 
 static const struct pmic_child_info pmic_children_info[] = {
{ .prefix = "ldo", .driver = PALMAS_LDO_DRIVER },
@@ -46,7 +46,16 @@ static int palmas_bind(struct udevice *dev)
 {
ofnode pmic_node = ofnode_null(), regulators_node;
ofnode subnode;
-   int children;
+   int children, ret;
+
+   if (IS_ENABLED(CONFIG_SYSRESET_PALMAS)) {
+   ret = device_bind_driver(dev, PALMAS_RST_DRIVER,
+"sysreset", NULL);
+   if (ret) {
+   log_err("cannot bind SYSRESET (ret = %d)\n", ret);
+   return ret;
+   }
+   }
 
dev_for_each_subnode(subnode, dev) {
const char *name;
@@ -80,6 +89,24 @@ static int palmas_bind(struct udevice *dev)
return 0;
 }
 
+static int palmas_probe(struct udevice *dev)
+{
+   struct dm_i2c_chip *chip = dev_get_parent_plat(dev);
+   struct palmas_priv *priv = dev_get_priv(dev);
+   struct udevice *bus = dev_get_parent(dev);
+   u32 chip2_addr = chip->chip_addr + 1;
+   int ret;
+
+   /* Palmas PMIC is multi chip and chips are located in a row */
+   ret = i2c_get_chip(bus, chip2_addr, 1, &priv->chip2);
+   if (ret) {
+   log_err("cannot get second PMIC I2C chip (err %d)\n", ret);
+   return ret;
+   }
+
+   return 0;
+}
+
 static struct dm_pmic_ops palmas_ops = {
.read = palmas_read,
.write = palmas_write,
@@ -97,5 +124,7 @@ U_BOOT_DRIVER(pmic_palmas) = {
.id = UCLASS_PMIC,
.of_match = palmas_ids,
.bind = palmas_bind,
+   .probe = palmas_probe,
.ops = &palmas_ops,
+   .priv_auto = sizeof(struct palmas_priv),
 };
diff --git a/drivers/sysreset/Kconfig b/drivers/sysreset/Kconfig
index 659170d156..0e52f99628 100644
--- a/drivers/sysreset/Kconfig
+++ b/drivers/sysreset/Kconfig
@@ -109,6 +109,13 @@ config SYSRESET_SPL_AT91
  This enables the system reset driver support for Microchip/Atmel
  SoCs in SPL.
 
+config SYSRESET_PALMAS
+   bool "Enable support for PALMAS System Reset"
+   depends on PMIC_PALMAS
+   select SYSRESET_CMD_POWEROFF if CMD_POWEROFF
+   help
+ Enable system power management functions found in PLAMAS PMIC family.
+
 config SYSRESET_PSCI
bool "Enable support for PSCI System Reset"
depends on ARM_PSCI_FW
diff --git a/drivers/sysreset/Makefile b/drivers/sysreset/Makefile
index 0d96a204a9..c9f1c625ae 100644
--- a/drivers/sysreset/Makefile
+++ b/drivers/sysreset/Makefile
@@ -13,6 +13,7 @@ obj-$(CONFIG_$(SPL_TPL_)SYSRESET_MAX77663) += 
sysreset_max77663.o
 obj-$(CONFIG_SYSRESET_MPC83XX) += sysreset_mpc83xx.o
 obj-$(CONFIG_SYSRESET_MICROBLAZE) += sysreset_microblaze.o
 obj-$(CONFIG_SYSRESET_OCTEON) += sysreset_octeon.o
+obj-$(CONFIG_$(SPL_TPL_)SYSRESET_PALMAS) += sysreset_palmas.o
 obj-$(CONFIG_SYSRESET_PSCI) += sysreset_psci.o
 obj-$(CONFIG_SYSRESET_SBI) += sysreset_sbi.o
 obj-$(CONFIG_SYSRESET_SOCFPGA) += sysreset_socfpga.o
diff --git a/drivers/sysreset/sysreset_palmas.c 
b/drivers/sysreset/sysreset_palmas.c
new file mode 100644
index 00..d853c33504
--- /dev/null
+++ b/drivers/sysreset/sysreset_palmas.c
@@ -0,0 +1,53 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ *  Copyright(C) 2023 Svyatoslav Ryhel 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static int palmas_sysreset_request(struct udevice *dev,
+  enum sysreset_t type)
+{
+   struct palmas_priv *priv = dev_get_priv(dev->parent);
+   int ret;
+
+   /*
+* Mask INT3 on second page which detects vbus
+* or device will immediately turn on.
+*/
+   ret = dm_i2c_reg_clrset(priv->chip2, PALMAS_INT3_MASK,
+   MASK_VBUS, MASK_VBUS);
+   if (ret < 0)
+   return ret;
+
+   switch (type) {
+   case SYSRESET_POWER:
+   /* PALMAS: SW_RST > DEV_CTRL */
+   pmic_reg_write(dev->parent, PALMAS_DEV_CTRL, SW_RST);
+   break;
+   case SYSRESET_POWER_OFF:
+   /

[PATCH v2 4/6] sysreset: implement TPS80031 sysreset functions

2023-08-27 Thread Svyatoslav Ryhel
TPS80031/TPS80032 PMICs have embedded power control functions
used by some device to initiane device power off. Implement it as
sysreset driver.

Signed-off-by: Svyatoslav Ryhel 
---
 drivers/power/pmic/tps80031.c| 12 +++-
 drivers/sysreset/Kconfig |  8 ++
 drivers/sysreset/Makefile|  1 +
 drivers/sysreset/sysreset_tps80031.c | 41 
 include/power/tps80031.h |  5 
 5 files changed, 66 insertions(+), 1 deletion(-)
 create mode 100644 drivers/sysreset/sysreset_tps80031.c

diff --git a/drivers/power/pmic/tps80031.c b/drivers/power/pmic/tps80031.c
index c2b04fffdf..45e89ba5c9 100644
--- a/drivers/power/pmic/tps80031.c
+++ b/drivers/power/pmic/tps80031.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -49,7 +50,16 @@ static int tps80031_read(struct udevice *dev, uint reg, 
uint8_t *buff, int len)
 static int tps80031_bind(struct udevice *dev)
 {
ofnode regulators_node;
-   int children;
+   int children, ret;
+
+   if (IS_ENABLED(CONFIG_SYSRESET_TPS80031)) {
+   ret = device_bind_driver(dev, TPS80031_RST_DRIVER,
+"sysreset", NULL);
+   if (ret) {
+   log_err("cannot bind SYSRESET (ret = %d)\n", ret);
+   return ret;
+   }
+   }
 
regulators_node = dev_read_subnode(dev, "regulators");
if (!ofnode_valid(regulators_node)) {
diff --git a/drivers/sysreset/Kconfig b/drivers/sysreset/Kconfig
index bc35896101..cdb4ae2bb1 100644
--- a/drivers/sysreset/Kconfig
+++ b/drivers/sysreset/Kconfig
@@ -157,6 +157,14 @@ config SYSRESET_TI_SCI
  This enables the system reset driver support over TI System Control
  Interface available on some new TI's SoCs.
 
+config SYSRESET_TPS80031
+   bool "Enable support for TPS80031/TPS80032 PMIC System Reset"
+   depends on DM_PMIC_TPS80031
+   select SYSRESET_CMD_POWEROFF if CMD_POWEROFF
+   help
+ Enable system power management functions found in TPS80031/TPS80032
+ PMICs.
+
 config SYSRESET_SYSCON
bool "Enable support for mfd syscon reboot driver"
select REGMAP
diff --git a/drivers/sysreset/Makefile b/drivers/sysreset/Makefile
index c31f51c581..f62db899da 100644
--- a/drivers/sysreset/Makefile
+++ b/drivers/sysreset/Makefile
@@ -19,6 +19,7 @@ obj-$(CONFIG_SYSRESET_SOCFPGA) += sysreset_socfpga.o
 obj-$(CONFIG_SYSRESET_SOCFPGA_SOC64) += sysreset_socfpga_soc64.o
 obj-$(CONFIG_SYSRESET_TEGRA) += sysreset_tegra.o
 obj-$(CONFIG_SYSRESET_TI_SCI) += sysreset-ti-sci.o
+obj-$(CONFIG_$(SPL_TPL_)SYSRESET_TPS80031) += sysreset_tps80031.o
 obj-$(CONFIG_SYSRESET_SYSCON) += sysreset_syscon.o
 obj-$(CONFIG_SYSRESET_WATCHDOG) += sysreset_watchdog.o
 obj-$(CONFIG_SYSRESET_RESETCTL) += sysreset_resetctl.o
diff --git a/drivers/sysreset/sysreset_tps80031.c 
b/drivers/sysreset/sysreset_tps80031.c
new file mode 100644
index 00..ea35f48ebd
--- /dev/null
+++ b/drivers/sysreset/sysreset_tps80031.c
@@ -0,0 +1,41 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ *  Copyright(C) 2023 Svyatoslav Ryhel 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static int tps80031_sysreset_request(struct udevice *dev,
+enum sysreset_t type)
+{
+   switch (type) {
+   case SYSRESET_POWER:
+   /* TPS80031: SW_RESET > PHOENIX_DEV_ON */
+   pmic_reg_write(dev->parent, TPS80031_PHOENIX_DEV_ON, SW_RESET);
+   break;
+   case SYSRESET_POWER_OFF:
+   /* TPS80031: DEVOFF > PHOENIX_DEV_ON */
+   pmic_reg_write(dev->parent, TPS80031_PHOENIX_DEV_ON, DEVOFF);
+   break;
+   default:
+   return -EPROTONOSUPPORT;
+   }
+
+   return -EINPROGRESS;
+}
+
+static struct sysreset_ops tps80031_sysreset = {
+   .request = tps80031_sysreset_request,
+};
+
+U_BOOT_DRIVER(sysreset_tps80031) = {
+   .id = UCLASS_SYSRESET,
+   .name   = TPS80031_RST_DRIVER,
+   .ops= &tps80031_sysreset,
+};
diff --git a/include/power/tps80031.h b/include/power/tps80031.h
index c80692a8af..983c841bfe 100644
--- a/include/power/tps80031.h
+++ b/include/power/tps80031.h
@@ -12,6 +12,7 @@
 /* Drivers name */
 #define TPS80031_LDO_DRIVER"tps80031_ldo"
 #define TPS80031_SMPS_DRIVER   "tps80031_smps"
+#define TPS80031_RST_DRIVER"tps80031_rst"
 
 #define TPS80031_SMPS_OFFSET   0xe0
 #define TPS80031_OFFSET_FLAG   BIT(0)
@@ -35,6 +36,10 @@
 #define LDO_VOLT_MIN   1018000
 #define LDO_VOLT_BASE  916000
 
+#define TPS80031_PHOENIX_DEV_ON0x25
+#define   SW_RESET BIT(6)
+#define   DEVOFF   BIT(0)
+
 /* register groups */
 enum {
CTRL,
-- 
2.39.2



[PATCH v2 5/6] sysreset: implement TPS65910 sysreset functions

2023-08-27 Thread Svyatoslav Ryhel
TPS65910/TPS65911 PMICs have embedded power control functions
used by some device to initiane device power off. Implement it as
sysreset driver.

Signed-off-by: Svyatoslav Ryhel 
---
 drivers/power/pmic/pmic_tps65910_dm.c | 12 +-
 drivers/sysreset/Kconfig  |  8 
 drivers/sysreset/Makefile |  1 +
 drivers/sysreset/sysreset_tps65910.c  | 55 +++
 include/power/tps65910_pmic.h |  7 
 5 files changed, 82 insertions(+), 1 deletion(-)
 create mode 100644 drivers/sysreset/sysreset_tps65910.c

diff --git a/drivers/power/pmic/pmic_tps65910_dm.c 
b/drivers/power/pmic/pmic_tps65910_dm.c
index 53af3171cc..b9c2326d5b 100644
--- a/drivers/power/pmic/pmic_tps65910_dm.c
+++ b/drivers/power/pmic/pmic_tps65910_dm.c
@@ -7,6 +7,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -58,7 +59,16 @@ static int pmic_tps65910_bind(struct udevice *dev)
const struct pmic_child_info *tps6591x_children_info =
(struct pmic_child_info *)dev_get_driver_data(dev);
ofnode regulators_node;
-   int children;
+   int children, ret;
+
+   if (IS_ENABLED(CONFIG_SYSRESET_TPS65910)) {
+   ret = device_bind_driver(dev, TPS65910_RST_DRIVER,
+"sysreset", NULL);
+   if (ret) {
+   log_err("cannot bind SYSRESET (ret = %d)\n", ret);
+   return ret;
+   }
+   }
 
regulators_node = dev_read_subnode(dev, "regulators");
if (!ofnode_valid(regulators_node)) {
diff --git a/drivers/sysreset/Kconfig b/drivers/sysreset/Kconfig
index cdb4ae2bb1..659170d156 100644
--- a/drivers/sysreset/Kconfig
+++ b/drivers/sysreset/Kconfig
@@ -157,6 +157,14 @@ config SYSRESET_TI_SCI
  This enables the system reset driver support over TI System Control
  Interface available on some new TI's SoCs.
 
+config SYSRESET_TPS65910
+   bool "Enable support for TPS65910/TPS65911 PMIC System Reset"
+   depends on DM_PMIC_TPS65910
+   select SYSRESET_CMD_POWEROFF if CMD_POWEROFF
+   help
+ Enable system power management functions found in TPS65910/TPS65911
+ PMICs.
+
 config SYSRESET_TPS80031
bool "Enable support for TPS80031/TPS80032 PMIC System Reset"
depends on DM_PMIC_TPS80031
diff --git a/drivers/sysreset/Makefile b/drivers/sysreset/Makefile
index f62db899da..0d96a204a9 100644
--- a/drivers/sysreset/Makefile
+++ b/drivers/sysreset/Makefile
@@ -19,6 +19,7 @@ obj-$(CONFIG_SYSRESET_SOCFPGA) += sysreset_socfpga.o
 obj-$(CONFIG_SYSRESET_SOCFPGA_SOC64) += sysreset_socfpga_soc64.o
 obj-$(CONFIG_SYSRESET_TEGRA) += sysreset_tegra.o
 obj-$(CONFIG_SYSRESET_TI_SCI) += sysreset-ti-sci.o
+obj-$(CONFIG_$(SPL_TPL_)SYSRESET_TPS65910) += sysreset_tps65910.o
 obj-$(CONFIG_$(SPL_TPL_)SYSRESET_TPS80031) += sysreset_tps80031.o
 obj-$(CONFIG_SYSRESET_SYSCON) += sysreset_syscon.o
 obj-$(CONFIG_SYSRESET_WATCHDOG) += sysreset_watchdog.o
diff --git a/drivers/sysreset/sysreset_tps65910.c 
b/drivers/sysreset/sysreset_tps65910.c
new file mode 100644
index 00..1a362dea0d
--- /dev/null
+++ b/drivers/sysreset/sysreset_tps65910.c
@@ -0,0 +1,55 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ *  Copyright(C) 2023 Svyatoslav Ryhel 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static int tps65910_sysreset_request(struct udevice *dev,
+enum sysreset_t type)
+{
+   int val;
+
+   val = pmic_reg_read(dev->parent, TPS65910_REG_DEVICE_CTRL);
+   if (val < 0)
+   return val;
+
+   /* define power-off to be sequential */
+   val |= PWR_OFF_SEQ;
+   pmic_reg_write(dev->parent, TPS65910_REG_DEVICE_CTRL, val);
+
+   val &= ~DEV_ON;
+
+   switch (type) {
+   case SYSRESET_POWER:
+   /* TPS65910: DEV_OFF_RST > DEVICE_CTRL */
+   pmic_reg_write(dev->parent, TPS65910_REG_DEVICE_CTRL,
+  val | DEV_OFF_RST);
+   break;
+   case SYSRESET_POWER_OFF:
+   /* TPS65910: DEV_OFF > DEVICE_CTRL */
+   pmic_reg_write(dev->parent, TPS65910_REG_DEVICE_CTRL,
+  val | DEV_OFF);
+   break;
+   default:
+   return -EPROTONOSUPPORT;
+   }
+
+   return -EINPROGRESS;
+}
+
+static struct sysreset_ops tps65910_sysreset = {
+   .request = tps65910_sysreset_request,
+};
+
+U_BOOT_DRIVER(sysreset_tps65910) = {
+   .id = UCLASS_SYSRESET,
+   .name   = TPS65910_RST_DRIVER,
+   .ops= &tps65910_sysreset,
+};
diff --git a/include/power/tps65910_pmic.h b/include/power/tps65910_pmic.h
index 7d6545abdf..2026ec2f42 100644
--- a/include/power/tps65910_pmic.h
+++ b/include/power/tps65910_pmic.h
@@ -17,6 +17,12 @@
 #define TPS65910_SUPPLY_STATE_OFF  0x0
 #define TPS65910_SUPPLY_STATE_ON   0x1
 
+/* TPS65910 DEVICE_C

[PATCH v2 3/6] sysreset: implement MAX77663 sysreset functions

2023-08-27 Thread Svyatoslav Ryhel
MAX77663 PMIC has embedded poweroff function used by some
device to initiane device power off. Implement it as sysreset
driver.

Signed-off-by: Svyatoslav Ryhel 
---
 drivers/power/pmic/max77663.c| 12 ++-
 drivers/sysreset/Kconfig |  7 
 drivers/sysreset/Makefile|  1 +
 drivers/sysreset/sysreset_max77663.c | 53 
 include/power/max77663.h |  5 +++
 5 files changed, 77 insertions(+), 1 deletion(-)
 create mode 100644 drivers/sysreset/sysreset_max77663.c

diff --git a/drivers/power/pmic/max77663.c b/drivers/power/pmic/max77663.c
index 4070235d3c..e333c8dcf5 100644
--- a/drivers/power/pmic/max77663.c
+++ b/drivers/power/pmic/max77663.c
@@ -9,6 +9,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -49,7 +50,16 @@ static int max77663_read(struct udevice *dev, uint reg, 
uint8_t *buff, int len)
 static int max77663_bind(struct udevice *dev)
 {
ofnode regulators_node;
-   int children;
+   int children, ret;
+
+   if (IS_ENABLED(CONFIG_SYSRESET_MAX77663)) {
+   ret = device_bind_driver(dev, MAX77663_RST_DRIVER,
+"sysreset", NULL);
+   if (ret) {
+   log_err("cannot bind SYSRESET (ret = %d)\n", ret);
+   return ret;
+   }
+   }
 
regulators_node = dev_read_subnode(dev, "regulators");
if (!ofnode_valid(regulators_node)) {
diff --git a/drivers/sysreset/Kconfig b/drivers/sysreset/Kconfig
index eab556c349..bc35896101 100644
--- a/drivers/sysreset/Kconfig
+++ b/drivers/sysreset/Kconfig
@@ -74,6 +74,13 @@ config SYSRESET_GPIO
  example on Microblaze where reset logic can be controlled via GPIO
  pin which triggers cpu reset.
 
+config SYSRESET_MAX77663
+   bool "Enable support for MAX77663 PMIC System Reset"
+   depends on DM_PMIC_MAX77663
+   select SYSRESET_CMD_POWEROFF if CMD_POWEROFF
+   help
+ Enable system power management functions found in MAX77663 PMIC.
+
 config SYSRESET_MICROBLAZE
bool "Enable support for Microblaze soft reset"
depends on MICROBLAZE
diff --git a/drivers/sysreset/Makefile b/drivers/sysreset/Makefile
index a9ac123754..c31f51c581 100644
--- a/drivers/sysreset/Makefile
+++ b/drivers/sysreset/Makefile
@@ -9,6 +9,7 @@ obj-$(CONFIG_ARCH_STI) += sysreset_sti.o
 obj-$(CONFIG_SANDBOX) += sysreset_sandbox.o
 obj-$(CONFIG_POWEROFF_GPIO) += poweroff_gpio.o
 obj-$(CONFIG_SYSRESET_GPIO) += sysreset_gpio.o
+obj-$(CONFIG_$(SPL_TPL_)SYSRESET_MAX77663) += sysreset_max77663.o
 obj-$(CONFIG_SYSRESET_MPC83XX) += sysreset_mpc83xx.o
 obj-$(CONFIG_SYSRESET_MICROBLAZE) += sysreset_microblaze.o
 obj-$(CONFIG_SYSRESET_OCTEON) += sysreset_octeon.o
diff --git a/drivers/sysreset/sysreset_max77663.c 
b/drivers/sysreset/sysreset_max77663.c
new file mode 100644
index 00..4a2a2275df
--- /dev/null
+++ b/drivers/sysreset/sysreset_max77663.c
@@ -0,0 +1,53 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ *  Copyright(C) 2023 Svyatoslav Ryhel 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static int max77663_sysreset_request(struct udevice *dev,
+enum sysreset_t type)
+{
+   int val;
+
+   val = pmic_reg_read(dev->parent, MAX77663_REG_ONOFF_CFG1);
+   if (val < 0)
+   return val;
+
+   /* clear both bits */
+   val &= ~ONOFF_SFT_RST;
+   val &= ~ONOFF_PWR_OFF;
+
+   switch (type) {
+   case SYSRESET_POWER:
+   /* MAX77663: SFT_RST > ONOFF_CFG1 */
+   pmic_reg_write(dev->parent, MAX77663_REG_ONOFF_CFG1,
+  val | ONOFF_SFT_RST);
+   break;
+   case SYSRESET_POWER_OFF:
+   /* MAX77663: PWR_OFF > ONOFF_CFG1 */
+   pmic_reg_write(dev->parent, MAX77663_REG_ONOFF_CFG1,
+  val | ONOFF_PWR_OFF);
+   break;
+   default:
+   return -EPROTONOSUPPORT;
+   }
+
+   return -EINPROGRESS;
+}
+
+static struct sysreset_ops max77663_sysreset = {
+   .request = max77663_sysreset_request,
+};
+
+U_BOOT_DRIVER(sysreset_max77663) = {
+   .id = UCLASS_SYSRESET,
+   .name   = MAX77663_RST_DRIVER,
+   .ops= &max77663_sysreset,
+};
diff --git a/include/power/max77663.h b/include/power/max77663.h
index 0f764bcbcc..b3ae3dabf4 100644
--- a/include/power/max77663.h
+++ b/include/power/max77663.h
@@ -12,6 +12,7 @@
 /* Drivers name */
 #define MAX77663_LDO_DRIVER"max77663_ldo"
 #define MAX77663_SD_DRIVER "max77663_sd"
+#define MAX77663_RST_DRIVER"max77663_rst"
 
 /* Step-Down (SD) Regulator calculations */
 #define SD_STATUS_MASK 0x30
@@ -39,4 +40,8 @@
 
 #define LDO_VOLT_BASE  80
 
+#define MAX77663_REG_ONOFF_CFG10x41
+#define   ONOFF_SFT_RST 

[PATCH v2 2/6] arm: mach-tegra: enable sysreset driver

2023-08-27 Thread Svyatoslav Ryhel
Signed-off-by: Svyatoslav Ryhel 
---
 arch/arm/mach-tegra/Kconfig | 3 +++
 arch/arm/mach-tegra/pmc.c   | 9 -
 2 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/arch/arm/mach-tegra/Kconfig b/arch/arm/mach-tegra/Kconfig
index 464bd0798f..453f94bcf2 100644
--- a/arch/arm/mach-tegra/Kconfig
+++ b/arch/arm/mach-tegra/Kconfig
@@ -61,6 +61,9 @@ config TEGRA_COMMON
select MISC
select OF_CONTROL
select SPI
+   select SYSRESET
+   select SPL_SYSRESET
+   select SYSRESET_TEGRA
imply CMD_DM
imply CRC32_VERIFY
 
diff --git a/arch/arm/mach-tegra/pmc.c b/arch/arm/mach-tegra/pmc.c
index 8d617bee63..c4f5106750 100644
--- a/arch/arm/mach-tegra/pmc.c
+++ b/arch/arm/mach-tegra/pmc.c
@@ -84,12 +84,3 @@ void tegra_pmc_writel(u32 value, unsigned long offset)
 
writel(value, NV_PA_PMC_BASE + offset);
 }
-
-void reset_cpu(void)
-{
-   u32 value;
-
-   value = tegra_pmc_readl(PMC_CNTRL);
-   value |= PMC_CNTRL_MAIN_RST;
-   tegra_pmc_writel(value, PMC_CNTRL);
-}
-- 
2.39.2



[PATCH v2 1/6] sysreset: tegra: create arch specific sysreset driver

2023-08-27 Thread Svyatoslav Ryhel
Tegra uses built in Power Management Controller (PMC) to perform
CPU reset. Code to perform this was located in mach-tegra, so lest
create DM driver to handle this.

Signed-off-by: Svyatoslav Ryhel 
---
 drivers/sysreset/Kconfig  |  6 
 drivers/sysreset/Makefile |  1 +
 drivers/sysreset/sysreset_tegra.c | 46 +++
 3 files changed, 53 insertions(+)
 create mode 100644 drivers/sysreset/sysreset_tegra.c

diff --git a/drivers/sysreset/Kconfig b/drivers/sysreset/Kconfig
index bdbe2a9536..eab556c349 100644
--- a/drivers/sysreset/Kconfig
+++ b/drivers/sysreset/Kconfig
@@ -137,6 +137,12 @@ config SYSRESET_SOCFPGA_SOC64
  This enables the system reset driver support for Intel SOCFPGA
  SoC64 SoCs.
 
+config SYSRESET_TEGRA
+   bool "Tegra PMC system reset driver"
+   depends on ARCH_TEGRA
+   help
+ This enables the system reset ability of PMC used in Tegra SoCs.
+
 config SYSRESET_TI_SCI
bool "TI System Control Interface (TI SCI) system reset driver"
depends on TI_SCI_PROTOCOL
diff --git a/drivers/sysreset/Makefile b/drivers/sysreset/Makefile
index 40c876764a..a9ac123754 100644
--- a/drivers/sysreset/Makefile
+++ b/drivers/sysreset/Makefile
@@ -16,6 +16,7 @@ obj-$(CONFIG_SYSRESET_PSCI) += sysreset_psci.o
 obj-$(CONFIG_SYSRESET_SBI) += sysreset_sbi.o
 obj-$(CONFIG_SYSRESET_SOCFPGA) += sysreset_socfpga.o
 obj-$(CONFIG_SYSRESET_SOCFPGA_SOC64) += sysreset_socfpga_soc64.o
+obj-$(CONFIG_SYSRESET_TEGRA) += sysreset_tegra.o
 obj-$(CONFIG_SYSRESET_TI_SCI) += sysreset-ti-sci.o
 obj-$(CONFIG_SYSRESET_SYSCON) += sysreset_syscon.o
 obj-$(CONFIG_SYSRESET_WATCHDOG) += sysreset_watchdog.o
diff --git a/drivers/sysreset/sysreset_tegra.c 
b/drivers/sysreset/sysreset_tegra.c
new file mode 100644
index 00..ee95826a29
--- /dev/null
+++ b/drivers/sysreset/sysreset_tegra.c
@@ -0,0 +1,46 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright(C) 2023 Svyatoslav Ryhel 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static int tegra_sysreset_request(struct udevice *dev,
+ enum sysreset_t type)
+{
+   u32 value;
+
+   switch (type) {
+   case SYSRESET_WARM:
+   case SYSRESET_COLD:
+   /* resets everything but scratch 0 and reset status */
+   value = tegra_pmc_readl(PMC_CNTRL);
+   value |= PMC_CNTRL_MAIN_RST;
+   tegra_pmc_writel(value, PMC_CNTRL);
+   break;
+   default:
+   return -EPROTONOSUPPORT;
+   }
+
+   return -EINPROGRESS;
+}
+
+static struct sysreset_ops tegra_sysreset = {
+   .request = tegra_sysreset_request,
+};
+
+U_BOOT_DRIVER(sysreset_tegra) = {
+   .id = UCLASS_SYSRESET,
+   .name   = "sysreset_tegra",
+   .ops= &tegra_sysreset,
+};
+
+/* Link to Tegra PMC once there is a driver */
+U_BOOT_DRVINFO(sysreset_tegra) = {
+   .name = "sysreset_tegra"
+};
-- 
2.39.2



[PATCH v2 0/6] Implement proper sysreset ability for Tegra SoCs and some PMICs

2023-08-27 Thread Svyatoslav Ryhel
This patchset converts do_reset from mach-tegra function to a proper
sysreset dm driver with saving all its previous abilities.

Additionally implement do_poweroff (since Tegra sysreset can only reset) by
making sysreset drivers for the most widely used PMICs on Tegra devices.
This includes sysreset cells for MAX77663, TPS80031/TPS80032,
TPS65910/TPS65911 and PALMAS PMIC family.

All drivers are tested on actual hardware and confirmed to work as
expected.

These patches require "Add support for PMICs used on Tegra 3 devices"
patches to be merged first for proper work.

https://patchwork.ozlabs.org/project/uboot/list/?series=369756

---
Changes from v1:
- move variable declaration from switch
---

Svyatoslav Ryhel (6):
  sysreset: tegra: create arch specific sysreset driver
  arm: mach-tegra: enable sysreset driver
  sysreset: implement MAX77663 sysreset functions
  sysreset: implement TPS80031 sysreset functions
  sysreset: implement TPS65910 sysreset functions
  sysreset: implement PALMAS sysreset functions

 arch/arm/mach-tegra/Kconfig   |  3 ++
 arch/arm/mach-tegra/pmc.c |  9 -
 drivers/power/pmic/max77663.c | 12 +-
 drivers/power/pmic/palmas.c   | 33 +++-
 drivers/power/pmic/pmic_tps65910_dm.c | 12 +-
 drivers/power/pmic/tps80031.c | 12 +-
 drivers/sysreset/Kconfig  | 36 ++
 drivers/sysreset/Makefile |  5 +++
 drivers/sysreset/sysreset_max77663.c  | 53 ++
 drivers/sysreset/sysreset_palmas.c| 53 ++
 drivers/sysreset/sysreset_tegra.c | 46 ++
 drivers/sysreset/sysreset_tps65910.c  | 55 +++
 drivers/sysreset/sysreset_tps80031.c  | 41 
 include/power/max77663.h  |  5 +++
 include/power/palmas.h| 11 ++
 include/power/tps65910_pmic.h |  7 
 include/power/tps80031.h  |  5 +++
 17 files changed, 384 insertions(+), 14 deletions(-)
 create mode 100644 drivers/sysreset/sysreset_max77663.c
 create mode 100644 drivers/sysreset/sysreset_palmas.c
 create mode 100644 drivers/sysreset/sysreset_tegra.c
 create mode 100644 drivers/sysreset/sysreset_tps65910.c
 create mode 100644 drivers/sysreset/sysreset_tps80031.c

-- 
2.39.2



Pull request efi-2023-10-rc4

2023-08-27 Thread Heinrich Schuchardt

Dear Tom,

The following changes since commit e508b930021168c788f14977fc101ccc1151b3c8:

  Merge https://source.denx.de/u-boot/custodians/u-boot-usb (2023-08-25
10:52:39 -0400)

are available in the Git repository at:

  https://source.denx.de/u-boot/custodians/u-boot-efi.git
tags/efi-2023-10-rc4

for you to fetch changes up to cc889bd0754e50a3cd50e8ed3094388480fbec86:

  efi_loader: delete handle from events when a protocol is uninstalled
(2023-08-27 08:21:08 +0200)

Gitlab CI showed no issues:
https://source.denx.de/u-boot/custodians/u-boot-efi/-/pipelines/17537


Pull request efi-2023-10-rc4

Documentation:

* describe TPL/VPL/SPL boot
* Add support for sphinx-prompt and convert TI K3 to use it
* board: sdm845: Explicitly add boot.img flashing command

EFI:

* remove handle from events when deleting it

Others:

* fix gpt sub-commands setenv and enumerate
* add a parameter check in hash_calculate()


Heinrich Schuchardt (5):
  lib: parameter check in hash_calculate
  cmd: fix gpt setenv
  cmd: fix gpt enumerate
  cmd: let gpt_partition_entry be hexadecimal
  doc: describe TPL/VPL/SPL boot

Ilias Apalodimas (1):
  efi_loader: delete handle from events when a protocol is uninstalled

Nishanth Menon (2):
  doc: sphinx: Add sphinx-prompt
  doc: board: ti: k3: Convert to sphinx-prompt

Sumit Garg (1):
  doc: board: sdm845: Explicitly add boot.img flashing command

 cmd/gpt.c |  22 +--
 doc/board/qualcomm/sdm845.rst |  11 +-
 doc/board/ti/k3.rst   | 112 +++
 doc/conf.py   |   2 +-
 doc/sphinx/requirements.txt   |   1 +
 doc/usage/index.rst   |   1 +
 doc/usage/spl_boot.rst| 321
++
 lib/efi_loader/efi_boottime.c |  89 
 lib/hash-checksum.c   |   6 +-
 9 files changed, 469 insertions(+), 96 deletions(-)
 create mode 100644 doc/usage/spl_boot.rst


[PATCH 1/1] cmd: gpt: fix gpt read

2023-08-27 Thread Heinrich Schuchardt
To partition a block device the partition type GUIDs are needed but 'gpt
read' does not provide these. Add the missing parts.

Part of gpt.c has been written to work with CONFIG_PARTITION_UUIDS=n. But
when reading the disk information this is not considered. Currently we let
CONFIG_CMD_GPT select CONFIG_PARTITION_UUIDS but we should enable dropping
this requirement.

Signed-off-by: Heinrich Schuchardt 
---
 cmd/gpt.c | 22 --
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/cmd/gpt.c b/cmd/gpt.c
index 964056bd28..d5d525397f 100644
--- a/cmd/gpt.c
+++ b/cmd/gpt.c
@@ -173,7 +173,10 @@ static int calc_parts_list_len(int numparts)
/* see part.h for definition of struct disk_partition */
partlistlen += numparts * (strlen("start=MiB,") + sizeof(lbaint_t) + 1);
partlistlen += numparts * (strlen("size=MiB,") + sizeof(lbaint_t) + 1);
-   partlistlen += numparts * (strlen("uuid=;") + UUID_STR_LEN + 1);
+   if (CONFIG_IS_ENABLED(PARTITION_UUIDS))
+   partlistlen += numparts * (strlen("uuid=,") + UUID_STR_LEN + 1);
+   if (IS_ENABLED(CONFIG_PARTITION_TYPE_GUID))
+   partlistlen += numparts * (strlen("type=;") + UUID_STR_LEN + 1);
/* for the terminating null */
partlistlen++;
debug("Length of partitions_list is %d for %d partitions\n", 
partlistlen,
@@ -217,6 +220,12 @@ static struct disk_part *allocate_disk_part(struct 
disk_partition *info,
/* UUID_STR_LEN is correct, as uuid[]'s length is UUID_STR_LEN+1 chars 
*/
newpart->gpt_part_info.uuid[UUID_STR_LEN] = '\0';
 #endif
+#ifdef CONFIG_PARTITION_TYPE_GUID
+   strncpy(newpart->gpt_part_info.type_guid, (const char *)info->type_guid,
+   UUID_STR_LEN);
+   newpart->gpt_part_info.type_guid[UUID_STR_LEN] = '\0';
+#endif
+
newpart->partnum = partnum;
 
return newpart;
@@ -254,6 +263,9 @@ static void print_gpt_info(void)
   curr->gpt_part_info.bootable & PART_BOOTABLE);
 #ifdef CONFIG_PARTITION_UUIDS
printf("UUID %s\n", curr->gpt_part_info.uuid);
+#endif
+#ifdef CONFIG_PARTITION_TYPE_GUID
+   printf("Type GUID %s\n", curr->gpt_part_info.type_guid);
 #endif
printf("\n");
}
@@ -298,10 +310,16 @@ static int create_gpt_partitions_list(int numparts, const 
char *guid,
(unsigned long long)curr->gpt_part_info.size *
curr->gpt_part_info.blksz);
strncat(partitions_list, partstr, PART_NAME_LEN + 1);
-
+#if CONFIG_IS_ENABLED(PARTITION_UUIDS)
strcat(partitions_list, ",uuid=");
strncat(partitions_list, curr->gpt_part_info.uuid,
UUID_STR_LEN + 1);
+#endif
+#ifdef CONFIG_PARTITION_TYPE_GUID
+   strcat(partitions_list, ",type=");
+   strncat(partitions_list, curr->gpt_part_info.type_guid,
+   UUID_STR_LEN + 1);
+#endif
strcat(partitions_list, ";");
}
return 0;
-- 
2.40.1



Re: [PATCH 1/2] tools: relocate-rela: Add M68K support

2023-08-27 Thread Angelo Dureghello

Hi Marex,

thanks,

Acked-by: Angelo Dureghello 

On 27/08/23 12:29 AM, Marek Vasut wrote:

On 8/26/23 09:44, Angelo Dureghello wrote:

Hi Marek,

thanks a lot for the job i should have done.

Tested on real hw:

m5282evb   worked out of the box
mcf54415   not working,
had a lot of unsupported relocation type for R_68K_JMP_SLOT
mcf5307    need to fix the hw, will do in short

i had to add this fix:

diff --git a/tools/relocate-rela.c b/tools/relocate-rela.c
index 2d008c7f60..9722a6291a 100644
--- a/tools/relocate-rela.c
+++ b/tools/relocate-rela.c
@@ -40,6 +40,10 @@
  #define R_68K_GLOB_DAT 20
  #endif

+#ifndef R_68K_JMP_SLOT
+#define R_68K_JMP_SLOT  21
+#endif
+
  #ifndef R_68K_RELATIVE
  #define R_68K_RELATIVE 22
  #endif
@@ -531,6 +535,9 @@ static bool supported_rela32(Elf32_Rela *rela, 
uint32_t *type)

 case R_68K_RELATIVE:
 debug("R_68K_RELATIVE\n");
 return true;
+   case R_68K_JMP_SLOT:
+    debug("R_68K_JMP_SLOT\n");
+    return true;
 }
 } else {
 switch (*type) {
@@ -631,8 +638,9 @@ static int rela_elf32(char **argv, FILE *f)
 return 4;
 }
 } else if ((machine == EM_M68K &&
-   (type == R_68K_32 || type == 
R_68K_GLOB_DAT)) ||

-  (machine == EM_MICROBLAZE &&
+   (type == R_68K_32 || type == 
R_68K_GLOB_DAT ||

+    type == R_68K_JMP_SLOT)) ||
+   (machine == EM_MICROBLAZE &&
 (type == R_MICROBLAZE_32 ||
  type == R_MICROBLAZE_GLOB_DAT))) {
 /* global symbols read it and add reloc 
offset */


Wrapped into V2, thanks