Re: [PATCH 1/1] test: fix pylint warning for capsule tests

2023-04-19 Thread Heinrich Schuchardt




On 4/20/23 00:40, Simon Glass wrote:

Hi Heinrich,

On Wed, 19 Apr 2023 at 18:30, Heinrich Schuchardt
 wrote:




On 4/19/23 03:45, Simon Glass wrote:

Hi Heinrich,

On Fri, 14 Apr 2023 at 02:34, Heinrich Schuchardt
 wrote:


Fix pylint warnings like:

* Class inherits from object
* Missing module description
* Missing class description
* First line of comment blank
* Superfluous imports

Signed-off-by: Heinrich Schuchardt 
---
   test/py/tests/test_efi_capsule/conftest.py| 27 
   .../test_capsule_firmware_fit.py  | 35 
   .../test_capsule_firmware_signed_fit.py   | 41 ++-
   .../test_capsule_firmware_signed_raw.py   | 38 -
   4 files changed, 65 insertions(+), 76 deletions(-)

diff --git a/test/py/tests/test_efi_capsule/conftest.py 
b/test/py/tests/test_efi_capsule/conftest.py
index 4879f2b5c2..0e5137de60 100644
--- a/test/py/tests/test_efi_capsule/conftest.py
+++ b/test/py/tests/test_efi_capsule/conftest.py
@@ -2,30 +2,21 @@
   # Copyright (c) 2020, Linaro Limited
   # Author: AKASHI Takahiro 

-import os
-import os.path
-import re
-from subprocess import call, check_call, check_output, CalledProcessError
-import pytest
-from capsule_defs import *
+"""Fixture for UEFI capsule test
+"""

-#
-# Fixture for UEFI capsule test
-#
+from subprocess import call, check_call, CalledProcessError
+import pytest
+from capsule_defs import CAPSULE_DATA_DIR, CAPSULE_INSTALL_DIR, EFITOOLS_PATH

   @pytest.fixture(scope='session')
   def efi_capsule_data(request, u_boot_config):
-"""Set up a file system to be used in UEFI capsule and
-   authentication test.
-
-Args:
-request: Pytest request object.
-u_boot_config: U-boot configuration.
+"""Set up a file system to be used in UEFI capsule and authentication test
+and return a ath to disk image to be used for testing


Thanks for cleaning this up. I suppose with all the rounds of review
we got tired of worrying about the style. Also this probably predates
the pylint check.

Can we please follow the style in the rest of the code? This should
have a heading line, with further notes after a blank line.



-Return:
-A path to disk image to be used for testing
+request -- Pytest request object.
+u_boot_config -- U-boot configuration.


Again the style is:

Return:
 request (pytest.Request): Request to be processed
 u_boot_config (type): U-Boot configuration


