RE: [EXT] [PATCH v11 01/14] crypto/fsl: Add support for CAAM Job ring driver model

2022-04-12 Thread Gaurav Jain
Hi Priyanka

Stefano has applied the patches for imx.
Please help to apply the layerscape patches.

Regards
Gaurav Jain

> -Original Message-
> From: sba...@denx.de 
> Sent: Tuesday, April 12, 2022 7:05 PM
> To: Gaurav Jain ; u-boot@lists.denx.de
> Subject: [EXT] [PATCH v11 01/14] crypto/fsl: Add support for CAAM Job ring
> driver model
> 
> Caution: EXT Email
> 
> > added device tree support for job ring driver.
> > sec is initialized based on job ring information processed from device
> > tree.
> > Signed-off-by: Gaurav Jain 
> > Reviewed-by: Ye Li 
> > Reviewed-by: Simon Glass 
> Applied to u-boot-imx, master, thanks !
> 
> Best regards,
> Stefano Babic
> 
> --
> 
> =
> DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
> 
> =


RE: [PATCH V3 0/6] Convert COUNTER_FREQUENCY to CONFIG_COUNTER_FREQUENCY

2022-04-12 Thread Peng Fan
> Subject: [PATCH V3 0/6] Convert COUNTER_FREQUENCY to
> CONFIG_COUNTER_FREQUENCY

Seems I need post a V4, some arm64 boards are not handled by my
script.

Sorry for re-spin so fast.

Thanks,
Peng.

> 
> From: Peng Fan 
> 
> 
> V3:
>  Add more help info for CONFIG_COUNTER_FREQUENCY  Drop uneeded
> comments  Pass git bisect build  Rebased
> 
> V2:
>  Drop imx93 which is wrongly included
> 
> This patchset is to convert COUNTER_FREQUENCY to
> CONFIG_COUNTER_FREQUENCY for arm64. arm32 is not included for now, this
> could be in following up patches if this patchset is accepted.
> 
> This patchset touches lots of boards, so please help review.
> 
> 
> Peng Fan (6):
>   xilinx: versal: board: use CONFIG_COUNTER_FREQUENCY
>   arch: arm: move COUNTER_FREQUENCY from versal to arm
>   arch: arm: Kconfig: set default COUNTER_FREQUENCY for i.MX
>   configs: set CONFIG_COUNTER_FREQUENCY
>   armv8: set cntfrq_el0 if CONFIG_COUNTER_FREQUENCY is valid
>   include/configs: drop COUNTER_FREQUENCY
> 
>  arch/arm/Kconfig  | 13 +
>  arch/arm/cpu/armv8/fsl-layerscape/spintable.S |  2 +-
>  arch/arm/cpu/armv8/start.S|  4 ++--
>  arch/arm/mach-versal/Kconfig  |  6 --
>  board/xilinx/versal/board.c   |  2 +-
>  configs/a3y17lte_defconfig|  1 +
>  configs/a5y17lte_defconfig|  1 +
>  configs/a7y17lte_defconfig|  1 +
>  configs/apalis-imx8_defconfig |  1 +
>  configs/apalis-imx8x_defconfig|  1 +
>  configs/bubblegum_96_defconfig|  1 +
>  configs/cgtqmx8_defconfig |  1 +
>  configs/colibri-imx8x_defconfig   |  1 +
>  configs/cortina_presidio-asic-base_defconfig  |  1 +  
> configs/cortina_presidio-
> asic-emmc_defconfig  |  1 +  configs/cortina_presidio-asic-pnand_defconfig |  
> 1
> +
>  configs/cubieboard7_defconfig |  1 +
>  configs/deneb_defconfig   |  1 +
>  configs/dragonboard410c_defconfig |  1 +
>  configs/dragonboard820c_defconfig |  1 +
>  configs/espresso7420_defconfig|  1 +
>  configs/evb-px30_defconfig|  1 +
>  configs/evb-px5_defconfig |  1 +
>  configs/evb-rk3308_defconfig  |  1 +
>  configs/evb-rk3328_defconfig  |  1 +
>  configs/evb-rk3399_defconfig  |  1 +
>  configs/evb-rk3568_defconfig  |  1 +
>  configs/firefly-px30_defconfig|  1 +
>  configs/firefly-rk3399_defconfig  |  1 +
>  configs/hihope_rzg2_defconfig |  1 +
>  configs/hikey960_defconfig|  1 +
>  configs/hikey_defconfig   |  1 +
>  configs/imx8qm_mek_defconfig  |  1 +
>  configs/imx8qm_rom7720_a1_4G_defconfig|  1 +
>  configs/imx8qxp_mek_defconfig |  1 +
>  configs/khadas-edge-captain-rk3399_defconfig  |  1 +
>  configs/khadas-edge-rk3399_defconfig  |  1 +
>  configs/khadas-edge-v-rk3399_defconfig|  1 +
>  configs/leez-rk3399_defconfig |  1 +
>  configs/ls1012a2g5rdb_qspi_defconfig  |  1 +
>  configs/ls1012a2g5rdb_tfa_defconfig   |  1 +
>  configs/ls1043aqds_defconfig  |  1 +
>  configs/ls1043aqds_lpuart_defconfig   |  1 +
>  configs/ls1043aqds_nand_defconfig |  1 +
>  configs/ls1043aqds_nor_ddr3_defconfig |  1 +
>  configs/ls1043aqds_qspi_defconfig |  1 +
>  configs/ls1043aqds_sdcard_ifc_defconfig   |  1 +
>  configs/ls1043aqds_sdcard_qspi_defconfig  |  1 +
>  configs/ls1043aqds_tfa_SECURE_BOOT_defconfig  |  1 +
>  configs/ls1043aqds_tfa_defconfig  |  1 +
>  configs/ls1046afrwy_tfa_SECURE_BOOT_defconfig |  1 +
>  configs/ls1046afrwy_tfa_defconfig |  1 +
>  configs/mt8183_pumpkin_defconfig  |  1 +
>  configs/mt8512_bm1_emmc_defconfig |  1 +
>  configs/mt8516_pumpkin_defconfig  |  1 +
>  configs/mt8518_ap1_emmc_defconfig |  1 +
>  configs/nanopc-t4-rk3399_defconfig|  1 +
>  configs/nanopi-m4-2gb-rk3399_defconfig|  1 +
>  configs/nanopi-m4-rk3399_defconfig|  1 +
>  configs/nanopi-m4b-rk3399_defconfig   |  1 +
>  configs/nanopi-neo4-rk3399_defconfig  |  1 +
>  configs/nanopi-r2s-rk3328_defconfig   |  1 +
>  configs/nanopi-r4s-rk3399_defconfig   |  1 +
>  configs/orangepi-rk3399_defconfig |  1 +
>  configs/p2371-2180_defconfig  |  1 +
>  configs/p2771--000_defconfig  |  1 +
>  configs/p2771--500_defconfig  |  1 +
>  configs/p3450-_defconfig  |  1 +
>  configs/r8a77970_eagle_defconfig  |  1 +
>  configs/r8a77980_condor_defconfig |  1 +
>  configs/r8a77990_ebisu_defconfig  |  

Re: [PATCH v2 17/17] configs: net: dm9000: Move new Kconfig option to board configs

2022-04-12 Thread Ramon Fried
On Wed, Apr 13, 2022 at 5:16 AM Marek Vasut  wrote:
>
> Drop legacy #define CONFIG_DRIVER_DM9000 from board include/configs/
> and enable the same in Kconfig configs/ .
>
> Signed-off-by: Marek Vasut 
> Cc: Joe Hershberger 
> Cc: Ramon Fried 
> ---
> V2: New patch
> ---
>  configs/M5253DEMO_defconfig   | 1 +
>  configs/at91sam9261ek_dataflash_cs0_defconfig | 1 +
>  configs/at91sam9261ek_dataflash_cs3_defconfig | 1 +
>  configs/at91sam9261ek_nandflash_defconfig | 1 +
>  configs/ci20_mmc_defconfig| 1 +
>  configs/colibri_pxa270_defconfig  | 1 +
>  configs/devkit8000_defconfig  | 1 +
>  include/configs/M5253DEMO.h   | 1 -
>  include/configs/at91sam9261ek.h   | 1 -
>  include/configs/ci20.h| 1 -
>  include/configs/colibri_pxa270.h  | 1 -
>  include/configs/devkit8000.h  | 1 -
>  scripts/config_whitelist.txt  | 1 -
>  13 files changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/configs/M5253DEMO_defconfig b/configs/M5253DEMO_defconfig
> index a072f9663e9..6f69acaee16 100644
> --- a/configs/M5253DEMO_defconfig
> +++ b/configs/M5253DEMO_defconfig
> @@ -37,4 +37,5 @@ CONFIG_SYS_I2C_SLAVE=0x7F
>  CONFIG_SYS_I2C_SPEED=8
>  CONFIG_MTD_NOR_FLASH=y
>  CONFIG_USE_SYS_MAX_FLASH_BANKS=y
> +CONFIG_DRIVER_DM9000=y
>  CONFIG_MCFUART=y
> diff --git a/configs/at91sam9261ek_dataflash_cs0_defconfig 
> b/configs/at91sam9261ek_dataflash_cs0_defconfig
> index c43a8a58db7..2f6651e4fb9 100644
> --- a/configs/at91sam9261ek_dataflash_cs0_defconfig
> +++ b/configs/at91sam9261ek_dataflash_cs0_defconfig
> @@ -53,6 +53,7 @@ CONFIG_NAND_ATMEL=y
>  CONFIG_DM_SPI_FLASH=y
>  CONFIG_SPI_FLASH_ATMEL=y
>  CONFIG_SPI_FLASH_DATAFLASH=y
> +CONFIG_DRIVER_DM9000=y
>  CONFIG_PINCTRL=y
>  CONFIG_PINCTRL_AT91=y
>  CONFIG_DM_SERIAL=y
> diff --git a/configs/at91sam9261ek_dataflash_cs3_defconfig 
> b/configs/at91sam9261ek_dataflash_cs3_defconfig
> index baf527ff32d..99fecc5aef5 100644
> --- a/configs/at91sam9261ek_dataflash_cs3_defconfig
> +++ b/configs/at91sam9261ek_dataflash_cs3_defconfig
> @@ -53,6 +53,7 @@ CONFIG_NAND_ATMEL=y
>  CONFIG_DM_SPI_FLASH=y
>  CONFIG_SPI_FLASH_ATMEL=y
>  CONFIG_SPI_FLASH_DATAFLASH=y
> +CONFIG_DRIVER_DM9000=y
>  CONFIG_PINCTRL=y
>  CONFIG_PINCTRL_AT91=y
>  CONFIG_DM_SERIAL=y
> diff --git a/configs/at91sam9261ek_nandflash_defconfig 
> b/configs/at91sam9261ek_nandflash_defconfig
> index 482a37d6a55..71127466208 100644
> --- a/configs/at91sam9261ek_nandflash_defconfig
> +++ b/configs/at91sam9261ek_nandflash_defconfig
> @@ -51,6 +51,7 @@ CONFIG_NAND_ATMEL=y
>  CONFIG_DM_SPI_FLASH=y
>  CONFIG_SPI_FLASH_ATMEL=y
>  CONFIG_SPI_FLASH_DATAFLASH=y
> +CONFIG_DRIVER_DM9000=y
>  CONFIG_PINCTRL=y
>  CONFIG_PINCTRL_AT91=y
>  CONFIG_DM_SERIAL=y
> diff --git a/configs/ci20_mmc_defconfig b/configs/ci20_mmc_defconfig
> index ed1ca2c7cdb..bcbfaad8ca8 100644
> --- a/configs/ci20_mmc_defconfig
> +++ b/configs/ci20_mmc_defconfig
> @@ -49,6 +49,7 @@ CONFIG_MMC_UHS_SUPPORT=y
>  CONFIG_MMC_HS400_SUPPORT=y
>  # CONFIG_MMC_VERBOSE is not set
>  CONFIG_JZ47XX_MMC=y
> +CONFIG_DRIVER_DM9000=y
>  CONFIG_DM_SERIAL=y
>  CONFIG_SYS_NS16550=y
>  CONFIG_SPL_TINY_MEMSET=y
> diff --git a/configs/colibri_pxa270_defconfig 
> b/configs/colibri_pxa270_defconfig
> index 9ce65861046..0a7a2a3bd58 100644
> --- a/configs/colibri_pxa270_defconfig
> +++ b/configs/colibri_pxa270_defconfig
> @@ -50,6 +50,7 @@ CONFIG_FLASH_CFI_DRIVER=y
>  CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y
>  CONFIG_SYS_FLASH_PROTECTION=y
>  CONFIG_SYS_FLASH_CFI=y
> +CONFIG_DRIVER_DM9000=y
>  CONFIG_DM_SERIAL=y
>  CONFIG_PXA_SERIAL=y
>  CONFIG_USB=y
> diff --git a/configs/devkit8000_defconfig b/configs/devkit8000_defconfig
> index e009f21ecd6..2bff7dfbf42 100644
> --- a/configs/devkit8000_defconfig
> +++ b/configs/devkit8000_defconfig
> @@ -57,6 +57,7 @@ CONFIG_SYS_NAND_OOBSIZE=0x40
>  CONFIG_SYS_NAND_BUSWIDTH_16BIT=y
>  CONFIG_SYS_NAND_U_BOOT_LOCATIONS=y
>  CONFIG_SYS_NAND_U_BOOT_OFFS=0x8
> +CONFIG_DRIVER_DM9000=y
>  CONFIG_CONS_INDEX=3
>  CONFIG_JFFS2_NAND=y
>  CONFIG_OF_LIBFDT=y
> diff --git a/include/configs/M5253DEMO.h b/include/configs/M5253DEMO.h
> index b7fdd7135f2..079675be5bc 100644
> --- a/include/configs/M5253DEMO.h
> +++ b/include/configs/M5253DEMO.h
> @@ -25,7 +25,6 @@
>  #  undef CONFIG_LBA48
>  #endif
>
> -#define CONFIG_DRIVER_DM9000
>  #ifdef CONFIG_DRIVER_DM9000
>  #  define CONFIG_DM9000_BASE   (CONFIG_SYS_CS1_BASE | 0x300)
>  #  define DM9000_IOCONFIG_DM9000_BASE
> diff --git a/include/configs/at91sam9261ek.h b/include/configs/at91sam9261ek.h
> index 55ddb38c70a..2089fe52e45 100644
> --- a/include/configs/at91sam9261ek.h
> +++ b/include/configs/at91sam9261ek.h
> @@ -44,7 +44,6 @@
>  #endif
>
>  /* Ethernet */
> -#define CONFIG_DRIVER_DM9000
>  #define CONFIG_DM9000_BASE 0x3000
>  #define DM9000_IO  CONFIG_DM9000_BASE
>  #define DM9000_DATA

Re: [PATCH V2] imx: mx7dsabresd: enable DM_SERIAL

2022-04-12 Thread Peng Fan (OSS)




On 2022/4/12 18:16, Fabio Estevam wrote:

On Mon, Apr 11, 2022 at 10:32 PM Peng Fan (OSS)  wrote:


+ {
+   u-boot,dm-pre-reloc;
+};
+
+&{/soc/bus@3080/spba-bus@3080} {


 would be easier to read.


There is no alias to spba-bus@3080.




+_lpsr {
+   u-boot,dm-pre-reloc;
+};
+
+&{/soc/bus@3000/iomuxc@3033/imx7d-sdb} {


 would be easier to read.


There is no alias to imx7d-sdb




  int board_early_init_f(void)
  {
-   setup_iomux_uart();
-
 return 0;


After this change board_early_init_f() is unnecessary. Please remove it.


Sure.

Thanks,
Peng.





Re: [PATCH v3 11/19] dm: disk: add UCLASS_PARTITION

2022-04-12 Thread AKASHI Takahiro
Heinrich,
(and Simon)

On Sat, Apr 09, 2022 at 09:05:07PM +0200, Heinrich Schuchardt wrote:
> On 3/8/22 12:36, AKASHI Takahiro wrote:
> > With this new function, UCLASS_PARTITION devices will be created as
> > child nodes of UCLASS_BLK device.
> > 
> > Signed-off-by: AKASHI Takahiro 
> > ---
> >   disk/Makefile  |   3 +
> >   disk/disk-uclass.c | 153 +
> >   include/dm/uclass-id.h |   1 +
> >   include/part.h |  11 +++
> >   4 files changed, 168 insertions(+)
> >   create mode 100644 disk/disk-uclass.c
> > 
> > diff --git a/disk/Makefile b/disk/Makefile
> > index 6ce5a687b36c..ec37b74f5f40 100644
> > --- a/disk/Makefile
> > +++ b/disk/Makefile
> > @@ -6,6 +6,9 @@
> >   #ccflags-y += -DET_DEBUG -DDEBUG
> > 
> >   obj-$(CONFIG_PARTITIONS)  += part.o
> > +ifdef CONFIG_$(SPL_)BLK
> > +obj-$(CONFIG_PARTITIONS)   += disk-uclass.o
> 
> phycore-rk3288_defconfig has CONFIG_SPL_LIBDISK_SUPPORT=n ("Support disk
> partitions").

I think that SPL_LIBDISK_SUPPORT no longer make any sense and is obsolete.

> But spl/disk/disk-uclass is built.

Right, but what is strange is:
- SPL_PARTITION is enabled by "default y if PARTITONS", while
- none of any particular partition types is enabled for spl
  due to *explicit* disablement of
 # CONFIG_SPL_DOS_PARTITION is not set
 # CONFIG_SPL_EFI_PARTITION is not set
  in phycore-rk3288_defconfig.

I think that disk/Kconfig should be revised.

-Takahiro Akashi

> This leads to an unnecessary size increase of the SPL image.
> With this size increase building fails.
> 
> Best regards
> 
> Heinrich
> 
> > +endif
> >   obj-$(CONFIG_$(SPL_)MAC_PARTITION)   += part_mac.o
> >   obj-$(CONFIG_$(SPL_)DOS_PARTITION)   += part_dos.o
> >   obj-$(CONFIG_$(SPL_)ISO_PARTITION)   += part_iso.o
> > diff --git a/disk/disk-uclass.c b/disk/disk-uclass.c
> > new file mode 100644
> > index ..4918a2f72d1e
> > --- /dev/null
> > +++ b/disk/disk-uclass.c
> > @@ -0,0 +1,153 @@
> > +// SPDX-License-Identifier: GPL-2.0+
> > +/*
> > + *  Software partition device (UCLASS_PARTITION)
> > + *
> > + *  Copyright (c) 2021 Linaro Limited
> > + * Author: AKASHI Takahiro
> > + */
> > +
> > +#define LOG_CATEGORY UCLASS_PARTITION
> > +
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +#include 
> > +
> > +int part_create_block_devices(struct udevice *blk_dev)
> > +{
> > +   int part, count;
> > +   struct blk_desc *desc = dev_get_uclass_plat(blk_dev);
> > +   struct disk_partition info;
> > +   struct disk_part *part_data;
> > +   char devname[32];
> > +   struct udevice *dev;
> > +   int ret;
> > +
> > +   if (!CONFIG_IS_ENABLED(PARTITIONS) ||
> > +   !CONFIG_IS_ENABLED(HAVE_BLOCK_DEVICE))
> > +   return 0;
> > +
> > +   if (device_get_uclass_id(blk_dev) != UCLASS_BLK)
> > +   return 0;
> > +
> > +   /* Add devices for each partition */
> > +   for (count = 0, part = 1; part <= MAX_SEARCH_PARTITIONS; part++) {
> > +   if (part_get_info(desc, part, ))
> > +   continue;
> > +   snprintf(devname, sizeof(devname), "%s:%d", blk_dev->name,
> > +part);
> > +
> > +   ret = device_bind_driver(blk_dev, "blk_partition",
> > +strdup(devname), );
> > +   if (ret)
> > +   return ret;
> > +
> > +   part_data = dev_get_uclass_plat(dev);
> > +   part_data->partnum = part;
> > +   part_data->gpt_part_info = info;
> > +   count++;
> > +
> > +   ret = device_probe(dev);
> > +   if (ret) {
> > +   debug("Can't probe\n");
> > +   count--;
> > +   device_unbind(dev);
> > +
> > +   continue;
> > +   }
> > +   }
> > +   debug("%s: %d partitions found in %s\n", __func__, count,
> > + blk_dev->name);
> > +
> > +   return 0;
> > +}
> > +
> > +static ulong blk_part_read(struct udevice *dev, lbaint_t start,
> > +  lbaint_t blkcnt, void *buffer)
> > +{
> > +   struct udevice *parent;
> > +   struct disk_part *part;
> > +   const struct blk_ops *ops;
> > +
> > +   parent = dev_get_parent(dev);
> > +   ops = blk_get_ops(parent);
> > +   if (!ops->read)
> > +   return -ENOSYS;
> > +
> > +   part = dev_get_uclass_plat(dev);
> > +   if (start >= part->gpt_part_info.size)
> > +   return 0;
> > +
> > +   if ((start + blkcnt) > part->gpt_part_info.size)
> > +   blkcnt = part->gpt_part_info.size - start;
> > +   start += part->gpt_part_info.start;
> > +
> > +   return ops->read(parent, start, blkcnt, buffer);
> > +}
> > +
> > +static ulong blk_part_write(struct udevice *dev, lbaint_t start,
> > +   lbaint_t blkcnt, const void *buffer)
> > +{
> > +   struct udevice *parent;
> > +   struct disk_part *part;
> > +   const struct blk_ops *ops;
> > +
> > +   parent = dev_get_parent(dev);
> > +   ops = 

Re: [PATCH V2 19/26] imx: imx8ulp_evk: Power down the domains may used in u-boot

2022-04-12 Thread Peng Fan (OSS)

Hi Stefano,

On 2022/4/13 1:10, Stefano Babic wrote:

Hi Peng,Ye,

On 06.04.22 08:30, Peng Fan (OSS) wrote:

From: Ye Li 

Since ATF power domain will hold the enable counter for each power domain,
We need to power off them before entering kernel to avoid this
power domain can't be really powered off.

Signed-off-by: Ye Li 
Signed-off-by: Peng Fan 
---
   board/freescale/imx8ulp_evk/imx8ulp_evk.c | 30 +++
   1 file changed, 30 insertions(+)

diff --git a/board/freescale/imx8ulp_evk/imx8ulp_evk.c 
b/board/freescale/imx8ulp_evk/imx8ulp_evk.c
index b61a4cfbe8d..1bd308148f3 100644
--- a/board/freescale/imx8ulp_evk/imx8ulp_evk.c
+++ b/board/freescale/imx8ulp_evk/imx8ulp_evk.c
@@ -13,6 +13,8 @@
   #include 
   #include 
   #include 
+#include 
+#include 


But which patch is adding the file above ? I cannot find it, it is not
part of this series and of course build is broken without it.


V5 patchset should not have such issue. I just see you already picked up 
V5 in your repo.


Thanks,
Peng.



Best regards,
Stefano


   DECLARE_GLOBAL_DATA_PTR;
   
@@ -129,3 +131,31 @@ int board_late_init(void)

   {
return 0;
   }
+
+void board_quiesce_devices(void)
+{
+   /* Disable the power domains may used in u-boot before entering kernel 
*/
+#if CONFIG_IS_ENABLED(POWER_DOMAIN)
+   struct udevice *scmi_devpd;
+   int ret, i;
+   struct power_domain pd;
+   ulong ids[] = { IMX8ULP_PD_FLEXSPI2, IMX8ULP_PD_USB0, IMX8ULP_PD_USDHC0,
+   IMX8ULP_PD_USDHC1, IMX8ULP_PD_USDHC2_USB1, 
IMX8ULP_PD_DCNANO,
+   IMX8ULP_PD_MIPI_DSI };
+
+   ret = uclass_get_device(UCLASS_POWER_DOMAIN, 0, _devpd);
+   if (ret) {
+   printf("Cannot get scmi devpd: err=%d\n", ret);
+   return;
+   }
+
+   pd.dev = scmi_devpd;
+
+   for (i = 0; i < ARRAY_SIZE(ids); i++) {
+   pd.id = ids[i];
+   ret = power_domain_off();
+   if (ret)
+   printf("power_domain_off %lu failed: err=%d\n", ids[i], 
ret);
+   }
+#endif
+}




[PATCH] ram: stm32mp1: Conditionally enable ASR

2022-04-12 Thread Marek Vasut
Enable DRAM ASR, auto self-refresh, conditionally, based on DT property
"st,mem-enable-asr" . While ASR does save considerable amount of power
at runtime automatically, it also causes LTDC underruns on large panels.
Let user select whether or not ASR is required or not, generally ASR
should be enabled on portable and battery operated devices.

Signed-off-by: Marek Vasut 
Cc: Patrick Delaunay 
Cc: Patrice Chotard 
---
 drivers/ram/stm32mp1/stm32mp1_ddr.c | 3 ++-
 drivers/ram/stm32mp1/stm32mp1_ddr.h | 1 +
 drivers/ram/stm32mp1/stm32mp1_ram.c | 1 +
 3 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/ram/stm32mp1/stm32mp1_ddr.c 
b/drivers/ram/stm32mp1/stm32mp1_ddr.c
index 528a171b454..fd11e02aff4 100644
--- a/drivers/ram/stm32mp1/stm32mp1_ddr.c
+++ b/drivers/ram/stm32mp1/stm32mp1_ddr.c
@@ -845,7 +845,8 @@ start:
 config->c_reg.pwrctl);
 
 /* Enable auto-self-refresh, which saves a bit of power at runtime. */
-   stm32mp1_asr_enable(priv);
+   if (config->info.enable_asr)
+   stm32mp1_asr_enable(priv);
 
/* enable uMCTL2 AXI port 0 and 1 */
setbits_le32(>ctl->pctrl_0, DDRCTRL_PCTRL_N_PORT_EN);
diff --git a/drivers/ram/stm32mp1/stm32mp1_ddr.h 
b/drivers/ram/stm32mp1/stm32mp1_ddr.h
index 861efff92be..c74a9cea2cc 100644
--- a/drivers/ram/stm32mp1/stm32mp1_ddr.h
+++ b/drivers/ram/stm32mp1/stm32mp1_ddr.h
@@ -144,6 +144,7 @@ struct stm32mp1_ddr_info {
const char *name;
u32 speed; /* in kHZ */
u32 size;  /* memory size in byte = col * row * width */
+   bool enable_asr;
 };
 
 struct stm32mp1_ddr_config {
diff --git a/drivers/ram/stm32mp1/stm32mp1_ram.c 
b/drivers/ram/stm32mp1/stm32mp1_ram.c
index 49b1262461b..f39cfad4764 100644
--- a/drivers/ram/stm32mp1/stm32mp1_ram.c
+++ b/drivers/ram/stm32mp1/stm32mp1_ram.c
@@ -122,6 +122,7 @@ static int stm32mp1_ddr_setup(struct udevice *dev)
config.info.speed = ofnode_read_u32_default(node, "st,mem-speed", 0);
config.info.size = ofnode_read_u32_default(node, "st,mem-size", 0);
config.info.name = ofnode_read_string(node, "st,mem-name");
+   config.info.enable_asr = ofnode_read_bool(node, "st,mem-enable-asr");
if (!config.info.name) {
dev_dbg(dev, "no st,mem-name\n");
return -EINVAL;
-- 
2.35.1



[PATCH V3 4/6] configs: set CONFIG_COUNTER_FREQUENCY

2022-04-12 Thread Peng Fan (OSS)
From: Peng Fan 

Set CONFIG_COUNTER_FREQUENCY according to COUNTER_FREQUENCY in
config header file.

Signed-off-by: Peng Fan 
---
 configs/a3y17lte_defconfig| 1 +
 configs/a5y17lte_defconfig| 1 +
 configs/a7y17lte_defconfig| 1 +
 configs/apalis-imx8_defconfig | 1 +
 configs/apalis-imx8x_defconfig| 1 +
 configs/bubblegum_96_defconfig| 1 +
 configs/cgtqmx8_defconfig | 1 +
 configs/colibri-imx8x_defconfig   | 1 +
 configs/cortina_presidio-asic-base_defconfig  | 1 +
 configs/cortina_presidio-asic-emmc_defconfig  | 1 +
 configs/cortina_presidio-asic-pnand_defconfig | 1 +
 configs/cubieboard7_defconfig | 1 +
 configs/deneb_defconfig   | 1 +
 configs/dragonboard410c_defconfig | 1 +
 configs/dragonboard820c_defconfig | 1 +
 configs/espresso7420_defconfig| 1 +
 configs/evb-px30_defconfig| 1 +
 configs/evb-px5_defconfig | 1 +
 configs/evb-rk3308_defconfig  | 1 +
 configs/evb-rk3328_defconfig  | 1 +
 configs/evb-rk3399_defconfig  | 1 +
 configs/evb-rk3568_defconfig  | 1 +
 configs/firefly-px30_defconfig| 1 +
 configs/firefly-rk3399_defconfig  | 1 +
 configs/hihope_rzg2_defconfig | 1 +
 configs/hikey960_defconfig| 1 +
 configs/hikey_defconfig   | 1 +
 configs/imx8qm_mek_defconfig  | 1 +
 configs/imx8qm_rom7720_a1_4G_defconfig| 1 +
 configs/imx8qxp_mek_defconfig | 1 +
 configs/khadas-edge-captain-rk3399_defconfig  | 1 +
 configs/khadas-edge-rk3399_defconfig  | 1 +
 configs/khadas-edge-v-rk3399_defconfig| 1 +
 configs/leez-rk3399_defconfig | 1 +
 configs/ls1012a2g5rdb_qspi_defconfig  | 1 +
 configs/ls1012a2g5rdb_tfa_defconfig   | 1 +
 configs/ls1043aqds_defconfig  | 1 +
 configs/ls1043aqds_lpuart_defconfig   | 1 +
 configs/ls1043aqds_nand_defconfig | 1 +
 configs/ls1043aqds_nor_ddr3_defconfig | 1 +
 configs/ls1043aqds_qspi_defconfig | 1 +
 configs/ls1043aqds_sdcard_ifc_defconfig   | 1 +
 configs/ls1043aqds_sdcard_qspi_defconfig  | 1 +
 configs/ls1043aqds_tfa_SECURE_BOOT_defconfig  | 1 +
 configs/ls1043aqds_tfa_defconfig  | 1 +
 configs/ls1046afrwy_tfa_SECURE_BOOT_defconfig | 1 +
 configs/ls1046afrwy_tfa_defconfig | 1 +
 configs/mt8183_pumpkin_defconfig  | 1 +
 configs/mt8512_bm1_emmc_defconfig | 1 +
 configs/mt8516_pumpkin_defconfig  | 1 +
 configs/mt8518_ap1_emmc_defconfig | 1 +
 configs/nanopc-t4-rk3399_defconfig| 1 +
 configs/nanopi-m4-2gb-rk3399_defconfig| 1 +
 configs/nanopi-m4-rk3399_defconfig| 1 +
 configs/nanopi-m4b-rk3399_defconfig   | 1 +
 configs/nanopi-neo4-rk3399_defconfig  | 1 +
 configs/nanopi-r2s-rk3328_defconfig   | 1 +
 configs/nanopi-r4s-rk3399_defconfig   | 1 +
 configs/orangepi-rk3399_defconfig | 1 +
 configs/p2371-2180_defconfig  | 1 +
 configs/p2771--000_defconfig  | 1 +
 configs/p2771--500_defconfig  | 1 +
 configs/p3450-_defconfig  | 1 +
 configs/r8a77970_eagle_defconfig  | 1 +
 configs/r8a77980_condor_defconfig | 1 +
 configs/r8a77990_ebisu_defconfig  | 1 +
 configs/r8a77995_draak_defconfig  | 1 +
 configs/r8a779a0_falcon_defconfig | 1 +
 configs/rcar3_salvator-x_defconfig| 1 +
 configs/rcar3_ulcb_defconfig  | 1 +
 configs/roc-cc-rk3328_defconfig   | 1 +
 configs/rock-pi-4-rk3399_defconfig| 1 +
 configs/rock-pi-4c-rk3399_defconfig   | 1 +
 configs/rock-pi-e-rk3328_defconfig| 1 +
 configs/rock-pi-n10-rk3399pro_defconfig   | 1 +
 configs/rock64-rk3328_defconfig   | 1 +
 configs/silinux_ek874_defconfig   | 1 +
 configs/socfpga_agilex_atf_defconfig  | 1 +
 configs/socfpga_agilex_defconfig  | 1 +
 configs/socfpga_agilex_vab_defconfig  | 1 +
 configs/starqltechn_defconfig | 1 +
 configs/ten64_tfa_defconfig   | 1 +
 configs/thunderx_88xx_defconfig   | 1 +
 configs/vexpress_aemv8a_juno_defconfig| 1 +
 configs/vexpress_aemv8a_semi_defconfig| 1 +
 configs/vexpress_aemv8r_defconfig | 1 +
 86 files changed, 86 insertions(+)

diff --git a/configs/a3y17lte_defconfig b/configs/a3y17lte_defconfig
index 7ca7ce0daf2..8081168371b 100644
--- a/configs/a3y17lte_defconfig
+++ b/configs/a3y17lte_defconfig
@@ -1,6 +1,7 @@
 CONFIG_ARM=y
 CONFIG_SYS_CONFIG_NAME="exynos78x0-common"
 

Re: [PATCH] Revert "env: Load env when ENV_IS_NOWHERE is only location selected"

2022-04-12 Thread Felix . Vietmeyer
I am not exactly sure to be honest. We were running with this patched
version for a while and it worked from what I remember.

But we have since updated u-boot and the Kernel and the latest version
does not depend on this patch.

Nevertheless, I can try to recreate the problem and see if I can figure it
out now. I feel like I might pick up on a few more things now that went
unnoticed by me when I created the patch.

> On 4/10/22 13:54, felix.vietme...@jila.colorado.edu wrote:
>>>From your description it seems like the board I was working on must have
>> had an environment on NOR or eMMC which could be loaded but did not
>> allow
>> the board to come up.
>> Then, the patch forces u-boot to use the default environment despite an
>> existing env on NOR or eMMC.
>
> I suspect the board must have some other problem with the environment.
> I just cannot tell what it is. This is using some downstream U-Boot
> fork, right ? Can you reproduce the problem in mainline too ? How ?
>




[PATCH] cmd: adc: Add support for storing ADC result in env variable

2022-04-12 Thread Marek Vasut
Add the ability to start ADC conversion result in an environment
variable. This is useful for further arbitrary processing by the
U-Boot scripts.

Signed-off-by: Marek Vasut 
Cc: Fabrice Gasnier 
Cc: Simon Glass 
---
 cmd/adc.c | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/cmd/adc.c b/cmd/adc.c
index 75739bc8eed..4f548b811ec 100644
--- a/cmd/adc.c
+++ b/cmd/adc.c
@@ -71,6 +71,7 @@ static int do_adc_info(struct cmd_tbl *cmdtp, int flag, int 
argc,
 static int do_adc_single(struct cmd_tbl *cmdtp, int flag, int argc,
 char *const argv[])
 {
+   char *varname = NULL;
struct udevice *dev;
unsigned int data;
int ret, uV;
@@ -78,6 +79,9 @@ static int do_adc_single(struct cmd_tbl *cmdtp, int flag, int 
argc,
if (argc < 3)
return CMD_RET_USAGE;
 
+   if (argc >= 3)
+   varname = argv[2];
+
ret = adc_channel_single_shot(argv[1], simple_strtol(argv[2], NULL, 0),
  );
if (ret) {
@@ -92,6 +96,13 @@ static int do_adc_single(struct cmd_tbl *cmdtp, int flag, 
int argc,
else
printf("%u\n", data);
 
+   if (varname) {
+   if (!adc_raw_to_uV(dev, data, ))
+   env_set_ulong(varname, uV);
+   else
+   env_set_ulong(varname, data);
+   }
+
return CMD_RET_SUCCESS;
 }
 
@@ -149,7 +160,7 @@ static int do_adc_scan(struct cmd_tbl *cmdtp, int flag, int 
argc,
 static char adc_help_text[] =
"list - list ADC devices\n"
"adc info  - Get ADC device info\n"
-   "adc single   - Get Single data of ADC device channel\n"
+   "adc single   [varname] - Get Single data of ADC device 
channel\n"
"adc scan  [channel mask] - Scan all [or masked] ADC channels";
 
 U_BOOT_CMD_WITH_SUBCMDS(adc, "ADC sub-system", adc_help_text,
-- 
2.35.1



[PATCH v2 17/17] configs: net: dm9000: Move new Kconfig option to board configs

2022-04-12 Thread Marek Vasut
Drop legacy #define CONFIG_DRIVER_DM9000 from board include/configs/
and enable the same in Kconfig configs/ .

Signed-off-by: Marek Vasut 
Cc: Joe Hershberger 
Cc: Ramon Fried 
---
V2: New patch
---
 configs/M5253DEMO_defconfig   | 1 +
 configs/at91sam9261ek_dataflash_cs0_defconfig | 1 +
 configs/at91sam9261ek_dataflash_cs3_defconfig | 1 +
 configs/at91sam9261ek_nandflash_defconfig | 1 +
 configs/ci20_mmc_defconfig| 1 +
 configs/colibri_pxa270_defconfig  | 1 +
 configs/devkit8000_defconfig  | 1 +
 include/configs/M5253DEMO.h   | 1 -
 include/configs/at91sam9261ek.h   | 1 -
 include/configs/ci20.h| 1 -
 include/configs/colibri_pxa270.h  | 1 -
 include/configs/devkit8000.h  | 1 -
 scripts/config_whitelist.txt  | 1 -
 13 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/configs/M5253DEMO_defconfig b/configs/M5253DEMO_defconfig
index a072f9663e9..6f69acaee16 100644
--- a/configs/M5253DEMO_defconfig
+++ b/configs/M5253DEMO_defconfig
@@ -37,4 +37,5 @@ CONFIG_SYS_I2C_SLAVE=0x7F
 CONFIG_SYS_I2C_SPEED=8
 CONFIG_MTD_NOR_FLASH=y
 CONFIG_USE_SYS_MAX_FLASH_BANKS=y
+CONFIG_DRIVER_DM9000=y
 CONFIG_MCFUART=y
diff --git a/configs/at91sam9261ek_dataflash_cs0_defconfig 
b/configs/at91sam9261ek_dataflash_cs0_defconfig
index c43a8a58db7..2f6651e4fb9 100644
--- a/configs/at91sam9261ek_dataflash_cs0_defconfig
+++ b/configs/at91sam9261ek_dataflash_cs0_defconfig
@@ -53,6 +53,7 @@ CONFIG_NAND_ATMEL=y
 CONFIG_DM_SPI_FLASH=y
 CONFIG_SPI_FLASH_ATMEL=y
 CONFIG_SPI_FLASH_DATAFLASH=y
+CONFIG_DRIVER_DM9000=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_AT91=y
 CONFIG_DM_SERIAL=y
diff --git a/configs/at91sam9261ek_dataflash_cs3_defconfig 
b/configs/at91sam9261ek_dataflash_cs3_defconfig
index baf527ff32d..99fecc5aef5 100644
--- a/configs/at91sam9261ek_dataflash_cs3_defconfig
+++ b/configs/at91sam9261ek_dataflash_cs3_defconfig
@@ -53,6 +53,7 @@ CONFIG_NAND_ATMEL=y
 CONFIG_DM_SPI_FLASH=y
 CONFIG_SPI_FLASH_ATMEL=y
 CONFIG_SPI_FLASH_DATAFLASH=y
+CONFIG_DRIVER_DM9000=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_AT91=y
 CONFIG_DM_SERIAL=y
diff --git a/configs/at91sam9261ek_nandflash_defconfig 
b/configs/at91sam9261ek_nandflash_defconfig
index 482a37d6a55..71127466208 100644
--- a/configs/at91sam9261ek_nandflash_defconfig
+++ b/configs/at91sam9261ek_nandflash_defconfig
@@ -51,6 +51,7 @@ CONFIG_NAND_ATMEL=y
 CONFIG_DM_SPI_FLASH=y
 CONFIG_SPI_FLASH_ATMEL=y
 CONFIG_SPI_FLASH_DATAFLASH=y
+CONFIG_DRIVER_DM9000=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_AT91=y
 CONFIG_DM_SERIAL=y
diff --git a/configs/ci20_mmc_defconfig b/configs/ci20_mmc_defconfig
index ed1ca2c7cdb..bcbfaad8ca8 100644
--- a/configs/ci20_mmc_defconfig
+++ b/configs/ci20_mmc_defconfig
@@ -49,6 +49,7 @@ CONFIG_MMC_UHS_SUPPORT=y
 CONFIG_MMC_HS400_SUPPORT=y
 # CONFIG_MMC_VERBOSE is not set
 CONFIG_JZ47XX_MMC=y
+CONFIG_DRIVER_DM9000=y
 CONFIG_DM_SERIAL=y
 CONFIG_SYS_NS16550=y
 CONFIG_SPL_TINY_MEMSET=y
diff --git a/configs/colibri_pxa270_defconfig b/configs/colibri_pxa270_defconfig
index 9ce65861046..0a7a2a3bd58 100644
--- a/configs/colibri_pxa270_defconfig
+++ b/configs/colibri_pxa270_defconfig
@@ -50,6 +50,7 @@ CONFIG_FLASH_CFI_DRIVER=y
 CONFIG_SYS_FLASH_USE_BUFFER_WRITE=y
 CONFIG_SYS_FLASH_PROTECTION=y
 CONFIG_SYS_FLASH_CFI=y
+CONFIG_DRIVER_DM9000=y
 CONFIG_DM_SERIAL=y
 CONFIG_PXA_SERIAL=y
 CONFIG_USB=y
diff --git a/configs/devkit8000_defconfig b/configs/devkit8000_defconfig
index e009f21ecd6..2bff7dfbf42 100644
--- a/configs/devkit8000_defconfig
+++ b/configs/devkit8000_defconfig
@@ -57,6 +57,7 @@ CONFIG_SYS_NAND_OOBSIZE=0x40
 CONFIG_SYS_NAND_BUSWIDTH_16BIT=y
 CONFIG_SYS_NAND_U_BOOT_LOCATIONS=y
 CONFIG_SYS_NAND_U_BOOT_OFFS=0x8
+CONFIG_DRIVER_DM9000=y
 CONFIG_CONS_INDEX=3
 CONFIG_JFFS2_NAND=y
 CONFIG_OF_LIBFDT=y
diff --git a/include/configs/M5253DEMO.h b/include/configs/M5253DEMO.h
index b7fdd7135f2..079675be5bc 100644
--- a/include/configs/M5253DEMO.h
+++ b/include/configs/M5253DEMO.h
@@ -25,7 +25,6 @@
 #  undef CONFIG_LBA48
 #endif
 
-#define CONFIG_DRIVER_DM9000
 #ifdef CONFIG_DRIVER_DM9000
 #  define CONFIG_DM9000_BASE   (CONFIG_SYS_CS1_BASE | 0x300)
 #  define DM9000_IOCONFIG_DM9000_BASE
diff --git a/include/configs/at91sam9261ek.h b/include/configs/at91sam9261ek.h
index 55ddb38c70a..2089fe52e45 100644
--- a/include/configs/at91sam9261ek.h
+++ b/include/configs/at91sam9261ek.h
@@ -44,7 +44,6 @@
 #endif
 
 /* Ethernet */
-#define CONFIG_DRIVER_DM9000
 #define CONFIG_DM9000_BASE 0x3000
 #define DM9000_IO  CONFIG_DM9000_BASE
 #define DM9000_DATA(CONFIG_DM9000_BASE + 4)
diff --git a/include/configs/ci20.h b/include/configs/ci20.h
index ea9440dac07..cc70a59e728 100644
--- a/include/configs/ci20.h
+++ b/include/configs/ci20.h
@@ -24,7 +24,6 @@
 #define CONFIG_SYS_NS16550_CLK 4800
 
 /* Ethernet: davicom DM9000 */
-#define 

[PATCH v2 16/17] net: dm9000: Add Kconfig entry

2022-04-12 Thread Marek Vasut
Add Kconfig entry for the DM9000 MAC.

Reviewed-by: Ramon Fried 
Signed-off-by: Marek Vasut 
Cc: Joe Hershberger 
Cc: Ramon Fried 
---
V2: Add RB from Ramon
---
 drivers/net/Kconfig | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index a6171a7c7ff..347fe8aa425 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -191,6 +191,11 @@ config CALXEDA_XGMAC
  This driver supports the XGMAC in Calxeda Highbank and Midway
  machines.
 
+config DRIVER_DM9000
+   bool "Davicom DM9000 controller driver"
+   help
+ The Davicom DM9000 parallel bus external ethernet interface chip.
+
 config DWC_ETH_QOS
bool "Synopsys DWC Ethernet QOS device support"
depends on DM_ETH
-- 
2.35.1



[PATCH v2 06/17] net: dm9000: Drop volatiles

2022-04-12 Thread Marek Vasut
Remove volatile keyword usage from arrays, they are not really volatile
in any way, so this keyword is misused here. No functional change.

Reviewed-by: Ramon Fried 
Signed-off-by: Marek Vasut 
Cc: Joe Hershberger 
Cc: Ramon Fried 
---
V2: Add RB from Ramon
---
 drivers/net/dm9000x.c | 20 ++--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/net/dm9000x.c b/drivers/net/dm9000x.c
index da16b64610b..aacf5f670e9 100644
--- a/drivers/net/dm9000x.c
+++ b/drivers/net/dm9000x.c
@@ -71,7 +71,7 @@ typedef struct board_info {
u8 phy_addr;
u8 device_wait_reset;   /* device state */
unsigned char srom[128];
-   void (*outblk)(volatile void *data_ptr, int count);
+   void (*outblk)(void *data_ptr, int count);
void (*inblk)(void *data_ptr, int count);
void (*rx_status)(u16 *rxstatus, u16 *rxlen);
struct eth_device netdev;
@@ -88,12 +88,12 @@ static void dm9000_iow(int reg, u8 value);
 
 /* DM9000 network board routine  */
 #ifndef CONFIG_DM9000_BYTE_SWAPPED
-#define dm9000_outb(d,r) writeb(d, (volatile u8 *)(r))
-#define dm9000_outw(d,r) writew(d, (volatile u16 *)(r))
-#define dm9000_outl(d,r) writel(d, (volatile u32 *)(r))
-#define dm9000_inb(r) readb((volatile u8 *)(r))
-#define dm9000_inw(r) readw((volatile u16 *)(r))
-#define dm9000_inl(r) readl((volatile u32 *)(r))
+#define dm9000_outb(d,r) writeb((d), (r))
+#define dm9000_outw(d,r) writew((d), (r))
+#define dm9000_outl(d,r) writel((d), (r))
+#define dm9000_inb(r) readb(r)
+#define dm9000_inw(r) readw(r)
+#define dm9000_inl(r) readl(r)
 #else
 #define dm9000_outb(d, r) __raw_writeb(d, r)
 #define dm9000_outw(d, r) __raw_writew(d, r)
@@ -122,14 +122,14 @@ static void dm9000_dump_packet(const char *func, u8 
*packet, int length)
 static void dm9000_dump_packet(const char *func, u8 *packet, int length) {}
 #endif
 
-static void dm9000_outblk_8bit(volatile void *data_ptr, int count)
+static void dm9000_outblk_8bit(void *data_ptr, int count)
 {
int i;
for (i = 0; i < count; i++)
dm9000_outbu8 *) data_ptr)[i] & 0xff), DM9000_DATA);
 }
 
-static void dm9000_outblk_16bit(volatile void *data_ptr, int count)
+static void dm9000_outblk_16bit(void *data_ptr, int count)
 {
int i;
u32 tmplen = (count + 1) / 2;
@@ -137,7 +137,7 @@ static void dm9000_outblk_16bit(volatile void *data_ptr, 
int count)
for (i = 0; i < tmplen; i++)
dm9000_outw(((u16 *) data_ptr)[i], DM9000_DATA);
 }
-static void dm9000_outblk_32bit(volatile void *data_ptr, int count)
+static void dm9000_outblk_32bit(void *data_ptr, int count)
 {
int i;
u32 tmplen = (count + 3) / 4;
-- 
2.35.1



[PATCH v2 14/17] net: dm9000: Receive one packet per recv call

2022-04-12 Thread Marek Vasut
Instead of reading out the entire FIFO and possibly overwriting U-Boot
memory, read out one packet per recv call, pass it to U-Boot network
stack, and repeat.

Reviewed-by: Ramon Fried 
Signed-off-by: Marek Vasut 
Cc: Joe Hershberger 
Cc: Ramon Fried 
---
V2: Add RB from Ramon
---
 drivers/net/dm9000x.c | 102 +-
 1 file changed, 50 insertions(+), 52 deletions(-)

diff --git a/drivers/net/dm9000x.c b/drivers/net/dm9000x.c
index 639977ad6e6..6552079748a 100644
--- a/drivers/net/dm9000x.c
+++ b/drivers/net/dm9000x.c
@@ -481,10 +481,9 @@ static void dm9000_halt_common(struct dm9000_priv *db)
 /*
  * Received a packet and pass to upper layer
  */
-static int dm9000_recv_common(struct dm9000_priv *db)
+static int dm9000_recv_common(struct dm9000_priv *db, uchar *rdptr)
 {
u8 rxbyte;
-   u8 *rdptr = (u8 *)net_rx_packets[0];
u16 rxstatus, rxlen = 0;
 
/*
@@ -497,58 +496,52 @@ static int dm9000_recv_common(struct dm9000_priv *db)
dm9000_iow(db, DM9000_ISR, 0x01); /* clear PR status latched in bit 0 */
 
/* There is _at least_ 1 package in the fifo, read them all */
-   for (;;) {
-   dm9000_ior(db, DM9000_MRCMDX);  /* Dummy read */
-
-   /*
-* Get most updated data,
-* only look at bits 0:1, See application notes DM9000
-*/
-   rxbyte = dm9000_inb(db->base_data) & 0x03;
-
-   /* Status check: this byte must be 0 or 1 */
-   if (rxbyte > DM9000_PKT_RDY) {
-   dm9000_iow(db, DM9000_RCR, 0x00);   /* Stop Device 
*/
-   dm9000_iow(db, DM9000_ISR, 0x80);   /* Stop INT 
request */
-   printf("DM9000 error: status check fail: 0x%x\n",
-  rxbyte);
-   return 0;
-   }
+   dm9000_ior(db, DM9000_MRCMDX);  /* Dummy read */
+
+   /*
+* Get most updated data,
+* only look at bits 0:1, See application notes DM9000
+*/
+   rxbyte = dm9000_inb(db->base_data) & 0x03;
+
+   /* Status check: this byte must be 0 or 1 */
+   if (rxbyte > DM9000_PKT_RDY) {
+   dm9000_iow(db, DM9000_RCR, 0x00);   /* Stop Device */
+   dm9000_iow(db, DM9000_ISR, 0x80);   /* Stop INT request */
+   printf("DM9000 error: status check fail: 0x%x\n",
+  rxbyte);
+   return -EINVAL;
+   }
+
+   if (rxbyte != DM9000_PKT_RDY)
+   return 0; /* No packet received, ignore */
 
-   if (rxbyte != DM9000_PKT_RDY)
-   return 0; /* No packet received, ignore */
-
-   debug("receiving packet\n");
-
-   /* A packet ready now  & Get status/length */
-   db->rx_status(db, , );
-
-   debug("rx status: 0x%04x rx len: %d\n", rxstatus, rxlen);
-
-   /* Move data from DM9000 */
-   /* Read received packet from RX SRAM */
-   db->inblk(db, rdptr, rxlen);
-
-   if (rxstatus & 0xbf00 || rxlen < 0x40 ||
-   rxlen > DM9000_PKT_MAX) {
-   if (rxstatus & 0x100)
-   printf("rx fifo error\n");
-   if (rxstatus & 0x200)
-   printf("rx crc error\n");
-   if (rxstatus & 0x8000)
-   printf("rx length error\n");
-   if (rxlen > DM9000_PKT_MAX) {
-   printf("rx length too big\n");
-   dm9000_reset(db);
-   }
-   } else {
-   dm9000_dump_packet(__func__, rdptr, rxlen);
-
-   debug("passing packet to upper layer\n");
-   net_process_received_packet(net_rx_packets[0], rxlen);
+   debug("receiving packet\n");
+
+   /* A packet ready now  & Get status/length */
+   db->rx_status(db, , );
+
+   debug("rx status: 0x%04x rx len: %d\n", rxstatus, rxlen);
+
+   /* Move data from DM9000 */
+   /* Read received packet from RX SRAM */
+   db->inblk(db, rdptr, rxlen);
+
+   if (rxstatus & 0xbf00 || rxlen < 0x40 || rxlen > DM9000_PKT_MAX) {
+   if (rxstatus & 0x100)
+   printf("rx fifo error\n");
+   if (rxstatus & 0x200)
+   printf("rx crc error\n");
+   if (rxstatus & 0x8000)
+   printf("rx length error\n");
+   if (rxlen > DM9000_PKT_MAX) {
+   printf("rx length too big\n");
+   dm9000_reset(db);
}
+   return -EINVAL;
}
-   return 0;
+
+   return rxlen;
 }
 
 /*
@@ -600,8 +593,13 @@ static int dm9000_send(struct eth_device *dev, void 
*packet, int length)
 static int 

[PATCH v2 15/17] net: dm9000: Add DM support

2022-04-12 Thread Marek Vasut
Add support for U-Boot DM and DT probing.

Reviewed-by: Ramon Fried 
Signed-off-by: Marek Vasut 
Cc: Joe Hershberger 
Cc: Ramon Fried 
---
V2: Add RB from Ramon
---
 drivers/net/dm9000x.c | 118 ++
 1 file changed, 118 insertions(+)

diff --git a/drivers/net/dm9000x.c b/drivers/net/dm9000x.c
index 6552079748a..78ce536d4a3 100644
--- a/drivers/net/dm9000x.c
+++ b/drivers/net/dm9000x.c
@@ -51,6 +51,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -74,7 +75,9 @@ struct dm9000_priv {
void (*outblk)(struct dm9000_priv *db, void *data_ptr, int count);
void (*inblk)(struct dm9000_priv *db, void *data_ptr, int count);
void (*rx_status)(struct dm9000_priv *db, u16 *rxstatus, u16 *rxlen);
+#ifndef CONFIG_DM_ETH
struct eth_device dev;
+#endif
void __iomem *base_io;
void __iomem *base_data;
 };
@@ -569,6 +572,7 @@ static void dm9000_get_enetaddr(struct dm9000_priv *db, u8 
*enetaddr)
 static void dm9000_get_enetaddr(struct dm9000_priv *db, u8 *enetaddr) {}
 #endif
 
+#ifndef CONFIG_DM_ETH
 static int dm9000_init(struct eth_device *dev, struct bd_info *bd)
 {
struct dm9000_priv *db = container_of(dev, struct dm9000_priv, dev);
@@ -629,3 +633,117 @@ int dm9000_initialize(struct bd_info *bis)
 
return 0;
 }
+#else  /* ifdef CONFIG_DM_ETH */
+static int dm9000_start(struct udevice *dev)
+{
+   struct dm9000_priv *db = dev_get_priv(dev);
+   struct eth_pdata *pdata = dev_get_plat(dev);
+
+   return dm9000_init_common(db, pdata->enetaddr);
+}
+
+static void dm9000_stop(struct udevice *dev)
+{
+   struct dm9000_priv *db = dev_get_priv(dev);
+
+   dm9000_halt_common(db);
+}
+
+static int dm9000_send(struct udevice *dev, void *packet, int length)
+{
+   struct dm9000_priv *db = dev_get_priv(dev);
+   int ret;
+
+   ret = dm9000_send_common(db, packet, length);
+
+   return ret ? 0 : -ETIMEDOUT;
+}
+
+static int dm9000_recv(struct udevice *dev, int flags, uchar **packetp)
+{
+   struct dm9000_priv *db = dev_get_priv(dev);
+   uchar *data = net_rx_packets[0];
+   int ret;
+
+   ret = dm9000_recv_common(db, data);
+   if (ret)
+   *packetp = (void *)data;
+
+   return ret ? ret : -EAGAIN;
+}
+
+static int dm9000_write_hwaddr(struct udevice *dev)
+{
+   struct dm9000_priv *db = dev_get_priv(dev);
+   struct eth_pdata *pdata = dev_get_plat(dev);
+   int i, oft;
+
+   /* fill device MAC address registers */
+   for (i = 0, oft = DM9000_PAR; i < 6; i++, oft++)
+   dm9000_iow(db, oft, pdata->enetaddr[i]);
+
+   for (i = 0, oft = 0x16; i < 8; i++, oft++)
+   dm9000_iow(db, oft, 0xff);
+
+   /* read back mac, just to be sure */
+   for (i = 0, oft = 0x10; i < 6; i++, oft++)
+   debug("%02x:", dm9000_ior(db, oft));
+
+   debug("\n");
+
+   return 0;
+}
+
+static int dm9000_read_rom_hwaddr(struct udevice *dev)
+{
+   struct dm9000_priv *db = dev_get_priv(dev);
+   struct eth_pdata *pdata = dev_get_plat(dev);
+
+   dm9000_get_enetaddr(db, pdata->enetaddr);
+
+   return !is_valid_ethaddr(pdata->enetaddr);
+}
+
+static int dm9000_bind(struct udevice *dev)
+{
+   return device_set_name(dev, dev->name);
+}
+
+static int dm9000_of_to_plat(struct udevice *dev)
+{
+   struct dm9000_priv *db = dev_get_priv(dev);
+   struct eth_pdata *pdata = dev_get_plat(dev);
+
+   pdata->iobase = dev_read_addr_index(dev, 0);
+   db->base_io = (void __iomem *)pdata->iobase;
+   db->base_data = (void __iomem *)dev_read_addr_index(dev, 1);
+
+   return 0;
+}
+
+static const struct eth_ops dm9000_ops = {
+   .start  = dm9000_start,
+   .stop   = dm9000_stop,
+   .send   = dm9000_send,
+   .recv   = dm9000_recv,
+   .write_hwaddr   = dm9000_write_hwaddr,
+   .read_rom_hwaddr = dm9000_read_rom_hwaddr,
+};
+
+static const struct udevice_id dm9000_ids[] = {
+   { .compatible = "davicom,dm9000" },
+   { }
+};
+
+U_BOOT_DRIVER(dm9000) = {
+   .name   = "eth_dm9000",
+   .id = UCLASS_ETH,
+   .of_match   = dm9000_ids,
+   .bind   = dm9000_bind,
+   .of_to_plat = dm9000_of_to_plat,
+   .ops= _ops,
+   .priv_auto  = sizeof(struct dm9000_priv),
+   .plat_auto  = sizeof(struct eth_pdata),
+   .flags  = DM_FLAG_ALLOC_PRIV_DMA,
+};
+#endif
-- 
2.35.1



[PATCH v2 07/17] net: dm9000: Checkpatch cleanup

2022-04-12 Thread Marek Vasut
Fix checkpatch errors and warnings. No functional change.

Reviewed-by: Ramon Fried 
Signed-off-by: Marek Vasut 
Cc: Joe Hershberger 
Cc: Ramon Fried 
---
V2: Add RB from Ramon
---
 drivers/net/dm9000x.c | 251 +-
 1 file changed, 126 insertions(+), 125 deletions(-)

diff --git a/drivers/net/dm9000x.c b/drivers/net/dm9000x.c
index aacf5f670e9..becf7aec828 100644
--- a/drivers/net/dm9000x.c
+++ b/drivers/net/dm9000x.c
@@ -1,53 +1,53 @@
 // SPDX-License-Identifier: GPL-2.0+
 /*
-  dm9000.c: Version 1.2 12/15/2003
-
-   A Davicom DM9000 ISA NIC fast Ethernet driver for Linux.
-   Copyright (C) 1997  Sten Wang
-
-  (C)Copyright 1997-1998 DAVICOM Semiconductor,Inc. All Rights Reserved.
-
-V0.11  06/20/2001  REG_0A bit3=1, default enable BP with DA match
-   06/22/2001  Support DM9801 progrmming
-   E3: R25 = ((R24 + NF) & 0x00ff) | 0xf000
-   E4: R25 = ((R24 + NF) & 0x00ff) | 0xc200
-   R17 = (R17 & 0xfff0) | NF + 3
-   E5: R25 = ((R24 + NF - 3) & 0x00ff) | 0xc200
-   R17 = (R17 & 0xfff0) | NF
-
-v1.00  modify by simon 2001.9.5
-   change for kernel 2.4.x
-
-v1.1   11/09/2001  fix force mode bug
-
-v1.2   03/18/2003   Weilun Huang :
-   Fixed phy reset.
-   Added tx/rx 32 bit mode.
-   Cleaned up for kernel merge.
-
---
-
-   12/15/2003   Initial port to u-boot by
-   Sascha Hauer 
-
-   06/03/2008  Remy Bohmer 
-   - Fixed the driver to work with DM9000A.
- (check on ISR receive status bit before reading the
- FIFO as described in DM9000 programming guide and
- application notes)
-   - Added autodetect of databus width.
-   - Made debug code compile again.
-   - Adapt eth_send such that it matches the DM9000*
- application notes. Needed to make it work properly
- for DM9000A.
-   - Adapted reset procedure to match DM9000 application
- notes (i.e. double reset)
-   - some minor code cleanups
-   These changes are tested with DM9000{A,EP,E} together
-   with a 200MHz Atmel AT91SAM9261 core
-
-TODO: external MII is not functional, only internal at the moment.
-*/
+ *   dm9000.c: Version 1.2 12/15/2003
+ *
+ * A Davicom DM9000 ISA NIC fast Ethernet driver for Linux.
+ * Copyright (C) 1997  Sten Wang
+ *
+ *   (C)Copyright 1997-1998 DAVICOM Semiconductor,Inc. All Rights Reserved.
+ *
+ * V0.11   06/20/2001  REG_0A bit3=1, default enable BP with DA match
+ * 06/22/2001  Support DM9801 progrmming
+ * E3: R25 = ((R24 + NF) & 0x00ff) | 0xf000
+ * E4: R25 = ((R24 + NF) & 0x00ff) | 0xc200
+ * R17 = (R17 & 0xfff0) | NF + 3
+ * E5: R25 = ((R24 + NF - 3) & 0x00ff) | 0xc200
+ * R17 = (R17 & 0xfff0) | NF
+ *
+ * v1.00   modify by simon 2001.9.5
+ * change for kernel 2.4.x
+ *
+ * v1.1   11/09/2001   fix force mode bug
+ *
+ * v1.2   03/18/2003   Weilun Huang :
+ * Fixed phy reset.
+ * Added tx/rx 32 bit mode.
+ * Cleaned up for kernel merge.
+ *
+ * --
+ *
+ *12/15/2003   Initial port to u-boot by
+ * Sascha Hauer 
+ *
+ *06/03/2008   Remy Bohmer 
+ * - Fixed the driver to work with DM9000A.
+ *   (check on ISR receive status bit before reading the
+ *   FIFO as described in DM9000 programming guide and
+ *   application notes)
+ * - Added autodetect of databus width.
+ * - Made debug code compile again.
+ * - Adapt eth_send such that it matches the DM9000*
+ *   application notes. Needed to make it work properly
+ *   for DM9000A.
+ * - Adapted reset procedure to match DM9000 application
+ *   notes (i.e. double reset)
+ * - some minor code cleanups
+ * These changes are tested with DM9000{A,EP,E} together
+ * with a 200MHz Atmel AT91SAM9261 core
+ *
+ * TODO: external MII is not functional, only internal at the moment.
+ */
 
 #include 
 #include 
@@ -59,7 +59,7 @@ TODO: external MII is not functional, only internal at the 
moment.
 #include "dm9000x.h"
 
 /* Structure/enum declaration --- */
-typedef struct board_info {

[PATCH v2 13/17] net: dm9000: Split non-DM specific bits from common code

2022-04-12 Thread Marek Vasut
Split network handling functions into non-DM specific parts and
common code in preparation for conversion to DM.

Reviewed-by: Ramon Fried 
Signed-off-by: Marek Vasut 
Cc: Joe Hershberger 
Cc: Ramon Fried 
---
V2: - Add RB from Ramon
- Ignore return value of dm9000_halt_common(), the function
  is static void dm9000_halt_common(struct dm9000_priv *db)
  so it returns nothing. Fix dm9000_halt() function prototype.
---
 drivers/net/dm9000x.c | 58 +--
 1 file changed, 40 insertions(+), 18 deletions(-)

diff --git a/drivers/net/dm9000x.c b/drivers/net/dm9000x.c
index a40e60bbe61..639977ad6e6 100644
--- a/drivers/net/dm9000x.c
+++ b/drivers/net/dm9000x.c
@@ -311,9 +311,8 @@ static void dm9000_reset(struct dm9000_priv *db)
 }
 
 /* Initialize dm9000 board */
-static int dm9000_init(struct eth_device *dev, struct bd_info *bd)
+static int dm9000_init_common(struct dm9000_priv *db, u8 enetaddr[6])
 {
-   struct dm9000_priv *db = container_of(dev, struct dm9000_priv, dev);
int i, oft, lnk;
u8 io_mode;
 
@@ -371,13 +370,13 @@ static int dm9000_init(struct eth_device *dev, struct 
bd_info *bd)
/* Clear interrupt status */
dm9000_iow(db, DM9000_ISR, ISR_ROOS | ISR_ROS | ISR_PTS | ISR_PRS);
 
-   printf("MAC: %pM\n", dev->enetaddr);
-   if (!is_valid_ethaddr(dev->enetaddr))
+   printf("MAC: %pM\n", enetaddr);
+   if (!is_valid_ethaddr(enetaddr))
printf("WARNING: Bad MAC address (uninitialized EEPROM?)\n");
 
/* fill device MAC address registers */
for (i = 0, oft = DM9000_PAR; i < 6; i++, oft++)
-   dm9000_iow(db, oft, dev->enetaddr[i]);
+   dm9000_iow(db, oft, enetaddr[i]);
for (i = 0, oft = 0x16; i < 8; i++, oft++)
dm9000_iow(db, oft, 0xff);
 
@@ -430,9 +429,8 @@ static int dm9000_init(struct eth_device *dev, struct 
bd_info *bd)
  * Hardware start transmission.
  * Send a packet to media from the upper layer.
  */
-static int dm9000_send(struct eth_device *dev, void *packet, int length)
+static int dm9000_send_common(struct dm9000_priv *db, void *packet, int length)
 {
-   struct dm9000_priv *db = container_of(dev, struct dm9000_priv, dev);
int tmo;
 
dm9000_dump_packet(__func__, packet, length);
@@ -471,10 +469,8 @@ static int dm9000_send(struct eth_device *dev, void 
*packet, int length)
  * Stop the interface.
  * The interface is stopped when it is brought.
  */
-static void dm9000_halt(struct eth_device *netdev)
+static void dm9000_halt_common(struct dm9000_priv *db)
 {
-   struct dm9000_priv *db = container_of(dev, struct dm9000_priv, dev);
-
/* RESET device */
dm9000_phy_write(db, 0, 0x8000);/* PHY RESET */
dm9000_iow(db, DM9000_GPR, 0x01);   /* Power-Down PHY */
@@ -485,9 +481,8 @@ static void dm9000_halt(struct eth_device *netdev)
 /*
  * Received a packet and pass to upper layer
  */
-static int dm9000_rx(struct eth_device *dev)
+static int dm9000_recv_common(struct dm9000_priv *db)
 {
-   struct dm9000_priv *db = container_of(dev, struct dm9000_priv, dev);
u8 rxbyte;
u8 *rdptr = (u8 *)net_rx_packets[0];
u16 rxstatus, rxlen = 0;
@@ -570,18 +565,45 @@ static void dm9000_read_srom_word(struct dm9000_priv *db, 
int offset, u8 *to)
to[1] = dm9000_ior(db, DM9000_EPDRH);
 }
 
-static void dm9000_get_enetaddr(struct eth_device *dev)
+static void dm9000_get_enetaddr(struct dm9000_priv *db, u8 *enetaddr)
 {
-   struct dm9000_priv *db = container_of(dev, struct dm9000_priv, dev);
int i;
 
for (i = 0; i < 3; i++)
-   dm9000_read_srom_word(db, i, dev->enetaddr + (2 * i));
+   dm9000_read_srom_word(db, i, enetaddr + (2 * i));
 }
 #else
-static void dm9000_get_enetaddr(struct eth_device *dev) {}
+static void dm9000_get_enetaddr(struct dm9000_priv *db, u8 *enetaddr) {}
 #endif
 
+static int dm9000_init(struct eth_device *dev, struct bd_info *bd)
+{
+   struct dm9000_priv *db = container_of(dev, struct dm9000_priv, dev);
+
+   return dm9000_init_common(db, dev->enetaddr);
+}
+
+static void dm9000_halt(struct eth_device *dev)
+{
+   struct dm9000_priv *db = container_of(dev, struct dm9000_priv, dev);
+
+   dm9000_halt_common(db);
+}
+
+static int dm9000_send(struct eth_device *dev, void *packet, int length)
+{
+   struct dm9000_priv *db = container_of(dev, struct dm9000_priv, dev);
+
+   return dm9000_send_common(db, packet, length);
+}
+
+static int dm9000_recv(struct eth_device *dev)
+{
+   struct dm9000_priv *db = container_of(dev, struct dm9000_priv, dev);
+
+   return dm9000_recv_common(db);
+}
+
 int dm9000_initialize(struct bd_info *bis)
 {
struct dm9000_priv *priv;
@@ -597,12 +619,12 @@ int dm9000_initialize(struct bd_info *bis)
priv->base_data = (void __iomem *)DM9000_DATA;
 
/* Load MAC address from EEPROM */
-   

[PATCH v2 12/17] net: dm9000: Pass private data around for IO

2022-04-12 Thread Marek Vasut
Pass private data into IO accessors and use the base addresses of
IO and DATA window from the private data instead of using the hard
coded macros DM9000_IO/DM9000_DATA. Currently both the DM9000_IO
and DM9000_DATA are assigned to the respecive private data fields
for the non-DM case backward compatibility.

Reviewed-by: Ramon Fried 
Signed-off-by: Marek Vasut 
Cc: Joe Hershberger 
Cc: Ramon Fried 
---
V2: - Add RB from Ramon
- Replace phys_addr_t usage with void __iomem * to fix build
  warning on mips
---
 drivers/net/dm9000x.c | 230 ++
 1 file changed, 119 insertions(+), 111 deletions(-)

diff --git a/drivers/net/dm9000x.c b/drivers/net/dm9000x.c
index a8ce8ac02ee..a40e60bbe61 100644
--- a/drivers/net/dm9000x.c
+++ b/drivers/net/dm9000x.c
@@ -71,10 +71,12 @@ struct dm9000_priv {
u8 phy_addr;
u8 device_wait_reset;   /* device state */
unsigned char srom[128];
-   void (*outblk)(void *data_ptr, int count);
-   void (*inblk)(void *data_ptr, int count);
-   void (*rx_status)(u16 *rxstatus, u16 *rxlen);
+   void (*outblk)(struct dm9000_priv *db, void *data_ptr, int count);
+   void (*inblk)(struct dm9000_priv *db, void *data_ptr, int count);
+   void (*rx_status)(struct dm9000_priv *db, u16 *rxstatus, u16 *rxlen);
struct eth_device dev;
+   void __iomem *base_io;
+   void __iomem *base_data;
 };
 
 /* DM9000 network board routine  */
@@ -113,120 +115,121 @@ static void dm9000_dump_packet(const char *func, u8 
*packet, int length)
 static void dm9000_dump_packet(const char *func, u8 *packet, int length) {}
 #endif
 
-static void dm9000_outblk_8bit(void *data_ptr, int count)
+static void dm9000_outblk_8bit(struct dm9000_priv *db, void *data_ptr, int 
count)
 {
int i;
 
for (i = 0; i < count; i++)
-   dm9000_outbu8 *)data_ptr)[i] & 0xff), DM9000_DATA);
+   dm9000_outbu8 *)data_ptr)[i] & 0xff), db->base_data);
 }
 
-static void dm9000_outblk_16bit(void *data_ptr, int count)
+static void dm9000_outblk_16bit(struct dm9000_priv *db, void *data_ptr, int 
count)
 {
int i;
u32 tmplen = (count + 1) / 2;
 
for (i = 0; i < tmplen; i++)
-   dm9000_outw(((u16 *)data_ptr)[i], DM9000_DATA);
+   dm9000_outw(((u16 *)data_ptr)[i], db->base_data);
 }
 
-static void dm9000_outblk_32bit(void *data_ptr, int count)
+static void dm9000_outblk_32bit(struct dm9000_priv *db, void *data_ptr, int 
count)
 {
int i;
u32 tmplen = (count + 3) / 4;
 
for (i = 0; i < tmplen; i++)
-   dm9000_outl(((u32 *)data_ptr)[i], DM9000_DATA);
+   dm9000_outl(((u32 *)data_ptr)[i], db->base_data);
 }
 
-static void dm9000_inblk_8bit(void *data_ptr, int count)
+static void dm9000_inblk_8bit(struct dm9000_priv *db, void *data_ptr, int 
count)
 {
int i;
 
for (i = 0; i < count; i++)
-   ((u8 *)data_ptr)[i] = dm9000_inb(DM9000_DATA);
+   ((u8 *)data_ptr)[i] = dm9000_inb(db->base_data);
 }
 
-static void dm9000_inblk_16bit(void *data_ptr, int count)
+static void dm9000_inblk_16bit(struct dm9000_priv *db, void *data_ptr, int 
count)
 {
int i;
u32 tmplen = (count + 1) / 2;
 
for (i = 0; i < tmplen; i++)
-   ((u16 *)data_ptr)[i] = dm9000_inw(DM9000_DATA);
+   ((u16 *)data_ptr)[i] = dm9000_inw(db->base_data);
 }
 
-static void dm9000_inblk_32bit(void *data_ptr, int count)
+static void dm9000_inblk_32bit(struct dm9000_priv *db, void *data_ptr, int 
count)
 {
int i;
u32 tmplen = (count + 3) / 4;
 
for (i = 0; i < tmplen; i++)
-   ((u32 *)data_ptr)[i] = dm9000_inl(DM9000_DATA);
+   ((u32 *)data_ptr)[i] = dm9000_inl(db->base_data);
 }
 
-static void dm9000_rx_status_32bit(u16 *rxstatus, u16 *rxlen)
+static void dm9000_rx_status_32bit(struct dm9000_priv *db, u16 *rxstatus, u16 
*rxlen)
 {
u32 tmpdata;
 
-   dm9000_outb(DM9000_MRCMD, DM9000_IO);
+   dm9000_outb(DM9000_MRCMD, db->base_io);
 
-   tmpdata = dm9000_inl(DM9000_DATA);
+   tmpdata = dm9000_inl(db->base_data);
*rxstatus = __le16_to_cpu(tmpdata);
*rxlen = __le16_to_cpu(tmpdata >> 16);
 }
 
-static void dm9000_rx_status_16bit(u16 *rxstatus, u16 *rxlen)
+static void dm9000_rx_status_16bit(struct dm9000_priv *db, u16 *rxstatus, u16 
*rxlen)
 {
-   dm9000_outb(DM9000_MRCMD, DM9000_IO);
+   dm9000_outb(DM9000_MRCMD, db->base_io);
 
-   *rxstatus = __le16_to_cpu(dm9000_inw(DM9000_DATA));
-   *rxlen = __le16_to_cpu(dm9000_inw(DM9000_DATA));
+   *rxstatus = __le16_to_cpu(dm9000_inw(db->base_data));
+   *rxlen = __le16_to_cpu(dm9000_inw(db->base_data));
 }
 
-static void dm9000_rx_status_8bit(u16 *rxstatus, u16 *rxlen)
+static void dm9000_rx_status_8bit(struct dm9000_priv *db, u16 *rxstatus, u16 
*rxlen)
 {
-   dm9000_outb(DM9000_MRCMD, 

[PATCH v2 09/17] net: dm9000: Rename board_info to dm9000_priv

2022-04-12 Thread Marek Vasut
Rename board_info structure to dm9000_priv to make it clear what this
structure really contains, the driver private data. No functional change.

Reviewed-by: Ramon Fried 
Signed-off-by: Marek Vasut 
Cc: Joe Hershberger 
Cc: Ramon Fried 
---
V2: Add RB from Ramon
---
 drivers/net/dm9000x.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/dm9000x.c b/drivers/net/dm9000x.c
index 85f3c079ec1..7e1368a1be9 100644
--- a/drivers/net/dm9000x.c
+++ b/drivers/net/dm9000x.c
@@ -59,7 +59,7 @@
 #include "dm9000x.h"
 
 /* Structure/enum declaration --- */
-struct board_info {
+struct dm9000_priv {
u32 runt_length_counter;/* counter: RX length < 64byte */
u32 long_length_counter;/* counter: RX length > 1514byte */
u32 reset_counter;  /* counter: RESET */
@@ -77,7 +77,7 @@ struct board_info {
struct eth_device netdev;
 };
 
-static struct board_info dm9000_info;
+static struct dm9000_priv dm9000_info;
 
 /* DM9000 network board routine  */
 #ifndef CONFIG_DM9000_BYTE_SWAPPED
@@ -315,7 +315,7 @@ static int dm9000_init(struct eth_device *dev, struct 
bd_info *bd)
 {
int i, oft, lnk;
u8 io_mode;
-   struct board_info *db = _info;
+   struct dm9000_priv *db = _info;
 
/* RESET device */
dm9000_reset();
@@ -433,7 +433,7 @@ static int dm9000_init(struct eth_device *dev, struct 
bd_info *bd)
 static int dm9000_send(struct eth_device *netdev, void *packet, int length)
 {
int tmo;
-   struct board_info *db = _info;
+   struct dm9000_priv *db = _info;
 
dm9000_dump_packet(__func__, packet, length);
 
@@ -488,7 +488,7 @@ static int dm9000_rx(struct eth_device *netdev)
u8 rxbyte;
u8 *rdptr = (u8 *)net_rx_packets[0];
u16 rxstatus, rxlen = 0;
-   struct board_info *db = _info;
+   struct dm9000_priv *db = _info;
 
/*
 * Check packet ready or not, we must check
-- 
2.35.1



[PATCH v2 10/17] net: dm9000: Drop static device private data

2022-04-12 Thread Marek Vasut
Allocate driver private data dynamically in its init function and drop
the static driver private data variable. Pass the dynamic private data
throughout the driver. This is done in preparation for DM conversion.

Reviewed-by: Ramon Fried 
Signed-off-by: Marek Vasut 
Cc: Joe Hershberger 
Cc: Ramon Fried 
---
V2: - Add RB from Ramon
- Rename struct eth_device netdev to struct eth_device dev in
  struct dm9000_priv{}, so that it actually matches the use of
  container_of(). Also, dev is shorter than netdev and that
  makes those container_of() calls fit on one line.
- Add local struct eth_device *dev; and dev = >dev; to
  dm9000_initialize() to fix the missing variable in non-DM case
- Replace kcalloc() with calloc() and include malloc.h
---
 drivers/net/dm9000x.c | 28 +---
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/drivers/net/dm9000x.c b/drivers/net/dm9000x.c
index 7e1368a1be9..36411bd8ebd 100644
--- a/drivers/net/dm9000x.c
+++ b/drivers/net/dm9000x.c
@@ -51,6 +51,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -74,11 +75,9 @@ struct dm9000_priv {
void (*outblk)(void *data_ptr, int count);
void (*inblk)(void *data_ptr, int count);
void (*rx_status)(u16 *rxstatus, u16 *rxlen);
-   struct eth_device netdev;
+   struct eth_device dev;
 };
 
-static struct dm9000_priv dm9000_info;
-
 /* DM9000 network board routine  */
 #ifndef CONFIG_DM9000_BYTE_SWAPPED
 #define dm9000_outb(d, r) writeb((d), (r))
@@ -313,9 +312,9 @@ dm9000_reset(void)
 /* Initialize dm9000 board */
 static int dm9000_init(struct eth_device *dev, struct bd_info *bd)
 {
+   struct dm9000_priv *db = container_of(dev, struct dm9000_priv, dev);
int i, oft, lnk;
u8 io_mode;
-   struct dm9000_priv *db = _info;
 
/* RESET device */
dm9000_reset();
@@ -430,10 +429,10 @@ static int dm9000_init(struct eth_device *dev, struct 
bd_info *bd)
  * Hardware start transmission.
  * Send a packet to media from the upper layer.
  */
-static int dm9000_send(struct eth_device *netdev, void *packet, int length)
+static int dm9000_send(struct eth_device *dev, void *packet, int length)
 {
+   struct dm9000_priv *db = container_of(dev, struct dm9000_priv, dev);
int tmo;
-   struct dm9000_priv *db = _info;
 
dm9000_dump_packet(__func__, packet, length);
 
@@ -483,12 +482,12 @@ static void dm9000_halt(struct eth_device *netdev)
 /*
  * Received a packet and pass to upper layer
  */
-static int dm9000_rx(struct eth_device *netdev)
+static int dm9000_rx(struct eth_device *dev)
 {
+   struct dm9000_priv *db = container_of(dev, struct dm9000_priv, dev);
u8 rxbyte;
u8 *rdptr = (u8 *)net_rx_packets[0];
u16 rxstatus, rxlen = 0;
-   struct dm9000_priv *db = _info;
 
/*
 * Check packet ready or not, we must check
@@ -591,10 +590,17 @@ static void dm9000_get_enetaddr(struct eth_device *dev) {}
 
 int dm9000_initialize(struct bd_info *bis)
 {
-   struct eth_device *dev = _info.netdev;
+   struct dm9000_priv *priv;
+   struct eth_device *dev;
+
+   priv = calloc(1, sizeof(*priv));
+   if (!priv)
+   return -ENOMEM;
+
+   dev = >dev;
 
/* Load MAC address from EEPROM */
-   dm9000_get_enetaddr(dev);
+   dm9000_get_enetaddr(>dev);
 
dev->init = dm9000_init;
dev->halt = dm9000_halt;
@@ -602,7 +608,7 @@ int dm9000_initialize(struct bd_info *bis)
dev->recv = dm9000_rx;
strcpy(dev->name, "dm9000");
 
-   eth_register(dev);
+   eth_register(>dev);
 
return 0;
 }
-- 
2.35.1



[PATCH v2 11/17] net: dm9000: Drop dm9000.h and staticize SROM access

2022-04-12 Thread Marek Vasut
Dispose of dm9000.h because none of the function prototypes declared in
it are called anywhere in the codebase. Staticize dm9000_read_srom_word()
because it is now called only from within the dm9000 driver. Drop
dm9000_write_srom_word() because it is no longer used.

Reviewed-by: Ramon Fried 
Signed-off-by: Marek Vasut 
Cc: Joe Hershberger 
Cc: Ramon Fried 
---
V2: Add RB from Ramon
---
 drivers/net/dm9000x.c | 13 +
 include/dm9000.h  | 16 
 2 files changed, 1 insertion(+), 28 deletions(-)
 delete mode 100644 include/dm9000.h

diff --git a/drivers/net/dm9000x.c b/drivers/net/dm9000x.c
index 36411bd8ebd..a8ce8ac02ee 100644
--- a/drivers/net/dm9000x.c
+++ b/drivers/net/dm9000x.c
@@ -54,7 +54,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 #include "dm9000x.h"
@@ -557,7 +556,7 @@ static int dm9000_rx(struct eth_device *dev)
  * Read a word data from SROM
  */
 #if !defined(CONFIG_DM9000_NO_SROM)
-void dm9000_read_srom_word(int offset, u8 *to)
+static void dm9000_read_srom_word(int offset, u8 *to)
 {
dm9000_iow(DM9000_EPAR, offset);
dm9000_iow(DM9000_EPCR, 0x4);
@@ -567,16 +566,6 @@ void dm9000_read_srom_word(int offset, u8 *to)
to[1] = dm9000_ior(DM9000_EPDRH);
 }
 
-void dm9000_write_srom_word(int offset, u16 val)
-{
-   dm9000_iow(DM9000_EPAR, offset);
-   dm9000_iow(DM9000_EPDRH, ((val >> 8) & 0xff));
-   dm9000_iow(DM9000_EPDRL, (val & 0xff));
-   dm9000_iow(DM9000_EPCR, 0x12);
-   mdelay(8);
-   dm9000_iow(DM9000_EPCR, 0);
-}
-
 static void dm9000_get_enetaddr(struct eth_device *dev)
 {
int i;
diff --git a/include/dm9000.h b/include/dm9000.h
deleted file mode 100644
index f780e513f69..000
--- a/include/dm9000.h
+++ /dev/null
@@ -1,16 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * NOTE:DAVICOM DM9000 ethernet driver interface
- *
- * Authors: Remy Bohmer 
- */
-#ifndef __DM9000_H__
-#define __DM9000_H__
-
-/**  function prototypes **/
-#if !defined(CONFIG_DM9000_NO_SROM)
-void dm9000_write_srom_word(int offset, u16 val);
-void dm9000_read_srom_word(int offset, u8 *to);
-#endif
-
-#endif /* __DM9000_H__ */
-- 
2.35.1



[PATCH v2 08/17] net: dm9000: Reorder and staticize

2022-04-12 Thread Marek Vasut
Reorder the driver functions to get rid of forward declarations.
Staticize whatever is possible. No functional change.

Reviewed-by: Ramon Fried 
Signed-off-by: Marek Vasut 
Cc: Joe Hershberger 
Cc: Ramon Fried 
---
V2: Add RB from Ramon
---
 drivers/net/dm9000x.c | 122 +++---
 1 file changed, 55 insertions(+), 67 deletions(-)

diff --git a/drivers/net/dm9000x.c b/drivers/net/dm9000x.c
index becf7aec828..85f3c079ec1 100644
--- a/drivers/net/dm9000x.c
+++ b/drivers/net/dm9000x.c
@@ -79,13 +79,6 @@ struct board_info {
 
 static struct board_info dm9000_info;
 
-/* function declaration - */
-static int dm9000_probe(void);
-static u16 dm9000_phy_read(int);
-static void dm9000_phy_write(int, u16);
-static u8 dm9000_ior(int);
-static void dm9000_iow(int reg, u8 value);
-
 /* DM9000 network board routine  */
 #ifndef CONFIG_DM9000_BYTE_SWAPPED
 #define dm9000_outb(d, r) writeb((d), (r))
@@ -205,11 +198,64 @@ static void dm9000_rx_status_8bit(u16 *rxstatus, u16 
*rxlen)
  (dm9000_inb(DM9000_DATA) << 8));
 }
 
+/*
+ *  Read a byte from I/O port
+ */
+static u8 dm9000_ior(int reg)
+{
+   dm9000_outb(reg, DM9000_IO);
+   return dm9000_inb(DM9000_DATA);
+}
+
+/*
+ *  Write a byte to I/O port
+ */
+static void dm9000_iow(int reg, u8 value)
+{
+   dm9000_outb(reg, DM9000_IO);
+   dm9000_outb(value, DM9000_DATA);
+}
+
+/*
+ *  Read a word from phyxcer
+ */
+static u16 dm9000_phy_read(int reg)
+{
+   u16 val;
+
+   /* Fill the phyxcer register into REG_0C */
+   dm9000_iow(DM9000_EPAR, DM9000_PHY | reg);
+   dm9000_iow(DM9000_EPCR, 0xc);   /* Issue phyxcer read command */
+   udelay(100);/* Wait read complete */
+   dm9000_iow(DM9000_EPCR, 0x0);   /* Clear phyxcer read command */
+   val = (dm9000_ior(DM9000_EPDRH) << 8) | dm9000_ior(DM9000_EPDRL);
+
+   /* The read data keeps on REG_0D & REG_0E */
+   debug("%s(0x%x): 0x%x\n", __func__, reg, val);
+   return val;
+}
+
+/*
+ *  Write a word to phyxcer
+ */
+static void dm9000_phy_write(int reg, u16 value)
+{
+   /* Fill the phyxcer register into REG_0C */
+   dm9000_iow(DM9000_EPAR, DM9000_PHY | reg);
+
+   /* Fill the written data into REG_0D & REG_0E */
+   dm9000_iow(DM9000_EPDRL, (value & 0xff));
+   dm9000_iow(DM9000_EPDRH, ((value >> 8) & 0xff));
+   dm9000_iow(DM9000_EPCR, 0xa);   /* Issue phyxcer write command */
+   udelay(500);/* Wait write complete */
+   dm9000_iow(DM9000_EPCR, 0x0);   /* Clear phyxcer write command */
+   debug("%s(reg:0x%x, value:0x%x)\n", __func__, reg, value);
+}
+
 /*
  * Search DM9000 board, allocate space and register it
  */
-int
-dm9000_probe(void)
+static int dm9000_probe(void)
 {
u32 id_val;
 
@@ -543,64 +589,6 @@ static void dm9000_get_enetaddr(struct eth_device *dev)
 static void dm9000_get_enetaddr(struct eth_device *dev) {}
 #endif
 
-/*
- *  Read a byte from I/O port
- */
-static u8
-dm9000_ior(int reg)
-{
-   dm9000_outb(reg, DM9000_IO);
-   return dm9000_inb(DM9000_DATA);
-}
-
-/*
- *  Write a byte to I/O port
- */
-static void
-dm9000_iow(int reg, u8 value)
-{
-   dm9000_outb(reg, DM9000_IO);
-   dm9000_outb(value, DM9000_DATA);
-}
-
-/*
- *  Read a word from phyxcer
- */
-static u16
-dm9000_phy_read(int reg)
-{
-   u16 val;
-
-   /* Fill the phyxcer register into REG_0C */
-   dm9000_iow(DM9000_EPAR, DM9000_PHY | reg);
-   dm9000_iow(DM9000_EPCR, 0xc);   /* Issue phyxcer read command */
-   udelay(100);/* Wait read complete */
-   dm9000_iow(DM9000_EPCR, 0x0);   /* Clear phyxcer read command */
-   val = (dm9000_ior(DM9000_EPDRH) << 8) | dm9000_ior(DM9000_EPDRL);
-
-   /* The read data keeps on REG_0D & REG_0E */
-   debug("%s(0x%x): 0x%x\n", __func__, reg, val);
-   return val;
-}
-
-/*
- *  Write a word to phyxcer
- */
-static void
-dm9000_phy_write(int reg, u16 value)
-{
-   /* Fill the phyxcer register into REG_0C */
-   dm9000_iow(DM9000_EPAR, DM9000_PHY | reg);
-
-   /* Fill the written data into REG_0D & REG_0E */
-   dm9000_iow(DM9000_EPDRL, (value & 0xff));
-   dm9000_iow(DM9000_EPDRH, ((value >> 8) & 0xff));
-   dm9000_iow(DM9000_EPCR, 0xa);   /* Issue phyxcer write command */
-   udelay(500);/* Wait write complete */
-   dm9000_iow(DM9000_EPCR, 0x0);   /* Clear phyxcer write command */
-   debug("%s(reg:0x%x, value:0x%x)\n", __func__, reg, value);
-}
-
 int dm9000_initialize(struct bd_info *bis)
 {
struct eth_device *dev = _info.netdev;
-- 
2.35.1



[PATCH v2 05/17] net: dm9000: Turn DM9000_DMP_PACKET() into a function

2022-04-12 Thread Marek Vasut
Rework DM9000_DMP_PACKET() into dm9000_dump_packet() function,
this brings better type checking. No functional change.

Reviewed-by: Ramon Fried 
Signed-off-by: Marek Vasut 
Cc: Joe Hershberger 
Cc: Ramon Fried 
---
V2: Add RB from Ramon
---
 drivers/net/dm9000x.c | 42 +-
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/drivers/net/dm9000x.c b/drivers/net/dm9000x.c
index 223df944a48..da16b64610b 100644
--- a/drivers/net/dm9000x.c
+++ b/drivers/net/dm9000x.c
@@ -58,25 +58,6 @@ TODO: external MII is not functional, only internal at the 
moment.
 
 #include "dm9000x.h"
 
-/* Board/System/Debug information/definition  */
-
-/* #define CONFIG_DM9000_DEBUG */
-
-#ifdef CONFIG_DM9000_DEBUG
-#define DM9000_DMP_PACKET(func,packet,length)  \
-   do { \
-   int i;  \
-   printf("%s: length: %d\n", func, length);   \
-   for (i = 0; i < length; i++) {  \
-   if (i % 8 == 0) \
-   printf("\n%s: %02x: ", func, i);\
-   printf("%02x ", ((unsigned char *) packet)[i]); \
-   } printf("\n"); \
-   } while(0)
-#else
-#define DM9000_DMP_PACKET(func,packet,length)
-#endif
-
 /* Structure/enum declaration --- */
 typedef struct board_info {
u32 runt_length_counter;/* counter: RX length < 64byte */
@@ -122,6 +103,25 @@ static void dm9000_iow(int reg, u8 value);
 #define dm9000_inl(r) __raw_readl(r)
 #endif
 
+#ifdef DEBUG
+static void dm9000_dump_packet(const char *func, u8 *packet, int length)
+{
+   int i;
+
+   printf("%s: length: %d\n", func, length);
+
+   for (i = 0; i < length; i++) {
+   if (i % 8 == 0)
+   printf("\n%s: %02x: ", func, i);
+   printf("%02x ", packet[i]);
+   }
+
+   printf("\n");
+}
+#else
+static void dm9000_dump_packet(const char *func, u8 *packet, int length) {}
+#endif
+
 static void dm9000_outblk_8bit(volatile void *data_ptr, int count)
 {
int i;
@@ -387,7 +387,7 @@ static int dm9000_send(struct eth_device *netdev, void 
*packet, int length)
int tmo;
struct board_info *db = _info;
 
-   DM9000_DMP_PACKET(__func__ , packet, length);
+   dm9000_dump_packet(__func__ , packet, length);
 
dm9000_iow(DM9000_ISR, IMR_PTM); /* Clear Tx bit in ISR */
 
@@ -498,7 +498,7 @@ static int dm9000_rx(struct eth_device *netdev)
dm9000_reset();
}
} else {
-   DM9000_DMP_PACKET(__func__ , rdptr, rxlen);
+   dm9000_dump_packet(__func__ , rdptr, rxlen);
 
debug("passing packet to upper layer\n");
net_process_received_packet(net_rx_packets[0], rxlen);
-- 
2.35.1



[PATCH v2 04/17] net: dm9000: Drop unused dump_regs()

2022-04-12 Thread Marek Vasut
Drop unused function dump_regs() because it is unused.
No functional change.

Reviewed-by: Ramon Fried 
Signed-off-by: Marek Vasut 
Cc: Joe Hershberger 
Cc: Ramon Fried 
---
V2: Add RB from Ramon
---
 drivers/net/dm9000x.c | 17 -
 1 file changed, 17 deletions(-)

diff --git a/drivers/net/dm9000x.c b/drivers/net/dm9000x.c
index a99a901e828..223df944a48 100644
--- a/drivers/net/dm9000x.c
+++ b/drivers/net/dm9000x.c
@@ -122,23 +122,6 @@ static void dm9000_iow(int reg, u8 value);
 #define dm9000_inl(r) __raw_readl(r)
 #endif
 
-#ifdef CONFIG_DM9000_DEBUG
-static void
-dump_regs(void)
-{
-   debug("\n");
-   debug("NCR   (0x00): %02x\n", dm9000_ior(0));
-   debug("NSR   (0x01): %02x\n", dm9000_ior(1));
-   debug("TCR   (0x02): %02x\n", dm9000_ior(2));
-   debug("TSRI  (0x03): %02x\n", dm9000_ior(3));
-   debug("TSRII (0x04): %02x\n", dm9000_ior(4));
-   debug("RCR   (0x05): %02x\n", dm9000_ior(5));
-   debug("RSR   (0x06): %02x\n", dm9000_ior(6));
-   debug("ISR   (0xFE): %02x\n", dm9000_ior(DM9000_ISR));
-   debug("\n");
-}
-#endif
-
 static void dm9000_outblk_8bit(volatile void *data_ptr, int count)
 {
int i;
-- 
2.35.1



[PATCH v2 03/17] net: dm9000: Make RxLen and RxStatus lowercase

2022-04-12 Thread Marek Vasut
Rename variables to lowercase to be consistent with coding style.
No functional change.

Reviewed-by: Ramon Fried 
Signed-off-by: Marek Vasut 
Cc: Joe Hershberger 
Cc: Ramon Fried 
---
V2: Add RB from Ramon
---
 drivers/net/dm9000x.c | 44 +--
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/drivers/net/dm9000x.c b/drivers/net/dm9000x.c
index e83b838fd82..a99a901e828 100644
--- a/drivers/net/dm9000x.c
+++ b/drivers/net/dm9000x.c
@@ -92,7 +92,7 @@ typedef struct board_info {
unsigned char srom[128];
void (*outblk)(volatile void *data_ptr, int count);
void (*inblk)(void *data_ptr, int count);
-   void (*rx_status)(u16 *RxStatus, u16 *RxLen);
+   void (*rx_status)(u16 *rxstatus, u16 *rxlen);
struct eth_device netdev;
 } board_info_t;
 static board_info_t dm9000_info;
@@ -187,33 +187,33 @@ static void dm9000_inblk_32bit(void *data_ptr, int count)
((u32 *) data_ptr)[i] = dm9000_inl(DM9000_DATA);
 }
 
-static void dm9000_rx_status_32bit(u16 *RxStatus, u16 *RxLen)
+static void dm9000_rx_status_32bit(u16 *rxstatus, u16 *rxlen)
 {
u32 tmpdata;
 
dm9000_outb(DM9000_MRCMD, DM9000_IO);
 
tmpdata = dm9000_inl(DM9000_DATA);
-   *RxStatus = __le16_to_cpu(tmpdata);
-   *RxLen = __le16_to_cpu(tmpdata >> 16);
+   *rxstatus = __le16_to_cpu(tmpdata);
+   *rxlen = __le16_to_cpu(tmpdata >> 16);
 }
 
-static void dm9000_rx_status_16bit(u16 *RxStatus, u16 *RxLen)
+static void dm9000_rx_status_16bit(u16 *rxstatus, u16 *rxlen)
 {
dm9000_outb(DM9000_MRCMD, DM9000_IO);
 
-   *RxStatus = __le16_to_cpu(dm9000_inw(DM9000_DATA));
-   *RxLen = __le16_to_cpu(dm9000_inw(DM9000_DATA));
+   *rxstatus = __le16_to_cpu(dm9000_inw(DM9000_DATA));
+   *rxlen = __le16_to_cpu(dm9000_inw(DM9000_DATA));
 }
 
-static void dm9000_rx_status_8bit(u16 *RxStatus, u16 *RxLen)
+static void dm9000_rx_status_8bit(u16 *rxstatus, u16 *rxlen)
 {
dm9000_outb(DM9000_MRCMD, DM9000_IO);
 
-   *RxStatus =
+   *rxstatus =
__le16_to_cpu(dm9000_inb(DM9000_DATA) +
  (dm9000_inb(DM9000_DATA) << 8));
-   *RxLen =
+   *rxlen =
__le16_to_cpu(dm9000_inb(DM9000_DATA) +
  (dm9000_inb(DM9000_DATA) << 8));
 }
@@ -458,7 +458,7 @@ static int dm9000_rx(struct eth_device *netdev)
 {
u8 rxbyte;
u8 *rdptr = (u8 *)net_rx_packets[0];
-   u16 RxStatus, RxLen = 0;
+   u16 rxstatus, rxlen = 0;
struct board_info *db = _info;
 
/* Check packet ready or not, we must check
@@ -491,34 +491,34 @@ static int dm9000_rx(struct eth_device *netdev)
debug("receiving packet\n");
 
/* A packet ready now  & Get status/length */
-   (db->rx_status)(, );
+   (db->rx_status)(, );
 
-   debug("rx status: 0x%04x rx len: %d\n", RxStatus, RxLen);
+   debug("rx status: 0x%04x rx len: %d\n", rxstatus, rxlen);
 
/* Move data from DM9000 */
/* Read received packet from RX SRAM */
-   (db->inblk)(rdptr, RxLen);
+   (db->inblk)(rdptr, rxlen);
 
-   if ((RxStatus & 0xbf00) || (RxLen < 0x40)
-   || (RxLen > DM9000_PKT_MAX)) {
-   if (RxStatus & 0x100) {
+   if ((rxstatus & 0xbf00) || (rxlen < 0x40)
+   || (rxlen > DM9000_PKT_MAX)) {
+   if (rxstatus & 0x100) {
printf("rx fifo error\n");
}
-   if (RxStatus & 0x200) {
+   if (rxstatus & 0x200) {
printf("rx crc error\n");
}
-   if (RxStatus & 0x8000) {
+   if (rxstatus & 0x8000) {
printf("rx length error\n");
}
-   if (RxLen > DM9000_PKT_MAX) {
+   if (rxlen > DM9000_PKT_MAX) {
printf("rx length too big\n");
dm9000_reset();
}
} else {
-   DM9000_DMP_PACKET(__func__ , rdptr, RxLen);
+   DM9000_DMP_PACKET(__func__ , rdptr, rxlen);
 
debug("passing packet to upper layer\n");
-   net_process_received_packet(net_rx_packets[0], RxLen);
+   net_process_received_packet(net_rx_packets[0], rxlen);
}
}
return 0;
-- 
2.35.1



[PATCH v2 02/17] net: dm9000: Replace DM9000_DBG() with debug()

2022-04-12 Thread Marek Vasut
Use standard debug() macro to print debug messages instead of
reinventing driver-specific macro again. No functional change.

Reviewed-by: Ramon Fried 
Signed-off-by: Marek Vasut 
Cc: Joe Hershberger 
Cc: Ramon Fried 
---
V2: Add RB from Ramon
---
 drivers/net/dm9000x.c | 48 +--
 1 file changed, 23 insertions(+), 25 deletions(-)

diff --git a/drivers/net/dm9000x.c b/drivers/net/dm9000x.c
index 93699135f75..e83b838fd82 100644
--- a/drivers/net/dm9000x.c
+++ b/drivers/net/dm9000x.c
@@ -63,7 +63,6 @@ TODO: external MII is not functional, only internal at the 
moment.
 /* #define CONFIG_DM9000_DEBUG */
 
 #ifdef CONFIG_DM9000_DEBUG
-#define DM9000_DBG(fmt,args...) printf(fmt, ##args)
 #define DM9000_DMP_PACKET(func,packet,length)  \
do { \
int i;  \
@@ -75,7 +74,6 @@ TODO: external MII is not functional, only internal at the 
moment.
} printf("\n"); \
} while(0)
 #else
-#define DM9000_DBG(fmt,args...)
 #define DM9000_DMP_PACKET(func,packet,length)
 #endif
 
@@ -128,16 +126,16 @@ static void dm9000_iow(int reg, u8 value);
 static void
 dump_regs(void)
 {
-   DM9000_DBG("\n");
-   DM9000_DBG("NCR   (0x00): %02x\n", dm9000_ior(0));
-   DM9000_DBG("NSR   (0x01): %02x\n", dm9000_ior(1));
-   DM9000_DBG("TCR   (0x02): %02x\n", dm9000_ior(2));
-   DM9000_DBG("TSRI  (0x03): %02x\n", dm9000_ior(3));
-   DM9000_DBG("TSRII (0x04): %02x\n", dm9000_ior(4));
-   DM9000_DBG("RCR   (0x05): %02x\n", dm9000_ior(5));
-   DM9000_DBG("RSR   (0x06): %02x\n", dm9000_ior(6));
-   DM9000_DBG("ISR   (0xFE): %02x\n", dm9000_ior(DM9000_ISR));
-   DM9000_DBG("\n");
+   debug("\n");
+   debug("NCR   (0x00): %02x\n", dm9000_ior(0));
+   debug("NSR   (0x01): %02x\n", dm9000_ior(1));
+   debug("TCR   (0x02): %02x\n", dm9000_ior(2));
+   debug("TSRI  (0x03): %02x\n", dm9000_ior(3));
+   debug("TSRII (0x04): %02x\n", dm9000_ior(4));
+   debug("RCR   (0x05): %02x\n", dm9000_ior(5));
+   debug("RSR   (0x06): %02x\n", dm9000_ior(6));
+   debug("ISR   (0xFE): %02x\n", dm9000_ior(DM9000_ISR));
+   debug("\n");
 }
 #endif
 
@@ -246,7 +244,7 @@ dm9000_probe(void)
 static void
 dm9000_reset(void)
 {
-   DM9000_DBG("resetting DM9000\n");
+   debug("resetting DM9000\n");
 
/* Reset DM9000,
   see DM9000 Application Notes V1.22 Jun 11, 2004 page 29 */
@@ -259,7 +257,7 @@ dm9000_reset(void)
dm9000_iow(DM9000_NCR, (NCR_LBK_INT_MAC | NCR_RST));
 
do {
-   DM9000_DBG("resetting the DM9000, 1st reset\n");
+   debug("resetting the DM9000, 1st reset\n");
udelay(25); /* Wait at least 20 us */
} while (dm9000_ior(DM9000_NCR) & 1);
 
@@ -267,7 +265,7 @@ dm9000_reset(void)
dm9000_iow(DM9000_NCR, (NCR_LBK_INT_MAC | NCR_RST)); /* Issue a second 
reset */
 
do {
-   DM9000_DBG("resetting the DM9000, 2nd reset\n");
+   debug("resetting the DM9000, 2nd reset\n");
udelay(25); /* Wait at least 20 us */
} while (dm9000_ior(DM9000_NCR) & 1);
 
@@ -285,7 +283,7 @@ static int dm9000_init(struct eth_device *dev, struct 
bd_info *bd)
u8 io_mode;
struct board_info *db = _info;
 
-   DM9000_DBG("%s\n", __func__);
+   debug("%s\n", __func__);
 
/* RESET device */
dm9000_reset();
@@ -354,8 +352,8 @@ static int dm9000_init(struct eth_device *dev, struct 
bd_info *bd)
 
/* read back mac, just to be sure */
for (i = 0, oft = 0x10; i < 6; i++, oft++)
-   DM9000_DBG("%02x:", dm9000_ior(oft));
-   DM9000_DBG("\n");
+   debug("%02x:", dm9000_ior(oft));
+   debug("\n");
 
/* Activate DM9000 */
/* RX enable */
@@ -434,7 +432,7 @@ static int dm9000_send(struct eth_device *netdev, void 
*packet, int length)
}
dm9000_iow(DM9000_ISR, IMR_PTM); /* Clear Tx bit in ISR */
 
-   DM9000_DBG("transmit done\n\n");
+   debug("transmit done\n\n");
return 0;
 }
 
@@ -444,7 +442,7 @@ static int dm9000_send(struct eth_device *netdev, void 
*packet, int length)
 */
 static void dm9000_halt(struct eth_device *netdev)
 {
-   DM9000_DBG("%s\n", __func__);
+   debug("%s\n", __func__);
 
/* RESET devie */
dm9000_phy_write(0, 0x8000);/* PHY RESET */
@@ -490,12 +488,12 @@ static int dm9000_rx(struct eth_device *netdev)
if (rxbyte != DM9000_PKT_RDY)
return 0; /* No packet received, ignore */
 
-   DM9000_DBG("receiving packet\n");
+   debug("receiving packet\n");
 
/* A packet ready now  & Get status/length */
(db->rx_status)(, );
 
-   DM9000_DBG("rx status: 0x%04x rx len: %d\n", RxStatus, RxLen);
+   debug("rx status: 0x%04x rx len: 

[PATCH v2 01/17] net: dm9000: Make accessor names lowercase

2022-04-12 Thread Marek Vasut
Make accessor names lowercase to be consistent with coding style.
No functional change.

Reviewed-by: Ramon Fried 
Signed-off-by: Marek Vasut 
Cc: Joe Hershberger 
Cc: Ramon Fried 
---
V2: Add RB from Ramon
---
 drivers/net/dm9000x.c | 214 +-
 1 file changed, 107 insertions(+), 107 deletions(-)

diff --git a/drivers/net/dm9000x.c b/drivers/net/dm9000x.c
index 4f062e99d9b..93699135f75 100644
--- a/drivers/net/dm9000x.c
+++ b/drivers/net/dm9000x.c
@@ -104,24 +104,24 @@ static board_info_t dm9000_info;
 static int dm9000_probe(void);
 static u16 dm9000_phy_read(int);
 static void dm9000_phy_write(int, u16);
-static u8 DM9000_ior(int);
-static void DM9000_iow(int reg, u8 value);
+static u8 dm9000_ior(int);
+static void dm9000_iow(int reg, u8 value);
 
 /* DM9000 network board routine  */
 #ifndef CONFIG_DM9000_BYTE_SWAPPED
-#define DM9000_outb(d,r) writeb(d, (volatile u8 *)(r))
-#define DM9000_outw(d,r) writew(d, (volatile u16 *)(r))
-#define DM9000_outl(d,r) writel(d, (volatile u32 *)(r))
-#define DM9000_inb(r) readb((volatile u8 *)(r))
-#define DM9000_inw(r) readw((volatile u16 *)(r))
-#define DM9000_inl(r) readl((volatile u32 *)(r))
+#define dm9000_outb(d,r) writeb(d, (volatile u8 *)(r))
+#define dm9000_outw(d,r) writew(d, (volatile u16 *)(r))
+#define dm9000_outl(d,r) writel(d, (volatile u32 *)(r))
+#define dm9000_inb(r) readb((volatile u8 *)(r))
+#define dm9000_inw(r) readw((volatile u16 *)(r))
+#define dm9000_inl(r) readl((volatile u32 *)(r))
 #else
-#define DM9000_outb(d, r) __raw_writeb(d, r)
-#define DM9000_outw(d, r) __raw_writew(d, r)
-#define DM9000_outl(d, r) __raw_writel(d, r)
-#define DM9000_inb(r) __raw_readb(r)
-#define DM9000_inw(r) __raw_readw(r)
-#define DM9000_inl(r) __raw_readl(r)
+#define dm9000_outb(d, r) __raw_writeb(d, r)
+#define dm9000_outw(d, r) __raw_writew(d, r)
+#define dm9000_outl(d, r) __raw_writel(d, r)
+#define dm9000_inb(r) __raw_readb(r)
+#define dm9000_inw(r) __raw_readw(r)
+#define dm9000_inl(r) __raw_readl(r)
 #endif
 
 #ifdef CONFIG_DM9000_DEBUG
@@ -129,14 +129,14 @@ static void
 dump_regs(void)
 {
DM9000_DBG("\n");
-   DM9000_DBG("NCR   (0x00): %02x\n", DM9000_ior(0));
-   DM9000_DBG("NSR   (0x01): %02x\n", DM9000_ior(1));
-   DM9000_DBG("TCR   (0x02): %02x\n", DM9000_ior(2));
-   DM9000_DBG("TSRI  (0x03): %02x\n", DM9000_ior(3));
-   DM9000_DBG("TSRII (0x04): %02x\n", DM9000_ior(4));
-   DM9000_DBG("RCR   (0x05): %02x\n", DM9000_ior(5));
-   DM9000_DBG("RSR   (0x06): %02x\n", DM9000_ior(6));
-   DM9000_DBG("ISR   (0xFE): %02x\n", DM9000_ior(DM9000_ISR));
+   DM9000_DBG("NCR   (0x00): %02x\n", dm9000_ior(0));
+   DM9000_DBG("NSR   (0x01): %02x\n", dm9000_ior(1));
+   DM9000_DBG("TCR   (0x02): %02x\n", dm9000_ior(2));
+   DM9000_DBG("TSRI  (0x03): %02x\n", dm9000_ior(3));
+   DM9000_DBG("TSRII (0x04): %02x\n", dm9000_ior(4));
+   DM9000_DBG("RCR   (0x05): %02x\n", dm9000_ior(5));
+   DM9000_DBG("RSR   (0x06): %02x\n", dm9000_ior(6));
+   DM9000_DBG("ISR   (0xFE): %02x\n", dm9000_ior(DM9000_ISR));
DM9000_DBG("\n");
 }
 #endif
@@ -145,7 +145,7 @@ static void dm9000_outblk_8bit(volatile void *data_ptr, int 
count)
 {
int i;
for (i = 0; i < count; i++)
-   DM9000_outbu8 *) data_ptr)[i] & 0xff), DM9000_DATA);
+   dm9000_outbu8 *) data_ptr)[i] & 0xff), DM9000_DATA);
 }
 
 static void dm9000_outblk_16bit(volatile void *data_ptr, int count)
@@ -154,7 +154,7 @@ static void dm9000_outblk_16bit(volatile void *data_ptr, 
int count)
u32 tmplen = (count + 1) / 2;
 
for (i = 0; i < tmplen; i++)
-   DM9000_outw(((u16 *) data_ptr)[i], DM9000_DATA);
+   dm9000_outw(((u16 *) data_ptr)[i], DM9000_DATA);
 }
 static void dm9000_outblk_32bit(volatile void *data_ptr, int count)
 {
@@ -162,14 +162,14 @@ static void dm9000_outblk_32bit(volatile void *data_ptr, 
int count)
u32 tmplen = (count + 3) / 4;
 
for (i = 0; i < tmplen; i++)
-   DM9000_outl(((u32 *) data_ptr)[i], DM9000_DATA);
+   dm9000_outl(((u32 *) data_ptr)[i], DM9000_DATA);
 }
 
 static void dm9000_inblk_8bit(void *data_ptr, int count)
 {
int i;
for (i = 0; i < count; i++)
-   ((u8 *) data_ptr)[i] = DM9000_inb(DM9000_DATA);
+   ((u8 *) data_ptr)[i] = dm9000_inb(DM9000_DATA);
 }
 
 static void dm9000_inblk_16bit(void *data_ptr, int count)
@@ -178,7 +178,7 @@ static void dm9000_inblk_16bit(void *data_ptr, int count)
u32 tmplen = (count + 1) / 2;
 
for (i = 0; i < tmplen; i++)
-   ((u16 *) data_ptr)[i] = DM9000_inw(DM9000_DATA);
+   ((u16 *) data_ptr)[i] = dm9000_inw(DM9000_DATA);
 }
 static void dm9000_inblk_32bit(void *data_ptr, int count)
 {
@@ -186,38 +186,38 @@ static void dm9000_inblk_32bit(void *data_ptr, int count)
u32 tmplen = (count + 3) / 4;
 
for (i = 0; i < 

Re: [PATCH] riscv: Fix build against binutils 2.38

2022-04-12 Thread Leo Liang
Hi Alex,
On Tue, Apr 12, 2022 at 11:14:32AM +0200, Alexandre Ghiti wrote:
> Hi Leo,
> > A gentle ping.
> >
> > Any comments?
> > Or should we spin a patch for updating the toolchain used for 32 bit build?
> 
> Sorry for being very slow here, if the patch is too much of a burden,
> maybe you should drop it for now, I will have more time to work on
> this in 2 weeks, sorry again.
> 
> Alex
> 

Understood! No worries! Take your time to it.

Best regards,
Leo

> >
> > Best regards,
> > Leo


[PATCH V3 4/4] imx: imx8mq-evk: enable CONFIG_DM_SERIAL

2022-04-12 Thread Peng Fan (OSS)
From: Peng Fan 

Marked related nodes as u-boot,dm-spl for serial driver model
Enable CONFIG_DM_SERIAL

Signed-off-by: Peng Fan 
---
 arch/arm/dts/imx8mq-evk-u-boot.dtsi | 32 +
 configs/imx8mq_evk_defconfig|  1 +
 2 files changed, 33 insertions(+)

diff --git a/arch/arm/dts/imx8mq-evk-u-boot.dtsi 
b/arch/arm/dts/imx8mq-evk-u-boot.dtsi
index 6f9c81462ea..919c1f66d38 100644
--- a/arch/arm/dts/imx8mq-evk-u-boot.dtsi
+++ b/arch/arm/dts/imx8mq-evk-u-boot.dtsi
@@ -2,6 +2,34 @@
 
 #include "imx8mq-u-boot.dtsi"
 
+&{/soc@0} {
+   u-boot,dm-spl;
+};
+
+&{/soc@0/bus@3000} {
+   u-boot,dm-spl;
+};
+
+&{/soc@0/bus@3040} {
+   u-boot,dm-spl;
+};
+
+&{/soc@0/bus@3080} {
+   u-boot,dm-spl;
+};
+
+&{/soc@0/bus@32c0} {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+_uart1 {
+   u-boot,dm-spl;
+};
+
  {
mmc-hs400-1_8v;
 };
@@ -10,3 +38,7 @@
sd-uhs-sdr104;
sd-uhs-ddr50;
 };
+
+ {
+   u-boot,dm-spl;
+};
diff --git a/configs/imx8mq_evk_defconfig b/configs/imx8mq_evk_defconfig
index df7a259f35a..780f93103c7 100644
--- a/configs/imx8mq_evk_defconfig
+++ b/configs/imx8mq_evk_defconfig
@@ -80,6 +80,7 @@ CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_REGULATOR_GPIO=y
 CONFIG_SPL_POWER_I2C=y
 CONFIG_DM_RESET=y
+CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
 CONFIG_DM_THERMAL=y
 CONFIG_USB=y
-- 
2.35.1



[PATCH V3 3/4] imx: imx8mn_evk: enable CONFIG_DM_SERIAL

2022-04-12 Thread Peng Fan (OSS)
From: Peng Fan 

Enable CONFIG_DM_SERIAL. uart2 and its pinmux was already
marked with u-boot,dm-spl.

Signed-off-by: Peng Fan 
---
 board/freescale/imx8mn_evk/spl.c  | 12 ++--
 configs/imx8mn_ddr4_evk_defconfig |  1 +
 configs/imx8mn_evk_defconfig  |  1 +
 3 files changed, 4 insertions(+), 10 deletions(-)

diff --git a/board/freescale/imx8mn_evk/spl.c b/board/freescale/imx8mn_evk/spl.c
index 03f2a56e805..8708c93fa34 100644
--- a/board/freescale/imx8mn_evk/spl.c
+++ b/board/freescale/imx8mn_evk/spl.c
@@ -110,14 +110,8 @@ int board_fit_config_name_match(const char *name)
 }
 #endif
 
-#define UART_PAD_CTRL  (PAD_CTL_DSE6 | PAD_CTL_FSEL1)
 #define WDOG_PAD_CTRL  (PAD_CTL_DSE6 | PAD_CTL_ODE | PAD_CTL_PUE | PAD_CTL_PE)
 
-static iomux_v3_cfg_t const uart_pads[] = {
-   IMX8MN_PAD_UART2_RXD__UART2_DCE_RX | MUX_PAD_CTRL(UART_PAD_CTRL),
-   IMX8MN_PAD_UART2_TXD__UART2_DCE_TX | MUX_PAD_CTRL(UART_PAD_CTRL),
-};
-
 static iomux_v3_cfg_t const wdog_pads[] = {
IMX8MN_PAD_GPIO1_IO02__WDOG1_WDOG_B  | MUX_PAD_CTRL(WDOG_PAD_CTRL),
 };
@@ -130,8 +124,6 @@ int board_early_init_f(void)
 
set_wdog_reset(wdog);
 
-   imx_iomux_v3_setup_multiple_pads(uart_pads, ARRAY_SIZE(uart_pads));
-
return 0;
 }
 
@@ -147,8 +139,6 @@ void board_init_f(ulong dummy)
 
timer_init();
 
-   preloader_console_init();
-
/* Clear the BSS. */
memset(__bss_start, 0, __bss_end - __bss_start);
 
@@ -158,6 +148,8 @@ void board_init_f(ulong dummy)
hang();
}
 
+   preloader_console_init();
+
enable_tzc380();
 
/* DDR initialization */
diff --git a/configs/imx8mn_ddr4_evk_defconfig 
b/configs/imx8mn_ddr4_evk_defconfig
index 917cdb5aa9d..474d9cfa4d2 100644
--- a/configs/imx8mn_ddr4_evk_defconfig
+++ b/configs/imx8mn_ddr4_evk_defconfig
@@ -76,6 +76,7 @@ CONFIG_PINCTRL_IMX8M=y
 CONFIG_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
 CONFIG_SYSRESET=y
 CONFIG_SPL_SYSRESET=y
diff --git a/configs/imx8mn_evk_defconfig b/configs/imx8mn_evk_defconfig
index 7749ebe537e..5bc175154ba 100644
--- a/configs/imx8mn_evk_defconfig
+++ b/configs/imx8mn_evk_defconfig
@@ -83,6 +83,7 @@ CONFIG_DM_REGULATOR=y
 CONFIG_SPL_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
 CONFIG_SYSRESET=y
 CONFIG_SPL_SYSRESET=y
-- 
2.35.1



[PATCH V3 2/4] imx: imx8mm_evk: enable CONFIG_DM_SERIAL

2022-04-12 Thread Peng Fan (OSS)
From: Peng Fan 

Enable CONFIG_DM_SERIAL. uart2 and its pinmux was already
marked with u-boot,dm-spl.

Signed-off-by: Peng Fan 
---
 board/freescale/imx8mm_evk/spl.c | 12 ++--
 configs/imx8mm_evk_defconfig |  1 +
 2 files changed, 3 insertions(+), 10 deletions(-)

diff --git a/board/freescale/imx8mm_evk/spl.c b/board/freescale/imx8mm_evk/spl.c
index 4ef7f6f1806..e65dc2194ea 100644
--- a/board/freescale/imx8mm_evk/spl.c
+++ b/board/freescale/imx8mm_evk/spl.c
@@ -64,14 +64,8 @@ int board_fit_config_name_match(const char *name)
 }
 #endif
 
-#define UART_PAD_CTRL  (PAD_CTL_DSE6 | PAD_CTL_FSEL1)
 #define WDOG_PAD_CTRL  (PAD_CTL_DSE6 | PAD_CTL_ODE | PAD_CTL_PUE | PAD_CTL_PE)
 
-static iomux_v3_cfg_t const uart_pads[] = {
-   IMX8MM_PAD_UART2_RXD_UART2_RX | MUX_PAD_CTRL(UART_PAD_CTRL),
-   IMX8MM_PAD_UART2_TXD_UART2_TX | MUX_PAD_CTRL(UART_PAD_CTRL),
-};
-
 static iomux_v3_cfg_t const wdog_pads[] = {
IMX8MM_PAD_GPIO1_IO02_WDOG1_WDOG_B  | MUX_PAD_CTRL(WDOG_PAD_CTRL),
 };
@@ -84,8 +78,6 @@ int board_early_init_f(void)
 
set_wdog_reset(wdog);
 
-   imx_iomux_v3_setup_multiple_pads(uart_pads, ARRAY_SIZE(uart_pads));
-
return 0;
 }
 
@@ -139,8 +131,6 @@ void board_init_f(ulong dummy)
 
timer_init();
 
-   preloader_console_init();
-
/* Clear the BSS. */
memset(__bss_start, 0, __bss_end - __bss_start);
 
@@ -158,6 +148,8 @@ void board_init_f(ulong dummy)
hang();
}
 
+   preloader_console_init();
+
enable_tzc380();
 
power_init_board();
diff --git a/configs/imx8mm_evk_defconfig b/configs/imx8mm_evk_defconfig
index 81268788fa1..cc5f2801b15 100644
--- a/configs/imx8mm_evk_defconfig
+++ b/configs/imx8mm_evk_defconfig
@@ -78,6 +78,7 @@ CONFIG_SPL_DM_PMIC_PCA9450=y
 CONFIG_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_REGULATOR_GPIO=y
+CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
 CONFIG_SYSRESET=y
 CONFIG_SPL_SYSRESET=y
-- 
2.35.1



[PATCH V3 1/4] imx: imx8mp_evk: enable CONFIG_DM_SERIAL

2022-04-12 Thread Peng Fan (OSS)
From: Peng Fan 

Enable CONFIG_DM_SERIAL. uart2 and its pinmux was already
marked with u-boot,dm-spl.

Signed-off-by: Peng Fan 
---
 board/freescale/imx8mp_evk/imx8mp_evk.c | 8 
 configs/imx8mp_evk_defconfig| 1 +
 2 files changed, 1 insertion(+), 8 deletions(-)

diff --git a/board/freescale/imx8mp_evk/imx8mp_evk.c 
b/board/freescale/imx8mp_evk/imx8mp_evk.c
index 62096c24fb7..fb6c61c39e7 100644
--- a/board/freescale/imx8mp_evk/imx8mp_evk.c
+++ b/board/freescale/imx8mp_evk/imx8mp_evk.c
@@ -20,14 +20,8 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#define UART_PAD_CTRL  (PAD_CTL_DSE6 | PAD_CTL_FSEL1)
 #define WDOG_PAD_CTRL  (PAD_CTL_DSE6 | PAD_CTL_ODE | PAD_CTL_PUE | PAD_CTL_PE)
 
-static iomux_v3_cfg_t const uart_pads[] = {
-   MX8MP_PAD_UART2_RXD__UART2_DCE_RX | MUX_PAD_CTRL(UART_PAD_CTRL),
-   MX8MP_PAD_UART2_TXD__UART2_DCE_TX | MUX_PAD_CTRL(UART_PAD_CTRL),
-};
-
 static iomux_v3_cfg_t const wdog_pads[] = {
MX8MP_PAD_GPIO1_IO02__WDOG1_WDOG_B  | MUX_PAD_CTRL(WDOG_PAD_CTRL),
 };
@@ -40,8 +34,6 @@ int board_early_init_f(void)
 
set_wdog_reset(wdog);
 
-   imx_iomux_v3_setup_multiple_pads(uart_pads, ARRAY_SIZE(uart_pads));
-
return 0;
 }
 
diff --git a/configs/imx8mp_evk_defconfig b/configs/imx8mp_evk_defconfig
index c64b699e105..01240e543af 100644
--- a/configs/imx8mp_evk_defconfig
+++ b/configs/imx8mp_evk_defconfig
@@ -91,6 +91,7 @@ CONFIG_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_FIXED=y
 CONFIG_DM_REGULATOR_GPIO=y
 CONFIG_SPL_POWER_I2C=y
+CONFIG_DM_SERIAL=y
 CONFIG_MXC_UART=y
 CONFIG_SYSRESET=y
 CONFIG_SPL_SYSRESET=y
-- 
2.35.1



[PATCH V3 0/4] imx: imx8m: enable DM SERIAL

2022-04-12 Thread Peng Fan (OSS)
From: Peng Fan 

V3:
 Add missed Signed-off-by
 Rebased to only add CONFIG_DM_SERIAL, not touch other config change in 
defconfig

V2:
 Include imx8mq-evk in this patchset.
 For i.MX8MN/M/P, drop board level uart pinmux settings,
 move preloader_console_init after driver probe.

 Tested on all four boards. Note i.MX8MQ-EVK not have SPL_DM, so pinmux for
 uart still there for spl usage.


Peng Fan (4):
  imx: imx8mp_evk: enable CONFIG_DM_SERIAL
  imx: imx8mm_evk: enable CONFIG_DM_SERIAL
  imx: imx8mn_evk: enable CONFIG_DM_SERIAL
  imx: imx8mq-evk: enable CONFIG_DM_SERIAL

 arch/arm/dts/imx8mq-evk-u-boot.dtsi | 32 +
 board/freescale/imx8mm_evk/spl.c| 12 ++
 board/freescale/imx8mn_evk/spl.c| 12 ++
 board/freescale/imx8mp_evk/imx8mp_evk.c |  8 ---
 configs/imx8mm_evk_defconfig|  1 +
 configs/imx8mn_ddr4_evk_defconfig   |  1 +
 configs/imx8mn_evk_defconfig|  1 +
 configs/imx8mp_evk_defconfig|  1 +
 configs/imx8mq_evk_defconfig|  1 +
 9 files changed, 41 insertions(+), 28 deletions(-)

-- 
2.35.1



[PATCH V3 6/6] include/configs: drop COUNTER_FREQUENCY

2022-04-12 Thread Peng Fan (OSS)
From: Peng Fan 

Since we have CONFIG_COUNTER_FREQUENCY enabled, no need COUNTER_FREQUENCY

Signed-off-by: Peng Fan 
---
 arch/arm/cpu/armv8/fsl-layerscape/spintable.S | 2 +-
 include/configs/apalis-imx8.h | 3 ---
 include/configs/apalis-imx8x.h| 3 ---
 include/configs/capricorn-common.h| 3 ---
 include/configs/cgtqmx8.h | 3 ---
 include/configs/colibri-imx8x.h   | 1 -
 include/configs/condor.h  | 3 ---
 include/configs/draak.h   | 3 ---
 include/configs/dragonboard410c.h | 3 ---
 include/configs/dragonboard820c.h | 3 ---
 include/configs/eagle.h   | 3 ---
 include/configs/ebisu.h   | 3 ---
 include/configs/exynos7420-common.h   | 3 ---
 include/configs/exynos78x0-common.h   | 3 ---
 include/configs/falcon.h  | 3 ---
 include/configs/hihope-rzg2.h | 3 ---
 include/configs/hikey.h   | 3 ---
 include/configs/hikey960.h| 3 ---
 include/configs/imx8qm_mek.h  | 3 ---
 include/configs/imx8qm_rom7720.h  | 3 ---
 include/configs/imx8qxp_mek.h | 3 ---
 include/configs/ls1012a_common.h  | 3 ---
 include/configs/ls1028a_common.h  | 3 ---
 include/configs/ls1043a_common.h  | 3 ---
 include/configs/ls1046a_common.h  | 3 ---
 include/configs/ls2080a_common.h  | 2 --
 include/configs/mt8183.h  | 1 -
 include/configs/mt8512.h  | 1 -
 include/configs/mt8516.h  | 1 -
 include/configs/mt8518.h  | 1 -
 include/configs/owl-common.h  | 3 ---
 include/configs/p2371-2180.h  | 3 ---
 include/configs/p2771-.h  | 3 ---
 include/configs/p3450-.h  | 3 ---
 include/configs/presidio_asic.h   | 3 +--
 include/configs/px30_common.h | 1 -
 include/configs/rk3308_common.h   | 1 -
 include/configs/rk3328_common.h   | 1 -
 include/configs/rk3368_common.h   | 1 -
 include/configs/rk3399_common.h   | 1 -
 include/configs/rk3568_common.h   | 1 -
 include/configs/salvator-x.h  | 3 ---
 include/configs/sdm845.h  | 3 ---
 include/configs/silinux-ek874.h   | 3 ---
 include/configs/socfpga_soc64_common.h| 5 -
 include/configs/ten64.h   | 1 -
 include/configs/thunderx_88xx.h   | 3 ---
 include/configs/ulcb.h| 3 ---
 include/configs/vexpress_aemv8.h  | 3 ---
 49 files changed, 2 insertions(+), 121 deletions(-)

diff --git a/arch/arm/cpu/armv8/fsl-layerscape/spintable.S 
b/arch/arm/cpu/armv8/fsl-layerscape/spintable.S
index d6bd1884599..1eb0c2d4a7e 100644
--- a/arch/arm/cpu/armv8/fsl-layerscape/spintable.S
+++ b/arch/arm/cpu/armv8/fsl-layerscape/spintable.S
@@ -113,6 +113,6 @@ _dead_loop:
.align 3
.global __real_cntfrq
 __real_cntfrq:
-   .quad COUNTER_FREQUENCY
+   .quad CONFIG_COUNTER_FREQUENCY
/* Secondary Boot Code ends here */
 __secondary_boot_code_end:
diff --git a/include/configs/apalis-imx8.h b/include/configs/apalis-imx8.h
index c87bcd475ef..e759f18fe46 100644
--- a/include/configs/apalis-imx8.h
+++ b/include/configs/apalis-imx8.h
@@ -84,7 +84,4 @@
 #define CONFIG_SYS_PBSIZE  (CONFIG_SYS_CBSIZE + \
sizeof(CONFIG_SYS_PROMPT) + 16)
 
-/* Generic Timer Definitions */
-#define COUNTER_FREQUENCY  800 /* 8MHz */
-
 #endif /* __APALIS_IMX8_H */
diff --git a/include/configs/apalis-imx8x.h b/include/configs/apalis-imx8x.h
index 71a80f38bbb..17f1981643f 100644
--- a/include/configs/apalis-imx8x.h
+++ b/include/configs/apalis-imx8x.h
@@ -115,9 +115,6 @@
 #define CONFIG_SYS_PBSIZE  (CONFIG_SYS_CBSIZE + \
sizeof(CONFIG_SYS_PROMPT) + 16)
 
-/* Generic Timer Definitions */
-#define COUNTER_FREQUENCY  800 /* 8MHz */
-
 /* Networking */
 #define CONFIG_FEC_ENET_DEV 0
 #define IMX_FEC_BASE   0x5b04
diff --git a/include/configs/capricorn-common.h 
b/include/configs/capricorn-common.h
index 58d7a3a8ce2..1466be10fcd 100644
--- a/include/configs/capricorn-common.h
+++ b/include/configs/capricorn-common.h
@@ -123,9 +123,6 @@
 #define CONFIG_SYS_MAXARGS 64
 #define CONFIG_SYS_BARGSIZECONFIG_SYS_CBSIZE
 
-/* Generic Timer Definitions */
-#define COUNTER_FREQUENCY  800 /* 8MHz */
-
 #define BOOTAUX_RESERVED_MEM_BASE  0x8800
 #define BOOTAUX_RESERVED_MEM_SIZE  SZ_128M /* Reserve from second 128MB */
 
diff --git a/include/configs/cgtqmx8.h b/include/configs/cgtqmx8.h
index bd5c072382a..b5817f1e42d 100644

[PATCH V3 5/6] armv8: set cntfrq_el0 if CONFIG_COUNTER_FREQUENCY is valid

2022-04-12 Thread Peng Fan (OSS)
From: Peng Fan 

Since COUNTER_FREQUENCY is obselete, so set cntfrq_el0 if
CONFIG_COUNTER_FREQUENCY is valid

Signed-off-by: Peng Fan 
---
 arch/arm/cpu/armv8/start.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/cpu/armv8/start.S b/arch/arm/cpu/armv8/start.S
index 6a6a4f86502..d328e8c08a1 100644
--- a/arch/arm/cpu/armv8/start.S
+++ b/arch/arm/cpu/armv8/start.S
@@ -138,9 +138,9 @@ pie_fixup_done:
 0:
msr daifclr, #0x4   /* Unmask SError interrupts */
 
-#ifdef COUNTER_FREQUENCY
+#if CONFIG_COUNTER_FREQUENCY
branch_if_not_highest_el x0, 4f
-   ldr x0, =COUNTER_FREQUENCY
+   ldr x0, =CONFIG_COUNTER_FREQUENCY
msr cntfrq_el0, x0  /* Initialize CNTFRQ */
 #endif
 
-- 
2.35.1



[PATCH V3 2/6] arch: arm: move COUNTER_FREQUENCY from versal to arm

2022-04-12 Thread Peng Fan (OSS)
From: Peng Fan 

Make COUNTER_FREQUENCY usable to armv8 and armv7-a, not limited to
versal. And update help message.

Signed-off-by: Peng Fan 
---
 arch/arm/Kconfig | 12 
 arch/arm/mach-versal/Kconfig |  6 --
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 6771f14b105..d77186b77b4 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -19,6 +19,18 @@ config ARM64_CRC32
  not be present on all ARMv8.0, but is always present on ARMv8.1 and
  newer.
 
+config COUNTER_FREQUENCY
+   int "Timer clock frequency"
+   depends on ARM64 || CPU_V7A
+   default 0
+   help
+ For platforms with ARMv8-A and ARMv7-A which features a system
+ counter, those platforms needs software to program the counter
+ frequency. Setup time clock frequency for certain platform.
+ 0 means no need to configure the system counter frequency.
+ For platforms needs the frequency set in U-Boot with a
+ pre-defined value, should have the macro defined as a non-zero value.
+
 config POSITION_INDEPENDENT
bool "Generate position-independent pre-relocation code"
depends on ARM64 || CPU_V7A
diff --git a/arch/arm/mach-versal/Kconfig b/arch/arm/mach-versal/Kconfig
index 0c6ad345ffd..645f06add44 100644
--- a/arch/arm/mach-versal/Kconfig
+++ b/arch/arm/mach-versal/Kconfig
@@ -24,12 +24,6 @@ config SYS_CONFIG_NAME
 config SYS_MALLOC_LEN
default 0x200
 
-config COUNTER_FREQUENCY
-   int "Timer clock frequency"
-   default 0
-   help
- Setup time clock frequency for certain platform
-
 config ZYNQ_SDHCI_MAX_FREQ
default 2
 
-- 
2.35.1



[PATCH V3 3/6] arch: arm: Kconfig: set default COUNTER_FREQUENCY for i.MX

2022-04-12 Thread Peng Fan (OSS)
From: Peng Fan 

i.MX6UL/ULL/7D/8QM/8QXP all has system counter frequency run at 8MHz,
so set default value for them.

Signed-off-by: Peng Fan 
---
 arch/arm/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index d77186b77b4..b633cc9c943 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -23,6 +23,7 @@ config COUNTER_FREQUENCY
int "Timer clock frequency"
depends on ARM64 || CPU_V7A
default 0
+   default 800 if IMX8 || MX7 || MX6UL || MX6ULL
help
  For platforms with ARMv8-A and ARMv7-A which features a system
  counter, those platforms needs software to program the counter
-- 
2.35.1



[PATCH V3 1/6] xilinx: versal: board: use CONFIG_COUNTER_FREQUENCY

2022-04-12 Thread Peng Fan (OSS)
From: Peng Fan 

Since versal has CONFIG_COUNTER_FREQUENCY, so use it. And
COUNTER_FREQUENCY will be dropped.

Signed-off-by: Peng Fan 
Reviewed-by: Michal Simek 
---
 board/xilinx/versal/board.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/board/xilinx/versal/board.c b/board/xilinx/versal/board.c
index 9940f2aeb33..2e2807eee46 100644
--- a/board/xilinx/versal/board.c
+++ b/board/xilinx/versal/board.c
@@ -74,7 +74,7 @@ int board_early_init_r(void)
 * Program freq register in System counter and
 * enable system counter.
 */
-   writel(COUNTER_FREQUENCY,
+   writel(CONFIG_COUNTER_FREQUENCY,
   _scntr_secure->base_frequency_id_register);
 
debug("counter val 0x%x\n",
-- 
2.35.1



[PATCH V3 0/6] Convert COUNTER_FREQUENCY to CONFIG_COUNTER_FREQUENCY

2022-04-12 Thread Peng Fan (OSS)
From: Peng Fan 


V3:
 Add more help info for CONFIG_COUNTER_FREQUENCY
 Drop uneeded comments
 Pass git bisect build
 Rebased

V2:
 Drop imx93 which is wrongly included

This patchset is to convert COUNTER_FREQUENCY to CONFIG_COUNTER_FREQUENCY
for arm64. arm32 is not included for now, this could be in following up
patches if this patchset is accepted.

This patchset touches lots of boards, so please help review.


Peng Fan (6):
  xilinx: versal: board: use CONFIG_COUNTER_FREQUENCY
  arch: arm: move COUNTER_FREQUENCY from versal to arm
  arch: arm: Kconfig: set default COUNTER_FREQUENCY for i.MX
  configs: set CONFIG_COUNTER_FREQUENCY
  armv8: set cntfrq_el0 if CONFIG_COUNTER_FREQUENCY is valid
  include/configs: drop COUNTER_FREQUENCY

 arch/arm/Kconfig  | 13 +
 arch/arm/cpu/armv8/fsl-layerscape/spintable.S |  2 +-
 arch/arm/cpu/armv8/start.S|  4 ++--
 arch/arm/mach-versal/Kconfig  |  6 --
 board/xilinx/versal/board.c   |  2 +-
 configs/a3y17lte_defconfig|  1 +
 configs/a5y17lte_defconfig|  1 +
 configs/a7y17lte_defconfig|  1 +
 configs/apalis-imx8_defconfig |  1 +
 configs/apalis-imx8x_defconfig|  1 +
 configs/bubblegum_96_defconfig|  1 +
 configs/cgtqmx8_defconfig |  1 +
 configs/colibri-imx8x_defconfig   |  1 +
 configs/cortina_presidio-asic-base_defconfig  |  1 +
 configs/cortina_presidio-asic-emmc_defconfig  |  1 +
 configs/cortina_presidio-asic-pnand_defconfig |  1 +
 configs/cubieboard7_defconfig |  1 +
 configs/deneb_defconfig   |  1 +
 configs/dragonboard410c_defconfig |  1 +
 configs/dragonboard820c_defconfig |  1 +
 configs/espresso7420_defconfig|  1 +
 configs/evb-px30_defconfig|  1 +
 configs/evb-px5_defconfig |  1 +
 configs/evb-rk3308_defconfig  |  1 +
 configs/evb-rk3328_defconfig  |  1 +
 configs/evb-rk3399_defconfig  |  1 +
 configs/evb-rk3568_defconfig  |  1 +
 configs/firefly-px30_defconfig|  1 +
 configs/firefly-rk3399_defconfig  |  1 +
 configs/hihope_rzg2_defconfig |  1 +
 configs/hikey960_defconfig|  1 +
 configs/hikey_defconfig   |  1 +
 configs/imx8qm_mek_defconfig  |  1 +
 configs/imx8qm_rom7720_a1_4G_defconfig|  1 +
 configs/imx8qxp_mek_defconfig |  1 +
 configs/khadas-edge-captain-rk3399_defconfig  |  1 +
 configs/khadas-edge-rk3399_defconfig  |  1 +
 configs/khadas-edge-v-rk3399_defconfig|  1 +
 configs/leez-rk3399_defconfig |  1 +
 configs/ls1012a2g5rdb_qspi_defconfig  |  1 +
 configs/ls1012a2g5rdb_tfa_defconfig   |  1 +
 configs/ls1043aqds_defconfig  |  1 +
 configs/ls1043aqds_lpuart_defconfig   |  1 +
 configs/ls1043aqds_nand_defconfig |  1 +
 configs/ls1043aqds_nor_ddr3_defconfig |  1 +
 configs/ls1043aqds_qspi_defconfig |  1 +
 configs/ls1043aqds_sdcard_ifc_defconfig   |  1 +
 configs/ls1043aqds_sdcard_qspi_defconfig  |  1 +
 configs/ls1043aqds_tfa_SECURE_BOOT_defconfig  |  1 +
 configs/ls1043aqds_tfa_defconfig  |  1 +
 configs/ls1046afrwy_tfa_SECURE_BOOT_defconfig |  1 +
 configs/ls1046afrwy_tfa_defconfig |  1 +
 configs/mt8183_pumpkin_defconfig  |  1 +
 configs/mt8512_bm1_emmc_defconfig |  1 +
 configs/mt8516_pumpkin_defconfig  |  1 +
 configs/mt8518_ap1_emmc_defconfig |  1 +
 configs/nanopc-t4-rk3399_defconfig|  1 +
 configs/nanopi-m4-2gb-rk3399_defconfig|  1 +
 configs/nanopi-m4-rk3399_defconfig|  1 +
 configs/nanopi-m4b-rk3399_defconfig   |  1 +
 configs/nanopi-neo4-rk3399_defconfig  |  1 +
 configs/nanopi-r2s-rk3328_defconfig   |  1 +
 configs/nanopi-r4s-rk3399_defconfig   |  1 +
 configs/orangepi-rk3399_defconfig |  1 +
 configs/p2371-2180_defconfig  |  1 +
 configs/p2771--000_defconfig  |  1 +
 configs/p2771--500_defconfig  |  1 +
 configs/p3450-_defconfig  |  1 +
 configs/r8a77970_eagle_defconfig  |  1 +
 configs/r8a77980_condor_defconfig |  1 +
 configs/r8a77990_ebisu_defconfig  |  1 +
 configs/r8a77995_draak_defconfig  |  1 +
 configs/r8a779a0_falcon_defconfig |  1 +
 configs/rcar3_salvator-x_defconfig|  1 +
 configs/rcar3_ulcb_defconfig  |  1 +
 configs/roc-cc-rk3328_defconfig   |  1 +
 configs/rock-pi-4-rk3399_defconfig|  1 +
 configs/rock-pi-4c-rk3399_defconfig   |  1 +
 

Re: [PATCH] Revert "env: Load env when ENV_IS_NOWHERE is only location selected"

2022-04-12 Thread Marek Vasut

On 4/13/22 02:49, felix.vietme...@jila.colorado.edu wrote:

I am not exactly sure to be honest. We were running with this patched
version for a while and it worked from what I remember.

But we have since updated u-boot and the Kernel and the latest version
does not depend on this patch.

Nevertheless, I can try to recreate the problem and see if I can figure it
out now. I feel like I might pick up on a few more things now that went
unnoticed by me when I created the patch.


Thanks. Please CC me if you have a V2.


Re: [PATCH v2 13/18] pci: Map bars with offset and length

2022-04-12 Thread Tom Rini
On Tue, Apr 12, 2022 at 11:54:33PM +0100, Andrew Scull wrote:
> On Tue, 12 Apr 2022 at 17:42, Tom Rini  wrote:
> >
> > On Tue, Mar 29, 2022 at 04:58:55PM +, Andrew Scull wrote:
> >
> > > Evolve dm_pci_map_bar() to include an offset and length parameter. These
> > > allow a portion of the memory to be mapped and range checks to be
> > > applied.
> > >
> > > Passing both the offset and length as zero results in the previous
> > > behaviour and this is used to migtate the previous callers.
> > >
> > > Signed-off-by: Andrew Scull 
> >
> > This breaks rpi_arm64 building, and possibly others.  It may be helpful
> > to read https://u-boot.readthedocs.io/en/latest/develop/ci_testing.html
> > and get a CI run completed for the whole series to shake out any other
> > failures.  Thanks!
> 
> That CI sounds like it will be useful to know how to use, thanks for
> the pointers.
> 
> Aside from just building, I'd also be interested in feedback as to
> whether this evolution of the API is a suitable direction to be
> taking.

Ah.  To be clear, I was preparing to merge the series and ran in to this
problem.  So, I think it's fine once CI passes.

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH 00/11] virtio: Harden and test vring

2022-04-12 Thread Tom Rini
On Tue, Apr 12, 2022 at 11:49:12PM +0100, Andrew Scull wrote:
> On Tue, 12 Apr 2022 at 19:10, Tom Rini  wrote:
> >
> > On Thu, Mar 31, 2022 at 10:09:38AM +, Andrew Scull wrote:
> >
> > > Continuing the theme of making the virtio code resilient against
> > > corruption of the buffers shared with the device, this series focusses
> > > on the vring. This series is simpler and more self-contained than the
> > > series for virtio-pci!
> > >
> > > It follows the example of Linux by keeping a private copy of the
> > > descriptors and metadata for state tracking and only ever writing to the
> > > descriptors that are shared with the device.
> > >
> > > I was able to test these hardening steps in the sandbox by simulating
> > > device writes to the queues. I was also looking into testing the device
> > > drivers against a simulated device but the lack of an API to access the
> > > virtqueues meant this ended up being a hack. I've included that hack and
> > > the at the end of the series as an RFC.
> > >
> > > Andrew Scull (11):
> > >   virtio_ring: Merge identical variables
> > >   virtio_ring: Add helper to attach vring descriptor
> > >   virtio_ring: Maintain a shadow copy of descriptors
> > >   virtio_ring: Check used descriptors are chain heads
> > >   dm: test: virtio: Test the virtio ring
> > >   virtio: sandbox: Fix device features bitfield
> > >   test: dm: virtio: Test notify before del_vqs
> > >   virtio: sandbox: Bind RNG rather than block device
> > >   test: dm: virtio: Test virtio device driver probing
> > >   virtio: rng: Check length before copying
> > >   RFC: test: dm: virtio: Test virtio-rng with faked device
> >
> > What does this series depend on?  I got a failure to build on sandbox:
> > https://source.denx.de/u-boot/u-boot/-/jobs/422500#L104
> 
> Problem is from the final, RFC, patch on SPL where CONFIG_DM_RNG is
> not set so `dm_rng_read` isn't defined. I don't really understand the
> difference with SPL just yet, but I expect CONFIG_DM_RNG can be set.
> But in the meantime, it's also fine to drop that final patch from the
> series.

I'd like to have the test included.  SPL (and TPL) are special builds of
U-Boot used earlier on in the boot process so that we can load full
U-Boot, but have less resources and subsystems available.  Can you
please take a look at modifying the patch so that we only try and test
on full U-Boot?  There should be some other examples in the tests
directory doing what you need to do here.  Thanks!


-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] configs: Enable EXT4 and ISO partitions for the DeveloperBox

2022-04-12 Thread Masami Hiramatsu
This looks good to me.

Acked-by: Masami Hiramatsu 

Thank you!

2022年4月13日(水) 6:16 Ilias Apalodimas :
>
> Since this box is SystemReady compliant enable ISO_PARTITION which is
> needed to start some installers (e.g Fedora).  While at it enable EXT4
> as well which is a common filesystem for targets
>
> Signed-off-by: Ilias Apalodimas 
> ---
>  configs/synquacer_developerbox_defconfig | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/configs/synquacer_developerbox_defconfig 
> b/configs/synquacer_developerbox_defconfig
> index fe12c74374f9..4b06b2a523fb 100644
> --- a/configs/synquacer_developerbox_defconfig
> +++ b/configs/synquacer_developerbox_defconfig
> @@ -37,6 +37,7 @@ CONFIG_CMD_FAT=y
>  CONFIG_CMD_FS_GENERIC=y
>  CONFIG_CMD_MTDPARTS=y
>  CONFIG_CMD_LOG=y
> +CONFIG_ISO_PARTITION=y
>  CONFIG_PARTITION_TYPE_GUID=y
>  CONFIG_ENV_OVERWRITE=y
>  CONFIG_ENV_IS_IN_SPI_FLASH=y
> @@ -85,6 +86,7 @@ CONFIG_USB=y
>  CONFIG_USB_XHCI_HCD=y
>  CONFIG_USB_XHCI_PCI=y
>  CONFIG_USB_STORAGE=y
> +CONFIG_FS_EXT4=y
>  CONFIG_EFI_SET_TIME=y
>  CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y
>  CONFIG_EFI_CAPSULE_ON_DISK=y
> --
> 2.32.0
>


-- 
Masami Hiramatsu


Re: [PATCH 00/11] virtio: Harden and test vring

2022-04-12 Thread Andrew Scull
On Tue, 12 Apr 2022 at 19:10, Tom Rini  wrote:
>
> On Thu, Mar 31, 2022 at 10:09:38AM +, Andrew Scull wrote:
>
> > Continuing the theme of making the virtio code resilient against
> > corruption of the buffers shared with the device, this series focusses
> > on the vring. This series is simpler and more self-contained than the
> > series for virtio-pci!
> >
> > It follows the example of Linux by keeping a private copy of the
> > descriptors and metadata for state tracking and only ever writing to the
> > descriptors that are shared with the device.
> >
> > I was able to test these hardening steps in the sandbox by simulating
> > device writes to the queues. I was also looking into testing the device
> > drivers against a simulated device but the lack of an API to access the
> > virtqueues meant this ended up being a hack. I've included that hack and
> > the at the end of the series as an RFC.
> >
> > Andrew Scull (11):
> >   virtio_ring: Merge identical variables
> >   virtio_ring: Add helper to attach vring descriptor
> >   virtio_ring: Maintain a shadow copy of descriptors
> >   virtio_ring: Check used descriptors are chain heads
> >   dm: test: virtio: Test the virtio ring
> >   virtio: sandbox: Fix device features bitfield
> >   test: dm: virtio: Test notify before del_vqs
> >   virtio: sandbox: Bind RNG rather than block device
> >   test: dm: virtio: Test virtio device driver probing
> >   virtio: rng: Check length before copying
> >   RFC: test: dm: virtio: Test virtio-rng with faked device
>
> What does this series depend on?  I got a failure to build on sandbox:
> https://source.denx.de/u-boot/u-boot/-/jobs/422500#L104

Problem is from the final, RFC, patch on SPL where CONFIG_DM_RNG is
not set so `dm_rng_read` isn't defined. I don't really understand the
difference with SPL just yet, but I expect CONFIG_DM_RNG can be set.
But in the meantime, it's also fine to drop that final patch from the
series.


[PATCH v4 10/10] arm: dts: imx8mp: Import GPCv2 subset, HSIOMIX and USB PD

2022-04-12 Thread Marek Vasut
Add DT bindings for a subset of GPCv2 which handles USB and PCIe PDs,
HSIOMIX PD controller and missing USB PD properties. This is required
to bring up the DWC3 USB controller up.

This is based on linux next and patches which are still pending
review, but which are likely going to be part of Linux 5.19:
b2d67d7bdf74 ("arm64: dts: imx8mp: disable usb3_phy1")
290918c72a29 ("arm64: dts: imx8mp: Add memory for USB3 glue layer to usb3 
nodes")
https://www.spinics.net/lists/arm-kernel/msg958501.html

Tested-By: Tim Harvey  #imx8mp-venice-gw74xx
Signed-off-by: Marek Vasut 
Cc: Fabio Estevam 
Cc: Peng Fan 
Cc: Stefano Babic 
---
V2: Add TB by Tim
V3: Skipped to align the Vx scheme
V4: Rebase on u-boot-imx/master
---
 arch/arm/dts/imx8mp.dtsi | 72 ++--
 1 file changed, 70 insertions(+), 2 deletions(-)

diff --git a/arch/arm/dts/imx8mp.dtsi b/arch/arm/dts/imx8mp.dtsi
index f9d64253c8a..79b65750da9 100644
--- a/arch/arm/dts/imx8mp.dtsi
+++ b/arch/arm/dts/imx8mp.dtsi
@@ -4,6 +4,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -434,6 +435,44 @@
interrupts = ;
#reset-cells = <1>;
};
+
+   gpc: gpc@303a {
+   compatible = "fsl,imx8mp-gpc";
+   reg = <0x303a 0x1000>;
+   interrupt-parent = <>;
+   interrupt-controller;
+   #interrupt-cells = <3>;
+
+   pgc {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   pgc_pcie_phy: power-domain@1 {
+   #power-domain-cells = <0>;
+   reg = 
;
+   };
+
+   pgc_usb1_phy: power-domain@2 {
+   #power-domain-cells = <0>;
+   reg = 
;
+   };
+
+   pgc_usb2_phy: power-domain@3 {
+   #power-domain-cells = <0>;
+   reg = 
;
+   };
+
+   pgc_hsiomix: power-domains@17 {
+   #power-domain-cells = <0>;
+   reg = 
;
+   clocks = < 
IMX8MP_CLK_HSIO_AXI>,
+< 
IMX8MP_CLK_HSIO_ROOT>;
+   assigned-clocks = < 
IMX8MP_CLK_HSIO_AXI>;
+   assigned-clock-parents = < 
IMX8MP_SYS_PLL2_500M>;
+   assigned-clock-rates = 
<5>;
+   };
+   };
+   };
};
 
aips2: bus@3040 {
@@ -842,6 +881,28 @@
};
};
 
+   aips4: bus@32c0 {
+   compatible = "fsl,aips-bus", "simple-bus";
+   reg = <0x32c0 0x40>;
+   #address-cells = <1>;
+   #size-cells = <1>;
+   ranges;
+
+   hsio_blk_ctrl: blk-ctrl@32f1 {
+   compatible = "fsl,imx8mp-hsio-blk-ctrl", 
"syscon";
+   reg = <0x32f1 0x24>;
+   clocks = < IMX8MP_CLK_USB_ROOT>,
+< IMX8MP_CLK_PCIE_ROOT>;
+   clock-names = "usb", "pcie";
+   power-domains = <_hsiomix>, <_hsiomix>,
+   <_usb1_phy>, 
<_usb2_phy>,
+   <_hsiomix>, <_pcie_phy>;
+   power-domain-names = "bus", "usb", "usb-phy1",
+"usb-phy2", "pcie", 
"pcie-phy";
+   #power-domain-cells = <1>;
+   };
+   };
+
gic: interrupt-controller@3880 {
compatible = "arm,gic-v3";
reg = <0x3880 0x1>,
@@ -865,17 +926,20 @@
clock-names = "phy";
assigned-clocks = < IMX8MP_CLK_USB_PHY_REF>;
assigned-clock-parents = < IMX8MP_CLK_24M>;
+   power-domains = <_blk_ctrl 
IMX8MP_HSIOBLK_PD_USB_PHY1>;
#phy-cells = <0>;
  

[PATCH v4 09/10] usb: dwc3: Implement .glue_configure for i.MX8MP

2022-04-12 Thread Marek Vasut
The i.MX8MP glue needs to be configured based on a couple of DT
properties, implement .glue_configure callback to parse those DT
properties and configure the glue accordingly.

Tested-By: Tim Harvey  #imx8mp-venice-gw74xx
Signed-off-by: Marek Vasut 
Cc: Angus Ainslie 
Cc: Bin Meng 
Cc: Fabio Estevam 
Cc: Kunihiko Hayashi 
Cc: Michal Simek 
Cc: Peng Fan 
Cc: Stefano Babic 
---
V2: Add TB by Tim
V3: Skipped to align the Vx scheme
V4: Rebase on u-boot-imx/master
---
 drivers/usb/dwc3/dwc3-generic.c | 52 +
 1 file changed, 52 insertions(+)

diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index 7e3814207e4..6cf844cb483 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -223,6 +223,57 @@ struct dwc3_glue_ops {
   enum usb_dr_mode mode);
 };
 
+void dwc3_imx8mp_glue_configure(struct udevice *dev, int index,
+   enum usb_dr_mode mode)
+{
+/* USB glue registers */
+#define USB_CTRL0  0x00
+#define USB_CTRL1  0x04
+
+#define USB_CTRL0_PORTPWR_EN   BIT(12) /* 1 - PPC enabled (default) */
+#define USB_CTRL0_USB3_FIXED   BIT(22) /* 1 - USB3 permanent attached */
+#define USB_CTRL0_USB2_FIXED   BIT(23) /* 1 - USB2 permanent attached */
+
+#define USB_CTRL1_OC_POLARITY  BIT(16) /* 0 - HIGH / 1 - LOW */
+#define USB_CTRL1_PWR_POLARITY BIT(17) /* 0 - HIGH / 1 - LOW */
+   fdt_addr_t regs = dev_read_addr_index(dev, 1);
+   void *base = map_physmem(regs, 0x8, MAP_NOCACHE);
+   u32 value;
+
+   value = readl(base + USB_CTRL0);
+
+   if (dev_read_bool(dev, "fsl,permanently-attached"))
+   value |= (USB_CTRL0_USB2_FIXED | USB_CTRL0_USB3_FIXED);
+   else
+   value &= ~(USB_CTRL0_USB2_FIXED | USB_CTRL0_USB3_FIXED);
+
+   if (dev_read_bool(dev, "fsl,disable-port-power-control"))
+   value &= ~(USB_CTRL0_PORTPWR_EN);
+   else
+   value |= USB_CTRL0_PORTPWR_EN;
+
+   writel(value, base + USB_CTRL0);
+
+   value = readl(base + USB_CTRL1);
+   if (dev_read_bool(dev, "fsl,over-current-active-low"))
+   value |= USB_CTRL1_OC_POLARITY;
+   else
+   value &= ~USB_CTRL1_OC_POLARITY;
+
+   if (dev_read_bool(dev, "fsl,power-active-low"))
+   value |= USB_CTRL1_PWR_POLARITY;
+   else
+   value &= ~USB_CTRL1_PWR_POLARITY;
+
+   writel(value, base + USB_CTRL1);
+
+   unmap_physmem(base, MAP_NOCACHE);
+}
+
+struct dwc3_glue_ops imx8mp_ops = {
+   .glue_configure = dwc3_imx8mp_glue_configure,
+};
+
 void dwc3_ti_glue_configure(struct udevice *dev, int index,
enum usb_dr_mode mode)
 {
@@ -464,6 +515,7 @@ static const struct udevice_id dwc3_glue_ids[] = {
{ .compatible = "rockchip,rk3328-dwc3" },
{ .compatible = "rockchip,rk3399-dwc3" },
{ .compatible = "qcom,dwc3" },
+   { .compatible = "fsl,imx8mp-dwc3", .data = (ulong)_ops },
{ .compatible = "fsl,imx8mq-dwc3" },
{ .compatible = "intel,tangier-dwc3" },
{ }
-- 
2.35.1



[PATCH v4 08/10] usb: dwc3: Rename .select_dr_mode to .glue_configure

2022-04-12 Thread Marek Vasut
Rename the select_dr_mode callback to glue_configure, the callback is
used for more than enforcing controller mode even on the TI chips, so
change the name to a more generic one. No functional change.

Tested-By: Tim Harvey  #imx8mp-venice-gw74xx
Signed-off-by: Marek Vasut 
Cc: Angus Ainslie 
Cc: Bin Meng 
Cc: Fabio Estevam 
Cc: Kunihiko Hayashi 
Cc: Michal Simek 
Cc: Peng Fan 
Cc: Stefano Babic 
---
V2: Add TB by Tim
V3: Skipped to align the Vx scheme
V4: Rebase on u-boot-imx/master
---
 drivers/usb/dwc3/dwc3-generic.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-generic.c b/drivers/usb/dwc3/dwc3-generic.c
index 01bd0ca190e..7e3814207e4 100644
--- a/drivers/usb/dwc3/dwc3-generic.c
+++ b/drivers/usb/dwc3/dwc3-generic.c
@@ -219,11 +219,11 @@ U_BOOT_DRIVER(dwc3_generic_host) = {
 #endif
 
 struct dwc3_glue_ops {
-   void (*select_dr_mode)(struct udevice *dev, int index,
+   void (*glue_configure)(struct udevice *dev, int index,
   enum usb_dr_mode mode);
 };
 
-void dwc3_ti_select_dr_mode(struct udevice *dev, int index,
+void dwc3_ti_glue_configure(struct udevice *dev, int index,
enum usb_dr_mode mode)
 {
 #define USBOTGSS_UTMI_OTG_STATUS   0x0084
@@ -304,7 +304,7 @@ enum dwc3_omap_utmi_mode {
 }
 
 struct dwc3_glue_ops ti_ops = {
-   .select_dr_mode = dwc3_ti_select_dr_mode,
+   .glue_configure = dwc3_ti_glue_configure,
 };
 
 static int dwc3_glue_bind(struct udevice *parent)
@@ -435,8 +435,8 @@ static int dwc3_glue_probe(struct udevice *dev)
 
dr_mode = usb_get_dr_mode(dev_ofnode(child));
device_find_next_child();
-   if (ops && ops->select_dr_mode)
-   ops->select_dr_mode(dev, index, dr_mode);
+   if (ops && ops->glue_configure)
+   ops->glue_configure(dev, index, dr_mode);
index++;
}
 
-- 
2.35.1



[PATCH v4 07/10] imx: power-domain: Add i.MX8MP HSIOMIX driver

2022-04-12 Thread Marek Vasut
Add trivial driver for i.MX8MP HSIOMIX handling. This is responsible
for enabling the GPCv2 power domains and clock for USB 3.0 and PCIe
in the correct order. Currently supported is the USB 3.0 part which
can be tested, PCIe support should be easy to add.

Tested-By: Tim Harvey  #imx8mp-venice-gw74xx
Signed-off-by: Marek Vasut 
Cc: Fabio Estevam 
Cc: Peng Fan 
Cc: Stefano Babic 
---
V2: Drop two left over unused variables which triggered build warning
V3: Add TB from Tim
V4: Rebase on u-boot-imx/master
---
 drivers/power/domain/Kconfig  |   7 ++
 drivers/power/domain/Makefile |   1 +
 drivers/power/domain/imx8mp-hsiomix.c | 159 ++
 3 files changed, 167 insertions(+)
 create mode 100644 drivers/power/domain/imx8mp-hsiomix.c

diff --git a/drivers/power/domain/Kconfig b/drivers/power/domain/Kconfig
index 04fc0054323..7e1b8c072fa 100644
--- a/drivers/power/domain/Kconfig
+++ b/drivers/power/domain/Kconfig
@@ -40,6 +40,13 @@ config IMX8M_POWER_DOMAIN
  Enable support for manipulating NXP i.MX8M on-SoC power domains via
  requests to the ATF.
 
+config IMX8MP_HSIOMIX_BLKCTRL
+   bool "Enable i.MX8MP HSIOMIX domain driver"
+   depends on POWER_DOMAIN && IMX8MP
+   select CLK
+   help
+ Enable support for manipulating NXP i.MX8MP on-SoC HSIOMIX block 
controller.
+
 config MTK_POWER_DOMAIN
bool "Enable the MediaTek power domain driver"
depends on POWER_DOMAIN && ARCH_MEDIATEK
diff --git a/drivers/power/domain/Makefile b/drivers/power/domain/Makefile
index 7c8af67dbd6..e6244776216 100644
--- a/drivers/power/domain/Makefile
+++ b/drivers/power/domain/Makefile
@@ -8,6 +8,7 @@ obj-$(CONFIG_APPLE_PMGR_POWER_DOMAIN) += apple-pmgr.o
 obj-$(CONFIG_BCM6328_POWER_DOMAIN) += bcm6328-power-domain.o
 obj-$(CONFIG_IMX8_POWER_DOMAIN) += imx8-power-domain-legacy.o 
imx8-power-domain.o
 obj-$(CONFIG_IMX8M_POWER_DOMAIN) += imx8m-power-domain.o
+obj-$(CONFIG_IMX8MP_HSIOMIX_BLKCTRL) += imx8mp-hsiomix.o
 obj-$(CONFIG_MTK_POWER_DOMAIN) += mtk-power-domain.o
 obj-$(CONFIG_MESON_GX_VPU_POWER_DOMAIN) += meson-gx-pwrc-vpu.o
 obj-$(CONFIG_MESON_EE_POWER_DOMAIN) += meson-ee-pwrc.o
diff --git a/drivers/power/domain/imx8mp-hsiomix.c 
b/drivers/power/domain/imx8mp-hsiomix.c
new file mode 100644
index 000..6a721a934a7
--- /dev/null
+++ b/drivers/power/domain/imx8mp-hsiomix.c
@@ -0,0 +1,159 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2022 Marek Vasut 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#define GPR_REG0   0x0
+#define  PCIE_CLOCK_MODULE_EN  BIT(0)
+#define  USB_CLOCK_MODULE_EN   BIT(1)
+
+struct imx8mp_hsiomix_priv {
+   void __iomem *base;
+   struct clk clk_usb;
+   struct power_domain pd_bus;
+   struct power_domain pd_usb;
+   struct power_domain pd_usb_phy1;
+   struct power_domain pd_usb_phy2;
+};
+
+static int imx8mp_hsiomix_on(struct power_domain *power_domain)
+{
+   struct udevice *dev = power_domain->dev;
+   struct imx8mp_hsiomix_priv *priv = dev_get_priv(dev);
+   struct power_domain *domain;
+   int ret;
+
+   ret = power_domain_on(>pd_bus);
+   if (ret)
+   return ret;
+
+   if (power_domain->id == IMX8MP_HSIOBLK_PD_USB) {
+   domain = >pd_usb;
+   } else if (power_domain->id == IMX8MP_HSIOBLK_PD_USB_PHY1) {
+   domain = >pd_usb_phy1;
+   } else if (power_domain->id == IMX8MP_HSIOBLK_PD_USB_PHY2) {
+   domain = >pd_usb_phy2;
+   } else {
+   ret = -EINVAL;
+   goto err_pd;
+   }
+
+   ret = power_domain_on(domain);
+   if (ret)
+   goto err_pd;
+
+   ret = clk_enable(>clk_usb);
+   if (ret)
+   goto err_clk;
+
+   if (power_domain->id == IMX8MP_HSIOBLK_PD_USB)
+   setbits_le32(priv->base + GPR_REG0, USB_CLOCK_MODULE_EN);
+
+   return 0;
+
+err_clk:
+   power_domain_off(domain);
+err_pd:
+   power_domain_off(>pd_bus);
+   return ret;
+}
+
+static int imx8mp_hsiomix_off(struct power_domain *power_domain)
+{
+   struct udevice *dev = power_domain->dev;
+   struct imx8mp_hsiomix_priv *priv = dev_get_priv(dev);
+
+   if (power_domain->id == IMX8MP_HSIOBLK_PD_USB)
+   clrbits_le32(priv->base + GPR_REG0, USB_CLOCK_MODULE_EN);
+
+   clk_disable(>clk_usb);
+
+   if (power_domain->id == IMX8MP_HSIOBLK_PD_USB)
+   power_domain_off(>pd_usb);
+   else if (power_domain->id == IMX8MP_HSIOBLK_PD_USB_PHY1)
+   power_domain_off(>pd_usb_phy1);
+   else if (power_domain->id == IMX8MP_HSIOBLK_PD_USB_PHY2)
+   power_domain_off(>pd_usb_phy2);
+
+   power_domain_off(>pd_bus);
+
+   return 0;
+}
+
+static int imx8mp_hsiomix_of_xlate(struct power_domain *power_domain,
+  struct ofnode_phandle_args *args)
+{
+   power_domain->id = 

[PATCH v4 06/10] imx: power-domain: Add i.MX8MP support

2022-04-12 Thread Marek Vasut
Add i.MX8MP power domain handling into the driver. This is based on the
Linux GPCv2 driver state which is soon to be in Linux next.

Tested-By: Tim Harvey  #imx8mp-venice-gw74xx
Signed-off-by: Marek Vasut 
Cc: Fabio Estevam 
Cc: Peng Fan 
Cc: Stefano Babic 
---
V2: Add TB by Tim
V3: Skipped to align the Vx scheme
V4: Rebase on u-boot-imx/master
---
 drivers/power/domain/imx8m-power-domain.c | 79 +++
 include/dt-bindings/power/imx8mp-power.h  | 46 +
 2 files changed, 125 insertions(+)
 create mode 100644 include/dt-bindings/power/imx8mp-power.h

diff --git a/drivers/power/domain/imx8m-power-domain.c 
b/drivers/power/domain/imx8m-power-domain.c
index e2e41cf5fee..145f6ec0cd3 100644
--- a/drivers/power/domain/imx8m-power-domain.c
+++ b/drivers/power/domain/imx8m-power-domain.c
@@ -20,11 +20,13 @@
 
 #include 
 #include 
+#include 
 #include 
 
 DECLARE_GLOBAL_DATA_PTR;
 
 #define GPC_PGC_CPU_MAPPING0x0ec
+#define IMX8MP_GPC_PGC_CPU_MAPPING 0x1cc
 
 #define IMX8M_PCIE2_A53_DOMAIN BIT(15)
 #define IMX8M_OTG2_A53_DOMAIN  BIT(5)
@@ -38,6 +40,14 @@ DECLARE_GLOBAL_DATA_PTR;
 #define IMX8MN_OTG1_A53_DOMAIN BIT(4)
 #define IMX8MN_MIPI_A53_DOMAIN BIT(2)
 
+#define IMX8MP_HSIOMIX_A53_DOMAIN  BIT(19)
+#define IMX8MP_USB2_PHY_A53_DOMAIN BIT(5)
+#define IMX8MP_USB1_PHY_A53_DOMAIN BIT(4)
+#define IMX8MP_PCIE_PHY_A53_DOMAIN BIT(3)
+
+#define IMX8MP_GPC_PU_PGC_SW_PUP_REQ   0x0d8
+#define IMX8MP_GPC_PU_PGC_SW_PDN_REQ   0x0e4
+
 #define GPC_PU_PGC_SW_PUP_REQ  0x0f8
 #define GPC_PU_PGC_SW_PDN_REQ  0x104
 
@@ -53,8 +63,14 @@ DECLARE_GLOBAL_DATA_PTR;
 #define IMX8MN_OTG1_SW_Pxx_REQ BIT(2)
 #define IMX8MN_MIPI_SW_Pxx_REQ BIT(0)
 
+#define IMX8MP_HSIOMIX_Pxx_REQ BIT(17)
+#define IMX8MP_USB2_PHY_Pxx_REQBIT(3)
+#define IMX8MP_USB1_PHY_Pxx_REQBIT(2)
+#define IMX8MP_PCIE_PHY_SW_Pxx_REQ BIT(1)
+
 #define GPC_M4_PU_PDN_FLG  0x1bc
 
+#define IMX8MP_GPC_PU_PWRHSK   0x190
 #define GPC_PU_PWRHSK  0x1fc
 
 #define IMX8MM_HSIO_HSK_PWRDNACKN  (BIT(23) | BIT(24))
@@ -63,6 +79,9 @@ DECLARE_GLOBAL_DATA_PTR;
 #define IMX8MN_HSIO_HSK_PWRDNACKN  BIT(23)
 #define IMX8MN_HSIO_HSK_PWRDNREQN  BIT(5)
 
+#define IMX8MP_HSIOMIX_PWRDNACKN   BIT(28)
+#define IMX8MP_HSIOMIX_PWRDNREQN   BIT(12)
+
 /*
  * The PGC offset values in Reference Manual
  * (Rev. 1, 01/2018 and the older ones) GPC chapter's
@@ -80,6 +99,11 @@ DECLARE_GLOBAL_DATA_PTR;
 
 #define IMX8MN_PGC_OTG118
 
+#define IMX8MP_PGC_PCIE13
+#define IMX8MP_PGC_USB114
+#define IMX8MP_PGC_USB215
+#define IMX8MP_PGC_HSIOMIX 29
+
 #define GPC_PGC_CTRL(n)(0x800 + (n) * 0x40)
 #define GPC_PGC_SR(n)  (GPC_PGC_CTRL(n) + 0xc)
 
@@ -244,6 +268,58 @@ static const struct imx_pgc_domain_data 
imx8mn_pgc_domain_data = {
 };
 #endif
 
+#ifdef CONFIG_IMX8MP
+static const struct imx_pgc_domain imx8mp_pgc_domains[] = {
+   [IMX8MP_POWER_DOMAIN_PCIE_PHY] = {
+   .bits = {
+   .pxx = IMX8MP_PCIE_PHY_SW_Pxx_REQ,
+   .map = IMX8MP_PCIE_PHY_A53_DOMAIN,
+   },
+   .pgc = BIT(IMX8MP_PGC_PCIE),
+   },
+
+   [IMX8MP_POWER_DOMAIN_USB1_PHY] = {
+   .bits = {
+   .pxx = IMX8MP_USB1_PHY_Pxx_REQ,
+   .map = IMX8MP_USB1_PHY_A53_DOMAIN,
+   },
+   .pgc = BIT(IMX8MP_PGC_USB1),
+   },
+
+   [IMX8MP_POWER_DOMAIN_USB2_PHY] = {
+   .bits = {
+   .pxx = IMX8MP_USB2_PHY_Pxx_REQ,
+   .map = IMX8MP_USB2_PHY_A53_DOMAIN,
+   },
+   .pgc = BIT(IMX8MP_PGC_USB2),
+   },
+
+   [IMX8MP_POWER_DOMAIN_HSIOMIX] = {
+   .bits = {
+   .pxx = IMX8MP_HSIOMIX_Pxx_REQ,
+   .map = IMX8MP_HSIOMIX_A53_DOMAIN,
+   .hskreq = IMX8MP_HSIOMIX_PWRDNREQN,
+   .hskack = IMX8MP_HSIOMIX_PWRDNACKN,
+   },
+   .pgc = BIT(IMX8MP_PGC_HSIOMIX),
+   .keep_clocks = true,
+   },
+};
+
+static const struct imx_pgc_regs imx8mp_pgc_regs = {
+   .map = IMX8MP_GPC_PGC_CPU_MAPPING,
+   .pup = IMX8MP_GPC_PU_PGC_SW_PUP_REQ,
+   .pdn = IMX8MP_GPC_PU_PGC_SW_PDN_REQ,
+   .hsk = IMX8MP_GPC_PU_PWRHSK,
+};
+
+static const struct imx_pgc_domain_data imx8mp_pgc_domain_data = {
+   .domains = imx8mp_pgc_domains,
+   .domains_num = ARRAY_SIZE(imx8mp_pgc_domains),
+   .pgc_regs = _pgc_regs,
+};
+#endif

[PATCH v4 05/10] power_domain: Add power_domain_get_by_name()

2022-04-12 Thread Marek Vasut
Implement power_domain_get_by_name() convenience function which parses
DT property 'power-domain-names' and looks up power domain by matching
name.

Signed-off-by: Marek Vasut 
Cc: Patrick Delaunay 
Cc: Simon Glass 
---
V2: Skipped to align the Vx scheme
V3: Skipped to align the Vx scheme
V4: Rebase on u-boot-imx/master
---
 drivers/power/domain/power-domain-uclass.c | 14 ++
 include/power-domain.h | 21 +
 2 files changed, 35 insertions(+)

diff --git a/drivers/power/domain/power-domain-uclass.c 
b/drivers/power/domain/power-domain-uclass.c
index 0c5823ceddf..74c33d4e2e0 100644
--- a/drivers/power/domain/power-domain-uclass.c
+++ b/drivers/power/domain/power-domain-uclass.c
@@ -80,6 +80,20 @@ int power_domain_get_by_index(struct udevice *dev,
return 0;
 }
 
+int power_domain_get_by_name(struct udevice *dev,
+struct power_domain *power_domain, const char 
*name)
+{
+   int index;
+
+   index = dev_read_stringlist_search(dev, "power-domain-names", name);
+   if (index < 0) {
+   debug("fdt_stringlist_search() failed: %d\n", index);
+   return index;
+   }
+
+   return power_domain_get_by_index(dev, power_domain, index);
+}
+
 int power_domain_get(struct udevice *dev, struct power_domain *power_domain)
 {
return power_domain_get_by_index(dev, power_domain, 0);
diff --git a/include/power-domain.h b/include/power-domain.h
index 113276b5119..2ff6c77cd76 100644
--- a/include/power-domain.h
+++ b/include/power-domain.h
@@ -107,6 +107,27 @@ int power_domain_get_by_index(struct udevice *dev,
 }
 #endif
 
+/**
+ * power_domain_get_by_name - Get the named power domain for a device.
+ *
+ * @dev:   The client device.
+ * @power_domain:  A pointer to a power domain struct to initialize.
+ * @name:  Power domain name to be powered on.
+ *
+ * Return: 0 if OK, or a negative error code.
+ */
+#if CONFIG_IS_ENABLED(POWER_DOMAIN)
+int power_domain_get_by_name(struct udevice *dev,
+struct power_domain *power_domain, const char 
*name);
+#else
+static inline
+int power_domain_get_by_name(struct udevice *dev,
+struct power_domain *power_domain, const char 
*name)
+{
+   return -ENOSYS;
+}
+#endif
+
 /**
  * power_domain_free - Free a previously requested power domain.
  *
-- 
2.35.1



[PATCH v4 04/10] imx: power-domain: Get rid of SMCCC dependency

2022-04-12 Thread Marek Vasut
This driver is the only SMCCC dependency in iMX8M U-Boot port. Rework
the driver based on Linux GPCv2 driver to directly control the GPCv2
block instead of using SMCCC calls. This way, U-Boot can operate the
i.MX8M power domains without depending on anything else.

This is losely based on Linux GPCv2 driver. The GPU, VPU, MIPI power
domains are not supported to save space, since they are not useful in
the bootloader. The only domains kept are ones for HSIO, PCIe, USB.

Tested-By: Tim Harvey  #imx8mp-venice-defconfig
Signed-off-by: Marek Vasut 
Cc: Fabio Estevam 
Cc: Peng Fan 
Cc: Stefano Babic 
---
V2: Add TB by Tim
V3: Skipped to align the Vx scheme
V4: Rebase on u-boot-imx/master
---
 drivers/power/domain/Kconfig  |   1 +
 drivers/power/domain/imx8m-power-domain.c | 379 --
 2 files changed, 361 insertions(+), 19 deletions(-)

diff --git a/drivers/power/domain/Kconfig b/drivers/power/domain/Kconfig
index 93d2599d83c..04fc0054323 100644
--- a/drivers/power/domain/Kconfig
+++ b/drivers/power/domain/Kconfig
@@ -35,6 +35,7 @@ config IMX8_POWER_DOMAIN
 config IMX8M_POWER_DOMAIN
bool "Enable i.MX8M power domain driver"
depends on POWER_DOMAIN && ARCH_IMX8M
+   select CLK
help
  Enable support for manipulating NXP i.MX8M on-SoC power domains via
  requests to the ATF.
diff --git a/drivers/power/domain/imx8m-power-domain.c 
b/drivers/power/domain/imx8m-power-domain.c
index c32dbcc31ae..e2e41cf5fee 100644
--- a/drivers/power/domain/imx8m-power-domain.c
+++ b/drivers/power/domain/imx8m-power-domain.c
@@ -4,6 +4,7 @@
  */
 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -12,52 +13,361 @@
 #include 
 #include 
 #include 
+#include 
 #include 
-#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#define GPC_PGC_CPU_MAPPING0x0ec
+
+#define IMX8M_PCIE2_A53_DOMAIN BIT(15)
+#define IMX8M_OTG2_A53_DOMAIN  BIT(5)
+#define IMX8M_OTG1_A53_DOMAIN  BIT(4)
+#define IMX8M_PCIE1_A53_DOMAIN BIT(3)
+
+#define IMX8MM_OTG2_A53_DOMAIN BIT(5)
+#define IMX8MM_OTG1_A53_DOMAIN BIT(4)
+#define IMX8MM_PCIE_A53_DOMAIN BIT(3)
+
+#define IMX8MN_OTG1_A53_DOMAIN BIT(4)
+#define IMX8MN_MIPI_A53_DOMAIN BIT(2)
+
+#define GPC_PU_PGC_SW_PUP_REQ  0x0f8
+#define GPC_PU_PGC_SW_PDN_REQ  0x104
+
+#define IMX8M_PCIE2_SW_Pxx_REQ BIT(13)
+#define IMX8M_OTG2_SW_Pxx_REQ  BIT(3)
+#define IMX8M_OTG1_SW_Pxx_REQ  BIT(2)
+#define IMX8M_PCIE1_SW_Pxx_REQ BIT(1)
+
+#define IMX8MM_OTG2_SW_Pxx_REQ BIT(3)
+#define IMX8MM_OTG1_SW_Pxx_REQ BIT(2)
+#define IMX8MM_PCIE_SW_Pxx_REQ BIT(1)
+
+#define IMX8MN_OTG1_SW_Pxx_REQ BIT(2)
+#define IMX8MN_MIPI_SW_Pxx_REQ BIT(0)
+
+#define GPC_M4_PU_PDN_FLG  0x1bc
+
+#define GPC_PU_PWRHSK  0x1fc
+
+#define IMX8MM_HSIO_HSK_PWRDNACKN  (BIT(23) | BIT(24))
+#define IMX8MM_HSIO_HSK_PWRDNREQN  (BIT(5) | BIT(6))
+
+#define IMX8MN_HSIO_HSK_PWRDNACKN  BIT(23)
+#define IMX8MN_HSIO_HSK_PWRDNREQN  BIT(5)
+
+/*
+ * The PGC offset values in Reference Manual
+ * (Rev. 1, 01/2018 and the older ones) GPC chapter's
+ * GPC_PGC memory map are incorrect, below offset
+ * values are from design RTL.
+ */
+#define IMX8M_PGC_PCIE117
+#define IMX8M_PGC_OTG1 18
+#define IMX8M_PGC_OTG2 19
+#define IMX8M_PGC_PCIE229
+
+#define IMX8MM_PGC_PCIE17
+#define IMX8MM_PGC_OTG118
+#define IMX8MM_PGC_OTG219
+
+#define IMX8MN_PGC_OTG118
+
+#define GPC_PGC_CTRL(n)(0x800 + (n) * 0x40)
+#define GPC_PGC_SR(n)  (GPC_PGC_CTRL(n) + 0xc)
+
+#define GPC_PGC_CTRL_PCR   BIT(0)
+
+struct imx_pgc_regs {
+   u16 map;
+   u16 pup;
+   u16 pdn;
+   u16 hsk;
+};
+
+struct imx_pgc_domain {
+   unsigned long pgc;
+
+   const struct {
+   u32 pxx;
+   u32 map;
+   u32 hskreq;
+   u32 hskack;
+   } bits;
+
+   const bool keep_clocks;
+};
+
+struct imx_pgc_domain_data {
+   const struct imx_pgc_domain *domains;
+   size_t domains_num;
+   const struct imx_pgc_regs *pgc_regs;
+};
+
 struct imx8m_power_domain_plat {
+   struct power_domain pd;
+   const struct imx_pgc_domain *domain;
+   const struct imx_pgc_regs *regs;
+   struct clk_bulk clk;
+   void __iomem *base;
int resource_id;
int has_pd;
-   struct power_domain pd;
 };
 
+#if defined(CONFIG_IMX8MM) || defined(CONFIG_IMX8MN) || 

[PATCH v4 03/10] imx: power-domain: Inline arch-imx8m/power-domain.h

2022-04-12 Thread Marek Vasut
The arch/arm/include/asm/arch-imx8m/power-domain.h is not included
anywhere except in drivers/power/domain/imx8m-power-domain.c, just
inline the content and drop the header. No functional change.

Tested-By: Tim Harvey  #imx8mp-venice-defconfig
Signed-off-by: Marek Vasut 
Cc: Fabio Estevam 
Cc: Peng Fan 
Cc: Stefano Babic 
---
V2: Add TB by Tim
V3: Skipped to align the Vx scheme
V4: Rebase on u-boot-imx/master
---
 arch/arm/include/asm/arch-imx8m/power-domain.h | 15 ---
 drivers/power/domain/imx8m-power-domain.c  |  7 ++-
 2 files changed, 6 insertions(+), 16 deletions(-)
 delete mode 100644 arch/arm/include/asm/arch-imx8m/power-domain.h

diff --git a/arch/arm/include/asm/arch-imx8m/power-domain.h 
b/arch/arm/include/asm/arch-imx8m/power-domain.h
deleted file mode 100644
index 7a833e564b5..000
--- a/arch/arm/include/asm/arch-imx8m/power-domain.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Copyright 2017 NXP
- */
-
-#ifndef _ASM_ARCH_IMX8M_POWER_DOMAIN_H
-#define _ASM_ARCH_IMX8M_POWER_DOMAIN_H
-
-struct imx8m_power_domain_plat {
-   int resource_id;
-   int has_pd;
-   struct power_domain pd;
-};
-
-#endif
diff --git a/drivers/power/domain/imx8m-power-domain.c 
b/drivers/power/domain/imx8m-power-domain.c
index ac7411f8327..c32dbcc31ae 100644
--- a/drivers/power/domain/imx8m-power-domain.c
+++ b/drivers/power/domain/imx8m-power-domain.c
@@ -9,7 +9,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
@@ -18,6 +17,12 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+struct imx8m_power_domain_plat {
+   int resource_id;
+   int has_pd;
+   struct power_domain pd;
+};
+
 static int imx8m_power_domain_on(struct power_domain *power_domain)
 {
struct udevice *dev = power_domain->dev;
-- 
2.35.1



[PATCH v4 02/10] imx: power-domain: Descend into pgc subnode if present

2022-04-12 Thread Marek Vasut
In case the power domain node structure is gpc@303a/pgc/power-domain@N,
do not bind power domain driver to the 'pgc' node, but rather descend into
it and only bind power domain drivers to power-domain@N subnodes. This way
we do not waste one useless driver instance associated with 'pgc' node.

Tested-By: Tim Harvey  #imx8mp-venice-defconfig
Signed-off-by: Marek Vasut 
Cc: Fabio Estevam 
Cc: Peng Fan 
Cc: Stefano Babic 
---
V2: Add TB by Tim
V3: Skipped to align the Vx scheme
V4: Rebase on u-boot-imx/master
---
 drivers/power/domain/imx8m-power-domain.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/power/domain/imx8m-power-domain.c 
b/drivers/power/domain/imx8m-power-domain.c
index 6082ee6ff8c..ac7411f8327 100644
--- a/drivers/power/domain/imx8m-power-domain.c
+++ b/drivers/power/domain/imx8m-power-domain.c
@@ -73,6 +73,12 @@ static int imx8m_power_domain_bind(struct udevice *dev)
/* Bind the subnode to this driver */
name = fdt_get_name(gd->fdt_blob, offset, NULL);
 
+   /* Descend into 'pgc' subnode */
+   if (!strstr(name, "power-domain")) {
+   offset = fdt_first_subnode(gd->fdt_blob, offset);
+   name = fdt_get_name(gd->fdt_blob, offset, NULL);
+   }
+
ret = device_bind_with_driver_data(dev, dev->driver, name,
   dev->driver_data,
   offset_to_ofnode(offset),
-- 
2.35.1



[PATCH v4 01/10] power-domain: Return 0 if ops unimplemented and remove empty functions

2022-04-12 Thread Marek Vasut
In case the ops is not implemented, return 0 in the core right away.
This is better than having multiple copies of functions which just
return 0 in each power domain driver. Drop all those empty functions.

Signed-off-by: Marek Vasut 
Cc: Patrick Delaunay 
Cc: Simon Glass 
---
V2: Skipped to align the Vx scheme
V3: Skipped to align the Vx scheme
V4: Rebase on u-boot-imx/master
---
 drivers/power/domain/apple-pmgr.c | 30 ---
 drivers/power/domain/bcm6328-power-domain.c   |  6 
 .../power/domain/imx8-power-domain-legacy.c   | 16 --
 drivers/power/domain/imx8-power-domain.c  | 24 ---
 drivers/power/domain/imx8m-power-domain.c | 18 ---
 drivers/power/domain/meson-ee-pwrc.c  | 12 
 drivers/power/domain/meson-gx-pwrc-vpu.c  | 12 
 drivers/power/domain/mtk-power-domain.c   |  6 
 drivers/power/domain/power-domain-uclass.c|  8 ++---
 drivers/power/domain/tegra186-power-domain.c  | 26 
 drivers/power/domain/ti-power-domain.c| 13 
 drivers/power/domain/ti-sci-power-domain.c| 14 -
 12 files changed, 4 insertions(+), 181 deletions(-)

diff --git a/drivers/power/domain/apple-pmgr.c 
b/drivers/power/domain/apple-pmgr.c
index 4d06e76ff5e..402c5b1fd18 100644
--- a/drivers/power/domain/apple-pmgr.c
+++ b/drivers/power/domain/apple-pmgr.c
@@ -42,16 +42,6 @@ static int apple_reset_of_xlate(struct reset_ctl *reset_ctl,
return 0;
 }
 
-static int apple_reset_request(struct reset_ctl *reset_ctl)
-{
-   return 0;
-}
-
-static int apple_reset_free(struct reset_ctl *reset_ctl)
-{
-   return 0;
-}
-
 static int apple_reset_assert(struct reset_ctl *reset_ctl)
 {
struct apple_pmgr_priv *priv = dev_get_priv(reset_ctl->dev->parent);
@@ -80,8 +70,6 @@ static int apple_reset_deassert(struct reset_ctl *reset_ctl)
 
 struct reset_ops apple_reset_ops = {
.of_xlate = apple_reset_of_xlate,
-   .request = apple_reset_request,
-   .rfree = apple_reset_free,
.rst_assert = apple_reset_assert,
.rst_deassert = apple_reset_deassert,
 };
@@ -92,16 +80,6 @@ static struct driver apple_reset_driver = {
.ops = _reset_ops,
 };
 
-static int apple_pmgr_request(struct power_domain *power_domain)
-{
-   return 0;
-}
-
-static int apple_pmgr_rfree(struct power_domain *power_domain)
-{
-   return 0;
-}
-
 static int apple_pmgr_ps_set(struct power_domain *power_domain, u32 pstate)
 {
struct apple_pmgr_priv *priv = dev_get_priv(power_domain->dev);
@@ -121,11 +99,6 @@ static int apple_pmgr_on(struct power_domain *power_domain)
return apple_pmgr_ps_set(power_domain, APPLE_PMGR_PS_ACTIVE);
 }
 
-static int apple_pmgr_off(struct power_domain *power_domain)
-{
-   return 0;
-}
-
 static int apple_pmgr_of_xlate(struct power_domain *power_domain,
   struct ofnode_phandle_args *args)
 {
@@ -167,10 +140,7 @@ static int apple_pmgr_probe(struct udevice *dev)
 }
 
 struct power_domain_ops apple_pmgr_ops = {
-   .request = apple_pmgr_request,
-   .rfree = apple_pmgr_rfree,
.on = apple_pmgr_on,
-   .off = apple_pmgr_off,
.of_xlate = apple_pmgr_of_xlate,
 };
 
diff --git a/drivers/power/domain/bcm6328-power-domain.c 
b/drivers/power/domain/bcm6328-power-domain.c
index 6e720e0798c..80144dd9772 100644
--- a/drivers/power/domain/bcm6328-power-domain.c
+++ b/drivers/power/domain/bcm6328-power-domain.c
@@ -24,11 +24,6 @@ static int bcm6328_power_domain_request(struct power_domain 
*power_domain)
return 0;
 }
 
-static int bcm6328_power_domain_free(struct power_domain *power_domain)
-{
-   return 0;
-}
-
 static int bcm6328_power_domain_on(struct power_domain *power_domain)
 {
struct bcm6328_power_domain *priv = dev_get_priv(power_domain->dev);
@@ -64,7 +59,6 @@ static const struct udevice_id bcm6328_power_domain_ids[] = {
 };
 
 struct power_domain_ops bcm6328_power_domain_ops = {
-   .rfree = bcm6328_power_domain_free,
.off = bcm6328_power_domain_off,
.on = bcm6328_power_domain_on,
.request = bcm6328_power_domain_request,
diff --git a/drivers/power/domain/imx8-power-domain-legacy.c 
b/drivers/power/domain/imx8-power-domain-legacy.c
index e2fae2dbc86..bf45891bccd 100644
--- a/drivers/power/domain/imx8-power-domain-legacy.c
+++ b/drivers/power/domain/imx8-power-domain-legacy.c
@@ -84,20 +84,6 @@ int imx8_power_domain_lookup_name(const char *name,
return 0;
 }
 
-static int imx8_power_domain_request(struct power_domain *power_domain)
-{
-   debug("%s(power_domain=%p)\n", __func__, power_domain);
-
-   return 0;
-}
-
-static int imx8_power_domain_free(struct power_domain *power_domain)
-{
-   debug("%s(power_domain=%p)\n", __func__, power_domain);
-
-   return 0;
-}
-
 static int imx8_power_domain_on(struct power_domain *power_domain)
 {
struct udevice *dev = power_domain->dev;
@@ -364,8 +350,6 @@ static const 

[PATCH v2] ARM: imx: Enable instruction cache early on on i.MX8M

2022-04-12 Thread Marek Vasut
Enable instruction cache early on to speed up the boot process on i.MX8M.

Signed-off-by: Marek Vasut 
Cc: Fabio Estevam 
Cc: Peng Fan 
Cc: Stefano Babic 
---
V2: Protect the icache_enable with !CONFIG_IS_ENABLED(SYS_ICACHE_OFF),
the symbol might be undefined in case CONFIG_(SPL_)SYS_ICACHE_OFF
is set
---
 arch/arm/mach-imx/imx8m/soc.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/mach-imx/imx8m/soc.c b/arch/arm/mach-imx/imx8m/soc.c
index bb94ef51492..8171631db10 100644
--- a/arch/arm/mach-imx/imx8m/soc.c
+++ b/arch/arm/mach-imx/imx8m/soc.c
@@ -550,6 +550,11 @@ EVENT_SPY(EVT_DM_POST_INIT, imx8m_check_clock);
 int arch_cpu_init(void)
 {
struct ocotp_regs *ocotp = (struct ocotp_regs *)OCOTP_BASE_ADDR;
+
+#if !CONFIG_IS_ENABLED(SYS_ICACHE_OFF)
+   icache_enable();
+#endif
+
/*
 * ROM might disable clock for SCTR,
 * enable the clock before timer_init.
-- 
2.35.1



[PATCH] clk: imx8mp: Fix 24M and 32k clock

2022-04-12 Thread Marek Vasut
Fix registration of 24M and 32k clock, those got applied or rebased
incorrectly, so fill in the correct code.

Fixes: 7a2c3be95a5 ("clk: imx8mp: Fill in DWC3 USB, USB PHY, HSIOMIX clock")
Signed-off-by: Marek Vasut 
Cc: Fabio Estevam 
Cc: Peng Fan 
Cc: Stefano Babic 
Cc: Ye Li 
---
 drivers/clk/imx/clk-imx8mp.c | 12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/clk/imx/clk-imx8mp.c b/drivers/clk/imx/clk-imx8mp.c
index aba347bc108..ac727b7e404 100644
--- a/drivers/clk/imx/clk-imx8mp.c
+++ b/drivers/clk/imx/clk-imx8mp.c
@@ -162,7 +162,9 @@ static const char *imx8mp_dram_core_sels[] = 
{"dram_pll_out", "dram_alt_root", }
 
 static int imx8mp_clk_probe(struct udevice *dev)
 {
+   struct clk osc_24m_clk, osc_32k_clk;
void __iomem *base;
+   int ret;
 
base = (void *)ANATOP_BASE_ADDR;
 
@@ -215,7 +217,15 @@ static int imx8mp_clk_probe(struct udevice *dev)
clk_dm(IMX8MP_SYS_PLL2_500M, imx_clk_fixed_factor("sys_pll2_500m", 
"sys_pll2_out", 1, 2));
clk_dm(IMX8MP_SYS_PLL2_1000M, imx_clk_fixed_factor("sys_pll2_1000m", 
"sys_pll2_out", 1, 1));
 
-   clk_dm(IMX8MP_CLK_24M, imx_clk_fixed_factor("clock-osc-24m", "osc_24m", 
1, 1));
+   ret = clk_get_by_name(dev, "osc_24m", _24m_clk);
+   if (ret)
+   return ret;
+   clk_dm(IMX8MP_CLK_24M, dev_get_clk_ptr(osc_24m_clk.dev));
+
+   ret = clk_get_by_name(dev, "osc_32k", _32k_clk);
+   if (ret)
+   return ret;
+   clk_dm(IMX8MP_CLK_32K, dev_get_clk_ptr(osc_32k_clk.dev));
 
base = dev_read_addr_ptr(dev);
if (!base)
-- 
2.35.1



[PATCH v3] ARM: imx: Get rid of only i.MX8M SMCCC arch call

2022-04-12 Thread Marek Vasut
This is the only place where i.MX8M code does SMCCC call, remove it.
The output has little value as it prints some part of commit ID, and
worse, if there is no SMC handler installed, the code outright hangs
or crashes the system.

By removing this one instance of SMCCC call, U-Boot no longer depends
on SMC handlers and can boot without hanging in any case. If there is
a need to dump this commit ID, use CMD_SMC instead and do 'smc' call
from U-Boot shell or scripts instead of hard-coding SMCCC dependency
into architecture code. This particular code can be replaced by:
 => smc 0xc203 0 0 0 0 0 0

Reviewed-by: Peng Fan 
Signed-off-by: Marek Vasut 
Cc: Fabio Estevam 
Cc: Peng Fan 
Cc: Stefano Babic 
---
V2: Add RB by Peng
V3: Rebase on u-boot-imx/master
---
 arch/arm/mach-imx/imx8m/soc.c | 19 ---
 1 file changed, 19 deletions(-)

diff --git a/arch/arm/mach-imx/imx8m/soc.c b/arch/arm/mach-imx/imx8m/soc.c
index 75559e3b799..bb94ef51492 100644
--- a/arch/arm/mach-imx/imx8m/soc.c
+++ b/arch/arm/mach-imx/imx8m/soc.c
@@ -29,7 +29,6 @@
 #include 
 #include 
 #include 
-#include 
 #include 
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -1399,23 +1398,6 @@ void reset_cpu(void)
 #endif
 
 #if defined(CONFIG_ARCH_MISC_INIT)
-static void acquire_buildinfo(void)
-{
-   u64 atf_commit = 0;
-   struct arm_smccc_res res;
-
-   /* Get ARM Trusted Firmware commit id */
-   arm_smccc_smc(IMX_SIP_BUILDINFO, IMX_SIP_BUILDINFO_GET_COMMITHASH,
- 0, 0, 0, 0, 0, 0, );
-   atf_commit = res.a0;
-   if (atf_commit == 0x) {
-   debug("ATF does not support build info\n");
-   atf_commit = 0x30; /* Display 0, 0 ascii is 0x30 */
-   }
-
-   printf("\n BuildInfo:\n  - ATF %s\n\n", (char *)_commit);
-}
-
 int arch_misc_init(void)
 {
if (IS_ENABLED(CONFIG_FSL_CAAM)) {
@@ -1426,7 +1408,6 @@ int arch_misc_init(void)
if (ret)
printf("Failed to initialize %s: %d\n", dev->name, ret);
}
-   acquire_buildinfo();
 
return 0;
 }
-- 
2.35.1



[PATCH v3 2/2] pmic: pca9450: Add regulator driver

2022-04-12 Thread Marek Vasut
Add PCA9450 regulator driver. This is complementary driver for the BUCKn
and LDOn regulators provided by the PCA9450 PMIC driver. Currently the
driver permits reading the settngs and configuring the BUCKn and LDOn
regulators.

Reviewed-by: Fabio Estevam 
Signed-off-by: Marek Vasut 
Cc: Fabio Estevam 
Cc: Peng Fan 
Cc: Stefano Babic 
---
V2: Add RB by Fabio
V3: Rebase on u-boot-imx/master
---
 drivers/power/pmic/pca9450.c  |   6 +-
 drivers/power/regulator/Kconfig   |  15 ++
 drivers/power/regulator/Makefile  |   1 +
 drivers/power/regulator/pca9450.c | 333 ++
 include/power/pca9450.h   |  11 +
 5 files changed, 363 insertions(+), 3 deletions(-)
 create mode 100644 drivers/power/regulator/pca9450.c

diff --git a/drivers/power/pmic/pca9450.c b/drivers/power/pmic/pca9450.c
index 26c876c9c45..116ac49a8db 100644
--- a/drivers/power/pmic/pca9450.c
+++ b/drivers/power/pmic/pca9450.c
@@ -83,9 +83,9 @@ static struct dm_pmic_ops pca9450_ops = {
 };
 
 static const struct udevice_id pca9450_ids[] = {
-   { .compatible = "nxp,pca9450a", .data = 0x25, },
-   { .compatible = "nxp,pca9450b", .data = 0x25, },
-   { .compatible = "nxp,pca9450c", .data = 0x25, },
+   { .compatible = "nxp,pca9450a", .data = NXP_CHIP_TYPE_PCA9450A, },
+   { .compatible = "nxp,pca9450b", .data = NXP_CHIP_TYPE_PCA9450BC, },
+   { .compatible = "nxp,pca9450c", .data = NXP_CHIP_TYPE_PCA9450BC, },
{ }
 };
 
diff --git a/drivers/power/regulator/Kconfig b/drivers/power/regulator/Kconfig
index cd253b95f2f..d486bad6bdc 100644
--- a/drivers/power/regulator/Kconfig
+++ b/drivers/power/regulator/Kconfig
@@ -60,6 +60,21 @@ config SPL_DM_REGULATOR_BD71837
This config enables implementation of driver-model regulator uclass
features for regulators on ROHM BD71837 and BD71847 in SPL.
 
+config DM_REGULATOR_PCA9450
+   bool "Enable Driver Model for NXP PCA9450 regulators"
+   depends on DM_REGULATOR && DM_PMIC_PCA9450
+   help
+   This config enables implementation of driver-model regulator uclass
+   features for regulators on NXP PCA9450 PMICs. PCA9450 contains 6 bucks
+   and 5 LDOS. The driver implements get/set api for value and enable.
+
+config SPL_DM_REGULATOR_PCA9450
+   bool "Enable Driver Model for NXP PCA9450 regulators in SPL"
+   depends on DM_REGULATOR_PCA9450
+   help
+   This config enables implementation of driver-model regulator uclass
+   features for regulators on ROHM PCA9450 in SPL.
+
 config DM_REGULATOR_DA9063
bool "Enable Driver Model for REGULATOR DA9063"
depends on DM_REGULATOR && DM_PMIC_DA9063
diff --git a/drivers/power/regulator/Makefile b/drivers/power/regulator/Makefile
index 4efb32a3228..d2d17f7aed0 100644
--- a/drivers/power/regulator/Makefile
+++ b/drivers/power/regulator/Makefile
@@ -11,6 +11,7 @@ obj-$(CONFIG_$(SPL_)DM_REGULATOR_DA9063) += da9063.o
 obj-$(CONFIG_DM_REGULATOR_MAX77686) += max77686.o
 obj-$(CONFIG_$(SPL_)DM_PMIC_PFUZE100) += pfuze100.o
 obj-$(CONFIG_$(SPL_)DM_REGULATOR_BD71837) += bd71837.o
+obj-$(CONFIG_$(SPL_)DM_REGULATOR_PCA9450) += pca9450.o
 obj-$(CONFIG_$(SPL_)REGULATOR_PWM) += pwm_regulator.o
 obj-$(CONFIG_$(SPL_)DM_REGULATOR_FAN53555) += fan53555.o
 obj-$(CONFIG_$(SPL_)DM_REGULATOR_COMMON) += regulator_common.o
diff --git a/drivers/power/regulator/pca9450.c 
b/drivers/power/regulator/pca9450.c
new file mode 100644
index 000..4847c9f90f0
--- /dev/null
+++ b/drivers/power/regulator/pca9450.c
@@ -0,0 +1,333 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * NXP PCA9450 regulator driver
+ * Copyright (C) 2022 Marek Vasut 
+ *
+ * Largely based on:
+ * ROHM BD71837 regulator driver
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define HW_STATE_CONTROL 0
+#define DEBUG
+
+/**
+ * struct pca9450_vrange - describe linear range of voltages
+ *
+ * @min_volt:  smallest voltage in range
+ * @step:  how much voltage changes at each selector step
+ * @min_sel:   smallest selector in the range
+ * @max_sel:   maximum selector in the range
+ */
+struct pca9450_vrange {
+   unsigned intmin_volt;
+   unsigned intstep;
+   u8  min_sel;
+   u8  max_sel;
+};
+
+/**
+ * struct pca9450_plat - describe regulator control registers
+ *
+ * @name:  name of the regulator. Used for matching the dt-entry
+ * @enable_reg:register address used to enable/disable regulator
+ * @enablemask:register mask used to enable/disable regulator
+ * @volt_reg:  register address used to configure regulator voltage
+ * @volt_mask: register mask used to configure regulator voltage
+ * @ranges:pointer to ranges of regulator voltages and matching register
+ * values
+ * @numranges: number of voltage ranges pointed by ranges
+ * @dvs:   whether the voltage can be changed when regulator is enabled
+ */
+struct pca9450_plat {
+   const char  

[PATCH v3 1/2] pmic: pca9450: Add upstream regulators subnode match

2022-04-12 Thread Marek Vasut
The upstream DT regulators node subnodes are named BUCKn and LDOn,
the downstream DT regulators node subnodes are named buckn and ldon,
add the upstream match.

Reviewed-by: Fabio Estevam 
Signed-off-by: Marek Vasut 
Cc: Fabio Estevam 
Cc: Peng Fan 
Cc: Stefano Babic 
---
V2: Add RB by Fabio
V3: Rebase on u-boot-imx/master
---
 drivers/power/pmic/pca9450.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/power/pmic/pca9450.c b/drivers/power/pmic/pca9450.c
index 2394b196c56..26c876c9c45 100644
--- a/drivers/power/pmic/pca9450.c
+++ b/drivers/power/pmic/pca9450.c
@@ -19,8 +19,10 @@ DECLARE_GLOBAL_DATA_PTR;
 static const struct pmic_child_info pmic_children_info[] = {
/* buck */
{ .prefix = "b", .driver = PCA9450_REGULATOR_DRIVER},
+   { .prefix = "B", .driver = PCA9450_REGULATOR_DRIVER},
/* ldo */
{ .prefix = "l", .driver = PCA9450_REGULATOR_DRIVER},
+   { .prefix = "L", .driver = PCA9450_REGULATOR_DRIVER},
{ },
 };
 
-- 
2.35.1



[PATCH] ARM: dts: imx: Add flexspi node to i.MX8MP

2022-04-12 Thread sbabic
> Add flexspi DT node matching Linux kernel as of commit
> d7cd74466651e ("arm64: dts: imx8mp: Reorder flexspi clock-names entry")
> Signed-off-by: Marek Vasut 
> Cc: Fabio Estevam 
> Cc: Peng Fan 
> Cc: Stefano Babic 
> Reviewed-by: Peng Fan 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

-- 
=
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=


[PATCH] board: venice: add spl_board_loader_name

2022-04-12 Thread sbabic
> Implement spl_board_loader_name to provide more meaningful device names
> vs MMC1 and MMC2.
> Signed-off-by: Tim Harvey 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

-- 
=
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=


[PATCH 2/2] ARM: dts: imx8mm: Add i.MX8M Mini Toradex Verdin based Menlo board

2022-04-12 Thread sbabic
> Add new board based on the Toradex Verdin iMX8M Mini SoM, the MX8Menlo.
> The board is a compatible replacement for i.MX53 M53Menlo and features
> USB, multiple UARTs, ethernet, LEDs, SD and eMMC.
> Signed-off-by: Marek Vasut 
> Cc: Fabio Estevam 
> Cc: Marcel Ziswiler 
> Cc: Max Krummenacher 
> Cc: Peng Fan 
> Cc: Stefano Babic 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

-- 
=
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=


[PATCH v2 3/4] ARM: dts: imxrt10..-evk: Linux moved pins-imxrt1020 to dts

2022-04-12 Thread sbabic
> The Linux kernel moved dt-bindings/pinctrl/pins-imxrt to the device tree
> This patch move it in U-Boot as well.
> Signed-off-by: Jesse Taube 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

-- 
=
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=


[PATCH] include: configs: *imx8*: remove IMX_FEC_BASE

2022-04-12 Thread sbabic
> The IMX_FEC_BASE value is not used when CONFIG_DM_ETH is configured. So this
> value can be removed.
> Signed-off-by: Heiko Thiery 
> Reviewed-By: Tim Harvey 
> Reviewed-by: Fabio Estevam 
> Tested-by: Marcel Ziswiler 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

-- 
=
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=


[PATCH] ARM: imx: romapi: Repair FlexSPI NOR boot offset

2022-04-12 Thread sbabic
> The FlexSPI NOR boot offset does not require any special handling,
> the image_offset is correct in either case (0x1000 for FlexSPI NOR
> and 0x8000 for SD/eMMC) and the offset of u-boot.itb from the start
> of flash.bin is always 0x58000 on MX8MN/MX8MP, which matches the
> CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR * 512 - 0x8000 in case
> CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x300, which is always the
> case on MX8MN/MX8MP.
> The CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR is really overloaded in
> case of the MX8MN/MX8MP, but fixing that needs additional plumbing.
> Signed-off-by: Marek Vasut 
> Cc: Fabio Estevam 
> Cc: Peng Fan 
> Cc: Stefano Babic 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

-- 
=
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=


[PATCH] spi: nxp_fspi: Add i.MX8MP compatible string

2022-04-12 Thread sbabic
> The i.MX8M Mini and i.MX8M Plus flexspi IPs are compatible with one
> another, however the linux kernel DT uses separate compatible string
> for each SoC. Add the missing i.MX8MP compatible into this driver.
> Signed-off-by: Marek Vasut 
> Cc: Fabio Estevam 
> Cc: Peng Fan 
> Cc: Stefano Babic 
> Reviewed-by: Peng Fan 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

-- 
=
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=


[PATCH] mmc: fsl_esdhc_imx: Add i.MX8MP compatible string

2022-04-12 Thread sbabic
> Add compatible string for i.MX8MP, which permits i.MX8MP to use
> HS400ES mode, just like all the other i.MX8M.
> Signed-off-by: Marek Vasut 
> Cc: Fabio Estevam 
> Cc: Haibo Chen 
> Cc: Peng Fan 
> Cc: Stefano Babic 
> Reviewed-by: Fabio Estevam 
> Reviewed-by: Peng Fan 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

-- 
=
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=


[PATCH] board: gateworks venice: add support for GPY111 phy

2022-04-12 Thread sbabic
> The TI DP83867 phy has been replaced with the MaxLinear GPY111 phy due
> to part availability.
> Add support for it by adding LED config and dt-prop based internal delay
> config tx-delay/rx-delay per PHY ID.
> Signed-off-by: Tim Harvey 
> Acked-by: Peng Fan 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

-- 
=
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=


[PATCH] imx8m{m,n}-venice-gw7902: add GSC ADC rail for VDD_5P0

2022-04-12 Thread sbabic
> The GW7902-C revision adds an ADC for the VDD_5P0 voltage rail.
> Add register definitions for it.
> Signed-off-by: Tim Harvey 
> Acked-by: Peng Fan 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

-- 
=
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=


[PATCH] clk: imx8mp: Add ECSPI clocks

2022-04-12 Thread sbabic
> Add clock tables required for bing up ECSPI interfaces
> Signed-off-by: Elmar Albert 
> Cc: Fabio Estevam 
> Cc: Peng Fan 
> Cc: Stefano Babic 
> Cc: uboot-imx 
> Signed-off-by: Elmar Albert 
> Reviewed-by: Fabio Esteva, 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

-- 
=
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=


[PATCH v2 4/4] board: freescale: imxrt10..-evk: Fix missing include of serial.h

2022-04-12 Thread sbabic
> If FALCON mode is enabled we have a missing include in spl_start_uboot.
> Signed-off-by: Jesse Taube 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

-- 
=
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=


[PATCH v2 2/4] configs/*imxrt10*: SYS_MALLOC_LEN is too large

2022-04-12 Thread sbabic
> 1M of heap is more than internal ram making booting without SDRAM not
> possible now it is 256k
> Signed-off-by: Jesse Taube 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

-- 
=
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=


[PATCH] imx8m{m,n}_venice: update boot_net script to load fdt

2022-04-12 Thread sbabic
> Update the 'boot_net' script to load the fdt with the kernel.
> Signed-off-by: Tim Harvey 
> Reviewed-by: Fabio Estevam 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

-- 
=
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=


[PATCH] kontron-pitx-imx8m: change environment address variables

2022-04-12 Thread sbabic
> Currently the space between kernel_addr_r and the fdt_addr_r is only 32MB.
> To have enought space to load kernel images bigger than 32MB change the
> variables to a feasible value.
> The new environment variables layout is based on the scheme from
> "include/configs/ti_armv7_common.h".
> The CONFIG_SYS_LOAD_ADDR value is set to 0x4200. With that we have
> the same value as for the kernel_addr_r.
> Signed-off-by: Heiko Thiery 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

-- 
=
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=


[PATCH v2 1/4] clk: imxrt: Use dts for anatop base address

2022-04-12 Thread sbabic
> In Linux IMX and IMXRT use the device tree to hold the anatop address.
> The anatop is used in clock drivers as it controls the internal PLLs
> This will move the macro from asm/arch-imxrt to the device tree.
> This presumably should also be done with the other IMX boards as well.
> Signed-off-by: Jesse Taube 
Applied to u-boot-imx, master, thanks !

Best regards,
Stefano Babic

-- 
=
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=


[PATCH] configs: Enable EXT4 and ISO partitions for the DeveloperBox

2022-04-12 Thread Ilias Apalodimas
Since this box is SystemReady compliant enable ISO_PARTITION which is
needed to start some installers (e.g Fedora).  While at it enable EXT4
as well which is a common filesystem for targets

Signed-off-by: Ilias Apalodimas 
---
 configs/synquacer_developerbox_defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/configs/synquacer_developerbox_defconfig 
b/configs/synquacer_developerbox_defconfig
index fe12c74374f9..4b06b2a523fb 100644
--- a/configs/synquacer_developerbox_defconfig
+++ b/configs/synquacer_developerbox_defconfig
@@ -37,6 +37,7 @@ CONFIG_CMD_FAT=y
 CONFIG_CMD_FS_GENERIC=y
 CONFIG_CMD_MTDPARTS=y
 CONFIG_CMD_LOG=y
+CONFIG_ISO_PARTITION=y
 CONFIG_PARTITION_TYPE_GUID=y
 CONFIG_ENV_OVERWRITE=y
 CONFIG_ENV_IS_IN_SPI_FLASH=y
@@ -85,6 +86,7 @@ CONFIG_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_PCI=y
 CONFIG_USB_STORAGE=y
+CONFIG_FS_EXT4=y
 CONFIG_EFI_SET_TIME=y
 CONFIG_EFI_RUNTIME_UPDATE_CAPSULE=y
 CONFIG_EFI_CAPSULE_ON_DISK=y
-- 
2.32.0



Re: [PATCH] rpi: always set fdt_addr to the correct value

2022-04-12 Thread Jim Posen
Another related issue that I was confused by is that I expected the FDT address
to be in the variable fdt_addr_r but it is in fdt_addr. In the U-Boot
documentation here
https://u-boot.readthedocs.io/en/latest/usage/environment.html#image-locations,
*_r variables indicate addresses in RAM whereas fdt_addr refers to a flash
location. This may provide a solution to the backwards compatibility problem
with this patch. I propose setting both fdt_addr and fdt_addr_r to the
firmware-provided FDT in fw_dtb_pointer, and you can make it so that fdt_addr_r
will be overwritten even if there is a pre-existing value for it in the
environment. Thoughts?


On Mon, Feb 14, 2022 at 6:25 AM Marek Szyprowski
 wrote:
>
> The fdt_addr env have meaning only for the current runtime and it depends
> on the dtb size or firmware version. If one save the environment to disk
> and the loads it on the latter boot, the fdt_addr might change, what
> result in passing incorrect dtb address to the kernel. Fix this by always
> setting the fdt_addr env. This fixes system operation after saving the
> env to disk and updating i.e. dtb files or firmware.
>
> Signed-off-by: Marek Szyprowski 
> Reviewed-by: Jaehoon Chung 
> ---
>  board/raspberrypi/rpi/rpi.c | 3 ---
>  1 file changed, 3 deletions(-)
>
> diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
> index bc3cc597adb..6d6d2e69234 100644
> --- a/board/raspberrypi/rpi/rpi.c
> +++ b/board/raspberrypi/rpi/rpi.c
> @@ -347,9 +347,6 @@ static void set_fdtfile(void)
>   */
>  static void set_fdt_addr(void)
>  {
> -   if (env_get("fdt_addr"))
> -   return;
> -
> if (fdt_magic(fw_dtb_pointer) != FDT_MAGIC)
> return;
>


[PATCH] net: marvell: mvgbe: Set PHY page 0 before phy_connect

2022-04-12 Thread Tony Dinh
For most Kirkwood boards, the PHY page is already set to page 0
(in register 22) before phy_connect is invoked. But some board like
the Zyxel NSA310S (which uses the network chip MV88E1318S), the PHY page
is not set to page 0. There seems to be some bad data remained in
register 22 when the uclass MVGBE about to invoke phy_connect().

This patch enables the uclass MVGBE to always set the PHY page to 0
before phy_connect.

For reference, please see this discussion:
[RFC PATCH v2] arm: kirkwood: nsa310s: Use Marvell uclass mvgbe
and PHY driver for DM Ethernet.
https://lists.denx.de/pipermail/u-boot/2022-April/480946.html

This patch has been tested with the following Kirkwood boards:

NSA310S (88F6702, network chip MV88E1318S)
Sheevaplug (88F6281, network chip MV88E1318)
Pogo V4 (88F6192, network chip 88E1116R)
GF Home(88F6281, network chip 88E1116R)
Dreamplug (88F6281, network chip MV88E1318)
Dell Kace M300 (88F6282, network chip MV88E1318) - out of tree u-boot

Signed-off-by: Tony Dinh 
---

 drivers/net/mvgbe.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/mvgbe.c b/drivers/net/mvgbe.c
index 954bf86121..d2db1e584a 100644
--- a/drivers/net/mvgbe.c
+++ b/drivers/net/mvgbe.c
@@ -43,6 +43,7 @@ DECLARE_GLOBAL_DATA_PTR;
 
 #define MV_PHY_ADR_REQUEST 0xee
 #define MVGBE_SMI_REG (((struct mvgbe_registers *)MVGBE0_BASE)->smi)
+#define MVGBE_PGADR_REG22
 
 #if defined(CONFIG_PHYLIB) || defined(CONFIG_MII) || defined(CONFIG_CMD_MII)
 static int smi_wait_ready(struct mvgbe_device *dmvgbe)
@@ -745,6 +746,9 @@ static struct phy_device *__mvgbe_phy_init(struct 
eth_device *dev,
miiphy_write(dev->name, MV_PHY_ADR_REQUEST, MV_PHY_ADR_REQUEST,
 phyid);
 
+   /* Make sure the selected PHY page is 0 before connecting */
+   miiphy_write(dev->name, phyid, MVGBE_PGADR_REG, 0);
+
phydev = phy_connect(bus, phyid, dev, phy_interface);
if (!phydev) {
printf("phy_connect failed\n");
-- 
2.30.2



Re: [PATCH v2] image-fdt: save name of FIT configuration in '/chosen' node

2022-04-12 Thread Tom Rini
On Tue, Apr 12, 2022 at 09:00:43PM +0100, Daniel Golle wrote:

> It can be useful for the OS (Linux) to know which configuration has
> been chosen by U-Boot when launching a FIT image.
> Store the name of the FIT configuration node used in a new string
> property called 'u-boot,bootconf' in the '/chosen' node in device tree.
> 
> Signed-off-by: Daniel Golle 

Reviewed-by: Tom Rini 

-- 
Tom


signature.asc
Description: PGP signature


Re: [PATCH] ram: k3-ddrss: Allow use of dt provided initial frequency

2022-04-12 Thread Tom Rini
On Tue, Apr 12, 2022 at 02:32:16PM -0500, Dave Gerlach wrote:
> Hi,
> 
> On 4/11/22 07:32, Tom Rini wrote:
> > On Fri, Apr 08, 2022 at 04:46:50PM -0500, Dave Gerlach wrote:
> > 
> >> Allow device tree to provide ti,ddr-freq0 to be used as the initial DDR
> >> frequency that is set for lpddr4 before initialization of the
> >> controller. Make this optional and continue to use PLL bypass frequency
> >> as is done currently if ti,ddr-freq0 is not provided.
> >>
> >> Signed-off-by: Dave Gerlach 
> >> ---
> >>  .../memory-controller/k3-j721e-ddrss.txt  |  2 ++
> >>  drivers/ram/k3-ddrss/k3-ddrss.c   | 15 ++-
> >>  2 files changed, 12 insertions(+), 5 deletions(-)
> > 
> > What's the status of getting this binding upstreamed?  I forget if this
> > is one I've asked about before or not.  Thanks.
> 
> I am pretty sure nobody is looking at this one, but I'd be happy to take
> it up.

Great, thanks!

-- 
Tom


signature.asc
Description: PGP signature


[PATCH v2] image-fdt: save name of FIT configuration in '/chosen' node

2022-04-12 Thread Daniel Golle
It can be useful for the OS (Linux) to know which configuration has
been chosen by U-Boot when launching a FIT image.
Store the name of the FIT configuration node used in a new string
property called 'u-boot,bootconf' in the '/chosen' node in device tree.

Signed-off-by: Daniel Golle 
---
v2: change node name to 'u-boot,bootconf' instead of just 'bootconf'

Sibling PR to dt-schema: https://github.com/devicetree-org/dt-schema/pull/71

 boot/image-fdt.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/boot/image-fdt.c b/boot/image-fdt.c
index 692a9ad3e4..fdb69926a2 100644
--- a/boot/image-fdt.c
+++ b/boot/image-fdt.c
@@ -601,6 +601,12 @@ int image_setup_libfdt(bootm_headers_t *images, void *blob,
goto err;
}
 
+   /* Store name of configuration node as u-boot,bootconf in /chosen node 
*/
+   if (images->fit_uname_cfg)
+   fdt_find_and_setprop(blob, "/chosen", "u-boot,bootconf",
+   images->fit_uname_cfg,
+   strlen(images->fit_uname_cfg) + 1, 1);
+
/* Update ethernet nodes */
fdt_fixup_ethernet(blob);
 #if CONFIG_IS_ENABLED(CMD_PSTORE)
-- 
2.35.1



Re: [PATCH u-boot-net 0/3] A tiny batch of keystone_net changes

2022-04-12 Thread Ramon Fried
On Mon, Apr 11, 2022 at 10:21 PM Marek Behún  wrote:
>
> From: Marek Behún 
>
> Hello Ramon,
>
> here comes a tiny batch of changes for keystone_net.
> Applicable on top of net/next.
>
> Marek
>
> Marek Behún (3):
>   driver: net: ti: keystone_net: Deduplicate code
>   driver: net: ti: keystone_net: Convert to ofnode functions
>   driver: net: ti: keystone_net: Change priv member type
>
>  drivers/net/ti/keystone_net.c | 172 +++---
>  1 file changed, 74 insertions(+), 98 deletions(-)
>
> --
> 2.35.1
>
Applied to u-boot-net/next,
Thanks,
Ramon


Re: [PATCH u-boot-net 3/3] driver: net: ti: keystone_net: Change priv member type

2022-04-12 Thread Ramon Fried
On Mon, Apr 11, 2022 at 10:21 PM Marek Behún  wrote:
>
> From: Marek Behún 
>
> Change type of private struct member mdio_base from void * to
> phys_addr_t. This allows us to drop 2 casts.
>
> Signed-off-by: Marek Behún 
> ---
>  drivers/net/ti/keystone_net.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/ti/keystone_net.c b/drivers/net/ti/keystone_net.c
> index 3c1f616086..fbec69f571 100644
> --- a/drivers/net/ti/keystone_net.c
> +++ b/drivers/net/ti/keystone_net.c
> @@ -92,7 +92,7 @@ struct ks2_eth_priv {
> phy_interface_t phy_if;
> ofnode  phy_ofnode;
> int sgmii_link_type;
> -   void *  mdio_base;
> +   phys_addr_t mdio_base;
> struct rx_buff_desc net_rx_buffs;
> struct pktdma_cfg   *netcp_pktdma;
> void*hd;
> @@ -569,7 +569,7 @@ static int ks2_eth_probe(struct udevice *dev)
>  * to re-use the same
>  */
> mdio_bus = cpsw_mdio_init("ethernet-mdio",
> - (u32)priv->mdio_base,
> + priv->mdio_base,
>   EMAC_MDIO_CLOCK_FREQ,
>   EMAC_MDIO_BUS_FREQ);
> if (!mdio_bus) {
> @@ -701,7 +701,7 @@ static int ks2_eth_parse_slave_interface(ofnode netcp, 
> ofnode slave,
> pr_err("mdio dt not found\n");
> return -ENODEV;
> }
> -   priv->mdio_base = (void *)ofnode_get_addr(mdio);
> +   priv->mdio_base = ofnode_get_addr(mdio);
> }
>
> if (priv->link_type == LINK_TYPE_SGMII_MAC_TO_PHY_MODE) {
> --
> 2.35.1
>
Reviewed-by: Ramon Fried 


Re: [PATCH u-boot-net 2/3] driver: net: ti: keystone_net: Convert to ofnode functions

2022-04-12 Thread Ramon Fried
On Mon, Apr 11, 2022 at 10:21 PM Marek Behún  wrote:
>
> From: Marek Behún 
>
> Convert fdt parsing functions to ofnode parsing functions.
>
> Signed-off-by: Marek Behún 
> ---
>  drivers/net/ti/keystone_net.c | 113 +++---
>  1 file changed, 48 insertions(+), 65 deletions(-)
>
> diff --git a/drivers/net/ti/keystone_net.c b/drivers/net/ti/keystone_net.c
> index 3ee4740ec5..3c1f616086 100644
> --- a/drivers/net/ti/keystone_net.c
> +++ b/drivers/net/ti/keystone_net.c
> @@ -23,7 +23,6 @@
>  #include 
>  #include 
>  #include 
> -#include 
>
>  #include "cpsw_mdio.h"
>
> @@ -91,9 +90,9 @@ struct ks2_eth_priv {
> struct mii_dev  *mdio_bus;
> int phy_addr;
> phy_interface_t phy_if;
> -   int phy_of_handle;
> +   ofnode  phy_ofnode;
> int sgmii_link_type;
> -   void*mdio_base;
> +   void *  mdio_base;
> struct rx_buff_desc net_rx_buffs;
> struct pktdma_cfg   *netcp_pktdma;
> void*hd;
> @@ -593,8 +592,8 @@ static int ks2_eth_probe(struct udevice *dev)
> priv->phydev = phy_connect(priv->mdio_bus, priv->phy_addr,
>dev, priv->phy_if);
>  #ifdef CONFIG_DM_ETH
> -   if (priv->phy_of_handle)
> -   priv->phydev->node = offset_to_ofnode(priv->phy_of_handle);
> +   if (ofnode_valid(priv->phy_ofnode))
> +   priv->phydev->node = priv->phy_ofnode;
>  #endif
> phy_config(priv->phydev);
> }
> @@ -621,15 +620,13 @@ static const struct eth_ops ks2_eth_ops = {
> .write_hwaddr   = ks2_eth_write_hwaddr,
>  };
>
> -static int ks2_bind_one_slave(struct udevice *dev, int slave, int *gbe_0)
> +static int ks2_bind_one_slave(struct udevice *dev, ofnode slave, ofnode 
> *gbe_0)
>  {
> -   const void *fdt = gd->fdt_blob;
> char *slave_name;
> -   int slave_no;
> +   u32 slave_no;
> int ret;
>
> -   slave_no = fdtdec_get_int(fdt, slave, "slave-port", -ENOENT);
> -   if (slave_no == -ENOENT)
> +   if (ofnode_read_u32(slave, "slave-port", _no))
> return 0;
>
> if (gbe_0 && slave_no == 0) {
> @@ -641,28 +638,28 @@ static int ks2_bind_one_slave(struct udevice *dev, int 
> slave, int *gbe_0)
> /* Slave devices to be registered */
> slave_name = malloc(20);
> snprintf(slave_name, 20, "netcp@slave-%d", slave_no);
> -   ret = device_bind_driver_to_node(dev, "eth_ks2_sl", slave_name,
> -offset_to_ofnode(slave), NULL);
> +   ret = device_bind_driver_to_node(dev, "eth_ks2_sl", slave_name, slave,
> +NULL);
> if (ret)
> pr_err("ks2_net - not able to bind slave interfaces\n");
>
> return ret;
>  }
>
> -static int ks2_eth_bind_slaves(struct udevice *dev, int gbe, int *gbe_0)
> +static int ks2_eth_bind_slaves(struct udevice *dev, ofnode gbe, ofnode 
> *gbe_0)
>  {
> -   int interfaces, sec_slave, slave, ret;
> -   const void *fdt = gd->fdt_blob;
> +   ofnode interfaces, sec_slave, slave;
> +   int ret;
>
> -   interfaces = fdt_subnode_offset(fdt, gbe, "interfaces");
> -   fdt_for_each_subnode(slave, fdt, interfaces) {
> +   interfaces = ofnode_find_subnode(gbe, "interfaces");
> +   ofnode_for_each_subnode(slave, interfaces) {
> ret = ks2_bind_one_slave(dev, slave, gbe_0);
> if (ret)
> return ret;
> }
>
> -   sec_slave = fdt_subnode_offset(fdt, gbe, "secondary-slave-ports");
> -   fdt_for_each_subnode(slave, fdt, sec_slave) {
> +   sec_slave = ofnode_find_subnode(gbe, "secondary-slave-ports");
> +   ofnode_for_each_subnode(slave, sec_slave) {
> ret = ks2_bind_one_slave(dev, slave, NULL);
> if (ret)
> return ret;
> @@ -671,47 +668,40 @@ static int ks2_eth_bind_slaves(struct udevice *dev, int 
> gbe, int *gbe_0)
> return 0;
>  }
>
> -static int ks2_eth_parse_slave_interface(int netcp, int slave,
> +static int ks2_eth_parse_slave_interface(ofnode netcp, ofnode slave,
>  struct ks2_eth_priv *priv,
>  struct eth_pdata *pdata)
>  {
> -   const void *fdt = gd->fdt_blob;
> -   int mdio;
> -   int phy;
> +   struct ofnode_phandle_args dma_args;
> +   ofnode phy, mdio;
> int dma_count;
> -   u32 dma_channel[8];
>
> -   priv->slave_port = fdtdec_get_int(fdt, slave, "slave-port", -1);
> +   priv->slave_port = ofnode_read_s32_default(slave, "slave-port", -1);
> priv->net_rx_buffs.rx_flow = 

Re: [PATCH u-boot-net 1/3] driver: net: ti: keystone_net: Deduplicate code

2022-04-12 Thread Ramon Fried
On Mon, Apr 11, 2022 at 10:21 PM Marek Behún  wrote:
>
> From: Marek Behún 
>
> Deduplicate common code in ks2_eth_bind_slaves().
>
> Signed-off-by: Marek Behún 
> ---
>  drivers/net/ti/keystone_net.c | 75 ---
>  1 file changed, 34 insertions(+), 41 deletions(-)
>
> diff --git a/drivers/net/ti/keystone_net.c b/drivers/net/ti/keystone_net.c
> index 16e3f32bb0..3ee4740ec5 100644
> --- a/drivers/net/ti/keystone_net.c
> +++ b/drivers/net/ti/keystone_net.c
> @@ -621,58 +621,51 @@ static const struct eth_ops ks2_eth_ops = {
> .write_hwaddr   = ks2_eth_write_hwaddr,
>  };
>
> -static int ks2_eth_bind_slaves(struct udevice *dev, int gbe, int *gbe_0)
> +static int ks2_bind_one_slave(struct udevice *dev, int slave, int *gbe_0)
>  {
> const void *fdt = gd->fdt_blob;
> -   struct udevice *sl_dev;
> -   int interfaces;
> -   int sec_slave;
> -   int slave;
> -   int ret;
> char *slave_name;
> +   int slave_no;
> +   int ret;
> +
> +   slave_no = fdtdec_get_int(fdt, slave, "slave-port", -ENOENT);
> +   if (slave_no == -ENOENT)
> +   return 0;
> +
> +   if (gbe_0 && slave_no == 0) {
> +   /* This is the current eth device */
> +   *gbe_0 = slave;
> +   return 0;
> +   }
> +
> +   /* Slave devices to be registered */
> +   slave_name = malloc(20);
> +   snprintf(slave_name, 20, "netcp@slave-%d", slave_no);
> +   ret = device_bind_driver_to_node(dev, "eth_ks2_sl", slave_name,
> +offset_to_ofnode(slave), NULL);
> +   if (ret)
> +   pr_err("ks2_net - not able to bind slave interfaces\n");
> +
> +   return ret;
> +}
> +
> +static int ks2_eth_bind_slaves(struct udevice *dev, int gbe, int *gbe_0)
> +{
> +   int interfaces, sec_slave, slave, ret;
> +   const void *fdt = gd->fdt_blob;
>
> interfaces = fdt_subnode_offset(fdt, gbe, "interfaces");
> fdt_for_each_subnode(slave, fdt, interfaces) {
> -   int slave_no;
> -
> -   slave_no = fdtdec_get_int(fdt, slave, "slave-port", -ENOENT);
> -   if (slave_no == -ENOENT)
> -   continue;
> -
> -   if (slave_no == 0) {
> -   /* This is the current eth device */
> -   *gbe_0 = slave;
> -   } else {
> -   /* Slave devices to be registered */
> -   slave_name = malloc(20);
> -   snprintf(slave_name, 20, "netcp@slave-%d", slave_no);
> -   ret = device_bind_driver_to_node(dev, "eth_ks2_sl",
> -   slave_name, offset_to_ofnode(slave),
> -   _dev);
> -   if (ret) {
> -   pr_err("ks2_net - not able to bind slave 
> interfaces\n");
> -   return ret;
> -   }
> -   }
> +   ret = ks2_bind_one_slave(dev, slave, gbe_0);
> +   if (ret)
> +   return ret;
> }
>
> sec_slave = fdt_subnode_offset(fdt, gbe, "secondary-slave-ports");
> fdt_for_each_subnode(slave, fdt, sec_slave) {
> -   int slave_no;
> -
> -   slave_no = fdtdec_get_int(fdt, slave, "slave-port", -ENOENT);
> -   if (slave_no == -ENOENT)
> -   continue;
> -
> -   /* Slave devices to be registered */
> -   slave_name = malloc(20);
> -   snprintf(slave_name, 20, "netcp@slave-%d", slave_no);
> -   ret = device_bind_driver_to_node(dev, "eth_ks2_sl", 
> slave_name,
> -   offset_to_ofnode(slave), _dev);
> -   if (ret) {
> -   pr_err("ks2_net - not able to bind slave 
> interfaces\n");
> +   ret = ks2_bind_one_slave(dev, slave, NULL);
> +   if (ret)
> return ret;
> -   }
> }
>
> return 0;
> --
> 2.35.1
>
Reviewed-by: Ramon Fried 


Re: [PATCH 16/16] net: dm9000: Add Kconfig entry

2022-04-12 Thread Ramon Fried
On Mon, Apr 11, 2022 at 8:56 PM Marek Vasut  wrote:
>
> Add Kconfig entry for the DM9000 MAC.
>
> Signed-off-by: Marek Vasut 
> Cc: Joe Hershberger 
> Cc: Ramon Fried 
> ---
>  drivers/net/Kconfig | 5 +
>  1 file changed, 5 insertions(+)
>
> diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
> index a6171a7c7ff..347fe8aa425 100644
> --- a/drivers/net/Kconfig
> +++ b/drivers/net/Kconfig
> @@ -191,6 +191,11 @@ config CALXEDA_XGMAC
>   This driver supports the XGMAC in Calxeda Highbank and Midway
>   machines.
>
> +config DRIVER_DM9000
> +   bool "Davicom DM9000 controller driver"
> +   help
> + The Davicom DM9000 parallel bus external ethernet interface chip.
> +
>  config DWC_ETH_QOS
> bool "Synopsys DWC Ethernet QOS device support"
> depends on DM_ETH
> --
> 2.35.1
>
Reviewed-by: Ramon Fried 


Re: [PATCH 15/16] net: dm9000: Add DM support

2022-04-12 Thread Ramon Fried
On Mon, Apr 11, 2022 at 8:56 PM Marek Vasut  wrote:
>
> Add support for U-Boot DM and DT probing.
>
> Signed-off-by: Marek Vasut 
> Cc: Joe Hershberger 
> Cc: Ramon Fried 
> ---
>  drivers/net/dm9000x.c | 118 ++
>  1 file changed, 118 insertions(+)
>
> diff --git a/drivers/net/dm9000x.c b/drivers/net/dm9000x.c
> index 84b012ec65d..d63a7c442c9 100644
> --- a/drivers/net/dm9000x.c
> +++ b/drivers/net/dm9000x.c
> @@ -51,6 +51,7 @@
>
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -73,7 +74,9 @@ struct dm9000_priv {
> void (*outblk)(struct dm9000_priv *db, void *data_ptr, int count);
> void (*inblk)(struct dm9000_priv *db, void *data_ptr, int count);
> void (*rx_status)(struct dm9000_priv *db, u16 *rxstatus, u16 *rxlen);
> +#ifndef CONFIG_DM_ETH
> struct eth_device netdev;
> +#endif
> phys_addr_t base_io;
> phys_addr_t base_data;
>  };
> @@ -568,6 +571,7 @@ static void dm9000_get_enetaddr(struct dm9000_priv *db, 
> u8 *enetaddr)
>  static void dm9000_get_enetaddr(struct dm9000_priv *db, u8 *enetaddr) {}
>  #endif
>
> +#ifndef CONFIG_DM_ETH
>  static int dm9000_init(struct eth_device *dev, struct bd_info *bd)
>  {
> struct dm9000_priv *db = container_of(dev, struct dm9000_priv, dev);
> @@ -625,3 +629,117 @@ int dm9000_initialize(struct bd_info *bis)
>
> return 0;
>  }
> +#else  /* ifdef CONFIG_DM_ETH */
> +static int dm9000_start(struct udevice *dev)
> +{
> +   struct dm9000_priv *db = dev_get_priv(dev);
> +   struct eth_pdata *pdata = dev_get_plat(dev);
> +
> +   return dm9000_init_common(db, pdata->enetaddr);
> +}
> +
> +static void dm9000_stop(struct udevice *dev)
> +{
> +   struct dm9000_priv *db = dev_get_priv(dev);
> +
> +   dm9000_halt_common(db);
> +}
> +
> +static int dm9000_send(struct udevice *dev, void *packet, int length)
> +{
> +   struct dm9000_priv *db = dev_get_priv(dev);
> +   int ret;
> +
> +   ret = dm9000_send_common(db, packet, length);
> +
> +   return ret ? 0 : -ETIMEDOUT;
> +}
> +
> +static int dm9000_recv(struct udevice *dev, int flags, uchar **packetp)
> +{
> +   struct dm9000_priv *db = dev_get_priv(dev);
> +   uchar *data = net_rx_packets[0];
> +   int ret;
> +
> +   ret = dm9000_recv_common(db, data);
> +   if (ret)
> +   *packetp = (void *)data;
> +
> +   return ret ? ret : -EAGAIN;
> +}
> +
> +static int dm9000_write_hwaddr(struct udevice *dev)
> +{
> +   struct dm9000_priv *db = dev_get_priv(dev);
> +   struct eth_pdata *pdata = dev_get_plat(dev);
> +   int i, oft;
> +
> +   /* fill device MAC address registers */
> +   for (i = 0, oft = DM9000_PAR; i < 6; i++, oft++)
> +   dm9000_iow(db, oft, pdata->enetaddr[i]);
> +
> +   for (i = 0, oft = 0x16; i < 8; i++, oft++)
> +   dm9000_iow(db, oft, 0xff);
> +
> +   /* read back mac, just to be sure */
> +   for (i = 0, oft = 0x10; i < 6; i++, oft++)
> +   debug("%02x:", dm9000_ior(db, oft));
> +
> +   debug("\n");
> +
> +   return 0;
> +}
> +
> +static int dm9000_read_rom_hwaddr(struct udevice *dev)
> +{
> +   struct dm9000_priv *db = dev_get_priv(dev);
> +   struct eth_pdata *pdata = dev_get_plat(dev);
> +
> +   dm9000_get_enetaddr(db, pdata->enetaddr);
> +
> +   return !is_valid_ethaddr(pdata->enetaddr);
> +}
> +
> +static int dm9000_bind(struct udevice *dev)
> +{
> +   return device_set_name(dev, dev->name);
> +}
> +
> +static int dm9000_of_to_plat(struct udevice *dev)
> +{
> +   struct dm9000_priv *db = dev_get_priv(dev);
> +   struct eth_pdata *pdata = dev_get_plat(dev);
> +
> +   pdata->iobase = dev_read_addr_index(dev, 0);
> +   db->base_io = pdata->iobase;
> +   db->base_data = dev_read_addr_index(dev, 1);
> +
> +   return 0;
> +}
> +
> +static const struct eth_ops dm9000_ops = {
> +   .start  = dm9000_start,
> +   .stop   = dm9000_stop,
> +   .send   = dm9000_send,
> +   .recv   = dm9000_recv,
> +   .write_hwaddr   = dm9000_write_hwaddr,
> +   .read_rom_hwaddr = dm9000_read_rom_hwaddr,
> +};
> +
> +static const struct udevice_id dm9000_ids[] = {
> +   { .compatible = "davicom,dm9000" },
> +   { }
> +};
> +
> +U_BOOT_DRIVER(dm9000) = {
> +   .name   = "eth_dm9000",
> +   .id = UCLASS_ETH,
> +   .of_match   = dm9000_ids,
> +   .bind   = dm9000_bind,
> +   .of_to_plat = dm9000_of_to_plat,
> +   .ops= _ops,
> +   .priv_auto  = sizeof(struct dm9000_priv),
> +   .plat_auto  = sizeof(struct eth_pdata),
> +   .flags  = DM_FLAG_ALLOC_PRIV_DMA,
> +};
> +#endif
> --
> 2.35.1
>
Reviewed-by: Ramon Fried 


Re: [PATCH 14/16] net: dm9000: Receive one packet per recv call

2022-04-12 Thread Ramon Fried
On Mon, Apr 11, 2022 at 8:56 PM Marek Vasut  wrote:
>
> Instead of reading out the entire FIFO and possibly overwriting U-Boot
> memory, read out one packet per recv call, pass it to U-Boot network
> stack, and repeat.
>
> Signed-off-by: Marek Vasut 
> Cc: Joe Hershberger 
> Cc: Ramon Fried 
> ---
>  drivers/net/dm9000x.c | 102 +-
>  1 file changed, 50 insertions(+), 52 deletions(-)
>
> diff --git a/drivers/net/dm9000x.c b/drivers/net/dm9000x.c
> index 97084d16ffa..84b012ec65d 100644
> --- a/drivers/net/dm9000x.c
> +++ b/drivers/net/dm9000x.c
> @@ -480,10 +480,9 @@ static void dm9000_halt_common(struct dm9000_priv *db)
>  /*
>   * Received a packet and pass to upper layer
>   */
> -static int dm9000_recv_common(struct dm9000_priv *db)
> +static int dm9000_recv_common(struct dm9000_priv *db, uchar *rdptr)
>  {
> u8 rxbyte;
> -   u8 *rdptr = (u8 *)net_rx_packets[0];
> u16 rxstatus, rxlen = 0;
>
> /*
> @@ -496,58 +495,52 @@ static int dm9000_recv_common(struct dm9000_priv *db)
> dm9000_iow(db, DM9000_ISR, 0x01); /* clear PR status latched in bit 0 
> */
>
> /* There is _at least_ 1 package in the fifo, read them all */
> -   for (;;) {
> -   dm9000_ior(db, DM9000_MRCMDX);  /* Dummy read */
> -
> -   /*
> -* Get most updated data,
> -* only look at bits 0:1, See application notes DM9000
> -*/
> -   rxbyte = dm9000_inb(db->base_data) & 0x03;
> -
> -   /* Status check: this byte must be 0 or 1 */
> -   if (rxbyte > DM9000_PKT_RDY) {
> -   dm9000_iow(db, DM9000_RCR, 0x00);   /* Stop 
> Device */
> -   dm9000_iow(db, DM9000_ISR, 0x80);   /* Stop INT 
> request */
> -   printf("DM9000 error: status check fail: 0x%x\n",
> -  rxbyte);
> -   return 0;
> -   }
> +   dm9000_ior(db, DM9000_MRCMDX);  /* Dummy read */
> +
> +   /*
> +* Get most updated data,
> +* only look at bits 0:1, See application notes DM9000
> +*/
> +   rxbyte = dm9000_inb(db->base_data) & 0x03;
> +
> +   /* Status check: this byte must be 0 or 1 */
> +   if (rxbyte > DM9000_PKT_RDY) {
> +   dm9000_iow(db, DM9000_RCR, 0x00);   /* Stop Device */
> +   dm9000_iow(db, DM9000_ISR, 0x80);   /* Stop INT request */
> +   printf("DM9000 error: status check fail: 0x%x\n",
> +  rxbyte);
> +   return -EINVAL;
> +   }
> +
> +   if (rxbyte != DM9000_PKT_RDY)
> +   return 0; /* No packet received, ignore */
>
> -   if (rxbyte != DM9000_PKT_RDY)
> -   return 0; /* No packet received, ignore */
> -
> -   debug("receiving packet\n");
> -
> -   /* A packet ready now  & Get status/length */
> -   db->rx_status(db, , );
> -
> -   debug("rx status: 0x%04x rx len: %d\n", rxstatus, rxlen);
> -
> -   /* Move data from DM9000 */
> -   /* Read received packet from RX SRAM */
> -   db->inblk(db, rdptr, rxlen);
> -
> -   if (rxstatus & 0xbf00 || rxlen < 0x40 ||
> -   rxlen > DM9000_PKT_MAX) {
> -   if (rxstatus & 0x100)
> -   printf("rx fifo error\n");
> -   if (rxstatus & 0x200)
> -   printf("rx crc error\n");
> -   if (rxstatus & 0x8000)
> -   printf("rx length error\n");
> -   if (rxlen > DM9000_PKT_MAX) {
> -   printf("rx length too big\n");
> -   dm9000_reset(db);
> -   }
> -   } else {
> -   dm9000_dump_packet(__func__, rdptr, rxlen);
> -
> -   debug("passing packet to upper layer\n");
> -   net_process_received_packet(net_rx_packets[0], rxlen);
> +   debug("receiving packet\n");
> +
> +   /* A packet ready now  & Get status/length */
> +   db->rx_status(db, , );
> +
> +   debug("rx status: 0x%04x rx len: %d\n", rxstatus, rxlen);
> +
> +   /* Move data from DM9000 */
> +   /* Read received packet from RX SRAM */
> +   db->inblk(db, rdptr, rxlen);
> +
> +   if (rxstatus & 0xbf00 || rxlen < 0x40 || rxlen > DM9000_PKT_MAX) {
> +   if (rxstatus & 0x100)
> +   printf("rx fifo error\n");
> +   if (rxstatus & 0x200)
> +   printf("rx crc error\n");
> +   if (rxstatus & 0x8000)
> +   printf("rx length error\n");
> +   if (rxlen > DM9000_PKT_MAX) {
> +   printf("rx length too big\n");
> +   

Re: [PATCH 13/16] net: dm9000: Split non-DM specific bits from common code

2022-04-12 Thread Ramon Fried
On Mon, Apr 11, 2022 at 8:56 PM Marek Vasut  wrote:
>
> Split network handling functions into non-DM specific parts and
> common code in preparation for conversion to DM.
>
> Signed-off-by: Marek Vasut 
> Cc: Joe Hershberger 
> Cc: Ramon Fried 
> ---
>  drivers/net/dm9000x.c | 58 +--
>  1 file changed, 40 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/net/dm9000x.c b/drivers/net/dm9000x.c
> index 54b8f848397..97084d16ffa 100644
> --- a/drivers/net/dm9000x.c
> +++ b/drivers/net/dm9000x.c
> @@ -310,9 +310,8 @@ static void dm9000_reset(struct dm9000_priv *db)
>  }
>
>  /* Initialize dm9000 board */
> -static int dm9000_init(struct eth_device *dev, struct bd_info *bd)
> +static int dm9000_init_common(struct dm9000_priv *db, u8 enetaddr[6])
>  {
> -   struct dm9000_priv *db = container_of(dev, struct dm9000_priv, dev);
> int i, oft, lnk;
> u8 io_mode;
>
> @@ -370,13 +369,13 @@ static int dm9000_init(struct eth_device *dev, struct 
> bd_info *bd)
> /* Clear interrupt status */
> dm9000_iow(db, DM9000_ISR, ISR_ROOS | ISR_ROS | ISR_PTS | ISR_PRS);
>
> -   printf("MAC: %pM\n", dev->enetaddr);
> -   if (!is_valid_ethaddr(dev->enetaddr))
> +   printf("MAC: %pM\n", enetaddr);
> +   if (!is_valid_ethaddr(enetaddr))
> printf("WARNING: Bad MAC address (uninitialized EEPROM?)\n");
>
> /* fill device MAC address registers */
> for (i = 0, oft = DM9000_PAR; i < 6; i++, oft++)
> -   dm9000_iow(db, oft, dev->enetaddr[i]);
> +   dm9000_iow(db, oft, enetaddr[i]);
> for (i = 0, oft = 0x16; i < 8; i++, oft++)
> dm9000_iow(db, oft, 0xff);
>
> @@ -429,9 +428,8 @@ static int dm9000_init(struct eth_device *dev, struct 
> bd_info *bd)
>   * Hardware start transmission.
>   * Send a packet to media from the upper layer.
>   */
> -static int dm9000_send(struct eth_device *dev, void *packet, int length)
> +static int dm9000_send_common(struct dm9000_priv *db, void *packet, int 
> length)
>  {
> -   struct dm9000_priv *db = container_of(dev, struct dm9000_priv, dev);
> int tmo;
>
> dm9000_dump_packet(__func__, packet, length);
> @@ -470,10 +468,8 @@ static int dm9000_send(struct eth_device *dev, void 
> *packet, int length)
>   * Stop the interface.
>   * The interface is stopped when it is brought.
>   */
> -static void dm9000_halt(struct eth_device *netdev)
> +static void dm9000_halt_common(struct dm9000_priv *db)
>  {
> -   struct dm9000_priv *db = container_of(dev, struct dm9000_priv, dev);
> -
> /* RESET device */
> dm9000_phy_write(db, 0, 0x8000);/* PHY RESET */
> dm9000_iow(db, DM9000_GPR, 0x01);   /* Power-Down PHY */
> @@ -484,9 +480,8 @@ static void dm9000_halt(struct eth_device *netdev)
>  /*
>   * Received a packet and pass to upper layer
>   */
> -static int dm9000_rx(struct eth_device *dev)
> +static int dm9000_recv_common(struct dm9000_priv *db)
>  {
> -   struct dm9000_priv *db = container_of(dev, struct dm9000_priv, dev);
> u8 rxbyte;
> u8 *rdptr = (u8 *)net_rx_packets[0];
> u16 rxstatus, rxlen = 0;
> @@ -569,18 +564,45 @@ static void dm9000_read_srom_word(struct dm9000_priv 
> *db, int offset, u8 *to)
> to[1] = dm9000_ior(db, DM9000_EPDRH);
>  }
>
> -static void dm9000_get_enetaddr(struct eth_device *dev)
> +static void dm9000_get_enetaddr(struct dm9000_priv *db, u8 *enetaddr)
>  {
> -   struct dm9000_priv *db = container_of(dev, struct dm9000_priv, dev);
> int i;
>
> for (i = 0; i < 3; i++)
> -   dm9000_read_srom_word(db, i, dev->enetaddr + (2 * i));
> +   dm9000_read_srom_word(db, i, enetaddr + (2 * i));
>  }
>  #else
> -static void dm9000_get_enetaddr(struct eth_device *dev) {}
> +static void dm9000_get_enetaddr(struct dm9000_priv *db, u8 *enetaddr) {}
>  #endif
>
> +static int dm9000_init(struct eth_device *dev, struct bd_info *bd)
> +{
> +   struct dm9000_priv *db = container_of(dev, struct dm9000_priv, dev);
> +
> +   return dm9000_init_common(db, dev->enetaddr);
> +}
> +
> +static int dm9000_halt(struct eth_device *dev, struct bd_info *bd)
> +{
> +   struct dm9000_priv *db = container_of(dev, struct dm9000_priv, dev);
> +
> +   return dm9000_halt_common(db);
> +}
> +
> +static int dm9000_send(struct eth_device *dev, void *packet, int length)
> +{
> +   struct dm9000_priv *db = container_of(dev, struct dm9000_priv, dev);
> +
> +   return dm9000_send_common(db, packet, length);
> +}
> +
> +static int dm9000_recv(struct eth_device *dev)
> +{
> +   struct dm9000_priv *db = container_of(dev, struct dm9000_priv, dev);
> +
> +   return dm9000_recv_common(db);
> +}
> +
>  int dm9000_initialize(struct bd_info *bis)
>  {
> struct dm9000_priv *priv;
> @@ -593,12 +615,12 @@ int dm9000_initialize(struct bd_info *bis)
> priv->base_data = DM9000_DATA;
>
> /* 

Re: [PATCH 12/16] net: dm9000: Pass private data around for IO

2022-04-12 Thread Ramon Fried
On Mon, Apr 11, 2022 at 8:56 PM Marek Vasut  wrote:
>
> Pass private data into IO accessors and use the base addresses of
> IO and DATA window from the private data instead of using the hard
> coded macros DM9000_IO/DM9000_DATA. Currently both the DM9000_IO
> and DM9000_DATA are assigned to the respecive private data fields
> for the non-DM case backward compatibility.
>
> Signed-off-by: Marek Vasut 
> Cc: Joe Hershberger 
> Cc: Ramon Fried 
> ---
>  drivers/net/dm9000x.c | 230 ++
>  1 file changed, 119 insertions(+), 111 deletions(-)
>
> diff --git a/drivers/net/dm9000x.c b/drivers/net/dm9000x.c
> index 3c0d848b10f..54b8f848397 100644
> --- a/drivers/net/dm9000x.c
> +++ b/drivers/net/dm9000x.c
> @@ -70,10 +70,12 @@ struct dm9000_priv {
> u8 phy_addr;
> u8 device_wait_reset;   /* device state */
> unsigned char srom[128];
> -   void (*outblk)(void *data_ptr, int count);
> -   void (*inblk)(void *data_ptr, int count);
> -   void (*rx_status)(u16 *rxstatus, u16 *rxlen);
> +   void (*outblk)(struct dm9000_priv *db, void *data_ptr, int count);
> +   void (*inblk)(struct dm9000_priv *db, void *data_ptr, int count);
> +   void (*rx_status)(struct dm9000_priv *db, u16 *rxstatus, u16 *rxlen);
> struct eth_device netdev;
> +   phys_addr_t base_io;
> +   phys_addr_t base_data;
>  };
>
>  /* DM9000 network board routine  */
> @@ -112,120 +114,121 @@ static void dm9000_dump_packet(const char *func, u8 
> *packet, int length)
>  static void dm9000_dump_packet(const char *func, u8 *packet, int length) {}
>  #endif
>
> -static void dm9000_outblk_8bit(void *data_ptr, int count)
> +static void dm9000_outblk_8bit(struct dm9000_priv *db, void *data_ptr, int 
> count)
>  {
> int i;
>
> for (i = 0; i < count; i++)
> -   dm9000_outbu8 *)data_ptr)[i] & 0xff), DM9000_DATA);
> +   dm9000_outbu8 *)data_ptr)[i] & 0xff), db->base_data);
>  }
>
> -static void dm9000_outblk_16bit(void *data_ptr, int count)
> +static void dm9000_outblk_16bit(struct dm9000_priv *db, void *data_ptr, int 
> count)
>  {
> int i;
> u32 tmplen = (count + 1) / 2;
>
> for (i = 0; i < tmplen; i++)
> -   dm9000_outw(((u16 *)data_ptr)[i], DM9000_DATA);
> +   dm9000_outw(((u16 *)data_ptr)[i], db->base_data);
>  }
>
> -static void dm9000_outblk_32bit(void *data_ptr, int count)
> +static void dm9000_outblk_32bit(struct dm9000_priv *db, void *data_ptr, int 
> count)
>  {
> int i;
> u32 tmplen = (count + 3) / 4;
>
> for (i = 0; i < tmplen; i++)
> -   dm9000_outl(((u32 *)data_ptr)[i], DM9000_DATA);
> +   dm9000_outl(((u32 *)data_ptr)[i], db->base_data);
>  }
>
> -static void dm9000_inblk_8bit(void *data_ptr, int count)
> +static void dm9000_inblk_8bit(struct dm9000_priv *db, void *data_ptr, int 
> count)
>  {
> int i;
>
> for (i = 0; i < count; i++)
> -   ((u8 *)data_ptr)[i] = dm9000_inb(DM9000_DATA);
> +   ((u8 *)data_ptr)[i] = dm9000_inb(db->base_data);
>  }
>
> -static void dm9000_inblk_16bit(void *data_ptr, int count)
> +static void dm9000_inblk_16bit(struct dm9000_priv *db, void *data_ptr, int 
> count)
>  {
> int i;
> u32 tmplen = (count + 1) / 2;
>
> for (i = 0; i < tmplen; i++)
> -   ((u16 *)data_ptr)[i] = dm9000_inw(DM9000_DATA);
> +   ((u16 *)data_ptr)[i] = dm9000_inw(db->base_data);
>  }
>
> -static void dm9000_inblk_32bit(void *data_ptr, int count)
> +static void dm9000_inblk_32bit(struct dm9000_priv *db, void *data_ptr, int 
> count)
>  {
> int i;
> u32 tmplen = (count + 3) / 4;
>
> for (i = 0; i < tmplen; i++)
> -   ((u32 *)data_ptr)[i] = dm9000_inl(DM9000_DATA);
> +   ((u32 *)data_ptr)[i] = dm9000_inl(db->base_data);
>  }
>
> -static void dm9000_rx_status_32bit(u16 *rxstatus, u16 *rxlen)
> +static void dm9000_rx_status_32bit(struct dm9000_priv *db, u16 *rxstatus, 
> u16 *rxlen)
>  {
> u32 tmpdata;
>
> -   dm9000_outb(DM9000_MRCMD, DM9000_IO);
> +   dm9000_outb(DM9000_MRCMD, db->base_io);
>
> -   tmpdata = dm9000_inl(DM9000_DATA);
> +   tmpdata = dm9000_inl(db->base_data);
> *rxstatus = __le16_to_cpu(tmpdata);
> *rxlen = __le16_to_cpu(tmpdata >> 16);
>  }
>
> -static void dm9000_rx_status_16bit(u16 *rxstatus, u16 *rxlen)
> +static void dm9000_rx_status_16bit(struct dm9000_priv *db, u16 *rxstatus, 
> u16 *rxlen)
>  {
> -   dm9000_outb(DM9000_MRCMD, DM9000_IO);
> +   dm9000_outb(DM9000_MRCMD, db->base_io);
>
> -   *rxstatus = __le16_to_cpu(dm9000_inw(DM9000_DATA));
> -   *rxlen = __le16_to_cpu(dm9000_inw(DM9000_DATA));
> +   *rxstatus = __le16_to_cpu(dm9000_inw(db->base_data));
> +   *rxlen = __le16_to_cpu(dm9000_inw(db->base_data));
>  }
>
> -static void dm9000_rx_status_8bit(u16 

Re: [PATCH 11/16] net: dm9000: Drop dm9000.h and staticize SROM access

2022-04-12 Thread Ramon Fried
On Mon, Apr 11, 2022 at 8:56 PM Marek Vasut  wrote:
>
> Dispose of dm9000.h because none of the function prototypes declared in
> it are called anywhere in the codebase. Staticize dm9000_read_srom_word()
> because it is now called only from within the dm9000 driver. Drop
> dm9000_write_srom_word() because it is no longer used.
>
> Signed-off-by: Marek Vasut 
> Cc: Joe Hershberger 
> Cc: Ramon Fried 
> ---
>  drivers/net/dm9000x.c | 13 +
>  include/dm9000.h  | 16 
>  2 files changed, 1 insertion(+), 28 deletions(-)
>  delete mode 100644 include/dm9000.h
>
> diff --git a/drivers/net/dm9000x.c b/drivers/net/dm9000x.c
> index 666883ee19e..3c0d848b10f 100644
> --- a/drivers/net/dm9000x.c
> +++ b/drivers/net/dm9000x.c
> @@ -53,7 +53,6 @@
>  #include 
>  #include 
>  #include 
> -#include 
>  #include 
>
>  #include "dm9000x.h"
> @@ -556,7 +555,7 @@ static int dm9000_rx(struct eth_device *dev)
>   * Read a word data from SROM
>   */
>  #if !defined(CONFIG_DM9000_NO_SROM)
> -void dm9000_read_srom_word(int offset, u8 *to)
> +static void dm9000_read_srom_word(int offset, u8 *to)
>  {
> dm9000_iow(DM9000_EPAR, offset);
> dm9000_iow(DM9000_EPCR, 0x4);
> @@ -566,16 +565,6 @@ void dm9000_read_srom_word(int offset, u8 *to)
> to[1] = dm9000_ior(DM9000_EPDRH);
>  }
>
> -void dm9000_write_srom_word(int offset, u16 val)
> -{
> -   dm9000_iow(DM9000_EPAR, offset);
> -   dm9000_iow(DM9000_EPDRH, ((val >> 8) & 0xff));
> -   dm9000_iow(DM9000_EPDRL, (val & 0xff));
> -   dm9000_iow(DM9000_EPCR, 0x12);
> -   mdelay(8);
> -   dm9000_iow(DM9000_EPCR, 0);
> -}
> -
>  static void dm9000_get_enetaddr(struct eth_device *dev)
>  {
> int i;
> diff --git a/include/dm9000.h b/include/dm9000.h
> deleted file mode 100644
> index f780e513f69..000
> --- a/include/dm9000.h
> +++ /dev/null
> @@ -1,16 +0,0 @@
> -/* SPDX-License-Identifier: GPL-2.0+ */
> -/*
> - * NOTE:DAVICOM DM9000 ethernet driver interface
> - *
> - * Authors: Remy Bohmer 
> - */
> -#ifndef __DM9000_H__
> -#define __DM9000_H__
> -
> -/**  function prototypes **/
> -#if !defined(CONFIG_DM9000_NO_SROM)
> -void dm9000_write_srom_word(int offset, u16 val);
> -void dm9000_read_srom_word(int offset, u8 *to);
> -#endif
> -
> -#endif /* __DM9000_H__ */
> --
> 2.35.1
>
Reviewed-by: Ramon Fried 


Re: [PATCH 10/16] net: dm9000: Drop static device private data

2022-04-12 Thread Ramon Fried
On Mon, Apr 11, 2022 at 8:56 PM Marek Vasut  wrote:
>
> Allocate driver private data dynamically in its init function and drop
> the static driver private data variable. Pass the dynamic private data
> throughout the driver. This is done in preparation for DM conversion.
>
> Signed-off-by: Marek Vasut 
> Cc: Joe Hershberger 
> Cc: Ramon Fried 
> ---
>  drivers/net/dm9000x.c | 24 +---
>  1 file changed, 13 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/net/dm9000x.c b/drivers/net/dm9000x.c
> index 7e1368a1be9..666883ee19e 100644
> --- a/drivers/net/dm9000x.c
> +++ b/drivers/net/dm9000x.c
> @@ -77,8 +77,6 @@ struct dm9000_priv {
> struct eth_device netdev;
>  };
>
> -static struct dm9000_priv dm9000_info;
> -
>  /* DM9000 network board routine  */
>  #ifndef CONFIG_DM9000_BYTE_SWAPPED
>  #define dm9000_outb(d, r) writeb((d), (r))
> @@ -313,9 +311,9 @@ dm9000_reset(void)
>  /* Initialize dm9000 board */
>  static int dm9000_init(struct eth_device *dev, struct bd_info *bd)
>  {
> +   struct dm9000_priv *db = container_of(dev, struct dm9000_priv, dev);
> int i, oft, lnk;
> u8 io_mode;
> -   struct dm9000_priv *db = _info;
>
> /* RESET device */
> dm9000_reset();
> @@ -430,10 +428,10 @@ static int dm9000_init(struct eth_device *dev, struct 
> bd_info *bd)
>   * Hardware start transmission.
>   * Send a packet to media from the upper layer.
>   */
> -static int dm9000_send(struct eth_device *netdev, void *packet, int length)
> +static int dm9000_send(struct eth_device *dev, void *packet, int length)
>  {
> +   struct dm9000_priv *db = container_of(dev, struct dm9000_priv, dev);
> int tmo;
> -   struct dm9000_priv *db = _info;
>
> dm9000_dump_packet(__func__, packet, length);
>
> @@ -483,12 +481,12 @@ static void dm9000_halt(struct eth_device *netdev)
>  /*
>   * Received a packet and pass to upper layer
>   */
> -static int dm9000_rx(struct eth_device *netdev)
> +static int dm9000_rx(struct eth_device *dev)
>  {
> +   struct dm9000_priv *db = container_of(dev, struct dm9000_priv, dev);
> u8 rxbyte;
> u8 *rdptr = (u8 *)net_rx_packets[0];
> u16 rxstatus, rxlen = 0;
> -   struct dm9000_priv *db = _info;
>
> /*
>  * Check packet ready or not, we must check
> @@ -591,18 +589,22 @@ static void dm9000_get_enetaddr(struct eth_device *dev) 
> {}
>
>  int dm9000_initialize(struct bd_info *bis)
>  {
> -   struct eth_device *dev = _info.netdev;
> +   struct dm9000_priv *priv;
> +
> +   priv = kcalloc(1, sizeof(*priv));
> +   if (!priv)
> +   return -ENOMEM;
>
> /* Load MAC address from EEPROM */
> -   dm9000_get_enetaddr(dev);
> +   dm9000_get_enetaddr(>dev);
>
> dev->init = dm9000_init;
> dev->halt = dm9000_halt;
> dev->send = dm9000_send;
> dev->recv = dm9000_rx;
> -   strcpy(dev->name, "dm9000");
> +   strcpy(>dev.name, "dm9000");
>
> -   eth_register(dev);
> +   eth_register(>dev);
>
> return 0;
>  }
> --
> 2.35.1
>
Reviewed-by: Ramon Fried 


Re: [PATCH 09/16] net: dm9000: Rename board_info to dm9000_priv

2022-04-12 Thread Ramon Fried
On Mon, Apr 11, 2022 at 8:56 PM Marek Vasut  wrote:
>
> Rename board_info structure to dm9000_priv to make it clear what this
> structure really contains, the driver private data. No functional change.
>
> Signed-off-by: Marek Vasut 
> Cc: Joe Hershberger 
> Cc: Ramon Fried 
> ---
>  drivers/net/dm9000x.c | 10 +-
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/dm9000x.c b/drivers/net/dm9000x.c
> index 85f3c079ec1..7e1368a1be9 100644
> --- a/drivers/net/dm9000x.c
> +++ b/drivers/net/dm9000x.c
> @@ -59,7 +59,7 @@
>  #include "dm9000x.h"
>
>  /* Structure/enum declaration --- */
> -struct board_info {
> +struct dm9000_priv {
> u32 runt_length_counter;/* counter: RX length < 64byte */
> u32 long_length_counter;/* counter: RX length > 1514byte */
> u32 reset_counter;  /* counter: RESET */
> @@ -77,7 +77,7 @@ struct board_info {
> struct eth_device netdev;
>  };
>
> -static struct board_info dm9000_info;
> +static struct dm9000_priv dm9000_info;
>
>  /* DM9000 network board routine  */
>  #ifndef CONFIG_DM9000_BYTE_SWAPPED
> @@ -315,7 +315,7 @@ static int dm9000_init(struct eth_device *dev, struct 
> bd_info *bd)
>  {
> int i, oft, lnk;
> u8 io_mode;
> -   struct board_info *db = _info;
> +   struct dm9000_priv *db = _info;
>
> /* RESET device */
> dm9000_reset();
> @@ -433,7 +433,7 @@ static int dm9000_init(struct eth_device *dev, struct 
> bd_info *bd)
>  static int dm9000_send(struct eth_device *netdev, void *packet, int length)
>  {
> int tmo;
> -   struct board_info *db = _info;
> +   struct dm9000_priv *db = _info;
>
> dm9000_dump_packet(__func__, packet, length);
>
> @@ -488,7 +488,7 @@ static int dm9000_rx(struct eth_device *netdev)
> u8 rxbyte;
> u8 *rdptr = (u8 *)net_rx_packets[0];
> u16 rxstatus, rxlen = 0;
> -   struct board_info *db = _info;
> +   struct dm9000_priv *db = _info;
>
> /*
>  * Check packet ready or not, we must check
> --
> 2.35.1
>
Reviewed-by: Ramon Fried 


Re: [PATCH 08/16] net: dm9000: Reorder and staticize

2022-04-12 Thread Ramon Fried
On Mon, Apr 11, 2022 at 8:56 PM Marek Vasut  wrote:
>
> Reorder the driver functions to get rid of forward declarations.
> Staticize whatever is possible. No functional change.
>
> Signed-off-by: Marek Vasut 
> Cc: Joe Hershberger 
> Cc: Ramon Fried 
> ---
>  drivers/net/dm9000x.c | 122 +++---
>  1 file changed, 55 insertions(+), 67 deletions(-)
>
> diff --git a/drivers/net/dm9000x.c b/drivers/net/dm9000x.c
> index becf7aec828..85f3c079ec1 100644
> --- a/drivers/net/dm9000x.c
> +++ b/drivers/net/dm9000x.c
> @@ -79,13 +79,6 @@ struct board_info {
>
>  static struct board_info dm9000_info;
>
> -/* function declaration - */
> -static int dm9000_probe(void);
> -static u16 dm9000_phy_read(int);
> -static void dm9000_phy_write(int, u16);
> -static u8 dm9000_ior(int);
> -static void dm9000_iow(int reg, u8 value);
> -
>  /* DM9000 network board routine  */
>  #ifndef CONFIG_DM9000_BYTE_SWAPPED
>  #define dm9000_outb(d, r) writeb((d), (r))
> @@ -205,11 +198,64 @@ static void dm9000_rx_status_8bit(u16 *rxstatus, u16 
> *rxlen)
>   (dm9000_inb(DM9000_DATA) << 8));
>  }
>
> +/*
> + *  Read a byte from I/O port
> + */
> +static u8 dm9000_ior(int reg)
> +{
> +   dm9000_outb(reg, DM9000_IO);
> +   return dm9000_inb(DM9000_DATA);
> +}
> +
> +/*
> + *  Write a byte to I/O port
> + */
> +static void dm9000_iow(int reg, u8 value)
> +{
> +   dm9000_outb(reg, DM9000_IO);
> +   dm9000_outb(value, DM9000_DATA);
> +}
> +
> +/*
> + *  Read a word from phyxcer
> + */
> +static u16 dm9000_phy_read(int reg)
> +{
> +   u16 val;
> +
> +   /* Fill the phyxcer register into REG_0C */
> +   dm9000_iow(DM9000_EPAR, DM9000_PHY | reg);
> +   dm9000_iow(DM9000_EPCR, 0xc);   /* Issue phyxcer read command */
> +   udelay(100);/* Wait read complete */
> +   dm9000_iow(DM9000_EPCR, 0x0);   /* Clear phyxcer read command */
> +   val = (dm9000_ior(DM9000_EPDRH) << 8) | dm9000_ior(DM9000_EPDRL);
> +
> +   /* The read data keeps on REG_0D & REG_0E */
> +   debug("%s(0x%x): 0x%x\n", __func__, reg, val);
> +   return val;
> +}
> +
> +/*
> + *  Write a word to phyxcer
> + */
> +static void dm9000_phy_write(int reg, u16 value)
> +{
> +   /* Fill the phyxcer register into REG_0C */
> +   dm9000_iow(DM9000_EPAR, DM9000_PHY | reg);
> +
> +   /* Fill the written data into REG_0D & REG_0E */
> +   dm9000_iow(DM9000_EPDRL, (value & 0xff));
> +   dm9000_iow(DM9000_EPDRH, ((value >> 8) & 0xff));
> +   dm9000_iow(DM9000_EPCR, 0xa);   /* Issue phyxcer write command */
> +   udelay(500);/* Wait write complete */
> +   dm9000_iow(DM9000_EPCR, 0x0);   /* Clear phyxcer write command */
> +   debug("%s(reg:0x%x, value:0x%x)\n", __func__, reg, value);
> +}
> +
>  /*
>   * Search DM9000 board, allocate space and register it
>   */
> -int
> -dm9000_probe(void)
> +static int dm9000_probe(void)
>  {
> u32 id_val;
>
> @@ -543,64 +589,6 @@ static void dm9000_get_enetaddr(struct eth_device *dev)
>  static void dm9000_get_enetaddr(struct eth_device *dev) {}
>  #endif
>
> -/*
> - *  Read a byte from I/O port
> - */
> -static u8
> -dm9000_ior(int reg)
> -{
> -   dm9000_outb(reg, DM9000_IO);
> -   return dm9000_inb(DM9000_DATA);
> -}
> -
> -/*
> - *  Write a byte to I/O port
> - */
> -static void
> -dm9000_iow(int reg, u8 value)
> -{
> -   dm9000_outb(reg, DM9000_IO);
> -   dm9000_outb(value, DM9000_DATA);
> -}
> -
> -/*
> - *  Read a word from phyxcer
> - */
> -static u16
> -dm9000_phy_read(int reg)
> -{
> -   u16 val;
> -
> -   /* Fill the phyxcer register into REG_0C */
> -   dm9000_iow(DM9000_EPAR, DM9000_PHY | reg);
> -   dm9000_iow(DM9000_EPCR, 0xc);   /* Issue phyxcer read command */
> -   udelay(100);/* Wait read complete */
> -   dm9000_iow(DM9000_EPCR, 0x0);   /* Clear phyxcer read command */
> -   val = (dm9000_ior(DM9000_EPDRH) << 8) | dm9000_ior(DM9000_EPDRL);
> -
> -   /* The read data keeps on REG_0D & REG_0E */
> -   debug("%s(0x%x): 0x%x\n", __func__, reg, val);
> -   return val;
> -}
> -
> -/*
> - *  Write a word to phyxcer
> - */
> -static void
> -dm9000_phy_write(int reg, u16 value)
> -{
> -   /* Fill the phyxcer register into REG_0C */
> -   dm9000_iow(DM9000_EPAR, DM9000_PHY | reg);
> -
> -   /* Fill the written data into REG_0D & REG_0E */
> -   dm9000_iow(DM9000_EPDRL, (value & 0xff));
> -   dm9000_iow(DM9000_EPDRH, ((value >> 8) & 0xff));
> -   dm9000_iow(DM9000_EPCR, 0xa);   /* Issue phyxcer write command */
> -   udelay(500);/* Wait write complete */
> -   dm9000_iow(DM9000_EPCR, 0x0);   /* Clear phyxcer write command */
> -   debug("%s(reg:0x%x, value:0x%x)\n", __func__, reg, value);
> -}
> -
>  int dm9000_initialize(struct bd_info *bis)
>  {
> struct 

Re: [PATCH 07/16] net: dm9000: Checkpatch cleanup

2022-04-12 Thread Ramon Fried
On Mon, Apr 11, 2022 at 8:56 PM Marek Vasut  wrote:
>
> Fix checkpatch errors and warnings. No functional change.
>
> Signed-off-by: Marek Vasut 
> Cc: Joe Hershberger 
> Cc: Ramon Fried 
> ---
>  drivers/net/dm9000x.c | 251 +-
>  1 file changed, 126 insertions(+), 125 deletions(-)
>
> diff --git a/drivers/net/dm9000x.c b/drivers/net/dm9000x.c
> index aacf5f670e9..becf7aec828 100644
> --- a/drivers/net/dm9000x.c
> +++ b/drivers/net/dm9000x.c
> @@ -1,53 +1,53 @@
>  // SPDX-License-Identifier: GPL-2.0+
>  /*
> -  dm9000.c: Version 1.2 12/15/2003
> -
> -   A Davicom DM9000 ISA NIC fast Ethernet driver for Linux.
> -   Copyright (C) 1997  Sten Wang
> -
> -  (C)Copyright 1997-1998 DAVICOM Semiconductor,Inc. All Rights Reserved.
> -
> -V0.11  06/20/2001  REG_0A bit3=1, default enable BP with DA match
> -   06/22/2001  Support DM9801 progrmming
> -   E3: R25 = ((R24 + NF) & 0x00ff) | 0xf000
> -   E4: R25 = ((R24 + NF) & 0x00ff) | 0xc200
> -   R17 = (R17 & 0xfff0) | NF + 3
> -   E5: R25 = ((R24 + NF - 3) & 0x00ff) | 0xc200
> -   R17 = (R17 & 0xfff0) | NF
> -
> -v1.00  modify by simon 2001.9.5
> -   change for kernel 2.4.x
> -
> -v1.1   11/09/2001  fix force mode bug
> -
> -v1.2   03/18/2003   Weilun Huang :
> -   Fixed phy reset.
> -   Added tx/rx 32 bit mode.
> -   Cleaned up for kernel merge.
> -
> ---
> -
> -   12/15/2003   Initial port to u-boot by
> -   Sascha Hauer 
> -
> -   06/03/2008  Remy Bohmer 
> -   - Fixed the driver to work with DM9000A.
> - (check on ISR receive status bit before reading the
> - FIFO as described in DM9000 programming guide and
> - application notes)
> -   - Added autodetect of databus width.
> -   - Made debug code compile again.
> -   - Adapt eth_send such that it matches the DM9000*
> - application notes. Needed to make it work properly
> - for DM9000A.
> -   - Adapted reset procedure to match DM9000 application
> - notes (i.e. double reset)
> -   - some minor code cleanups
> -   These changes are tested with DM9000{A,EP,E} together
> -   with a 200MHz Atmel AT91SAM9261 core
> -
> -TODO: external MII is not functional, only internal at the moment.
> -*/
> + *   dm9000.c: Version 1.2 12/15/2003
> + *
> + * A Davicom DM9000 ISA NIC fast Ethernet driver for Linux.
> + * Copyright (C) 1997  Sten Wang
> + *
> + *   (C)Copyright 1997-1998 DAVICOM Semiconductor,Inc. All Rights Reserved.
> + *
> + * V0.11   06/20/2001  REG_0A bit3=1, default enable BP with DA match
> + * 06/22/2001  Support DM9801 progrmming
> + * E3: R25 = ((R24 + NF) & 0x00ff) | 0xf000
> + * E4: R25 = ((R24 + NF) & 0x00ff) | 0xc200
> + * R17 = (R17 & 0xfff0) | NF + 3
> + * E5: R25 = ((R24 + NF - 3) & 0x00ff) | 0xc200
> + * R17 = (R17 & 0xfff0) | NF
> + *
> + * v1.00   modify by simon 2001.9.5
> + * change for kernel 2.4.x
> + *
> + * v1.1   11/09/2001   fix force mode bug
> + *
> + * v1.2   03/18/2003   Weilun Huang :
> + * Fixed phy reset.
> + * Added tx/rx 32 bit mode.
> + * Cleaned up for kernel merge.
> + *
> + * --
> + *
> + *12/15/2003   Initial port to u-boot by
> + * Sascha Hauer 
> + *
> + *06/03/2008   Remy Bohmer 
> + * - Fixed the driver to work with DM9000A.
> + *   (check on ISR receive status bit before reading the
> + *   FIFO as described in DM9000 programming guide and
> + *   application notes)
> + * - Added autodetect of databus width.
> + * - Made debug code compile again.
> + * - Adapt eth_send such that it matches the DM9000*
> + *   application notes. Needed to make it work properly
> + *   for DM9000A.
> + * - Adapted reset procedure to match DM9000 application
> + *   notes (i.e. double reset)
> + * - some minor code cleanups
> + * These changes are tested with DM9000{A,EP,E} together
> + * with a 200MHz Atmel AT91SAM9261 core
> + *
> + * TODO: external MII is not functional, only internal at the moment.
> + */
>
>  

Re: [PATCH 06/16] net: dm9000: Drop volatiles

2022-04-12 Thread Ramon Fried
On Mon, Apr 11, 2022 at 8:56 PM Marek Vasut  wrote:
>
> Remove volatile keyword usage from arrays, they are not really volatile
> in any way, so this keyword is misused here. No functional change.
>
> Signed-off-by: Marek Vasut 
> Cc: Joe Hershberger 
> Cc: Ramon Fried 
> ---
>  drivers/net/dm9000x.c | 20 ++--
>  1 file changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/net/dm9000x.c b/drivers/net/dm9000x.c
> index da16b64610b..aacf5f670e9 100644
> --- a/drivers/net/dm9000x.c
> +++ b/drivers/net/dm9000x.c
> @@ -71,7 +71,7 @@ typedef struct board_info {
> u8 phy_addr;
> u8 device_wait_reset;   /* device state */
> unsigned char srom[128];
> -   void (*outblk)(volatile void *data_ptr, int count);
> +   void (*outblk)(void *data_ptr, int count);
> void (*inblk)(void *data_ptr, int count);
> void (*rx_status)(u16 *rxstatus, u16 *rxlen);
> struct eth_device netdev;
> @@ -88,12 +88,12 @@ static void dm9000_iow(int reg, u8 value);
>
>  /* DM9000 network board routine  */
>  #ifndef CONFIG_DM9000_BYTE_SWAPPED
> -#define dm9000_outb(d,r) writeb(d, (volatile u8 *)(r))
> -#define dm9000_outw(d,r) writew(d, (volatile u16 *)(r))
> -#define dm9000_outl(d,r) writel(d, (volatile u32 *)(r))
> -#define dm9000_inb(r) readb((volatile u8 *)(r))
> -#define dm9000_inw(r) readw((volatile u16 *)(r))
> -#define dm9000_inl(r) readl((volatile u32 *)(r))
> +#define dm9000_outb(d,r) writeb((d), (r))
> +#define dm9000_outw(d,r) writew((d), (r))
> +#define dm9000_outl(d,r) writel((d), (r))
> +#define dm9000_inb(r) readb(r)
> +#define dm9000_inw(r) readw(r)
> +#define dm9000_inl(r) readl(r)
>  #else
>  #define dm9000_outb(d, r) __raw_writeb(d, r)
>  #define dm9000_outw(d, r) __raw_writew(d, r)
> @@ -122,14 +122,14 @@ static void dm9000_dump_packet(const char *func, u8 
> *packet, int length)
>  static void dm9000_dump_packet(const char *func, u8 *packet, int length) {}
>  #endif
>
> -static void dm9000_outblk_8bit(volatile void *data_ptr, int count)
> +static void dm9000_outblk_8bit(void *data_ptr, int count)
>  {
> int i;
> for (i = 0; i < count; i++)
> dm9000_outbu8 *) data_ptr)[i] & 0xff), DM9000_DATA);
>  }
>
> -static void dm9000_outblk_16bit(volatile void *data_ptr, int count)
> +static void dm9000_outblk_16bit(void *data_ptr, int count)
>  {
> int i;
> u32 tmplen = (count + 1) / 2;
> @@ -137,7 +137,7 @@ static void dm9000_outblk_16bit(volatile void *data_ptr, 
> int count)
> for (i = 0; i < tmplen; i++)
> dm9000_outw(((u16 *) data_ptr)[i], DM9000_DATA);
>  }
> -static void dm9000_outblk_32bit(volatile void *data_ptr, int count)
> +static void dm9000_outblk_32bit(void *data_ptr, int count)
>  {
> int i;
> u32 tmplen = (count + 3) / 4;
> --
> 2.35.1
>
Reviewed-by: Ramon Fried 


Re: [PATCH 05/16] net: dm9000: Turn DM9000_DMP_PACKET() into a function

2022-04-12 Thread Ramon Fried
On Mon, Apr 11, 2022 at 8:56 PM Marek Vasut  wrote:
>
> Rework DM9000_DMP_PACKET() into dm9000_dump_packet() function,
> this brings better type checking. No functional change.
>
> Signed-off-by: Marek Vasut 
> Cc: Joe Hershberger 
> Cc: Ramon Fried 
> ---
>  drivers/net/dm9000x.c | 42 +-
>  1 file changed, 21 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/net/dm9000x.c b/drivers/net/dm9000x.c
> index 223df944a48..da16b64610b 100644
> --- a/drivers/net/dm9000x.c
> +++ b/drivers/net/dm9000x.c
> @@ -58,25 +58,6 @@ TODO: external MII is not functional, only internal at the 
> moment.
>
>  #include "dm9000x.h"
>
> -/* Board/System/Debug information/definition  */
> -
> -/* #define CONFIG_DM9000_DEBUG */
> -
> -#ifdef CONFIG_DM9000_DEBUG
> -#define DM9000_DMP_PACKET(func,packet,length)  \
> -   do { \
> -   int i;  \
> -   printf("%s: length: %d\n", func, length);   \
> -   for (i = 0; i < length; i++) {  \
> -   if (i % 8 == 0) \
> -   printf("\n%s: %02x: ", func, i);\
> -   printf("%02x ", ((unsigned char *) packet)[i]); \
> -   } printf("\n"); \
> -   } while(0)
> -#else
> -#define DM9000_DMP_PACKET(func,packet,length)
> -#endif
> -
>  /* Structure/enum declaration --- */
>  typedef struct board_info {
> u32 runt_length_counter;/* counter: RX length < 64byte */
> @@ -122,6 +103,25 @@ static void dm9000_iow(int reg, u8 value);
>  #define dm9000_inl(r) __raw_readl(r)
>  #endif
>
> +#ifdef DEBUG
> +static void dm9000_dump_packet(const char *func, u8 *packet, int length)
> +{
> +   int i;
> +
> +   printf("%s: length: %d\n", func, length);
> +
> +   for (i = 0; i < length; i++) {
> +   if (i % 8 == 0)
> +   printf("\n%s: %02x: ", func, i);
> +   printf("%02x ", packet[i]);
> +   }
> +
> +   printf("\n");
> +}
> +#else
> +static void dm9000_dump_packet(const char *func, u8 *packet, int length) {}
> +#endif
> +
>  static void dm9000_outblk_8bit(volatile void *data_ptr, int count)
>  {
> int i;
> @@ -387,7 +387,7 @@ static int dm9000_send(struct eth_device *netdev, void 
> *packet, int length)
> int tmo;
> struct board_info *db = _info;
>
> -   DM9000_DMP_PACKET(__func__ , packet, length);
> +   dm9000_dump_packet(__func__ , packet, length);
>
> dm9000_iow(DM9000_ISR, IMR_PTM); /* Clear Tx bit in ISR */
>
> @@ -498,7 +498,7 @@ static int dm9000_rx(struct eth_device *netdev)
> dm9000_reset();
> }
> } else {
> -   DM9000_DMP_PACKET(__func__ , rdptr, rxlen);
> +   dm9000_dump_packet(__func__ , rdptr, rxlen);
>
> debug("passing packet to upper layer\n");
> net_process_received_packet(net_rx_packets[0], rxlen);
> --
> 2.35.1
>
Reviewed-by: Ramon Fried 


Re: [PATCH 04/16] net: dm9000: Drop unused dump_regs()

2022-04-12 Thread Ramon Fried
On Mon, Apr 11, 2022 at 8:56 PM Marek Vasut  wrote:
>
> Drop unused function dump_regs() because it is unused.
> No functional change.
>
> Signed-off-by: Marek Vasut 
> Cc: Joe Hershberger 
> Cc: Ramon Fried 
> ---
>  drivers/net/dm9000x.c | 17 -
>  1 file changed, 17 deletions(-)
>
> diff --git a/drivers/net/dm9000x.c b/drivers/net/dm9000x.c
> index a99a901e828..223df944a48 100644
> --- a/drivers/net/dm9000x.c
> +++ b/drivers/net/dm9000x.c
> @@ -122,23 +122,6 @@ static void dm9000_iow(int reg, u8 value);
>  #define dm9000_inl(r) __raw_readl(r)
>  #endif
>
> -#ifdef CONFIG_DM9000_DEBUG
> -static void
> -dump_regs(void)
> -{
> -   debug("\n");
> -   debug("NCR   (0x00): %02x\n", dm9000_ior(0));
> -   debug("NSR   (0x01): %02x\n", dm9000_ior(1));
> -   debug("TCR   (0x02): %02x\n", dm9000_ior(2));
> -   debug("TSRI  (0x03): %02x\n", dm9000_ior(3));
> -   debug("TSRII (0x04): %02x\n", dm9000_ior(4));
> -   debug("RCR   (0x05): %02x\n", dm9000_ior(5));
> -   debug("RSR   (0x06): %02x\n", dm9000_ior(6));
> -   debug("ISR   (0xFE): %02x\n", dm9000_ior(DM9000_ISR));
> -   debug("\n");
> -}
> -#endif
> -
>  static void dm9000_outblk_8bit(volatile void *data_ptr, int count)
>  {
> int i;
> --
> 2.35.1
>
Reviewed-by: Ramon Fried 


Re: [PATCH 03/16] net: dm9000: Make RxLen and RxStatus lowercase

2022-04-12 Thread Ramon Fried
On Mon, Apr 11, 2022 at 8:56 PM Marek Vasut  wrote:
>
> Rename variables to lowercase to be consistent with coding style.
> No functional change.
>
> Signed-off-by: Marek Vasut 
> Cc: Joe Hershberger 
> Cc: Ramon Fried 
> ---
>  drivers/net/dm9000x.c | 44 +--
>  1 file changed, 22 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/net/dm9000x.c b/drivers/net/dm9000x.c
> index e83b838fd82..a99a901e828 100644
> --- a/drivers/net/dm9000x.c
> +++ b/drivers/net/dm9000x.c
> @@ -92,7 +92,7 @@ typedef struct board_info {
> unsigned char srom[128];
> void (*outblk)(volatile void *data_ptr, int count);
> void (*inblk)(void *data_ptr, int count);
> -   void (*rx_status)(u16 *RxStatus, u16 *RxLen);
> +   void (*rx_status)(u16 *rxstatus, u16 *rxlen);
> struct eth_device netdev;
>  } board_info_t;
>  static board_info_t dm9000_info;
> @@ -187,33 +187,33 @@ static void dm9000_inblk_32bit(void *data_ptr, int 
> count)
> ((u32 *) data_ptr)[i] = dm9000_inl(DM9000_DATA);
>  }
>
> -static void dm9000_rx_status_32bit(u16 *RxStatus, u16 *RxLen)
> +static void dm9000_rx_status_32bit(u16 *rxstatus, u16 *rxlen)
>  {
> u32 tmpdata;
>
> dm9000_outb(DM9000_MRCMD, DM9000_IO);
>
> tmpdata = dm9000_inl(DM9000_DATA);
> -   *RxStatus = __le16_to_cpu(tmpdata);
> -   *RxLen = __le16_to_cpu(tmpdata >> 16);
> +   *rxstatus = __le16_to_cpu(tmpdata);
> +   *rxlen = __le16_to_cpu(tmpdata >> 16);
>  }
>
> -static void dm9000_rx_status_16bit(u16 *RxStatus, u16 *RxLen)
> +static void dm9000_rx_status_16bit(u16 *rxstatus, u16 *rxlen)
>  {
> dm9000_outb(DM9000_MRCMD, DM9000_IO);
>
> -   *RxStatus = __le16_to_cpu(dm9000_inw(DM9000_DATA));
> -   *RxLen = __le16_to_cpu(dm9000_inw(DM9000_DATA));
> +   *rxstatus = __le16_to_cpu(dm9000_inw(DM9000_DATA));
> +   *rxlen = __le16_to_cpu(dm9000_inw(DM9000_DATA));
>  }
>
> -static void dm9000_rx_status_8bit(u16 *RxStatus, u16 *RxLen)
> +static void dm9000_rx_status_8bit(u16 *rxstatus, u16 *rxlen)
>  {
> dm9000_outb(DM9000_MRCMD, DM9000_IO);
>
> -   *RxStatus =
> +   *rxstatus =
> __le16_to_cpu(dm9000_inb(DM9000_DATA) +
>   (dm9000_inb(DM9000_DATA) << 8));
> -   *RxLen =
> +   *rxlen =
> __le16_to_cpu(dm9000_inb(DM9000_DATA) +
>   (dm9000_inb(DM9000_DATA) << 8));
>  }
> @@ -458,7 +458,7 @@ static int dm9000_rx(struct eth_device *netdev)
>  {
> u8 rxbyte;
> u8 *rdptr = (u8 *)net_rx_packets[0];
> -   u16 RxStatus, RxLen = 0;
> +   u16 rxstatus, rxlen = 0;
> struct board_info *db = _info;
>
> /* Check packet ready or not, we must check
> @@ -491,34 +491,34 @@ static int dm9000_rx(struct eth_device *netdev)
> debug("receiving packet\n");
>
> /* A packet ready now  & Get status/length */
> -   (db->rx_status)(, );
> +   (db->rx_status)(, );
>
> -   debug("rx status: 0x%04x rx len: %d\n", RxStatus, RxLen);
> +   debug("rx status: 0x%04x rx len: %d\n", rxstatus, rxlen);
>
> /* Move data from DM9000 */
> /* Read received packet from RX SRAM */
> -   (db->inblk)(rdptr, RxLen);
> +   (db->inblk)(rdptr, rxlen);
>
> -   if ((RxStatus & 0xbf00) || (RxLen < 0x40)
> -   || (RxLen > DM9000_PKT_MAX)) {
> -   if (RxStatus & 0x100) {
> +   if ((rxstatus & 0xbf00) || (rxlen < 0x40)
> +   || (rxlen > DM9000_PKT_MAX)) {
> +   if (rxstatus & 0x100) {
> printf("rx fifo error\n");
> }
> -   if (RxStatus & 0x200) {
> +   if (rxstatus & 0x200) {
> printf("rx crc error\n");
> }
> -   if (RxStatus & 0x8000) {
> +   if (rxstatus & 0x8000) {
> printf("rx length error\n");
> }
> -   if (RxLen > DM9000_PKT_MAX) {
> +   if (rxlen > DM9000_PKT_MAX) {
> printf("rx length too big\n");
> dm9000_reset();
> }
> } else {
> -   DM9000_DMP_PACKET(__func__ , rdptr, RxLen);
> +   DM9000_DMP_PACKET(__func__ , rdptr, rxlen);
>
> debug("passing packet to upper layer\n");
> -   net_process_received_packet(net_rx_packets[0], RxLen);
> +   net_process_received_packet(net_rx_packets[0], rxlen);
> }
> }
> return 0;
> --
> 2.35.1
>
Reviewed-by: Ramon Fried 


Re: [PATCH 02/16] net: dm9000: Replace DM9000_DBG() with debug()

2022-04-12 Thread Ramon Fried
On Mon, Apr 11, 2022 at 8:56 PM Marek Vasut  wrote:
>
> Use standard debug() macro to print debug messages instead of
> reinventing driver-specific macro again. No functional change.
>
> Signed-off-by: Marek Vasut 
> Cc: Joe Hershberger 
> Cc: Ramon Fried 
> ---
>  drivers/net/dm9000x.c | 48 +--
>  1 file changed, 23 insertions(+), 25 deletions(-)
>
> diff --git a/drivers/net/dm9000x.c b/drivers/net/dm9000x.c
> index 93699135f75..e83b838fd82 100644
> --- a/drivers/net/dm9000x.c
> +++ b/drivers/net/dm9000x.c
> @@ -63,7 +63,6 @@ TODO: external MII is not functional, only internal at the 
> moment.
>  /* #define CONFIG_DM9000_DEBUG */
>
>  #ifdef CONFIG_DM9000_DEBUG
> -#define DM9000_DBG(fmt,args...) printf(fmt, ##args)
>  #define DM9000_DMP_PACKET(func,packet,length)  \
> do { \
> int i;  \
> @@ -75,7 +74,6 @@ TODO: external MII is not functional, only internal at the 
> moment.
> } printf("\n"); \
> } while(0)
>  #else
> -#define DM9000_DBG(fmt,args...)
>  #define DM9000_DMP_PACKET(func,packet,length)
>  #endif
>
> @@ -128,16 +126,16 @@ static void dm9000_iow(int reg, u8 value);
>  static void
>  dump_regs(void)
>  {
> -   DM9000_DBG("\n");
> -   DM9000_DBG("NCR   (0x00): %02x\n", dm9000_ior(0));
> -   DM9000_DBG("NSR   (0x01): %02x\n", dm9000_ior(1));
> -   DM9000_DBG("TCR   (0x02): %02x\n", dm9000_ior(2));
> -   DM9000_DBG("TSRI  (0x03): %02x\n", dm9000_ior(3));
> -   DM9000_DBG("TSRII (0x04): %02x\n", dm9000_ior(4));
> -   DM9000_DBG("RCR   (0x05): %02x\n", dm9000_ior(5));
> -   DM9000_DBG("RSR   (0x06): %02x\n", dm9000_ior(6));
> -   DM9000_DBG("ISR   (0xFE): %02x\n", dm9000_ior(DM9000_ISR));
> -   DM9000_DBG("\n");
> +   debug("\n");
> +   debug("NCR   (0x00): %02x\n", dm9000_ior(0));
> +   debug("NSR   (0x01): %02x\n", dm9000_ior(1));
> +   debug("TCR   (0x02): %02x\n", dm9000_ior(2));
> +   debug("TSRI  (0x03): %02x\n", dm9000_ior(3));
> +   debug("TSRII (0x04): %02x\n", dm9000_ior(4));
> +   debug("RCR   (0x05): %02x\n", dm9000_ior(5));
> +   debug("RSR   (0x06): %02x\n", dm9000_ior(6));
> +   debug("ISR   (0xFE): %02x\n", dm9000_ior(DM9000_ISR));
> +   debug("\n");
>  }
>  #endif
>
> @@ -246,7 +244,7 @@ dm9000_probe(void)
>  static void
>  dm9000_reset(void)
>  {
> -   DM9000_DBG("resetting DM9000\n");
> +   debug("resetting DM9000\n");
>
> /* Reset DM9000,
>see DM9000 Application Notes V1.22 Jun 11, 2004 page 29 */
> @@ -259,7 +257,7 @@ dm9000_reset(void)
> dm9000_iow(DM9000_NCR, (NCR_LBK_INT_MAC | NCR_RST));
>
> do {
> -   DM9000_DBG("resetting the DM9000, 1st reset\n");
> +   debug("resetting the DM9000, 1st reset\n");
> udelay(25); /* Wait at least 20 us */
> } while (dm9000_ior(DM9000_NCR) & 1);
>
> @@ -267,7 +265,7 @@ dm9000_reset(void)
> dm9000_iow(DM9000_NCR, (NCR_LBK_INT_MAC | NCR_RST)); /* Issue a 
> second reset */
>
> do {
> -   DM9000_DBG("resetting the DM9000, 2nd reset\n");
> +   debug("resetting the DM9000, 2nd reset\n");
> udelay(25); /* Wait at least 20 us */
> } while (dm9000_ior(DM9000_NCR) & 1);
>
> @@ -285,7 +283,7 @@ static int dm9000_init(struct eth_device *dev, struct 
> bd_info *bd)
> u8 io_mode;
> struct board_info *db = _info;
>
> -   DM9000_DBG("%s\n", __func__);
> +   debug("%s\n", __func__);
>
> /* RESET device */
> dm9000_reset();
> @@ -354,8 +352,8 @@ static int dm9000_init(struct eth_device *dev, struct 
> bd_info *bd)
>
> /* read back mac, just to be sure */
> for (i = 0, oft = 0x10; i < 6; i++, oft++)
> -   DM9000_DBG("%02x:", dm9000_ior(oft));
> -   DM9000_DBG("\n");
> +   debug("%02x:", dm9000_ior(oft));
> +   debug("\n");
>
> /* Activate DM9000 */
> /* RX enable */
> @@ -434,7 +432,7 @@ static int dm9000_send(struct eth_device *netdev, void 
> *packet, int length)
> }
> dm9000_iow(DM9000_ISR, IMR_PTM); /* Clear Tx bit in ISR */
>
> -   DM9000_DBG("transmit done\n\n");
> +   debug("transmit done\n\n");
> return 0;
>  }
>
> @@ -444,7 +442,7 @@ static int dm9000_send(struct eth_device *netdev, void 
> *packet, int length)
>  */
>  static void dm9000_halt(struct eth_device *netdev)
>  {
> -   DM9000_DBG("%s\n", __func__);
> +   debug("%s\n", __func__);
>
> /* RESET devie */
> dm9000_phy_write(0, 0x8000);/* PHY RESET */
> @@ -490,12 +488,12 @@ static int dm9000_rx(struct eth_device *netdev)
> if (rxbyte != DM9000_PKT_RDY)
> return 0; /* No packet received, ignore */
>
> -   DM9000_DBG("receiving packet\n");
> +   debug("receiving 

  1   2   3   >