This seems to be some Google internal code style. We should stick to
PEP257 (https://peps.python.org/pep-0257/).


That doesn't really tell you much though. It is just the idea of a
docstring from 20 years ago. We need a convention for what is in the
strings, not just the strings.

The one we currently use is at least based on [1] or something like
it. I would not describe it as internal to Google. What makes you
think that? It is widely used.

For me at least, pylint asks for type information:

tools/binman/control.py:146:0: W9016: "modules, test_missing" missing
in parameter type documentation (missing-type-doc)


You should add type hints (PEP484) and use snake case (PEP8):

-def WriteEntryDocs(modules, test_missing=None):
+def write_entry_docs(modules: List[str], test_missing: str=None):

-def ListEntries(image_fname, entry_paths):
+def list_entries(image_fname: str, entry_paths: List[str]):

Best regards

Heinrich



You should be able to try that and see what you get.

Regards,
Simon

[1] https://sphinxcontrib-napoleon.readthedocs.io/en/latest/index.html


Re: [PATCH v1 4/6] video: panel: add Renesas R69328 MIPI DSI panel driver

2023-04-19 Thread Svyatoslav Ryhel
чт, 20 квіт. 2023 р. о 01:41 Simon Glass  пише:
>
> Hi Svyatoslav,
>
> On Wed, 19 Apr 2023 at 13:17, Svyatoslav Ryhel  wrote:
> >
> > Driver adds support for panels with Renesas R69328 IC
> >
> > Currently supported compatible is:
> > - jdi,dx12d100vm0eaa
> >
> > Tested-by: Andreas Westman Dorcsak  # LG P880 T30
> > Tested-by: Svyatoslav Ryhel  # LG P895 T30
> > Signed-off-by: Svyatoslav Ryhel 
> > ---
> >  drivers/video/Kconfig  |   9 ++
> >  drivers/video/Makefile |   1 +
> >  drivers/video/renesas-r69328.c | 232 +
> >  3 files changed, 242 insertions(+)
> >  create mode 100644 drivers/video/renesas-r69328.c
>
> Reviewed-by: Simon Glass 
>
> Please see below
>
> [..]
>
> > +static int renesas_r69328_enable_backlight(struct udevice *dev)
> > +{
> > +   struct renesas_r69328_priv *priv = dev_get_priv(dev);
> > +   int ret;
> > +
> > +   ret = dm_gpio_set_value(>enable_gpio, 1);
> > +   if (ret) {
> > +   printf("%s: error changing enable-gpios (%d)\n", __func__, 
> > ret);
>
> If you use log_err() then the function name is should automatically if
> CONFIG_LOGF_FUNC is enabled
>
> > +   return ret;
> > +   }
> > +   mdelay(5);
> > +
> > +   ret = dm_gpio_set_value(>reset_gpio, 0);
> > +   if (ret) {
> > +   printf("%s: error changing reset-gpios (%d)\n", __func__, 
> > ret);
> > +   return ret;
> > +   }
> > +   mdelay(5);
> > +
> > +   ret = dm_gpio_set_value(>reset_gpio, 1);
> > +   if (ret) {
> > +   printf("%s: error changing reset-gpios (%d)\n", __func__, 
> > ret);
> > +   return ret;
> > +   }
> > +
> > +   mdelay(5);
>
> Please add a comment about the delays so people know how they were
> chosen. E.g. it might be in the datasheet.
>

I would love to add reasonable arguments for these delays but unfortunately
I am not LG developer and there are no public datasheets available for either
of the panels. I have used the downstream kernel as a reference and built it
to a more modern look. In case someone can provide datasheets for this panel
or for a similar one with the same controller, this driver may be completed and
further extended for new panels. As for now it was extensively tested on p895
and p880 respectively and did not fail any time.

> > +
> > +   return 0;
> > +}
> > +
> > +static int renesas_r69328_set_backlight(struct udevice *dev, int percent)
> > +{
> > +   struct renesas_r69328_priv *priv = dev_get_priv(dev);
> > +   struct mipi_dsi_panel_plat *plat = dev_get_plat(dev);
> > +   struct mipi_dsi_device *dsi = plat->device;
> > +   int ret;
> > +
> > +   mipi_dsi_dcs_write_buffer(dsi, address_mode,
> > + sizeof(address_mode));
> > +
> > +   ret = mipi_dsi_dcs_set_pixel_format(dsi, MIPI_DCS_PIXEL_FMT_24BIT 
> > << 4);
> > +   if (ret < 0) {
> > +   printf("%s: failed to set pixel format: %d\n", __func__, 
> > ret);
> > +   return ret;
> > +   }
> > +
> > +   ret = mipi_dsi_dcs_exit_sleep_mode(dsi);
> > +   if (ret < 0) {
> > +   printf("%s: failed to exit sleep mode: %d\n", __func__, 
> > ret);
> > +   return ret;
> > +   }
> > +
> > +   mdelay(100);
>
> Wow that is a long time. Please add a comment.
>
> > +
> > +   /* MACP Off */
> > +   dsi_generic_write_seq(dsi, R69328_MACP, 0x04);
> > +
> > +   dsi_generic_write_seq(dsi, R69328_POWER_SET, 0x14,
> > + 0x1D, 0x21, 0x67, 0x11, 0x9A);
> > +
> > +   dsi_generic_write_seq(dsi, R69328_GAMMA_SET_A, 0x00,
> > + 0x1A, 0x20, 0x28, 0x25, 0x24,
> > + 0x26, 0x15, 0x13, 0x11, 0x18,
> > + 0x1E, 0x1C, 0x00, 0x00, 0x1A,
> > + 0x20, 0x28, 0x25, 0x24, 0x26,
> > + 0x15, 0x13, 0x11, 0x18, 0x1E,
> > + 0x1C, 0x00);
>
> lower-case hex
>
> > +   dsi_generic_write_seq(dsi, R69328_GAMMA_SET_B, 0x00,
> > + 0x1A, 0x20, 0x28, 0x25, 0x24,
> > + 0x26, 0x15, 0x13, 0x11, 0x18,
> > + 0x1E, 0x1C, 0x00, 0x00, 0x1A,
> > + 0x20, 0x28, 0x25, 0x24, 0x26,
> > + 0x15, 0x13, 0x11, 0x18, 0x1E,
> > + 0x1C, 0x00);
> > +   dsi_generic_write_seq(dsi, R69328_GAMMA_SET_C, 0x00,
> > + 0x1A, 0x20, 0x28, 0x25, 0x24,
> > + 0x26, 0x15, 0x13, 0x11, 0x18,
> > + 0x1E, 0x1C, 0x00, 0x00, 0x1A,
> > + 0x20, 0x28, 0x25, 0x24, 0x26,
> > + 0x15, 0x13, 0x11, 0x18, 0x1E,
> > + 0x1C, 0x00);
> > +
> > +   /* MACP On */
> > +   

Re: [PATCH V8 14/14] common: Replace #ifdef and #if with if's

2023-04-19 Thread Devarsh Thakkar
Hi Nikhil,

Thanks for the patch.
On 19/04/23 11:40, Nikhil M Jain wrote:
> Avoid using preprocessor compilation directives and instead use simple
> logical expressions for better readability since compiler will anyway
> optimize out the respective code block if condition is not satisfied.
> 
> Signed-off-by: Nikhil M Jain 
> ---
> V8:
> - Update as per review comments.
> - Call bmp_display only when CONFIG_BMP is defined.
> 
> V7(patch introduced):
> - Replace #ifdef and #if with if's.
> 
>  common/bmp.c | 14 +-
>  common/splash.c  | 14 +++---
>  include/splash.h | 11 ---
>  3 files changed, 12 insertions(+), 27 deletions(-)
> 
> diff --git a/common/bmp.c b/common/bmp.c
> index ad91351f19..57764f3653 100644
> --- a/common/bmp.c
> +++ b/common/bmp.c
> @@ -31,9 +31,9 @@
>   * by the caller after use.
>   *
>   * Returns NULL if decompression failed, or if the decompressed data
> - * didn't contain a valid BMP signature.
> + * didn't contain a valid BMP signature or decompression is not enabled in
> + * Kconfig.
>   */
> -#if CONFIG_IS_ENABLED(VIDEO_BMP_GZIP)
>  struct bmp_image *gunzip_bmp(unsigned long addr, unsigned long *lenp,
>void **alloc_addr)
>  {
> @@ -41,6 +41,9 @@ struct bmp_image *gunzip_bmp(unsigned long addr, unsigned 
> long *lenp,
>   unsigned long len;
>   struct bmp_image *bmp;
>  
> + if (!CONFIG_IS_ENABLED(VIDEO_BMP_GZIP))
> + return NULL;
> +
>   /*
>* Decompress bmp image
>*/
> @@ -77,13 +80,6 @@ struct bmp_image *gunzip_bmp(unsigned long addr, unsigned 
> long *lenp,
>   *alloc_addr = dst;
>   return bmp;
>  }
> -#else
> -struct bmp_image *gunzip_bmp(unsigned long addr, unsigned long *lenp,
> -  void **alloc_addr)
> -{
> - return NULL;
> -}
> -#endif
>  
>  #ifdef CONFIG_NEEDS_MANUAL_RELOC
>  void bmp_reloc(void)
> diff --git a/common/splash.c b/common/splash.c
> index a4e68b7042..2a6d83d695 100644
> --- a/common/splash.c
> +++ b/common/splash.c
> @@ -96,12 +96,11 @@ __weak int splash_screen_prepare(void)
>   return splash_video_logo_load();
>  }
>  
> -#if CONFIG_IS_ENABLED(SPLASH_SCREEN_ALIGN)
>  void splash_get_pos(int *x, int *y)
>  {
>   char *s = env_get("splashpos");
>  
> - if (!s)
> + if (!CONFIG_IS_ENABLED(SPLASH_SCREEN_ALIGN) || !s)
>   return;
>  
>   if (s[0] == 'm')
> @@ -117,7 +116,6 @@ void splash_get_pos(int *x, int *y)
>   *y = simple_strtol(s + 1, NULL, 0);
>   }
>  }
> -#endif /* CONFIG_SPLASH_SCREEN_ALIGN */
>  
>  #if CONFIG_IS_ENABLED(VIDEO) && !CONFIG_IS_ENABLED(HIDE_LOGO_VERSION)
>  
> @@ -159,13 +157,13 @@ void splash_display_banner(void)
>   * Common function to show a splash image if env("splashimage") is set.
>   * For additional details please refer to doc/README.splashprepare.
>   */
> -#if CONFIG_IS_ENABLED(SPLASH_SCREEN) && CONFIG_IS_ENABLED(BMP)
>  int splash_display(void)
>  {
>   ulong addr;
>   char *s;
>   int x = 0, y = 0, ret;
> -
> + if (!(CONFIG_IS_ENABLED(SPLASH_SCREEN)))
Remove extra braces as below :
if (!CONFIG_IS_ENABLED(SPLASH_SCREEN))
> + return -ENOSYS;
>   s = env_get("splashimage");
>   if (!s)
>   return -EINVAL;
> @@ -177,7 +175,10 @@ int splash_display(void)
>  
>   splash_get_pos(, );
>  
> - ret = bmp_display(addr, x, y);
> + if (CONFIG_IS_ENABLED(BMP))
> + ret = bmp_display(addr, x, y);
> + else
> + return -ENOSYS;
>  
>   /* Skip banner output on video console if the logo is not at 0,0 */
>   if (x || y)
> @@ -189,4 +190,3 @@ int splash_display(void)
>  end:
>   return ret;
>  }
> -#endif
> diff --git a/include/splash.h b/include/splash.h
> index b6a100ffc3..9027f5d978 100644
> --- a/include/splash.h
> +++ b/include/splash.h
> @@ -61,20 +61,9 @@ static inline int splash_source_load(struct 
> splash_location *locations,
>  

As Ifdefs are removed in my opinion blank lines are not needed after each
function declaration now,
>  int splash_screen_prepare(void);
>  

Remove this blank line
> -#if CONFIG_IS_ENABLED(SPLASH_SCREEN_ALIGN)
>  void splash_get_pos(int *x, int *y);
> -#else
> -static inline void splash_get_pos(int *x, int *y) { }
> -#endif
>  

Remove this blank line

With those changes,

Reviewed-by: Devarsh Thakkar 

Regards
Devarsh
> -#if CONFIG_IS_ENABLED(SPLASH_SCREEN) && CONFIG_IS_ENABLED(BMP)
>  int splash_display(void);
> -#else
> -static inline int splash_display(void)
> -{
> - return -ENOSYS;
> -}
> -#endif
>  
>  #define BMP_ALIGN_CENTER 0x7FFF
>  


Re: [PATCH v1 2/6] video: bridge: add Solomon SSD2825 DSI/LVDS driver

2023-04-19 Thread Svyatoslav Ryhel
чт, 20 квіт. 2023 р. о 01:41 Simon Glass  пише:
>
> Hi Svyatoslav,
>
> On Wed, 19 Apr 2023 at 13:17, Svyatoslav Ryhel  wrote:
> >
> > SSD2825 is an innovative and cost-effective MIPI Bridge Chip solution
> > targeting high resolution smartphones. It can convert 24bit RGB
> > interface into 4-lane MIPI-DSI interface to drive extremely high
> > resolution display modules of up to 800 x 1366, while supporting AMOLED,
> > a-si LCD or LTPS advanced panel technologies for smartphone applications.
> >
> > Bridge is wrapped in panel uClass model for wider compatibility.
> >
> > Tested-by: Andreas Westman Dorcsak  # LG P880 T30
> > Tested-by: Svyatoslav Ryhel  # LG P895 T30
> > Signed-off-by: Svyatoslav Ryhel 
> > ---
> >  drivers/video/bridge/Kconfig   |   7 +
> >  drivers/video/bridge/Makefile  |   1 +
> >  drivers/video/bridge/ssd2825.c | 523 +
> >  3 files changed, 531 insertions(+)
> >  create mode 100644 drivers/video/bridge/ssd2825.c
> >
>
> [..]
>
> > +static int ssd2825_spi_write(struct udevice *dev, int reg,
> > +const void *buf, int flags)
> > +{
> > +   struct spi_slave *slave = dev_get_parent_priv(dev);
> > +   u8 command[2];
> > +
> > +   if (flags & SSD2825_CMD_SEND) {
> > +   command[0] = SSD2825_CMD_MASK;
> > +   command[1] = reg;
> > +   spi_xfer(slave, 9, ,
> > +NULL, SPI_XFER_ONCE);
>
> Please can you use dm_spi_xfer() instead, thoughout?
>

I will replace it, but isn't spi_xfer preferable over dm_spi_xfer?
I remember that I had doubts about which to use.

> Also note that when you add a printf() for errors, the string is
> stored and it increases code size. It might be better to use
> log_debug(), unless the errors are likely.
>
> [..]
>
> Regards,
> Simon


Re: [PATCH v5 4/4] test/py: efi_capsule: test for FMP versioning

2023-04-19 Thread Masahisa Kojima
Hi Simon,

On Wed, 19 Apr 2023 at 10:47, Simon Glass  wrote:
>
> Hi Masahisa,
>
> On Mon, 10 Apr 2023 at 03:07, Masahisa Kojima
>  wrote:
> >
> > This test covers FMP versioning for both raw and FIT image,
> > and both signed and non-signed capsule update.
> >
> > Signed-off-by: Masahisa Kojima 
> > ---
> > Changes in v5:
> > - get aligned to the device tree based versioning
> >
> > Newly created in v4
> >
> >  test/py/tests/test_efi_capsule/conftest.py|  73 +++
> >  .../test_capsule_firmware_fit.py  | 187 
> >  .../test_capsule_firmware_raw.py  | 201 ++
> >  .../test_capsule_firmware_signed_fit.py   | 165 ++
> >  .../test_capsule_firmware_signed_raw.py   | 169 +++
> >  test/py/tests/test_efi_capsule/version.dts|  27 +++
> >  6 files changed, 822 insertions(+)
> >  create mode 100644 test/py/tests/test_efi_capsule/version.dts
>
> I hate to say this, but we must fix the reboot stuff here before
> adding more code.

I read the previous discussion.
https://lore.kernel.org/u-boot/164388018493.446835.11931101380744085380.stgit@localhost/

>
> The test needs to tell U-Boot to do the update (e.g. via a command),
> then continue. It should not reboot sandbox.I have said this before
> but the feedback was not understood or taken. If you need help
> designing this, please let me know. In fact I am happy to create a
> patch for one of the tests if that is what it takes to convey this.

Current efi capsule update test tries to verify the following behavior
stated in the UEFI spec v2.10, so the reboot is required to trigger
the capsule update.

=== quote from UEFI v2.10 P.243
8.5.5 Delivery of Capsules via file on Mass Storage Device

As an alternative to the UpdateCapsule() runtime API, capsules of any
type supported by platform may also be delivered to firmware via a
file within the EFI system partition on the mass storage device
targeted for boot. Capsules staged using this method are processed on
the next system restart. This method is only available when booting
from mass storage devices which are formatted with GPT and contain an
EFI System Partition in the device image. System firmware will search
for capsule when EFI_OS_INDICATIONS_FILE_CAPSULE_DELIVERY_SUPPORTED
bit in OsIndications is set as described in Exchanging information
between the OS and Firmware.
===

>
> Also, while it is normal to have a fair bit of duplication in tests,
> just to make them easier to read, it does make them hard to m
aintain,
> and the duplication here seems very large.
>
> We have the same code repeated but with different code style or
> indentation. Sorry, but this is not setting us up for the future, in
> terms of maintaining this code. Just search for 'env set -e -nv -bs
> -rt OsIndications =0x0004' for example.
>
> The common code needs to go in functions in a separate Python file, as
> we have done for other tests. The goal should be to use the same code
> for the same functions. Sure there will be some duplication, but it is
> too much.
>
> These fixes should happen before we accept any more non=trivial
> patches to this code.

I agree, I will try to create common functions to reduce code duplication.

>
> BTW I do wonder whether the test would be better written mostly in C,
> since from what I can see, it mostly just runs commands. You can still
> have a Python wrapper - see for example how test_vbe works. It uses
> 'ut xxx -f' to execute the C part of a Python test. You can do setup
> in Python, then run the C test. What do you think?

It is just my opinion, if the test requires some setup in Python, I like Python
to write the test cases as far as tests can be implemented in Python,
because we can maintain the test code in one place.

Thanks,
Masahisa Kojima

>
> Regards,
> Simon


Re: [RESEND PATCH v2] netconsole: various improvements

2023-04-19 Thread Tony Dinh
On Wed, Apr 19, 2023 at 6:22 PM Tony Dinh  wrote:
>
> HI Simon,
>
> On Tue, Apr 18, 2023 at 6:46 PM Simon Glass  wrote:
> >
> > Hi Tony,
> >
> > On Mon, 3 Apr 2023 at 15:42, Tony Dinh  wrote:
> > >
> > > Use CONFIG_CONSOLE_MUX for netconsole. When netconsole is running,
> > > stdin/stdout/stder must be set to some primary console, in addtion to nc.
> > > For example, stdin=serial,nc. Some recent Linux kernels will not boot with
> > > only nc on the stdout list, ie. stdout=nc. When netconsole exits, remove
> > > nc from the list of devices in stdin/stdout/stderr.
> > >
> > > Signed-off-by: Tony Dinh 
> > > ---
> > >
> > > Changes in v2:
> > > - Select CONFIG_CONSOLE_MUX if CONFIG_NETCONSOLE is enabled
> > > - Add new functions in netconsole driver to support CONSOLE_MUX
> > > - Add new function to encapsulate the process of stopping netconsole
> > > from bootm
> > > - Remove unecessary net_timeout initial value = 1
> > > - Resend to correct missing  include in bootm.c
> > >
> > >  boot/bootm.c | 14 +++---
> > >  drivers/net/Kconfig  | 10 +++
> > >  drivers/net/netconsole.c | 60 
> > >  include/stdio_dev.h  |  1 +
> > >  4 files changed, 81 insertions(+), 4 deletions(-)
> >
> > This seems OK to me but for a few thoughts below.
> >
> > But can we use this opportunity to move this to driver model? The
> > netconsole driver could be bound in eth_post_bind() and the code in
> > netconsole.c converted to be a driver.
> >
> > I think that would be better than building on an out-of-date driver.
>
> I'd agree that converting to a driver model is the logical next step.
> My motivation is to fix the booting problem for the Linux kernel first
> (I'm having problems booting some kernels without this patch). And
> then in the next go round, I'll convert netconsole to a driver. Most
> of the code in this small patch will be needed whether it is an old
> driver or DM anyway.
>
> >
> > >
> > > diff --git a/boot/bootm.c b/boot/bootm.c
> > > index 2eec60ec7b..1b2542b570 100644
> > > --- a/boot/bootm.c
> > > +++ b/boot/bootm.c
> > > @@ -18,6 +18,7 @@
> > >  #include 
> > >  #include 
> > >  #include 
> > > +#include 
> > >  #include 
> > >  #include 
> > >  #include 
> > > @@ -472,11 +473,16 @@ ulong bootm_disable_interrupts(void)
> > >  * recover from any failures any more...
> > >  */
> > > iflag = disable_interrupts();
> > > -#ifdef CONFIG_NETCONSOLE
> > > -   /* Stop the ethernet stack if NetConsole could have left it up */
> > > -   eth_halt();
> > > -#endif
> > >
> > > +   if (IS_ENABLED(CONFIG_NETCONSOLE)) {
> > > +   /*
> > > +* Make sure that the starting kernel message printed out,
> > > +* stop netconsole and the ethernet stack
> > > +*/
> > > +   printf("\n\nStarting kernel ...\n\n");
> > > +   drv_nc_stop();
> > > +   eth_halt();
> > > +   }
> > >  #if defined(CONFIG_CMD_USB)
> > > /*
> > >  * turn off USB to prevent the host controller from writing to the
> > > diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
> > > index ceadee98a1..0661059dfa 100644
> > > --- a/drivers/net/Kconfig
> > > +++ b/drivers/net/Kconfig
> > > @@ -945,4 +945,14 @@ config MDIO_MUX_MESON_G12A
> > >   This driver is used for the MDIO mux found on the Amlogic G12A 
> > > & compatible
> > >   SoCs.
> > >
> > > +config NETCONSOLE
> > > +   bool "Enable netconsole"
> > > +   select CONSOLE_MUX
> > > +   help
> > > + NetConsole requires CONSOLE_MUX, i.e. at least one default 
> > > console such
> > > + must be specified in addition to nc console. For example, for 
> > > boards that
> > > + the main console is serial, set each of the envs 
> > > stdin/stdout/stderr to serial,nc.
> > > + See CONFIG_CONSOLE_MUX and CONFIG_SYS_CONSOLE_IS_IN_ENV help 
> > > for detailed
> > > + description of usage.
> > > +
> > >  endif # NETDEVICES
> > > diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
> > > index 151bc55e07..bb92d2e130 100644
> > > --- a/drivers/net/netconsole.c
> > > +++ b/drivers/net/netconsole.c
> > > @@ -7,6 +7,7 @@
> > >  #include 
> > >  #include 
> > >  #include 
> > > +#include 
> > >  #include 
> > >  #include 
> > >  #include 
> > > @@ -33,6 +34,12 @@ static int output_packet_len;
> > >   */
> > >  enum proto_t net_loop_last_protocol = BOOTP;
> > >
> > > +/*
> > > + * Net console helpers
> > > + */
> > > +static void usage(void);
> > > +static void remove_nc_from(const int console);
> > > +
> > >  static void nc_wait_arp_handler(uchar *pkt, unsigned dest,
> > >  struct in_addr sip, unsigned src,
> > >  unsigned len)
> > > @@ -111,6 +118,21 @@ static int refresh_settings_from_env(void)
> > > return 0;
> > >  }
> > >
> > > +static void remove_nc_from(const int 

Re: [PATCH v5 00/17] Basic StarFive JH7110 RISC-V SoC support

2023-04-19 Thread Leo Liang
Hi YanHong, Torsten, Matthias,

On Thu, Apr 13, 2023 at 06:05:56PM +0800, yanhong wang wrote:
> 
> 
> On 2023/4/13 17:03, Torsten Duwe wrote:
> > On Thu, 13 Apr 2023 10:05:28 +0800
> > yanhong wang  wrote:
> > 
> >> the definition of DT refers to Linux and is consistent with the definition 
> >> framework of Linux.
> > 
> > This is one of the desired goals, to avoid confusion, usually. But note 
> > there are already the
> > -u-boot.dtsi files; in this case it would be vice-versa: U-Boot could be 
> > simple, the kernel
> > required a different treatment. As long as the resulting tree matches the 
> > hardware!
> > 
> >> The difference between 1.2A and 1.3B is the PHY type and phy clock delay 
> >> configuration, 
> >> which are reflected in DT, and the difference in defconfig is the 
> >> configuration of the DT file.
> >> 
> >> Is defconfig defined separately or merged?
> > 
> > You are the implementer, this is your decision. You make a proposal, and it 
> > will get accepted
> > or not. We only make suggestions, with the intention to improve the code.
> > 
> 
> Thanks. A defconfig matches a piece of hardware, which is more 
> developer-friendly and less confusing, 
> so defconfig is better defined separately.
> 
> >> The EEPROM is being prepared and will be submitted as soon as possible. Is 
> >> it necessary to 
> >> incorporate EEPROM into this submission?
> >>
> >> When eeprom is supported, the MAC address will be read from eeprom. The 
> >> board reversion 
> >> can be read from eeprom, but phy clock delay configuration cannot be read 
> >> from eeprom, only in DT.
> > 
> > But the board revision number in EEPROM can be used to differentiate 
> > between 1.2 and 1.3, right?
> > 
> 
> Yes, board reversion read from eeprom can distinguish between 1.2A and 1.3B.
> 
> 1.2A and 1.3B are two sets of hardware, and the differences between the 
> hardware are defined
> by DT, which is more concise and clear.
> 
> > When I look at the code and my test results, this is my proposal to pull 
> > this in, in order to
> > simplify things and avoid duplication. Whether you do so is up to you, see 
> > above. Let me recap:
> > 
> > * the device tree *must* match the hardware at hand.
> > 
> > * the differences are minor and could be patched, Copy is error prone 
> > and causes extra work.
> > 
> > It is my firm conviction that this patch set does not introduce hardware 
> > variants, and it would be
> > the task of the ethernet driver patch set to split the code (DT+defconfig) 
> > OR to provide a patching
> > method. Maybe I find a few cycles to look at the EEPROM.
> > 
> > Torsten

Agree with Torsten.

I too IMHO think it makes much sense that 
whether "to split the (DT + defconfig)" or "patching DT"
should be the task of ethernet driver patch.

However, this patch set is rather complete and stay on the ML
for quite a time. And also Torsten has sent out the RFC patch 
that is going for the patching method.

In that sense, I think I could probably merge this v5 patch set
with [v4 17/17] patch that only introduces a single defconfig,
and wait for Torsten's DT patches if you guys agree.

Any thoughts?

Best regards,
Leo


Re: [RESEND PATCH v2] netconsole: various improvements

2023-04-19 Thread Tony Dinh
HI Simon,

On Tue, Apr 18, 2023 at 6:46 PM Simon Glass  wrote:
>
> Hi Tony,
>
> On Mon, 3 Apr 2023 at 15:42, Tony Dinh  wrote:
> >
> > Use CONFIG_CONSOLE_MUX for netconsole. When netconsole is running,
> > stdin/stdout/stder must be set to some primary console, in addtion to nc.
> > For example, stdin=serial,nc. Some recent Linux kernels will not boot with
> > only nc on the stdout list, ie. stdout=nc. When netconsole exits, remove
> > nc from the list of devices in stdin/stdout/stderr.
> >
> > Signed-off-by: Tony Dinh 
> > ---
> >
> > Changes in v2:
> > - Select CONFIG_CONSOLE_MUX if CONFIG_NETCONSOLE is enabled
> > - Add new functions in netconsole driver to support CONSOLE_MUX
> > - Add new function to encapsulate the process of stopping netconsole
> > from bootm
> > - Remove unecessary net_timeout initial value = 1
> > - Resend to correct missing  include in bootm.c
> >
> >  boot/bootm.c | 14 +++---
> >  drivers/net/Kconfig  | 10 +++
> >  drivers/net/netconsole.c | 60 
> >  include/stdio_dev.h  |  1 +
> >  4 files changed, 81 insertions(+), 4 deletions(-)
>
> This seems OK to me but for a few thoughts below.
>
> But can we use this opportunity to move this to driver model? The
> netconsole driver could be bound in eth_post_bind() and the code in
> netconsole.c converted to be a driver.
>
> I think that would be better than building on an out-of-date driver.

I'd agree that converting to a driver model is the logical next step.
My motivation is to fix the booting problem for the Linux kernel first
(I'm having problems booting some kernels without this patch). And
then in the next go round, I'll convert netconsole to a driver. Most
of the code in this small patch will be needed whether it is an old
driver or DM anyway.

>
> >
> > diff --git a/boot/bootm.c b/boot/bootm.c
> > index 2eec60ec7b..1b2542b570 100644
> > --- a/boot/bootm.c
> > +++ b/boot/bootm.c
> > @@ -18,6 +18,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> > @@ -472,11 +473,16 @@ ulong bootm_disable_interrupts(void)
> >  * recover from any failures any more...
> >  */
> > iflag = disable_interrupts();
> > -#ifdef CONFIG_NETCONSOLE
> > -   /* Stop the ethernet stack if NetConsole could have left it up */
> > -   eth_halt();
> > -#endif
> >
> > +   if (IS_ENABLED(CONFIG_NETCONSOLE)) {
> > +   /*
> > +* Make sure that the starting kernel message printed out,
> > +* stop netconsole and the ethernet stack
> > +*/
> > +   printf("\n\nStarting kernel ...\n\n");
> > +   drv_nc_stop();
> > +   eth_halt();
> > +   }
> >  #if defined(CONFIG_CMD_USB)
> > /*
> >  * turn off USB to prevent the host controller from writing to the
> > diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
> > index ceadee98a1..0661059dfa 100644
> > --- a/drivers/net/Kconfig
> > +++ b/drivers/net/Kconfig
> > @@ -945,4 +945,14 @@ config MDIO_MUX_MESON_G12A
> >   This driver is used for the MDIO mux found on the Amlogic G12A & 
> > compatible
> >   SoCs.
> >
> > +config NETCONSOLE
> > +   bool "Enable netconsole"
> > +   select CONSOLE_MUX
> > +   help
> > + NetConsole requires CONSOLE_MUX, i.e. at least one default 
> > console such
> > + must be specified in addition to nc console. For example, for 
> > boards that
> > + the main console is serial, set each of the envs 
> > stdin/stdout/stderr to serial,nc.
> > + See CONFIG_CONSOLE_MUX and CONFIG_SYS_CONSOLE_IS_IN_ENV help for 
> > detailed
> > + description of usage.
> > +
> >  endif # NETDEVICES
> > diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
> > index 151bc55e07..bb92d2e130 100644
> > --- a/drivers/net/netconsole.c
> > +++ b/drivers/net/netconsole.c
> > @@ -7,6 +7,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  #include 
> >  #include 
> >  #include 
> > @@ -33,6 +34,12 @@ static int output_packet_len;
> >   */
> >  enum proto_t net_loop_last_protocol = BOOTP;
> >
> > +/*
> > + * Net console helpers
> > + */
> > +static void usage(void);
> > +static void remove_nc_from(const int console);
> > +
> >  static void nc_wait_arp_handler(uchar *pkt, unsigned dest,
> >  struct in_addr sip, unsigned src,
> >  unsigned len)
> > @@ -111,6 +118,21 @@ static int refresh_settings_from_env(void)
> > return 0;
> >  }
> >
> > +static void remove_nc_from(const int console)
> > +{
> > +   int ret;
> > +
> > +   ret = iomux_replace_device(console, "nc", "nulldev");
> > +   if (ret) {
> > +   printf("\n*** Warning: Cannot remove nc from %s Error=%d\n",
> > +   stdio_names[console], ret);
> > +   printf("%s=", 

[PATCH 2/2] sunxi: defconfig: Add Lctech Pi F1C200s board

2023-04-19 Thread Andre Przywara
The Lctech Pi F1C200s (also previously known under the Cherry Pi brand)
is a small development board with the Allwinner F1C200s SoC. This is the
same as the F1C100s, but with 64MB instead of 32MB co-packaged DRAM.

Add a defconfig for this board, enabling the most basic features. This
uses the new 64MB memory map, which avoids the very tight memory map we
use for the 32MB F1C100s board(s).
The devicetree file is already in the tree, courtesy of the previous
Linux repo sync.

Signed-off-by: Andre Przywara 
---
 configs/lctech_pi_f1c200s_defconfig | 11 +++
 1 file changed, 11 insertions(+)
 create mode 100644 configs/lctech_pi_f1c200s_defconfig

diff --git a/configs/lctech_pi_f1c200s_defconfig 
b/configs/lctech_pi_f1c200s_defconfig
new file mode 100644
index 000..310719cf915
--- /dev/null
+++ b/configs/lctech_pi_f1c200s_defconfig
@@ -0,0 +1,11 @@
+CONFIG_ARM=y
+CONFIG_ARCH_SUNXI=y
+CONFIG_DEFAULT_DEVICE_TREE="suniv-f1c200s-lctech-pi"
+CONFIG_SPL=y
+CONFIG_MACH_SUNIV=y
+CONFIG_DRAM_CLK=156
+CONFIG_DRAM_ZQ=0
+CONFIG_SUNXI_MINIMUM_DRAM_MB=64
+# CONFIG_VIDEO_SUNXI is not set
+CONFIG_CONS_INDEX=2
+CONFIG_SPI=y
-- 
2.35.7



[PATCH 1/2] sunxi: dts: arm/arm64: update devicetree files from Linux-v6.4 queue

2023-04-19 Thread Andre Przywara
Sync the devicetree files from the sunxi Linux queue [1], to match
the Linux 6.4-rc pull request. Those patches are in Linux-next for a bit
now. This is covering both 64-bit and 32-bit Allwinner SoCs with Arm
Ltd. cores, we skip the new RISC-V bits for now, as sunxi RISC-V support
for U-Boot is still work in progress.

Among smaller cosmetic changes, this adds a SATA regulator node which we
need in U-Boot to get rid of hard-coded GPIOs.
Also this updates the Allwinner F1C100s DTs, adding its USB nodes, and
also adding the DTs for two new boards.

As before, this omits the non-backwards compatible changes to the R_INTC
controller, to remain compatible with older kernels.

[1] 
https://git.kernel.org/pub/scm/linux/kernel/git/sunxi/linux.git/commit/?h=sunxi/dt-for-6.4=20c5db6c3d79d357c9d787edad3bbf03d98a08bf

Signed-off-by: Andre Przywara 
---
 arch/arm/dts/sun50i-h5-orangepi-pc2.dts  |  1 +
 arch/arm/dts/sun5i-gr8-chip-pro.dts  |  2 +-
 arch/arm/dts/sun5i-r8-chip.dts   |  2 +-
 arch/arm/dts/sun6i-a31s-sina31s.dts  |  2 +-
 arch/arm/dts/sun8i-a33.dtsi  |  1 +
 arch/arm/dts/sun8i-a83t-bananapi-m3.dts  | 15 
 arch/arm/dts/sun8i-h3-beelink-x2.dts |  2 +-
 arch/arm/dts/sun8i-h3-nanopi-duo2.dts|  2 +-
 arch/arm/dts/suniv-f1c100s-licheepi-nano.dts | 16 
 arch/arm/dts/suniv-f1c100s.dtsi  | 32 
 arch/arm/dts/suniv-f1c200s-lctech-pi.dts | 76 ++
 arch/arm/dts/suniv-f1c200s-popstick-v1.1.dts | 81 
 12 files changed, 227 insertions(+), 5 deletions(-)
 create mode 100644 arch/arm/dts/suniv-f1c200s-lctech-pi.dts
 create mode 100644 arch/arm/dts/suniv-f1c200s-popstick-v1.1.dts

diff --git a/arch/arm/dts/sun50i-h5-orangepi-pc2.dts 
b/arch/arm/dts/sun50i-h5-orangepi-pc2.dts
index b5c1ff19b4c..ce3ae19e72d 100644
--- a/arch/arm/dts/sun50i-h5-orangepi-pc2.dts
+++ b/arch/arm/dts/sun50i-h5-orangepi-pc2.dts
@@ -3,6 +3,7 @@
 
 /dts-v1/;
 #include "sun50i-h5.dtsi"
+#include "sun50i-h5-cpu-opp.dtsi"
 
 #include 
 #include 
diff --git a/arch/arm/dts/sun5i-gr8-chip-pro.dts 
b/arch/arm/dts/sun5i-gr8-chip-pro.dts
index a32cde3e32e..5c3562b85a5 100644
--- a/arch/arm/dts/sun5i-gr8-chip-pro.dts
+++ b/arch/arm/dts/sun5i-gr8-chip-pro.dts
@@ -70,7 +70,7 @@
leds {
compatible = "gpio-leds";
 
-   status {
+   led-0 {
label = "chip-pro:white:status";
gpios = <_gpio 2 GPIO_ACTIVE_HIGH>;
default-state = "on";
diff --git a/arch/arm/dts/sun5i-r8-chip.dts b/arch/arm/dts/sun5i-r8-chip.dts
index 4bf4943d4eb..fd37bd1f392 100644
--- a/arch/arm/dts/sun5i-r8-chip.dts
+++ b/arch/arm/dts/sun5i-r8-chip.dts
@@ -70,7 +70,7 @@
leds {
compatible = "gpio-leds";
 
-   status {
+   led-0 {
label = "chip:white:status";
gpios = <_gpio 2 GPIO_ACTIVE_HIGH>;
default-state = "on";
diff --git a/arch/arm/dts/sun6i-a31s-sina31s.dts 
b/arch/arm/dts/sun6i-a31s-sina31s.dts
index 0af48e143b6..56956352914 100644
--- a/arch/arm/dts/sun6i-a31s-sina31s.dts
+++ b/arch/arm/dts/sun6i-a31s-sina31s.dts
@@ -67,7 +67,7 @@
leds {
compatible = "gpio-leds";
 
-   status {
+   led-0 {
label = "sina31s:status:usr";
gpios = < 7 13 GPIO_ACTIVE_HIGH>; /* PH13 */
};
diff --git a/arch/arm/dts/sun8i-a33.dtsi b/arch/arm/dts/sun8i-a33.dtsi
index b3d1bdfb511..30fdd2703b1 100644
--- a/arch/arm/dts/sun8i-a33.dtsi
+++ b/arch/arm/dts/sun8i-a33.dtsi
@@ -278,6 +278,7 @@
dphy: d-phy@1ca1000 {
compatible = "allwinner,sun6i-a31-mipi-dphy";
reg = <0x01ca1000 0x1000>;
+   interrupts = ;
clocks = < CLK_BUS_MIPI_DSI>,
 < CLK_DSI_DPHY>;
clock-names = "bus", "mod";
diff --git a/arch/arm/dts/sun8i-a83t-bananapi-m3.dts 
b/arch/arm/dts/sun8i-a83t-bananapi-m3.dts
index b60016a4429..197cf6959b5 100644
--- a/arch/arm/dts/sun8i-a83t-bananapi-m3.dts
+++ b/arch/arm/dts/sun8i-a83t-bananapi-m3.dts
@@ -105,6 +105,21 @@
/* enables internal regulator and de-asserts reset */
reset-gpios = <_pio 0 2 GPIO_ACTIVE_LOW>; /* PL2 WL-PMU-EN */
};
+
+   /*
+* Power supply for the SATA disk, behind a USB-SATA bridge.
+* Since it is a USB device, there is no consumer in the DT, so we
+* have to keep this always on.
+*/
+   regulator-sata-disk-pwr {
+   compatible = "regulator-fixed";
+   regulator-name = "sata-disk-pwr";
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   regulator-always-on;
+   enable-active-high;
+  

[PATCH v3 35/43] x86: Record the start and end of the tables

2023-04-19 Thread Simon Glass
The ACPI tables are special in that they are passed to EFI as a separate
piece, independent of other tables.

Also they can be spread over two areas of memory, e.g. with QEMU we end
up with tables kept in high memory as well.

Add new global_data fields to hold this information and update the bdinfo
command to show the table areas.

Move the rom_table_end variable into the loop that uses it.

Signed-off-by: Simon Glass 
---

Changes in v3:
- Adjust the code to handle qemu writing a pointer to tables in memory

Changes in v2:
- Handle the case where the tables are in the bloblist

 arch/sandbox/include/asm/global_data.h |  4 
 arch/x86/include/asm/global_data.h |  4 
 arch/x86/lib/bdinfo.c  |  4 
 arch/x86/lib/tables.c  | 18 +-
 drivers/misc/qfw.c |  8 
 5 files changed, 37 insertions(+), 1 deletion(-)

diff --git a/arch/sandbox/include/asm/global_data.h 
b/arch/sandbox/include/asm/global_data.h
index f4ce72d56602..f0ab3ba5c146 100644
--- a/arch/sandbox/include/asm/global_data.h
+++ b/arch/sandbox/include/asm/global_data.h
@@ -13,6 +13,10 @@
 struct arch_global_data {
uint8_t *ram_buf;   /* emulated RAM buffer */
void*text_base; /* pointer to base of text region */
+   ulong table_start;  /* Start address of x86 tables */
+   ulong table_end;/* End address of x86 tables */
+   ulong table_start_high; /* Start address of high x86 tables */
+   ulong table_end_high;   /* End address of high x86 tables */
 };
 
 #include 
diff --git a/arch/x86/include/asm/global_data.h 
b/arch/x86/include/asm/global_data.h
index 22d103df4ee8..ea58259ad774 100644
--- a/arch/x86/include/asm/global_data.h
+++ b/arch/x86/include/asm/global_data.h
@@ -123,6 +123,10 @@ struct arch_global_data {
 #endif
void *itss_priv;/* Private ITSS data pointer */
ulong coreboot_table;   /* Address of coreboot table */
+   ulong table_start;  /* Start address of x86 tables */
+   ulong table_end;/* End address of x86 tables */
+   ulong table_start_high; /* Start address of high x86 tables */
+   ulong table_end_high;   /* End address of high x86 tables */
 };
 
 #endif
diff --git a/arch/x86/lib/bdinfo.c b/arch/x86/lib/bdinfo.c
index 0970efa4726f..9504e7fc293e 100644
--- a/arch/x86/lib/bdinfo.c
+++ b/arch/x86/lib/bdinfo.c
@@ -23,6 +23,10 @@ void arch_print_bdinfo(void)
bdinfo_print_str(" name", cpu_vendor_name(gd->arch.x86_vendor));
bdinfo_print_num_l("model", gd->arch.x86_model);
bdinfo_print_num_l("phys_addr", cpu_phys_address_size());
+   bdinfo_print_num_l("table start", gd->arch.table_start);
+   bdinfo_print_num_l("table end", gd->arch.table_end);
+   bdinfo_print_num_l(" high start", gd->arch.table_start_high);
+   bdinfo_print_num_l(" high end", gd->arch.table_end_high);
 
if (IS_ENABLED(CONFIG_EFI_STUB))
efi_show_bdinfo();
diff --git a/arch/x86/lib/tables.c b/arch/x86/lib/tables.c
index 132c02ee80f4..d95fdb205000 100644
--- a/arch/x86/lib/tables.c
+++ b/arch/x86/lib/tables.c
@@ -54,6 +54,10 @@ static struct table_info table_list[] = {
 #ifdef CONFIG_GENERATE_MP_TABLE
{ "mp", write_mp_table, },
 #endif
+   /*
+* tables which can go in the bloblist must be last in this list, so
+* that the calculation of gd->table_end works properly
+*/
 #ifdef CONFIG_GENERATE_ACPI_TABLE
{ "acpi", write_acpi_tables, BLOBLISTT_ACPI_TABLES, 0x1, 0x1000},
 #endif
@@ -80,10 +84,12 @@ int write_tables(void)
 {
u32 high_table, table_size;
struct memory_area cfg_tables[ARRAY_SIZE(table_list) + 1];
+   bool use_high = false;
u32 rom_addr;
int i;
 
-   rom_addr = ROM_TABLE_ADDR;
+   gd->arch.table_start = ROM_TABLE_ADDR;
+   rom_addr = gd->arch.table_start;
 
debug("Writing tables to %x:\n", rom_addr);
for (i = 0; i < ARRAY_SIZE(table_list); i++) {
@@ -92,10 +98,15 @@ int write_tables(void)
u32 rom_table_end;
 
if (IS_ENABLED(CONFIG_BLOBLIST_TABLES) && table->tag) {
+   if (!gd->arch.table_end)
+   gd->arch.table_end = rom_addr;
rom_addr = (ulong)bloblist_add(table->tag, size,
  table->align);
if (!rom_addr)
return log_msg_ret("bloblist", -ENOBUFS);
+   use_high = true;
+   if (!gd->arch.table_start_high)
+   gd->arch.table_start_high = rom_addr;
}
rom_table_end = table->write(rom_addr);
if (!rom_table_end) {
@@ -132,6 +143,11 @@ int write_tables(void)

[PATCH v3 34/43] x86: Refactor table-writing code a litlle

2023-04-19 Thread Simon Glass
The implementation of write_tables() is confusing because it uses the
rom_table_start variable as the address pointer as it progresses.

Rename it to rom_addr to make the code clearer. Move the rom_table_end
variable into the block where it is used.

Also update logging to use the ACPI category, now that it is available.

Signed-off-by: Simon Glass 
---

Changes in v3:
- Add new patch to refactor table-writing code a ltitle

 arch/x86/lib/tables.c | 26 +-
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/arch/x86/lib/tables.c b/arch/x86/lib/tables.c
index ea834a5035f5..132c02ee80f4 100644
--- a/arch/x86/lib/tables.c
+++ b/arch/x86/lib/tables.c
@@ -3,7 +3,7 @@
  * Copyright (C) 2015, Bin Meng 
  */
 
-#define LOG_CATEGORY LOGC_BOARD
+#define LOG_CATEGORY LOGC_ACPI
 
 #include 
 #include 
@@ -78,33 +78,33 @@ void table_fill_string(char *dest, const char *src, size_t 
n, char pad)
 
 int write_tables(void)
 {
-   u32 rom_table_start;
-   u32 rom_table_end;
u32 high_table, table_size;
struct memory_area cfg_tables[ARRAY_SIZE(table_list) + 1];
+   u32 rom_addr;
int i;
 
-   rom_table_start = ROM_TABLE_ADDR;
+   rom_addr = ROM_TABLE_ADDR;
 
-   debug("Writing tables to %x:\n", rom_table_start);
+   debug("Writing tables to %x:\n", rom_addr);
for (i = 0; i < ARRAY_SIZE(table_list); i++) {
const struct table_info *table = _list[i];
int size = table->size ? : CONFIG_ROM_TABLE_SIZE;
+   u32 rom_table_end;
 
if (IS_ENABLED(CONFIG_BLOBLIST_TABLES) && table->tag) {
-   rom_table_start = (ulong)bloblist_add(table->tag, size,
+   rom_addr = (ulong)bloblist_add(table->tag, size,
  table->align);
-   if (!rom_table_start)
+   if (!rom_addr)
return log_msg_ret("bloblist", -ENOBUFS);
}
-   rom_table_end = table->write(rom_table_start);
+   rom_table_end = table->write(rom_addr);
if (!rom_table_end) {
log_err("Can't create configuration table %d\n", i);
return -EINTR;
}
 
if (IS_ENABLED(CONFIG_SEABIOS)) {
-   table_size = rom_table_end - rom_table_start;
+   table_size = rom_table_end - rom_addr;
high_table = (u32)(ulong)high_table_malloc(table_size);
if (high_table) {
if (!table->write(high_table)) {
@@ -123,13 +123,13 @@ int write_tables(void)
}
 
debug("- wrote '%s' to %x, end %x\n", table->name,
- rom_table_start, rom_table_end);
-   if (rom_table_end - rom_table_start > size) {
+ rom_addr, rom_table_end);
+   if (rom_table_end - rom_addr > size) {
log_err("Out of space for configuration tables: need 
%x, have %x\n",
-   rom_table_end - rom_table_start, size);
+   rom_table_end - rom_addr, size);
return log_msg_ret("bloblist", -ENOSPC);
}
-   rom_table_start = rom_table_end;
+   rom_addr = rom_table_end;
}
 
if (IS_ENABLED(CONFIG_SEABIOS)) {
-- 
2.40.0.634.g4ca3ef3211-goog



[PATCH] efi: Rename the base efi self-test

2023-04-19 Thread Simon Glass
This function uses the same base name as all the others in this file, so
it is not easy to run just that one test. Add a _base suffix so that it
can be run on its own.

Signed-off-by: Simon Glass 
---

 test/py/tests/test_efi_selftest.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/py/tests/test_efi_selftest.py 
b/test/py/tests/test_efi_selftest.py
index e92d63cde6e1..43f242455828 100644
--- a/test/py/tests/test_efi_selftest.py
+++ b/test/py/tests/test_efi_selftest.py
@@ -7,7 +7,7 @@
 import pytest
 
 @pytest.mark.buildconfigspec('cmd_bootefi_selftest')
-def test_efi_selftest(u_boot_console):
+def test_efi_selftest_base(u_boot_console):
 """Run UEFI unit tests
 
 u_boot_console -- U-Boot console
-- 
2.40.0.634.g4ca3ef3211-goog



Re: [PATCH v1 3/6] video: panel: add Renesas R61307 MIPI DSI panel driver

2023-04-19 Thread Simon Glass
On Wed, 19 Apr 2023 at 13:17, Svyatoslav Ryhel  wrote:
>
> R61307 is liquid crystal driver for high-definition
> amorphous silicon (a-Si) panels and is ideal for
> tablets and smartphones.
>
> Supported compatibles are:
> - koe,tx13d100vm0eaa
> - hitachi,tx13d100vm0eaa
>
> Tested-by: Andreas Westman Dorcsak  # LG P880 T30
> Tested-by: Svyatoslav Ryhel  # LG P895 T30
> Signed-off-by: Svyatoslav Ryhel 
> ---
>  drivers/video/Kconfig  |   9 +
>  drivers/video/Makefile |   1 +
>  drivers/video/renesas-r61307.c | 296 +
>  3 files changed, 306 insertions(+)
>  create mode 100644 drivers/video/renesas-r61307.c
>

Reviewed-by: Simon Glass 

Best to use lower-case hex consistently.


Re: [PATCH v4 3/6] tools: Add mkfwumdata tool for FWU metadata image

2023-04-19 Thread Simon Glass
Hi Jassi,

On Tue, 18 Apr 2023 at 20:58, Jassi Brar  wrote:
>
> On Tue, 18 Apr 2023 at 20:46, Simon Glass  wrote:
> >
> > Hi,
> >
> > On Fri, 14 Apr 2023 at 07:53, Michal Simek  wrote:
> > >
> > >
> > >
> > > On 4/10/23 06:25, Jassi Brar wrote:
> > > > On Wed, 29 Mar 2023 at 15:02, Simon Glass  wrote:
> > > >>
> > > >> Hi,
> > > >>
> > > >> On Tue, 28 Mar 2023 at 10:16,  wrote:
> > > >>>
> > > >>> From: Masami Hiramatsu 
> > > >>>
> > > >>> Add 'mkfwumdata' tool to generate FWU metadata image for the meta-data
> > > >>> partition to be used in A/B Update imeplementation.
> > > >>>
> > > >>> Signed-off-by: Masami Hiramatsu 
> > > >>> Signed-off-by: Sughosh Ganu 
> > > >>> Signed-off-by: Jassi Brar 
> > > >>> ---
> > > >>>   tools/Kconfig  |   9 ++
> > > >>>   tools/Makefile |   4 +
> > > >>>   tools/mkfwumdata.c | 334 
> > > >>> +
> > > >>>   3 files changed, 347 insertions(+)
> > > >>>   create mode 100644 tools/mkfwumdata.c
> > > >>
> > > >> Can you please look at putting this in binman instead, since we would
> > > >> rather not have another tool with no tests.
> > > >>
> > > > Must I do that? I have no history with binman and it seems the
> > > > mkfwumdata.c would need to be rewritten in python?
> > >
> > > I think it is about calling this utility from python not about rewriting 
> > > it to
> > > python.
> >
> > Yes that's the question. If this tool is for creating firmware
> > updates, then how are they created? I would expect binman to handle
> > this when U-Boot is built. Then you can build in some tests in binman
> > perhaps?
> >
> The FWU meta-data format is specified in a standards document created
> by ARM and not tied to u-boot.
> U-Boot may not necessarily be the bootloader using the output of
> mkfwumdata. The u-boot/tools/ is more like a welcoming host.
>
> Ideally mkfwumdata should be a reference implementation, also created
> by ARM. But it is trivial enough that nobody thought there could be
> any confusion about the format, I guess.

OK

>
> > How does one know what parameters to pass? Is the documentation for
> > this tool elsewhere?
> >
> In the latest submission I also created a man-page for it.

Good

>
> >  Where are the tests?
> >
> I am open to learning what could be tested and how.

Well normally we would have a binman test which uses the tool to
create an image, then checks that it works. See ftest.py for some
examples.

>
> > It is also unfortunate that this seems to be inventing yet another
> > format (I recall that FIP was invented at one point also), when it
> > could use FIT.
> >
> Hopefully it won't be that bad of a predicament after my explanation above.

Regards,
Simon


Re: [PATCH V8 14/14] common: Replace #ifdef and #if with if's

2023-04-19 Thread Simon Glass
On Wed, 19 Apr 2023 at 18:11, Nikhil M Jain  wrote:
>
> Avoid using preprocessor compilation directives and instead use simple
> logical expressions for better readability since compiler will anyway
> optimize out the respective code block if condition is not satisfied.
>
> Signed-off-by: Nikhil M Jain 
> ---
> V8:
> - Update as per review comments.
> - Call bmp_display only when CONFIG_BMP is defined.
>
> V7(patch introduced):
> - Replace #ifdef and #if with if's.
>
>  common/bmp.c | 14 +-
>  common/splash.c  | 14 +++---
>  include/splash.h | 11 ---
>  3 files changed, 12 insertions(+), 27 deletions(-)
>

Reviewed-by: Simon Glass 


Re: [PATCH 1/1] doc: codingstyle: Python coding style

2023-04-19 Thread Simon Glass
On Wed, 19 Apr 2023 at 18:45, Heinrich Schuchardt
 wrote:
>
> Indicate that we follow PEP8 and PEP257.
>
> Signed-off-by: Heinrich Schuchardt 
> ---
>  doc/develop/codingstyle.rst | 7 +++
>  1 file changed, 7 insertions(+)
>

Reviewed-by: Simon Glass 


Re: [PATCH v1 1/1] misc: extcon: add MAX14526 MUIC support

2023-04-19 Thread Simon Glass
Hi Svyatoslav,

On Wed, 19 Apr 2023 at 12:53, Svyatoslav Ryhel  wrote:
>
> MAX14526 is a powerful extcon chip which allows detection of various
> plugs like usb, mhl, uart, headset etc. This version of driver
> implements support of AP-usb and CP-usb/uart paths.
>
> Tested-by: Andreas Westman Dorcsak  # LG P880 T30
> Tested-by: Svyatoslav Ryhel  # LG P895 T30
> Signed-off-by: Svyatoslav Ryhel 
> ---
>  drivers/misc/Kconfig  |   2 +
>  drivers/misc/Makefile |   1 +
>  drivers/misc/extcon/Kconfig   |   8 ++
>  drivers/misc/extcon/Makefile  |   2 +
>  drivers/misc/extcon/extcon-max14526.c | 153 ++
>  5 files changed, 166 insertions(+)
>  create mode 100644 drivers/misc/extcon/Kconfig
>  create mode 100644 drivers/misc/extcon/Makefile
>  create mode 100644 drivers/misc/extcon/extcon-max14526.c
>
> diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
> index 4e1ae03e9f..1b49f3cf72 100644
> --- a/drivers/misc/Kconfig
> +++ b/drivers/misc/Kconfig
> @@ -659,4 +659,6 @@ config SL28CPLD
>   the base driver which provides common access methods for the
>   sub-drivers.
>
> +source "drivers/misc/extcon/Kconfig"
> +
>  endmenu
> diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
> index 3b792f2a14..6d4fc8ddf9 100644
> --- a/drivers/misc/Makefile
> +++ b/drivers/misc/Makefile
> @@ -87,3 +87,4 @@ obj-$(CONFIG_K3_AVS0) += k3_avs.o
>  obj-$(CONFIG_ESM_K3) += k3_esm.o
>  obj-$(CONFIG_ESM_PMIC) += esm_pmic.o
>  obj-$(CONFIG_SL28CPLD) += sl28cpld.o
> +obj-y += extcon/
> diff --git a/drivers/misc/extcon/Kconfig b/drivers/misc/extcon/Kconfig
> new file mode 100644
> index 00..99c38224f3
> --- /dev/null
> +++ b/drivers/misc/extcon/Kconfig
> @@ -0,0 +1,8 @@
> +config EXTCON_MAX14526
> +   bool "Maxim MAX14526 EXTCON Support"
> +   select DM_I2C
> +   select DM_MISC
> +   help
> + If you say yes here you get support for the MUIC device of
> + Maxim MAX14526. The MAX14526 MUIC is a USB port accessory
> + detector and switch.
> diff --git a/drivers/misc/extcon/Makefile b/drivers/misc/extcon/Makefile
> new file mode 100644
> index 00..f012b688ce
> --- /dev/null
> +++ b/drivers/misc/extcon/Makefile
> @@ -0,0 +1,2 @@
> +# SPDX-License-Identifier: GPL-2.0+
> +obj-$(CONFIG_EXTCON_MAX14526) += extcon-max14526.o
> diff --git a/drivers/misc/extcon/extcon-max14526.c 
> b/drivers/misc/extcon/extcon-max14526.c
> new file mode 100644
> index 00..c8505dae49
> --- /dev/null
> +++ b/drivers/misc/extcon/extcon-max14526.c
> @@ -0,0 +1,153 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * Copyright (c) 2022 Svyatoslav Ryhel 
> + *
> + * U-boot lacks extcon DM.

In that case I think it is best to add a new uclass for it.

Regards,
Simon


Re: [PATCH v1 4/6] video: panel: add Renesas R69328 MIPI DSI panel driver

2023-04-19 Thread Simon Glass
Hi Svyatoslav,

On Wed, 19 Apr 2023 at 13:17, Svyatoslav Ryhel  wrote:
>
> Driver adds support for panels with Renesas R69328 IC
>
> Currently supported compatible is:
> - jdi,dx12d100vm0eaa
>
> Tested-by: Andreas Westman Dorcsak  # LG P880 T30
> Tested-by: Svyatoslav Ryhel  # LG P895 T30
> Signed-off-by: Svyatoslav Ryhel 
> ---
>  drivers/video/Kconfig  |   9 ++
>  drivers/video/Makefile |   1 +
>  drivers/video/renesas-r69328.c | 232 +
>  3 files changed, 242 insertions(+)
>  create mode 100644 drivers/video/renesas-r69328.c

Reviewed-by: Simon Glass 

Please see below

[..]

> +static int renesas_r69328_enable_backlight(struct udevice *dev)
> +{
> +   struct renesas_r69328_priv *priv = dev_get_priv(dev);
> +   int ret;
> +
> +   ret = dm_gpio_set_value(>enable_gpio, 1);
> +   if (ret) {
> +   printf("%s: error changing enable-gpios (%d)\n", __func__, 
> ret);

If you use log_err() then the function name is should automatically if
CONFIG_LOGF_FUNC is enabled

> +   return ret;
> +   }
> +   mdelay(5);
> +
> +   ret = dm_gpio_set_value(>reset_gpio, 0);
> +   if (ret) {
> +   printf("%s: error changing reset-gpios (%d)\n", __func__, 
> ret);
> +   return ret;
> +   }
> +   mdelay(5);
> +
> +   ret = dm_gpio_set_value(>reset_gpio, 1);
> +   if (ret) {
> +   printf("%s: error changing reset-gpios (%d)\n", __func__, 
> ret);
> +   return ret;
> +   }
> +
> +   mdelay(5);

Please add a comment about the delays so people know how they were
chosen. E.g. it might be in the datasheet.

> +
> +   return 0;
> +}
> +
> +static int renesas_r69328_set_backlight(struct udevice *dev, int percent)
> +{
> +   struct renesas_r69328_priv *priv = dev_get_priv(dev);
> +   struct mipi_dsi_panel_plat *plat = dev_get_plat(dev);
> +   struct mipi_dsi_device *dsi = plat->device;
> +   int ret;
> +
> +   mipi_dsi_dcs_write_buffer(dsi, address_mode,
> + sizeof(address_mode));
> +
> +   ret = mipi_dsi_dcs_set_pixel_format(dsi, MIPI_DCS_PIXEL_FMT_24BIT << 
> 4);
> +   if (ret < 0) {
> +   printf("%s: failed to set pixel format: %d\n", __func__, ret);
> +   return ret;
> +   }
> +
> +   ret = mipi_dsi_dcs_exit_sleep_mode(dsi);
> +   if (ret < 0) {
> +   printf("%s: failed to exit sleep mode: %d\n", __func__, ret);
> +   return ret;
> +   }
> +
> +   mdelay(100);

Wow that is a long time. Please add a comment.

> +
> +   /* MACP Off */
> +   dsi_generic_write_seq(dsi, R69328_MACP, 0x04);
> +
> +   dsi_generic_write_seq(dsi, R69328_POWER_SET, 0x14,
> + 0x1D, 0x21, 0x67, 0x11, 0x9A);
> +
> +   dsi_generic_write_seq(dsi, R69328_GAMMA_SET_A, 0x00,
> + 0x1A, 0x20, 0x28, 0x25, 0x24,
> + 0x26, 0x15, 0x13, 0x11, 0x18,
> + 0x1E, 0x1C, 0x00, 0x00, 0x1A,
> + 0x20, 0x28, 0x25, 0x24, 0x26,
> + 0x15, 0x13, 0x11, 0x18, 0x1E,
> + 0x1C, 0x00);

lower-case hex

> +   dsi_generic_write_seq(dsi, R69328_GAMMA_SET_B, 0x00,
> + 0x1A, 0x20, 0x28, 0x25, 0x24,
> + 0x26, 0x15, 0x13, 0x11, 0x18,
> + 0x1E, 0x1C, 0x00, 0x00, 0x1A,
> + 0x20, 0x28, 0x25, 0x24, 0x26,
> + 0x15, 0x13, 0x11, 0x18, 0x1E,
> + 0x1C, 0x00);
> +   dsi_generic_write_seq(dsi, R69328_GAMMA_SET_C, 0x00,
> + 0x1A, 0x20, 0x28, 0x25, 0x24,
> + 0x26, 0x15, 0x13, 0x11, 0x18,
> + 0x1E, 0x1C, 0x00, 0x00, 0x1A,
> + 0x20, 0x28, 0x25, 0x24, 0x26,
> + 0x15, 0x13, 0x11, 0x18, 0x1E,
> + 0x1C, 0x00);
> +
> +   /* MACP On */
> +   dsi_generic_write_seq(dsi, R69328_MACP, 0x03);
> +
> +   ret = mipi_dsi_dcs_set_display_on(dsi);
> +   if (ret < 0) {
> +   printf("%s: failed to set display on: %d\n", __func__, ret);
> +   return ret;
> +   }
> +
> +   mdelay(50);
> +
[..]

Regards,
Simon


Re: [PATCH v1 2/6] video: bridge: add Solomon SSD2825 DSI/LVDS driver

2023-04-19 Thread Simon Glass
Hi Svyatoslav,

On Wed, 19 Apr 2023 at 13:17, Svyatoslav Ryhel  wrote:
>
> SSD2825 is an innovative and cost-effective MIPI Bridge Chip solution
> targeting high resolution smartphones. It can convert 24bit RGB
> interface into 4-lane MIPI-DSI interface to drive extremely high
> resolution display modules of up to 800 x 1366, while supporting AMOLED,
> a-si LCD or LTPS advanced panel technologies for smartphone applications.
>
> Bridge is wrapped in panel uClass model for wider compatibility.
>
> Tested-by: Andreas Westman Dorcsak  # LG P880 T30
> Tested-by: Svyatoslav Ryhel  # LG P895 T30
> Signed-off-by: Svyatoslav Ryhel 
> ---
>  drivers/video/bridge/Kconfig   |   7 +
>  drivers/video/bridge/Makefile  |   1 +
>  drivers/video/bridge/ssd2825.c | 523 +
>  3 files changed, 531 insertions(+)
>  create mode 100644 drivers/video/bridge/ssd2825.c
>

[..]

> +static int ssd2825_spi_write(struct udevice *dev, int reg,
> +const void *buf, int flags)
> +{
> +   struct spi_slave *slave = dev_get_parent_priv(dev);
> +   u8 command[2];
> +
> +   if (flags & SSD2825_CMD_SEND) {
> +   command[0] = SSD2825_CMD_MASK;
> +   command[1] = reg;
> +   spi_xfer(slave, 9, ,
> +NULL, SPI_XFER_ONCE);

Please can you use dm_spi_xfer() instead, thoughout?

Also note that when you add a printf() for errors, the string is
stored and it increases code size. It might be better to use
log_debug(), unless the errors are likely.

[..]

Regards,
Simon


Re: [PATCH 1/1] sandbox: enable CONFIG_EFI_CAPSULE_AUTHENTICATE

2023-04-19 Thread Simon Glass
Hi Ilias,

On Wed, 19 Apr 2023 at 18:05, Ilias Apalodimas
 wrote:
>
> On Tue, Apr 18, 2023 at 10:47:24AM -0600, Simon Glass wrote:
> > Hi Heinrich,
> >
> > On Fri, 14 Apr 2023 at 02:39, Heinrich Schuchardt
> >  wrote:
> > >
> > > Without CONFIG_EFI_CAPSULE_AUTHENTICATE=y the following tests are skipped:
> > >
> > > * test/py/tests/test_efi_capsule/test_capsule_firmware_signed_fit.py
> > > * test/py/tests/test_efi_capsule/test_capsule_firmware_signed_raw.py
> > >
> > > Signed-off-by: Heinrich Schuchardt 
> > > ---
> > >  configs/sandbox_defconfig  | 1 +
> > >  configs/sandbox_flattree_defconfig | 1 +
> > >  2 files changed, 2 insertions(+)
> > >
> >
> > Reviewed-by: Simon Glass 
> >
> > This still has the problem that it reboots in the middle of the test.
> > Can we get that fixed? If someone at Linaro isn't interested I could
> > take a look at it.
>
> I think we discussed this in the past.  We *need* to reboot as that's what
> the EFI describes.  Why is it a problem?

Would you like me to provide a patch that shows it not rebooting? It
is a simple matter of kicking off the update process, which we can do
directly, without a reboot.

Regards,
Simon


Re: [PATCH 1/1] test: fix pylint warning for capsule tests

2023-04-19 Thread Simon Glass
Hi Heinrich,

On Wed, 19 Apr 2023 at 18:30, Heinrich Schuchardt
 wrote:
>
>
>
> On 4/19/23 03:45, Simon Glass wrote:
> > Hi Heinrich,
> >
> > On Fri, 14 Apr 2023 at 02:34, Heinrich Schuchardt
> >  wrote:
> >>
> >> Fix pylint warnings like:
> >>
> >> * Class inherits from object
> >> * Missing module description
> >> * Missing class description
> >> * First line of comment blank
> >> * Superfluous imports
> >>
> >> Signed-off-by: Heinrich Schuchardt 
> >> ---
> >>   test/py/tests/test_efi_capsule/conftest.py| 27 
> >>   .../test_capsule_firmware_fit.py  | 35 
> >>   .../test_capsule_firmware_signed_fit.py   | 41 ++-
> >>   .../test_capsule_firmware_signed_raw.py   | 38 -
> >>   4 files changed, 65 insertions(+), 76 deletions(-)
> >>
> >> diff --git a/test/py/tests/test_efi_capsule/conftest.py 
> >> b/test/py/tests/test_efi_capsule/conftest.py
> >> index 4879f2b5c2..0e5137de60 100644
> >> --- a/test/py/tests/test_efi_capsule/conftest.py
> >> +++ b/test/py/tests/test_efi_capsule/conftest.py
> >> @@ -2,30 +2,21 @@
> >>   # Copyright (c) 2020, Linaro Limited
> >>   # Author: AKASHI Takahiro 
> >>
> >> -import os
> >> -import os.path
> >> -import re
> >> -from subprocess import call, check_call, check_output, CalledProcessError
> >> -import pytest
> >> -from capsule_defs import *
> >> +"""Fixture for UEFI capsule test
> >> +"""
> >>
> >> -#
> >> -# Fixture for UEFI capsule test
> >> -#
> >> +from subprocess import call, check_call, CalledProcessError
> >> +import pytest
> >> +from capsule_defs import CAPSULE_DATA_DIR, CAPSULE_INSTALL_DIR, 
> >> EFITOOLS_PATH
> >>
> >>   @pytest.fixture(scope='session')
> >>   def efi_capsule_data(request, u_boot_config):
> >> -"""Set up a file system to be used in UEFI capsule and
> >> -   authentication test.
> >> -
> >> -Args:
> >> -request: Pytest request object.
> >> -u_boot_config: U-boot configuration.
> >> +"""Set up a file system to be used in UEFI capsule and authentication 
> >> test
> >> +and return a ath to disk image to be used for testing
> >
> > Thanks for cleaning this up. I suppose with all the rounds of review
> > we got tired of worrying about the style. Also this probably predates
> > the pylint check.
> >
> > Can we please follow the style in the rest of the code? This should
> > have a heading line, with further notes after a blank line.
> >
> >>
> >> -Return:
> >> -A path to disk image to be used for testing
> >> +request -- Pytest request object.
> >> +u_boot_config -- U-boot configuration.
> >
> > Again the style is:
> >
> > Return:
> > request (pytest.Request): Request to be processed
> > u_boot_config (type): U-Boot configuration
>
> This seems to be some Google internal code style. We should stick to
> PEP257 (https://peps.python.org/pep-0257/).

That doesn't really tell you much though. It is just the idea of a
docstring from 20 years ago. We need a convention for what is in the
strings, not just the strings.

The one we currently use is at least based on [1] or something like
it. I would not describe it as internal to Google. What makes you
think that? It is widely used.

For me at least, pylint asks for type information:

tools/binman/control.py:146:0: W9016: "modules, test_missing" missing
in parameter type documentation (missing-type-doc)

You should be able to try that and see what you get.

Regards,
Simon

[1] https://sphinxcontrib-napoleon.readthedocs.io/en/latest/index.html


Re: [PATCH v1 1/6] video: add lm3533 backlight driver

2023-04-19 Thread Simon Glass
On Wed, 19 Apr 2023 at 13:17, Svyatoslav Ryhel  wrote:
>
> This is basic lm3533 driver only with bank A and
> backlight cell support.
>
> Tested-by: Andreas Westman Dorcsak  # LG P880 T30
> Tested-by: Svyatoslav Ryhel  # LG P895 T30
> Signed-off-by: Svyatoslav Ryhel 
> ---
>  drivers/video/Kconfig|   8 ++
>  drivers/video/Makefile   |   1 +
>  drivers/video/lm3533_backlight.c | 135 +++
>  3 files changed, 144 insertions(+)
>  create mode 100644 drivers/video/lm3533_backlight.c
>

Reviewed-by: Simon Glass 

> diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
> index 334d64c948..1695d17c8d 100644
> --- a/drivers/video/Kconfig
> +++ b/drivers/video/Kconfig
> @@ -606,6 +606,14 @@ config ATMEL_HLCD
> help
>HLCDC supports video output to an attached LCD panel.
>
> +config BACKLIGHT_LM3533
> +   bool "Backlight Driver for LM3533"
> +   depends on BACKLIGHT
> +   select DM_I2C
> +   help
> + Say Y to enable the backlight driver for National Semiconductor / TI
> + LM3533 Lighting Power chips.

Would be good to mention that it supports a programmable brightness
level. We are supposed to have at least 3 lines of help, so think of
useful info to add.

Regards,
Simon


Re: [PATCH v2 0/3] rpi: Convert to standard boot

2023-04-19 Thread Simon Glass
Hi Peter,

On Wed, 19 Apr 2023 at 19:42, Peter Robinson  wrote:
>
> Hi Simon,
>
> On Wed, Apr 19, 2023 at 2:46 AM Simon Glass  wrote:
> >
> > Hi Peter,
> >
> > On Sun, 2 Apr 2023 at 14:29, Simon Glass  wrote:
> > >
> > > This series moves Raspberry Pi boards over to use standard boot.
> > >
> > > It also moves rpi over to use a text-based environment. Unfortunately it
> > > is not possible to empty the header file due to several CFG options.
> > >
> > > Fix the repeated "and and" while we are here.
> > >
> > > Note that this reduces rodata size by about 4.5KB. We could get another
> > >
> > > for a total image-size saving of about 15KB. This is mostly because
> > > HUSH_PARSER is not enabled anymore and the environment shrinks down by
> > > about 3.5K. Hush is not actually needed anymore, since standard boot does
> > > not use it. Also CMD_SYSBOOT is dropped since standard boot calls the
> > > pxe_utils code directly in that case.
> > >
> > > Changes in v2:
> > > - Rebase to -next
> > > - Add new patch to disable DISTRO_DEFAULTS
> > >
> > > Simon Glass (3):
> > >   arm: rpi: Switch to standard boot
> > >   rpi: Disable DISTRO_DEFAULTS
> > >   arm: rpi: Switch to a text environment
> > >
> > >  board/raspberrypi/rpi/rpi.env  |  77 +++
> > >  configs/rpi_0_w_defconfig  |   2 +-
> > >  configs/rpi_2_defconfig|   2 +-
> > >  configs/rpi_3_32b_defconfig|   2 +-
> > >  configs/rpi_3_b_plus_defconfig |   2 +-
> > >  configs/rpi_3_defconfig|   2 +-
> > >  configs/rpi_4_32b_defconfig|   2 +-
> > >  configs/rpi_4_defconfig|   2 +-
> > >  configs/rpi_arm64_defconfig|   2 +-
> > >  configs/rpi_defconfig  |   2 +-
> > >  include/configs/rpi.h  | 134 -
> > >  11 files changed, 86 insertions(+), 143 deletions(-)
> > >  create mode 100644 board/raspberrypi/rpi/rpi.env
> > >
> > > --
> > > 2.40.0.348.gf938b09366-goog
> > >
> >
> > Any thoughts on this series, please?
>
> It's in my backlog to review, I've been focused on other things so my
> time is limited ATM but I'm also a little hesitant given the issues
> with the rockchip conversion and still outstanding issues there.

Yes, there is an outstanding series on that side also. I hope you can
find the time soon, as the merge window closes in a week or so
(getting it in before then gives us the most test time before the
release).

Regards,
Simon


Re: [PATCH v1 5/6] video: tegra: add DC based PWM backlight driver

2023-04-19 Thread Simon Glass
On Wed, 19 Apr 2023 at 13:18, Svyatoslav Ryhel  wrote:
>
> DC based PWM backlight is found on some T20 and T30 devices
> (HTC One X). This backlight is controlled by Tegra DC and
> is adjustable by the DC PM0 or PM1 signal.
>
> Tested-by: Andreas Westman Dorcsak  # HTC One X T30
> Tested-by: Svyatoslav Ryhel  # HTC One X T30
> Signed-off-by: Svyatoslav Ryhel 
> ---
>  drivers/video/tegra20/Kconfig   |   7 +
>  drivers/video/tegra20/Makefile  |   1 +
>  drivers/video/tegra20/tegra-pwm-backlight.c | 155 
>  3 files changed, 163 insertions(+)
>  create mode 100644 drivers/video/tegra20/tegra-pwm-backlight.c

Reviewed-by: Simon Glass 


Re: Re: The u-boot supports i2c-over-hid?

2023-04-19 Thread Simon Glass
Hi,

On Wed, 19 Apr 2023 at 20:33, skyo...@126.com  wrote:
>
> hi,
> For i2c interface keyboard, how should we implement u-boot driver?
>
> Do you have any suggestions

Please try to avoid top posting. See below.

>
>
> 
> skyo...@126.com
>
>
> From: Simon Glass
> Date: 2023-04-19 09:45
> To: skyo...@126.com
> CC: u-boot
> Subject: Re: The u-boot supports i2c-over-hid?
> Hi,
>
> +Heinrich Schuchardt +Heiko Schocher
>
> On Thu, 13 Apr 2023 at 08:58, skyo...@126.com  wrote:
> >
> > Hello,
> > I would like to ask whether i2c-over-hid is not supported under u-boot 
> > at present. At present, we have this development need. I would like to ask 
> > whether it is feasible to transplant i2c-over-hid from kernel. If not, is 
> > there any other way?
> >
>
> I don't see any support for it. Yes, bringing things in from Linux is
> a common approach. Some changes are needed for driver model and some
> differing APIs.

Do you mean HID over I2C? I cannot see anything for the other way
around. But for i2c over hid, see cros_ec_i2c.c which implements I2C
over a Chromium OS EC interface.

For HID over I2C, you could start with a simple driver which uses I2C
to communicate with the device. It would need a new uclass, so it can
be a proper driver. For plumbing it into U-Boot, keyboard-uclass.c
shows how this is done today.

Regards,
Simon


Re: [PATCH] gpio-uclass: fix off-by-one in gpio_request_list_by_name_nodev()

2023-04-19 Thread Simon Glass
On Wed, 19 Apr 2023 at 22:11, Rasmus Villemoes
 wrote:
>
> By the time we jump to the err label, count represents the number of
> gpios we've succesfully requested. So by subtracting one, we fail to
> free the most recently requested.
>
> Signed-off-by: Rasmus Villemoes 
> ---
>  drivers/gpio/gpio-uclass.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Simon Glass 

Could the tests catch this bug?


>
> diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
> index c8be5a4d66..712119c341 100644
> --- a/drivers/gpio/gpio-uclass.c
> +++ b/drivers/gpio/gpio-uclass.c
> @@ -1219,7 +1219,7 @@ int gpio_request_list_by_name_nodev(ofnode node, const 
> char *list_name,
> return count;
>
>  err:
> -   gpio_free_list_nodev(desc, count - 1);
> +   gpio_free_list_nodev(desc, count);
>
> return ret;
>  }
> --
> 2.37.2
>


Re: Support for NXP S32K3 Family

2023-04-19 Thread Simon Glass
Hi Ashok,

On Wed, 19 Apr 2023 at 21:42, Ashok Kumar
 wrote:
>
> Hi Simon,
>
> Thanks for the reply.
>
> NXP people said we don't support this feature for S32K family.
>
> I am just wondering whether I can get any help from the u-boot sources?

I would expect you would need to add support for the board. You can
see Cortex-M support for NXP i.MXRT and STM32, so far. I imagine there
will be some differences, such as peripherals, memory layout, etc. If
there is another bootloader or some libraries available that should
provide some hints.

Regards,
Simon


>
>
> Regards
>
> Ashok
>
> On 19/04/2023 02:45, Simon Glass wrote:
> > Hi Ashok,
> >
> > On Fri, 14 Apr 2023 at 08:55, Ashok Kumar
> >  wrote:
> >> Hi Folks,
> >>
> >>
> >> I am trying to build a u-boot boot-loader for my S32K344 board.
> >>
> >> Can you guys please help me, which defconf/config file is suitable for
> >> my S32K344 board for building a u-boot binaries?
> > If you look in MAINTAINERS you should be able to find contacts for NXP.
> >
> > Regards,
> > Simon


Re: [PATCH v5 3/3] regulator: handle different error codes in regulator_set_enable_if_allowed

2023-04-19 Thread Simon Glass
On Thu, 20 Apr 2023 at 01:45, Eugen Hristev  wrote:
>
> The regulator core can return different codes which are not considered
> a real error for this function.
> Return success in such cases.
>
> Signed-off-by: Eugen Hristev 
> ---
> Changes in v5:
>  - this is a new patch
>
>  drivers/power/regulator/regulator-uclass.c | 6 ++
>  1 file changed, 6 insertions(+)

Reviewed-by: Simon Glass 


[PATCH] binman: Use expanduser instead of HOME

2023-04-19 Thread Simon Glass
There may not be a HOME environment variable, so use the os.expanduser()
function instead.

Signed-off-by: Simon Glass 
---

 tools/binman/bintool.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/binman/bintool.py b/tools/binman/bintool.py
index 8fda13ff012..f460243e796 100644
--- a/tools/binman/bintool.py
+++ b/tools/binman/bintool.py
@@ -43,7 +43,7 @@ FETCH_NAMES = {
 # Status of tool fetching
 FETCHED, FAIL, PRESENT, STATUS_COUNT = range(4)
 
-DOWNLOAD_DESTDIR = os.path.join(os.getenv('HOME'), 'bin')
+DOWNLOAD_DESTDIR = os.path.expanduser('~/bin')
 
 class Bintool:
 """Tool which operates on binaries to help produce entry contents
-- 
2.40.0.634.g4ca3ef3211-goog



Re: Reading file would overwrite reserved memory. Failed to load 'hello_world.bin - imx7d-pico - Uboot 2022.04

2023-04-19 Thread Simon Glass
+U-Boot Mailing List

Hi

On Wed, 19 Apr 2023 at 11:32, Neuber Sousa  wrote:
>
> To illustrate what is happening here and what I already said in a previous 
> email, currently, even Uboot 2021.04 pulled recently (and not last year) does 
> not work. To illustrate, I posted two files below:
>
> lmb.c when RPMsg work
> https://gist.github.com/neuberfran/c4df18a27974cd6fdc8a967f192d54d6
>
> lmb.c when RPMsg not Work
> https://gist.github.com/neuberfran/aebbac2db52c5f78c680f10496cb8784

I'm sorry, but I think you will need to debug this, unless someone
else has a bright idea.

Thererror is in fs_read_lmb_check() so something must be wrong in what
you think should happen in lmb_alloc_addr(), I suspect.

Regards,
Simon


>
> Em ter., 18 de abr. de 2023 às 22:50, Simon Glass  
> escreveu:
>>
>> Hi Neuber,
>>
>> On Mon, 10 Apr 2023 at 14:59, Neuber Sousa  wrote:
>> >
>> > https://stackoverflow.com/questions/71073386/reading-file-would-overwrite-reserved-memory-failed-to-load-hello-world-bin
>> >
>> > Hi,
>> >
>> > I had this issue last year and I solved it via device tree. However, I used
>> > Yocto hardknott and uboot 2021.04 and Ubuntu 20.04. Now I use Yocto
>> > kirkstone and uboot 2022.04 and Ubuntu 22.04
>> >
>> >
>> > I've been trying to resolve this issue for seven days now. I've already
>> > made several changes to the uboot and yocto/device tree configurations
>> > without success.
>> >
>> > Every help is welcome
>> >
>> > Note I tried:
>> >
>> > https://dantechrb.com/blog/how-to-build-and-debug-freertos-applications-for-cortexm4-on-mx6sx
>> >
>> > https://whycan.com/t_5474.html
>>
>> If you add '#define LOG_DEBUG' to the top of lmb.c you should see some
>> debugging about the reserved memory.
>>
>> Regards,
>> Simon


[PATCH v1 6/6] video: panel: add generic endeavoru panel

2023-04-19 Thread Svyatoslav Ryhel
Family of panels used by HTC in One X. Though were used variants
at least from 3 vendors, this driver provides generic support for
all of them.

Tested-by: Ion Agorria  # HTC One X T30 Sony
Tested-by: Svyatoslav Ryhel  # HTC One X T30 Sharp
Signed-off-by: Svyatoslav Ryhel 
---
 drivers/video/Kconfig   |  11 ++
 drivers/video/Makefile  |   1 +
 drivers/video/endeavoru-panel.c | 252 
 3 files changed, 264 insertions(+)
 create mode 100644 drivers/video/endeavoru-panel.c

diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 2218eab3dd..44c36ba7e6 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -466,6 +466,17 @@ config VIDEO_BCM2835
  that same resolution (or as near as possible) and 32bpp depth, so
  that U-Boot can access it with full colour depth.
 
+config VIDEO_LCD_ENDEAVORU
+   tristate "Endeavoru 720x1280 DSI video mode panel"
+   depends on PANEL && BACKLIGHT
+   select VIDEO_MIPI_DSI
+   help
+ Say Y here if you want to enable support for the IPS-LCD panel
+ module for HTC One X. Driver supports a family of panels,
+ made at least by 3 vendors (Sharp, Sony and AUO), but set up
+ using the same DSI command sequence. The panel has a 720x1280
+ resolution and uses 24 bit RGB per pixel.
+
 config VIDEO_LCD_ORISETECH_OTM8009A
bool "OTM8009A DSI LCD panel support"
select VIDEO_MIPI_DSI
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index cddfc8fd33..4aff7771a8 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -53,6 +53,7 @@ obj-$(CONFIG_VIDEO_EFI) += efi.o
 obj-$(CONFIG_VIDEO_IPUV3) += imx/
 obj-$(CONFIG_VIDEO_IVYBRIDGE_IGD) += ivybridge_igd.o
 obj-$(CONFIG_VIDEO_LCD_ANX9804) += anx9804.o
+obj-$(CONFIG_VIDEO_LCD_ENDEAVORU) += endeavoru-panel.o
 obj-$(CONFIG_VIDEO_LCD_HITACHI_TX18D42VM) += hitachi_tx18d42vm_lcd.o
 obj-$(CONFIG_VIDEO_LCD_ORISETECH_OTM8009A) += orisetech_otm8009a.o
 obj-$(CONFIG_VIDEO_LCD_RAYDIUM_RM68200) += raydium-rm68200.o
diff --git a/drivers/video/endeavoru-panel.c b/drivers/video/endeavoru-panel.c
new file mode 100644
index 00..1c665222b8
--- /dev/null
+++ b/drivers/video/endeavoru-panel.c
@@ -0,0 +1,252 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2022 Svyatoslav Ryhel 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct endeavoru_panel_priv {
+   struct udevice *vdd;
+   struct udevice *vddio;
+
+   struct udevice *backlight;
+
+   struct gpio_desc reset_gpio;
+};
+
+static struct display_timing default_timing = {
+   .pixelclock.typ = 6320,
+   .hactive.typ= 720,
+   .hfront_porch.typ   = 55,
+   .hback_porch.typ= 29,
+   .hsync_len.typ  = 16,
+   .vactive.typ= 1280,
+   .vfront_porch.typ   = 2,
+   .vback_porch.typ= 1,
+   .vsync_len.typ  = 1,
+};
+
+static void dcs_write_one(struct mipi_dsi_device *dsi, u8 cmd, u8 data)
+{
+   mipi_dsi_dcs_write(dsi, cmd, , 1);
+}
+
+/*
+ * This panel is not able to auto-increment all cmd addresses so for some of
+ * them, we need to send them one by one...
+ */
+#define dcs_write_seq(dsi, cmd, seq...)\
+({ \
+   static const u8 d[] = { seq };  \
+   unsigned int i; \
+   \
+   for (i = 0; i < ARRAY_SIZE(d) ; i++)\
+   dcs_write_one(dsi, cmd + i, d[i]);  \
+})
+
+static int endeavoru_panel_enable_backlight(struct udevice *dev)
+{
+   struct endeavoru_panel_priv *priv = dev_get_priv(dev);
+   int ret;
+
+   ret = dm_gpio_set_value(>reset_gpio, 1);
+   if (ret) {
+   printf("%s: error changing reset-gpios (%d)\n", __func__, ret);
+   return ret;
+   }
+   mdelay(5);
+
+   ret = regulator_set_enable_if_allowed(priv->vddio, 1);
+   if (ret) {
+   printf("%s: error enabling iovcc-supply (%d)\n", __func__, ret);
+   return ret;
+   }
+   mdelay(1);
+
+   ret = regulator_set_enable_if_allowed(priv->vdd, 1);
+   if (ret) {
+   printf("%s: error enabling vcc-supply (%d)\n", __func__, ret);
+   return ret;
+   }
+   mdelay(20);
+
+   ret = dm_gpio_set_value(>reset_gpio, 0);
+   if (ret) {
+   printf("%s: error changing reset-gpios (%d)\n", __func__, ret);
+   return ret;
+   }
+   mdelay(2);
+
+   /* Reset panel */
+   ret = dm_gpio_set_value(>reset_gpio, 1);
+   if (ret) {
+   printf("%s: error changing reset-gpios (%d)\n", __func__, ret);
+   return ret;
+   }
+   mdelay(1);
+
+   ret = 

[PATCH v1 5/6] video: tegra: add DC based PWM backlight driver

2023-04-19 Thread Svyatoslav Ryhel
DC based PWM backlight is found on some T20 and T30 devices
(HTC One X). This backlight is controlled by Tegra DC and
is adjustable by the DC PM0 or PM1 signal.

Tested-by: Andreas Westman Dorcsak  # HTC One X T30
Tested-by: Svyatoslav Ryhel  # HTC One X T30
Signed-off-by: Svyatoslav Ryhel 
---
 drivers/video/tegra20/Kconfig   |   7 +
 drivers/video/tegra20/Makefile  |   1 +
 drivers/video/tegra20/tegra-pwm-backlight.c | 155 
 3 files changed, 163 insertions(+)
 create mode 100644 drivers/video/tegra20/tegra-pwm-backlight.c

diff --git a/drivers/video/tegra20/Kconfig b/drivers/video/tegra20/Kconfig
index 5b1dfbfbbe..f5c4843e11 100644
--- a/drivers/video/tegra20/Kconfig
+++ b/drivers/video/tegra20/Kconfig
@@ -15,3 +15,10 @@ config VIDEO_DSI_TEGRA30
help
   T30 has native support for DSI panels. This option enables support
   for such panels which can be used on endeavoru and tf600t.
+
+config TEGRA_BACKLIGHT_PWM
+   bool "Enable Tegra DC PWM backlight support"
+   depends on BACKLIGHT
+   select VIDEO_TEGRA20
+   help
+  Tegra DC dependent backlight.
diff --git a/drivers/video/tegra20/Makefile b/drivers/video/tegra20/Makefile
index e82ee96962..f0b534c579 100644
--- a/drivers/video/tegra20/Makefile
+++ b/drivers/video/tegra20/Makefile
@@ -2,3 +2,4 @@
 
 obj-$(CONFIG_VIDEO_TEGRA20) += tegra-dc.o
 obj-$(CONFIG_VIDEO_DSI_TEGRA30) += tegra-dsi.o mipi-phy.o
+obj-$(CONFIG_TEGRA_BACKLIGHT_PWM) += tegra-pwm-backlight.o
diff --git a/drivers/video/tegra20/tegra-pwm-backlight.c 
b/drivers/video/tegra20/tegra-pwm-backlight.c
new file mode 100644
index 00..409304b0e0
--- /dev/null
+++ b/drivers/video/tegra20/tegra-pwm-backlight.c
@@ -0,0 +1,155 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2022 Svyatoslav Ryhel 
+ */
+
+#define LOG_CATEGORY UCLASS_PANEL_BACKLIGHT
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+#define TEGRA_DISPLAY_A_BASE   0x5420
+#define TEGRA_DISPLAY_B_BASE   0x5424
+
+#define TEGRA_PWM_BL_MIN_BRIGHTNESS0x10
+#define TEGRA_PWM_BL_MAX_BRIGHTNESS0xFF
+
+#define TEGRA_PWM_BL_PERIOD0xFF
+#define TEGRA_PWM_BL_CLK_DIV   0x14
+#define TEGRA_PWM_BL_CLK_SELECT0x00
+
+#define PM_PERIOD_SHIFT 18
+#define PM_CLK_DIVIDER_SHIFT   4
+
+#define TEGRA_PWM_PM0  0
+#define TEGRA_PWM_PM1  1
+
+struct tegra_pwm_backlight_priv {
+   struct dc_ctlr *dc; /* Display controller regmap */
+
+   u32 pwm_source;
+   u32 period;
+   u32 clk_div;
+   u32 clk_select;
+   u32 dft_brightness;
+};
+
+static int tegra_pwm_backlight_set_brightness(struct udevice *dev, int percent)
+{
+   struct tegra_pwm_backlight_priv *priv = dev_get_priv(dev);
+   struct dc_cmd_reg *cmd = >dc->cmd;
+   struct dc_com_reg *com = >dc->com;
+   unsigned int ctrl;
+   unsigned long out_sel;
+   unsigned long cmd_state;
+
+   if (percent == BACKLIGHT_DEFAULT)
+   percent = priv->dft_brightness;
+
+   if (percent < TEGRA_PWM_BL_MIN_BRIGHTNESS)
+   percent = TEGRA_PWM_BL_MIN_BRIGHTNESS;
+
+   if (percent > TEGRA_PWM_BL_MAX_BRIGHTNESS)
+   percent = TEGRA_PWM_BL_MAX_BRIGHTNESS;
+
+   ctrl = ((priv->period << PM_PERIOD_SHIFT) |
+   (priv->clk_div << PM_CLK_DIVIDER_SHIFT) |
+priv->clk_select);
+
+   /* The new value should be effected immediately */
+   cmd_state = readl(>state_access);
+   writel((cmd_state | (1 << 2)), >state_access);
+
+   switch (priv->pwm_source) {
+   case TEGRA_PWM_PM0:
+   /* Select the LM0 on PM0 */
+   out_sel = readl(>pin_output_sel[5]);
+   out_sel &= ~(7 << 0);
+   out_sel |= (3 << 0);
+   writel(out_sel, >pin_output_sel[5]);
+   writel(ctrl, >pm0_ctrl);
+   writel(percent, >pm0_duty_cycle);
+   break;
+   case TEGRA_PWM_PM1:
+   /* Select the LM1 on PM1 */
+   out_sel = readl(>pin_output_sel[5]);
+   out_sel &= ~(7 << 4);
+   out_sel |= (3 << 4);
+   writel(out_sel, >pin_output_sel[5]);
+   writel(ctrl, >pm1_ctrl);
+   writel(percent, >pm1_duty_cycle);
+   break;
+   default:
+   break;
+   }
+
+   writel(cmd_state, >state_access);
+   return 0;
+}
+
+static int tegra_pwm_backlight_enable(struct udevice *dev)
+{
+   struct tegra_pwm_backlight_priv *priv = dev_get_priv(dev);
+   return tegra_pwm_backlight_set_brightness(dev, priv->dft_brightness);
+}
+
+static int tegra_pwm_backlight_probe(struct udevice *dev)
+{
+   struct tegra_pwm_backlight_priv *priv = dev_get_priv(dev);
+
+   if (dev_read_bool(dev, "nvidia,display-b-base"))
+   

[PATCH v1 3/6] video: panel: add Renesas R61307 MIPI DSI panel driver

2023-04-19 Thread Svyatoslav Ryhel
R61307 is liquid crystal driver for high-definition
amorphous silicon (a-Si) panels and is ideal for
tablets and smartphones.

Supported compatibles are:
- koe,tx13d100vm0eaa
- hitachi,tx13d100vm0eaa

Tested-by: Andreas Westman Dorcsak  # LG P880 T30
Tested-by: Svyatoslav Ryhel  # LG P895 T30
Signed-off-by: Svyatoslav Ryhel 
---
 drivers/video/Kconfig  |   9 +
 drivers/video/Makefile |   1 +
 drivers/video/renesas-r61307.c | 296 +
 3 files changed, 306 insertions(+)
 create mode 100644 drivers/video/renesas-r61307.c

diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 1695d17c8d..bfd8c4f126 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -480,6 +480,15 @@ config VIDEO_LCD_RAYDIUM_RM68200
Say Y here if you want to enable support for Raydium RM68200
720x1280 DSI video mode panel.
 
+config VIDEO_LCD_RENESAS_R61307
+   tristate "Renesas R61307 DSI video mode panel"
+   depends on PANEL && BACKLIGHT
+   select VIDEO_MIPI_DSI
+   help
+ Say Y here if you want to enable support for KOE tx13d100vm0eaa
+ IPS-LCD module with Renesas R69328 IC. The panel has a 1024x768
+ resolution and uses 24 bit RGB per pixel.
+
 config VIDEO_LCD_SSD2828
bool "SSD2828 bridge chip"
---help---
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index 05fb063105..9ab5de8858 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -56,6 +56,7 @@ obj-$(CONFIG_VIDEO_LCD_ANX9804) += anx9804.o
 obj-$(CONFIG_VIDEO_LCD_HITACHI_TX18D42VM) += hitachi_tx18d42vm_lcd.o
 obj-$(CONFIG_VIDEO_LCD_ORISETECH_OTM8009A) += orisetech_otm8009a.o
 obj-$(CONFIG_VIDEO_LCD_RAYDIUM_RM68200) += raydium-rm68200.o
+obj-$(CONFIG_VIDEO_LCD_RENESAS_R61307) += renesas-r61307.o
 obj-$(CONFIG_VIDEO_LCD_SSD2828) += ssd2828.o
 obj-$(CONFIG_VIDEO_LCD_TDO_TL070WSH30) += tdo-tl070wsh30.o
 obj-$(CONFIG_VIDEO_MCDE_SIMPLE) += mcde_simple.o
diff --git a/drivers/video/renesas-r61307.c b/drivers/video/renesas-r61307.c
new file mode 100644
index 00..6af95f1107
--- /dev/null
+++ b/drivers/video/renesas-r61307.c
@@ -0,0 +1,296 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Renesas R61307 panel driver
+ *
+ * Copyright (c) 2022 Svyatoslav Ryhel 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define R61307_MACP0xB0 /* Manufacturer CMD Protect */
+
+#define R61307_INVERSION   0xC1
+#define R61307_GAMMA_SET_A 0xC8 /* Gamma Setting A */
+#define R61307_GAMMA_SET_B 0xC9 /* Gamma Setting B */
+#define R61307_GAMMA_SET_C 0xCA /* Gamma Setting C */
+#define R61307_CONTRAST_SET0xCC
+
+struct renesas_r61307_priv {
+   struct udevice *vcc;
+   struct udevice *iovcc;
+
+   struct udevice *backlight;
+
+   struct gpio_desc reset_gpio;
+
+   bool dig_cont_adj;
+   bool inversion;
+   u32 gamma;
+};
+
+static const u8 macp_on[] = {
+   R61307_MACP, 0x03
+};
+
+static const u8 macp_off[] = {
+   R61307_MACP, 0x04
+};
+
+static const u8 address_mode[] = {
+   MIPI_DCS_SET_ADDRESS_MODE
+};
+
+static const u8 contrast_setting[] = {
+   R61307_CONTRAST_SET,
+   0xDC, 0xB4, 0xFF
+};
+
+static const u8 column_inversion[] = {
+   R61307_INVERSION,
+   0x00, 0x50, 0x03, 0x22,
+   0x16, 0x06, 0x60, 0x11
+};
+
+static const u8 line_inversion[] = {
+   R61307_INVERSION,
+   0x00, 0x10, 0x03, 0x22,
+   0x16, 0x06, 0x60, 0x01
+};
+
+static const u8 gamma_setting[][25] = {
+   {},
+   {
+   R61307_GAMMA_SET_A,
+   0x00, 0x06, 0x0A, 0x0F,
+   0x14, 0x1F, 0x1F, 0x17,
+   0x12, 0x0C, 0x09, 0x06,
+   0x00, 0x06, 0x0A, 0x0F,
+   0x14, 0x1F, 0x1F, 0x17,
+   0x12, 0x0C, 0x09, 0x06
+   },
+   {
+   R61307_GAMMA_SET_A,
+   0x00, 0x05, 0x0B, 0x0F,
+   0x11, 0x1D, 0x20, 0x18,
+   0x18, 0x09, 0x07, 0x06,
+   0x00, 0x05, 0x0B, 0x0F,
+   0x11, 0x1D, 0x20, 0x18,
+   0x18, 0x09, 0x07, 0x06
+   },
+   {
+   R61307_GAMMA_SET_A,
+   0x0B, 0x0D, 0x10, 0x14,
+   0x13, 0x1D, 0x20, 0x18,
+   0x12, 0x09, 0x07, 0x06,
+   0x0A, 0x0C, 0x10, 0x14,
+   0x13, 0x1D, 0x20, 0x18,
+   0x12, 0x09, 0x07, 0x06
+   },
+};
+
+static struct display_timing default_timing = {
+   .pixelclock.typ = 6200,
+   .hactive.typ= 768,
+   .hfront_porch.typ   = 116,
+   .hback_porch.typ= 81,
+   .hsync_len.typ  = 5,
+   .vactive.typ= 1024,
+   .vfront_porch.typ   = 24,
+   .vback_porch.typ= 8,
+   .vsync_len.typ  = 2,
+};
+
+static int renesas_r61307_enable_backlight(struct udevice *dev)
+{
+   struct 

[PATCH v1 2/6] video: bridge: add Solomon SSD2825 DSI/LVDS driver

2023-04-19 Thread Svyatoslav Ryhel
SSD2825 is an innovative and cost-effective MIPI Bridge Chip solution
targeting high resolution smartphones. It can convert 24bit RGB
interface into 4-lane MIPI-DSI interface to drive extremely high
resolution display modules of up to 800 x 1366, while supporting AMOLED,
a-si LCD or LTPS advanced panel technologies for smartphone applications.

Bridge is wrapped in panel uClass model for wider compatibility.

Tested-by: Andreas Westman Dorcsak  # LG P880 T30
Tested-by: Svyatoslav Ryhel  # LG P895 T30
Signed-off-by: Svyatoslav Ryhel 
---
 drivers/video/bridge/Kconfig   |   7 +
 drivers/video/bridge/Makefile  |   1 +
 drivers/video/bridge/ssd2825.c | 523 +
 3 files changed, 531 insertions(+)
 create mode 100644 drivers/video/bridge/ssd2825.c

diff --git a/drivers/video/bridge/Kconfig b/drivers/video/bridge/Kconfig
index 765f7380b8..2311ca2d1a 100644
--- a/drivers/video/bridge/Kconfig
+++ b/drivers/video/bridge/Kconfig
@@ -33,3 +33,10 @@ config VIDEO_BRIDGE_ANALOGIX_ANX6345
help
 The Analogix ANX6345 is RGB-to-DP converter. It enables an eDP LCD
 panel to be connected to an parallel LCD interface.
+
+config VIDEO_BRIDGE_SOLOMON_SSD2825
+   bool "Solomon SSD2825 bridge driver"
+   depends on PANEL && DM_GPIO
+   select VIDEO_MIPI_DSI
+   help
+ Solomon SSD2824 SPI RGB-DSI bridge driver wrapped into panel uClass.
diff --git a/drivers/video/bridge/Makefile b/drivers/video/bridge/Makefile
index 45e54ac176..22625c8bc6 100644
--- a/drivers/video/bridge/Makefile
+++ b/drivers/video/bridge/Makefile
@@ -7,3 +7,4 @@ obj-$(CONFIG_VIDEO_BRIDGE) += video-bridge-uclass.o
 obj-$(CONFIG_VIDEO_BRIDGE_PARADE_PS862X) += ps862x.o
 obj-$(CONFIG_VIDEO_BRIDGE_NXP_PTN3460) += ptn3460.o
 obj-$(CONFIG_VIDEO_BRIDGE_ANALOGIX_ANX6345) += anx6345.o
+obj-$(CONFIG_VIDEO_BRIDGE_SOLOMON_SSD2825) += ssd2825.o
diff --git a/drivers/video/bridge/ssd2825.c b/drivers/video/bridge/ssd2825.c
new file mode 100644
index 00..6b504b7318
--- /dev/null
+++ b/drivers/video/bridge/ssd2825.c
@@ -0,0 +1,523 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2022 Svyatoslav Ryhel 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define SSD2825_DEVICE_ID_REG  0xB0
+#define SSD2825_RGB_INTERFACE_CTRL_REG_1   0xB1
+#define SSD2825_RGB_INTERFACE_CTRL_REG_2   0xB2
+#define SSD2825_RGB_INTERFACE_CTRL_REG_3   0xB3
+#define SSD2825_RGB_INTERFACE_CTRL_REG_4   0xB4
+#define SSD2825_RGB_INTERFACE_CTRL_REG_5   0xB5
+#define SSD2825_RGB_INTERFACE_CTRL_REG_6   0xB6
+#define   SSD2825_NON_BURSTBIT(2)
+#define   SSD2825_BURSTBIT(3)
+#define   SSD2825_PCKL_HIGHBIT(13)
+#define   SSD2825_HSYNC_HIGH   BIT(14)
+#define   SSD2825_VSYNC_HIGH   BIT(15)
+#define SSD2825_CONFIGURATION_REG  0xB7
+#define   SSD2825_CONF_REG_HS  BIT(0)
+#define   SSD2825_CONF_REG_CKE BIT(1)
+#define   SSD2825_CONF_REG_SLP BIT(2)
+#define   SSD2825_CONF_REG_VEN BIT(3)
+#define   SSD2825_CONF_REG_HCLKBIT(4)
+#define   SSD2825_CONF_REG_CSS BIT(5)
+#define   SSD2825_CONF_REG_DCS BIT(6)
+#define   SSD2825_CONF_REG_REN BIT(7)
+#define   SSD2825_CONF_REG_ECD BIT(8)
+#define   SSD2825_CONF_REG_EOT BIT(9)
+#define   SSD2825_CONF_REG_LPE BIT(10)
+#define SSD2825_VC_CTRL_REG0xB8
+#define SSD2825_PLL_CTRL_REG   0xB9
+#define SSD2825_PLL_CONFIGURATION_REG  0xBA
+#define SSD2825_CLOCK_CTRL_REG 0xBB
+#define SSD2825_PACKET_SIZE_CTRL_REG_1 0xBC
+#define SSD2825_PACKET_SIZE_CTRL_REG_2 0xBD
+#define SSD2825_PACKET_SIZE_CTRL_REG_3 0xBE
+#define SSD2825_PACKET_DROP_REG0xBF
+#define SSD2825_OPERATION_CTRL_REG 0xC0
+#define SSD2825_MAX_RETURN_SIZE_REG0xC1
+#define SSD2825_RETURN_DATA_COUNT_REG  0xC2
+#define SSD2825_ACK_RESPONSE_REG   0xC3
+#define SSD2825_LINE_CTRL_REG  0xC4
+#define SSD2825_INTERRUPT_CTRL_REG 0xC5
+#define SSD2825_INTERRUPT_STATUS_REG   0xC6
+#define SSD2825_ERROR_STATUS_REG   0xC7
+#define SSD2825_DATA_FORMAT_REG0xC8
+#define SSD2825_DELAY_ADJ_REG_10xC9
+#define SSD2825_DELAY_ADJ_REG_20xCA
+#define SSD2825_DELAY_ADJ_REG_30xCB
+#define SSD2825_DELAY_ADJ_REG_40xCC
+#define SSD2825_DELAY_ADJ_REG_50xCD
+#define SSD2825_DELAY_ADJ_REG_60xCE
+#define SSD2825_HS_TX_TIMER_REG_1  0xCF
+#define 

[PATCH v1 4/6] video: panel: add Renesas R69328 MIPI DSI panel driver

2023-04-19 Thread Svyatoslav Ryhel
Driver adds support for panels with Renesas R69328 IC

Currently supported compatible is:
- jdi,dx12d100vm0eaa

Tested-by: Andreas Westman Dorcsak  # LG P880 T30
Tested-by: Svyatoslav Ryhel  # LG P895 T30
Signed-off-by: Svyatoslav Ryhel 
---
 drivers/video/Kconfig  |   9 ++
 drivers/video/Makefile |   1 +
 drivers/video/renesas-r69328.c | 232 +
 3 files changed, 242 insertions(+)
 create mode 100644 drivers/video/renesas-r69328.c

diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index bfd8c4f126..2218eab3dd 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -489,6 +489,15 @@ config VIDEO_LCD_RENESAS_R61307
  IPS-LCD module with Renesas R69328 IC. The panel has a 1024x768
  resolution and uses 24 bit RGB per pixel.
 
+config VIDEO_LCD_RENESAS_R69328
+   tristate "Renesas R69328 720x1280 DSI video mode panel"
+   depends on PANEL && BACKLIGHT
+   select VIDEO_MIPI_DSI
+   help
+ Say Y here if you want to enable support for JDI dx12d100vm0eaa
+ IPS-LCD module with Renesas R69328 IC. The panel has a 720x1280
+ resolution and uses 24 bit RGB per pixel.
+
 config VIDEO_LCD_SSD2828
bool "SSD2828 bridge chip"
---help---
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index 9ab5de8858..cddfc8fd33 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -57,6 +57,7 @@ obj-$(CONFIG_VIDEO_LCD_HITACHI_TX18D42VM) += 
hitachi_tx18d42vm_lcd.o
 obj-$(CONFIG_VIDEO_LCD_ORISETECH_OTM8009A) += orisetech_otm8009a.o
 obj-$(CONFIG_VIDEO_LCD_RAYDIUM_RM68200) += raydium-rm68200.o
 obj-$(CONFIG_VIDEO_LCD_RENESAS_R61307) += renesas-r61307.o
+obj-$(CONFIG_VIDEO_LCD_RENESAS_R69328) += renesas-r69328.o
 obj-$(CONFIG_VIDEO_LCD_SSD2828) += ssd2828.o
 obj-$(CONFIG_VIDEO_LCD_TDO_TL070WSH30) += tdo-tl070wsh30.o
 obj-$(CONFIG_VIDEO_MCDE_SIMPLE) += mcde_simple.o
diff --git a/drivers/video/renesas-r69328.c b/drivers/video/renesas-r69328.c
new file mode 100644
index 00..999bf54c57
--- /dev/null
+++ b/drivers/video/renesas-r69328.c
@@ -0,0 +1,232 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Renesas R69328 panel driver
+ *
+ * Copyright (c) 2022 Svyatoslav Ryhel 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define R69328_MACP0xB0 /* Manufacturer Command Access Protect */
+
+#define R69328_GAMMA_SET_A 0xC8 /* Gamma Setting A */
+#define R69328_GAMMA_SET_B 0xC9 /* Gamma Setting B */
+#define R69328_GAMMA_SET_C 0xCA /* Gamma Setting C */
+
+#define R69328_POWER_SET   0xD1
+
+struct renesas_r69328_priv {
+   struct udevice *backlight;
+
+   struct gpio_desc enable_gpio;
+   struct gpio_desc reset_gpio;
+};
+
+static const u8 address_mode[] = {
+   MIPI_DCS_SET_ADDRESS_MODE
+};
+
+#define dsi_generic_write_seq(dsi, cmd, seq...) do {   \
+   static const u8 b[] = { cmd, seq }; \
+   int ret;\
+   ret = mipi_dsi_dcs_write_buffer(dsi, b, ARRAY_SIZE(b)); \
+   if (ret < 0)\
+   return ret; \
+   } while (0)
+
+static struct display_timing default_timing = {
+   .pixelclock.typ = 6800,
+   .hactive.typ= 720,
+   .hfront_porch.typ   = 92,
+   .hback_porch.typ= 62,
+   .hsync_len.typ  = 4,
+   .vactive.typ= 1280,
+   .vfront_porch.typ   = 6,
+   .vback_porch.typ= 3,
+   .vsync_len.typ  = 1,
+};
+
+static int renesas_r69328_enable_backlight(struct udevice *dev)
+{
+   struct renesas_r69328_priv *priv = dev_get_priv(dev);
+   int ret;
+
+   ret = dm_gpio_set_value(>enable_gpio, 1);
+   if (ret) {
+   printf("%s: error changing enable-gpios (%d)\n", __func__, ret);
+   return ret;
+   }
+   mdelay(5);
+
+   ret = dm_gpio_set_value(>reset_gpio, 0);
+   if (ret) {
+   printf("%s: error changing reset-gpios (%d)\n", __func__, ret);
+   return ret;
+   }
+   mdelay(5);
+
+   ret = dm_gpio_set_value(>reset_gpio, 1);
+   if (ret) {
+   printf("%s: error changing reset-gpios (%d)\n", __func__, ret);
+   return ret;
+   }
+
+   mdelay(5);
+
+   return 0;
+}
+
+static int renesas_r69328_set_backlight(struct udevice *dev, int percent)
+{
+   struct renesas_r69328_priv *priv = dev_get_priv(dev);
+   struct mipi_dsi_panel_plat *plat = dev_get_plat(dev);
+   struct mipi_dsi_device *dsi = plat->device;
+   int ret;
+
+   mipi_dsi_dcs_write_buffer(dsi, address_mode,
+ sizeof(address_mode));
+
+   ret = 

[PATCH v1 1/6] video: add lm3533 backlight driver

2023-04-19 Thread Svyatoslav Ryhel
This is basic lm3533 driver only with bank A and
backlight cell support.

Tested-by: Andreas Westman Dorcsak  # LG P880 T30
Tested-by: Svyatoslav Ryhel  # LG P895 T30
Signed-off-by: Svyatoslav Ryhel 
---
 drivers/video/Kconfig|   8 ++
 drivers/video/Makefile   |   1 +
 drivers/video/lm3533_backlight.c | 135 +++
 3 files changed, 144 insertions(+)
 create mode 100644 drivers/video/lm3533_backlight.c

diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig
index 334d64c948..1695d17c8d 100644
--- a/drivers/video/Kconfig
+++ b/drivers/video/Kconfig
@@ -606,6 +606,14 @@ config ATMEL_HLCD
help
   HLCDC supports video output to an attached LCD panel.
 
+config BACKLIGHT_LM3533
+   bool "Backlight Driver for LM3533"
+   depends on BACKLIGHT
+   select DM_I2C
+   help
+ Say Y to enable the backlight driver for National Semiconductor / TI
+ LM3533 Lighting Power chips.
+
 source "drivers/video/ti/Kconfig"
 
 source "drivers/video/exynos/Kconfig"
diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index 4d75771745..05fb063105 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -28,6 +28,7 @@ obj-$(CONFIG_VIDEO_LOGO) += u_boot_logo.o
 
 endif
 
+obj-$(CONFIG_BACKLIGHT_LM3533) += lm3533_backlight.o
 obj-${CONFIG_EXYNOS_FB} += exynos/
 obj-${CONFIG_VIDEO_ROCKCHIP} += rockchip/
 obj-${CONFIG_VIDEO_STM32} += stm32/
diff --git a/drivers/video/lm3533_backlight.c b/drivers/video/lm3533_backlight.c
new file mode 100644
index 00..3a56534b2f
--- /dev/null
+++ b/drivers/video/lm3533_backlight.c
@@ -0,0 +1,135 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2022 Svyatoslav Ryhel 
+ */
+
+#define LOG_CATEGORY UCLASS_PANEL_BACKLIGHT
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define LM3533_BL_MIN_BRIGHTNESS   0x02
+#define LM3533_BL_MAX_BRIGHTNESS   0xFF
+
+#define LM3533_SINK_OUTPUT_CONFIG_10x10
+#define LM3533_CONTROL_BANK_A_PWM  0x14
+#define LM3533_CONTROL_BANK_AB_BRIGHTNESS  0x1A
+#define LM3533_CONTROL_BANK_A_FULLSCALE_CURRENT0x1F
+#define LM3533_CONTROL_BANK_ENABLE 0x27
+#define LM3533_OVP_FREQUENCY_PWM_POLARITY  0x2C
+#define LM3533_BRIGHTNESS_REGISTER_A   0x40
+
+struct lm3533_backlight_priv {
+   struct gpio_desc enable_gpio;
+   u32 def_bl_lvl;
+};
+
+static int lm3533_backlight_enable(struct udevice *dev)
+{
+   struct lm3533_backlight_priv *priv = dev_get_priv(dev);
+   int ret;
+
+   dm_gpio_set_value(>enable_gpio, 1);
+   mdelay(5);
+
+   /* HVLED 1 & 2 are controlled by Bank A */
+   ret = dm_i2c_reg_write(dev, LM3533_SINK_OUTPUT_CONFIG_1, 0x00);
+   if (ret)
+   return ret;
+
+   /* PWM input is disabled for CABC */
+   ret = dm_i2c_reg_write(dev, LM3533_CONTROL_BANK_A_PWM, 0x00);
+   if (ret)
+   return ret;
+
+   /* Linear & Control Bank A is configured for register Current control */
+   ret = dm_i2c_reg_write(dev, LM3533_CONTROL_BANK_AB_BRIGHTNESS, 0x02);
+   if (ret)
+   return ret;
+
+   /* Full-Scale Current (20.2mA) */
+   ret = dm_i2c_reg_write(dev, LM3533_CONTROL_BANK_A_FULLSCALE_CURRENT, 
0x13);
+   if (ret)
+   return ret;
+
+   /* Control Bank A is enable */
+   ret = dm_i2c_reg_write(dev, LM3533_CONTROL_BANK_ENABLE, 0x01);
+   if (ret)
+   return ret;
+
+   ret = dm_i2c_reg_write(dev, LM3533_OVP_FREQUENCY_PWM_POLARITY, 0x0A);
+   if (ret)
+   return ret;
+
+   return 0;
+}
+
+static int lm3533_backlight_set_brightness(struct udevice *dev, int percent)
+{
+   struct lm3533_backlight_priv *priv = dev_get_priv(dev);
+   int ret;
+
+   if (percent == BACKLIGHT_DEFAULT)
+   percent = priv->def_bl_lvl;
+
+   if (percent < LM3533_BL_MIN_BRIGHTNESS)
+   percent = LM3533_BL_MIN_BRIGHTNESS;
+
+   if (percent > LM3533_BL_MAX_BRIGHTNESS)
+   percent = LM3533_BL_MAX_BRIGHTNESS;
+
+   /* Set brightness level */
+   ret = dm_i2c_reg_write(dev, LM3533_BRIGHTNESS_REGISTER_A,
+  percent);
+   if (ret)
+   return ret;
+
+   return 0;
+}
+
+static int lm3533_backlight_probe(struct udevice *dev)
+{
+   struct lm3533_backlight_priv *priv = dev_get_priv(dev);
+   int ret;
+
+   if (device_get_uclass_id(dev->parent) != UCLASS_I2C)
+   return -EPROTONOSUPPORT;
+
+   ret = gpio_request_by_name(dev, "enable-gpios", 0,
+  >enable_gpio, GPIOD_IS_OUT);
+   if (ret) {
+   printf("%s: Could not decode enable-gpios (%d)\n",
+  __func__, ret);
+   return ret;
+   }
+
+   priv->def_bl_lvl = 

[PATCH v1 0/6] Add video drivers for endeavoru and p880/p895

2023-04-19 Thread Svyatoslav Ryhel
This patchset contains mostly generic drivers used by endeavoru
and p895/p880 (which are currently in the process of merging).
Drivers do not contain any device specific parts and mostly can
be used by any device with supported hardware.

LG P880\P895 related drivers:
- lm3533 backlight driver implements only backlight part for
bank A. Unfortunately, I can not test and set up bank B since
my device does not use it.
- Solomon ssd2825 bridge is fully implemented for 3wire-9bit
mode. It uses SPI interface and is wrapped into panel DM for
wider compatibility.
- 2 DSI panels which use Renesas R61307 and R69328 controllers
are fully implemented as well.

HTC One X (endeavoru) related drivers:
- backlight driver which uses a PWM source provided by the display
controller.
- endeavoru uses panels made by 3 different vendors but the command
sequence seems to be generally the same. Endeavoru panel driver
is set to support all 3 variants of this panel.

Svyatoslav Ryhel (6):
  video: add lm3533 backlight driver
  video: bridge: add Solomon SSD2825 DSI/LVDS driver
  video: panel: add Renesas R61307 MIPI DSI panel driver
  video: panel: add Renesas R69328 MIPI DSI panel driver
  video: tegra: add DC based PWM backlight driver
  video: panel: add generic endeavoru panel

 drivers/video/Kconfig   |  37 ++
 drivers/video/Makefile  |   4 +
 drivers/video/bridge/Kconfig|   7 +
 drivers/video/bridge/Makefile   |   1 +
 drivers/video/bridge/ssd2825.c  | 523 
 drivers/video/endeavoru-panel.c | 252 ++
 drivers/video/lm3533_backlight.c| 135 +
 drivers/video/renesas-r61307.c  | 296 +++
 drivers/video/renesas-r69328.c  | 232 +
 drivers/video/tegra20/Kconfig   |   7 +
 drivers/video/tegra20/Makefile  |   1 +
 drivers/video/tegra20/tegra-pwm-backlight.c | 155 ++
 12 files changed, 1650 insertions(+)
 create mode 100644 drivers/video/bridge/ssd2825.c
 create mode 100644 drivers/video/endeavoru-panel.c
 create mode 100644 drivers/video/lm3533_backlight.c
 create mode 100644 drivers/video/renesas-r61307.c
 create mode 100644 drivers/video/renesas-r69328.c
 create mode 100644 drivers/video/tegra20/tegra-pwm-backlight.c

-- 
2.37.2



[PATCH v1 1/1] misc: extcon: add MAX14526 MUIC support

2023-04-19 Thread Svyatoslav Ryhel
MAX14526 is a powerful extcon chip which allows detection of various
plugs like usb, mhl, uart, headset etc. This version of driver
implements support of AP-usb and CP-usb/uart paths.

Tested-by: Andreas Westman Dorcsak  # LG P880 T30
Tested-by: Svyatoslav Ryhel  # LG P895 T30
Signed-off-by: Svyatoslav Ryhel 
---
 drivers/misc/Kconfig  |   2 +
 drivers/misc/Makefile |   1 +
 drivers/misc/extcon/Kconfig   |   8 ++
 drivers/misc/extcon/Makefile  |   2 +
 drivers/misc/extcon/extcon-max14526.c | 153 ++
 5 files changed, 166 insertions(+)
 create mode 100644 drivers/misc/extcon/Kconfig
 create mode 100644 drivers/misc/extcon/Makefile
 create mode 100644 drivers/misc/extcon/extcon-max14526.c

diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 4e1ae03e9f..1b49f3cf72 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -659,4 +659,6 @@ config SL28CPLD
  the base driver which provides common access methods for the
  sub-drivers.
 
+source "drivers/misc/extcon/Kconfig"
+
 endmenu
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 3b792f2a14..6d4fc8ddf9 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -87,3 +87,4 @@ obj-$(CONFIG_K3_AVS0) += k3_avs.o
 obj-$(CONFIG_ESM_K3) += k3_esm.o
 obj-$(CONFIG_ESM_PMIC) += esm_pmic.o
 obj-$(CONFIG_SL28CPLD) += sl28cpld.o
+obj-y += extcon/
diff --git a/drivers/misc/extcon/Kconfig b/drivers/misc/extcon/Kconfig
new file mode 100644
index 00..99c38224f3
--- /dev/null
+++ b/drivers/misc/extcon/Kconfig
@@ -0,0 +1,8 @@
+config EXTCON_MAX14526
+   bool "Maxim MAX14526 EXTCON Support"
+   select DM_I2C
+   select DM_MISC
+   help
+ If you say yes here you get support for the MUIC device of
+ Maxim MAX14526. The MAX14526 MUIC is a USB port accessory
+ detector and switch.
diff --git a/drivers/misc/extcon/Makefile b/drivers/misc/extcon/Makefile
new file mode 100644
index 00..f012b688ce
--- /dev/null
+++ b/drivers/misc/extcon/Makefile
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0+
+obj-$(CONFIG_EXTCON_MAX14526) += extcon-max14526.o
diff --git a/drivers/misc/extcon/extcon-max14526.c 
b/drivers/misc/extcon/extcon-max14526.c
new file mode 100644
index 00..c8505dae49
--- /dev/null
+++ b/drivers/misc/extcon/extcon-max14526.c
@@ -0,0 +1,153 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (c) 2022 Svyatoslav Ryhel 
+ *
+ * U-boot lacks extcon DM.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define CONTROL_1  0x01
+#define SW_CONTROL 0x03
+
+#define ID_200 0x10
+#define ADC_EN 0x02
+#define CP_EN  0x01
+
+#define DP_USB 0x00
+#define DP_UART0x08
+#define DP_AUDIO   0x10
+#define DP_OPEN0x38
+
+#define DM_USB 0x00
+#define DM_UART0x01
+#define DM_AUDIO   0x02
+#define DM_OPEN0x07
+
+#define AP_USB BIT(0)
+#define CP_USB BIT(1)
+#define CP_UARTBIT(2)
+
+struct max14526_priv {
+   struct gpio_desc usif_gpio;
+   struct gpio_desc dp2t_gpio;
+   struct gpio_desc ifx_usb_vbus_gpio;
+};
+
+static void max14526_set_mode(struct udevice *dev, int mode)
+{
+   struct max14526_priv *priv = dev_get_priv(dev);
+   int ret;
+
+   if ((mode & AP_USB) || (mode & CP_USB)) {
+   /* Connect CP UART signals to AP */
+   ret = dm_gpio_set_value(>usif_gpio, 0);
+   if (ret)
+   printf("%s: error changing usif-gpio (%d)\n", __func__, 
ret);
+   }
+
+   if (mode & CP_UART) {
+   /* Connect CP UART signals to DP2T */
+   ret = dm_gpio_set_value(>usif_gpio, 1);
+   if (ret)
+   printf("%s: error changing usif-gpio (%d)\n", __func__, 
ret);
+   }
+
+   if (mode & CP_USB) {
+   /* Connect CP USB to MUIC UART */
+   ret = dm_gpio_set_value(>ifx_usb_vbus_gpio, 1);
+   if (ret)
+   printf("%s: error changing usb-vbus-gpio (%d)\n", 
__func__, ret);
+
+   ret = dm_gpio_set_value(>dp2t_gpio, 1);
+   if (ret)
+   printf("%s: error changing dp2t-gpio (%d)\n", __func__, 
ret);
+   }
+
+   if ((mode & AP_USB) || (mode & CP_UART)) {
+   /* Connect CP UART to MUIC UART */
+   ret = dm_gpio_set_value(>dp2t_gpio, 0);
+   if (ret)
+   printf("%s: error changing dp2t-gpio (%d)\n", __func__, 
ret);
+   }
+
+   if (mode & AP_USB) {
+   /* Enables USB Path */
+   ret = dm_i2c_reg_write(dev, SW_CONTROL, DP_USB | DM_USB);
+   if (ret)
+   printf("USB Path set failed: %d\n", ret);
+   }
+
+   if ((mode & CP_USB) || (mode & CP_UART)) {
+ 

[PATCH v1 0/1] Add MAX14526 MUIC driver

2023-04-19 Thread Svyatoslav Ryhel
MAX14526 MUIC is used by LG P880/P895 which are currently
in the process of merging.

Unfortunately U-Boot has no extcon driver model so I used
a MISC model for now.

MAX14526 is a powerful extcon device which has the ability to
accurately determine plugged devices. In this implementation
muic can be configured to represent 3 modes: CP-USB/UART and
AP-USB. Unfortunately AP-UART was disabled on P880/P895.
Additionally the driver configures some stuff required by
the charger.

Svyatoslav Ryhel (1):
  misc: extcon: add MAX14526 MUIC support

 drivers/misc/Kconfig  |   2 +
 drivers/misc/Makefile |   1 +
 drivers/misc/extcon/Kconfig   |   8 ++
 drivers/misc/extcon/Makefile  |   2 +
 drivers/misc/extcon/extcon-max14526.c | 153 ++
 5 files changed, 166 insertions(+)
 create mode 100644 drivers/misc/extcon/Kconfig
 create mode 100644 drivers/misc/extcon/Makefile
 create mode 100644 drivers/misc/extcon/extcon-max14526.c

-- 
2.37.2



Re: [PATCH] rmobile: avoid deprecated srec_cat flags

2023-04-19 Thread Marek Vasut

On 4/19/23 18:30, Ralph Siemsen wrote:

On Tue, Apr 18, 2023 at 3:36 PM Marek Vasut  wrote:

I'm afraid this needs some backward compatibility sreccat version check
. Similar to GCC compiler flags presence check. To avoid breaking legacy
users.


I'll revisit this after the rz/n1 work, which is more important.

Also I noticed that srec_cat is being called even when it is not
installed, which of course causes the build to fail. This is curious
since the makefile checks for srec_cat prior to using it.


I have this one on my ToDo too. Basically what I am pondering about is 
whether we can get rid of SREC_CAT and replace it somehow with binman. 
The keyword here is "somehow" right now ... for I have no idea how yet.


Re: [PATCH] rmobile: avoid deprecated srec_cat flags

2023-04-19 Thread Ralph Siemsen
On Tue, Apr 18, 2023 at 3:36 PM Marek Vasut  wrote:
> I'm afraid this needs some backward compatibility sreccat version check
> . Similar to GCC compiler flags presence check. To avoid breaking legacy
> users.

I'll revisit this after the rz/n1 work, which is more important.

Also I noticed that srec_cat is being called even when it is not
installed, which of course causes the build to fail. This is curious
since the makefile checks for srec_cat prior to using it.

Ralph


Re: [PATCH v2] nand: brcmnand: add iproc support

2023-04-19 Thread Dario Binacchi
Hi Linus,

On Wed, Apr 19, 2023 at 4:00 PM Linus Walleij  wrote:
>
> On Wed, Apr 19, 2023 at 3:19 PM Dario Binacchi
>  wrote:
> > On Wed, Apr 19, 2023 at 3:04 PM Linus Walleij  
> > wrote:
> > >
> > > On Mon, Apr 17, 2023 at 10:37 AM Dario Binacchi
> > >  wrote:
> > >
> > > > Applied to nand-next ( as well as the patch "mtd: rawnand: nand_base:
> > > > Handle algorithm selection").
> > >
> > > 1) Sweet! Thanks.
> > >
> > > 2) Did you use the latest versions that I resent as part of the
> > > NorthStar support?
> >
> > I applied v2:
> > https://patchwork.ozlabs.org/project/uboot/patch/20230308214231.378013-1-linus.wall...@linaro.org/
> > https://patchwork.ozlabs.org/project/uboot/patch/20230308212851.370939-1-linus.wall...@linaro.org/
>
> The second patch will be problematic, can you switch it to the newer
> versions?

This one?
https://patchwork.ozlabs.org/project/uboot/patch/20230308212851.370939-1-linus.wall...@linaro.org/
I can revert the commit
ff33d3c87c2a mtd: rawnand: nand_base: Handle algorithm selection
and apply your newer patch.
Do you agree?

Thanks and regards,
Dario
>
> I'm sorry for messing things up by moving the patches over to a
> different series :(
>
> Thanks,
> Linus Walleij



-- 

Dario Binacchi

Senior Embedded Linux Developer

dario.binac...@amarulasolutions.com

__


Amarula Solutions SRL

Via Le Canevare 30, 31100 Treviso, Veneto, IT

T. +39 042 243 5310
i...@amarulasolutions.com

www.amarulasolutions.com


Re: [PATCH] arch: arm: mach-k3: Delete tifs node in DT fixup

2023-04-19 Thread Nishanth Menon
On 11:43-20230419, Udit Kumar wrote:
> This patch deletes tifs DT node as part of fixup.
> 
> TISCI API reported msmc_size, does not include
> 64KB reserved size for tifs aka MSMC comms memory.
> 
> As part of fixup, original code uses TISCI API
> reported msmc_size as size for sram DT node.
> 
> tifs node is similar to l3-cache, which should
> hold address above msms_size, and should be deleted
> before passing control to OS.
> 
> Documentation
> https://software-dl.ti.com/tisci/esd/latest/2_tisci_msgs/general/core.html?highlight=msmc#tisci-msg-query-msmc
> 
> Signed-off-by: Udit Kumar 
> ---
>  arch/arm/mach-k3/common.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c
> index a2adb791f6..4651744821 100644
> --- a/arch/arm/mach-k3/common.c
> +++ b/arch/arm/mach-k3/common.c
> @@ -349,9 +349,11 @@ int fdt_fixup_msmc_ram(void *blob, char *parent_path, 
> char *node_name)
>   size = fdt_read_number(sub_reg, 1);
>   debug("%s: subnode = %d, addr = 0x%x. size = 0x%x\n", __func__,
> subnode, addr, size);
> +
>   if (addr + size > msmc_size ||
>   !strncmp(fdt_get_name(blob, subnode, ), "sysfw", 5) ||
> - !strncmp(fdt_get_name(blob, subnode, ), "l3cache", 7)) {
> + !strncmp(fdt_get_name(blob, subnode, ), "l3cache", 7) ||
> + !strncmp(fdt_get_name(blob, subnode, ), "tifs", 4)) {
I would probably move the tifs check above the l3cache check.

>   fdt_del_node(blob, subnode);
>   debug("%s: deleting subnode %d\n", __func__, subnode);
>   if (!prev_node)
> -- 
> 2.34.1
> 

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


Re: Support for NXP S32K3 Family

2023-04-19 Thread Ashok Kumar
Hi Simon,

Thanks for the reply.

NXP people said we don't support this feature for S32K family.

I am just wondering whether I can get any help from the u-boot sources?


Regards

Ashok

On 19/04/2023 02:45, Simon Glass wrote:
> Hi Ashok,
>
> On Fri, 14 Apr 2023 at 08:55, Ashok Kumar
>  wrote:
>> Hi Folks,
>>
>>
>> I am trying to build a u-boot boot-loader for my S32K344 board.
>>
>> Can you guys please help me, which defconf/config file is suitable for
>> my S32K344 board for building a u-boot binaries?
> If you look in MAINTAINERS you should be able to find contacts for NXP.
>
> Regards,
> Simon


Re: Re: The u-boot supports i2c-over-hid?

2023-04-19 Thread skyo...@126.com
hi,
For i2c interface keyboard, how should we implement u-boot driver?
Do you have any suggestions



skyo...@126.com
 
From: Simon Glass
Date: 2023-04-19 09:45
To: skyo...@126.com
CC: u-boot
Subject: Re: The u-boot supports i2c-over-hid?
Hi,
 
+Heinrich Schuchardt +Heiko Schocher
 
On Thu, 13 Apr 2023 at 08:58, skyo...@126.com  wrote:
>
> Hello,
> I would like to ask whether i2c-over-hid is not supported under u-boot at 
> present. At present, we have this development need. I would like to ask 
> whether it is feasible to transplant i2c-over-hid from kernel. If not, is 
> there any other way?
>
 
I don't see any support for it. Yes, bringing things in from Linux is
a common approach. Some changes are needed for driver model and some
differing APIs.
 
Regards,
Simon


Re: [PATCH v2] nand: brcmnand: add iproc support

2023-04-19 Thread Linus Walleij
On Wed, Apr 19, 2023 at 3:19 PM Dario Binacchi
 wrote:
> On Wed, Apr 19, 2023 at 3:04 PM Linus Walleij  
> wrote:
> >
> > On Mon, Apr 17, 2023 at 10:37 AM Dario Binacchi
> >  wrote:
> >
> > > Applied to nand-next ( as well as the patch "mtd: rawnand: nand_base:
> > > Handle algorithm selection").
> >
> > 1) Sweet! Thanks.
> >
> > 2) Did you use the latest versions that I resent as part of the
> > NorthStar support?
>
> I applied v2:
> https://patchwork.ozlabs.org/project/uboot/patch/20230308214231.378013-1-linus.wall...@linaro.org/
> https://patchwork.ozlabs.org/project/uboot/patch/20230308212851.370939-1-linus.wall...@linaro.org/

The second patch will be problematic, can you switch it to the newer
versions?

I'm sorry for messing things up by moving the patches over to a
different series :(

Thanks,
Linus Walleij


[PATCH v5 3/3] regulator: handle different error codes in regulator_set_enable_if_allowed

2023-04-19 Thread Eugen Hristev
The regulator core can return different codes which are not considered
a real error for this function.
Return success in such cases.

Signed-off-by: Eugen Hristev 
---
Changes in v5:
 - this is a new patch

 drivers/power/regulator/regulator-uclass.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/power/regulator/regulator-uclass.c 
b/drivers/power/regulator/regulator-uclass.c
index d608f7c23657..3a6ba69f6d5f 100644
--- a/drivers/power/regulator/regulator-uclass.c
+++ b/drivers/power/regulator/regulator-uclass.c
@@ -197,6 +197,12 @@ int regulator_set_enable_if_allowed(struct udevice *dev, 
bool enable)
ret = regulator_set_enable(dev, enable);
if (ret == -ENOSYS || ret == -EACCES)
return 0;
+   /* if we want to disable but it's in use by someone else */
+   if (!enable && ret == -EBUSY)
+   return 0;
+   /* if it's already enabled/disabled */
+   if (ret == -EALREADY)
+   return 0;
 
return ret;
 }
-- 
2.34.1



[PATCH v5 2/3] regulator: rename dev_pdata to plat

2023-04-19 Thread Eugen Hristev
Simplify the subsystem by renaming `dev_pdata` to just `plat`.
No functional change, just trivial renaming.

Suggested-by: Simon Glass 
Signed-off-by: Eugen Hristev 
Reviewed-by: Simon Glass 
---
Changes in v3,v4,v5: 
 - none
Changes in v2:
 - this is a new patch

 drivers/power/regulator/fan53555.c | 10 ++--
 drivers/power/regulator/fixed.c| 16 +++
 drivers/power/regulator/gpio-regulator.c   | 46 +--
 drivers/power/regulator/regulator_common.c | 53 +++---
 drivers/power/regulator/regulator_common.h |  8 ++--
 5 files changed, 66 insertions(+), 67 deletions(-)

diff --git a/drivers/power/regulator/fan53555.c 
b/drivers/power/regulator/fan53555.c
index 5681206bbafe..815f96beef61 100644
--- a/drivers/power/regulator/fan53555.c
+++ b/drivers/power/regulator/fan53555.c
@@ -101,7 +101,7 @@ struct fan53555_priv {
 
 static int fan53555_regulator_of_to_plat(struct udevice *dev)
 {
-   struct fan53555_plat *dev_pdata = dev_get_plat(dev);
+   struct fan53555_plat *plat = dev_get_plat(dev);
struct dm_regulator_uclass_plat *uc_pdata =
dev_get_uclass_plat(dev);
u32 sleep_vsel;
@@ -118,12 +118,12 @@ static int fan53555_regulator_of_to_plat(struct udevice 
*dev)
 */
switch (sleep_vsel) {
case FAN53555_VSEL0:
-   dev_pdata->sleep_reg = FAN53555_VSEL0;
-   dev_pdata->vol_reg = FAN53555_VSEL1;
+   plat->sleep_reg = FAN53555_VSEL0;
+   plat->vol_reg = FAN53555_VSEL1;
break;
case FAN53555_VSEL1:
-   dev_pdata->sleep_reg = FAN53555_VSEL1;
-   dev_pdata->vol_reg = FAN53555_VSEL0;
+   plat->sleep_reg = FAN53555_VSEL1;
+   plat->vol_reg = FAN53555_VSEL0;
break;
default:
pr_err("%s: invalid vsel id %d\n", dev->name, sleep_vsel);
diff --git a/drivers/power/regulator/fixed.c b/drivers/power/regulator/fixed.c
index 90004d1601a9..ad3b4b98d667 100644
--- a/drivers/power/regulator/fixed.c
+++ b/drivers/power/regulator/fixed.c
@@ -24,16 +24,16 @@ struct fixed_clock_regulator_plat {
 static int fixed_regulator_of_to_plat(struct udevice *dev)
 {
struct dm_regulator_uclass_plat *uc_pdata;
-   struct regulator_common_plat *dev_pdata;
+   struct regulator_common_plat *plat;
 
-   dev_pdata = dev_get_plat(dev);
+   plat = dev_get_plat(dev);
uc_pdata = dev_get_uclass_plat(dev);
if (!uc_pdata)
return -ENXIO;
 
uc_pdata->type = REGULATOR_TYPE_FIXED;
 
-   return regulator_common_of_to_plat(dev, dev_pdata, "gpio");
+   return regulator_common_of_to_plat(dev, plat, "gpio");
 }
 
 static int fixed_regulator_get_value(struct udevice *dev)
@@ -88,7 +88,7 @@ static int fixed_clock_regulator_get_enable(struct udevice 
*dev)
 static int fixed_clock_regulator_set_enable(struct udevice *dev, bool enable)
 {
struct fixed_clock_regulator_plat *priv = dev_get_priv(dev);
-   struct regulator_common_plat *dev_pdata = dev_get_plat(dev);
+   struct regulator_common_plat *plat = dev_get_plat(dev);
int ret = 0;
 
if (enable) {
@@ -101,11 +101,11 @@ static int fixed_clock_regulator_set_enable(struct 
udevice *dev, bool enable)
if (ret)
return ret;
 
-   if (enable && dev_pdata->startup_delay_us)
-   udelay(dev_pdata->startup_delay_us);
+   if (enable && plat->startup_delay_us)
+   udelay(plat->startup_delay_us);
 
-   if (!enable && dev_pdata->off_on_delay_us)
-   udelay(dev_pdata->off_on_delay_us);
+   if (!enable && plat->off_on_delay_us)
+   udelay(plat->off_on_delay_us);
 
return ret;
 }
diff --git a/drivers/power/regulator/gpio-regulator.c 
b/drivers/power/regulator/gpio-regulator.c
index 9c0a68aa5af4..ded7be059bb0 100644
--- a/drivers/power/regulator/gpio-regulator.c
+++ b/drivers/power/regulator/gpio-regulator.c
@@ -27,12 +27,12 @@ struct gpio_regulator_plat {
 static int gpio_regulator_of_to_plat(struct udevice *dev)
 {
struct dm_regulator_uclass_plat *uc_pdata;
-   struct gpio_regulator_plat *dev_pdata;
+   struct gpio_regulator_plat *plat;
struct gpio_desc *gpio;
int ret, count, i, j;
u32 states_array[GPIO_REGULATOR_MAX_STATES * 2];
 
-   dev_pdata = dev_get_plat(dev);
+   plat = dev_get_plat(dev);
uc_pdata = dev_get_uclass_plat(dev);
if (!uc_pdata)
return -ENXIO;
@@ -47,7 +47,7 @@ static int gpio_regulator_of_to_plat(struct udevice *dev)
 * per gpio-regulator. As of now no instance with multiple
 * gpios is presnt
 */
-   gpio = _pdata->gpio;
+   gpio = >gpio;
ret = gpio_request_by_name(dev, "gpios", 0, gpio, GPIOD_IS_OUT);
if (ret)
debug("regulator gpio - not found! Error: %d", ret);
@@ -68,21 +68,21 @@ static int 

[PATCH v5 1/3] regulator: implement basic reference counter

2023-04-19 Thread Eugen Hristev
Some devices share a regulator supply, when the first one will request
regulator disable, the second device will have it's supply cut off before
graciously shutting down. Hence there will be timeouts and other failed
operations.
Implement a reference counter mechanism similar with what is done in
Linux, to keep track of enable and disable requests, and only disable the
regulator when the last of the consumers has requested shutdown.

Signed-off-by: Eugen Hristev 
Reviewed-by: Simon Glass 
---
Changes in v5:
 - none
Changes in v4:
 - add documentation for error codes
Changes in v3:
 - add error return codes
Changes in v2:
 - add info in header regarding the function

 drivers/power/regulator/regulator_common.c | 22 ++
 drivers/power/regulator/regulator_common.h | 21 +
 2 files changed, 43 insertions(+)

diff --git a/drivers/power/regulator/regulator_common.c 
b/drivers/power/regulator/regulator_common.c
index 93d8196b381e..484a4fc31ef7 100644
--- a/drivers/power/regulator/regulator_common.c
+++ b/drivers/power/regulator/regulator_common.c
@@ -73,6 +73,23 @@ int regulator_common_set_enable(const struct udevice *dev,
return 0;
}
 
+   /* If previously enabled, increase count */
+   if (enable && dev_pdata->enable_count > 0) {
+   dev_pdata->enable_count++;
+   return -EALREADY;
+   }
+
+   if (!enable) {
+   if (dev_pdata->enable_count > 1) {
+   /* If enabled multiple times, decrease count */
+   dev_pdata->enable_count--;
+   return -EBUSY;
+   } else if (!dev_pdata->enable_count) {
+   /* If already disabled, do nothing */
+   return -EALREADY;
+   }
+   }
+
ret = dm_gpio_set_value(_pdata->gpio, enable);
if (ret) {
pr_err("Can't set regulator : %s gpio to: %d\n", dev->name,
@@ -87,5 +104,10 @@ int regulator_common_set_enable(const struct udevice *dev,
if (!enable && dev_pdata->off_on_delay_us)
udelay(dev_pdata->off_on_delay_us);
 
+   if (enable)
+   dev_pdata->enable_count++;
+   else
+   dev_pdata->enable_count--;
+
return 0;
 }
diff --git a/drivers/power/regulator/regulator_common.h 
b/drivers/power/regulator/regulator_common.h
index c10492f01675..0faab447d099 100644
--- a/drivers/power/regulator/regulator_common.h
+++ b/drivers/power/regulator/regulator_common.h
@@ -13,6 +13,7 @@ struct regulator_common_plat {
struct gpio_desc gpio; /* GPIO for regulator enable control */
unsigned int startup_delay_us;
unsigned int off_on_delay_us;
+   unsigned int enable_count;
 };
 
 int regulator_common_of_to_plat(struct udevice *dev,
@@ -20,6 +21,26 @@ int regulator_common_of_to_plat(struct udevice *dev,
char *enable_gpio_name);
 int regulator_common_get_enable(const struct udevice *dev,
struct regulator_common_plat *dev_pdata);
+/*
+ * Enable or Disable a regulator
+ *
+ * This is a reentrant function and subsequent calls that enable will
+ * increase an internal counter, and disable calls will decrease the counter.
+ * The actual resource will be enabled when the counter gets to 1 coming from 
0,
+ * and disabled when it reaches 0 coming from 1.
+ *
+ * @dev: regulator device
+ * @dev_pdata: Platform data
+ * @enable: bool indicating whether to enable or disable the regulator
+ * @return:
+ * 0 on Success
+ * -EBUSY if the regulator cannot be disabled because it's requested by
+ *another device
+ * -EALREADY if the regulator has already been enabled or has already been
+ *disabled
+ * -EACCES if there is no possibility to enable/disable the regulator
+ * -ve on different error situation
+ */
 int regulator_common_set_enable(const struct udevice *dev,
struct regulator_common_plat *dev_pdata, bool enable);
 
-- 
2.34.1



[PATCH v5 4/6] phy: remove phy-supply related code

2023-04-19 Thread Eugen Hristev
phy-supply is now handled at uclass level. Remove it from the drivers that
implement it at the driver level.

Suggested-by: Jonas Karlman 
Signed-off-by: Eugen Hristev 
---
 drivers/phy/meson-g12a-usb2.c | 48 ---
 drivers/phy/meson-gxbb-usb2.c | 38 ---
 drivers/phy/meson-gxl-usb2.c  | 30 --
 3 files changed, 116 deletions(-)

diff --git a/drivers/phy/meson-g12a-usb2.c b/drivers/phy/meson-g12a-usb2.c
index 2fbba7fdae01..650b88bd1803 100644
--- a/drivers/phy/meson-g12a-usb2.c
+++ b/drivers/phy/meson-g12a-usb2.c
@@ -54,50 +54,12 @@
 
 struct phy_meson_g12a_usb2_priv {
struct regmap   *regmap;
-#if CONFIG_IS_ENABLED(DM_REGULATOR)
-   struct udevice  *phy_supply;
-#endif
 #if CONFIG_IS_ENABLED(CLK)
struct clk  clk;
 #endif
struct reset_ctlreset;
 };
 
-
-static int phy_meson_g12a_usb2_power_on(struct phy *phy)
-{
-#if CONFIG_IS_ENABLED(DM_REGULATOR)
-   struct udevice *dev = phy->dev;
-   struct phy_meson_g12a_usb2_priv *priv = dev_get_priv(dev);
-
-   if (priv->phy_supply) {
-   int ret = regulator_set_enable(priv->phy_supply, true);
-   if (ret)
-   return ret;
-   }
-#endif
-
-   return 0;
-}
-
-static int phy_meson_g12a_usb2_power_off(struct phy *phy)
-{
-#if CONFIG_IS_ENABLED(DM_REGULATOR)
-   struct udevice *dev = phy->dev;
-   struct phy_meson_g12a_usb2_priv *priv = dev_get_priv(dev);
-
-   if (priv->phy_supply) {
-   int ret = regulator_set_enable(priv->phy_supply, false);
-   if (ret) {
-   pr_err("Error disabling PHY supply\n");
-   return ret;
-   }
-   }
-#endif
-
-   return 0;
-}
-
 static int phy_meson_g12a_usb2_init(struct phy *phy)
 {
struct udevice *dev = phy->dev;
@@ -155,8 +117,6 @@ static int phy_meson_g12a_usb2_exit(struct phy *phy)
 struct phy_ops meson_g12a_usb2_phy_ops = {
.init = phy_meson_g12a_usb2_init,
.exit = phy_meson_g12a_usb2_exit,
-   .power_on = phy_meson_g12a_usb2_power_on,
-   .power_off = phy_meson_g12a_usb2_power_off,
 };
 
 int meson_g12a_usb2_phy_probe(struct udevice *dev)
@@ -193,14 +153,6 @@ int meson_g12a_usb2_phy_probe(struct udevice *dev)
}
 #endif
 
-#if CONFIG_IS_ENABLED(DM_REGULATOR)
-   ret = device_get_supply_regulator(dev, "phy-supply", >phy_supply);
-   if (ret && ret != -ENOENT) {
-   pr_err("Failed to get PHY regulator\n");
-   return ret;
-   }
-#endif
-
return 0;
 }
 
diff --git a/drivers/phy/meson-gxbb-usb2.c b/drivers/phy/meson-gxbb-usb2.c
index 7a2e3d2739e8..70a80b863819 100644
--- a/drivers/phy/meson-gxbb-usb2.c
+++ b/drivers/phy/meson-gxbb-usb2.c
@@ -12,7 +12,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -81,9 +80,6 @@
 struct phy_meson_gxbb_usb2_priv {
struct regmap *regmap;
struct reset_ctl_bulk resets;
-#if CONFIG_IS_ENABLED(DM_REGULATOR)
-   struct udevice *phy_supply;
-#endif
 };
 
 static int phy_meson_gxbb_usb2_power_on(struct phy *phy)
@@ -92,15 +88,6 @@ static int phy_meson_gxbb_usb2_power_on(struct phy *phy)
struct phy_meson_gxbb_usb2_priv *priv = dev_get_priv(dev);
uint val;
 
-#if CONFIG_IS_ENABLED(DM_REGULATOR)
-   if (priv->phy_supply) {
-   int ret = regulator_set_enable(priv->phy_supply, true);
-
-   if (ret)
-   return ret;
-   }
-#endif
-
regmap_update_bits(priv->regmap, REG_CONFIG,
   REG_CONFIG_CLK_32k_ALTSEL,
   REG_CONFIG_CLK_32k_ALTSEL);
@@ -140,26 +127,8 @@ static int phy_meson_gxbb_usb2_power_on(struct phy *phy)
return 0;
 }
 
-static int phy_meson_gxbb_usb2_power_off(struct phy *phy)
-{
-#if CONFIG_IS_ENABLED(DM_REGULATOR)
-   struct udevice *dev = phy->dev;
-   struct phy_meson_gxbb_usb2_priv *priv = dev_get_priv(dev);
-
-   if (priv->phy_supply) {
-   int ret = regulator_set_enable(priv->phy_supply, false);
-
-   if (ret)
-   return ret;
-   }
-#endif
-
-   return 0;
-}
-
 static struct phy_ops meson_gxbb_usb2_phy_ops = {
.power_on = phy_meson_gxbb_usb2_power_on,
-   .power_off = phy_meson_gxbb_usb2_power_off,
 };
 
 static int meson_gxbb_usb2_phy_probe(struct udevice *dev)
@@ -192,13 +161,6 @@ static int meson_gxbb_usb2_phy_probe(struct udevice *dev)
return ret;
}
 
-#if CONFIG_IS_ENABLED(DM_REGULATOR)
-   ret = device_get_supply_regulator(dev, "phy-supply", >phy_supply);
-   if (ret && ret != -ENOENT) {
-   pr_err("Failed to get PHY regulator\n");
-   return ret;
-   }
-#endif
ret = reset_get_bulk(dev, >resets);
if (!ret) {
ret = reset_deassert_bulk(>resets);
diff --git 

[PATCH v5 6/6] phy: Keep balance of counts when ops is missing

2023-04-19 Thread Eugen Hristev
From: Jonas Karlman 

Fixes: 226fce6108fe ("phy: Track power-on and init counts in uclass")
Signed-off-by: Jonas Karlman 
---
 drivers/phy/phy-uclass.c | 80 
 1 file changed, 39 insertions(+), 41 deletions(-)

diff --git a/drivers/phy/phy-uclass.c b/drivers/phy/phy-uclass.c
index 45ec1471d0ae..2a672549f268 100644
--- a/drivers/phy/phy-uclass.c
+++ b/drivers/phy/phy-uclass.c
@@ -228,24 +228,24 @@ int generic_phy_init(struct phy *phy)
 
if (!generic_phy_valid(phy))
return 0;
-   ops = phy_dev_ops(phy->dev);
-   if (!ops->init)
-   return 0;
-
counts = phy_get_counts(phy);
if (counts->init_count > 0) {
counts->init_count++;
return 0;
}
 
-   ret = ops->init(phy);
-   if (ret)
-   dev_err(phy->dev, "PHY: Failed to init %s: %d.\n",
-   phy->dev->name, ret);
-   else
-   counts->init_count = 1;
+   ops = phy_dev_ops(phy->dev);
+   if (ops->init) {
+   ret = ops->init(phy);
+   if (ret) {
+   dev_err(phy->dev, "PHY: Failed to init %s: %d.\n",
+   phy->dev->name, ret);
+   return ret;
+   }
+   }
+   counts->init_count = 1;
 
-   return ret;
+   return 0;
 }
 
 int generic_phy_reset(struct phy *phy)
@@ -274,10 +274,6 @@ int generic_phy_exit(struct phy *phy)
 
if (!generic_phy_valid(phy))
return 0;
-   ops = phy_dev_ops(phy->dev);
-   if (!ops->exit)
-   return 0;
-
counts = phy_get_counts(phy);
if (counts->init_count == 0)
return 0;
@@ -286,14 +282,18 @@ int generic_phy_exit(struct phy *phy)
return 0;
}
 
-   ret = ops->exit(phy);
-   if (ret)
-   dev_err(phy->dev, "PHY: Failed to exit %s: %d.\n",
-   phy->dev->name, ret);
-   else
-   counts->init_count = 0;
+   ops = phy_dev_ops(phy->dev);
+   if (ops->exit) {
+   ret = ops->exit(phy);
+   if (ret) {
+   dev_err(phy->dev, "PHY: Failed to exit %s: %d.\n",
+   phy->dev->name, ret);
+   return ret;
+   }
+   }
+   counts->init_count = 0;
 
-   return ret;
+   return 0;
 }
 
 int generic_phy_power_on(struct phy *phy)
@@ -304,10 +304,6 @@ int generic_phy_power_on(struct phy *phy)
 
if (!generic_phy_valid(phy))
return 0;
-   ops = phy_dev_ops(phy->dev);
-   if (!ops->power_on)
-   return 0;
-
counts = phy_get_counts(phy);
if (counts->power_on_count > 0) {
counts->power_on_count++;
@@ -321,12 +317,15 @@ int generic_phy_power_on(struct phy *phy)
return ret;
}
 
-   ret = ops->power_on(phy);
-   if (ret) {
-   dev_err(phy->dev, "PHY: Failed to power on %s: %d.\n",
-   phy->dev->name, ret);
-   regulator_set_enable_if_allowed(counts->supply, false);
-   return ret;
+   ops = phy_dev_ops(phy->dev);
+   if (ops->power_on) {
+   ret = ops->power_on(phy);
+   if (ret) {
+   dev_err(phy->dev, "PHY: Failed to power on %s: %d.\n",
+   phy->dev->name, ret);
+   regulator_set_enable_if_allowed(counts->supply, false);
+   return ret;
+   }
}
counts->power_on_count = 1;
 
@@ -341,10 +340,6 @@ int generic_phy_power_off(struct phy *phy)
 
if (!generic_phy_valid(phy))
return 0;
-   ops = phy_dev_ops(phy->dev);
-   if (!ops->power_off)
-   return 0;
-
counts = phy_get_counts(phy);
if (counts->power_on_count == 0)
return 0;
@@ -353,11 +348,14 @@ int generic_phy_power_off(struct phy *phy)
return 0;
}
 
-   ret = ops->power_off(phy);
-   if (ret) {
-   dev_err(phy->dev, "PHY: Failed to power off %s: %d.\n",
-   phy->dev->name, ret);
-   return ret;
+   ops = phy_dev_ops(phy->dev);
+   if (ops->power_off) {
+   ret = ops->power_off(phy);
+   if (ret) {
+   dev_err(phy->dev, "PHY: Failed to power off %s: %d.\n",
+   phy->dev->name, ret);
+   return ret;
+   }
}
counts->power_on_count = 0;
 
-- 
2.34.1



[PATCH v5 5/6] phy: rockchip-inno-usb2: add initial support for rk3588 PHY

2023-04-19 Thread Eugen Hristev
Add initial support for the rk3588 PHY variant.
The lookup for the host-port reg inside the struct now does a do {} while()
instead of a while() {} in order to allow a first check for reg == 0.

Co-developed-by: Frank Wang 
Signed-off-by: Frank Wang 
Signed-off-by: Eugen Hristev 
---
 drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 60 ++-
 1 file changed, 58 insertions(+), 2 deletions(-)

diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c 
b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
index 55e1dbcfef7e..22e2797eea28 100644
--- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
+++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
@@ -201,14 +201,14 @@ static int rockchip_usb2phy_probe(struct udevice *dev)
 
/* find out a proper config which can be matched with dt. */
index = 0;
-   while (phy_cfgs[index].reg) {
+   do {
if (phy_cfgs[index].reg == reg) {
priv->phy_cfg = _cfgs[index];
break;
}
 
++index;
-   }
+   } while (phy_cfgs[index].reg);
 
if (!priv->phy_cfg) {
dev_err(dev, "failed find proper phy-cfg\n");
@@ -348,6 +348,58 @@ static const struct rockchip_usb2phy_cfg rk3568_phy_cfgs[] 
= {
{ /* sentinel */ }
 };
 
+static const struct rockchip_usb2phy_cfg rk3588_phy_cfgs[] = {
+   {
+   .reg= 0x,
+   .port_cfgs  = {
+   [USB2PHY_PORT_OTG] = {
+   .phy_sus= { 0x000c, 11, 11, 0, 1 },
+   .ls_det_en  = { 0x0080, 0, 0, 0, 1 },
+   .ls_det_st  = { 0x0084, 0, 0, 0, 1 },
+   .ls_det_clr = { 0x0088, 0, 0, 0, 1 },
+   .utmi_ls= { 0x00c0, 10, 9, 0, 1 },
+   }
+   },
+   },
+   {
+   .reg= 0x4000,
+   .port_cfgs  = {
+   [USB2PHY_PORT_OTG] = {
+   .phy_sus= { 0x000c, 11, 11, 0, 0 },
+   .ls_det_en  = { 0x0080, 0, 0, 0, 1 },
+   .ls_det_st  = { 0x0084, 0, 0, 0, 1 },
+   .ls_det_clr = { 0x0088, 0, 0, 0, 1 },
+   .utmi_ls= { 0x00c0, 10, 9, 0, 1 },
+   }
+   },
+   },
+   {
+   .reg= 0x8000,
+   .port_cfgs  = {
+   [USB2PHY_PORT_HOST] = {
+   .phy_sus= { 0x0008, 2, 2, 0, 1 },
+   .ls_det_en  = { 0x0080, 0, 0, 0, 1 },
+   .ls_det_st  = { 0x0084, 0, 0, 0, 1 },
+   .ls_det_clr = { 0x0088, 0, 0, 0, 1 },
+   .utmi_ls= { 0x00c0, 10, 9, 0, 1 },
+   }
+   },
+   },
+   {
+   .reg= 0xc000,
+   .port_cfgs  = {
+   [USB2PHY_PORT_HOST] = {
+   .phy_sus= { 0x0008, 2, 2, 0, 1 },
+   .ls_det_en  = { 0x0080, 0, 0, 0, 1 },
+   .ls_det_st  = { 0x0084, 0, 0, 0, 1 },
+   .ls_det_clr = { 0x0088, 0, 0, 0, 1 },
+   .utmi_ls= { 0x00c0, 10, 9, 0, 1 },
+   }
+   },
+   },
+   { /* sentinel */ }
+};
+
 static const struct udevice_id rockchip_usb2phy_ids[] = {
{
.compatible = "rockchip,rk3399-usb2phy",
@@ -357,6 +409,10 @@ static const struct udevice_id rockchip_usb2phy_ids[] = {
.compatible = "rockchip,rk3568-usb2phy",
.data = (ulong)_phy_cfgs,
},
+   {
+   .compatible = "rockchip,rk3588-usb2phy",
+   .data = (ulong)_phy_cfgs,
+   },
{ /* sentinel */ }
 };
 
-- 
2.34.1



[PATCH v5 3/6] phy: add support for phy-supply

2023-04-19 Thread Eugen Hristev
Some phys require a phy-supply property that is a phandle to a regulator
that needs to be enabled for phy operations.
Implement basic supply lookup, enable and disabling, if DM_REGULATOR is
available.

[jo...@kwiboo.se:
use regulator_set_enable_if_allowed and disable if power_on ops fails]
Signed-off-by: Jonas Karlman 
Signed-off-by: Eugen Hristev 
---
Changes in v5:
- add changes done by Jonas

 drivers/phy/phy-uclass.c | 51 +++-
 1 file changed, 40 insertions(+), 11 deletions(-)

diff --git a/drivers/phy/phy-uclass.c b/drivers/phy/phy-uclass.c
index 3fef5135a9cb..45ec1471d0ae 100644
--- a/drivers/phy/phy-uclass.c
+++ b/drivers/phy/phy-uclass.c
@@ -12,6 +12,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /**
  * struct phy_counts - Init and power-on counts of a single PHY port
@@ -29,12 +30,14 @@
  *  without a matching generic_phy_exit() afterwards
  * @list: Handle for a linked list of these structures corresponding to
  *ports of the same PHY provider
+ * @supply: Handle to a phy-supply device
  */
 struct phy_counts {
unsigned long id;
int power_on_count;
int init_count;
struct list_head list;
+   struct udevice *supply;
 };
 
 static inline struct phy_ops *phy_dev_ops(struct udevice *dev)
@@ -58,7 +61,7 @@ static struct phy_counts *phy_get_counts(struct phy *phy)
return NULL;
 }
 
-static int phy_alloc_counts(struct phy *phy)
+static int phy_alloc_counts(struct phy *phy, struct udevice *supply)
 {
struct list_head *uc_priv;
struct phy_counts *counts;
@@ -76,6 +79,7 @@ static int phy_alloc_counts(struct phy *phy)
counts->id = phy->id;
counts->power_on_count = 0;
counts->init_count = 0;
+   counts->supply = supply;
list_add(>list, uc_priv);
 
return 0;
@@ -123,7 +127,7 @@ int generic_phy_get_by_index_nodev(ofnode node, int index, 
struct phy *phy)
 {
struct ofnode_phandle_args args;
struct phy_ops *ops;
-   struct udevice *phydev;
+   struct udevice *phydev, *supply = NULL;
int i, ret;
 
debug("%s(node=%s, index=%d, phy=%p)\n",
@@ -172,7 +176,17 @@ int generic_phy_get_by_index_nodev(ofnode node, int index, 
struct phy *phy)
goto err;
}
 
-   ret = phy_alloc_counts(phy);
+   if (CONFIG_IS_ENABLED(DM_REGULATOR)) {
+   ret = device_get_supply_regulator(phydev, "phy-supply",
+ );
+   if (ret && ret != -ENOENT) {
+   debug("%s: device_get_supply_regulator failed: %d\n",
+ __func__, ret);
+   goto err;
+   }
+   }
+
+   ret = phy_alloc_counts(phy, supply);
if (ret) {
debug("phy_alloc_counts() failed: %d\n", ret);
goto err;
@@ -300,14 +314,23 @@ int generic_phy_power_on(struct phy *phy)
return 0;
}
 
+   ret = regulator_set_enable_if_allowed(counts->supply, true);
+   if (ret && ret != -ENOSYS) {
+   dev_err(phy->dev, "PHY: Failed to enable regulator %s: %d.\n",
+   counts->supply->name, ret);
+   return ret;
+   }
+
ret = ops->power_on(phy);
-   if (ret)
+   if (ret) {
dev_err(phy->dev, "PHY: Failed to power on %s: %d.\n",
phy->dev->name, ret);
-   else
-   counts->power_on_count = 1;
+   regulator_set_enable_if_allowed(counts->supply, false);
+   return ret;
+   }
+   counts->power_on_count = 1;
 
-   return ret;
+   return 0;
 }
 
 int generic_phy_power_off(struct phy *phy)
@@ -331,13 +354,19 @@ int generic_phy_power_off(struct phy *phy)
}
 
ret = ops->power_off(phy);
-   if (ret)
+   if (ret) {
dev_err(phy->dev, "PHY: Failed to power off %s: %d.\n",
phy->dev->name, ret);
-   else
-   counts->power_on_count = 0;
+   return ret;
+   }
+   counts->power_on_count = 0;
 
-   return ret;
+   ret = regulator_set_enable_if_allowed(counts->supply, false);
+   if (ret && ret != -ENOSYS)
+   dev_err(phy->dev, "PHY: Failed to disable regulator %s: %d.\n",
+   counts->supply->name, ret);
+
+   return 0;
 }
 
 int generic_phy_configure(struct phy *phy, void *params)
-- 
2.34.1



[PATCH v5 1/6] ARM: dts: rockchip: rk3588-rock-5b-u-boot: add USB 2.0 host

2023-04-19 Thread Eugen Hristev
Add USB 2.0 host nodes and PHYs.

Co-developed-by: William Wu 
Signed-off-by: William Wu 
Signed-off-by: Eugen Hristev 
---
Changes in v5:
- none

Changes in v4:
- removed u-boot,dm-spl on regulator which was useless
- moved usb nodes to rk3588s-u-boot-dtsi

Changes in v2,v3:
- none

 arch/arm/dts/rk3588-rock-5b-u-boot.dtsi | 82 +++
 arch/arm/dts/rk3588s-u-boot.dtsi| 86 +
 2 files changed, 168 insertions(+)

diff --git a/arch/arm/dts/rk3588-rock-5b-u-boot.dtsi 
b/arch/arm/dts/rk3588-rock-5b-u-boot.dtsi
index bee4c32e8965..93942b105c3d 100644
--- a/arch/arm/dts/rk3588-rock-5b-u-boot.dtsi
+++ b/arch/arm/dts/rk3588-rock-5b-u-boot.dtsi
@@ -4,6 +4,9 @@
  */
 
 #include "rk3588-u-boot.dtsi"
+#include 
+#include 
+#include 
 
 / {
aliases {
@@ -13,6 +16,18 @@
chosen {
u-boot,spl-boot-order = 
};
+
+   vcc5v0_host: vcc5v0-host-regulator {
+   compatible = "regulator-fixed";
+   regulator-name = "vcc5v0_host";
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   enable-active-high;
+   gpio = < RK_PB0 GPIO_ACTIVE_HIGH>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_host_en>;
+   vin-supply = <_sys>;
+   };
 };
 
  {
@@ -20,3 +35,70 @@
bootph-pre-ram;
status = "okay";
 };
+
+ {
+   usb {
+   vcc5v0_host_en: vcc5v0-host-en {
+   rockchip,pins = <4 RK_PB0 RK_FUNC_GPIO _pull_none>;
+   };
+   };
+};
+
+_host0_ehci {
+   companion = <_host0_ohci>;
+   phys = <_host>;
+   phy-names = "usb2-phy";
+   status = "okay";
+};
+
+_host0_ohci {
+   phys = <_host>;
+   phy-names = "usb2-phy";
+   status = "okay";
+};
+
+_grf {
+   status = "okay";
+};
+
+ {
+   resets = < SRST_OTGPHY_U2_0>, < SRST_P_USB2PHY_U2_0_GRF0>;
+   reset-names = "phy", "apb";
+   clock-output-names = "usb480m_phy2";
+   status = "okay";
+};
+
+_host {
+   phy-supply = <_host>;
+   status = "okay";
+};
+
+_host1_ehci {
+   companion = <_host1_ohci>;
+   phys = <_host>;
+   phy-names = "usb2-phy";
+   status = "okay";
+};
+
+_host1_ohci {
+   phys = <_host>;
+   phy-names = "usb2-phy";
+   status = "okay";
+};
+
+_grf {
+   status = "okay";
+};
+
+ {
+   resets = < SRST_OTGPHY_U2_1>, < SRST_P_USB2PHY_U2_1_GRF0>;
+   reset-names = "phy", "apb";
+   clock-output-names = "usb480m_phy3";
+   status = "okay";
+};
+
+_host {
+   phy-supply = <_host>;
+   status = "okay";
+};
+
diff --git a/arch/arm/dts/rk3588s-u-boot.dtsi b/arch/arm/dts/rk3588s-u-boot.dtsi
index 1e225d71efc2..fb1b802fd273 100644
--- a/arch/arm/dts/rk3588s-u-boot.dtsi
+++ b/arch/arm/dts/rk3588s-u-boot.dtsi
@@ -12,12 +12,98 @@
status = "okay";
};
 
+   usb_host0_ehci: usb@fc80 {
+   compatible = "generic-ehci";
+   reg = <0x0 0xfc80 0x0 0x4>;
+   interrupts = ;
+   clocks = < HCLK_HOST0>, < HCLK_HOST_ARB0>;
+   clock-names = "usbhost", "arbiter";
+   power-domains = < RK3588_PD_USB>;
+   status = "disabled";
+   };
+
+   usb_host0_ohci: usb@fc84 {
+   compatible = "generic-ohci";
+   reg = <0x0 0xfc84 0x0 0x4>;
+   interrupts = ;
+   clocks = < HCLK_HOST0>, < HCLK_HOST_ARB0>;
+   clock-names = "usbhost", "arbiter";
+   power-domains = < RK3588_PD_USB>;
+   status = "disabled";
+   };
+
+   usb_host1_ehci: usb@fc88 {
+   compatible = "generic-ehci";
+   reg = <0x0 0xfc88 0x0 0x4>;
+   interrupts = ;
+   clocks = < HCLK_HOST1>, < HCLK_HOST_ARB1>;
+   clock-names = "usbhost", "arbiter";
+   power-domains = < RK3588_PD_USB>;
+   status = "disabled";
+   };
+
+   usb_host1_ohci: usb@fc8c {
+   compatible = "generic-ohci";
+   reg = <0x0 0xfc8c 0x0 0x4>;
+   interrupts = ;
+   clocks = < HCLK_HOST1>, < HCLK_HOST_ARB1>;
+   clock-names = "usbhost", "arbiter";
+   power-domains = < RK3588_PD_USB>;
+   status = "disabled";
+   };
+
pmu1_grf: syscon@fd58a000 {
bootph-all;
compatible = "rockchip,rk3588-pmu1-grf", "syscon";
reg = <0x0 0xfd58a000 0x0 0x2000>;
};
 
+   usb2phy2_grf: syscon@fd5d8000 {
+   compatible = "rockchip,rk3588-usb2phy-grf", "syscon",
+"simple-mfd";
+   reg = <0x0 0xfd5d8000 0x0 0x4000>;
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   u2phy2: usb2-phy@8000 {
+   

[PATCH v5 2/6] configs: rockchip: rock5b-rk3588: enable USB and regulators

2023-04-19 Thread Eugen Hristev
Enable USB command, USB drivers, PHY and regulators, for USB host
operations.

Signed-off-by: Eugen Hristev 
---
 configs/rock5b-rk3588_defconfig | 17 +
 1 file changed, 17 insertions(+)

diff --git a/configs/rock5b-rk3588_defconfig b/configs/rock5b-rk3588_defconfig
index f3026c7ea166..8d76c1eb4d42 100644
--- a/configs/rock5b-rk3588_defconfig
+++ b/configs/rock5b-rk3588_defconfig
@@ -41,7 +41,9 @@ CONFIG_SPL_STACK_R=y
 CONFIG_SPL_ATF=y
 CONFIG_CMD_GPT=y
 CONFIG_CMD_MMC=y
+CONFIG_CMD_USB=y
 # CONFIG_CMD_SETEXPR is not set
+CONFIG_CMD_REGULATOR=y
 # CONFIG_SPL_DOS_PARTITION is not set
 CONFIG_SPL_OF_CONTROL=y
 CONFIG_OF_LIVE=y
@@ -61,7 +63,9 @@ CONFIG_MMC_SDHCI_SDMA=y
 CONFIG_MMC_SDHCI_ROCKCHIP=y
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_GMAC_ROCKCHIP=y
+CONFIG_PHY_ROCKCHIP_INNO_USB2=y
 CONFIG_REGULATOR_PWM=y
+CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_PWM_ROCKCHIP=y
 CONFIG_SPL_RAM=y
 CONFIG_BAUDRATE=150
@@ -69,4 +73,17 @@ CONFIG_DEBUG_UART_SHIFT=2
 CONFIG_DEBUG_UART_ANNOUNCE=y
 CONFIG_SYSRESET=y
 # CONFIG_BINMAN_FDT is not set
+CONFIG_USB=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_EHCI_GENERIC=y
+CONFIG_USB_OHCI_HCD=y
+CONFIG_USB_OHCI_GENERIC=y
+CONFIG_USB_HOST_ETHER=y
+CONFIG_USB_ETHER_ASIX=y
+CONFIG_USB_ETHER_ASIX88179=y
+CONFIG_USB_ETHER_LAN75XX=y
+CONFIG_USB_ETHER_LAN78XX=y
+CONFIG_USB_ETHER_MCS7830=y
+CONFIG_USB_ETHER_RTL8152=y
+CONFIG_USB_ETHER_SMSC95XX=y
 CONFIG_ERRNO_STR=y
-- 
2.34.1



Re: [PATCH v2] nand: brcmnand: add iproc support

2023-04-19 Thread Dario Binacchi
Hi Linus,

On Wed, Apr 19, 2023 at 3:04 PM Linus Walleij  wrote:
>
> On Mon, Apr 17, 2023 at 10:37 AM Dario Binacchi
>  wrote:
>
> > Applied to nand-next ( as well as the patch "mtd: rawnand: nand_base:
> > Handle algorithm selection").
>
> 1) Sweet! Thanks.
>
> 2) Did you use the latest versions that I resent as part of the
> NorthStar support?

I applied v2:
https://patchwork.ozlabs.org/project/uboot/patch/20230308214231.378013-1-linus.wall...@linaro.org/
https://patchwork.ozlabs.org/project/uboot/patch/20230308212851.370939-1-linus.wall...@linaro.org/

Thanks and regards,
Dario

>
> https://lore.kernel.org/u-boot/20230407134008.1939717-2-linus.wall...@linaro.org/
> https://lore.kernel.org/u-boot/20230407134008.1939717-3-linus.wall...@linaro.org/
>
> Otherwise please use these versions instead, because the second
> patch needed some fixing for Tom's system. Thanks a lot!
>
> Yours,
> Linus Walleij



-- 

Dario Binacchi

Senior Embedded Linux Developer

dario.binac...@amarulasolutions.com

__


Amarula Solutions SRL

Via Le Canevare 30, 31100 Treviso, Veneto, IT

T. +39 042 243 5310
i...@amarulasolutions.com

www.amarulasolutions.com


Re: [PATCH v2] nand: brcmnand: add iproc support

2023-04-19 Thread Linus Walleij
On Mon, Apr 17, 2023 at 10:37 AM Dario Binacchi
 wrote:

> Applied to nand-next ( as well as the patch "mtd: rawnand: nand_base:
> Handle algorithm selection").

1) Sweet! Thanks.

2) Did you use the latest versions that I resent as part of the
NorthStar support?

https://lore.kernel.org/u-boot/20230407134008.1939717-2-linus.wall...@linaro.org/
https://lore.kernel.org/u-boot/20230407134008.1939717-3-linus.wall...@linaro.org/

Otherwise please use these versions instead, because the second
patch needed some fixing for Tom's system. Thanks a lot!

Yours,
Linus Walleij


Re: [RFC] riscv: visionfive2: use OF_BOARD_SETUP

2023-04-19 Thread Matthias Brugger




On 19/04/2023 13:28, Torsten Duwe wrote:

U-Boot already has a mechanism to fix up the DT before OS boot.
This avoids the excessive duplication of data and work proposed
by the explicit separation of 1.2a and 1.3b board revisions. It
will also, to a good degree, improve the user experience, as
pointed out by Matthias.

The defconfig changes required (in diffconfig format) are

-I2C n
-NET_RANDOM_ETHADDR y
+CMD_I2C y
+CMD_MISC y
+DM_I2C y
+I2C_EEPROM y
+MISC y
+MISC_INIT_R y
+OF_BOARD_SETUP y
+SPL_DM_I2C n
+SPL_MISC n
+SYS_I2C_DW y
+SYS_I2C_EEPROM_ADDR 0x0

along with the patch below. It has the neat side effect of providing
the network with the proper MAC addresses ;)

I take advantage of the fact that I²C-5 is also required to talk to the
PMIC, so it must already be initialised by OpenSBI. All that's required
is to declare the EEPROM and to pull in the drivers.

This is only a proof of concept; let me know if you like it and I can
add the other 12 DT patches to adjust_for_rev13b(), or maybe start with
1.3b as the default and go the other way, or something in between.

The last hunk, to the i2c Makefile, is IMHO an independent fix, because
the implication PCI => ACPI in designware_i2c_pci is invalid, and the
VisionFive2 config proves it. Use this quick hack for now.



Looks like a neat approach to enable a signle U-Boot binary to boot on both 
platforms.


Thanks for investigating this.


Signed-off-by: Torsten Duwe 

---
diff --git a/arch/riscv/dts/jh7110-starfive-visionfive-2.dtsi 
b/arch/riscv/dts/jh7110-starfive-visionfive-2.dtsi
index ff9df56ec2..fd3a1d057a 100644
--- a/arch/riscv/dts/jh7110-starfive-visionfive-2.dtsi
+++ b/arch/riscv/dts/jh7110-starfive-visionfive-2.dtsi
@@ -119,6 +119,12 @@
pinctrl-names = "default";
pinctrl-0 = <_pins>;
status = "okay";
+
+   eeprom@50 {
+   compatible = "atmel,24c04";
+   reg = <0x50>;
+   pagesize = <0x10>;
+   };
  };
  
   {

diff --git a/board/starfive/visionfive2/starfive_visionfive2.c 
b/board/starfive/visionfive2/starfive_visionfive2.c
index 613fe793c4..d7f846a357 100644
--- a/board/starfive/visionfive2/starfive_visionfive2.c
+++ b/board/starfive/visionfive2/starfive_visionfive2.c
@@ -7,6 +7,10 @@
  #include 
  #include 
  #include 
+#include 
+#include 
+#include 
+#include 
  #include 
  
  #define JH7110_L2_PREFETCHER_BASE_ADDR		0x203

@@ -38,3 +42,62 @@ int board_init(void)
  
  	return 0;

  }
+
+#ifdef CONFIG_MISC_INIT_R


As this is will be enabled for the board config I think we don't need the 
ifedef.


+int misc_init_r(void)
+{
+   int ret = 0;
+
+#ifdef CONFIG_I2C_EEPROM
+   struct udevice *dev;
+   char mac_addr[6];
+   unsigned char pcb_rev, BOM;
+
+   ret = uclass_first_device_err(UCLASS_I2C_EEPROM, );
+   if (ret)
+   goto out;
+
+   if (eth_env_get_enetaddr("ethaddr", mac_addr) == 0) {
+   int i;
+   for (i=0; i<2; i++) {
+   ret = i2c_eeprom_read(dev, 0x78+6*i, mac_addr, 6);
+   if (!ret && is_valid_ethaddr(mac_addr))
+   eth_env_set_enetaddr_by_index("eth", i, 
mac_addr);
+   }
+   }
+
+   ret = i2c_eeprom_read(dev, 0x76, _rev, 1);
+   if (!ret)
+   env_set_hex("board_revision", pcb_rev);
+
+   ret = i2c_eeprom_read(dev, 0x77, , 1);
+
+   out:
+#endif
+return ret;
+}
+#endif
+
+#ifdef CONFIG_OF_BOARD_SETUP


Same here.

Regards,
Matthias


+static void adjust_for_rev13b(void * fdt)
+{
+   do_fixup_by_path(fdt, "/soc/ethernet@1604",
+"phy-mode", "rgmii-id", 9, 0);
+   /*
+  ... other fixups ...
+
+*/
+}
+
+int ft_board_setup(void *fdt, struct bd_info *bdip)
+{
+   unsigned char pcb_rev = 0;
+
+   pcb_rev = env_get_hex("board_revision", pcb_rev);
+   if (pcb_rev >= 0xB2) {
+   printf("Adjusting FDT for v1.3B board rev\n");
+   adjust_for_rev13b(fdt);
+   }
+   return 0;
+}
+#endif
diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
index 99545df2e5..828856e40d 100644
--- a/drivers/i2c/Makefile
+++ b/drivers/i2c/Makefile
@@ -19,8 +19,10 @@ obj-$(CONFIG_SYS_I2C_CA) += i2c-cortina.o
  obj-$(CONFIG_SYS_I2C_DAVINCI) += davinci_i2c.o
  obj-$(CONFIG_SYS_I2C_DW) += designware_i2c.o
  ifdef CONFIG_PCI
+ifdef CONFIG_ACPIGEN
  obj-$(CONFIG_SYS_I2C_DW) += designware_i2c_pci.o
  endif
+endif
  obj-$(CONFIG_SYS_I2C_FSL) += fsl_i2c.o
  obj-$(CONFIG_SYS_I2C_IHS) += ihs_i2c.o
  obj-$(CONFIG_SYS_I2C_INTEL) += intel_i2c.o


[RFC] riscv: visionfive2: use OF_BOARD_SETUP

2023-04-19 Thread Torsten Duwe
U-Boot already has a mechanism to fix up the DT before OS boot.
This avoids the excessive duplication of data and work proposed
by the explicit separation of 1.2a and 1.3b board revisions. It
will also, to a good degree, improve the user experience, as
pointed out by Matthias.

The defconfig changes required (in diffconfig format) are

-I2C n
-NET_RANDOM_ETHADDR y
+CMD_I2C y
+CMD_MISC y
+DM_I2C y
+I2C_EEPROM y
+MISC y
+MISC_INIT_R y
+OF_BOARD_SETUP y
+SPL_DM_I2C n
+SPL_MISC n
+SYS_I2C_DW y
+SYS_I2C_EEPROM_ADDR 0x0

along with the patch below. It has the neat side effect of providing
the network with the proper MAC addresses ;)

I take advantage of the fact that I²C-5 is also required to talk to the
PMIC, so it must already be initialised by OpenSBI. All that's required
is to declare the EEPROM and to pull in the drivers.

This is only a proof of concept; let me know if you like it and I can
add the other 12 DT patches to adjust_for_rev13b(), or maybe start with
1.3b as the default and go the other way, or something in between.

The last hunk, to the i2c Makefile, is IMHO an independent fix, because
the implication PCI => ACPI in designware_i2c_pci is invalid, and the
VisionFive2 config proves it. Use this quick hack for now.

Signed-off-by: Torsten Duwe 

---
diff --git a/arch/riscv/dts/jh7110-starfive-visionfive-2.dtsi 
b/arch/riscv/dts/jh7110-starfive-visionfive-2.dtsi
index ff9df56ec2..fd3a1d057a 100644
--- a/arch/riscv/dts/jh7110-starfive-visionfive-2.dtsi
+++ b/arch/riscv/dts/jh7110-starfive-visionfive-2.dtsi
@@ -119,6 +119,12 @@
pinctrl-names = "default";
pinctrl-0 = <_pins>;
status = "okay";
+
+   eeprom@50 {
+   compatible = "atmel,24c04";
+   reg = <0x50>;
+   pagesize = <0x10>;
+   };
 };
 
  {
diff --git a/board/starfive/visionfive2/starfive_visionfive2.c 
b/board/starfive/visionfive2/starfive_visionfive2.c
index 613fe793c4..d7f846a357 100644
--- a/board/starfive/visionfive2/starfive_visionfive2.c
+++ b/board/starfive/visionfive2/starfive_visionfive2.c
@@ -7,6 +7,10 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
 #include 
 
 #define JH7110_L2_PREFETCHER_BASE_ADDR 0x203
@@ -38,3 +42,62 @@ int board_init(void)
 
return 0;
 }
+
+#ifdef CONFIG_MISC_INIT_R
+int misc_init_r(void)
+{
+   int ret = 0;
+
+#ifdef CONFIG_I2C_EEPROM
+   struct udevice *dev;
+   char mac_addr[6];
+   unsigned char pcb_rev, BOM;
+
+   ret = uclass_first_device_err(UCLASS_I2C_EEPROM, );
+   if (ret)
+   goto out;
+
+   if (eth_env_get_enetaddr("ethaddr", mac_addr) == 0) {
+   int i;
+   for (i=0; i<2; i++) {
+   ret = i2c_eeprom_read(dev, 0x78+6*i, mac_addr, 6);
+   if (!ret && is_valid_ethaddr(mac_addr))
+   eth_env_set_enetaddr_by_index("eth", i, 
mac_addr);
+   }
+   }
+
+   ret = i2c_eeprom_read(dev, 0x76, _rev, 1);
+   if (!ret)
+   env_set_hex("board_revision", pcb_rev);
+
+   ret = i2c_eeprom_read(dev, 0x77, , 1);
+
+   out:
+#endif
+return ret;
+}
+#endif
+
+#ifdef CONFIG_OF_BOARD_SETUP
+static void adjust_for_rev13b(void * fdt)
+{
+   do_fixup_by_path(fdt, "/soc/ethernet@1604",
+"phy-mode", "rgmii-id", 9, 0);
+   /*
+  ... other fixups ...
+
+*/
+}
+
+int ft_board_setup(void *fdt, struct bd_info *bdip)
+{
+   unsigned char pcb_rev = 0;
+
+   pcb_rev = env_get_hex("board_revision", pcb_rev);
+   if (pcb_rev >= 0xB2) {
+   printf("Adjusting FDT for v1.3B board rev\n");
+   adjust_for_rev13b(fdt);
+   }
+   return 0;
+}
+#endif
diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
index 99545df2e5..828856e40d 100644
--- a/drivers/i2c/Makefile
+++ b/drivers/i2c/Makefile
@@ -19,8 +19,10 @@ obj-$(CONFIG_SYS_I2C_CA) += i2c-cortina.o
 obj-$(CONFIG_SYS_I2C_DAVINCI) += davinci_i2c.o
 obj-$(CONFIG_SYS_I2C_DW) += designware_i2c.o
 ifdef CONFIG_PCI
+ifdef CONFIG_ACPIGEN
 obj-$(CONFIG_SYS_I2C_DW) += designware_i2c_pci.o
 endif
+endif
 obj-$(CONFIG_SYS_I2C_FSL) += fsl_i2c.o
 obj-$(CONFIG_SYS_I2C_IHS) += ihs_i2c.o
 obj-$(CONFIG_SYS_I2C_INTEL) += intel_i2c.o


[PATCH] gpio-uclass: fix off-by-one in gpio_request_list_by_name_nodev()

2023-04-19 Thread Rasmus Villemoes
By the time we jump to the err label, count represents the number of
gpios we've succesfully requested. So by subtracting one, we fail to
free the most recently requested.

Signed-off-by: Rasmus Villemoes 
---
 drivers/gpio/gpio-uclass.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
index c8be5a4d66..712119c341 100644
--- a/drivers/gpio/gpio-uclass.c
+++ b/drivers/gpio/gpio-uclass.c
@@ -1219,7 +1219,7 @@ int gpio_request_list_by_name_nodev(ofnode node, const 
char *list_name,
return count;
 
 err:
-   gpio_free_list_nodev(desc, count - 1);
+   gpio_free_list_nodev(desc, count);
 
return ret;
 }
-- 
2.37.2



[PULL] Pull request for u-boot master / v2023.07 = u-boot-stm32_20230409​

2023-04-19 Thread Patrice CHOTARD
Hi Tom

Please pull the STM32 related fixes for u-boot/master, v2023.07: 
u-boot-stm32-20230419

CI status: https://source.denx.de/u-boot/custodians/u-boot-stm/-/pipelines/16033

The following changes since commit 5db4972a5bbdbf9e3af48ffc9bc4fec73b7b6a79:

  Merge tag 'u-boot-nand-20230417' of 
https://source.denx.de/u-boot/custodians/u-boot-nand-flash (2023-04-17 10:47:33 
-0400)

are available in the Git repository at:

  https://source.denx.de/u-boot/custodians/u-boot-stm.git 
tags/u-boot-stm32-20230419

for you to fetch changes up to 0d5bd362f61dd3dc54f9a32fd38541b8d5c5d869:

  configs: stm32mp15: set CONFIG_USB_HUB_DEBOUNCE_TIMEOUT=2s (2023-04-19 
10:10:17 +0200)


configs:
_ Add usb_pgood_delay for ST boards
_ increase malloc size for pre-reloc for stm32mp15
_ Set CONFIG_USB_HUB_DEBOUNCE_TIMEOUT=2s for stm32mp15

dts:
_ Add QSPI support on STM32MP13x SoC family
_ Add FMC support on STM32MP13x SoC family

drivers/machine:
_ pinctrl_stm32: Add slew rate support for stm32_pinctrl_get_pin_muxing()
_ spi: stm32_qspi: Remove useless struct stm32_qspi_flash
_ rawnand: stm32_fmc2: remove unsupported EDO mode
_ stm32mp: fix various array bounds checks


Christophe Kerello (2):
  ARM: dts: stm32: add FMC support on STM32MP13x SoC family
  mtd: rawnand: stm32_fmc2: remove unsupported EDO mode

Patrice Chotard (5):
  configs: stm32mp15: Add usb_pgood_delay for ST boards
  configs: stm32mp13: Increase usb_pgood_delay for ST boards
  pinctrl: pinctrl_stm32: Add slew rate support for 
stm32_pinctrl_get_pin_muxing()
  ARM: dts: stm32: Add QSPI support on STM32MP13x SoC family
  spi: stm32_qspi: Remove useless struct stm32_qspi_flash

Patrick Delaunay (2):
  configs: stm32mp15: increase malloc size for pre-reloc
  configs: stm32mp15: set CONFIG_USB_HUB_DEBOUNCE_TIMEOUT=2s

Rasmus Villemoes (1):
  stm32mp: fix various array bounds checks

 arch/arm/dts/stm32mp131.dtsi| 48 

 arch/arm/mach-stm32mp/cpu.c |  4 ++--
 board/st/stm32mp1/stm32mp1.c|  2 +-
 configs/stm32mp15_basic_defconfig   |  1 +
 configs/stm32mp15_defconfig |  3 ++-
 configs/stm32mp15_trusted_defconfig |  1 +
 drivers/mtd/nand/raw/stm32_fmc2_nand.c  |  3 +++
 drivers/pinctrl/pinctrl_stm32.c | 19 +++
 drivers/ram/stm32mp1/stm32mp1_interactive.c |  2 +-
 drivers/spi/stm32_qspi.c| 27 +++
 include/configs/stm32mp13_st_common.h   |  2 +-
 include/configs/stm32mp15_st_common.h   |  1 +
 12 files changed, 79 insertions(+), 34 deletions(-)


Re: [PATCH 1/6] misc: add Qualcomm GENI SE QUP device driver

2023-04-19 Thread Vladimir Zapolskiy

Hi Simon,

On 4/19/23 04:45, Simon Glass wrote:

Hi Vladimir,

On Wed, 12 Apr 2023 at 06:45, Vladimir Zapolskiy
 wrote:


On 3/31/23 04:23, Konrad Dybcio wrote:



On 30.03.2023 21:47, Vladimir Zapolskiy wrote:

This change adds a Qualcomm GENI SE QUP device driver as a wrapper for
actually enabled and used serial devices found on a board.

At the moment the driver is pretty simple, its intention is to populate
childred devices and provide I/O mem read interface to them as clients,
this is needed for GENI UART driver to set up a proper clock divider
and provide the actually asked baud rate.

Signed-off-by: Vladimir Zapolskiy 
---
   drivers/misc/Kconfig|  6 ++
   drivers/misc/Makefile   |  1 +
   drivers/misc/qcom-geni-se.c | 42 +
   3 files changed, 49 insertions(+)
   create mode 100644 drivers/misc/qcom-geni-se.c

diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index b5707a15c504..348e1ab407ad 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -511,6 +511,12 @@ config WINBOND_W83627
legacy UART or other devices in the Winbond Super IO chips
on X86 platforms.

+config QCOM_GENI_SE
+bool "Qualcomm GENI Serial Engine Driver"
+help
+  The driver manages Generic Interface (GENI) firmware based
+  Qualcomm Technologies, Inc. Universal Peripheral (QUP) Wrapper.
+
   config QFW
  bool
  help
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 3b792f2a14ce..52aed096021f 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -60,6 +60,7 @@ obj-$(CONFIG_NUVOTON_NCT6102D) += nuvoton_nct6102d.o
   obj-$(CONFIG_P2SB) += p2sb-uclass.o
   obj-$(CONFIG_PCA9551_LED) += pca9551_led.o
   obj-$(CONFIG_$(SPL_)PWRSEQ) += pwrseq-uclass.o
+obj-$(CONFIG_QCOM_GENI_SE) += qcom-geni-se.o
   ifdef CONFIG_QFW
   obj-y += qfw.o
   obj-$(CONFIG_QFW_PIO) += qfw_pio.o
diff --git a/drivers/misc/qcom-geni-se.c b/drivers/misc/qcom-geni-se.c
new file mode 100644
index ..4f1775b11f62
--- /dev/null
+++ b/drivers/misc/qcom-geni-se.c
@@ -0,0 +1,42 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Qualcomm Generic Interface (GENI) Serial Engine (SE) Wrapper
+ *
+ * (C) Copyright 2023 Vladimir Zapolskiy 
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+static int geni_se_qup_read(struct udevice *dev, int offset,
+void *buf, int size)
+{
+fdt_addr_t base = dev_read_addr(dev);
+
+if (size != sizeof(u32))
+return -EINVAL;
+
+*(u32 *)buf = readl(base + offset);

Maybe

u32 *buffer = buf;

[...]

*buf = readl..


Well, I'd rather keep it as is, since it's one code of line less.


would be more stylish, but that's a nit and I don't have
any other complaints! :D


In fact there is a minor issue with the driver, namely after some
testing I have to remove '.bind = dm_scan_fdt_dev' from the ops,
since it's already done on an upper level.


Reviewed-by: Konrad Dybcio 



Thanks for review!

Best wishes,
Vladimir


+
+return 0;
+}
+
+static struct misc_ops geni_se_qup_ops = {
+.read = geni_se_qup_read,
+};
+
+static const struct udevice_id geni_se_qup_ids[] = {
+{ .compatible = "qcom,geni-se-qup" },
+{}
+};
+
+U_BOOT_DRIVER(geni_se_qup) = {
+.name = "geni_se_qup",
+.id = UCLASS_MISC,
+.of_match = geni_se_qup_ids,
+.bind = dm_scan_fdt_dev,
+.ops = _se_qup_ops,
+.flags  = DM_FLAG_PRE_RELOC,
+};


Please note that misc_read() should return the number of bytes read, not 0.


oh, definitely this should be fixed, and consequently it requires v3 to be sent.

Thank you for review!

--
Best wishes,
Vladimir


Re: [PATCH] spi: stm32_qspi: Remove useless struct stm32_qspi_flash

2023-04-19 Thread Patrice CHOTARD



On 4/17/23 17:32, Patrick DELAUNAY wrote:
> Hi,
> 
> On 4/3/23 08:04, Patrice Chotard wrote:
>> Currently, in stm32_qspi_claim_bus(), QSPI_CR and QSPI_DCR registers
>> are saved in stm32_ospi_flash struct on first flash memory initialization
>> and restored on each flash accesses.
>>
>> As the logic of spi-uclass.c changed since 'commit 741280e9accd
>> ("spi: spi-uclass: Fix spi_claim_bus() speed/mode setup logic")'
>> set_speed() and set_mode() callbacks are called systematically when bus
>> speed or bus mode need to be updated, QSPI_CR and QSPI_DCR registers are
>> set accordingly.
>>
>> So stm32_qspi_claim_bus() can be updated by removing QSPI_CR and QSPI_DCR
>> save/restore code and struct stm32_ospi_flash can be removed as well.
>>
>> Signed-off-by: Patrice Chotard 
>> ---
>>
>>   drivers/spi/stm32_qspi.c | 27 +++
>>   1 file changed, 3 insertions(+), 24 deletions(-)
>>
> 
> 
> Reviewed-by: Patrick Delaunay 
> 
> Thanks
> Patrick
> 
> 


Applied on u-boot-stm/master, thanks

Patrice


Re: [PATCH] ARM: dts: stm32: Add QSPI support on STM32MP13x SoC family

2023-04-19 Thread Patrice CHOTARD



On 4/3/23 09:45, Patrick DELAUNAY wrote:
> Hi,
> 
> On 4/3/23 08:04, Patrice Chotard wrote:
>> Add QSPI support on STM32MP13x SoC family
>>
>> Signed-off-by: Patrice Chotard 
>> ---
>>
>>   arch/arm/dts/stm32mp131.dtsi | 15 +++
>>   1 file changed, 15 insertions(+)
>>
>> diff --git a/arch/arm/dts/stm32mp131.dtsi b/arch/arm/dts/stm32mp131.dtsi
>> index 3cf51f09bcb..5a064d5566e 100644
>> --- a/arch/arm/dts/stm32mp131.dtsi
>> +++ b/arch/arm/dts/stm32mp131.dtsi
>> @@ -191,6 +191,21 @@
>>   dma-requests = <48>;
>>   };
>>   +    qspi: spi@58003000 {
>> +    compatible = "st,stm32f469-qspi";
>> +    reg = <0x58003000 0x1000>, <0x7000 0x1000>;
>> +    reg-names = "qspi", "qspi_mm";
>> +    #address-cells = <1>;
>> +    #size-cells = <0>;
>> +    interrupts = ;
>> +    dmas = < 26 0x2 0x1012 0x0 0x0>,
>> +   < 26 0x2 0x1018 0x0 0x0>;
>> +    dma-names = "tx", "rx";
>> +    clocks = < QSPI_K>;
>> +    resets = < QSPI_R>;
>> +    status = "disabled";
>> +    };
>> +
>>   sdmmc1: mmc@58005000 {
>>   compatible = "st,stm32-sdmmc2", "arm,pl18x", "arm,primecell";
>>   arm,primecell-periphid = <0x20253180>;
> 
> 
> 
> Reviewed-by: Patrick Delaunay 
> 
> Thanks
> Patrick
> 
> 
> 
> 

Applied on u-boot-stm/master, thanks

Patrice


[PATCH v2 3/3] firmware: zynqmp: Remove extraordinary return value

2023-04-19 Thread Stefan Herbrechtsmeier
From: Stefan Herbrechtsmeier 

Return a common -EACCES error value instead of a positive private error
value XST_PM_NO_ACCESS (2002) in zynqmp_pmufw_load_config_object
function if the config object is not loadable to simplify the error
checking.

Signed-off-by: Stefan Herbrechtsmeier 
---

Changes in v2:
- Use macro for node id

 drivers/firmware/firmware-zynqmp.c | 9 +++--
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/firmware/firmware-zynqmp.c 
b/drivers/firmware/firmware-zynqmp.c
index e763c639f7..7be4420a23 100644
--- a/drivers/firmware/firmware-zynqmp.c
+++ b/drivers/firmware/firmware-zynqmp.c
@@ -83,7 +83,7 @@ int zynqmp_pmufw_node(u32 id)
ret = zynqmp_pmufw_load_config_object(xpm_configobject,
  sizeof(xpm_configobject));

-   if (ret == XST_PM_NO_ACCESS && id == PMUFW_CFG_OBJ_SUPPORT_NODE)
+   if (ret == -EACCES && id == PMUFW_CFG_OBJ_SUPPORT_NODE)
skip_config = true;

return 0;
@@ -236,8 +236,7 @@ int zynqmp_pm_is_function_supported(const u32 api_id, const 
u32 id)
  *
  * @cfg_obj: Pointer to the configuration object
  * @size:Size of @cfg_obj in bytes
- * Return:   0 on success otherwise negative errno. If the config object
- *   is not loadable returns positive errno XST_PM_NO_ACCESS(2002)
+ * Return:   0 on success otherwise negative errno.
  */
 int zynqmp_pmufw_load_config_object(const void *cfg_obj, size_t size)
 {
@@ -254,10 +253,8 @@ int zynqmp_pmufw_load_config_object(const void *cfg_obj, 
size_t size)
if (err == XST_PM_NO_ACCESS) {
u32 id = ((u32 *)cfg_obj)[NODE_ID_LOCATION];

-   if (id != PMUFW_CFG_OBJ_SUPPORT_NODE) {
+   if (id != PMUFW_CFG_OBJ_SUPPORT_NODE)
printf("PMUFW:  No permission to change config 
object\n");
-   return err;
-   }
return -EACCES;
}

--
2.30.2


Kommanditgesellschaft - Sitz: Detmold - Amtsgericht Lemgo HRA 2790 -
Komplementärin: Weidmüller Interface Führungsgesellschaft mbH -
Sitz: Detmold - Amtsgericht Lemgo HRB 3924;
Geschäftsführer: Dr. Timo Berger, Volker Bibelhausen, Dr. Sebastian Durst, 
André Sombecki;
USt-ID-Nr. DE124599660


[PATCH v2 2/3] firmware: zynqmp: Mask expected and show unexpected warning

2023-04-19 Thread Stefan Herbrechtsmeier
From: Stefan Herbrechtsmeier 

Mask the expected and show the unexpected warning "No permission to
change config object" for PMUFW_CFG_OBJ_SUPPORT_NODE because this node
is used to detect if further zynqmp_pmufw_node function calls should be
skipped.

Signed-off-by: Stefan Herbrechtsmeier 

---

Changes in v2:
- Use macro for node id

 drivers/firmware/firmware-zynqmp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/firmware/firmware-zynqmp.c 
b/drivers/firmware/firmware-zynqmp.c
index baf5b0c253..e763c639f7 100644
--- a/drivers/firmware/firmware-zynqmp.c
+++ b/drivers/firmware/firmware-zynqmp.c
@@ -254,7 +254,7 @@ int zynqmp_pmufw_load_config_object(const void *cfg_obj, 
size_t size)
if (err == XST_PM_NO_ACCESS) {
u32 id = ((u32 *)cfg_obj)[NODE_ID_LOCATION];

-   if (id == PMUFW_CFG_OBJ_SUPPORT_NODE) {
+   if (id != PMUFW_CFG_OBJ_SUPPORT_NODE) {
printf("PMUFW:  No permission to change config 
object\n");
return err;
}
--
2.30.2


Kommanditgesellschaft - Sitz: Detmold - Amtsgericht Lemgo HRA 2790 -
Komplementärin: Weidmüller Interface Führungsgesellschaft mbH -
Sitz: Detmold - Amtsgericht Lemgo HRB 3924;
Geschäftsführer: Dr. Timo Berger, Volker Bibelhausen, Dr. Sebastian Durst, 
André Sombecki;
USt-ID-Nr. DE124599660


[PATCH v2 1/3] firmware: zynqmp: Add config object support macro

2023-04-19 Thread Stefan Herbrechtsmeier
From: Stefan Herbrechtsmeier 

The driver uses a specific node id to detect if the pmufw support config
objects. Add a macro for the node id to ensure that it match at
different locations.

Signed-off-by: Stefan Herbrechtsmeier 

---

Changes in v2:
- Added

 drivers/firmware/firmware-zynqmp.c | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/firmware/firmware-zynqmp.c 
b/drivers/firmware/firmware-zynqmp.c
index dc8e3ad2b9..baf5b0c253 100644
--- a/drivers/firmware/firmware-zynqmp.c
+++ b/drivers/firmware/firmware-zynqmp.c
@@ -19,6 +19,7 @@
 #include 

 #define PMUFW_PAYLOAD_ARG_CNT  8
+#define PMUFW_CFG_OBJ_SUPPORT_NODE NODE_OCM_BANK_0

 #define XST_PM_NO_ACCESS   2002L
 #define XST_PM_ALREADY_CONFIGURED  2009L
@@ -82,7 +83,7 @@ int zynqmp_pmufw_node(u32 id)
ret = zynqmp_pmufw_load_config_object(xpm_configobject,
  sizeof(xpm_configobject));

-   if (ret == XST_PM_NO_ACCESS && id == NODE_OCM_BANK_0)
+   if (ret == XST_PM_NO_ACCESS && id == PMUFW_CFG_OBJ_SUPPORT_NODE)
skip_config = true;

return 0;
@@ -251,7 +252,9 @@ int zynqmp_pmufw_load_config_object(const void *cfg_obj, 
size_t size)
err = xilinx_pm_request(PM_SET_CONFIGURATION, (u32)(u64)cfg_obj, 0, 0,
0, ret_payload);
if (err == XST_PM_NO_ACCESS) {
-   if (((u32 *)cfg_obj)[NODE_ID_LOCATION] == NODE_OCM_BANK_0) {
+   u32 id = ((u32 *)cfg_obj)[NODE_ID_LOCATION];
+
+   if (id == PMUFW_CFG_OBJ_SUPPORT_NODE) {
printf("PMUFW:  No permission to change config 
object\n");
return err;
}
@@ -299,7 +302,7 @@ static int zynqmp_power_probe(struct udevice *dev)
   ret & ZYNQMP_PM_VERSION_MINOR_MASK);

if (IS_ENABLED(CONFIG_ARCH_ZYNQMP))
-   zynqmp_pmufw_node(NODE_OCM_BANK_0);
+   zynqmp_pmufw_node(PMUFW_CFG_OBJ_SUPPORT_NODE);

return 0;
 };
--
2.30.2


Kommanditgesellschaft - Sitz: Detmold - Amtsgericht Lemgo HRA 2790 -
Komplementärin: Weidmüller Interface Führungsgesellschaft mbH -
Sitz: Detmold - Amtsgericht Lemgo HRB 3924;
Geschäftsführer: Dr. Timo Berger, Volker Bibelhausen, Dr. Sebastian Durst, 
André Sombecki;
USt-ID-Nr. DE124599660


Re: [PATCH 1/3] dt-bindings: misc: esm: Add ESM support for TI K3 devices

2023-04-19 Thread Neha Malcom Francis

Hi Krzysztof

On 18/04/23 21:40, Krzysztof Kozlowski wrote:

On 17/04/2023 10:56, Neha Malcom Francis wrote:

Hi Krzysztof

On 14/04/23 17:10, Krzysztof Kozlowski wrote:

On 14/04/2023 12:52, Neha Malcom Francis wrote:

Document the binding for TI K3 ESM (Error Signaling Module) block.

Signed-off-by: Neha Malcom Francis 
---
   .../devicetree/bindings/misc/esm-k3.yaml  | 54 +++
   1 file changed, 54 insertions(+)
   create mode 100644 Documentation/devicetree/bindings/misc/esm-k3.yaml

diff --git a/Documentation/devicetree/bindings/misc/esm-k3.yaml 
b/Documentation/devicetree/bindings/misc/esm-k3.yaml
new file mode 100644
index ..5e637add3b0e
--- /dev/null
+++ b/Documentation/devicetree/bindings/misc/esm-k3.yaml


Filename matching compatible. Missing vendor prefix and device name.


@@ -0,0 +1,54 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+# Copyright (C) 2022 Texas Instruments Incorporated
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/misc/esm-k3.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Texas Instruments K3 ESM Binding


Drop: Binding


+
+maintainers:
+  - Neha Malcom Francis 
+
+description: |
+  The ESM (Error Signaling Module) is an IP block on TI K3 devices
+  that allows handling of safety events somewhat similar to what interrupt
+  controller would do. The safety signals have their separate paths within
+  the SoC, and they are handld by the ESM, which routes them to the proper


typo: handled


+  destination, which can be system reset, interrupt controller, etc. In the
+  simplest configuration the signals are just routed to reset the SoC.


There is no proper bindings directory for ESM? Misc is discouraged.



There is no other directory I see fit for a block like ESM; it could
either remain in misc/ or maybe create a directory error/ for all error
signaling and correction mechanisms? I see misc/xlnx,sd-fec.txt that
could also go in error/

What do you think is fit?


I don't know. Maybe it is something like hwmon? Or maybe along with
xlnx,sd-fec, tmr-inject and tmr-manager should be moved to some "fault"
directory for all fault-management-and-handling hardware?



I think hwmon would be a fit for now. Maybe we can move to a common 
fault directory in a future patch if there is enough bindings.



Best regards,
Krzysztof



--
Thanking You
Neha Malcom Francis


Re: [PATCH] Revert "spi: zynq_qspi: Use dummy buswidth in dummy byte calculation"

2023-04-19 Thread Stefan Herbrechtsmeier

Hi Ashok,

have you test your patches with 1-4-4 mode?

I think your patches are a nop for 1-1-4 mode and break other modes:

spi-nor-core
op.dummy.nbytes = (nor->read_dummy * op.dummy.buswidth) / 8;

zynq_qspi:
dummy_bytes = op->dummy.nbytes / op->dummy.buswidth;

=> dummy_bytes = (nor->read_dummy * op.dummy.buswidth) / 8) /
op->dummy.buswidth
=> dummy_bytes = nor->read_dummy / 8

You changes ignores the bus width and breaks if the addr bus width is not 1!

Regards
  Stefan

Am 18.04.2023 um 12:27 schrieb Stefan Herbrechtsmeier:

Hi Ashok,

Am 18.04.2023 um 10:43 schrieb Soma, Ashok Reddy:




-Original Message-
From: Simek, Michal 
Sent: Monday, April 17, 2023 3:47 PM
To: Stefan Herbrechtsmeier
;
u-boot@lists.denx.de; Soma, Ashok Reddy 
Cc: Stefan Herbrechtsmeier ;
Jagan Teki 
Subject: Re: [PATCH] Revert "spi: zynq_qspi: Use dummy buswidth in
dummy
byte calculation"



On 3/31/23 16:44, Stefan Herbrechtsmeier wrote:

From: Stefan Herbrechtsmeier 

This reverts commit e09784728689de7949d4cdd559a9590e0bfcc702. The
commit wrongly divides the dummy bytes by dummy bus width to calculate
the dummy bytes. The framework already converts the dummy cycles to
the number of bytes and the controller use the SPI flash command to
determine the dummy cycles via the address width.

As per my understanding dummy bus width should be equal to data
buswidth and not equal to address bus width.
Please let me know if this understanding in incorrect.


Why? The kernel use the addr bus width too.

Independent of the correct answer the core should handle this because
it forward the dummy *bytes* to the driver:

/* convert the dummy cycles to the number of bytes */
op.dummy.nbytes = (nor->read_dummy * op.dummy.buswidth) / 8;


Furthermore, the driver send the dummy as part of the address:

/* 1st transfer: opcode + address + dummy cycles */


Based on the above understanding we have changed in Xilinx repo, at
below code
https://github.com/Xilinx/u-boot-xlnx/blob/024eb37c1e38ab811abe5408d42069fbd7901824/drivers/mtd/spi/spi-nor-core.c#L262

from
op->dummy.buswidth = spi_nor_get_protocol_addr_nbits(proto);
to
op->dummy.buswidth = spi_nor_get_protocol_data_nbits(proto);

I have sent the same as RFC. Please see the attached patch.

Currently this patch is present as part of Xilinx repo, and hence
based on this below implementation dymmy_bytes are recalculated.


In this case the patch should be reverted until the other patch is
accepted.


I have sent controller driver code to upstream but, I have not yet
sent spi-nor-core.c code, which I will be sending soon with some
other changes.

Please let me know your thoughts about this patch and the changes.


It is unclear to me why the dummy should be part of the data. The
current implementation is wrong because it doesn't respects the
address width and send the dummy bytes as part of the addr.

Regards
  Stefan



Kommanditgesellschaft - Sitz: Detmold - Amtsgericht Lemgo HRA 2790 -
Komplementärin: Weidmüller Interface Führungsgesellschaft mbH -
Sitz: Detmold - Amtsgericht Lemgo HRB 3924;
Geschäftsführer: Dr. Timo Berger, Volker Bibelhausen, Dr. Sebastian Durst, 
André Sombecki;
USt-ID-Nr. DE124599660


Re: [PATCH] stm32mp: fix various array bounds checks

2023-04-19 Thread Patrice CHOTARD



On 3/24/23 10:39, Patrice CHOTARD wrote:
> Hi Rasmus
> 
> On 3/24/23 08:55, Rasmus Villemoes wrote:
>> In all these cases, the index on the LHS is immediately afterwards
>> used to access the array appearing in the ARRAY_SIZE() on the RHS - so
>> if that index is equal to the array size, we'll access
>> one-past-the-end of the array.
>>
>> Signed-off-by: Rasmus Villemoes 
>> ---
>>
>> Patch generated with '-U5' to make that access obvious from the diff context.
>>
>>  arch/arm/mach-stm32mp/cpu.c | 4 ++--
>>  board/st/stm32mp1/stm32mp1.c| 2 +-
>>  drivers/ram/stm32mp1/stm32mp1_interactive.c | 2 +-
>>  3 files changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/arch/arm/mach-stm32mp/cpu.c b/arch/arm/mach-stm32mp/cpu.c
>> index dc4112d5e6..e2f67fc423 100644
>> --- a/arch/arm/mach-stm32mp/cpu.c
>> +++ b/arch/arm/mach-stm32mp/cpu.c
>> @@ -188,11 +188,11 @@ static void setup_boot_mode(void)
>>  
>>  log_debug("%s: boot_ctx=0x%x => boot_mode=%x, instance=%d forced=%x\n",
>>__func__, boot_ctx, boot_mode, instance, forced_mode);
>>  switch (boot_mode & TAMP_BOOT_DEVICE_MASK) {
>>  case BOOT_SERIAL_UART:
>> -if (instance > ARRAY_SIZE(serial_addr))
>> +if (instance >= ARRAY_SIZE(serial_addr))
>>  break;
>>  /* serial : search associated node in devicetree */
>>  sprintf(cmd, "serial@%x", serial_addr[instance]);
>>  if (uclass_get_device_by_name(UCLASS_SERIAL, cmd, )) {
>>  /* restore console on error */
>> @@ -218,11 +218,11 @@ static void setup_boot_mode(void)
>>  env_set("boot_device", "usb");
>>  env_set("boot_instance", "0");
>>  break;
>>  case BOOT_FLASH_SD:
>>  case BOOT_FLASH_EMMC:
>> -if (instance > ARRAY_SIZE(sdmmc_addr))
>> +if (instance >= ARRAY_SIZE(sdmmc_addr))
>>  break;
>>  /* search associated sdmmc node in devicetree */
>>  sprintf(cmd, "mmc@%x", sdmmc_addr[instance]);
>>  if (uclass_get_device_by_name(UCLASS_MMC, cmd, )) {
>>  printf("mmc%d = %s not found in device tree!\n",
>> diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c
>> index ca8f0255ae..1a1b1844c8 100644
>> --- a/board/st/stm32mp1/stm32mp1.c
>> +++ b/board/st/stm32mp1/stm32mp1.c
>> @@ -870,11 +870,11 @@ int mmc_get_boot(void)
>>  STM32_SDMMC1_BASE,
>>  STM32_SDMMC2_BASE,
>>  STM32_SDMMC3_BASE
>>  };
>>  
>> -if (instance > ARRAY_SIZE(sdmmc_addr))
>> +if (instance >= ARRAY_SIZE(sdmmc_addr))
>>  return 0;
>>  
>>  /* search associated sdmmc node in devicetree */
>>  snprintf(cmd, sizeof(cmd), "mmc@%x", sdmmc_addr[instance]);
>>  if (uclass_get_device_by_name(UCLASS_MMC, cmd, )) {
>> diff --git a/drivers/ram/stm32mp1/stm32mp1_interactive.c 
>> b/drivers/ram/stm32mp1/stm32mp1_interactive.c
>> index f0fe7e61e3..2c19847c66 100644
>> --- a/drivers/ram/stm32mp1/stm32mp1_interactive.c
>> +++ b/drivers/ram/stm32mp1/stm32mp1_interactive.c
>> @@ -389,11 +389,11 @@ bool stm32mp1_ddr_interactive(void *priv,
>>  log_debug("** step %d ** %s / %d\n", step, step_str[step], next_step);
>>  
>>  if (next_step < 0)
>>  return false;
>>  
>> -if (step < 0 || step > ARRAY_SIZE(step_str)) {
>> +if (step < 0 || step >= ARRAY_SIZE(step_str)) {
>>  printf("** step %d ** INVALID\n", step);
>>  return false;
>>  }
>>  
>>  printf("%d:%s\n", step, step_str[step]);
> 
> Good catch !
> 
> Reviewed-by: Patrice Chotard 
> 
> Thanks
> Patrice

Applied on u-boot-stm/master, thanks

Patrice


Re: [PATCH] mtd: rawnand: stm32_fmc2: remove unsupported EDO mode

2023-04-19 Thread Patrice CHOTARD



On 4/11/23 08:53, Patrice CHOTARD wrote:
> Hi Christophe
> 
> On 3/30/23 11:16, Christophe Kerello wrote:
>> Remove the EDO mode support from as the FMC2 controller does not
>> support the feature.
>>
>> Signed-off-by: Christophe Kerello 
>> ---
>>
>>  drivers/mtd/nand/raw/stm32_fmc2_nand.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/mtd/nand/raw/stm32_fmc2_nand.c 
>> b/drivers/mtd/nand/raw/stm32_fmc2_nand.c
>> index fb3279b405e..69dbb629e93 100644
>> --- a/drivers/mtd/nand/raw/stm32_fmc2_nand.c
>> +++ b/drivers/mtd/nand/raw/stm32_fmc2_nand.c
>> @@ -735,6 +735,9 @@ static int stm32_fmc2_nfc_setup_interface(struct 
>> mtd_info *mtd, int chipnr,
>>  if (IS_ERR(sdrt))
>>  return PTR_ERR(sdrt);
>>  
>> +if (sdrt->tRC_min < 3)
>> +return -EOPNOTSUPP;
>> +
>>  if (chipnr == NAND_DATA_IFACE_CHECK_ONLY)
>>  return 0;
>>  
> 
> Reviewed-by: Patrice Chotard 
> 
> Thanks
> Patrice



Applied on u-boot-stm/master, thanks

Patrice


Re: [PATCH] ARM: dts: stm32: add FMC support on STM32MP13x SoC family

2023-04-19 Thread Patrice CHOTARD



On 4/11/23 08:53, Patrice CHOTARD wrote:
> Hi Christophe
> 
> On 3/30/23 11:26, Christophe Kerello wrote:
>> Add FMC support on STM32MP13x SoC family.
>>
>> Signed-off-by: Christophe Kerello 
>> ---
>>
>>  arch/arm/dts/stm32mp131.dtsi | 33 +
>>  1 file changed, 33 insertions(+)
>>
>> diff --git a/arch/arm/dts/stm32mp131.dtsi b/arch/arm/dts/stm32mp131.dtsi
>> index 3cf51f09bcb..cf1171bc9bb 100644
>> --- a/arch/arm/dts/stm32mp131.dtsi
>> +++ b/arch/arm/dts/stm32mp131.dtsi
>> @@ -191,6 +191,39 @@
>>  dma-requests = <48>;
>>  };
>>  
>> +fmc: memory-controller@58002000 {
>> +compatible = "st,stm32mp1-fmc2-ebi";
>> +reg = <0x58002000 0x1000>;
>> +ranges = <0 0 0x6000 0x0400>, /* EBI CS 1 */
>> + <1 0 0x6400 0x0400>, /* EBI CS 2 */
>> + <2 0 0x6800 0x0400>, /* EBI CS 3 */
>> + <3 0 0x6c00 0x0400>, /* EBI CS 4 */
>> + <4 0 0x8000 0x1000>; /* NAND */
>> +#address-cells = <2>;
>> +#size-cells = <1>;
>> +clocks = < FMC_K>;
>> +resets = < FMC_R>;
>> +status = "disabled";
>> +
>> +nand-controller@4,0 {
>> +compatible = "st,stm32mp1-fmc2-nfc";
>> +reg = <4 0x 0x1000>,
>> +  <4 0x0801 0x1000>,
>> +  <4 0x0802 0x1000>,
>> +  <4 0x0100 0x1000>,
>> +  <4 0x0901 0x1000>,
>> +  <4 0x0902 0x1000>;
>> +#address-cells = <1>;
>> +#size-cells = <0>;
>> +interrupts = ;
>> +dmas = < 24 0x2 0x12000a02 0x0 0x0>,
>> +   < 24 0x2 0x12000a08 0x0 0x0>,
>> +   < 25 0x2 0x12000a0a 0x0 0x0>;
>> +dma-names = "tx", "rx", "ecc";
>> +status = "disabled";
>> +};
>> +};
>> +
>>  sdmmc1: mmc@58005000 {
>>  compatible = "st,stm32-sdmmc2", "arm,pl18x", 
>> "arm,primecell";
>>  arm,primecell-periphid = <0x20253180>;
> 
> 
> Reviewed-by: Patrice Chotard 
> 
> Thanks
> Patrice


Applied on u-boot-stm/master, thanks

Patrice


Re: [PATCH 1/2] firmware: zynqmp: Mask expected and show unexpected warning

2023-04-19 Thread Stefan Herbrechtsmeier

Hi Michal,

Am 17.04.2023 um 12:16 schrieb Michal Simek:


On 4/3/23 15:34, Stefan Herbrechtsmeier wrote:

From: Stefan Herbrechtsmeier 

Mask the expected and show the unexpected warning "No permission to
change config object" for NODE_OCM_BANK_0 because this node is used to
detect if further zynqmp_pmufw_node function calls should be skipped.

Signed-off-by: Stefan Herbrechtsmeier

---

  drivers/firmware/firmware-zynqmp.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/firmware/firmware-zynqmp.c
b/drivers/firmware/firmware-zynqmp.c
index dc8e3ad2b9..8435b58ef9 100644
--- a/drivers/firmware/firmware-zynqmp.c
+++ b/drivers/firmware/firmware-zynqmp.c
@@ -251,7 +251,7 @@ int zynqmp_pmufw_load_config_object(const void
*cfg_obj, size_t size)
 err = xilinx_pm_request(PM_SET_CONFIGURATION,
(u32)(u64)cfg_obj, 0, 0,
 0, ret_payload);
 if (err == XST_PM_NO_ACCESS) {
-   if (((u32 *)cfg_obj)[NODE_ID_LOCATION] ==
NODE_OCM_BANK_0) {
+   if (((u32 *)cfg_obj)[NODE_ID_LOCATION] !=
NODE_OCM_BANK_0) {
 printf("PMUFW:  No permission to change
config object\n");
 return err;
 }


First of all we should very likely create a macro for NODE_OCM_BANK_0
to cover that dependency that it is used in 3 different locations
which have to match.


Okay, I will add a PMUFW_CFG_OBJ_SUPPORT_NODE macro.


The second is the change you have in 2/2 should be the part of this
patch because when only 1/2 is applied you change behavior.


The patches should be independent, and the behavior change is intended.
The message should be printed if you don’t heave the permission for a
specific config object and not if the driver checks for support of
config objects. The NODE_OCM_BANK_0 call should never fail if load of
config objects is supported.


And changes in 2/2 makes sense.

I would be even fine to move skip_config out of zynqmp_pmufw_node()


The zynqmp_pmufw_node() function doesn't return an error and the
skip_config variable is static inside the function.


and setting up skip_config value directly in zynqmp_power_probe() not
to check in every call.


We still need to check the skip_config variable inside zynqmp_pmufw_node
to skip the load of the config object if the pmufw doesn't support it.



 85 if (ret == XST_PM_NO_ACCESS && id == NODE_OCM_BANK_0)
 86 skip_config = true;


Regards
  Stefan


Kommanditgesellschaft - Sitz: Detmold - Amtsgericht Lemgo HRA 2790 -
Komplementärin: Weidmüller Interface Führungsgesellschaft mbH -
Sitz: Detmold - Amtsgericht Lemgo HRB 3924;
Geschäftsführer: Dr. Timo Berger, Volker Bibelhausen, Dr. Sebastian Durst, 
André Sombecki;
USt-ID-Nr. DE124599660


Re: [PATCH] configs: stm32mp15: increase malloc size for pre-reloc

2023-04-19 Thread Patrice CHOTARD



On 4/7/23 11:37, Patrick Delaunay wrote:
> The early malloc usage increased so the associated defined
> CONFIG_SYS_MALLOC_F_LEN need to be increased.
> 
> For example, for stm32mp15_defconfig and
> stm32mp157c-dk2-scmi.dtsi, we have:
> 
> Early malloc usage: 280b8 / 8
> 
> Signed-off-by: Patrick Delaunay 
> ---
> 
>  configs/stm32mp15_defconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/configs/stm32mp15_defconfig b/configs/stm32mp15_defconfig
> index 0005e4266441..2676ff381d85 100644
> --- a/configs/stm32mp15_defconfig
> +++ b/configs/stm32mp15_defconfig
> @@ -1,7 +1,7 @@
>  CONFIG_ARM=y
>  CONFIG_ARCH_STM32MP=y
>  CONFIG_TFABOOT=y
> -CONFIG_SYS_MALLOC_F_LEN=0x2
> +CONFIG_SYS_MALLOC_F_LEN=0x8
>  CONFIG_CUSTOM_SYS_INIT_SP_ADDR=0xc010
>  CONFIG_ENV_OFFSET=0x48
>  CONFIG_ENV_SECT_SIZE=0x4


Applied on u-boot-stm/master, thanks.

Patrice


Re: [PATCH] pinctrl: pinctrl_stm32: Add slew rate support for stm32_pinctrl_get_pin_muxing()

2023-04-19 Thread Patrice CHOTARD



On 3/30/23 13:29, Patrick DELAUNAY wrote:
> Hi,
> 
> On 3/27/23 09:46, Patrice Chotard wrote:
>> For debug purpose, it should be useful to indicate the slew rate for
>> each pins.
>> Add ospeed register information for pins which are configured in
>> either alternate function or gpio output.
>>
>> Signed-off-by: Patrice Chotard 
>> ---
>>
>>   drivers/pinctrl/pinctrl_stm32.c | 19 +++
>>   1 file changed, 15 insertions(+), 4 deletions(-)
>>
>> diff --git a/drivers/pinctrl/pinctrl_stm32.c 
>> b/drivers/pinctrl/pinctrl_stm32.c
>> index b755fa42b4f..b06da50b2cd 100644
>> --- a/drivers/pinctrl/pinctrl_stm32.c
>> +++ b/drivers/pinctrl/pinctrl_stm32.c
>> @@ -61,6 +61,13 @@ static const char * const pinmux_otype[] = {
>>   [STM32_GPIO_OTYPE_OD] = "open-drain",
>>   };
>>   +static const char * const pinmux_speed[] = {
>> +    [STM32_GPIO_SPEED_2M] = "Low speed",
>> +    [STM32_GPIO_SPEED_25M] = "Medium speed",
>> +    [STM32_GPIO_SPEED_50M] = "High speed",
>> +    [STM32_GPIO_SPEED_100M] = "Very-high speed",
>> +};
>> +
>>   static int stm32_pinctrl_get_af(struct udevice *dev, unsigned int offset)
>>   {
>>   struct stm32_gpio_priv *priv = dev_get_priv(dev);
>> @@ -201,6 +208,7 @@ static int stm32_pinctrl_get_pin_muxing(struct udevice 
>> *dev,
>>   int af_num;
>>   unsigned int gpio_idx;
>>   u32 pupd, otype;
>> +    u8 speed;
>>     /* look up for the bank which owns the requested pin */
>>   gpio_dev = stm32_pinctrl_get_gpio_dev(dev, selector, _idx);
>> @@ -214,6 +222,7 @@ static int stm32_pinctrl_get_pin_muxing(struct udevice 
>> *dev,
>>   priv = dev_get_priv(gpio_dev);
>>   pupd = (readl(>regs->pupdr) >> (gpio_idx * 2)) & PUPD_MASK;
>>   otype = (readl(>regs->otyper) >> gpio_idx) & OTYPE_MSK;
>> +    speed = (readl(>regs->ospeedr) >> gpio_idx * 2) & OSPEED_MASK;
>>     switch (mode) {
>>   case GPIOF_UNKNOWN:
>> @@ -222,13 +231,15 @@ static int stm32_pinctrl_get_pin_muxing(struct udevice 
>> *dev,
>>   break;
>>   case GPIOF_FUNC:
>>   af_num = stm32_pinctrl_get_af(gpio_dev, gpio_idx);
>> -    snprintf(buf, size, "%s %d %s %s", pinmux_mode[mode], af_num,
>> - pinmux_otype[otype], pinmux_bias[pupd]);
>> +    snprintf(buf, size, "%s %d %s %s %s", pinmux_mode[mode], af_num,
>> + pinmux_otype[otype], pinmux_bias[pupd],
>> + pinmux_speed[speed]);
>>   break;
>>   case GPIOF_OUTPUT:
>> -    snprintf(buf, size, "%s %s %s %s",
>> +    snprintf(buf, size, "%s %s %s %s %s",
>>    pinmux_mode[mode], pinmux_otype[otype],
>> - pinmux_bias[pupd], label ? label : "");
>> + pinmux_bias[pupd], label ? label : "",
>> + pinmux_speed[speed]);
>>   break;
>>   case GPIOF_INPUT:
>>   snprintf(buf, size, "%s %s %s", pinmux_mode[mode],
> 
> 
> 
> Reviewed-by: Patrick Delaunay 
> 
> Thanks
> Patrick
> 

Applied on u-boot-stm/master, thanks.

Patrice


Re: [PATCH 2/2] configs: stm32mp13: Increase usb_pgood_delay for ST boards

2023-04-19 Thread Patrice CHOTARD



On 3/16/23 08:03, Patrice Chotard wrote:
> With some USB device, the current usb_pgood_delay value is not long
> enough to ensure a correct detection.
> 
> Signed-off-by: Patrice Chotard 
> ---
> 
>  include/configs/stm32mp13_st_common.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/configs/stm32mp13_st_common.h 
> b/include/configs/stm32mp13_st_common.h
> index ad8126f6103..20ec11477d6 100644
> --- a/include/configs/stm32mp13_st_common.h
> +++ b/include/configs/stm32mp13_st_common.h
> @@ -9,7 +9,7 @@
>  #define __CONFIG_STM32MP13_ST_COMMON_H__
>  
>  #define STM32MP_BOARD_EXTRA_ENV \
> - "usb_pgood_delay=1000\0" \
> + "usb_pgood_delay=2000\0" \
>   "console=ttySTM0\0"
>  
>  #include 

Applied on u-boot-stm/master, thanks.

Patrice


Re: [PATCH 1/2] configs: stm32mp15: Add usb_pgood_delay for ST boards

2023-04-19 Thread Patrice CHOTARD



On 3/16/23 08:03, Patrice Chotard wrote:
> Add usb_pgood_delay to ensure a correct detection of USB devices.
> 
> Signed-off-by: Patrice Chotard 
> ---
> 
>  include/configs/stm32mp15_st_common.h | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/include/configs/stm32mp15_st_common.h 
> b/include/configs/stm32mp15_st_common.h
> index d0cd4130cec..866cd7a719f 100644
> --- a/include/configs/stm32mp15_st_common.h
> +++ b/include/configs/stm32mp15_st_common.h
> @@ -9,6 +9,7 @@
>  #define __CONFIG_STM32MP15_ST_COMMON_H__
>  
>  #define STM32MP_BOARD_EXTRA_ENV \
> + "usb_pgood_delay=2000\0" \
>   "console=ttySTM0\0"
>  
>  #include 


Applied on u-boot-stm/master, thanks.


Re: [PATCH v2 0/3] rpi: Convert to standard boot

2023-04-19 Thread Peter Robinson
Hi Simon,

On Wed, Apr 19, 2023 at 2:46 AM Simon Glass  wrote:
>
> Hi Peter,
>
> On Sun, 2 Apr 2023 at 14:29, Simon Glass  wrote:
> >
> > This series moves Raspberry Pi boards over to use standard boot.
> >
> > It also moves rpi over to use a text-based environment. Unfortunately it
> > is not possible to empty the header file due to several CFG options.
> >
> > Fix the repeated "and and" while we are here.
> >
> > Note that this reduces rodata size by about 4.5KB. We could get another
> >
> > for a total image-size saving of about 15KB. This is mostly because
> > HUSH_PARSER is not enabled anymore and the environment shrinks down by
> > about 3.5K. Hush is not actually needed anymore, since standard boot does
> > not use it. Also CMD_SYSBOOT is dropped since standard boot calls the
> > pxe_utils code directly in that case.
> >
> > Changes in v2:
> > - Rebase to -next
> > - Add new patch to disable DISTRO_DEFAULTS
> >
> > Simon Glass (3):
> >   arm: rpi: Switch to standard boot
> >   rpi: Disable DISTRO_DEFAULTS
> >   arm: rpi: Switch to a text environment
> >
> >  board/raspberrypi/rpi/rpi.env  |  77 +++
> >  configs/rpi_0_w_defconfig  |   2 +-
> >  configs/rpi_2_defconfig|   2 +-
> >  configs/rpi_3_32b_defconfig|   2 +-
> >  configs/rpi_3_b_plus_defconfig |   2 +-
> >  configs/rpi_3_defconfig|   2 +-
> >  configs/rpi_4_32b_defconfig|   2 +-
> >  configs/rpi_4_defconfig|   2 +-
> >  configs/rpi_arm64_defconfig|   2 +-
> >  configs/rpi_defconfig  |   2 +-
> >  include/configs/rpi.h  | 134 -
> >  11 files changed, 86 insertions(+), 143 deletions(-)
> >  create mode 100644 board/raspberrypi/rpi/rpi.env
> >
> > --
> > 2.40.0.348.gf938b09366-goog
> >
>
> Any thoughts on this series, please?

It's in my backlog to review, I've been focused on other things so my
time is limited ATM but I'm also a little hesitant given the issues
with the rockchip conversion and still outstanding issues there.

Peter


Re: [PATCH 4/4] common: spl: spl: Remove video driver before u-boot proper

2023-04-19 Thread Nikhil M Jain

Hi Simon,

On 19/04/23 07:16, Simon Glass wrote:

Hi Nikhil,

On Mon, 10 Apr 2023 at 02:21, Nikhil M Jain  wrote:


Add method to remove video driver before loading u-boot proper. When
bootstage changes from SPL to u-boot proper, noo method is called to
remove video driver, and at u-boot proper if video driver is not
enabled, the video driver starts displaying garbage on the screen,
because there is no reserved space for video and the frame buffer gets
u-boot proper data written.

Signed-off-by: Nikhil M Jain 
---
  common/spl/spl.c | 15 +++
  1 file changed, 15 insertions(+)

diff --git a/common/spl/spl.c b/common/spl/spl.c
index a630e79866..72078a8ebc 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -35,6 +35,8 @@
  #include 
  #include 
  #include 
+#include 
+#include 
  #include 
  #include 
  #include 
@@ -889,6 +891,19 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
 debug("Failed to stash bootstage: err=%d\n", ret);
  #endif

+#if defined(CONFIG_SPL_VIDEO)


Should use if(IS_ENABLED(...))

But it would be better to pass the frame buffer to U-Boot proper so it
can use the same address. This can be done with a bloblist record. See
for example [1]

Yes it would be better, I will try to use bloblist for passing frame 
buffer to u-boot.



+   struct udevice *dev;
+   int rc;
+
+   rc = uclass_find_device(UCLASS_VIDEO, 0, );


uclass_find_first_device


+   if (!rc && dev) {
+   rc = device_remove(dev, DM_REMOVE_NORMAL);
+   if (rc)
+   printf("Cannot remove video device '%s' (err=%d)\n",
+  dev->name, rc);
+   }
+#endif
+
 spl_board_prepare_for_boot();
 jump_to_image_no_args(_image);
  }
--
2.34.1



Regards,
Simon

[1] 
https://patchwork.ozlabs.org/project/uboot/patch/20230331103047.26.Ieb0824a81d8ad4109fa501c9497b01b8749f913a@changeid/


Thanks,
Nikhil


Re: [PATCH v1 4/4] board: asus: grouper: add Google Nexus 7 (2012) support

2023-04-19 Thread Svyatoslav Ryhel
Hello Simon,
ср, 19 квіт. 2023 р. о 04:47 Simon Glass  пише:
>
> Hi Svyatoslav,
>
> On Wed, 12 Apr 2023 at 13:50, Svyatoslav Ryhel  wrote:
> >
> > Nexus 7 is a mini tablet computer co-developed by Google and Asus
> > that runs the Android operating system. The Nexus 7 features a 7"
> > display, an Nvidia Tegra 3 quad-core chip, 1 GB of RAM and 8/16 GB
> > of internal storage.
> >
> > This patch brings support for all 3 known ASUS/Google devices:
> > - Nexus 7 (2012) E1565
> > - Nexus 7 (2012) PM269
> > - Nexus 7 (2012) 3G - tilapia
> >
> > Tested-by: Andreas Westman Dorcsak  # ASUS Grouper E1565
> > Tested-by: Svyatoslav Ryhel  # ASUS Grouper E1565
> > Signed-off-by: Svyatoslav Ryhel 
> > ---
> >  arch/arm/dts/Makefile |   3 +
> >  arch/arm/dts/tegra30-asus-grouper-common.dtsi | 125 ++
> >  .../dts/tegra30-asus-nexus7-grouper-E1565.dts |  40 ++
> >  .../dts/tegra30-asus-nexus7-grouper-PM269.dts |  65 
> >  .../dts/tegra30-asus-nexus7-tilapia-E1565.dts |  40 ++
> >  arch/arm/mach-tegra/tegra30/Kconfig   |   5 +
> >  board/asus/grouper/Kconfig|  20 +
> >  board/asus/grouper/MAINTAINERS|   6 +
> >  board/asus/grouper/Makefile   |  14 +
> >  board/asus/grouper/grouper-spl-max.c  |  46 +++
> >  board/asus/grouper/grouper-spl-ti.c   |  42 ++
> >  board/asus/grouper/grouper.c  | 209 ++
> >  board/asus/grouper/pinmux-config-grouper.h| 362 ++
> >  configs/grouper_E1565.config  |   2 +
> >  configs/grouper_PM269.config  |   2 +
> >  configs/grouper_common_defconfig  |  85 
> >  configs/tilapia.config|   3 +
> >  include/configs/grouper.h |  68 
> >  18 files changed, 1137 insertions(+)
> >  create mode 100644 arch/arm/dts/tegra30-asus-grouper-common.dtsi
> >  create mode 100644 arch/arm/dts/tegra30-asus-nexus7-grouper-E1565.dts
> >  create mode 100644 arch/arm/dts/tegra30-asus-nexus7-grouper-PM269.dts
> >  create mode 100644 arch/arm/dts/tegra30-asus-nexus7-tilapia-E1565.dts
> >  create mode 100644 board/asus/grouper/Kconfig
> >  create mode 100644 board/asus/grouper/MAINTAINERS
> >  create mode 100644 board/asus/grouper/Makefile
> >  create mode 100644 board/asus/grouper/grouper-spl-max.c
> >  create mode 100644 board/asus/grouper/grouper-spl-ti.c
> >  create mode 100644 board/asus/grouper/grouper.c
> >  create mode 100644 board/asus/grouper/pinmux-config-grouper.h
> >  create mode 100644 configs/grouper_E1565.config
> >  create mode 100644 configs/grouper_PM269.config
> >  create mode 100644 configs/grouper_common_defconfig
> >  create mode 100644 configs/tilapia.config
> >  create mode 100644 include/configs/grouper.h
>
> Please can add you add a doc/board/... file to describe how to put
> this on the device?
>
> Regards,
> Simon

Sure, I will add doc/board/... for all boards I am proposing in the
next patchset iteration.

Best regards,
Svyatoslav R.


[PATCH] arch: arm: mach-k3: Delete tifs node in DT fixup

2023-04-19 Thread Udit Kumar
This patch deletes tifs DT node as part of fixup.

TISCI API reported msmc_size, does not include
64KB reserved size for tifs aka MSMC comms memory.

As part of fixup, original code uses TISCI API
reported msmc_size as size for sram DT node.

tifs node is similar to l3-cache, which should
hold address above msms_size, and should be deleted
before passing control to OS.

Documentation
https://software-dl.ti.com/tisci/esd/latest/2_tisci_msgs/general/core.html?highlight=msmc#tisci-msg-query-msmc

Signed-off-by: Udit Kumar 
---
 arch/arm/mach-k3/common.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c
index a2adb791f6..4651744821 100644
--- a/arch/arm/mach-k3/common.c
+++ b/arch/arm/mach-k3/common.c
@@ -349,9 +349,11 @@ int fdt_fixup_msmc_ram(void *blob, char *parent_path, char 
*node_name)
size = fdt_read_number(sub_reg, 1);
debug("%s: subnode = %d, addr = 0x%x. size = 0x%x\n", __func__,
  subnode, addr, size);
+
if (addr + size > msmc_size ||
!strncmp(fdt_get_name(blob, subnode, ), "sysfw", 5) ||
-   !strncmp(fdt_get_name(blob, subnode, ), "l3cache", 7)) {
+   !strncmp(fdt_get_name(blob, subnode, ), "l3cache", 7) ||
+   !strncmp(fdt_get_name(blob, subnode, ), "tifs", 4)) {
fdt_del_node(blob, subnode);
debug("%s: deleting subnode %d\n", __func__, subnode);
if (!prev_node)
-- 
2.34.1



Re: [PATCH 00/38] x86: Use qemu-x86_64 to boot EFI installers

2023-04-19 Thread Simon Glass
Hi Bin,

On Thu, 30 Mar 2023 at 15:32, Simon Glass  wrote:
>
> This series adds various minor features so that qemu-x86_64 can boot the
> Ubuntu 2022.04 installer using a virtio device:
>
> qemu-system-x86_64 -M pc -drive format=raw,file=root.img
> -bios /tmp/b/qemu-x86_64/u-boot.rom
> -drive if=virtio,file=ubuntu-22.04.2-desktop-amd64.iso
> -smp 4 -m 4G -serial mon:stdio
>
> The main changes include:
> - Enable video in SPL while running in 32-bit mode
> - Drop the duplicate ACPI tables with EFI
> - Support PCI autoconfig in SPL
> - Support FAT on a CDROM filesystem
> - Improved bootstd rules around device tree and efi_set_bootdev()
>
> There are also quite a number of minor tweaks and fixes to make things
> easier to use.
>
> This series is based on an older version of the SPL-video series from
> Nikhil M Jain. It is available at u-boot-dm/bryc-working
>
>
> Simon Glass (38):
>   x86: Tidy up availability of string functions
>   x86: Allow listing MTRRs in SPL
>   bios_emulator: Add Kconfig and adjust Makefile for SPL
>   bios_emulator: Drop VIDEO_IO_OFFSET
>   x86: Tidy up EFI code in interrupt_init()
>   x86: Set high bits of the mtrr base registrer
>   x86: Add a comment for board_init_f_r_trampoline()
>   x86: Show the CPU physical address size with bdinfo
>   x86: Correct get_sp() implementation for 64-bit
>   x86: Show an error when a BINS exception occurs
>   acpi: Add a comment to set the acpi tables
>   bdinfo: Show the RAM top and approximate stack pointer
>   part: Allow setting the partition-table type
>   qfw: Show the file address if available
>   log: Tidy up an ambiguous comment.
>   video: Allow building video drivers for SPL
>   qfw: Set the address of the ACPI tables
>   efi: Show all known UUIDs with CONFIG_CMD_EFIDEBUG
>   x86: Improve the trampoline in 64-bit mode
>   Show the malloc base with the bdinfo command
>   nvme: Provide more useful debugging messages
>   pci: Support autoconfig in SPL
>   pci: Allow the video BIOS to work in SPL with QEMU
>   pci: Tidy up logging and reporting for video BIOS
>   x86: Allow video-BIOS code to be built for SPL
>   x86: Pass video settings from SPL to U-Boot proper
>   x86: Init video in SPL if enabled
>   pci: Adjust video BIOS debugging to be SPL-friendly
>   pci: Mask the ROM address in case it is already enabled
>   x86: Enable display for QEMU 64-bit
>   x86: Allow logging to be used in SPL reliably
>   fs: fat: Shrink the size of a few strings
>   fs: fat: Support reading from a larger block size
>   x86: Enable useful options for qemu-86_64
>   x86: Record the start and end of the tables
>   sandbox: Correct header order in board file
>   sandbox: Install ACPI tables on startup
>   efi: Use the installed ACPI tables
>
>  arch/sandbox/include/asm/global_data.h|   4 +
>  arch/x86/cpu/i386/interrupt.c |  17 +--
>  arch/x86/cpu/mtrr.c   |  62 +++-
>  arch/x86/cpu/start64.S|  19 +++
>  arch/x86/include/asm/global_data.h|   4 +
>  arch/x86/include/asm/mtrr.h   |  20 +++
>  arch/x86/include/asm/string.h |   6 +-
>  arch/x86/include/asm/u-boot-x86.h |  21 ++-
>  arch/x86/lib/Makefile |   9 +-
>  arch/x86/lib/bdinfo.c |   5 +
>  arch/x86/lib/bios.c   |   5 +-
>  arch/x86/lib/bootm.c  |   2 +-
>  arch/x86/lib/spl.c|  26 +++-
>  arch/x86/lib/tables.c |   4 +-
>  board/google/Kconfig  |   7 -
>  board/sandbox/sandbox.c   |  22 ++-
>  cmd/Kconfig   |   8 ++
>  cmd/acpi.c|  24 +++-
>  cmd/bdinfo.c  |   6 +
>  cmd/part.c|  34 +
>  cmd/qfw.c |   2 +-
>  cmd/x86/mtrr.c|  60 +---
>  common/board_f.c  |  12 +-
>  common/board_r.c  |   7 +-
>  common/log.c  |   2 +-
>  configs/qemu-x86_64_defconfig |  14 ++
>  disk/part.c   |  16 +++
>  doc/usage/cmd/acpi.rst|  29 +++-
>  doc/usage/cmd/part.rst|  74 ++
>  doc/usage/cmd/qfw.rst |  28 ++--
>  drivers/Kconfig   |   2 +
>  drivers/Makefile  |   5 +-
>  drivers/bios_emulator/Kconfig |  10 ++
>  drivers/bios_emulator/biosemui.h  |  18 +--
>  drivers/bios_emulator/x86emu/sys.c|   1 +
>  drivers/misc/qfw.c|  12 ++
>  drivers/nvme/nvme.c   |  36 +++--
>  drivers/pci/Kconfig   |   8 ++
>  drivers/pci/pci-uclass.c  |  10 +-
>  drivers/pci/pci_rom.c | 165 +-
>  fs/fat/Kconfig  

Re: [PATCH 1/3] dt-bindings: misc: esm: Add ESM support for TI K3 devices

2023-04-19 Thread Krzysztof Kozlowski
On 17/04/2023 10:56, Neha Malcom Francis wrote:
> Hi Krzysztof
> 
> On 14/04/23 17:10, Krzysztof Kozlowski wrote:
>> On 14/04/2023 12:52, Neha Malcom Francis wrote:
>>> Document the binding for TI K3 ESM (Error Signaling Module) block.
>>>
>>> Signed-off-by: Neha Malcom Francis 
>>> ---
>>>   .../devicetree/bindings/misc/esm-k3.yaml  | 54 +++
>>>   1 file changed, 54 insertions(+)
>>>   create mode 100644 Documentation/devicetree/bindings/misc/esm-k3.yaml
>>>
>>> diff --git a/Documentation/devicetree/bindings/misc/esm-k3.yaml 
>>> b/Documentation/devicetree/bindings/misc/esm-k3.yaml
>>> new file mode 100644
>>> index ..5e637add3b0e
>>> --- /dev/null
>>> +++ b/Documentation/devicetree/bindings/misc/esm-k3.yaml
>>
>> Filename matching compatible. Missing vendor prefix and device name.
>>
>>> @@ -0,0 +1,54 @@
>>> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
>>> +# Copyright (C) 2022 Texas Instruments Incorporated
>>> +%YAML 1.2
>>> +---
>>> +$id: http://devicetree.org/schemas/misc/esm-k3.yaml#
>>> +$schema: http://devicetree.org/meta-schemas/core.yaml#
>>> +
>>> +title: Texas Instruments K3 ESM Binding
>>
>> Drop: Binding
>>
>>> +
>>> +maintainers:
>>> +  - Neha Malcom Francis 
>>> +
>>> +description: |
>>> +  The ESM (Error Signaling Module) is an IP block on TI K3 devices
>>> +  that allows handling of safety events somewhat similar to what interrupt
>>> +  controller would do. The safety signals have their separate paths within
>>> +  the SoC, and they are handld by the ESM, which routes them to the proper
>>
>> typo: handled
>>
>>> +  destination, which can be system reset, interrupt controller, etc. In the
>>> +  simplest configuration the signals are just routed to reset the SoC.
>>
>> There is no proper bindings directory for ESM? Misc is discouraged.
>>
> 
> There is no other directory I see fit for a block like ESM; it could 
> either remain in misc/ or maybe create a directory error/ for all error 
> signaling and correction mechanisms? I see misc/xlnx,sd-fec.txt that 
> could also go in error/
> 
> What do you think is fit?

I don't know. Maybe it is something like hwmon? Or maybe along with
xlnx,sd-fec, tmr-inject and tmr-manager should be moved to some "fault"
directory for all fault-management-and-handling hardware?

Best regards,
Krzysztof



[PATCH v2 00/18] x86: Various fixes for chromebooks

2023-04-19 Thread Simon Glass
This adds some fixes for x86-based Chromebook builds which have picked up
a few problems recently.

With this, chromebook_link/64, chromebook_samus and chromebook_coral work
correctly.

Changes in v2:
- Add new patch to set up LPC only after relocation
- Add new patch to tidy up address for loading U-Boot from SPL
- Drop patch "x86: Add on to existing MTRRs in SPL"
- Add various patches to resolve problems with chromebook_link64

Simon Glass (18):
  dm: Emit the arch_cpu_init_dm() even only before relocation
  binman: Support writing symbols for ucode etypes
  sf: Guard against zero erasesize
  sf: Rename spi-nor-tiny functions
  x86: ivybridge: Ensure LPC is available for GPIO base
  x86: samus: Drop EFI_LOADER
  x86: Support debug UART in 64-bit mode
  x86: Tidy up availability of string functions
  x86: mrc: Correct SPL debug message
  x86: spl: Show debugging for BSS
  x86: Set up LPC only after relocation
  x86: Tidy up address for loading U-Boot from SPL
  x86: Return mtrr_add_request() to its old purpose
  x86: spl: Avoid using init_cache_f_r() from SPL
  spl: Commit MTRRs only in board_init_f_r()
  x86: Simplify cpu_jump_to_64bit_uboot()
  x86: samus: Don't include audio and SATA in TPL
  x86: samus: Adjust TPL start and pre-reloc memory size

 arch/arm/mach-imx/imx8/cpu.c  |  2 +-
 arch/arm/mach-imx/imx8m/soc.c |  2 +-
 arch/arm/mach-imx/imx8ulp/soc.c   |  2 +-
 arch/arm/mach-imx/imx9/soc.c  |  2 +-
 arch/arm/mach-omap2/am33xx/board.c|  2 +-
 arch/arm/mach-omap2/hwinit-common.c   |  2 +-
 arch/mips/mach-pic32/cpu.c|  2 +-
 arch/nios2/cpu/cpu.c  |  2 +-
 arch/riscv/cpu/cpu.c  |  2 +-
 arch/x86/cpu/baytrail/cpu.c   |  2 +-
 arch/x86/cpu/broadwell/Makefile   |  4 +--
 arch/x86/cpu/broadwell/cpu.c  |  2 +-
 arch/x86/cpu/i386/cpu.c   | 32 +++
 arch/x86/cpu/ivybridge/bd82x6x.c  | 17 +-
 arch/x86/cpu/ivybridge/cpu.c  |  2 +-
 arch/x86/cpu/mtrr.c   |  6 +++-
 arch/x86/cpu/quark/quark.c|  2 +-
 arch/x86/cpu/x86_64/cpu.c |  7 
 arch/x86/include/asm/string.h |  6 +++-
 arch/x86/lib/Makefile |  4 ++-
 arch/x86/lib/fsp2/fsp_init.c  |  2 +-
 arch/x86/lib/mrccache.c   |  2 +-
 arch/x86/lib/spl.c| 21 +---
 configs/chromebook_samus_defconfig|  1 +
 configs/chromebook_samus_tpl_defconfig|  4 +--
 doc/develop/event.rst |  6 ++--
 drivers/core/root.c   |  4 +--
 drivers/cpu/microblaze_cpu.c  |  2 +-
 drivers/mtd/spi/sf_probe.c|  3 +-
 drivers/mtd/spi/spi-nor-tiny.c| 16 +-
 drivers/sysreset/sysreset_x86.c   |  9 --
 include/event.h   |  2 +-
 .../binman/etype/u_boot_spl_with_ucode_ptr.py |  2 +-
 .../binman/etype/u_boot_tpl_with_ucode_ptr.py |  2 +-
 tools/binman/etype/u_boot_with_ucode_ptr.py   |  4 +--
 35 files changed, 90 insertions(+), 92 deletions(-)

-- 
2.40.0.634.g4ca3ef3211-goog



Re: [PATCH 1/5] mtd/spinand: rework detect procedure for different READ_ID operation

2023-04-19 Thread Frieder Schrempf
On 18.04.23 20:24, Michael Nazzareno Trimarchi wrote:
> Hi
> 
> On Tue, Apr 18, 2023 at 8:20 PM Mikhail Kshevetskiy
>  wrote:
>>
>> I can try to resend patches (flash drivers synced with linux-6.1).
>> Unfortunately I am not sure I will be able to do it after changes in our
>> mail system.
> 
> I don't think that re-sync now is what we want to do. The idea here is
> to have easy patch that we can review.
> 
> We should go for this for now

Yes, there is no resend or resync needed. The patchset I sent [1] still
applies on current master.

Resyncing with a later version of Linux, like 6.1 won't be that easy
because of the upstream ECC engine abstraction.

Mikhail, if you are willing to do this, this is fine and appreciated,
but we should do that after merging this series.

[1]
https://patchwork.ozlabs.org/project/uboot/patch/20230110115843.391630-1-frie...@fris.de/


Re: [PATCH] riscv: Support riscv64 image type

2023-04-19 Thread Rick Chen
Hi Simon,

> Hi Rick,
>
> On Mon, 10 Apr 2023 at 01:26, Rick Chen  wrote:
> >
> > Allow U-Boot to load 32 or 64 bits RISC-V Kernel Image
> > distinguishly. It helps to avoid someone maybe make a mistake
> > to run 32-bit U-Boot to load 64-bit kernel.
> >
> > Signed-off-by: Rick Chen 
> >
> > ---
> > The patchset is based on Simon's patch:
> > riscv: Add a 64-bit image type
> > ---
> > ---
> >  arch/riscv/include/asm/u-boot.h | 4 
> >  cmd/booti.c | 2 +-
> >  2 files changed, 5 insertions(+), 1 deletion(-)
>
> Reviewed-by: Simon Glass 
>
> I don't know much about RISC-V, but I assume U-Boot is able to do this
> successfully? Does it not need to switch modes first?

No, it is not need to  switch modes as far as I know.
Here only provide a check mechanism just like arm to see if loader and
OS are match

But This patch is for bootm flow.
Maybe I still need to check if it is necessary to prepare a patch for
binman flow ?
/arch/riscv/dts/binman.dtsi
arch = "riscv";

maybe provide another binman64.dtsi for arch="riscv64"

Thanks,
Rick

>
> Regards,
> Simon


[PATCH 1/1] doc: codingstyle: Python coding style

2023-04-19 Thread Heinrich Schuchardt
Indicate that we follow PEP8 and PEP257.

Signed-off-by: Heinrich Schuchardt 
---
 doc/develop/codingstyle.rst | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/doc/develop/codingstyle.rst b/doc/develop/codingstyle.rst
index 1d5d0192b3..3d05a6b988 100644
--- a/doc/develop/codingstyle.rst
+++ b/doc/develop/codingstyle.rst
@@ -19,6 +19,10 @@ The following rules apply:
   applies only to Linux, not to U-Boot. Only large hunks which are copied
   unchanged from Linux may retain that comment format.
 
+* Python code shall conform to `PEP8 (Style Guide for Python Code)
+  `_. Use `pylint
+  `_ for checking the code.
+
 * Use patman to send your patches (``tools/patman/patman -H`` for full
   instructions). With a few tags in your commits this will check your patches
   and take care of emailing them.
@@ -67,6 +71,9 @@ documentation is strongly advised. The Linux kernel 
`kernel-doc
 `_
 documentation applies with no changes.
 
+Our Python code documentation follows `PEP257 (Docstring Conventions)
+`_.
+
 Use structures for I/O access
 -
 
-- 
2.39.2



Re: [PATCH 1/1] test: fix pylint warning for capsule tests

2023-04-19 Thread Heinrich Schuchardt




On 4/19/23 03:45, Simon Glass wrote:

Hi Heinrich,

On Fri, 14 Apr 2023 at 02:34, Heinrich Schuchardt
 wrote:


Fix pylint warnings like:

* Class inherits from object
* Missing module description
* Missing class description
* First line of comment blank
* Superfluous imports

Signed-off-by: Heinrich Schuchardt 
---
  test/py/tests/test_efi_capsule/conftest.py| 27 
  .../test_capsule_firmware_fit.py  | 35 
  .../test_capsule_firmware_signed_fit.py   | 41 ++-
  .../test_capsule_firmware_signed_raw.py   | 38 -
  4 files changed, 65 insertions(+), 76 deletions(-)

diff --git a/test/py/tests/test_efi_capsule/conftest.py 
b/test/py/tests/test_efi_capsule/conftest.py
index 4879f2b5c2..0e5137de60 100644
--- a/test/py/tests/test_efi_capsule/conftest.py
+++ b/test/py/tests/test_efi_capsule/conftest.py
@@ -2,30 +2,21 @@
  # Copyright (c) 2020, Linaro Limited
  # Author: AKASHI Takahiro 

-import os
-import os.path
-import re
-from subprocess import call, check_call, check_output, CalledProcessError
-import pytest
-from capsule_defs import *
+"""Fixture for UEFI capsule test
+"""

-#
-# Fixture for UEFI capsule test
-#
+from subprocess import call, check_call, CalledProcessError
+import pytest
+from capsule_defs import CAPSULE_DATA_DIR, CAPSULE_INSTALL_DIR, EFITOOLS_PATH

  @pytest.fixture(scope='session')
  def efi_capsule_data(request, u_boot_config):
-"""Set up a file system to be used in UEFI capsule and
-   authentication test.
-
-Args:
-request: Pytest request object.
-u_boot_config: U-boot configuration.
+"""Set up a file system to be used in UEFI capsule and authentication test
+and return a ath to disk image to be used for testing


Thanks for cleaning this up. I suppose with all the rounds of review
we got tired of worrying about the style. Also this probably predates
the pylint check.

Can we please follow the style in the rest of the code? This should
have a heading line, with further notes after a blank line.



-Return:
-A path to disk image to be used for testing
+request -- Pytest request object.
+u_boot_config -- U-boot configuration.


Again the style is:

Return:
request (pytest.Request): Request to be processed
u_boot_config (type): U-Boot configuration


This seems to be some Google internal code style. We should stick to 
PEP257 (https://peps.python.org/pep-0257/).


Best regards

Heinrich



(so avoid periods at the end and add the type in brackets)

The u_boot_config thing is pretty annoying since it creates a
strangely named class - see confest.py where is has:

 ubconfig = ArbitraryAttributeContainer()

Really that should be a class with a sensible name and documented
properties. The internals of this are a little too arcane for my
liking and discoverability is not great.

[..]

Also, this should be added to the checker - try 'make pylint' to see that.

Regards,
Simon


[PATCH V8 14/14] common: Replace #ifdef and #if with if's

2023-04-19 Thread Nikhil M Jain
Avoid using preprocessor compilation directives and instead use simple
logical expressions for better readability since compiler will anyway
optimize out the respective code block if condition is not satisfied.

Signed-off-by: Nikhil M Jain 
---
V8:
- Update as per review comments.
- Call bmp_display only when CONFIG_BMP is defined.

V7(patch introduced):
- Replace #ifdef and #if with if's.

 common/bmp.c | 14 +-
 common/splash.c  | 14 +++---
 include/splash.h | 11 ---
 3 files changed, 12 insertions(+), 27 deletions(-)

diff --git a/common/bmp.c b/common/bmp.c
index ad91351f19..57764f3653 100644
--- a/common/bmp.c
+++ b/common/bmp.c
@@ -31,9 +31,9 @@
  * by the caller after use.
  *
  * Returns NULL if decompression failed, or if the decompressed data
- * didn't contain a valid BMP signature.
+ * didn't contain a valid BMP signature or decompression is not enabled in
+ * Kconfig.
  */
-#if CONFIG_IS_ENABLED(VIDEO_BMP_GZIP)
 struct bmp_image *gunzip_bmp(unsigned long addr, unsigned long *lenp,
 void **alloc_addr)
 {
@@ -41,6 +41,9 @@ struct bmp_image *gunzip_bmp(unsigned long addr, unsigned 
long *lenp,
unsigned long len;
struct bmp_image *bmp;
 
+   if (!CONFIG_IS_ENABLED(VIDEO_BMP_GZIP))
+   return NULL;
+
/*
 * Decompress bmp image
 */
@@ -77,13 +80,6 @@ struct bmp_image *gunzip_bmp(unsigned long addr, unsigned 
long *lenp,
*alloc_addr = dst;
return bmp;
 }
-#else
-struct bmp_image *gunzip_bmp(unsigned long addr, unsigned long *lenp,
-void **alloc_addr)
-{
-   return NULL;
-}
-#endif
 
 #ifdef CONFIG_NEEDS_MANUAL_RELOC
 void bmp_reloc(void)
diff --git a/common/splash.c b/common/splash.c
index a4e68b7042..2a6d83d695 100644
--- a/common/splash.c
+++ b/common/splash.c
@@ -96,12 +96,11 @@ __weak int splash_screen_prepare(void)
return splash_video_logo_load();
 }
 
-#if CONFIG_IS_ENABLED(SPLASH_SCREEN_ALIGN)
 void splash_get_pos(int *x, int *y)
 {
char *s = env_get("splashpos");
 
-   if (!s)
+   if (!CONFIG_IS_ENABLED(SPLASH_SCREEN_ALIGN) || !s)
return;
 
if (s[0] == 'm')
@@ -117,7 +116,6 @@ void splash_get_pos(int *x, int *y)
*y = simple_strtol(s + 1, NULL, 0);
}
 }
-#endif /* CONFIG_SPLASH_SCREEN_ALIGN */
 
 #if CONFIG_IS_ENABLED(VIDEO) && !CONFIG_IS_ENABLED(HIDE_LOGO_VERSION)
 
@@ -159,13 +157,13 @@ void splash_display_banner(void)
  * Common function to show a splash image if env("splashimage") is set.
  * For additional details please refer to doc/README.splashprepare.
  */
-#if CONFIG_IS_ENABLED(SPLASH_SCREEN) && CONFIG_IS_ENABLED(BMP)
 int splash_display(void)
 {
ulong addr;
char *s;
int x = 0, y = 0, ret;
-
+   if (!(CONFIG_IS_ENABLED(SPLASH_SCREEN)))
+   return -ENOSYS;
s = env_get("splashimage");
if (!s)
return -EINVAL;
@@ -177,7 +175,10 @@ int splash_display(void)
 
splash_get_pos(, );
 
-   ret = bmp_display(addr, x, y);
+   if (CONFIG_IS_ENABLED(BMP))
+   ret = bmp_display(addr, x, y);
+   else
+   return -ENOSYS;
 
/* Skip banner output on video console if the logo is not at 0,0 */
if (x || y)
@@ -189,4 +190,3 @@ int splash_display(void)
 end:
return ret;
 }
-#endif
diff --git a/include/splash.h b/include/splash.h
index b6a100ffc3..9027f5d978 100644
--- a/include/splash.h
+++ b/include/splash.h
@@ -61,20 +61,9 @@ static inline int splash_source_load(struct splash_location 
*locations,
 
 int splash_screen_prepare(void);
 
-#if CONFIG_IS_ENABLED(SPLASH_SCREEN_ALIGN)
 void splash_get_pos(int *x, int *y);
-#else
-static inline void splash_get_pos(int *x, int *y) { }
-#endif
 
-#if CONFIG_IS_ENABLED(SPLASH_SCREEN) && CONFIG_IS_ENABLED(BMP)
 int splash_display(void);
-#else
-static inline int splash_display(void)
-{
-   return -ENOSYS;
-}
-#endif
 
 #define BMP_ALIGN_CENTER   0x7FFF
 
-- 
2.34.1



[PATCH V8 13/14] board: ti: am62x: evm: OSPI support for splash screen

2023-04-19 Thread Nikhil M Jain
Add ospi boot media support to load splash image from OSPI memory,
add offset to read image from ospi and necessary flags defininig type
of storage and storage device.

Use CONFIG_IS_ENBALED to use the splash locations at SPL and u-boot
proper.

Signed-off-by: Nikhil M Jain 
Reviewed-by: Simon Glass 
Reviewed-by: Devarsh Thakkar 
---
V8:
- No change.

V7:
- Add Reviewed-by tag.

V6:
- No change.

V5:
- Replace #ifdef with #if.
- Add Reviewed-by tag.

V4:
- Added Reviewed-by tag.

V3:
- Enable splash location at SPL.

V2:
- No change.

 board/ti/am62x/evm.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/board/ti/am62x/evm.c b/board/ti/am62x/evm.c
index 584b4ec552..fd58ece29c 100644
--- a/board/ti/am62x/evm.c
+++ b/board/ti/am62x/evm.c
@@ -20,8 +20,14 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#ifdef CONFIG_SPLASH_SCREEN
+#if CONFIG_IS_ENABLED(SPLASH_SCREEN)
 static struct splash_location default_splash_locations[] = {
+   {
+   .name = "sf",
+   .storage = SPLASH_STORAGE_SF,
+   .flags = SPLASH_STORAGE_RAW,
+   .offset = 0x70,
+   },
{
.name   = "mmc",
.storage= SPLASH_STORAGE_MMC,
-- 
2.34.1



[PATCH V8 12/14] include: Enable video related global data variable and splash at SPL

2023-04-19 Thread Nikhil M Jain
To include video related global data variables and splash functions at
SPL and u-boot proper, use CONFIG_IS_ENABLED.

Replace CONFIG_CMD_BMP with CONFIG_BMP to enable splash_display function
at u-boot proper and SPL.

Signed-off-by: Nikhil M Jain 
Reviewed-by: Devarsh Thakkar 
Reviewed-by: Simon Glass 
---
V8:
- No change.

V7:
- Add Reviewed-by tag.

V6:
- Fix commit message.
- Add Reviewed-by tag.

V5:
- Replace CONFIG_CMD_BMP with CONFIG_BMP.

V4:
- No change.

V3 (patch introduced):
- Enable splash functions at SPL.

 include/asm-generic/global_data.h | 4 ++--
 include/splash.h  | 6 +++---
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/include/asm-generic/global_data.h 
b/include/asm-generic/global_data.h
index 987fb66c17..65bf8df1e5 100644
--- a/include/asm-generic/global_data.h
+++ b/include/asm-generic/global_data.h
@@ -68,7 +68,7 @@ struct global_data {
 * @mem_clk: memory clock rate in Hz
 */
unsigned long mem_clk;
-#if defined(CONFIG_VIDEO)
+#if CONFIG_IS_ENABLED(VIDEO)
/**
 * @fb_base: base address of frame buffer memory
 */
@@ -359,7 +359,7 @@ struct global_data {
 */
struct membuff console_in;
 #endif
-#ifdef CONFIG_VIDEO
+#if CONFIG_IS_ENABLED(VIDEO)
/**
 * @video_top: top of video frame buffer area
 */
diff --git a/include/splash.h b/include/splash.h
index 33e45e6941..b6a100ffc3 100644
--- a/include/splash.h
+++ b/include/splash.h
@@ -49,7 +49,7 @@ struct splash_location {
char *ubivol;   /* UBI volume-name for ubifsmount */
 };
 
-#ifdef CONFIG_SPLASH_SOURCE
+#if CONFIG_IS_ENABLED(SPLASH_SOURCE)
 int splash_source_load(struct splash_location *locations, uint size);
 #else
 static inline int splash_source_load(struct splash_location *locations,
@@ -61,13 +61,13 @@ static inline int splash_source_load(struct splash_location 
*locations,
 
 int splash_screen_prepare(void);
 
-#ifdef CONFIG_SPLASH_SCREEN_ALIGN
+#if CONFIG_IS_ENABLED(SPLASH_SCREEN_ALIGN)
 void splash_get_pos(int *x, int *y);
 #else
 static inline void splash_get_pos(int *x, int *y) { }
 #endif
 
-#if defined(CONFIG_SPLASH_SCREEN) && defined(CONFIG_CMD_BMP)
+#if CONFIG_IS_ENABLED(SPLASH_SCREEN) && CONFIG_IS_ENABLED(BMP)
 int splash_display(void);
 #else
 static inline int splash_display(void)
-- 
2.34.1



[PATCH V8 11/14] common: Enable splash functions at SPL

2023-04-19 Thread Nikhil M Jain
To support splash screen at both u-boot proper and SPL use
CONFIG_IS_ENABLED and CONFIG_VAL to check for video related Kconfigs at
respective stages.

Replace CONFIG_CMD_BMP with CONFIG_BMP to enable splash_display function
at u-boot proper and SPL.

Signed-off-by: Nikhil M Jain 
Reviewed-by: Devarsh Thakkar 
Reviewed-by: Simon Glass 
---
V8:
- Update as per review comments.

V7:
- Add Reviewed-by tag.

V6:
- Fix commit message.
- Add Reviewed-by tag.

V5:
- Replace CONFIG_CMD_BMP with CONFIG_BMP.

V4:
- No change

V3 (patch introduced):
- Enable splash functions at SPL

 common/bmp.c| 10 +-
 common/splash.c | 10 +-
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/common/bmp.c b/common/bmp.c
index 4dbcb84893..ad91351f19 100644
--- a/common/bmp.c
+++ b/common/bmp.c
@@ -33,7 +33,7 @@
  * Returns NULL if decompression failed, or if the decompressed data
  * didn't contain a valid BMP signature.
  */
-#ifdef CONFIG_VIDEO_BMP_GZIP
+#if CONFIG_IS_ENABLED(VIDEO_BMP_GZIP)
 struct bmp_image *gunzip_bmp(unsigned long addr, unsigned long *lenp,
 void **alloc_addr)
 {
@@ -44,9 +44,9 @@ struct bmp_image *gunzip_bmp(unsigned long addr, unsigned 
long *lenp,
/*
 * Decompress bmp image
 */
-   len = CONFIG_VIDEO_LOGO_MAX_SIZE;
+   len = CONFIG_VAL(VIDEO_LOGO_MAX_SIZE);
/* allocate extra 3 bytes for 32-bit-aligned-address + 2 alignment */
-   dst = malloc(CONFIG_VIDEO_LOGO_MAX_SIZE + 3);
+   dst = malloc(CONFIG_VAL(VIDEO_LOGO_MAX_SIZE) + 3);
if (!dst) {
puts("Error: malloc in gunzip failed!\n");
return NULL;
@@ -55,12 +55,12 @@ struct bmp_image *gunzip_bmp(unsigned long addr, unsigned 
long *lenp,
/* align to 32-bit-aligned-address + 2 */
bmp = dst + 2;
 
-   if (gunzip(bmp, CONFIG_VIDEO_LOGO_MAX_SIZE, map_sysmem(addr, 0),
+   if (gunzip(bmp, CONFIG_VAL(VIDEO_LOGO_MAX_SIZE), map_sysmem(addr, 0),
   )) {
free(dst);
return NULL;
}
-   if (len == CONFIG_VIDEO_LOGO_MAX_SIZE)
+   if (len == CONFIG_VAL(VIDEO_LOGO_MAX_SIZE))
puts("Image could be truncated (increase 
CONFIG_VIDEO_LOGO_MAX_SIZE)!\n");
 
/*
diff --git a/common/splash.c b/common/splash.c
index 4bc54b1bf9..a4e68b7042 100644
--- a/common/splash.c
+++ b/common/splash.c
@@ -89,14 +89,14 @@ static inline int splash_video_logo_load(void) { return 
-ENOSYS; }
 
 __weak int splash_screen_prepare(void)
 {
-   if (IS_ENABLED(CONFIG_SPLASH_SOURCE))
+   if (CONFIG_IS_ENABLED(SPLASH_SOURCE))
return splash_source_load(default_splash_locations,
  ARRAY_SIZE(default_splash_locations));
 
return splash_video_logo_load();
 }
 
-#ifdef CONFIG_SPLASH_SCREEN_ALIGN
+#if CONFIG_IS_ENABLED(SPLASH_SCREEN_ALIGN)
 void splash_get_pos(int *x, int *y)
 {
char *s = env_get("splashpos");
@@ -119,7 +119,7 @@ void splash_get_pos(int *x, int *y)
 }
 #endif /* CONFIG_SPLASH_SCREEN_ALIGN */
 
-#if defined(CONFIG_VIDEO) && !defined(CONFIG_HIDE_LOGO_VERSION)
+#if CONFIG_IS_ENABLED(VIDEO) && !CONFIG_IS_ENABLED(HIDE_LOGO_VERSION)
 
 #ifdef CONFIG_VIDEO_LOGO
 #include 
@@ -159,7 +159,7 @@ void splash_display_banner(void)
  * Common function to show a splash image if env("splashimage") is set.
  * For additional details please refer to doc/README.splashprepare.
  */
-#if defined(CONFIG_SPLASH_SCREEN) && defined(CONFIG_CMD_BMP)
+#if CONFIG_IS_ENABLED(SPLASH_SCREEN) && CONFIG_IS_ENABLED(BMP)
 int splash_display(void)
 {
ulong addr;
@@ -183,7 +183,7 @@ int splash_display(void)
if (x || y)
goto end;
 
-#if defined(CONFIG_VIDEO) && !defined(CONFIG_HIDE_LOGO_VERSION)
+#if CONFIG_IS_ENABLED(VIDEO) && !CONFIG_IS_ENABLED(HIDE_LOGO_VERSION)
splash_display_banner();
 #endif
 end:
-- 
2.34.1



[PATCH V8 09/14] common: Makefile: Rule to compile bmp.c

2023-04-19 Thread Nikhil M Jain
Add rule to compile bmp.c at SPL and u-boot proper when CONFIG_SPL_BMP
and CONFIG_BMP are defined.

Signed-off-by: Nikhil M Jain 
Reviewed-by: Devarsh Thakkar 
Reviewed-by: Simon Glass 
Tested-by: Simon Glass 
---
V8:
- No change.

V7:
- Add Reviewed-by and Tested-by tag.

V6:
- Add Reviewed-by tag.

V5:
- Remove obj-y+= read.o.

V4:
- No change.

V3 (patch introduced):
- Rule to compile common/bmp.

 common/Makefile | 1 +
 1 file changed, 1 insertion(+)

diff --git a/common/Makefile b/common/Makefile
index 3a6ca337e0..c87bb2e78b 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -45,6 +45,7 @@ endif # !CONFIG_SPL_BUILD
 
 obj-$(CONFIG_$(SPL_TPL_)BOOTSTAGE) += bootstage.o
 obj-$(CONFIG_$(SPL_TPL_)BLOBLIST) += bloblist.o
+obj-$(CONFIG_$(SPL_)BMP) += bmp.o
 
 ifdef CONFIG_SPL_BUILD
 ifdef CONFIG_SPL_DFU
-- 
2.34.1



[PATCH V8 08/14] cmd: bmp: Split bmp commands and functions

2023-04-19 Thread Nikhil M Jain
To enable splash screen at SPL, need to compile cmd/bmp.c which also
includes bmp commands, since SPL doesn't use commands split bmp.c into
common/bmp.c which includes all bmp functions and cmd/bmp.c which only
contains bmp commands.

Add function delclaration for bmp_info in video.h.

Signed-off-by: Nikhil M Jain 
Reviewed-by: Simon Glass 
---
V8:
- No change.

V7:
- No change.

V6:
- Fix commit  message.
- Remove unused header files.

V5:
- Rename cmd/bmp_cmd to cmd/bmp.

V4:
- No change.

V3 (patch introduced):
- Split bmp functions and commands.

 cmd/bmp.c   | 162 +---
 common/bmp.c| 153 +
 include/video.h |   8 +++
 3 files changed, 163 insertions(+), 160 deletions(-)
 create mode 100644 common/bmp.c

diff --git a/cmd/bmp.c b/cmd/bmp.c
index 46d0d916e8..8f43a40daf 100644
--- a/cmd/bmp.c
+++ b/cmd/bmp.c
@@ -9,84 +9,12 @@
  */
 
 #include 
-#include 
 #include 
-#include 
-#include 
 #include 
-#include 
-#include 
 #include 
 #include 
 #include 
-#include 
-
-static int bmp_info (ulong addr);
-
-/*
- * Allocate and decompress a BMP image using gunzip().
- *
- * Returns a pointer to the decompressed image data. This pointer is
- * aligned to 32-bit-aligned-address + 2.
- * See doc/README.displaying-bmps for explanation.
- *
- * The allocation address is passed to 'alloc_addr' and must be freed
- * by the caller after use.
- *
- * Returns NULL if decompression failed, or if the decompressed data
- * didn't contain a valid BMP signature.
- */
-#ifdef CONFIG_VIDEO_BMP_GZIP
-struct bmp_image *gunzip_bmp(unsigned long addr, unsigned long *lenp,
-void **alloc_addr)
-{
-   void *dst;
-   unsigned long len;
-   struct bmp_image *bmp;
-
-   /*
-* Decompress bmp image
-*/
-   len = CONFIG_VIDEO_LOGO_MAX_SIZE;
-   /* allocate extra 3 bytes for 32-bit-aligned-address + 2 alignment */
-   dst = malloc(CONFIG_VIDEO_LOGO_MAX_SIZE + 3);
-   if (!dst) {
-   puts("Error: malloc in gunzip failed!\n");
-   return NULL;
-   }
-
-   /* align to 32-bit-aligned-address + 2 */
-   bmp = dst + 2;
-
-   if (gunzip(bmp, CONFIG_VIDEO_LOGO_MAX_SIZE, map_sysmem(addr, 0),
-  )) {
-   free(dst);
-   return NULL;
-   }
-   if (len == CONFIG_VIDEO_LOGO_MAX_SIZE)
-   puts("Image could be truncated (increase 
CONFIG_VIDEO_LOGO_MAX_SIZE)!\n");
-
-   /*
-* Check for bmp mark 'BM'
-*/
-   if (!((bmp->header.signature[0] == 'B') &&
- (bmp->header.signature[1] == 'M'))) {
-   free(dst);
-   return NULL;
-   }
-
-   debug("Gzipped BMP image detected!\n");
-
-   *alloc_addr = dst;
-   return bmp;
-}
-#else
-struct bmp_image *gunzip_bmp(unsigned long addr, unsigned long *lenp,
-void **alloc_addr)
-{
-   return NULL;
-}
-#endif
+#include 
 
 static int do_bmp_info(struct cmd_tbl *cmdtp, int flag, int argc,
   char *const argv[])
@@ -137,7 +65,7 @@ static int do_bmp_display(struct cmd_tbl *cmdtp, int flag, 
int argc,
return CMD_RET_USAGE;
}
 
-return (bmp_display(addr, x, y));
+   return (bmp_display(addr, x, y));
 }
 
 static struct cmd_tbl cmd_bmp_sub[] = {
@@ -145,22 +73,6 @@ static struct cmd_tbl cmd_bmp_sub[] = {
U_BOOT_CMD_MKENT(display, 5, 0, do_bmp_display, "", ""),
 };
 
-#ifdef CONFIG_NEEDS_MANUAL_RELOC
-void bmp_reloc(void) {
-   fixup_cmdtable(cmd_bmp_sub, ARRAY_SIZE(cmd_bmp_sub));
-}
-#endif
-
-/*
- * Subroutine:  do_bmp
- *
- * Description: Handler for 'bmp' command..
- *
- * Inputs: argv[1] contains the subcommand
- *
- * Return:  None
- *
- */
 static int do_bmp(struct cmd_tbl *cmdtp, int flag, int argc, char *const 
argv[])
 {
struct cmd_tbl *c;
@@ -183,73 +95,3 @@ U_BOOT_CMD(
"info   - display image info\n"
"bmp display  [x y] - display image at x,y"
 );
-
-/*
- * Subroutine:  bmp_info
- *
- * Description: Show information about bmp file in memory
- *
- * Inputs: addraddress of the bmp file
- *
- * Return:  None
- *
- */
-static int bmp_info(ulong addr)
-{
-   struct bmp_image *bmp = (struct bmp_image *)map_sysmem(addr, 0);
-   void *bmp_alloc_addr = NULL;
-   unsigned long len;
-
-   if (!((bmp->header.signature[0]=='B') &&
- (bmp->header.signature[1]=='M')))
-   bmp = gunzip_bmp(addr, , _alloc_addr);
-
-   if (bmp == NULL) {
-   printf("There is no valid bmp file at the given address\n");
-   return 1;
-   }
-
-   printf("Image size: %d x %d\n", le32_to_cpu(bmp->header.width),
-  le32_to_cpu(bmp->header.height));
-   printf("Bits per pixel: %d\n", le16_to_cpu(bmp->header.bit_count));
-   printf("Compression   : %d\n", 

[PATCH V8 10/14] drivers: video: Enable necessary video functions at SPL

2023-04-19 Thread Nikhil M Jain
To support video driver at SPL use CONFIG_IS_ENABLED and CONFIG_VAL,
which checks for stage specific configs and thus enables video support
at respective stage.

Signed-off-by: Nikhil M Jain 
Reviewed-by: Devarsh Thakkar 
Reviewed-by: Simon Glass 
Tested-by: Simon Glass 
---
V8:
- No change.

V7:
- Add Reviewed-by and Tested-by tag.

V6:
- No change.

V5:
- Add Reviewed-By tag.
- Use COFIG_IS_ENABLED in console_core in place of console_normal.

V4:
- No change.

V3 (patch introduced):
- Enable necessary video functions at SPL.

 drivers/video/console_core.c  |  6 +++---
 drivers/video/vidconsole-uclass.c |  2 +-
 drivers/video/video-uclass.c  | 14 +++---
 drivers/video/video_bmp.c |  8 
 4 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/drivers/video/console_core.c b/drivers/video/console_core.c
index d4f79c656a..1f93b1b85f 100644
--- a/drivers/video/console_core.c
+++ b/drivers/video/console_core.c
@@ -46,11 +46,11 @@ static int console_set_font(struct udevice *dev, struct 
video_fontdata *fontdata
 
 int check_bpix_support(int bpix)
 {
-   if (bpix == VIDEO_BPP8 && IS_ENABLED(CONFIG_VIDEO_BPP8))
+   if (bpix == VIDEO_BPP8 && CONFIG_IS_ENABLED(VIDEO_BPP8))
return 0;
-   else if (bpix == VIDEO_BPP16 && IS_ENABLED(CONFIG_VIDEO_BPP16))
+   else if (bpix == VIDEO_BPP16 && CONFIG_IS_ENABLED(VIDEO_BPP16))
return 0;
-   else if (bpix == VIDEO_BPP32 && IS_ENABLED(CONFIG_VIDEO_BPP32))
+   else if (bpix == VIDEO_BPP32 && CONFIG_IS_ENABLED(VIDEO_BPP32))
return 0;
else
return -ENOSYS;
diff --git a/drivers/video/vidconsole-uclass.c 
b/drivers/video/vidconsole-uclass.c
index 1225de2333..a21fde0e1d 100644
--- a/drivers/video/vidconsole-uclass.c
+++ b/drivers/video/vidconsole-uclass.c
@@ -86,7 +86,7 @@ static void vidconsole_newline(struct udevice *dev)
struct vidconsole_priv *priv = dev_get_uclass_priv(dev);
struct udevice *vid_dev = dev->parent;
struct video_priv *vid_priv = dev_get_uclass_priv(vid_dev);
-   const int rows = CONFIG_CONSOLE_SCROLL_LINES;
+   const int rows = CONFIG_VAL(CONSOLE_SCROLL_LINES);
int i, ret;
 
priv->xcur_frac = priv->xstart_frac;
diff --git a/drivers/video/video-uclass.c b/drivers/video/video-uclass.c
index da89f43144..8396bdfb11 100644
--- a/drivers/video/video-uclass.c
+++ b/drivers/video/video-uclass.c
@@ -132,7 +132,7 @@ int video_reserve(ulong *addrp)
 
/* Allocate space for PCI video devices in case there were not bound */
if (*addrp == gd->video_top)
-   *addrp -= CONFIG_VIDEO_PCI_DEFAULT_FB_SIZE;
+   *addrp -= CONFIG_VAL(VIDEO_PCI_DEFAULT_FB_SIZE);
 
gd->video_bottom = *addrp;
gd->fb_base = *addrp;
@@ -149,7 +149,7 @@ int video_fill(struct udevice *dev, u32 colour)
 
switch (priv->bpix) {
case VIDEO_BPP16:
-   if (IS_ENABLED(CONFIG_VIDEO_BPP16)) {
+   if (CONFIG_IS_ENABLED(VIDEO_BPP16)) {
u16 *ppix = priv->fb;
u16 *end = priv->fb + priv->fb_size;
 
@@ -158,7 +158,7 @@ int video_fill(struct udevice *dev, u32 colour)
break;
}
case VIDEO_BPP32:
-   if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
+   if (CONFIG_IS_ENABLED(VIDEO_BPP32)) {
u32 *ppix = priv->fb;
u32 *end = priv->fb + priv->fb_size;
 
@@ -212,14 +212,14 @@ u32 video_index_to_colour(struct video_priv *priv, 
unsigned int idx)
 {
switch (priv->bpix) {
case VIDEO_BPP16:
-   if (IS_ENABLED(CONFIG_VIDEO_BPP16)) {
+   if (CONFIG_IS_ENABLED(VIDEO_BPP16)) {
return ((colours[idx].r >> 3) << 11) |
   ((colours[idx].g >> 2) <<  5) |
   ((colours[idx].b >> 3) <<  0);
}
break;
case VIDEO_BPP32:
-   if (IS_ENABLED(CONFIG_VIDEO_BPP32)) {
+   if (CONFIG_IS_ENABLED(VIDEO_BPP32)) {
if (priv->format == VIDEO_X2R10G10B10)
return (colours[idx].r << 22) |
   (colours[idx].g << 12) |
@@ -513,8 +513,8 @@ static int video_post_probe(struct udevice *dev)
return ret;
}
 
-   if (IS_ENABLED(CONFIG_VIDEO_LOGO) &&
-   !IS_ENABLED(CONFIG_SPLASH_SCREEN) && !plat->hide_logo) {
+   if (CONFIG_IS_ENABLED(VIDEO_LOGO) &&
+   !CONFIG_IS_ENABLED(SPLASH_SCREEN) && !plat->hide_logo) {
ret = show_splash(dev);
if (ret) {
log_debug("Cannot show splash screen\n");
diff --git a/drivers/video/video_bmp.c b/drivers/video/video_bmp.c
index 6188a13e44..47e52c4f69 100644
--- a/drivers/video/video_bmp.c
+++ b/drivers/video/video_bmp.c
@@ -320,7 +320,7 @@ int 

[PATCH V8 05/14] drivers: video: tidss: Makefile: Add condition to compile TIDSS at SPL

2023-04-19 Thread Nikhil M Jain
To enable TIDSS driver only at SPL stage add rule to compile the TIDSS
video driver.

CONFIG_$(SPL_)VIDEO_TIDSS will compile tidss_drv, at SPL only if
CONFIG_SPL_VIDEO_TIDSS is defined and at u-boot proper if
CONFIG_VIDEO_TIDSS is defined.

Signed-off-by: Nikhil M Jain 
Reviewed-by: Simon Glass 
---
V8:
- No change.

V7:
- No change.

V6:
- No change.

V5:
- Use CONFIG_$(SPL_)VIDEO_TIDSS to build TIDSS driver at SPL and u-boot
  proper.

V4:
- Added Reviewed-by tag.

V3:
- No change.

V2:
- No change.

 drivers/video/Makefile   | 2 +-
 drivers/video/tidss/Makefile | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index ba2fd41865..c6a84581fc 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -32,7 +32,7 @@ obj-${CONFIG_EXYNOS_FB} += exynos/
 obj-${CONFIG_VIDEO_ROCKCHIP} += rockchip/
 obj-${CONFIG_VIDEO_STM32} += stm32/
 obj-${CONFIG_VIDEO_TEGRA124} += tegra124/
-obj-${CONFIG_VIDEO_TIDSS} += tidss/
+obj-${CONFIG_$(SPL_)VIDEO_TIDSS} += tidss/
 obj-y += ti/
 
 obj-$(CONFIG_ATMEL_HLCD) += atmel_hlcdfb.o
diff --git a/drivers/video/tidss/Makefile b/drivers/video/tidss/Makefile
index f4f8c6c470..a29cee2a41 100644
--- a/drivers/video/tidss/Makefile
+++ b/drivers/video/tidss/Makefile
@@ -9,4 +9,4 @@
 # Author: Tomi Valkeinen 
 
 
-obj-${CONFIG_VIDEO_TIDSS} = tidss_drv.o
+obj-${CONFIG_$(SPL_)VIDEO_TIDSS} = tidss_drv.o
-- 
2.34.1



[PATCH V8 06/14] common: Makefile: Add rule to compile splash and splash_source at SPL

2023-04-19 Thread Nikhil M Jain
To enable splash screen and loading bmp from boot media, add rules to
compile splash.c and splash_source.c at SPL stage only when
CONFIG_SPL_SPLASH_SCREEN and CONFIG_SPL_SPLASH_SOURCE are defined.

Signed-off-by: Nikhil M Jain 
Reviewed-by: Devarsh Thakkar 
Reviewed-by: Simon Glass 
---
V8:
- No change.

V7:
- Add Reviewed-by tag.

V6:
- Add Reviewed-by tag.

V5:
- No change.

V4:
- No change.

 common/Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/common/Makefile b/common/Makefile
index a50302d8b5..3a6ca337e0 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -56,6 +56,8 @@ obj-$(CONFIG_$(SPL_TPL_)OF_LIBFDT) += fdt_support.o
 obj-$(CONFIG_SPL_USB_HOST) += usb.o usb_hub.o
 obj-$(CONFIG_SPL_USB_STORAGE) += usb_storage.o
 obj-$(CONFIG_SPL_MUSB_NEW) += usb.o
+obj-$(CONFIG_SPL_SPLASH_SCREEN) += splash.o
+obj-$(CONFIG_SPL_SPLASH_SOURCE) += splash_source.o
 endif # CONFIG_SPL_BUILD
 
 #others
-- 
2.34.1



[PATCH V8 07/14] common: Kconfig: Add BMP configs

2023-04-19 Thread Nikhil M Jain
Add CONFIG_BMP and CONFIG_SPL_BMP which enable displaying bmp images at
u-boot proper and SPL.

Signed-off-by: Nikhil M Jain 
Reviewed-by: Simon Glass 
Reviewed-by: Devarsh Thakkar 
---
V8:
- No change.

V7:
- No change.

V6:
- Added Reviewed-by tag.

V5:
- Added Reviewed-by tag.

V4:
- No change.

 common/Kconfig | 12 
 1 file changed, 12 insertions(+)

diff --git a/common/Kconfig b/common/Kconfig
index 7ff62552cb..7329dc8253 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -1154,3 +1154,15 @@ config FDT_SIMPLEFB
 
 config IO_TRACE
bool
+
+config BMP
+   bool "Enable bmp image display"
+   default y if CMD_BMP
+   help
+ Enable bmp functions to display bmp image and get bmp info.
+
+config SPL_BMP
+   bool "Enable bmp image display at  SPL"
+   depends on SPL_VIDEO
+   help
+ Enable bmp functions to display bmp image and get bmp info at SPL.
-- 
2.34.1



[PATCH V8 04/14] drivers: video: Makefile: Rule to compile necessary video driver files

2023-04-19 Thread Nikhil M Jain
To enable video driver at SPL, need to compile video-uclass,
vidconsole-uclass, backlight-uclass, panel-uclass, simple-panel, add
rules to compile them at SPL and u-boot proper. To support
splash_display at SPL, need to compile video-bmp, add rule to compile at
SPL and u-boot proper.

Signed-off-by: Nikhil M Jain 
Reviewed-by: Devarsh Thakkar 
Reviewed-by: Simon Glass 
Tested-by: Simon Glass 
---
V8:
- No chage.

V7:
- Add Reviewed-by and Tested-by tag.

V6:
- Fix CONFIG_$(SPL_TPL)CONSOLE_NORMAL to CONFIG_$(SPL_TPL_)CONSOLE_NORMAL
- Add rule to compile simple_panel at SPL and u-boot proper.

V5:
- Use $(SPL_TPL_) to check for stage specific configs and compile at
  specific stages.
- Removed ifdef CONFIG_SPL_BUILD.

V4:
- No change.

V3:
- Rule to compile backlight, console and panel files.
- Not added Reiewed-by tag due to changes.

V2:
- No change.

 drivers/video/Makefile | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index cb3f373645..ba2fd41865 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -4,12 +4,12 @@
 # Wolfgang Denk, DENX Software Engineering, w...@denx.de.
 
 ifdef CONFIG_DM
-obj-$(CONFIG_BACKLIGHT) += backlight-uclass.o
+obj-$(CONFIG_$(SPL_TPL_)BACKLIGHT) += backlight-uclass.o
 obj-$(CONFIG_BACKLIGHT_GPIO) += backlight_gpio.o
 obj-$(CONFIG_BACKLIGHT_PWM) += pwm_backlight.o
-obj-$(CONFIG_CONSOLE_NORMAL) += console_normal.o
+obj-$(CONFIG_$(SPL_TPL_)CONSOLE_NORMAL) += console_normal.o
 obj-$(CONFIG_CONSOLE_ROTATION) += console_rotate.o
-ifdef CONFIG_CONSOLE_NORMAL
+ifdef CONFIG_$(SPL_TPL_)CONSOLE_NORMAL
 obj-y += console_core.o
 else ifdef CONFIG_CONSOLE_ROTATION
 obj-y += console_core.o
@@ -18,11 +18,11 @@ obj-$(CONFIG_CONSOLE_ROTATION) += console_core.o
 obj-$(CONFIG_CONSOLE_TRUETYPE) += console_truetype.o fonts/
 obj-$(CONFIG_DISPLAY) += display-uclass.o
 obj-$(CONFIG_VIDEO_MIPI_DSI) += dsi-host-uclass.o
-obj-$(CONFIG_VIDEO) += video-uclass.o vidconsole-uclass.o
-obj-$(CONFIG_VIDEO) += video_bmp.o
-obj-$(CONFIG_PANEL) += panel-uclass.o
+obj-$(CONFIG_$(SPL_TPL_)VIDEO) += video-uclass.o vidconsole-uclass.o
+obj-$(CONFIG_$(SPL_TPL_)VIDEO) += video_bmp.o
+obj-$(CONFIG_$(SPL_TPL_)PANEL) += panel-uclass.o
 obj-$(CONFIG_PANEL_HX8238D) += hx8238d.o
-obj-$(CONFIG_SIMPLE_PANEL) += simple_panel.o
+obj-$(CONFIG_$(SPL_TPL_)SIMPLE_PANEL) += simple_panel.o
 
 obj-$(CONFIG_VIDEO_LOGO) += u_boot_logo.o
 
-- 
2.34.1



  1   2   >