All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 00/16] General Tegra improvements
@ 2023-02-14 17:35 Svyatoslav Ryhel
  2023-02-14 17:35 ` [PATCH v4 01/16] tegra30: clock: add EXTPERIPH Svyatoslav Ryhel
                   ` (16 more replies)
  0 siblings, 17 replies; 28+ messages in thread
From: Svyatoslav Ryhel @ 2023-02-14 17:35 UTC (permalink / raw)
  To: Tom Warren, Marcel Ziswiler, Allen Martin, Jagan Teki,
	Lukasz Majewski, Marek Vasut, Svyatoslav Ryhel, Ramin Khonsari,
	Thierry Reding, Maxim Schwalm, Dmitry Osipenko, Simon Glass
  Cc: u-boot

List of changes in patch set:
 - add missing EXTPERIPH clocks for t30
 - swap host1x and disp1 clock parents (as they should be)
 - add clk_id_to_pll_id and clock_decode_pair helpers to use
   dts deeper (in tegra clocks often go in pair child - parent)
 - include PLLD setup in T30 (DISP1 may use it as parent on
   some devices)
 - fix Tegra PWM parent clock inline with linux
 - Tegra SLINK: patch to accept any word length (unlike 8bit
   aligned which was before)
 - provide default USB gadget setup for existing Nvidia boards
 - add late init function to be able to configure pre-boot stage
   (like uncovering serial number or setting mac address)
 - create common pre-dm i2c write for PMIC (used on T30 and T124
   to configure basic PMIC voltages required to boot like cpu and
   core voltages)
 - expose crypto module for all Tegra SoCs and implement BCT patching
   (ability to update bootloader from u-boot on production devices
   without need in host PC)

---
Changelog from v3
 - added tested-by

Changelog from v2
 - fixed T114 TEGRA114_CLK_PLL_E_OUT0
 - adjusted pre-dm i2c write commit description
 - added description file for ebtupdate command
 - minor improvements of bct.c comments

Changelog from v1
 - rebased to latest u-boot master 
 - PLLD setup for T30 moved specifically into T30 area
---

Maxim Schwalm (1):
  ARM: tegra: provide default USB gadget setup

Ramin Khonsari (1):
  ARM: tegra30: implement BCT patching

Svyatoslav Ryhel (14):
  tegra30: clock: add EXTPERIPH
  ARM: t20/t30: swap host1x and disp1 clock parents
  ARM: tegra: clock: add clk_id_to_pll_id helper
  ARM: tegra: clock: add clock_decode_pair helper
  ARM: tegra30: add PLLD to pll setup
  ARM: tegra: Fix Tegra PWM parent clock
  spi: tegra20_slink: accept any word length
  ARM: tegra: add late init support
  ARM: tegra: create common pre-dm i2c write
  board: tegra124: switch to updated pre-dm i2c write
  board: tegra30: switch to updated pre-dm i2c write
  ARM: tegra: expose crypto module for all Tegra SoCs
  ARM: tegra: crypto: extend crypto functional
  ARM: tegra20: implement BCT patching

 arch/arm/dts/tegra114.dtsi                    |  2 +-
 arch/arm/dts/tegra124.dtsi                    |  2 +-
 arch/arm/include/asm/arch-tegra/clock.h       | 21 +++++
 arch/arm/include/asm/arch-tegra/crypto.h      | 47 ++++++++++
 arch/arm/include/asm/arch-tegra/sys_proto.h   |  6 ++
 arch/arm/include/asm/arch-tegra/tegra_i2c.h   | 17 ++++
 .../include/asm/arch-tegra30/clock-tables.h   |  6 +-
 arch/arm/mach-tegra/Kconfig                   | 14 +++
 arch/arm/mach-tegra/Makefile                  |  1 +
 arch/arm/mach-tegra/board2.c                  |  2 +
 arch/arm/mach-tegra/clock.c                   | 23 +++++
 arch/arm/mach-tegra/cpu.h                     |  1 -
 arch/arm/mach-tegra/{tegra20 => }/crypto.c    | 63 +++++++++----
 arch/arm/mach-tegra/tegra114/clock.c          | 39 +++++++-
 arch/arm/mach-tegra/tegra124/clock.c          | 40 ++++++++-
 arch/arm/mach-tegra/tegra124/cpu.c            |  4 +
 arch/arm/mach-tegra/tegra20/Kconfig           |  1 +
 arch/arm/mach-tegra/tegra20/Makefile          |  7 +-
 arch/arm/mach-tegra/tegra20/bct.c             | 79 ++++++++++++++++
 arch/arm/mach-tegra/tegra20/bct.h             | 42 +++++++++
 arch/arm/mach-tegra/tegra20/clock.c           | 43 ++++++++-
 arch/arm/mach-tegra/tegra20/crypto.h          | 19 ----
 arch/arm/mach-tegra/tegra210/clock.c          | 39 +++++++-
 arch/arm/mach-tegra/tegra30/Kconfig           |  8 --
 arch/arm/mach-tegra/tegra30/Makefile          |  1 +
 arch/arm/mach-tegra/tegra30/bct.c             | 79 ++++++++++++++++
 arch/arm/mach-tegra/tegra30/bct.h             | 42 +++++++++
 arch/arm/mach-tegra/tegra30/clock.c           | 90 +++++++++++++++++--
 arch/arm/mach-tegra/tegra30/cpu.c             | 55 +-----------
 board/avionic-design/tec-ng/Makefile          |  4 +-
 board/avionic-design/tec-ng/tec-ng-spl.c      | 34 +++++++
 board/nvidia/beaver/Makefile                  |  2 +
 board/nvidia/beaver/beaver-spl.c              | 43 +++++++++
 board/nvidia/cardhu/Makefile                  |  4 +-
 board/nvidia/cardhu/cardhu-spl.c              | 43 +++++++++
 board/nvidia/venice2/as3722_init.c            | 65 +++++++++-----
 board/nvidia/venice2/as3722_init.h            | 43 ---------
 board/toradex/apalis-tk1/as3722_init.c        | 85 ++++++++++--------
 board/toradex/apalis-tk1/as3722_init.h        | 40 ---------
 board/toradex/apalis_t30/Makefile             |  2 +
 board/toradex/apalis_t30/apalis_t30-spl.c     | 34 +++++++
 board/toradex/colibri_t30/Makefile            |  2 +
 board/toradex/colibri_t30/colibri_t30-spl.c   | 34 +++++++
 configs/beaver_defconfig                      |  3 -
 configs/cei-tk1-som_defconfig                 |  3 -
 configs/dalmore_defconfig                     |  3 -
 configs/jetson-tk1_defconfig                  |  3 -
 configs/nyan-big_defconfig                    |  3 -
 configs/p2371-0000_defconfig                  |  3 -
 configs/p2371-2180_defconfig                  |  3 -
 configs/p2571_defconfig                       |  3 -
 configs/p3450-0000_defconfig                  |  3 -
 configs/venice2_defconfig                     |  3 -
 doc/usage/cmd/ebtupdate.rst                   | 70 +++++++++++++++
 drivers/pwm/tegra_pwm.c                       | 10 ++-
 drivers/spi/tegra20_slink.c                   | 19 ++--
 drivers/usb/gadget/Kconfig                    |  3 +
 57 files changed, 1051 insertions(+), 309 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-tegra/crypto.h
 rename arch/arm/mach-tegra/{tegra20 => }/crypto.c (68%)
 create mode 100644 arch/arm/mach-tegra/tegra20/bct.c
 create mode 100644 arch/arm/mach-tegra/tegra20/bct.h
 delete mode 100644 arch/arm/mach-tegra/tegra20/crypto.h
 create mode 100644 arch/arm/mach-tegra/tegra30/bct.c
 create mode 100644 arch/arm/mach-tegra/tegra30/bct.h
 create mode 100644 board/avionic-design/tec-ng/tec-ng-spl.c
 create mode 100644 board/nvidia/beaver/beaver-spl.c
 create mode 100644 board/nvidia/cardhu/cardhu-spl.c
 delete mode 100644 board/nvidia/venice2/as3722_init.h
 delete mode 100644 board/toradex/apalis-tk1/as3722_init.h
 create mode 100644 board/toradex/apalis_t30/apalis_t30-spl.c
 create mode 100644 board/toradex/colibri_t30/colibri_t30-spl.c
 create mode 100644 doc/usage/cmd/ebtupdate.rst

-- 
2.37.2


^ permalink raw reply	[flat|nested] 28+ messages in thread

* [PATCH v4 01/16] tegra30: clock: add EXTPERIPH
  2023-02-14 17:35 [PATCH v4 00/16] General Tegra improvements Svyatoslav Ryhel
@ 2023-02-14 17:35 ` Svyatoslav Ryhel
  2023-02-14 17:35 ` [PATCH v4 02/16] ARM: t20/t30: swap host1x and disp1 clock parents Svyatoslav Ryhel
                   ` (15 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Svyatoslav Ryhel @ 2023-02-14 17:35 UTC (permalink / raw)
  To: Tom Warren, Marcel Ziswiler, Allen Martin, Jagan Teki,
	Lukasz Majewski, Marek Vasut, Svyatoslav Ryhel, Ramin Khonsari,
	Thierry Reding, Maxim Schwalm, Dmitry Osipenko, Simon Glass
  Cc: u-boot

This mappings were missing for some reason.

Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # LG P895 T30
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
 arch/arm/include/asm/arch-tegra30/clock-tables.h | 6 +++---
 arch/arm/mach-tegra/tegra30/clock.c              | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/arm/include/asm/arch-tegra30/clock-tables.h b/arch/arm/include/asm/arch-tegra30/clock-tables.h
index 8588009c61..6c899ff64c 100644
--- a/arch/arm/include/asm/arch-tegra30/clock-tables.h
+++ b/arch/arm/include/asm/arch-tegra30/clock-tables.h
@@ -190,9 +190,9 @@ enum periph_id {
 	PERIPH_ID_ACTMON,
 
 	/* 24 */
-	PERIPH_ID_EX_RESERVED24,
-	PERIPH_ID_EX_RESERVED25,
-	PERIPH_ID_EX_RESERVED26,
+	PERIPH_ID_EXTPERIPH1,
+	PERIPH_ID_EXTPERIPH2,
+	PERIPH_ID_EXTPERIPH3,
 	PERIPH_ID_EX_RESERVED27,
 	PERIPH_ID_SATA,
 	PERIPH_ID_HDA,
diff --git a/arch/arm/mach-tegra/tegra30/clock.c b/arch/arm/mach-tegra/tegra30/clock.c
index 449b66e3b2..04ad5c504d 100644
--- a/arch/arm/mach-tegra/tegra30/clock.c
+++ b/arch/arm/mach-tegra/tegra30/clock.c
@@ -377,9 +377,9 @@ static s8 periph_id_to_internal_id[PERIPH_ID_COUNT] = {
 	PERIPHC_ACTMON,
 
 	/* 24 */
-	NONE(RESERVED24),
-	NONE(RESERVED25),
-	NONE(RESERVED26),
+	PERIPHC_EXTPERIPH1,
+	PERIPHC_EXTPERIPH2,
+	PERIPHC_EXTPERIPH3,
 	NONE(RESERVED27),
 	PERIPHC_SATA,
 	PERIPHC_HDA,
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v4 02/16] ARM: t20/t30: swap host1x and disp1 clock parents
  2023-02-14 17:35 [PATCH v4 00/16] General Tegra improvements Svyatoslav Ryhel
  2023-02-14 17:35 ` [PATCH v4 01/16] tegra30: clock: add EXTPERIPH Svyatoslav Ryhel
@ 2023-02-14 17:35 ` Svyatoslav Ryhel
  2023-02-14 17:35 ` [PATCH v4 03/16] ARM: tegra: clock: add clk_id_to_pll_id helper Svyatoslav Ryhel
                   ` (14 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Svyatoslav Ryhel @ 2023-02-14 17:35 UTC (permalink / raw)
  To: Tom Warren, Marcel Ziswiler, Allen Martin, Jagan Teki,
	Lukasz Majewski, Marek Vasut, Svyatoslav Ryhel, Ramin Khonsari,
	Thierry Reding, Maxim Schwalm, Dmitry Osipenko, Simon Glass
  Cc: u-boot

According to mainline clock tables and TRM HOST1X
parent is PLLC, while DISP1 usually uses PLLP as
parent clock.

Tested-by: Andreas Westman Dorcsak <hedmoo@yahoo.com> # ASUS TF T30
Tested-by: Robert Eckelmann <longnoserob@gmail.com> # ASUS TF101 T20
Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # LG P895 T30
Tested-by: Thierry Reding <treding@nvidia.com> # Beaver T30
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 arch/arm/mach-tegra/tegra20/clock.c | 4 ++--
 arch/arm/mach-tegra/tegra30/clock.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-tegra/tegra20/clock.c b/arch/arm/mach-tegra/tegra20/clock.c
index 8c127430aa..0316073d1a 100644
--- a/arch/arm/mach-tegra/tegra20/clock.c
+++ b/arch/arm/mach-tegra/tegra20/clock.c
@@ -760,8 +760,8 @@ struct periph_clk_init periph_clk_init_table[] = {
 	{ PERIPH_ID_SBC2, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_SBC3, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_SBC4, CLOCK_ID_PERIPH },
-	{ PERIPH_ID_HOST1X, CLOCK_ID_PERIPH },
-	{ PERIPH_ID_DISP1, CLOCK_ID_CGENERAL },
+	{ PERIPH_ID_HOST1X, CLOCK_ID_CGENERAL },
+	{ PERIPH_ID_DISP1, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_NDFLASH, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_SDMMC1, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_SDMMC2, CLOCK_ID_PERIPH },
diff --git a/arch/arm/mach-tegra/tegra30/clock.c b/arch/arm/mach-tegra/tegra30/clock.c
index 04ad5c504d..e5c2fd542c 100644
--- a/arch/arm/mach-tegra/tegra30/clock.c
+++ b/arch/arm/mach-tegra/tegra30/clock.c
@@ -799,8 +799,8 @@ struct periph_clk_init periph_clk_init_table[] = {
 	{ PERIPH_ID_SBC4, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_SBC5, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_SBC6, CLOCK_ID_PERIPH },
-	{ PERIPH_ID_HOST1X, CLOCK_ID_PERIPH },
-	{ PERIPH_ID_DISP1, CLOCK_ID_CGENERAL },
+	{ PERIPH_ID_HOST1X, CLOCK_ID_CGENERAL },
+	{ PERIPH_ID_DISP1, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_NDFLASH, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_SDMMC1, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_SDMMC2, CLOCK_ID_PERIPH },
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v4 03/16] ARM: tegra: clock: add clk_id_to_pll_id helper
  2023-02-14 17:35 [PATCH v4 00/16] General Tegra improvements Svyatoslav Ryhel
  2023-02-14 17:35 ` [PATCH v4 01/16] tegra30: clock: add EXTPERIPH Svyatoslav Ryhel
  2023-02-14 17:35 ` [PATCH v4 02/16] ARM: t20/t30: swap host1x and disp1 clock parents Svyatoslav Ryhel
@ 2023-02-14 17:35 ` Svyatoslav Ryhel
  2023-02-14 17:35 ` [PATCH v4 04/16] ARM: tegra: clock: add clock_decode_pair helper Svyatoslav Ryhel
                   ` (13 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Svyatoslav Ryhel @ 2023-02-14 17:35 UTC (permalink / raw)
  To: Tom Warren, Marcel Ziswiler, Allen Martin, Jagan Teki,
	Lukasz Majewski, Marek Vasut, Svyatoslav Ryhel, Ramin Khonsari,
	Thierry Reding, Maxim Schwalm, Dmitry Osipenko, Simon Glass
  Cc: u-boot

This function allows to convert a device tree clock ID to PLL ID.

Tested-by: Andreas Westman Dorcsak <hedmoo@yahoo.com> # ASUS TF T30
Tested-by: Robert Eckelmann <longnoserob@gmail.com> # ASUS TF101 T20
Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # HTC One X
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 arch/arm/include/asm/arch-tegra/clock.h |  8 ++++++
 arch/arm/mach-tegra/tegra114/clock.c    | 37 ++++++++++++++++++++++++
 arch/arm/mach-tegra/tegra124/clock.c    | 38 +++++++++++++++++++++++++
 arch/arm/mach-tegra/tegra20/clock.c     | 37 ++++++++++++++++++++++++
 arch/arm/mach-tegra/tegra210/clock.c    | 37 ++++++++++++++++++++++++
 arch/arm/mach-tegra/tegra30/clock.c     | 37 ++++++++++++++++++++++++
 6 files changed, 194 insertions(+)

diff --git a/arch/arm/include/asm/arch-tegra/clock.h b/arch/arm/include/asm/arch-tegra/clock.h
index 1dd5d0742c..2270501406 100644
--- a/arch/arm/include/asm/arch-tegra/clock.h
+++ b/arch/arm/include/asm/arch-tegra/clock.h
@@ -354,6 +354,14 @@ int get_periph_clock_source(enum periph_id periph_id,
  */
 enum periph_id clk_id_to_periph_id(int clk_id);
 
+/*
+ * Convert a device tree clock ID to our PLL ID.
+ *
+ * @param clk_id	Clock ID according to tegra device tree binding
+ * Return: clock ID, or CLOCK_ID_NONE if the clock ID is invalid
+ */
+enum clock_id clk_id_to_pll_id(int clk_id);
+
 /**
  * Set the output frequency you want for each PLL clock.
  * PLL output frequencies are programmed by setting their N, M and P values.
diff --git a/arch/arm/mach-tegra/tegra114/clock.c b/arch/arm/mach-tegra/tegra114/clock.c
index 143f86863f..15c2adc417 100644
--- a/arch/arm/mach-tegra/tegra114/clock.c
+++ b/arch/arm/mach-tegra/tegra114/clock.c
@@ -19,6 +19,8 @@
 #include <fdtdec.h>
 #include <linux/delay.h>
 
+#include <dt-bindings/clock/tegra114-car.h>
+
 /*
  * Clock types that we can use as a source. The Tegra114 has muxes for the
  * peripheral clocks, and in most cases there are four options for the clock
@@ -646,6 +648,41 @@ enum periph_id clk_id_to_periph_id(int clk_id)
 		return clk_id;
 	}
 }
+
+/*
+ * Convert a device tree clock ID to our PLL ID.
+ *
+ * @param clk_id	Clock ID according to tegra114 device tree binding
+ * Return: clock ID, or CLOCK_ID_NONE if the clock ID is invalid
+ */
+enum clock_id clk_id_to_pll_id(int clk_id)
+{
+	switch (clk_id) {
+	case TEGRA114_CLK_PLL_C:
+		return CLOCK_ID_CGENERAL;
+	case TEGRA114_CLK_PLL_M:
+		return CLOCK_ID_MEMORY;
+	case TEGRA114_CLK_PLL_P:
+		return CLOCK_ID_PERIPH;
+	case TEGRA114_CLK_PLL_A:
+		return CLOCK_ID_AUDIO;
+	case TEGRA114_CLK_PLL_U:
+		return CLOCK_ID_USB;
+	case TEGRA114_CLK_PLL_D:
+	case TEGRA114_CLK_PLL_D_OUT0:
+		return CLOCK_ID_DISPLAY;
+	case TEGRA114_CLK_PLL_X:
+		return CLOCK_ID_XCPU;
+	case TEGRA114_CLK_PLL_E_OUT0:
+		return CLOCK_ID_EPCI;
+	case TEGRA114_CLK_CLK_32K:
+		return CLOCK_ID_32KHZ;
+	case TEGRA114_CLK_CLK_M:
+		return CLOCK_ID_CLK_M;
+	default:
+		return CLOCK_ID_NONE;
+	}
+}
 #endif /* CONFIG_IS_ENABLED(OF_CONTROL) */
 
 void clock_early_init(void)
diff --git a/arch/arm/mach-tegra/tegra124/clock.c b/arch/arm/mach-tegra/tegra124/clock.c
index da38b26c27..415ba15e5d 100644
--- a/arch/arm/mach-tegra/tegra124/clock.c
+++ b/arch/arm/mach-tegra/tegra124/clock.c
@@ -19,6 +19,9 @@
 #include <fdtdec.h>
 #include <linux/delay.h>
 
+#include <dt-bindings/clock/tegra124-car.h>
+#include <dt-bindings/clock/tegra124-car-common.h>
+
 /*
  * Clock types that we can use as a source. The Tegra124 has muxes for the
  * peripheral clocks, and in most cases there are four options for the clock
@@ -826,6 +829,41 @@ enum periph_id clk_id_to_periph_id(int clk_id)
 		return clk_id;
 	}
 }
+
+/*
+ * Convert a device tree clock ID to our PLL ID.
+ *
+ * @param clk_id	Clock ID according to tegra124 device tree binding
+ * Return: clock ID, or CLOCK_ID_NONE if the clock ID is invalid
+ */
+enum clock_id clk_id_to_pll_id(int clk_id)
+{
+	switch (clk_id) {
+	case TEGRA124_CLK_PLL_C:
+		return CLOCK_ID_CGENERAL;
+	case TEGRA124_CLK_PLL_M:
+		return CLOCK_ID_MEMORY;
+	case TEGRA124_CLK_PLL_P:
+		return CLOCK_ID_PERIPH;
+	case TEGRA124_CLK_PLL_A:
+		return CLOCK_ID_AUDIO;
+	case TEGRA124_CLK_PLL_U:
+		return CLOCK_ID_USB;
+	case TEGRA124_CLK_PLL_D:
+	case TEGRA124_CLK_PLL_D_OUT0:
+		return CLOCK_ID_DISPLAY;
+	case TEGRA124_CLK_PLL_X:
+		return CLOCK_ID_XCPU;
+	case TEGRA124_CLK_PLL_E:
+		return CLOCK_ID_EPCI;
+	case TEGRA124_CLK_CLK_32K:
+		return CLOCK_ID_32KHZ;
+	case TEGRA124_CLK_CLK_M:
+		return CLOCK_ID_CLK_M;
+	default:
+		return CLOCK_ID_NONE;
+	}
+}
 #endif /* CONFIG_IS_ENABLED(OF_CONTROL) */
 
 void clock_early_init(void)
diff --git a/arch/arm/mach-tegra/tegra20/clock.c b/arch/arm/mach-tegra/tegra20/clock.c
index 0316073d1a..593622bfdc 100644
--- a/arch/arm/mach-tegra/tegra20/clock.c
+++ b/arch/arm/mach-tegra/tegra20/clock.c
@@ -20,6 +20,8 @@
 #include <fdtdec.h>
 #include <linux/delay.h>
 
+#include <dt-bindings/clock/tegra20-car.h>
+
 /*
  * Clock types that we can use as a source. The Tegra20 has muxes for the
  * peripheral clocks, and in most cases there are four options for the clock
@@ -578,6 +580,41 @@ enum periph_id clk_id_to_periph_id(int clk_id)
 		return clk_id;
 	}
 }
+
+/*
+ * Convert a device tree clock ID to our PLL ID.
+ *
+ * @param clk_id	Clock ID according to tegra20 device tree binding
+ * Return: clock ID, or CLOCK_ID_NONE if the clock ID is invalid
+ */
+enum clock_id clk_id_to_pll_id(int clk_id)
+{
+	switch (clk_id) {
+	case TEGRA20_CLK_PLL_C:
+		return CLOCK_ID_CGENERAL;
+	case TEGRA20_CLK_PLL_M:
+		return CLOCK_ID_MEMORY;
+	case TEGRA20_CLK_PLL_P:
+		return CLOCK_ID_PERIPH;
+	case TEGRA20_CLK_PLL_A:
+		return CLOCK_ID_AUDIO;
+	case TEGRA20_CLK_PLL_U:
+		return CLOCK_ID_USB;
+	case TEGRA20_CLK_PLL_D:
+	case TEGRA20_CLK_PLL_D_OUT0:
+		return CLOCK_ID_DISPLAY;
+	case TEGRA20_CLK_PLL_X:
+		return CLOCK_ID_XCPU;
+	case TEGRA20_CLK_PLL_E:
+		return CLOCK_ID_EPCI;
+	case TEGRA20_CLK_CLK_32K:
+		return CLOCK_ID_32KHZ;
+	case TEGRA20_CLK_CLK_M:
+		return CLOCK_ID_CLK_M;
+	default:
+		return CLOCK_ID_NONE;
+	}
+}
 #endif /* CONFIG_IS_ENABLED(OF_CONTROL) */
 
 void clock_early_init(void)
diff --git a/arch/arm/mach-tegra/tegra210/clock.c b/arch/arm/mach-tegra/tegra210/clock.c
index 330753f2ad..76fbfef580 100644
--- a/arch/arm/mach-tegra/tegra210/clock.c
+++ b/arch/arm/mach-tegra/tegra210/clock.c
@@ -22,6 +22,8 @@
 #include <linux/bitops.h>
 #include <linux/delay.h>
 
+#include <dt-bindings/clock/tegra210-car.h>
+
 /*
  * Clock types that we can use as a source. The Tegra210 has muxes for the
  * peripheral clocks, and in most cases there are four options for the clock
@@ -914,6 +916,41 @@ enum periph_id clk_id_to_periph_id(int clk_id)
 		return clk_id;
 	}
 }
+
+/*
+ * Convert a device tree clock ID to our PLL ID.
+ *
+ * @param clk_id	Clock ID according to tegra210 device tree binding
+ * Return: clock ID, or CLOCK_ID_NONE if the clock ID is invalid
+ */
+enum clock_id clk_id_to_pll_id(int clk_id)
+{
+	switch (clk_id) {
+	case TEGRA210_CLK_PLL_C:
+		return CLOCK_ID_CGENERAL;
+	case TEGRA210_CLK_PLL_M:
+		return CLOCK_ID_MEMORY;
+	case TEGRA210_CLK_PLL_P:
+		return CLOCK_ID_PERIPH;
+	case TEGRA210_CLK_PLL_A:
+		return CLOCK_ID_AUDIO;
+	case TEGRA210_CLK_PLL_U:
+		return CLOCK_ID_USB;
+	case TEGRA210_CLK_PLL_D:
+	case TEGRA210_CLK_PLL_D_OUT0:
+		return CLOCK_ID_DISPLAY;
+	case TEGRA210_CLK_PLL_X:
+		return CLOCK_ID_XCPU;
+	case TEGRA210_CLK_PLL_E:
+		return CLOCK_ID_EPCI;
+	case TEGRA210_CLK_CLK_32K:
+		return CLOCK_ID_32KHZ;
+	case TEGRA210_CLK_CLK_M:
+		return CLOCK_ID_CLK_M;
+	default:
+		return CLOCK_ID_NONE;
+	}
+}
 #endif /* CONFIG_OF_CONTROL */
 
 /*
diff --git a/arch/arm/mach-tegra/tegra30/clock.c b/arch/arm/mach-tegra/tegra30/clock.c
index e5c2fd542c..dcdd0d0978 100644
--- a/arch/arm/mach-tegra/tegra30/clock.c
+++ b/arch/arm/mach-tegra/tegra30/clock.c
@@ -19,6 +19,8 @@
 #include <fdtdec.h>
 #include <linux/delay.h>
 
+#include <dt-bindings/clock/tegra30-car.h>
+
 /*
  * Clock types that we can use as a source. The Tegra30 has muxes for the
  * peripheral clocks, and in most cases there are four options for the clock
@@ -628,6 +630,41 @@ enum periph_id clk_id_to_periph_id(int clk_id)
 		return clk_id;
 	}
 }
+
+/*
+ * Convert a device tree clock ID to our PLL ID.
+ *
+ * @param clk_id	Clock ID according to tegra30 device tree binding
+ * Return: clock ID, or CLOCK_ID_NONE if the clock ID is invalid
+ */
+enum clock_id clk_id_to_pll_id(int clk_id)
+{
+	switch (clk_id) {
+	case TEGRA30_CLK_PLL_C:
+		return CLOCK_ID_CGENERAL;
+	case TEGRA30_CLK_PLL_M:
+		return CLOCK_ID_MEMORY;
+	case TEGRA30_CLK_PLL_P:
+		return CLOCK_ID_PERIPH;
+	case TEGRA30_CLK_PLL_A:
+		return CLOCK_ID_AUDIO;
+	case TEGRA30_CLK_PLL_U:
+		return CLOCK_ID_USB;
+	case TEGRA30_CLK_PLL_D:
+	case TEGRA30_CLK_PLL_D_OUT0:
+		return CLOCK_ID_DISPLAY;
+	case TEGRA30_CLK_PLL_X:
+		return CLOCK_ID_XCPU;
+	case TEGRA30_CLK_PLL_E:
+		return CLOCK_ID_EPCI;
+	case TEGRA30_CLK_CLK_32K:
+		return CLOCK_ID_32KHZ;
+	case TEGRA30_CLK_CLK_M:
+		return CLOCK_ID_CLK_M;
+	default:
+		return CLOCK_ID_NONE;
+	}
+}
 #endif /* CONFIG_IS_ENABLED(OF_CONTROL) */
 
 void clock_early_init(void)
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v4 04/16] ARM: tegra: clock: add clock_decode_pair helper
  2023-02-14 17:35 [PATCH v4 00/16] General Tegra improvements Svyatoslav Ryhel
                   ` (2 preceding siblings ...)
  2023-02-14 17:35 ` [PATCH v4 03/16] ARM: tegra: clock: add clk_id_to_pll_id helper Svyatoslav Ryhel
@ 2023-02-14 17:35 ` Svyatoslav Ryhel
  2023-02-14 17:35 ` [PATCH v4 05/16] ARM: tegra30: add PLLD to pll setup Svyatoslav Ryhel
                   ` (12 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Svyatoslav Ryhel @ 2023-02-14 17:35 UTC (permalink / raw)
  To: Tom Warren, Marcel Ziswiler, Allen Martin, Jagan Teki,
	Lukasz Majewski, Marek Vasut, Svyatoslav Ryhel, Ramin Khonsari,
	Thierry Reding, Maxim Schwalm, Dmitry Osipenko, Simon Glass
  Cc: u-boot

Get periph clock id and its parent from device tree.
This works by looking up the peripheral's 'clocks' node and
reading out the second and fourth cells, which are the
peripheral and PLL clock numbers.

Tested-by: Andreas Westman Dorcsak <hedmoo@yahoo.com> # ASUS TF T30
Tested-by: Robert Eckelmann <longnoserob@gmail.com> # ASUS TF101 T20
Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # HTC One X
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 arch/arm/include/asm/arch-tegra/clock.h | 13 +++++++++++++
 arch/arm/mach-tegra/clock.c             | 23 +++++++++++++++++++++++
 2 files changed, 36 insertions(+)

diff --git a/arch/arm/include/asm/arch-tegra/clock.h b/arch/arm/include/asm/arch-tegra/clock.h
index 2270501406..61ef81e7fe 100644
--- a/arch/arm/include/asm/arch-tegra/clock.h
+++ b/arch/arm/include/asm/arch-tegra/clock.h
@@ -270,6 +270,19 @@ void clock_ll_start_uart(enum periph_id periph_id);
  */
 int clock_decode_periph_id(struct udevice *dev);
 
+/**
+ * Get periph clock id and its parent from device tree.
+ *
+ * This works by looking up the peripheral's 'clocks' node and reading out
+ * the second and fourth cells, which are the peripheral and PLL clock numbers.
+ *
+ * @param dev          udevice associated with FDT node
+ * @param clk_id       pointer to int array of 2 values
+ *                     first is periph clock, second is
+ *                     its PLL parent according to FDT.
+ */
+int clock_decode_pair(struct udevice *dev, int *clk_id);
+
 /**
  * Checks if the oscillator bypass is enabled (XOBP bit)
  *
diff --git a/arch/arm/mach-tegra/clock.c b/arch/arm/mach-tegra/clock.c
index 11bffc1701..966009f375 100644
--- a/arch/arm/mach-tegra/clock.c
+++ b/arch/arm/mach-tegra/clock.c
@@ -678,6 +678,29 @@ int clock_decode_periph_id(struct udevice *dev)
 	assert(clock_periph_id_isvalid(id));
 	return id;
 }
+
+/*
+ * Get periph clock id and its parent from device tree.
+ *
+ * @param dev		udevice associated with FDT node
+ * @param clk_id	pointer to u32 array of 2 values
+ *			first is periph clock, second is
+ *			its PLL parent according to FDT.
+ */
+int clock_decode_pair(struct udevice *dev, int *clk_id)
+{
+	u32 cell[4];
+	int err;
+
+	err = dev_read_u32_array(dev, "clocks", cell, ARRAY_SIZE(cell));
+	if (err)
+		return -EINVAL;
+
+	clk_id[0] = clk_id_to_periph_id(cell[1]);
+	clk_id[1] = clk_id_to_pll_id(cell[3]);
+
+	return 0;
+}
 #endif /* CONFIG_IS_ENABLED(OF_CONTROL) */
 
 int clock_verify(void)
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v4 05/16] ARM: tegra30: add PLLD to pll setup
  2023-02-14 17:35 [PATCH v4 00/16] General Tegra improvements Svyatoslav Ryhel
                   ` (3 preceding siblings ...)
  2023-02-14 17:35 ` [PATCH v4 04/16] ARM: tegra: clock: add clock_decode_pair helper Svyatoslav Ryhel
@ 2023-02-14 17:35 ` Svyatoslav Ryhel
  2023-02-14 17:35 ` [PATCH v4 06/16] ARM: tegra: Fix Tegra PWM parent clock Svyatoslav Ryhel
                   ` (11 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Svyatoslav Ryhel @ 2023-02-14 17:35 UTC (permalink / raw)
  To: Tom Warren, Marcel Ziswiler, Allen Martin, Jagan Teki,
	Lukasz Majewski, Marek Vasut, Svyatoslav Ryhel, Ramin Khonsari,
	Thierry Reding, Maxim Schwalm, Dmitry Osipenko, Simon Glass
  Cc: u-boot

On T30 unlike T20 dsi panels are wider used on devices
and PLLD is used as DISP1 parent more often, so lets
enable it as well for this cases.

Tested-by: Andreas Westman Dorcsak <hedmoo@yahoo.com> # ASUS TF700T T30
Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # HTC One X T30
Tested-by: Thierry Reding <treding@nvidia.com> # Beaver T30
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 arch/arm/mach-tegra/tegra30/clock.c | 41 +++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/arch/arm/mach-tegra/tegra30/clock.c b/arch/arm/mach-tegra/tegra30/clock.c
index dcdd0d0978..b66211ce94 100644
--- a/arch/arm/mach-tegra/tegra30/clock.c
+++ b/arch/arm/mach-tegra/tegra30/clock.c
@@ -669,7 +669,48 @@ enum clock_id clk_id_to_pll_id(int clk_id)
 
 void clock_early_init(void)
 {
+	struct clk_rst_ctlr *clkrst =
+		(struct clk_rst_ctlr *)NV_PA_CLK_RST_BASE;
+	struct clk_pll_info *pllinfo;
+	u32 data;
+
 	tegra30_set_up_pllp();
+
+	/*
+	 * PLLD output frequency set to 925Mhz
+	 */
+	switch (clock_get_osc_freq()) {
+	case CLOCK_OSC_FREQ_12_0: /* OSC is 12Mhz */
+	case CLOCK_OSC_FREQ_48_0: /* OSC is 48Mhz */
+		clock_set_rate(CLOCK_ID_DISPLAY, 925, 12, 0, 12);
+		break;
+
+	case CLOCK_OSC_FREQ_26_0: /* OSC is 26Mhz */
+		clock_set_rate(CLOCK_ID_DISPLAY, 925, 26, 0, 12);
+		break;
+
+	case CLOCK_OSC_FREQ_13_0: /* OSC is 13Mhz */
+	case CLOCK_OSC_FREQ_16_8: /* OSC is 16.8Mhz */
+		clock_set_rate(CLOCK_ID_DISPLAY, 925, 13, 0, 12);
+		break;
+
+	case CLOCK_OSC_FREQ_19_2:
+	case CLOCK_OSC_FREQ_38_4:
+	default:
+		/*
+		 * These are not supported. It is too early to print a
+		 * message and the UART likely won't work anyway due to the
+		 * oscillator being wrong.
+		 */
+		break;
+	}
+
+	/* PLLD_MISC: Set CLKENABLE, CPCON 12, LFCON 1, and enable lock */
+	pllinfo = &tegra_pll_info_table[CLOCK_ID_DISPLAY];
+	data = (12 << pllinfo->kcp_shift) | (1 << pllinfo->kvco_shift);
+	data |= (1 << PLLD_CLKENABLE) | (1 << pllinfo->lock_ena);
+	writel(data, &clkrst->crc_pll[CLOCK_ID_DISPLAY].pll_misc);
+	udelay(2);
 }
 
 void arch_timer_init(void)
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v4 06/16] ARM: tegra: Fix Tegra PWM parent clock
  2023-02-14 17:35 [PATCH v4 00/16] General Tegra improvements Svyatoslav Ryhel
                   ` (4 preceding siblings ...)
  2023-02-14 17:35 ` [PATCH v4 05/16] ARM: tegra30: add PLLD to pll setup Svyatoslav Ryhel
@ 2023-02-14 17:35 ` Svyatoslav Ryhel
  2023-02-14 17:35 ` [PATCH v4 07/16] spi: tegra20_slink: accept any word length Svyatoslav Ryhel
                   ` (10 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Svyatoslav Ryhel @ 2023-02-14 17:35 UTC (permalink / raw)
  To: Tom Warren, Marcel Ziswiler, Allen Martin, Jagan Teki,
	Lukasz Majewski, Marek Vasut, Svyatoslav Ryhel, Ramin Khonsari,
	Thierry Reding, Maxim Schwalm, Dmitry Osipenko, Simon Glass
  Cc: u-boot

Default parent clock for the PWM on Tegra is a 32kHz clock and
is unable to support the requested PWM period.

Fix PWM support on Tegra20, Tegra30, Tegra114, Tegra124 and Tegra210 by
updating the parent clock for the PWM to be the PLL_P.

This commit is equivalent to Linux kernel commit:
https://lore.kernel.org/all/20221010100046.6477-1-jonathanh@nvidia.com/

Tested-by: Andreas Westman Dorcsak <hedmoo@yahoo.com> # ASUS TF T30
Tested-by: Robert Eckelmann <longnoserob@gmail.com> # ASUS TF101 T20
Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # ASUS TF201 T30
Tested-by: Thierry Reding <treding@nvidia.com> # T30 and T124
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 arch/arm/dts/tegra114.dtsi           |  2 +-
 arch/arm/dts/tegra124.dtsi           |  2 +-
 arch/arm/mach-tegra/tegra114/clock.c |  2 +-
 arch/arm/mach-tegra/tegra124/clock.c |  2 +-
 arch/arm/mach-tegra/tegra20/clock.c  |  2 +-
 arch/arm/mach-tegra/tegra210/clock.c |  2 +-
 arch/arm/mach-tegra/tegra30/clock.c  |  2 +-
 drivers/pwm/tegra_pwm.c              | 10 ++++++----
 8 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/arch/arm/dts/tegra114.dtsi b/arch/arm/dts/tegra114.dtsi
index 8932ea3afd..68ee7f3165 100644
--- a/arch/arm/dts/tegra114.dtsi
+++ b/arch/arm/dts/tegra114.dtsi
@@ -312,7 +312,7 @@
 	};
 
 	pwm: pwm@7000a000 {
-		compatible = "nvidia,tegra114-pwm", "nvidia,tegra20-pwm";
+		compatible = "nvidia,tegra114-pwm";
 		reg = <0x7000a000 0x100>;
 		#pwm-cells = <2>;
 		clocks = <&tegra_car TEGRA114_CLK_PWM>;
diff --git a/arch/arm/dts/tegra124.dtsi b/arch/arm/dts/tegra124.dtsi
index f473ba28e4..ffec9cae09 100644
--- a/arch/arm/dts/tegra124.dtsi
+++ b/arch/arm/dts/tegra124.dtsi
@@ -377,7 +377,7 @@
 	};
 
 	pwm: pwm@7000a000 {
-		compatible = "nvidia,tegra124-pwm", "nvidia,tegra20-pwm";
+		compatible = "nvidia,tegra124-pwm", "nvidia,tegra114-pwm";
 		reg = <0x7000a000 0x100>;
 		#pwm-cells = <2>;
 		clocks = <&tegra_car TEGRA124_CLK_PWM>;
diff --git a/arch/arm/mach-tegra/tegra114/clock.c b/arch/arm/mach-tegra/tegra114/clock.c
index 15c2adc417..8ad71f590f 100644
--- a/arch/arm/mach-tegra/tegra114/clock.c
+++ b/arch/arm/mach-tegra/tegra114/clock.c
@@ -782,7 +782,7 @@ struct periph_clk_init periph_clk_init_table[] = {
 	{ PERIPH_ID_SDMMC2, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_SDMMC3, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_SDMMC4, CLOCK_ID_PERIPH },
-	{ PERIPH_ID_PWM, CLOCK_ID_SFROM32KHZ },
+	{ PERIPH_ID_PWM, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_I2C1, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_I2C2, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_I2C3, CLOCK_ID_PERIPH },
diff --git a/arch/arm/mach-tegra/tegra124/clock.c b/arch/arm/mach-tegra/tegra124/clock.c
index 415ba15e5d..ca9549a318 100644
--- a/arch/arm/mach-tegra/tegra124/clock.c
+++ b/arch/arm/mach-tegra/tegra124/clock.c
@@ -1208,7 +1208,7 @@ struct periph_clk_init periph_clk_init_table[] = {
 	{ PERIPH_ID_SDMMC2, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_SDMMC3, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_SDMMC4, CLOCK_ID_PERIPH },
-	{ PERIPH_ID_PWM, CLOCK_ID_SFROM32KHZ },
+	{ PERIPH_ID_PWM, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_I2C1, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_I2C2, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_I2C3, CLOCK_ID_PERIPH },
diff --git a/arch/arm/mach-tegra/tegra20/clock.c b/arch/arm/mach-tegra/tegra20/clock.c
index 593622bfdc..067a9f1a2f 100644
--- a/arch/arm/mach-tegra/tegra20/clock.c
+++ b/arch/arm/mach-tegra/tegra20/clock.c
@@ -804,7 +804,7 @@ struct periph_clk_init periph_clk_init_table[] = {
 	{ PERIPH_ID_SDMMC2, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_SDMMC3, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_SDMMC4, CLOCK_ID_PERIPH },
-	{ PERIPH_ID_PWM, CLOCK_ID_SFROM32KHZ },
+	{ PERIPH_ID_PWM, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_DVC_I2C, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_I2C1, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_I2C2, CLOCK_ID_PERIPH },
diff --git a/arch/arm/mach-tegra/tegra210/clock.c b/arch/arm/mach-tegra/tegra210/clock.c
index 76fbfef580..900537afbe 100644
--- a/arch/arm/mach-tegra/tegra210/clock.c
+++ b/arch/arm/mach-tegra/tegra210/clock.c
@@ -1278,7 +1278,7 @@ struct periph_clk_init periph_clk_init_table[] = {
 	{ PERIPH_ID_SDMMC2, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_SDMMC3, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_SDMMC4, CLOCK_ID_PERIPH },
-	{ PERIPH_ID_PWM, CLOCK_ID_SFROM32KHZ },
+	{ PERIPH_ID_PWM, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_I2C1, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_I2C2, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_I2C3, CLOCK_ID_PERIPH },
diff --git a/arch/arm/mach-tegra/tegra30/clock.c b/arch/arm/mach-tegra/tegra30/clock.c
index b66211ce94..1dc9d09dba 100644
--- a/arch/arm/mach-tegra/tegra30/clock.c
+++ b/arch/arm/mach-tegra/tegra30/clock.c
@@ -884,7 +884,7 @@ struct periph_clk_init periph_clk_init_table[] = {
 	{ PERIPH_ID_SDMMC2, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_SDMMC3, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_SDMMC4, CLOCK_ID_PERIPH },
-	{ PERIPH_ID_PWM, CLOCK_ID_SFROM32KHZ },
+	{ PERIPH_ID_PWM, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_DVC_I2C, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_I2C1, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_I2C2, CLOCK_ID_PERIPH },
diff --git a/drivers/pwm/tegra_pwm.c b/drivers/pwm/tegra_pwm.c
index 36c35c608b..95fc26458b 100644
--- a/drivers/pwm/tegra_pwm.c
+++ b/drivers/pwm/tegra_pwm.c
@@ -20,19 +20,21 @@ static int tegra_pwm_set_config(struct udevice *dev, uint channel,
 {
 	struct tegra_pwm_priv *priv = dev_get_priv(dev);
 	struct pwm_ctlr *regs = priv->regs;
+	const u32 pwm_max_freq = dev_get_driver_data(dev);
 	uint pulse_width;
 	u32 reg;
 
 	if (channel >= 4)
 		return -EINVAL;
 	debug("%s: Configure '%s' channel %u\n", __func__, dev->name, channel);
-	/* We ignore the period here and just use 32KHz */
-	clock_start_periph_pll(PERIPH_ID_PWM, CLOCK_ID_SFROM32KHZ, 32768);
+
+	clock_start_periph_pll(PERIPH_ID_PWM, CLOCK_ID_PERIPH, pwm_max_freq);
 
 	pulse_width = duty_ns * 255 / period_ns;
 
 	reg = pulse_width << PWM_WIDTH_SHIFT;
 	reg |= 1 << PWM_DIVIDER_SHIFT;
+	reg |= PWM_ENABLE_MASK;
 	writel(reg, &regs[channel].control);
 	debug("%s: pulse_width=%u\n", __func__, pulse_width);
 
@@ -68,8 +70,8 @@ static const struct pwm_ops tegra_pwm_ops = {
 };
 
 static const struct udevice_id tegra_pwm_ids[] = {
-	{ .compatible = "nvidia,tegra124-pwm" },
-	{ .compatible = "nvidia,tegra20-pwm" },
+	{ .compatible = "nvidia,tegra20-pwm", .data = 48 * 1000000 },
+	{ .compatible = "nvidia,tegra114-pwm", .data = 408 * 1000000 },
 	{ }
 };
 
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v4 07/16] spi: tegra20_slink: accept any word length
  2023-02-14 17:35 [PATCH v4 00/16] General Tegra improvements Svyatoslav Ryhel
                   ` (5 preceding siblings ...)
  2023-02-14 17:35 ` [PATCH v4 06/16] ARM: tegra: Fix Tegra PWM parent clock Svyatoslav Ryhel
@ 2023-02-14 17:35 ` Svyatoslav Ryhel
  2023-02-14 17:35 ` [PATCH v4 08/16] ARM: tegra: provide default USB gadget setup Svyatoslav Ryhel
                   ` (9 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Svyatoslav Ryhel @ 2023-02-14 17:35 UTC (permalink / raw)
  To: Tom Warren, Marcel Ziswiler, Allen Martin, Jagan Teki,
	Lukasz Majewski, Marek Vasut, Svyatoslav Ryhel, Ramin Khonsari,
	Thierry Reding, Maxim Schwalm, Dmitry Osipenko, Simon Glass
  Cc: u-boot

Original t20 slink could work with commands only
fully divisible by 8. This patch removes such
restriction, so commands of any bitlength now
can be passed and processed.

Tested-by: Andreas Westman Dorcsak <hedmoo@yahoo.com> # ASUS TF600T T30
Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # LG P895 T30
Tested-by: Thierry Reding <treding@nvidia.com> # T30 and T124
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 drivers/spi/tegra20_slink.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/spi/tegra20_slink.c b/drivers/spi/tegra20_slink.c
index 209ba8b0cc..d0e788539e 100644
--- a/drivers/spi/tegra20_slink.c
+++ b/drivers/spi/tegra20_slink.c
@@ -208,16 +208,14 @@ static int tegra30_spi_xfer(struct udevice *dev, unsigned int bitlen,
 	u32 reg, tmpdout, tmpdin = 0;
 	const u8 *dout = data_out;
 	u8 *din = data_in;
-	int num_bytes;
-	int ret;
+	int num_bytes, overflow;
+	int ret = 0;
 
 	debug("%s: slave %u:%u dout %p din %p bitlen %u\n",
 	      __func__, dev_seq(bus), spi_chip_select(dev), dout, din, bitlen);
-	if (bitlen % 8)
-		return -1;
-	num_bytes = bitlen / 8;
 
-	ret = 0;
+	num_bytes = DIV_ROUND_UP(bitlen, 8);
+	overflow = bitlen % 8;
 
 	reg = readl(&regs->status);
 	writel(reg, &regs->status);	/* Clear all SPI events via R/W */
@@ -254,8 +252,13 @@ static int tegra30_spi_xfer(struct udevice *dev, unsigned int bitlen,
 
 		num_bytes -= bytes;
 
-		clrsetbits_le32(&regs->command, SLINK_CMD_BIT_LENGTH_MASK,
-				bytes * 8 - 1);
+		if (overflow && !num_bytes)
+			clrsetbits_le32(&regs->command, SLINK_CMD_BIT_LENGTH_MASK,
+					(bytes - 1) * 8 + overflow - 1);
+		else
+			clrsetbits_le32(&regs->command, SLINK_CMD_BIT_LENGTH_MASK,
+					bytes * 8 - 1);
+
 		writel(tmpdout, &regs->tx_fifo);
 		setbits_le32(&regs->command, SLINK_CMD_GO);
 
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v4 08/16] ARM: tegra: provide default USB gadget setup
  2023-02-14 17:35 [PATCH v4 00/16] General Tegra improvements Svyatoslav Ryhel
                   ` (6 preceding siblings ...)
  2023-02-14 17:35 ` [PATCH v4 07/16] spi: tegra20_slink: accept any word length Svyatoslav Ryhel
@ 2023-02-14 17:35 ` Svyatoslav Ryhel
  2023-02-14 17:35 ` [PATCH v4 09/16] ARM: tegra: add late init support Svyatoslav Ryhel
                   ` (8 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Svyatoslav Ryhel @ 2023-02-14 17:35 UTC (permalink / raw)
  To: Tom Warren, Marcel Ziswiler, Allen Martin, Jagan Teki,
	Lukasz Majewski, Marek Vasut, Svyatoslav Ryhel, Ramin Khonsari,
	Thierry Reding, Maxim Schwalm, Dmitry Osipenko, Simon Glass
  Cc: u-boot

From: Maxim Schwalm <maxim.schwalm@gmail.com>

All Nvidia boards use the same manufacturer, vendor ID and product ID
for the gadgets. Make them the defaults to remove some boilerplate from
the defconfigs.

Inspired by commit e02687bda96c ("sunxi: provide default USB gadget
setup") which did the same for Allwinner boards.

Tested-by: Thierry Reding <treding@nvidia.com> # T30 and T124
Signed-off-by: Maxim Schwalm <maxim.schwalm@gmail.com>
---
 configs/beaver_defconfig      | 3 ---
 configs/cei-tk1-som_defconfig | 3 ---
 configs/dalmore_defconfig     | 3 ---
 configs/jetson-tk1_defconfig  | 3 ---
 configs/nyan-big_defconfig    | 3 ---
 configs/p2371-0000_defconfig  | 3 ---
 configs/p2371-2180_defconfig  | 3 ---
 configs/p2571_defconfig       | 3 ---
 configs/p3450-0000_defconfig  | 3 ---
 configs/venice2_defconfig     | 3 ---
 drivers/usb/gadget/Kconfig    | 3 +++
 11 files changed, 3 insertions(+), 30 deletions(-)

diff --git a/configs/beaver_defconfig b/configs/beaver_defconfig
index 0967367e6a..693ccb893d 100644
--- a/configs/beaver_defconfig
+++ b/configs/beaver_defconfig
@@ -64,8 +64,5 @@ CONFIG_USB_EHCI_TEGRA=y
 CONFIG_USB_HOST_ETHER=y
 CONFIG_USB_ETHER_ASIX=y
 CONFIG_USB_GADGET=y
-CONFIG_USB_GADGET_MANUFACTURER="NVIDIA"
-CONFIG_USB_GADGET_VENDOR_NUM=0x0955
-CONFIG_USB_GADGET_PRODUCT_NUM=0x701a
 CONFIG_CI_UDC=y
 CONFIG_USB_GADGET_DOWNLOAD=y
diff --git a/configs/cei-tk1-som_defconfig b/configs/cei-tk1-som_defconfig
index 0c4627aff0..6578ee83d9 100644
--- a/configs/cei-tk1-som_defconfig
+++ b/configs/cei-tk1-som_defconfig
@@ -70,8 +70,5 @@ CONFIG_USB_EHCI_TEGRA=y
 CONFIG_USB_HOST_ETHER=y
 CONFIG_USB_ETHER_ASIX=y
 CONFIG_USB_GADGET=y
-CONFIG_USB_GADGET_MANUFACTURER="NVIDIA"
-CONFIG_USB_GADGET_VENDOR_NUM=0x0955
-CONFIG_USB_GADGET_PRODUCT_NUM=0x701a
 CONFIG_CI_UDC=y
 CONFIG_USB_GADGET_DOWNLOAD=y
diff --git a/configs/dalmore_defconfig b/configs/dalmore_defconfig
index 5d29dae341..4507ddc84b 100644
--- a/configs/dalmore_defconfig
+++ b/configs/dalmore_defconfig
@@ -60,8 +60,5 @@ CONFIG_USB_EHCI_TEGRA=y
 CONFIG_USB_HOST_ETHER=y
 CONFIG_USB_ETHER_ASIX=y
 CONFIG_USB_GADGET=y
-CONFIG_USB_GADGET_MANUFACTURER="NVIDIA"
-CONFIG_USB_GADGET_VENDOR_NUM=0x0955
-CONFIG_USB_GADGET_PRODUCT_NUM=0x701a
 CONFIG_CI_UDC=y
 CONFIG_USB_GADGET_DOWNLOAD=y
diff --git a/configs/jetson-tk1_defconfig b/configs/jetson-tk1_defconfig
index d935e784ab..bcf45458a6 100644
--- a/configs/jetson-tk1_defconfig
+++ b/configs/jetson-tk1_defconfig
@@ -70,8 +70,5 @@ CONFIG_USB_EHCI_TEGRA=y
 CONFIG_USB_HOST_ETHER=y
 CONFIG_USB_ETHER_ASIX=y
 CONFIG_USB_GADGET=y
-CONFIG_USB_GADGET_MANUFACTURER="NVIDIA"
-CONFIG_USB_GADGET_VENDOR_NUM=0x0955
-CONFIG_USB_GADGET_PRODUCT_NUM=0x701a
 CONFIG_CI_UDC=y
 CONFIG_USB_GADGET_DOWNLOAD=y
diff --git a/configs/nyan-big_defconfig b/configs/nyan-big_defconfig
index e2e8bebf6d..fef9141d35 100644
--- a/configs/nyan-big_defconfig
+++ b/configs/nyan-big_defconfig
@@ -93,9 +93,6 @@ CONFIG_USB_EHCI_TEGRA=y
 CONFIG_USB_HOST_ETHER=y
 CONFIG_USB_ETHER_ASIX=y
 CONFIG_USB_GADGET=y
-CONFIG_USB_GADGET_MANUFACTURER="NVIDIA"
-CONFIG_USB_GADGET_VENDOR_NUM=0x0955
-CONFIG_USB_GADGET_PRODUCT_NUM=0x701a
 CONFIG_CI_UDC=y
 CONFIG_USB_GADGET_DOWNLOAD=y
 CONFIG_VIDEO=y
diff --git a/configs/p2371-0000_defconfig b/configs/p2371-0000_defconfig
index e8074914c8..2962a7db75 100644
--- a/configs/p2371-0000_defconfig
+++ b/configs/p2371-0000_defconfig
@@ -48,8 +48,5 @@ CONFIG_USB_EHCI_TEGRA=y
 CONFIG_USB_HOST_ETHER=y
 CONFIG_USB_ETHER_ASIX=y
 CONFIG_USB_GADGET=y
-CONFIG_USB_GADGET_MANUFACTURER="NVIDIA"
-CONFIG_USB_GADGET_VENDOR_NUM=0x0955
-CONFIG_USB_GADGET_PRODUCT_NUM=0x701a
 CONFIG_CI_UDC=y
 CONFIG_USB_GADGET_DOWNLOAD=y
diff --git a/configs/p2371-2180_defconfig b/configs/p2371-2180_defconfig
index ea62e18f73..6b44361b5b 100644
--- a/configs/p2371-2180_defconfig
+++ b/configs/p2371-2180_defconfig
@@ -57,8 +57,5 @@ CONFIG_USB_EHCI_TEGRA=y
 CONFIG_USB_HOST_ETHER=y
 CONFIG_USB_ETHER_ASIX=y
 CONFIG_USB_GADGET=y
-CONFIG_USB_GADGET_MANUFACTURER="NVIDIA"
-CONFIG_USB_GADGET_VENDOR_NUM=0x0955
-CONFIG_USB_GADGET_PRODUCT_NUM=0x701a
 CONFIG_CI_UDC=y
 CONFIG_USB_GADGET_DOWNLOAD=y
diff --git a/configs/p2571_defconfig b/configs/p2571_defconfig
index bc3fb3e5ae..00b0dc6109 100644
--- a/configs/p2571_defconfig
+++ b/configs/p2571_defconfig
@@ -49,8 +49,5 @@ CONFIG_USB_EHCI_TEGRA=y
 CONFIG_USB_HOST_ETHER=y
 CONFIG_USB_ETHER_ASIX=y
 CONFIG_USB_GADGET=y
-CONFIG_USB_GADGET_MANUFACTURER="NVIDIA"
-CONFIG_USB_GADGET_VENDOR_NUM=0x0955
-CONFIG_USB_GADGET_PRODUCT_NUM=0x701a
 CONFIG_CI_UDC=y
 CONFIG_USB_GADGET_DOWNLOAD=y
diff --git a/configs/p3450-0000_defconfig b/configs/p3450-0000_defconfig
index 8e16afde91..d35bea4220 100644
--- a/configs/p3450-0000_defconfig
+++ b/configs/p3450-0000_defconfig
@@ -61,8 +61,5 @@ CONFIG_USB_EHCI_TEGRA=y
 CONFIG_USB_HOST_ETHER=y
 CONFIG_USB_ETHER_ASIX=y
 CONFIG_USB_GADGET=y
-CONFIG_USB_GADGET_MANUFACTURER="NVIDIA"
-CONFIG_USB_GADGET_VENDOR_NUM=0x0955
-CONFIG_USB_GADGET_PRODUCT_NUM=0x701a
 CONFIG_CI_UDC=y
 CONFIG_USB_GADGET_DOWNLOAD=y
diff --git a/configs/venice2_defconfig b/configs/venice2_defconfig
index a754c20046..fe794b76ff 100644
--- a/configs/venice2_defconfig
+++ b/configs/venice2_defconfig
@@ -59,8 +59,5 @@ CONFIG_USB_EHCI_TEGRA=y
 CONFIG_USB_HOST_ETHER=y
 CONFIG_USB_ETHER_ASIX=y
 CONFIG_USB_GADGET=y
-CONFIG_USB_GADGET_MANUFACTURER="NVIDIA"
-CONFIG_USB_GADGET_VENDOR_NUM=0x0955
-CONFIG_USB_GADGET_PRODUCT_NUM=0x701a
 CONFIG_CI_UDC=y
 CONFIG_USB_GADGET_DOWNLOAD=y
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index e120efeb00..941f97c96d 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -40,6 +40,7 @@ if USB_GADGET
 
 config USB_GADGET_MANUFACTURER
 	string "Vendor name of the USB device"
+	default "NVIDIA" if ARCH_TEGRA
 	default "Allwinner Technology" if ARCH_SUNXI
 	default "Rockchip" if ARCH_ROCKCHIP
 	default "U-Boot"
@@ -49,6 +50,7 @@ config USB_GADGET_MANUFACTURER
 
 config USB_GADGET_VENDOR_NUM
 	hex "Vendor ID of the USB device"
+	default 0x0955 if ARCH_TEGRA
 	default 0x1f3a if ARCH_SUNXI
 	default 0x2207 if ARCH_ROCKCHIP
 	default 0x0
@@ -59,6 +61,7 @@ config USB_GADGET_VENDOR_NUM
 
 config USB_GADGET_PRODUCT_NUM
 	hex "Product ID of the USB device"
+	default 0x701a if ARCH_TEGRA
 	default 0x1010 if ARCH_SUNXI
 	default 0x310a if ROCKCHIP_RK3036
 	default 0x300a if ROCKCHIP_RK3066
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v4 09/16] ARM: tegra: add late init support
  2023-02-14 17:35 [PATCH v4 00/16] General Tegra improvements Svyatoslav Ryhel
                   ` (7 preceding siblings ...)
  2023-02-14 17:35 ` [PATCH v4 08/16] ARM: tegra: provide default USB gadget setup Svyatoslav Ryhel
@ 2023-02-14 17:35 ` Svyatoslav Ryhel
  2023-02-14 17:35 ` [PATCH v4 10/16] ARM: tegra: create common pre-dm i2c write Svyatoslav Ryhel
                   ` (7 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Svyatoslav Ryhel @ 2023-02-14 17:35 UTC (permalink / raw)
  To: Tom Warren, Marcel Ziswiler, Allen Martin, Jagan Teki,
	Lukasz Majewski, Marek Vasut, Svyatoslav Ryhel, Ramin Khonsari,
	Thierry Reding, Maxim Schwalm, Dmitry Osipenko, Simon Glass
  Cc: u-boot

Late init function allows passing values like identifiers and
perform device specific configurations of pre-boot stage.

Tested-by: Andreas Westman Dorcsak <hedmoo@yahoo.com> # ASUS TF T30
Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # LG P895 T30
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 arch/arm/include/asm/arch-tegra/sys_proto.h | 6 ++++++
 arch/arm/mach-tegra/board2.c                | 2 ++
 2 files changed, 8 insertions(+)

diff --git a/arch/arm/include/asm/arch-tegra/sys_proto.h b/arch/arm/include/asm/arch-tegra/sys_proto.h
index c3a2673e6c..566666a9a0 100644
--- a/arch/arm/include/asm/arch-tegra/sys_proto.h
+++ b/arch/arm/include/asm/arch-tegra/sys_proto.h
@@ -31,4 +31,10 @@ int tegra_lcd_pmic_init(int board_id);
  */
 int nvidia_board_init(void);
 
+/**
+ * nvidia_board_late_init() - perform any board-specific
+ *			      init on late stages
+ */
+void nvidia_board_late_init(void);
+
 #endif
diff --git a/arch/arm/mach-tegra/board2.c b/arch/arm/mach-tegra/board2.c
index c7a45f4ff8..0df18360ca 100644
--- a/arch/arm/mach-tegra/board2.c
+++ b/arch/arm/mach-tegra/board2.c
@@ -56,6 +56,7 @@ __weak void gpio_early_init_uart(void) {}
 __weak void pin_mux_display(void) {}
 __weak void start_cpu_fan(void) {}
 __weak void cboot_late_init(void) {}
+__weak void nvidia_board_late_init(void) {}
 
 #if defined(CONFIG_TEGRA_NAND)
 __weak void pin_mux_nand(void)
@@ -267,6 +268,7 @@ int board_late_init(void)
 #endif
 	start_cpu_fan();
 	cboot_late_init();
+	nvidia_board_late_init();
 
 	return 0;
 }
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v4 10/16] ARM: tegra: create common pre-dm i2c write
  2023-02-14 17:35 [PATCH v4 00/16] General Tegra improvements Svyatoslav Ryhel
                   ` (8 preceding siblings ...)
  2023-02-14 17:35 ` [PATCH v4 09/16] ARM: tegra: add late init support Svyatoslav Ryhel
@ 2023-02-14 17:35 ` Svyatoslav Ryhel
  2023-02-14 17:35 ` [PATCH v4 11/16] board: tegra124: switch to updated " Svyatoslav Ryhel
                   ` (6 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Svyatoslav Ryhel @ 2023-02-14 17:35 UTC (permalink / raw)
  To: Tom Warren, Marcel Ziswiler, Allen Martin, Jagan Teki,
	Lukasz Majewski, Marek Vasut, Svyatoslav Ryhel, Ramin Khonsari,
	Thierry Reding, Maxim Schwalm, Dmitry Osipenko, Simon Glass
  Cc: u-boot

This implementation allows pwr i2c writing on early SPL
stages when DM is not yet setup.

Such writing is needed to configure main voltages of PMIC
on early SPL for bootloader to boot properly.

Tested-by: Andreas Westman Dorcsak <hedmoo@yahoo.com> # ASUS TF T30
Tested-by: Robert Eckelmann <longnoserob@gmail.com> # ASUS TF101 T20
Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # LG P895 T30
Tested-by: Thierry Reding <treding@nvidia.com> # T30 and T124
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 arch/arm/include/asm/arch-tegra/tegra_i2c.h | 17 ++++++++++
 arch/arm/mach-tegra/cpu.h                   |  1 -
 arch/arm/mach-tegra/tegra124/cpu.c          |  4 +++
 arch/arm/mach-tegra/tegra30/cpu.c           | 37 +++++++--------------
 4 files changed, 33 insertions(+), 26 deletions(-)

diff --git a/arch/arm/include/asm/arch-tegra/tegra_i2c.h b/arch/arm/include/asm/arch-tegra/tegra_i2c.h
index c49f43251d..afec6bbdda 100644
--- a/arch/arm/include/asm/arch-tegra/tegra_i2c.h
+++ b/arch/arm/include/asm/arch-tegra/tegra_i2c.h
@@ -8,6 +8,7 @@
 #ifndef _TEGRA_I2C_H_
 #define _TEGRA_I2C_H_
 
+#include <asm/io.h>
 #include <asm/types.h>
 
 struct udevice;
@@ -154,4 +155,20 @@ struct i2c_ctlr {
  */
 int tegra_i2c_get_dvc_bus(struct udevice **busp);
 
+/* Pre-dm section used for initial setup of PMIC */
+#define I2C_SEND_2_BYTES		0x0A02
+
+static inline void tegra_i2c_ll_write(uint addr, uint data)
+{
+	struct i2c_ctlr *reg = (struct i2c_ctlr *)TEGRA_DVC_BASE;
+
+	writel(addr, &reg->cmd_addr0);
+	writel(0x2, &reg->cnfg);
+
+	writel(data, &reg->cmd_data1);
+	writel(I2C_SEND_2_BYTES, &reg->cnfg);
+}
+
+void pmic_enable_cpu_vdd(void);
+
 #endif	/* _TEGRA_I2C_H_ */
diff --git a/arch/arm/mach-tegra/cpu.h b/arch/arm/mach-tegra/cpu.h
index d541825441..006aae3d07 100644
--- a/arch/arm/mach-tegra/cpu.h
+++ b/arch/arm/mach-tegra/cpu.h
@@ -74,4 +74,3 @@ int tegra_get_chip(void);
 int tegra_get_sku_info(void);
 int tegra_get_chip_sku(void);
 void adjust_pllp_out_freqs(void);
-void pmic_enable_cpu_vdd(void);
diff --git a/arch/arm/mach-tegra/tegra124/cpu.c b/arch/arm/mach-tegra/tegra124/cpu.c
index d5f2683b26..b1bfe8fb5e 100644
--- a/arch/arm/mach-tegra/tegra124/cpu.c
+++ b/arch/arm/mach-tegra/tegra124/cpu.c
@@ -14,10 +14,14 @@
 #include <asm/arch/tegra.h>
 #include <asm/arch-tegra/clk_rst.h>
 #include <asm/arch-tegra/pmc.h>
+#include <asm/arch-tegra/tegra_i2c.h>
 #include <asm/arch-tegra/ap.h>
 #include <linux/delay.h>
 #include "../cpu.h"
 
+/* In case this function is not defined */
+__weak void pmic_enable_cpu_vdd(void) {}
+
 /* Tegra124-specific CPU init code */
 
 static void enable_cpu_power_rail(void)
diff --git a/arch/arm/mach-tegra/tegra30/cpu.c b/arch/arm/mach-tegra/tegra30/cpu.c
index 651edd27ee..6ac45af51a 100644
--- a/arch/arm/mach-tegra/tegra30/cpu.c
+++ b/arch/arm/mach-tegra/tegra30/cpu.c
@@ -15,23 +15,6 @@
 #include <linux/delay.h>
 #include "../cpu.h"
 
-/* Tegra30-specific CPU init code */
-void tegra_i2c_ll_write_addr(uint addr, uint config)
-{
-	struct i2c_ctlr *reg = (struct i2c_ctlr *)TEGRA_DVC_BASE;
-
-	writel(addr, &reg->cmd_addr0);
-	writel(config, &reg->cnfg);
-}
-
-void tegra_i2c_ll_write_data(uint data, uint config)
-{
-	struct i2c_ctlr *reg = (struct i2c_ctlr *)TEGRA_DVC_BASE;
-
-	writel(data, &reg->cmd_data1);
-	writel(config, &reg->cnfg);
-}
-
 #define TPS62366A_I2C_ADDR		0xC0
 #define TPS62366A_SET1_REG		0x01
 #define TPS62366A_SET1_DATA		(0x4600 | TPS62366A_SET1_REG)
@@ -45,7 +28,9 @@ void tegra_i2c_ll_write_data(uint data, uint config)
 #define TPS65911_VDDCTRL_SR_REG		0x27
 #define TPS65911_VDDCTRL_OP_DATA	(0x2400 | TPS65911_VDDCTRL_OP_REG)
 #define TPS65911_VDDCTRL_SR_DATA	(0x0100 | TPS65911_VDDCTRL_SR_REG)
-#define I2C_SEND_2_BYTES		0x0A02
+
+/* In case this function is not defined */
+__weak void pmic_enable_cpu_vdd(void) {}
 
 static void enable_cpu_power_rail(void)
 {
@@ -59,12 +44,12 @@ static void enable_cpu_power_rail(void)
 
 	/* Set VDD_CORE to 1.200V. */
 #ifdef CONFIG_TEGRA_VDD_CORE_TPS62366A_SET1
-	tegra_i2c_ll_write_addr(TPS62366A_I2C_ADDR, 2);
-	tegra_i2c_ll_write_data(TPS62366A_SET1_DATA, I2C_SEND_2_BYTES);
+	tegra_i2c_ll_write(TPS62366A_I2C_ADDR,
+			   TPS62366A_SET1_DATA);
 #endif
 #ifdef CONFIG_TEGRA_VDD_CORE_TPS62361B_SET3
-	tegra_i2c_ll_write_addr(TPS62361B_I2C_ADDR, 2);
-	tegra_i2c_ll_write_data(TPS62361B_SET3_DATA, I2C_SEND_2_BYTES);
+	tegra_i2c_ll_write(TPS62361B_I2C_ADDR,
+			   TPS62361B_SET3_DATA);
 #endif
 	udelay(1000);
 
@@ -72,10 +57,11 @@ static void enable_cpu_power_rail(void)
 	 * Bring up CPU VDD via the TPS65911x PMIC on the DVC I2C bus.
 	 * First set VDD to 1.0125V, then enable the VDD regulator.
 	 */
-	tegra_i2c_ll_write_addr(TPS65911_I2C_ADDR, 2);
-	tegra_i2c_ll_write_data(TPS65911_VDDCTRL_OP_DATA, I2C_SEND_2_BYTES);
+	tegra_i2c_ll_write(TPS65911_I2C_ADDR,
+			   TPS65911_VDDCTRL_OP_DATA);
 	udelay(1000);
-	tegra_i2c_ll_write_data(TPS65911_VDDCTRL_SR_DATA, I2C_SEND_2_BYTES);
+	tegra_i2c_ll_write(TPS65911_I2C_ADDR,
+			   TPS65911_VDDCTRL_SR_DATA);
 	udelay(10 * 1000);
 }
 
@@ -142,6 +128,7 @@ void start_cpu(u32 reset_vector)
 
 	/* Enable VDD_CPU */
 	enable_cpu_power_rail();
+	pmic_enable_cpu_vdd();
 
 	set_cpu_running(0);
 
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v4 11/16] board: tegra124: switch to updated pre-dm i2c write
  2023-02-14 17:35 [PATCH v4 00/16] General Tegra improvements Svyatoslav Ryhel
                   ` (9 preceding siblings ...)
  2023-02-14 17:35 ` [PATCH v4 10/16] ARM: tegra: create common pre-dm i2c write Svyatoslav Ryhel
@ 2023-02-14 17:35 ` Svyatoslav Ryhel
  2023-02-14 17:35 ` [PATCH v4 12/16] board: tegra30: " Svyatoslav Ryhel
                   ` (5 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Svyatoslav Ryhel @ 2023-02-14 17:35 UTC (permalink / raw)
  To: Tom Warren, Marcel Ziswiler, Allen Martin, Jagan Teki,
	Lukasz Majewski, Marek Vasut, Svyatoslav Ryhel, Ramin Khonsari,
	Thierry Reding, Maxim Schwalm, Dmitry Osipenko, Simon Glass
  Cc: u-boot

Configure PMIC for early stages using updated i2c write.

Tested-by: Thierry Reding <treding@nvidia.com> # Jetson TK1 T124
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
 board/nvidia/venice2/as3722_init.c     | 65 ++++++++++++--------
 board/nvidia/venice2/as3722_init.h     | 43 -------------
 board/toradex/apalis-tk1/as3722_init.c | 85 ++++++++++++++------------
 board/toradex/apalis-tk1/as3722_init.h | 40 ------------
 4 files changed, 88 insertions(+), 145 deletions(-)
 delete mode 100644 board/nvidia/venice2/as3722_init.h
 delete mode 100644 board/toradex/apalis-tk1/as3722_init.h

diff --git a/board/nvidia/venice2/as3722_init.c b/board/nvidia/venice2/as3722_init.c
index ba676547d3..395bdd99c7 100644
--- a/board/nvidia/venice2/as3722_init.c
+++ b/board/nvidia/venice2/as3722_init.c
@@ -9,25 +9,42 @@
 #include <asm/io.h>
 #include <asm/arch-tegra/tegra_i2c.h>
 #include <linux/delay.h>
-#include "as3722_init.h"
 
-/* AS3722-PMIC-specific early init code - get CPU rails up, etc */
+/* AS3722-PMIC-specific early init regs */
 
-void tegra_i2c_ll_write_addr(uint addr, uint config)
-{
-	struct i2c_ctlr *reg = (struct i2c_ctlr *)TEGRA_DVC_BASE;
+#define AS3722_I2C_ADDR		0x80
 
-	writel(addr, &reg->cmd_addr0);
-	writel(config, &reg->cnfg);
-}
+#define AS3722_SD0VOLTAGE_REG	0x00	/* CPU */
+#define AS3722_SD1VOLTAGE_REG	0x01	/* CORE, already set by OTP */
+#define AS3722_SD6VOLTAGE_REG	0x06	/* GPU */
+#define AS3722_SDCONTROL_REG	0x4D
 
-void tegra_i2c_ll_write_data(uint data, uint config)
-{
-	struct i2c_ctlr *reg = (struct i2c_ctlr *)TEGRA_DVC_BASE;
+#define AS3722_LDO2VOLTAGE_REG	0x12	/* VPP_FUSE */
+#define AS3722_LDO6VOLTAGE_REG	0x16	/* VDD_SDMMC */
+#define AS3722_LDCONTROL_REG	0x4E
 
-	writel(data, &reg->cmd_data1);
-	writel(config, &reg->cnfg);
-}
+#if defined(CONFIG_TARGET_VENICE2)
+#define AS3722_SD0VOLTAGE_DATA	(0x2800 | AS3722_SD0VOLTAGE_REG)
+#else /* TK1 or Nyan-Big */
+#define AS3722_SD0VOLTAGE_DATA	(0x3C00 | AS3722_SD0VOLTAGE_REG)
+#endif
+#define AS3722_SD0CONTROL_DATA	(0x0100 | AS3722_SDCONTROL_REG)
+
+#if defined(CONFIG_TARGET_JETSON_TK1) || defined(CONFIG_TARGET_CEI_TK1_SOM)
+#define AS3722_SD1VOLTAGE_DATA	(0x2800 | AS3722_SD1VOLTAGE_REG)
+#define AS3722_SD1CONTROL_DATA	(0x0200 | AS3722_SDCONTROL_REG)
+#endif
+
+#define AS3722_SD6CONTROL_DATA	(0x4000 | AS3722_SDCONTROL_REG)
+#define AS3722_SD6VOLTAGE_DATA	(0x2800 | AS3722_SD6VOLTAGE_REG)
+
+#define AS3722_LDO2CONTROL_DATA	(0x0400 | AS3722_LDCONTROL_REG)
+#define AS3722_LDO2VOLTAGE_DATA	(0x1000 | AS3722_LDO2VOLTAGE_REG)
+
+#define AS3722_LDO6CONTROL_DATA	(0x4000 | AS3722_LDCONTROL_REG)
+#define AS3722_LDO6VOLTAGE_DATA	(0x3F00 | AS3722_LDO6VOLTAGE_REG)
+
+/* AS3722-PMIC-specific early init code - get CPU rails up, etc */
 
 void pmic_enable_cpu_vdd(void)
 {
@@ -37,8 +54,8 @@ void pmic_enable_cpu_vdd(void)
 	/* Set up VDD_CORE, for boards where OTP is incorrect*/
 	debug("%s: Setting VDD_CORE via AS3722 reg 1\n", __func__);
 	/* Configure VDD_CORE via the AS3722 PMIC on the PWR I2C bus */
-	tegra_i2c_ll_write_addr(AS3722_I2C_ADDR, 2);
-	tegra_i2c_ll_write_data(AS3722_SD1VOLTAGE_DATA, I2C_SEND_2_BYTES);
+	tegra_i2c_ll_write(AS3722_I2C_ADDR,
+			   AS3722_SD1VOLTAGE_DATA);
 	/*
 	 * Don't write SDCONTROL - it's already 0x7F, i.e. all SDs enabled.
 	 * tegra_i2c_ll_write_data(AS3722_SD1CONTROL_DATA, I2C_SEND_2_BYTES);
@@ -51,8 +68,8 @@ void pmic_enable_cpu_vdd(void)
 	 * Bring up VDD_CPU via the AS3722 PMIC on the PWR I2C bus.
 	 * First set VDD to 1.0V, then enable the VDD regulator.
 	 */
-	tegra_i2c_ll_write_addr(AS3722_I2C_ADDR, 2);
-	tegra_i2c_ll_write_data(AS3722_SD0VOLTAGE_DATA, I2C_SEND_2_BYTES);
+	tegra_i2c_ll_write(AS3722_I2C_ADDR,
+			   AS3722_SD0VOLTAGE_DATA);
 	/*
 	 * Don't write SDCONTROL - it's already 0x7F, i.e. all SDs enabled.
 	 * tegra_i2c_ll_write_data(AS3722_SD0CONTROL_DATA, I2C_SEND_2_BYTES);
@@ -64,8 +81,8 @@ void pmic_enable_cpu_vdd(void)
 	 * Bring up VDD_GPU via the AS3722 PMIC on the PWR I2C bus.
 	 * First set VDD to 1.0V, then enable the VDD regulator.
 	 */
-	tegra_i2c_ll_write_addr(AS3722_I2C_ADDR, 2);
-	tegra_i2c_ll_write_data(AS3722_SD6VOLTAGE_DATA, I2C_SEND_2_BYTES);
+	tegra_i2c_ll_write(AS3722_I2C_ADDR,
+			   AS3722_SD6VOLTAGE_DATA);
 	/*
 	 * Don't write SDCONTROL - it's already 0x7F, i.e. all SDs enabled.
 	 * tegra_i2c_ll_write_data(AS3722_SD6CONTROL_DATA, I2C_SEND_2_BYTES);
@@ -77,8 +94,8 @@ void pmic_enable_cpu_vdd(void)
 	 * Bring up VPP_FUSE via the AS3722 PMIC on the PWR I2C bus.
 	 * First set VDD to 1.2V, then enable the VDD regulator.
 	 */
-	tegra_i2c_ll_write_addr(AS3722_I2C_ADDR, 2);
-	tegra_i2c_ll_write_data(AS3722_LDO2VOLTAGE_DATA, I2C_SEND_2_BYTES);
+	tegra_i2c_ll_write(AS3722_I2C_ADDR,
+			   AS3722_LDO2VOLTAGE_DATA);
 	/*
 	 * Don't write LDCONTROL - it's already 0xFF, i.e. all LDOs enabled.
 	 * tegra_i2c_ll_write_data(AS3722_LDO2CONTROL_DATA, I2C_SEND_2_BYTES);
@@ -93,8 +110,8 @@ void pmic_enable_cpu_vdd(void)
 	 * NOTE: We do this early because doing it later seems to hose the CPU
 	 * power rail/partition startup. Need to debug.
 	 */
-	tegra_i2c_ll_write_addr(AS3722_I2C_ADDR, 2);
-	tegra_i2c_ll_write_data(AS3722_LDO6VOLTAGE_DATA, I2C_SEND_2_BYTES);
+	tegra_i2c_ll_write(AS3722_I2C_ADDR,
+			   AS3722_LDO6VOLTAGE_DATA);
 	/*
 	 * Don't write LDCONTROL - it's already 0xFF, i.e. all LDOs enabled.
 	 * tegra_i2c_ll_write_data(AS3722_LDO6CONTROL_DATA, I2C_SEND_2_BYTES);
diff --git a/board/nvidia/venice2/as3722_init.h b/board/nvidia/venice2/as3722_init.h
deleted file mode 100644
index 17e7d76ae7..0000000000
--- a/board/nvidia/venice2/as3722_init.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * (C) Copyright 2013
- * NVIDIA Corporation <www.nvidia.com>
- */
-
-/* AS3722-PMIC-specific early init regs */
-
-#define AS3722_I2C_ADDR		0x80
-
-#define AS3722_SD0VOLTAGE_REG	0x00	/* CPU */
-#define AS3722_SD1VOLTAGE_REG	0x01	/* CORE, already set by OTP */
-#define AS3722_SD6VOLTAGE_REG	0x06	/* GPU */
-#define AS3722_SDCONTROL_REG	0x4D
-
-#define AS3722_LDO2VOLTAGE_REG	0x12	/* VPP_FUSE */
-#define AS3722_LDO6VOLTAGE_REG	0x16	/* VDD_SDMMC */
-#define AS3722_LDCONTROL_REG	0x4E
-
-#if defined(CONFIG_TARGET_VENICE2)
-#define AS3722_SD0VOLTAGE_DATA	(0x2800 | AS3722_SD0VOLTAGE_REG)
-#else /* TK1 or Nyan-Big */
-#define AS3722_SD0VOLTAGE_DATA	(0x3C00 | AS3722_SD0VOLTAGE_REG)
-#endif
-#define AS3722_SD0CONTROL_DATA	(0x0100 | AS3722_SDCONTROL_REG)
-
-#if defined(CONFIG_TARGET_JETSON_TK1) || defined(CONFIG_TARGET_CEI_TK1_SOM)
-#define AS3722_SD1VOLTAGE_DATA	(0x2800 | AS3722_SD1VOLTAGE_REG)
-#define AS3722_SD1CONTROL_DATA	(0x0200 | AS3722_SDCONTROL_REG)
-#endif
-
-#define AS3722_SD6CONTROL_DATA	(0x4000 | AS3722_SDCONTROL_REG)
-#define AS3722_SD6VOLTAGE_DATA	(0x2800 | AS3722_SD6VOLTAGE_REG)
-
-#define AS3722_LDO2CONTROL_DATA	(0x0400 | AS3722_LDCONTROL_REG)
-#define AS3722_LDO2VOLTAGE_DATA	(0x1000 | AS3722_LDO2VOLTAGE_REG)
-
-#define AS3722_LDO6CONTROL_DATA	(0x4000 | AS3722_LDCONTROL_REG)
-#define AS3722_LDO6VOLTAGE_DATA	(0x3F00 | AS3722_LDO6VOLTAGE_REG)
-
-#define I2C_SEND_2_BYTES	0x0A02
-
-void pmic_enable_cpu_vdd(void);
diff --git a/board/toradex/apalis-tk1/as3722_init.c b/board/toradex/apalis-tk1/as3722_init.c
index 68169f5548..e9bd1028be 100644
--- a/board/toradex/apalis-tk1/as3722_init.c
+++ b/board/toradex/apalis-tk1/as3722_init.c
@@ -8,25 +8,40 @@
 #include <asm/io.h>
 #include <asm/arch-tegra/tegra_i2c.h>
 #include <linux/delay.h>
-#include "as3722_init.h"
 
-/* AS3722-PMIC-specific early init code - get CPU rails up, etc */
+/* AS3722-PMIC-specific early init regs */
 
-void tegra_i2c_ll_write_addr(uint addr, uint config)
-{
-	struct i2c_ctlr *reg = (struct i2c_ctlr *)TEGRA_DVC_BASE;
+#define AS3722_I2C_ADDR		0x80
 
-	writel(addr, &reg->cmd_addr0);
-	writel(config, &reg->cnfg);
-}
+#define AS3722_SD0VOLTAGE_REG	0x00	/* CPU */
+#define AS3722_SD1VOLTAGE_REG	0x01	/* CORE, already set by OTP */
+#define AS3722_SD6VOLTAGE_REG	0x06	/* GPU */
+#define AS3722_SDCONTROL_REG	0x4D
 
-void tegra_i2c_ll_write_data(uint data, uint config)
-{
-	struct i2c_ctlr *reg = (struct i2c_ctlr *)TEGRA_DVC_BASE;
+#define AS3722_LDO1VOLTAGE_REG	0x11	/* VDD_SDMMC1 */
+#define AS3722_LDO2VOLTAGE_REG	0x12	/* VPP_FUSE */
+#define AS3722_LDO6VOLTAGE_REG	0x16	/* VDD_SDMMC3 */
+#define AS3722_LDCONTROL_REG	0x4E
 
-	writel(data, &reg->cmd_data1);
-	writel(config, &reg->cnfg);
-}
+#define AS3722_SD0VOLTAGE_DATA	(0x3C00 | AS3722_SD0VOLTAGE_REG)
+#define AS3722_SD0CONTROL_DATA	(0x0100 | AS3722_SDCONTROL_REG)
+
+#define AS3722_SD1VOLTAGE_DATA	(0x3200 | AS3722_SD1VOLTAGE_REG)
+#define AS3722_SD1CONTROL_DATA	(0x0200 | AS3722_SDCONTROL_REG)
+
+#define AS3722_SD6CONTROL_DATA	(0x4000 | AS3722_SDCONTROL_REG)
+#define AS3722_SD6VOLTAGE_DATA	(0x2800 | AS3722_SD6VOLTAGE_REG)
+
+#define AS3722_LDO1CONTROL_DATA	(0x0200 | AS3722_LDCONTROL_REG)
+#define AS3722_LDO1VOLTAGE_DATA	(0x7F00 | AS3722_LDO1VOLTAGE_REG)
+
+#define AS3722_LDO2CONTROL_DATA	(0x0400 | AS3722_LDCONTROL_REG)
+#define AS3722_LDO2VOLTAGE_DATA	(0x1000 | AS3722_LDO2VOLTAGE_REG)
+
+#define AS3722_LDO6CONTROL_DATA	(0x4000 | AS3722_LDCONTROL_REG)
+#define AS3722_LDO6VOLTAGE_DATA	(0x3F00 | AS3722_LDO6VOLTAGE_REG)
+
+/* AS3722-PMIC-specific early init code - get CPU rails up, etc */
 
 void pmic_enable_cpu_vdd(void)
 {
@@ -36,8 +51,8 @@ void pmic_enable_cpu_vdd(void)
 	/* Set up VDD_CORE, for boards where OTP is incorrect*/
 	debug("%s: Setting VDD_CORE via AS3722 reg 1\n", __func__);
 	/* Configure VDD_CORE via the AS3722 PMIC on the PWR I2C bus */
-	tegra_i2c_ll_write_addr(AS3722_I2C_ADDR, 2);
-	tegra_i2c_ll_write_data(AS3722_SD1VOLTAGE_DATA, I2C_SEND_2_BYTES);
+	tegra_i2c_ll_write(AS3722_I2C_ADDR,
+			   AS3722_SD1VOLTAGE_DATA);
 	/*
 	 * Don't write SDCONTROL - it's already 0x7F, i.e. all SDs enabled.
 	 * tegra_i2c_ll_write_data(AS3722_SD1CONTROL_DATA, I2C_SEND_2_BYTES);
@@ -49,23 +64,17 @@ void pmic_enable_cpu_vdd(void)
 	 * Make sure all non-fused regulators are down.
 	 * That way we're in known state after software reboot from linux
 	 */
-	tegra_i2c_ll_write_addr(AS3722_I2C_ADDR, 2);
-	tegra_i2c_ll_write_data(0x0003, I2C_SEND_2_BYTES);
+	tegra_i2c_ll_write(AS3722_I2C_ADDR, 0x0003);
 	udelay(10 * 1000);
-	tegra_i2c_ll_write_addr(AS3722_I2C_ADDR, 2);
-	tegra_i2c_ll_write_data(0x0004, I2C_SEND_2_BYTES);
+	tegra_i2c_ll_write(AS3722_I2C_ADDR, 0x0004);
 	udelay(10 * 1000);
-	tegra_i2c_ll_write_addr(AS3722_I2C_ADDR, 2);
-	tegra_i2c_ll_write_data(0x001b, I2C_SEND_2_BYTES);
+	tegra_i2c_ll_write(AS3722_I2C_ADDR, 0x001b);
 	udelay(10 * 1000);
-	tegra_i2c_ll_write_addr(AS3722_I2C_ADDR, 2);
-	tegra_i2c_ll_write_data(0x0014, I2C_SEND_2_BYTES);
+	tegra_i2c_ll_write(AS3722_I2C_ADDR, 0x0014);
 	udelay(10 * 1000);
-	tegra_i2c_ll_write_addr(AS3722_I2C_ADDR, 2);
-	tegra_i2c_ll_write_data(0x001a, I2C_SEND_2_BYTES);
+	tegra_i2c_ll_write(AS3722_I2C_ADDR, 0x001a);
 	udelay(10 * 1000);
-	tegra_i2c_ll_write_addr(AS3722_I2C_ADDR, 2);
-	tegra_i2c_ll_write_data(0x0019, I2C_SEND_2_BYTES);
+	tegra_i2c_ll_write(AS3722_I2C_ADDR, 0x0019);
 	udelay(10 * 1000);
 
 	debug("%s: Setting VDD_CPU to 1.0V via AS3722 reg 0/4D\n", __func__);
@@ -73,8 +82,8 @@ void pmic_enable_cpu_vdd(void)
 	 * Bring up VDD_CPU via the AS3722 PMIC on the PWR I2C bus.
 	 * First set VDD to 1.0V, then enable the VDD regulator.
 	 */
-	tegra_i2c_ll_write_addr(AS3722_I2C_ADDR, 2);
-	tegra_i2c_ll_write_data(AS3722_SD0VOLTAGE_DATA, I2C_SEND_2_BYTES);
+	tegra_i2c_ll_write(AS3722_I2C_ADDR,
+			   AS3722_SD0VOLTAGE_DATA);
 	/*
 	 * Don't write SDCONTROL - it's already 0x7F, i.e. all SDs enabled.
 	 * tegra_i2c_ll_write_data(AS3722_SD0CONTROL_DATA, I2C_SEND_2_BYTES);
@@ -86,8 +95,8 @@ void pmic_enable_cpu_vdd(void)
 	 * Bring up VDD_GPU via the AS3722 PMIC on the PWR I2C bus.
 	 * First set VDD to 1.0V, then enable the VDD regulator.
 	 */
-	tegra_i2c_ll_write_addr(AS3722_I2C_ADDR, 2);
-	tegra_i2c_ll_write_data(AS3722_SD6VOLTAGE_DATA, I2C_SEND_2_BYTES);
+	tegra_i2c_ll_write(AS3722_I2C_ADDR,
+			   AS3722_SD6VOLTAGE_DATA);
 	/*
 	 * Don't write SDCONTROL - it's already 0x7F, i.e. all SDs enabled.
 	 * tegra_i2c_ll_write_data(AS3722_SD6CONTROL_DATA, I2C_SEND_2_BYTES);
@@ -99,8 +108,8 @@ void pmic_enable_cpu_vdd(void)
 	 * Bring up VPP_FUSE via the AS3722 PMIC on the PWR I2C bus.
 	 * First set VDD to 1.2V, then enable the VDD regulator.
 	 */
-	tegra_i2c_ll_write_addr(AS3722_I2C_ADDR, 2);
-	tegra_i2c_ll_write_data(AS3722_LDO2VOLTAGE_DATA, I2C_SEND_2_BYTES);
+	tegra_i2c_ll_write(AS3722_I2C_ADDR,
+			   AS3722_LDO2VOLTAGE_DATA);
 	/*
 	 * Don't write LDCONTROL - it's already 0xFF, i.e. all LDOs enabled.
 	 * tegra_i2c_ll_write_data(AS3722_LDO2CONTROL_DATA, I2C_SEND_2_BYTES);
@@ -115,8 +124,8 @@ void pmic_enable_cpu_vdd(void)
 	 * NOTE: We do this early because doing it later seems to hose the CPU
 	 * power rail/partition startup. Need to debug.
 	 */
-	tegra_i2c_ll_write_addr(AS3722_I2C_ADDR, 2);
-	tegra_i2c_ll_write_data(AS3722_LDO1VOLTAGE_DATA, I2C_SEND_2_BYTES);
+	tegra_i2c_ll_write(AS3722_I2C_ADDR,
+			   AS3722_LDO1VOLTAGE_DATA);
 	/*
 	 * Don't write LDCONTROL - it's already 0xFF, i.e. all LDOs enabled.
 	 * tegra_i2c_ll_write_data(AS3722_LDO1CONTROL_DATA, I2C_SEND_2_BYTES);
@@ -131,8 +140,8 @@ void pmic_enable_cpu_vdd(void)
 	 * NOTE: We do this early because doing it later seems to hose the CPU
 	 * power rail/partition startup. Need to debug.
 	 */
-	tegra_i2c_ll_write_addr(AS3722_I2C_ADDR, 2);
-	tegra_i2c_ll_write_data(AS3722_LDO6VOLTAGE_DATA, I2C_SEND_2_BYTES);
+	tegra_i2c_ll_write(AS3722_I2C_ADDR,
+			   AS3722_LDO6VOLTAGE_DATA);
 	/*
 	 * Don't write LDCONTROL - it's already 0xFF, i.e. all LDOs enabled.
 	 * tegra_i2c_ll_write_data(AS3722_LDO6CONTROL_DATA, I2C_SEND_2_BYTES);
diff --git a/board/toradex/apalis-tk1/as3722_init.h b/board/toradex/apalis-tk1/as3722_init.h
deleted file mode 100644
index 99836de966..0000000000
--- a/board/toradex/apalis-tk1/as3722_init.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * Copyright (c) 2012-2016 Toradex, Inc.
- */
-
-/* AS3722-PMIC-specific early init regs */
-
-#define AS3722_I2C_ADDR		0x80
-
-#define AS3722_SD0VOLTAGE_REG	0x00	/* CPU */
-#define AS3722_SD1VOLTAGE_REG	0x01	/* CORE, already set by OTP */
-#define AS3722_SD6VOLTAGE_REG	0x06	/* GPU */
-#define AS3722_SDCONTROL_REG	0x4D
-
-#define AS3722_LDO1VOLTAGE_REG	0x11	/* VDD_SDMMC1 */
-#define AS3722_LDO2VOLTAGE_REG	0x12	/* VPP_FUSE */
-#define AS3722_LDO6VOLTAGE_REG	0x16	/* VDD_SDMMC3 */
-#define AS3722_LDCONTROL_REG	0x4E
-
-#define AS3722_SD0VOLTAGE_DATA	(0x3C00 | AS3722_SD0VOLTAGE_REG)
-#define AS3722_SD0CONTROL_DATA	(0x0100 | AS3722_SDCONTROL_REG)
-
-#define AS3722_SD1VOLTAGE_DATA	(0x3200 | AS3722_SD1VOLTAGE_REG)
-#define AS3722_SD1CONTROL_DATA	(0x0200 | AS3722_SDCONTROL_REG)
-
-#define AS3722_SD6CONTROL_DATA	(0x4000 | AS3722_SDCONTROL_REG)
-#define AS3722_SD6VOLTAGE_DATA	(0x2800 | AS3722_SD6VOLTAGE_REG)
-
-#define AS3722_LDO1CONTROL_DATA	(0x0200 | AS3722_LDCONTROL_REG)
-#define AS3722_LDO1VOLTAGE_DATA	(0x7F00 | AS3722_LDO1VOLTAGE_REG)
-
-#define AS3722_LDO2CONTROL_DATA	(0x0400 | AS3722_LDCONTROL_REG)
-#define AS3722_LDO2VOLTAGE_DATA	(0x1000 | AS3722_LDO2VOLTAGE_REG)
-
-#define AS3722_LDO6CONTROL_DATA	(0x4000 | AS3722_LDCONTROL_REG)
-#define AS3722_LDO6VOLTAGE_DATA	(0x3F00 | AS3722_LDO6VOLTAGE_REG)
-
-#define I2C_SEND_2_BYTES	0x0A02
-
-void pmic_enable_cpu_vdd(void);
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v4 12/16] board: tegra30: switch to updated pre-dm i2c write
  2023-02-14 17:35 [PATCH v4 00/16] General Tegra improvements Svyatoslav Ryhel
                   ` (10 preceding siblings ...)
  2023-02-14 17:35 ` [PATCH v4 11/16] board: tegra124: switch to updated " Svyatoslav Ryhel
@ 2023-02-14 17:35 ` Svyatoslav Ryhel
  2023-02-14 17:35 ` [PATCH v4 13/16] ARM: tegra: expose crypto module for all Tegra SoCs Svyatoslav Ryhel
                   ` (4 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Svyatoslav Ryhel @ 2023-02-14 17:35 UTC (permalink / raw)
  To: Tom Warren, Marcel Ziswiler, Allen Martin, Jagan Teki,
	Lukasz Majewski, Marek Vasut, Svyatoslav Ryhel, Ramin Khonsari,
	Thierry Reding, Maxim Schwalm, Dmitry Osipenko, Simon Glass
  Cc: u-boot

Configure PMIC voltages for early stages using updated
early i2c write.

Tested-by: Thierry Reding <treding@nvidia.com> # Beaver T30
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
 arch/arm/mach-tegra/tegra30/Kconfig         |  8 ----
 arch/arm/mach-tegra/tegra30/cpu.c           | 36 -----------------
 board/avionic-design/tec-ng/Makefile        |  4 +-
 board/avionic-design/tec-ng/tec-ng-spl.c    | 34 ++++++++++++++++
 board/nvidia/beaver/Makefile                |  2 +
 board/nvidia/beaver/beaver-spl.c            | 43 +++++++++++++++++++++
 board/nvidia/cardhu/Makefile                |  4 +-
 board/nvidia/cardhu/cardhu-spl.c            | 43 +++++++++++++++++++++
 board/toradex/apalis_t30/Makefile           |  2 +
 board/toradex/apalis_t30/apalis_t30-spl.c   | 34 ++++++++++++++++
 board/toradex/colibri_t30/Makefile          |  2 +
 board/toradex/colibri_t30/colibri_t30-spl.c | 34 ++++++++++++++++
 12 files changed, 200 insertions(+), 46 deletions(-)
 create mode 100644 board/avionic-design/tec-ng/tec-ng-spl.c
 create mode 100644 board/nvidia/beaver/beaver-spl.c
 create mode 100644 board/nvidia/cardhu/cardhu-spl.c
 create mode 100644 board/toradex/apalis_t30/apalis_t30-spl.c
 create mode 100644 board/toradex/colibri_t30/colibri_t30-spl.c

diff --git a/arch/arm/mach-tegra/tegra30/Kconfig b/arch/arm/mach-tegra/tegra30/Kconfig
index 5619d1cd42..85b8ce294f 100644
--- a/arch/arm/mach-tegra/tegra30/Kconfig
+++ b/arch/arm/mach-tegra/tegra30/Kconfig
@@ -1,11 +1,5 @@
 if TEGRA30
 
-config TEGRA_VDD_CORE_TPS62361B_SET3
-	bool
-
-config TEGRA_VDD_CORE_TPS62366A_SET1
-	bool
-
 choice
 	prompt "Tegra30 board select"
 	optional
@@ -17,12 +11,10 @@ config TARGET_APALIS_T30
 config TARGET_BEAVER
 	bool "NVIDIA Tegra30 Beaver evaluation board"
 	select BOARD_LATE_INIT
-	select TEGRA_VDD_CORE_TPS62366A_SET1
 
 config TARGET_CARDHU
 	bool "NVIDIA Tegra30 Cardhu evaluation board"
 	select BOARD_LATE_INIT
-	select TEGRA_VDD_CORE_TPS62361B_SET3
 
 config TARGET_COLIBRI_T30
 	bool "Toradex Colibri T30 board"
diff --git a/arch/arm/mach-tegra/tegra30/cpu.c b/arch/arm/mach-tegra/tegra30/cpu.c
index 6ac45af51a..60bbf13ea5 100644
--- a/arch/arm/mach-tegra/tegra30/cpu.c
+++ b/arch/arm/mach-tegra/tegra30/cpu.c
@@ -15,20 +15,6 @@
 #include <linux/delay.h>
 #include "../cpu.h"
 
-#define TPS62366A_I2C_ADDR		0xC0
-#define TPS62366A_SET1_REG		0x01
-#define TPS62366A_SET1_DATA		(0x4600 | TPS62366A_SET1_REG)
-
-#define TPS62361B_I2C_ADDR		0xC0
-#define TPS62361B_SET3_REG		0x03
-#define TPS62361B_SET3_DATA		(0x4600 | TPS62361B_SET3_REG)
-
-#define TPS65911_I2C_ADDR		0x5A
-#define TPS65911_VDDCTRL_OP_REG		0x28
-#define TPS65911_VDDCTRL_SR_REG		0x27
-#define TPS65911_VDDCTRL_OP_DATA	(0x2400 | TPS65911_VDDCTRL_OP_REG)
-#define TPS65911_VDDCTRL_SR_DATA	(0x0100 | TPS65911_VDDCTRL_SR_REG)
-
 /* In case this function is not defined */
 __weak void pmic_enable_cpu_vdd(void) {}
 
@@ -41,28 +27,6 @@ static void enable_cpu_power_rail(void)
 	reg = readl(&pmc->pmc_cntrl);
 	reg |= CPUPWRREQ_OE;
 	writel(reg, &pmc->pmc_cntrl);
-
-	/* Set VDD_CORE to 1.200V. */
-#ifdef CONFIG_TEGRA_VDD_CORE_TPS62366A_SET1
-	tegra_i2c_ll_write(TPS62366A_I2C_ADDR,
-			   TPS62366A_SET1_DATA);
-#endif
-#ifdef CONFIG_TEGRA_VDD_CORE_TPS62361B_SET3
-	tegra_i2c_ll_write(TPS62361B_I2C_ADDR,
-			   TPS62361B_SET3_DATA);
-#endif
-	udelay(1000);
-
-	/*
-	 * Bring up CPU VDD via the TPS65911x PMIC on the DVC I2C bus.
-	 * First set VDD to 1.0125V, then enable the VDD regulator.
-	 */
-	tegra_i2c_ll_write(TPS65911_I2C_ADDR,
-			   TPS65911_VDDCTRL_OP_DATA);
-	udelay(1000);
-	tegra_i2c_ll_write(TPS65911_I2C_ADDR,
-			   TPS65911_VDDCTRL_SR_DATA);
-	udelay(10 * 1000);
 }
 
 /**
diff --git a/board/avionic-design/tec-ng/Makefile b/board/avionic-design/tec-ng/Makefile
index 46df14d991..d6890e5797 100644
--- a/board/avionic-design/tec-ng/Makefile
+++ b/board/avionic-design/tec-ng/Makefile
@@ -3,4 +3,6 @@
 # (C) Copyright 2013
 # Avionic Design GmbH <www.avionic-design.de>
 
-obj-y	:= ../common/tamonten-ng.o
+obj-$(CONFIG_SPL_BUILD) += tec-ng-spl.o
+
+obj-y	+= ../common/tamonten-ng.o
diff --git a/board/avionic-design/tec-ng/tec-ng-spl.c b/board/avionic-design/tec-ng/tec-ng-spl.c
new file mode 100644
index 0000000000..6e54464183
--- /dev/null
+++ b/board/avionic-design/tec-ng/tec-ng-spl.c
@@ -0,0 +1,34 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ *  (C) Copyright 2010-2013
+ *  NVIDIA Corporation <www.nvidia.com>
+ *
+ *  (C) Copyright 2021
+ *  Svyatoslav Ryhel <clamor95@gmail.com>
+ */
+
+#include <common.h>
+#include <asm/arch-tegra/tegra_i2c.h>
+#include <linux/delay.h>
+
+/* I2C addr is in 8 bit */
+#define TPS65911_I2C_ADDR		0x5A
+#define TPS65911_VDDCTRL_OP_REG		0x28
+#define TPS65911_VDDCTRL_SR_REG		0x27
+#define TPS65911_VDDCTRL_OP_DATA	(0x2400 | TPS65911_VDDCTRL_OP_REG)
+#define TPS65911_VDDCTRL_SR_DATA	(0x0100 | TPS65911_VDDCTRL_SR_REG)
+
+void pmic_enable_cpu_vdd(void)
+{
+	/*
+	 * Bring up CPU VDD via the TPS65911x PMIC on the DVC I2C bus.
+	 * First set VDD to 1.0125V, then enable the VDD regulator.
+	 */
+	udelay(1000);
+	tegra_i2c_ll_write(TPS65911_I2C_ADDR,
+			   TPS65911_VDDCTRL_OP_DATA);
+	udelay(1000);
+	tegra_i2c_ll_write(TPS65911_I2C_ADDR,
+			   TPS65911_VDDCTRL_SR_DATA);
+	udelay(10 * 1000);
+}
diff --git a/board/nvidia/beaver/Makefile b/board/nvidia/beaver/Makefile
index 80cff3eb9c..5e9e70825c 100644
--- a/board/nvidia/beaver/Makefile
+++ b/board/nvidia/beaver/Makefile
@@ -2,4 +2,6 @@
 #
 # Copyright (c) 2010-2013, NVIDIA CORPORATION.  All rights reserved.
 
+obj-$(CONFIG_SPL_BUILD) += beaver-spl.o
+
 obj-y	= ../cardhu/cardhu.o
diff --git a/board/nvidia/beaver/beaver-spl.c b/board/nvidia/beaver/beaver-spl.c
new file mode 100644
index 0000000000..b5d0c14854
--- /dev/null
+++ b/board/nvidia/beaver/beaver-spl.c
@@ -0,0 +1,43 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ *  (C) Copyright 2010-2013
+ *  NVIDIA Corporation <www.nvidia.com>
+ *
+ *  (C) Copyright 2021
+ *  Svyatoslav Ryhel <clamor95@gmail.com>
+ */
+
+#include <common.h>
+#include <asm/arch-tegra/tegra_i2c.h>
+#include <linux/delay.h>
+
+/* I2C addr is in 8 bit */
+#define TPS65911_I2C_ADDR		0x5A
+#define TPS65911_VDDCTRL_OP_REG		0x28
+#define TPS65911_VDDCTRL_SR_REG		0x27
+#define TPS65911_VDDCTRL_OP_DATA	(0x2400 | TPS65911_VDDCTRL_OP_REG)
+#define TPS65911_VDDCTRL_SR_DATA	(0x0100 | TPS65911_VDDCTRL_SR_REG)
+
+#define TPS62366A_I2C_ADDR		0xC0
+#define TPS62366A_SET1_REG		0x01
+#define TPS62366A_SET1_DATA		(0x4600 | TPS62366A_SET1_REG)
+
+void pmic_enable_cpu_vdd(void)
+{
+	/* Set VDD_CORE to 1.200V. */
+	tegra_i2c_ll_write(TPS62366A_I2C_ADDR,
+			   TPS62366A_SET1_DATA);
+
+	udelay(1000);
+
+	/*
+	 * Bring up CPU VDD via the TPS65911x PMIC on the DVC I2C bus.
+	 * First set VDD to 1.0125V, then enable the VDD regulator.
+	 */
+	tegra_i2c_ll_write(TPS65911_I2C_ADDR,
+			   TPS65911_VDDCTRL_OP_DATA);
+	udelay(1000);
+	tegra_i2c_ll_write(TPS65911_I2C_ADDR,
+			   TPS65911_VDDCTRL_SR_DATA);
+	udelay(10 * 1000);
+}
diff --git a/board/nvidia/cardhu/Makefile b/board/nvidia/cardhu/Makefile
index 95971053d9..6f480cdfd3 100644
--- a/board/nvidia/cardhu/Makefile
+++ b/board/nvidia/cardhu/Makefile
@@ -3,4 +3,6 @@
 #  (C) Copyright 2010-2012
 #  NVIDIA Corporation <www.nvidia.com>
 
-obj-y	:= cardhu.o
+obj-$(CONFIG_SPL_BUILD) += cardhu-spl.o
+
+obj-y	+= cardhu.o
diff --git a/board/nvidia/cardhu/cardhu-spl.c b/board/nvidia/cardhu/cardhu-spl.c
new file mode 100644
index 0000000000..de2fa300f1
--- /dev/null
+++ b/board/nvidia/cardhu/cardhu-spl.c
@@ -0,0 +1,43 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ *  (C) Copyright 2010-2013
+ *  NVIDIA Corporation <www.nvidia.com>
+ *
+ *  (C) Copyright 2021
+ *  Svyatoslav Ryhel <clamor95@gmail.com>
+ */
+
+#include <common.h>
+#include <asm/arch-tegra/tegra_i2c.h>
+#include <linux/delay.h>
+
+/* I2C addr is in 8 bit */
+#define TPS65911_I2C_ADDR		0x5A
+#define TPS65911_VDDCTRL_OP_REG		0x28
+#define TPS65911_VDDCTRL_SR_REG		0x27
+#define TPS65911_VDDCTRL_OP_DATA	(0x2400 | TPS65911_VDDCTRL_OP_REG)
+#define TPS65911_VDDCTRL_SR_DATA	(0x0100 | TPS65911_VDDCTRL_SR_REG)
+
+#define TPS62361B_I2C_ADDR		0xC0
+#define TPS62361B_SET3_REG		0x03
+#define TPS62361B_SET3_DATA		(0x4600 | TPS62361B_SET3_REG)
+
+void pmic_enable_cpu_vdd(void)
+{
+	/* Set VDD_CORE to 1.200V. */
+	tegra_i2c_ll_write(TPS62361B_I2C_ADDR,
+			   TPS62361B_SET3_DATA);
+
+	udelay(1000);
+
+	/*
+	 * Bring up CPU VDD via the TPS65911x PMIC on the DVC I2C bus.
+	 * First set VDD to 1.0125V, then enable the VDD regulator.
+	 */
+	tegra_i2c_ll_write(TPS65911_I2C_ADDR,
+			   TPS65911_VDDCTRL_OP_DATA);
+	udelay(1000);
+	tegra_i2c_ll_write(TPS65911_I2C_ADDR,
+			   TPS65911_VDDCTRL_SR_DATA);
+	udelay(10 * 1000);
+}
diff --git a/board/toradex/apalis_t30/Makefile b/board/toradex/apalis_t30/Makefile
index 0ea3d8f217..eed607043f 100644
--- a/board/toradex/apalis_t30/Makefile
+++ b/board/toradex/apalis_t30/Makefile
@@ -1,4 +1,6 @@
 # Copyright (c) 2014 Marcel Ziswiler
 # SPDX-License-Identifier:      GPL-2.0+
 
+obj-$(CONFIG_SPL_BUILD) += apalis_t30-spl.o
+
 obj-y	+= apalis_t30.o
diff --git a/board/toradex/apalis_t30/apalis_t30-spl.c b/board/toradex/apalis_t30/apalis_t30-spl.c
new file mode 100644
index 0000000000..6e54464183
--- /dev/null
+++ b/board/toradex/apalis_t30/apalis_t30-spl.c
@@ -0,0 +1,34 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ *  (C) Copyright 2010-2013
+ *  NVIDIA Corporation <www.nvidia.com>
+ *
+ *  (C) Copyright 2021
+ *  Svyatoslav Ryhel <clamor95@gmail.com>
+ */
+
+#include <common.h>
+#include <asm/arch-tegra/tegra_i2c.h>
+#include <linux/delay.h>
+
+/* I2C addr is in 8 bit */
+#define TPS65911_I2C_ADDR		0x5A
+#define TPS65911_VDDCTRL_OP_REG		0x28
+#define TPS65911_VDDCTRL_SR_REG		0x27
+#define TPS65911_VDDCTRL_OP_DATA	(0x2400 | TPS65911_VDDCTRL_OP_REG)
+#define TPS65911_VDDCTRL_SR_DATA	(0x0100 | TPS65911_VDDCTRL_SR_REG)
+
+void pmic_enable_cpu_vdd(void)
+{
+	/*
+	 * Bring up CPU VDD via the TPS65911x PMIC on the DVC I2C bus.
+	 * First set VDD to 1.0125V, then enable the VDD regulator.
+	 */
+	udelay(1000);
+	tegra_i2c_ll_write(TPS65911_I2C_ADDR,
+			   TPS65911_VDDCTRL_OP_DATA);
+	udelay(1000);
+	tegra_i2c_ll_write(TPS65911_I2C_ADDR,
+			   TPS65911_VDDCTRL_SR_DATA);
+	udelay(10 * 1000);
+}
diff --git a/board/toradex/colibri_t30/Makefile b/board/toradex/colibri_t30/Makefile
index 4242902dae..8f333235b1 100644
--- a/board/toradex/colibri_t30/Makefile
+++ b/board/toradex/colibri_t30/Makefile
@@ -1,4 +1,6 @@
 # Copyright (c) 2013-2014 Stefan Agner
 # SPDX-License-Identifier:      GPL-2.0+
 
+obj-$(CONFIG_SPL_BUILD) += colibri_t30-spl.o
+
 obj-y	+= colibri_t30.o
diff --git a/board/toradex/colibri_t30/colibri_t30-spl.c b/board/toradex/colibri_t30/colibri_t30-spl.c
new file mode 100644
index 0000000000..6e54464183
--- /dev/null
+++ b/board/toradex/colibri_t30/colibri_t30-spl.c
@@ -0,0 +1,34 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ *  (C) Copyright 2010-2013
+ *  NVIDIA Corporation <www.nvidia.com>
+ *
+ *  (C) Copyright 2021
+ *  Svyatoslav Ryhel <clamor95@gmail.com>
+ */
+
+#include <common.h>
+#include <asm/arch-tegra/tegra_i2c.h>
+#include <linux/delay.h>
+
+/* I2C addr is in 8 bit */
+#define TPS65911_I2C_ADDR		0x5A
+#define TPS65911_VDDCTRL_OP_REG		0x28
+#define TPS65911_VDDCTRL_SR_REG		0x27
+#define TPS65911_VDDCTRL_OP_DATA	(0x2400 | TPS65911_VDDCTRL_OP_REG)
+#define TPS65911_VDDCTRL_SR_DATA	(0x0100 | TPS65911_VDDCTRL_SR_REG)
+
+void pmic_enable_cpu_vdd(void)
+{
+	/*
+	 * Bring up CPU VDD via the TPS65911x PMIC on the DVC I2C bus.
+	 * First set VDD to 1.0125V, then enable the VDD regulator.
+	 */
+	udelay(1000);
+	tegra_i2c_ll_write(TPS65911_I2C_ADDR,
+			   TPS65911_VDDCTRL_OP_DATA);
+	udelay(1000);
+	tegra_i2c_ll_write(TPS65911_I2C_ADDR,
+			   TPS65911_VDDCTRL_SR_DATA);
+	udelay(10 * 1000);
+}
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v4 13/16] ARM: tegra: expose crypto module for all Tegra SoCs
  2023-02-14 17:35 [PATCH v4 00/16] General Tegra improvements Svyatoslav Ryhel
                   ` (11 preceding siblings ...)
  2023-02-14 17:35 ` [PATCH v4 12/16] board: tegra30: " Svyatoslav Ryhel
@ 2023-02-14 17:35 ` Svyatoslav Ryhel
  2023-02-14 17:35 ` [PATCH v4 14/16] ARM: tegra: crypto: extend crypto functional Svyatoslav Ryhel
                   ` (3 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Svyatoslav Ryhel @ 2023-02-14 17:35 UTC (permalink / raw)
  To: Tom Warren, Marcel Ziswiler, Allen Martin, Jagan Teki,
	Lukasz Majewski, Marek Vasut, Svyatoslav Ryhel, Ramin Khonsari,
	Thierry Reding, Maxim Schwalm, Dmitry Osipenko, Simon Glass
  Cc: u-boot

Move crypto module from T20 only into common Tegra dir.

Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 arch/arm/mach-tegra/Kconfig                | 5 +++++
 arch/arm/mach-tegra/Makefile               | 1 +
 arch/arm/mach-tegra/{tegra20 => }/crypto.c | 0
 arch/arm/mach-tegra/{tegra20 => }/crypto.h | 0
 arch/arm/mach-tegra/tegra20/Kconfig        | 1 +
 arch/arm/mach-tegra/tegra20/Makefile       | 2 +-
 6 files changed, 8 insertions(+), 1 deletion(-)
 rename arch/arm/mach-tegra/{tegra20 => }/crypto.c (100%)
 rename arch/arm/mach-tegra/{tegra20 => }/crypto.h (100%)

diff --git a/arch/arm/mach-tegra/Kconfig b/arch/arm/mach-tegra/Kconfig
index 4fc79ebadb..5b0cd92d9e 100644
--- a/arch/arm/mach-tegra/Kconfig
+++ b/arch/arm/mach-tegra/Kconfig
@@ -15,6 +15,11 @@ config SPL_SERIAL
 config TEGRA_CLKRST
 	bool
 
+config TEGRA_CRYPTO
+	bool "Tegra AES128 crypto module"
+	select AES
+	default n
+
 config TEGRA_GP_PADCTRL
 	bool
 
diff --git a/arch/arm/mach-tegra/Makefile b/arch/arm/mach-tegra/Makefile
index 7165d70a60..9147050b32 100644
--- a/arch/arm/mach-tegra/Makefile
+++ b/arch/arm/mach-tegra/Makefile
@@ -16,6 +16,7 @@ obj-$(CONFIG_TEGRA_GP_PADCTRL) += ap.o
 obj-y += board.o board2.o
 obj-y += cache.o
 obj-$(CONFIG_TEGRA_CLKRST) += clock.o
+obj-$(CONFIG_$(SPL_)TEGRA_CRYPTO) += crypto.o
 obj-$(CONFIG_TEGRA_PINCTRL) += pinmux-common.o
 obj-$(CONFIG_TEGRA_PMC) += powergate.o
 obj-y += xusb-padctl-dummy.o
diff --git a/arch/arm/mach-tegra/tegra20/crypto.c b/arch/arm/mach-tegra/crypto.c
similarity index 100%
rename from arch/arm/mach-tegra/tegra20/crypto.c
rename to arch/arm/mach-tegra/crypto.c
diff --git a/arch/arm/mach-tegra/tegra20/crypto.h b/arch/arm/mach-tegra/crypto.h
similarity index 100%
rename from arch/arm/mach-tegra/tegra20/crypto.h
rename to arch/arm/mach-tegra/crypto.h
diff --git a/arch/arm/mach-tegra/tegra20/Kconfig b/arch/arm/mach-tegra/tegra20/Kconfig
index 955786c0c4..57d11024bf 100644
--- a/arch/arm/mach-tegra/tegra20/Kconfig
+++ b/arch/arm/mach-tegra/tegra20/Kconfig
@@ -3,6 +3,7 @@ if TEGRA20
 config TEGRA_LP0
 	bool
 	select TEGRA_CLOCK_SCALING
+	select TEGRA_CRYPTO
 
 config TEGRA_PMU
 	bool
diff --git a/arch/arm/mach-tegra/tegra20/Makefile b/arch/arm/mach-tegra/tegra20/Makefile
index bb17c90cca..67454ff5f4 100644
--- a/arch/arm/mach-tegra/tegra20/Makefile
+++ b/arch/arm/mach-tegra/tegra20/Makefile
@@ -13,6 +13,6 @@ CFLAGS_warmboot_avp.o = -march=armv4t -U__LINUX_ARM_ARCH__ \
 CFLAGS_REMOVE_warmboot_avp.o := $(LTO_CFLAGS)
 
 obj-y	+= clock.o funcmux.o pinmux.o
-obj-$(CONFIG_TEGRA_LP0) += warmboot.o crypto.o warmboot_avp.o
+obj-$(CONFIG_TEGRA_LP0) += warmboot.o warmboot_avp.o
 obj-$(CONFIG_TEGRA_CLOCK_SCALING) += emc.o
 obj-$(CONFIG_TEGRA_PMU) += pmu.o
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v4 14/16] ARM: tegra: crypto: extend crypto functional
  2023-02-14 17:35 [PATCH v4 00/16] General Tegra improvements Svyatoslav Ryhel
                   ` (12 preceding siblings ...)
  2023-02-14 17:35 ` [PATCH v4 13/16] ARM: tegra: expose crypto module for all Tegra SoCs Svyatoslav Ryhel
@ 2023-02-14 17:35 ` Svyatoslav Ryhel
  2023-02-14 17:35 ` [PATCH v4 15/16] ARM: tegra30: implement BCT patching Svyatoslav Ryhel
                   ` (2 subsequent siblings)
  16 siblings, 0 replies; 28+ messages in thread
From: Svyatoslav Ryhel @ 2023-02-14 17:35 UTC (permalink / raw)
  To: Tom Warren, Marcel Ziswiler, Allen Martin, Jagan Teki,
	Lukasz Majewski, Marek Vasut, Svyatoslav Ryhel, Ramin Khonsari,
	Thierry Reding, Maxim Schwalm, Dmitry Osipenko, Simon Glass
  Cc: u-boot

Add support for encryption, decryption and signinig with
non-zero key saving backward compatibility.

Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 arch/arm/include/asm/arch-tegra/crypto.h | 47 ++++++++++++++++++
 arch/arm/mach-tegra/crypto.c             | 63 +++++++++++++++++-------
 arch/arm/mach-tegra/crypto.h             | 19 -------
 3 files changed, 91 insertions(+), 38 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-tegra/crypto.h
 delete mode 100644 arch/arm/mach-tegra/crypto.h

diff --git a/arch/arm/include/asm/arch-tegra/crypto.h b/arch/arm/include/asm/arch-tegra/crypto.h
new file mode 100644
index 0000000000..7646163b97
--- /dev/null
+++ b/arch/arm/include/asm/arch-tegra/crypto.h
@@ -0,0 +1,47 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ * (C) Copyright 2010 - 2011 NVIDIA Corporation <www.nvidia.com>
+ */
+
+#ifndef _CRYPTO_H_
+#define _CRYPTO_H_
+
+/**
+ * Sign a block of data
+ *
+ * \param source	Source data
+ * \param length	Size of source data
+ * \param signature	Destination address for signature, AES_KEY_LENGTH bytes
+ */
+int sign_data_block(u8 *source, unsigned int length, u8 *signature);
+
+/**
+ * Sign an encrypted block of data
+ *
+ * \param source	Source data
+ * \param length	Size of source data
+ * \param signature	Destination address for signature, AES_KEY_LENGTH bytes
+ * \param key		AES128 encryption key
+ */
+int sign_enc_data_block(u8 *source, unsigned int length, u8 *signature, u8 *key);
+
+/**
+ * Encrypt a block of data
+ *
+ * \param source	Source data
+ * \param length	Size of source data
+ * \param key		AES128 encryption key
+ */
+int encrypt_data_block(u8 *source, unsigned int length, u8 *key);
+
+/**
+ * Decrypt a block of data
+ *
+ * \param source	Source data
+ * \param length	Size of source data
+ * \param key		AES128 encryption key
+ */
+int decrypt_data_block(u8 *source, unsigned int length, u8 *key);
+
+#endif /* #ifndef _CRYPTO_H_ */
diff --git a/arch/arm/mach-tegra/crypto.c b/arch/arm/mach-tegra/crypto.c
index 1efaa5c3ec..893da35e0b 100644
--- a/arch/arm/mach-tegra/crypto.c
+++ b/arch/arm/mach-tegra/crypto.c
@@ -7,7 +7,7 @@
 #include <common.h>
 #include <log.h>
 #include <linux/errno.h>
-#include "crypto.h"
+#include <asm/arch-tegra/crypto.h>
 #include "uboot_aes.h"
 
 static u8 zero_key[16];
@@ -17,6 +17,7 @@ static u8 zero_key[16];
 enum security_op {
 	SECURITY_SIGN		= 1 << 0,	/* Sign the data */
 	SECURITY_ENCRYPT	= 1 << 1,	/* Encrypt the data */
+	SECURITY_DECRYPT	= 1 << 2,	/* Dectypt the data */
 };
 
 /**
@@ -54,7 +55,7 @@ static void sign_object(u8 *key, u8 *key_schedule, u8 *src, u8 *dst,
 	u8 left[AES128_KEY_LENGTH];
 	u8 k1[AES128_KEY_LENGTH];
 	u8 *cbc_chain_data;
-	unsigned i;
+	unsigned int i;
 
 	cbc_chain_data = zero_key;	/* Convenient array of 0's for IV */
 
@@ -92,7 +93,7 @@ static void sign_object(u8 *key, u8 *key_schedule, u8 *src, u8 *dst,
 }
 
 /**
- * Encrypt and sign a block of data (depending on security mode).
+ * Decrypt, encrypt or sign a block of data (depending on security mode).
  *
  * \param key		Input AES key, length AES128_KEY_LENGTH
  * \param oper		Security operations mask to perform (enum security_op)
@@ -100,44 +101,68 @@ static void sign_object(u8 *key, u8 *key_schedule, u8 *src, u8 *dst,
  * \param length	Size of source data
  * \param sig_dst	Destination address for signature, AES128_KEY_LENGTH bytes
  */
-static int encrypt_and_sign(u8 *key, enum security_op oper, u8 *src,
-			    u32 length, u8 *sig_dst)
+static int tegra_crypto_core(u8 *key, enum security_op oper, u8 *src,
+			     u32 length, u8 *sig_dst)
 {
 	u32 num_aes_blocks;
 	u8 key_schedule[AES128_EXPAND_KEY_LENGTH];
 	u8 iv[AES128_KEY_LENGTH] = {0};
 
-	debug("encrypt_and_sign: length = %d\n", length);
+	debug("%s: length = %d\n", __func__, length);
 
-	/*
-	 * The only need for a key is for signing/checksum purposes, so
-	 * if not encrypting, expand a key of 0s.
-	 */
-	aes_expand_key(oper & SECURITY_ENCRYPT ? key : zero_key,
-		       AES128_KEY_LENGTH, key_schedule);
+	aes_expand_key(key, AES128_KEY_LENGTH, key_schedule);
 
 	num_aes_blocks = (length + AES128_KEY_LENGTH - 1) / AES128_KEY_LENGTH;
 
+	if (oper & SECURITY_DECRYPT) {
+		/* Perform this in place, resulting in src being decrypted. */
+		debug("%s: begin decryption\n", __func__);
+		aes_cbc_decrypt_blocks(AES128_KEY_LENGTH, key_schedule, iv, src,
+				       src, num_aes_blocks);
+		debug("%s: end decryption\n", __func__);
+	}
+
 	if (oper & SECURITY_ENCRYPT) {
 		/* Perform this in place, resulting in src being encrypted. */
-		debug("encrypt_and_sign: begin encryption\n");
+		debug("%s: begin encryption\n", __func__);
 		aes_cbc_encrypt_blocks(AES128_KEY_LENGTH, key_schedule, iv, src,
 				       src, num_aes_blocks);
-		debug("encrypt_and_sign: end encryption\n");
+		debug("%s: end encryption\n", __func__);
 	}
 
 	if (oper & SECURITY_SIGN) {
 		/* encrypt the data, overwriting the result in signature. */
-		debug("encrypt_and_sign: begin signing\n");
+		debug("%s: begin signing\n", __func__);
 		sign_object(key, key_schedule, src, sig_dst, num_aes_blocks);
-		debug("encrypt_and_sign: end signing\n");
+		debug("%s: end signing\n", __func__);
 	}
 
 	return 0;
 }
 
-int sign_data_block(u8 *source, unsigned length, u8 *signature)
+/**
+ * Tegra crypto group
+ */
+int sign_data_block(u8 *source, unsigned int length, u8 *signature)
+{
+	return tegra_crypto_core(zero_key, SECURITY_SIGN, source,
+				 length, signature);
+}
+
+int sign_enc_data_block(u8 *source, unsigned int length, u8 *signature, u8 *key)
+{
+	return tegra_crypto_core(key, SECURITY_SIGN, source,
+				 length, signature);
+}
+
+int encrypt_data_block(u8 *source, unsigned int length, u8 *key)
+{
+	return tegra_crypto_core(key, SECURITY_ENCRYPT, source,
+				 length, NULL);
+}
+
+int decrypt_data_block(u8 *source, unsigned int length, u8 *key)
 {
-	return encrypt_and_sign(zero_key, SECURITY_SIGN, source,
-				length, signature);
+	return tegra_crypto_core(key, SECURITY_DECRYPT, source,
+				 length, NULL);
 }
diff --git a/arch/arm/mach-tegra/crypto.h b/arch/arm/mach-tegra/crypto.h
deleted file mode 100644
index a773d03fc7..0000000000
--- a/arch/arm/mach-tegra/crypto.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * Copyright (c) 2011 The Chromium OS Authors.
- * (C) Copyright 2010 - 2011 NVIDIA Corporation <www.nvidia.com>
- */
-
-#ifndef _CRYPTO_H_
-#define _CRYPTO_H_
-
-/**
- * Sign a block of data
- *
- * \param source	Source data
- * \param length	Size of source data
- * \param signature	Destination address for signature, AES_KEY_LENGTH bytes
- */
-int sign_data_block(u8 *source, unsigned length, u8 *signature);
-
-#endif /* #ifndef _CRYPTO_H_ */
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v4 15/16] ARM: tegra30: implement BCT patching
  2023-02-14 17:35 [PATCH v4 00/16] General Tegra improvements Svyatoslav Ryhel
                   ` (13 preceding siblings ...)
  2023-02-14 17:35 ` [PATCH v4 14/16] ARM: tegra: crypto: extend crypto functional Svyatoslav Ryhel
@ 2023-02-14 17:35 ` Svyatoslav Ryhel
  2023-02-14 17:35 ` [PATCH v4 16/16] ARM: tegra20: " Svyatoslav Ryhel
  2023-02-14 21:45 ` [PATCH v4 00/16] General Tegra improvements Tom Warren
  16 siblings, 0 replies; 28+ messages in thread
From: Svyatoslav Ryhel @ 2023-02-14 17:35 UTC (permalink / raw)
  To: Tom Warren, Marcel Ziswiler, Allen Martin, Jagan Teki,
	Lukasz Majewski, Marek Vasut, Svyatoslav Ryhel, Ramin Khonsari,
	Thierry Reding, Maxim Schwalm, Dmitry Osipenko, Simon Glass
  Cc: u-boot

From: Ramin Khonsari <raminterex@yahoo.com>

This function allows updating bootloader from u-boot
on production devices without need in host PC.

Be aware! It works only with re-crypted BCT.

Tested-by: Andreas Westman Dorcsak <hedmoo@yahoo.com> # ASUS TF T30
Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # LG P895 T30
Signed-off-by: Ramin Khonsari <raminterex@yahoo.com>
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 arch/arm/mach-tegra/Kconfig          |  9 ++++
 arch/arm/mach-tegra/tegra30/Makefile |  1 +
 arch/arm/mach-tegra/tegra30/bct.c    | 79 ++++++++++++++++++++++++++++
 arch/arm/mach-tegra/tegra30/bct.h    | 42 +++++++++++++++
 4 files changed, 131 insertions(+)
 create mode 100644 arch/arm/mach-tegra/tegra30/bct.c
 create mode 100644 arch/arm/mach-tegra/tegra30/bct.h

diff --git a/arch/arm/mach-tegra/Kconfig b/arch/arm/mach-tegra/Kconfig
index 5b0cd92d9e..8490d42a7b 100644
--- a/arch/arm/mach-tegra/Kconfig
+++ b/arch/arm/mach-tegra/Kconfig
@@ -229,4 +229,13 @@ config CMD_ENTERRCM
 	  for mechanical button actuators, or hooking up relays/... to the
 	  button.
 
+config CMD_EBTUPDATE
+	bool "Enable 'ebtupdate' command"
+	depends on TEGRA30
+	select TEGRA_CRYPTO
+	help
+	  Updating u-boot from within u-boot in rather complex or even
+	  impossible on production devices. To make it easier procedure of
+	  re-cryption was created. If your device was re-crypted choose Y.
+
 endif
diff --git a/arch/arm/mach-tegra/tegra30/Makefile b/arch/arm/mach-tegra/tegra30/Makefile
index 9f170576e7..28dd486d8d 100644
--- a/arch/arm/mach-tegra/tegra30/Makefile
+++ b/arch/arm/mach-tegra/tegra30/Makefile
@@ -3,5 +3,6 @@
 # Copyright (c) 2010-2012, NVIDIA CORPORATION.  All rights reserved.
 
 obj-$(CONFIG_SPL_BUILD) += cpu.o
+obj-$(CONFIG_$(SPL_)CMD_EBTUPDATE) += bct.o
 
 obj-y	+= clock.o funcmux.o pinmux.o
diff --git a/arch/arm/mach-tegra/tegra30/bct.c b/arch/arm/mach-tegra/tegra30/bct.c
new file mode 100644
index 0000000000..c56958da69
--- /dev/null
+++ b/arch/arm/mach-tegra/tegra30/bct.c
@@ -0,0 +1,79 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2022, Ramin <raminterex@yahoo.com>
+ * Copyright (c) 2022, Svyatoslav Ryhel <clamor95@gmail.com>
+ */
+
+#include <common.h>
+#include <command.h>
+#include <log.h>
+#include <asm/arch-tegra/crypto.h>
+#include "bct.h"
+#include "uboot_aes.h"
+
+/*
+ * @param  bct		boot config table start in RAM
+ * @param  ect		bootloader start in RAM
+ * @param  ebt_size	bootloader file size in bytes
+ * Return: 0, or 1 if failed
+ */
+static int bct_patch(u8 *bct, u8 *ebt, u32 ebt_size)
+{
+	struct nvboot_config_table *bct_tbl = NULL;
+	u8 ebt_hash[AES128_KEY_LENGTH] = { 0 };
+	u8 sbk[AES128_KEY_LENGTH] = { 0 };
+	u8 *bct_hash = bct;
+	int ret;
+
+	bct += BCT_HASH;
+
+	memcpy(sbk, (u8 *)(bct + BCT_LENGTH),
+	       NVBOOT_CMAC_AES_HASH_LENGTH * 4);
+
+	ret = decrypt_data_block(bct, BCT_LENGTH, sbk);
+	if (ret)
+		return 1;
+
+	ebt_size = roundup(ebt_size, EBT_ALIGNMENT);
+
+	ret = encrypt_data_block(ebt, ebt_size, sbk);
+	if (ret)
+		return 1;
+
+	ret = sign_enc_data_block(ebt, ebt_size, ebt_hash, sbk);
+	if (ret)
+		return 1;
+
+	bct_tbl = (struct nvboot_config_table *)bct;
+
+	memcpy((u8 *)&bct_tbl->bootloader[0].crypto_hash,
+	       ebt_hash, NVBOOT_CMAC_AES_HASH_LENGTH * 4);
+	bct_tbl->bootloader[0].entry_point = CONFIG_SPL_TEXT_BASE;
+	bct_tbl->bootloader[0].load_addr = CONFIG_SPL_TEXT_BASE;
+	bct_tbl->bootloader[0].length = ebt_size;
+
+	ret = encrypt_data_block(bct, BCT_LENGTH, sbk);
+	if (ret)
+		return 1;
+
+	ret = sign_enc_data_block(bct, BCT_LENGTH, bct_hash, sbk);
+	if (ret)
+		return 1;
+
+	return 0;
+}
+
+static int do_ebtupdate(struct cmd_tbl *cmdtp, int flag, int argc,
+			char *const argv[])
+{
+	u32 bct_addr = hextoul(argv[1], NULL);
+	u32 ebt_addr = hextoul(argv[2], NULL);
+	u32 ebt_size = hextoul(argv[3], NULL);
+
+	return bct_patch((u8 *)bct_addr, (u8 *)ebt_addr, ebt_size);
+}
+
+U_BOOT_CMD(ebtupdate,	4,	0,	do_ebtupdate,
+	   "update bootloader on re-crypted Tegra30 devices",
+	   ""
+);
diff --git a/arch/arm/mach-tegra/tegra30/bct.h b/arch/arm/mach-tegra/tegra30/bct.h
new file mode 100644
index 0000000000..9797384da3
--- /dev/null
+++ b/arch/arm/mach-tegra/tegra30/bct.h
@@ -0,0 +1,42 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+
+#ifndef _BCT_H_
+#define _BCT_H_
+
+/*
+ * Defines the BCT parametres for T30
+ */
+#define BCT_LENGTH		0x17E0
+#define BCT_HASH		0x10
+#define EBT_ALIGNMENT		0x10
+
+/*
+ * Defines the CMAC-AES-128 hash length in 32 bit words. (128 bits = 4 words)
+ */
+#define NVBOOT_CMAC_AES_HASH_LENGTH		4
+
+/*
+ * Defines the maximum number of bootloader descriptions in the BCT.
+ */
+#define NVBOOT_MAX_BOOTLOADERS			4
+
+struct nv_bootloader_info {
+	u32 version;
+	u32 start_blk;
+	u32 start_page;
+	u32 length;
+	u32 load_addr;
+	u32 entry_point;
+	u32 attribute;
+	u32 crypto_hash[NVBOOT_CMAC_AES_HASH_LENGTH];
+};
+
+struct nvboot_config_table {
+	u32 unused0[4];
+	u32 boot_data_version;
+	u32 unused1[972];
+	struct nv_bootloader_info bootloader[NVBOOT_MAX_BOOTLOADERS];
+	u32 unused2[508];
+};
+
+#endif /* _BCT_H_ */
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* [PATCH v4 16/16] ARM: tegra20: implement BCT patching
  2023-02-14 17:35 [PATCH v4 00/16] General Tegra improvements Svyatoslav Ryhel
                   ` (14 preceding siblings ...)
  2023-02-14 17:35 ` [PATCH v4 15/16] ARM: tegra30: implement BCT patching Svyatoslav Ryhel
@ 2023-02-14 17:35 ` Svyatoslav Ryhel
  2023-02-14 21:45 ` [PATCH v4 00/16] General Tegra improvements Tom Warren
  16 siblings, 0 replies; 28+ messages in thread
From: Svyatoslav Ryhel @ 2023-02-14 17:35 UTC (permalink / raw)
  To: Tom Warren, Marcel Ziswiler, Allen Martin, Jagan Teki,
	Lukasz Majewski, Marek Vasut, Svyatoslav Ryhel, Ramin Khonsari,
	Thierry Reding, Maxim Schwalm, Dmitry Osipenko, Simon Glass
  Cc: u-boot

This function allows updating bootloader from u-boot
on production devices without need in host PC.

Be aware! It works only with re-crypt BCT.

Tested-by: Robert Eckelmann <longnoserob@gmail.com> # ASUS TF101 T20
Signed-off-by: Ramin Khonsari <raminterex@yahoo.com>
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 arch/arm/mach-tegra/Kconfig          |  2 +-
 arch/arm/mach-tegra/tegra20/Makefile |  5 +-
 arch/arm/mach-tegra/tegra20/bct.c    | 79 ++++++++++++++++++++++++++++
 arch/arm/mach-tegra/tegra20/bct.h    | 42 +++++++++++++++
 doc/usage/cmd/ebtupdate.rst          | 70 ++++++++++++++++++++++++
 5 files changed, 194 insertions(+), 4 deletions(-)
 create mode 100644 arch/arm/mach-tegra/tegra20/bct.c
 create mode 100644 arch/arm/mach-tegra/tegra20/bct.h
 create mode 100644 doc/usage/cmd/ebtupdate.rst

diff --git a/arch/arm/mach-tegra/Kconfig b/arch/arm/mach-tegra/Kconfig
index 8490d42a7b..464bd0798f 100644
--- a/arch/arm/mach-tegra/Kconfig
+++ b/arch/arm/mach-tegra/Kconfig
@@ -231,7 +231,7 @@ config CMD_ENTERRCM
 
 config CMD_EBTUPDATE
 	bool "Enable 'ebtupdate' command"
-	depends on TEGRA30
+	depends on TEGRA20 || TEGRA30
 	select TEGRA_CRYPTO
 	help
 	  Updating u-boot from within u-boot in rather complex or even
diff --git a/arch/arm/mach-tegra/tegra20/Makefile b/arch/arm/mach-tegra/tegra20/Makefile
index 67454ff5f4..991cabeec5 100644
--- a/arch/arm/mach-tegra/tegra20/Makefile
+++ b/arch/arm/mach-tegra/tegra20/Makefile
@@ -2,9 +2,8 @@
 #
 # (C) Copyright 2010,2011 Nvidia Corporation.
 
-ifdef CONFIG_SPL_BUILD
-obj-y	+= cpu.o
-endif
+obj-$(CONFIG_SPL_BUILD) += cpu.o
+obj-$(CONFIG_$(SPL_)CMD_EBTUPDATE) += bct.o
 
 # The AVP is ARMv4T architecture so we must use special compiler
 # flags for any startup files it might use.
diff --git a/arch/arm/mach-tegra/tegra20/bct.c b/arch/arm/mach-tegra/tegra20/bct.c
new file mode 100644
index 0000000000..5eb48990b6
--- /dev/null
+++ b/arch/arm/mach-tegra/tegra20/bct.c
@@ -0,0 +1,79 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2022, Ramin <raminterex@yahoo.com>
+ * Copyright (c) 2022, Svyatoslav Ryhel <clamor95@gmail.com>
+ */
+
+#include <common.h>
+#include <command.h>
+#include <log.h>
+#include <asm/arch-tegra/crypto.h>
+#include "bct.h"
+#include "uboot_aes.h"
+
+/*
+ * @param  bct		boot config table start in RAM
+ * @param  ect		bootloader start in RAM
+ * @param  ebt_size	bootloader file size in bytes
+ * Return: 0, or 1 if failed
+ */
+static int bct_patch(u8 *bct, u8 *ebt, u32 ebt_size)
+{
+	struct nvboot_config_table *bct_tbl = NULL;
+	u8 ebt_hash[AES128_KEY_LENGTH] = { 0 };
+	u8 sbk[AES128_KEY_LENGTH] = { 0 };
+	u8 *bct_hash = bct;
+	int ret;
+
+	bct += BCT_HASH;
+
+	memcpy(sbk, (u8 *)(bct + BCT_LENGTH),
+	       NVBOOT_CMAC_AES_HASH_LENGTH * 4);
+
+	ret = decrypt_data_block(bct, BCT_LENGTH, sbk);
+	if (ret)
+		return 1;
+
+	ebt_size = roundup(ebt_size, EBT_ALIGNMENT);
+
+	ret = encrypt_data_block(ebt, ebt_size, sbk);
+	if (ret)
+		return 1;
+
+	ret = sign_enc_data_block(ebt, ebt_size, ebt_hash, sbk);
+	if (ret)
+		return 1;
+
+	bct_tbl = (struct nvboot_config_table *)bct;
+
+	memcpy((u8 *)&bct_tbl->bootloader[0].crypto_hash,
+	       ebt_hash, NVBOOT_CMAC_AES_HASH_LENGTH * 4);
+	bct_tbl->bootloader[0].entry_point = CONFIG_SPL_TEXT_BASE;
+	bct_tbl->bootloader[0].load_addr = CONFIG_SPL_TEXT_BASE;
+	bct_tbl->bootloader[0].length = ebt_size;
+
+	ret = encrypt_data_block(bct, BCT_LENGTH, sbk);
+	if (ret)
+		return 1;
+
+	ret = sign_enc_data_block(bct, BCT_LENGTH, bct_hash, sbk);
+	if (ret)
+		return 1;
+
+	return 0;
+}
+
+static int do_ebtupdate(struct cmd_tbl *cmdtp, int flag, int argc,
+			char *const argv[])
+{
+	u32 bct_addr = hextoul(argv[1], NULL);
+	u32 ebt_addr = hextoul(argv[2], NULL);
+	u32 ebt_size = hextoul(argv[3], NULL);
+
+	return bct_patch((u8 *)bct_addr, (u8 *)ebt_addr, ebt_size);
+}
+
+U_BOOT_CMD(ebtupdate,	4,	0,	do_ebtupdate,
+	   "update bootloader on re-crypted Tegra20 devices",
+	   ""
+);
diff --git a/arch/arm/mach-tegra/tegra20/bct.h b/arch/arm/mach-tegra/tegra20/bct.h
new file mode 100644
index 0000000000..4b78aef7cf
--- /dev/null
+++ b/arch/arm/mach-tegra/tegra20/bct.h
@@ -0,0 +1,42 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+
+#ifndef _BCT_H_
+#define _BCT_H_
+
+/*
+ * Defines the BCT parametres for T20
+ */
+#define BCT_LENGTH		0xFE0
+#define BCT_HASH		0x10
+#define EBT_ALIGNMENT		0x10
+
+/*
+ * Defines the CMAC-AES-128 hash length in 32 bit words. (128 bits = 4 words)
+ */
+#define NVBOOT_CMAC_AES_HASH_LENGTH		4
+
+/*
+ * Defines the maximum number of bootloader descriptions in the BCT.
+ */
+#define NVBOOT_MAX_BOOTLOADERS			4
+
+struct nv_bootloader_info {
+	u32 version;
+	u32 start_blk;
+	u32 start_page;
+	u32 length;
+	u32 load_addr;
+	u32 entry_point;
+	u32 attribute;
+	u32 crypto_hash[NVBOOT_CMAC_AES_HASH_LENGTH];
+};
+
+struct nvboot_config_table {
+	u32 unused0[4];
+	u32 boot_data_version;
+	u32 unused1[668];
+	struct nv_bootloader_info bootloader[NVBOOT_MAX_BOOTLOADERS];
+	u32 unused2[508];
+};
+
+#endif /* _BCT_H_ */
diff --git a/doc/usage/cmd/ebtupdate.rst b/doc/usage/cmd/ebtupdate.rst
new file mode 100644
index 0000000000..d0905612c0
--- /dev/null
+++ b/doc/usage/cmd/ebtupdate.rst
@@ -0,0 +1,70 @@
+.. SPDX-License-Identifier: GPL-2.0+:
+
+ebtupdate command
+=============
+
+Synopsis
+--------
+
+::
+
+    ebtupdate [<bct> [<ebt>] [<size>]]
+
+Description
+-----------
+
+The "ebtupdate" command is used to self-update bootloader on Tegra 2 and Tegra 3
+production devices which were processed using re-cryption.
+
+The "ebtupdate" performs encryption of new bootloader and decryption, patching
+and re-encryption of BCT "in situ". After BCT and bootloader can be written in
+their respective places.
+
+bct
+    address of BCT block pre-loaded into RAM.
+
+ebt
+    address of the bootloader pre-loaded into RAM.
+
+size
+    size of the pre-loaded bootloader.
+
+Example
+-------
+
+This is the boot log of a LG Optimus Vu:
+
+::
+
+    => mmc dev 0 1
+    switch to partitions #1, OK
+    mmc0(part 1) is current device
+    => mmc read $kernel_addr_r 0 $boot_block_size
+    MMC read: dev # 0, block # 0, count 4096 ... 4096 blocks read: OK
+    => load mmc 0:1 $ramdisk_addr_r $bootloader_file
+    684783 bytes read in 44 ms (14.8 MiB/s)
+    => size mmc 0:1 $bootloader_file
+    => ebtupdate $kernel_addr_r $ramdisk_addr_r $filesize
+    => mmc dev 0 1
+    switch to partitions #1, OK
+    mmc0(part 1) is current device
+    => mmc write $kernel_addr_r 0 $boot_block_size
+    MMC write: dev # 0, block # 0, count 4096 ... 4096 blocks written: OK
+    => mmc dev 0 2
+    switch to partitions #2, OK
+    mmc0(part 2) is current device
+    => mmc write $ramdisk_addr_r 0 $boot_block_size
+    MMC write: dev # 0, block # 0, count 4096 ... 4096 blocks written: OK
+
+Configuration
+-------------
+
+The ebtupdate command is only available if CONFIG_CMD_EBTUPDATE=y and
+only on Tegra 2 and Tegra 3 configurations.
+
+Return value
+------------
+
+The return value $? is set to 0 (true) if everything went successfully. If an
+error occurs, the return value $? is set to 1 (false).
+
-- 
2.37.2


^ permalink raw reply related	[flat|nested] 28+ messages in thread

* RE: [PATCH v4 00/16] General Tegra improvements
  2023-02-14 17:35 [PATCH v4 00/16] General Tegra improvements Svyatoslav Ryhel
                   ` (15 preceding siblings ...)
  2023-02-14 17:35 ` [PATCH v4 16/16] ARM: tegra20: " Svyatoslav Ryhel
@ 2023-02-14 21:45 ` Tom Warren
  2023-02-15  7:26   ` Svyatoslav Ryhel
  2023-02-17  8:39   ` Svyatoslav Ryhel
  16 siblings, 2 replies; 28+ messages in thread
From: Tom Warren @ 2023-02-14 21:45 UTC (permalink / raw)
  To: Svyatoslav Ryhel; +Cc: u-boot

<reducing audience>

Svyatoslav,

Taking TOT u-boot-tegra/master, and fast-forwarding to TOT u-boot/master, I then try to apply your 16 patch series and get the following failures (using patch). Note that I retargeted the crypto.c patch by hand to point to tegra20/crypto.c, which I believe one of your patches moves to arch/arm/tegra. PTAL.

tom@tom-ThinkPad-T580:~/denx/uboot-tegra$ patch -p1 -i ~/Downloads/bundle-23303-Svyatoslav-16-v4.mbox  --dry-run 
checking file arch/arm/include/asm/arch-tegra30/clock-tables.h
checking file arch/arm/mach-tegra/tegra30/clock.c
checking file arch/arm/mach-tegra/tegra20/clock.c
checking file arch/arm/mach-tegra/tegra30/clock.c
checking file arch/arm/include/asm/arch-tegra/clock.h
checking file arch/arm/mach-tegra/tegra114/clock.c
checking file arch/arm/mach-tegra/tegra124/clock.c
checking file arch/arm/mach-tegra/tegra20/clock.c
checking file arch/arm/mach-tegra/tegra210/clock.c
checking file arch/arm/mach-tegra/tegra30/clock.c
checking file arch/arm/include/asm/arch-tegra/clock.h
checking file arch/arm/mach-tegra/clock.c
checking file arch/arm/mach-tegra/tegra30/clock.c
Hunk #1 succeeded at 632 (offset -37 lines).
checking file arch/arm/dts/tegra114.dtsi
checking file arch/arm/dts/tegra124.dtsi
checking file arch/arm/mach-tegra/tegra114/clock.c
Hunk #1 succeeded at 745 (offset -37 lines).
checking file arch/arm/mach-tegra/tegra124/clock.c
Hunk #1 succeeded at 1170 (offset -38 lines).
checking file arch/arm/mach-tegra/tegra20/clock.c
Hunk #1 succeeded at 767 (offset -37 lines).
checking file arch/arm/mach-tegra/tegra210/clock.c
Hunk #1 succeeded at 1241 (offset -37 lines).
checking file arch/arm/mach-tegra/tegra30/clock.c
Hunk #1 succeeded at 806 (offset -78 lines).
checking file drivers/pwm/tegra_pwm.c
checking file drivers/spi/tegra20_slink.c
checking file configs/beaver_defconfig
checking file configs/cei-tk1-som_defconfig
checking file configs/dalmore_defconfig
checking file configs/jetson-tk1_defconfig
checking file configs/nyan-big_defconfig
checking file configs/p2371-0000_defconfig
checking file configs/p2371-2180_defconfig
checking file configs/p2571_defconfig
checking file configs/p3450-0000_defconfig
checking file configs/venice2_defconfig
checking file drivers/usb/gadget/Kconfig
checking file arch/arm/include/asm/arch-tegra/sys_proto.h
checking file arch/arm/mach-tegra/board2.c
checking file arch/arm/include/asm/arch-tegra/tegra_i2c.h
checking file arch/arm/mach-tegra/cpu.h
checking file arch/arm/mach-tegra/tegra124/cpu.c
checking file arch/arm/mach-tegra/tegra30/cpu.c
checking file board/nvidia/venice2/as3722_init.c
checking file board/nvidia/venice2/as3722_init.h
checking file board/toradex/apalis-tk1/as3722_init.c
checking file board/toradex/apalis-tk1/as3722_init.h
checking file arch/arm/mach-tegra/tegra30/Kconfig
checking file arch/arm/mach-tegra/tegra30/cpu.c
Hunk #1 FAILED at 15.
Hunk #2 FAILED at 41.
2 out of 2 hunks FAILED
checking file board/avionic-design/tec-ng/Makefile
checking file board/avionic-design/tec-ng/tec-ng-spl.c
checking file board/nvidia/beaver/Makefile
checking file board/nvidia/beaver/beaver-spl.c
checking file board/nvidia/cardhu/Makefile
checking file board/nvidia/cardhu/cardhu-spl.c
checking file board/toradex/apalis_t30/Makefile
checking file board/toradex/apalis_t30/apalis_t30-spl.c
checking file board/toradex/colibri_t30/Makefile
checking file board/toradex/colibri_t30/colibri_t30-spl.c
checking file arch/arm/mach-tegra/Kconfig
checking file arch/arm/mach-tegra/Makefile
checking file arch/arm/mach-tegra/crypto.c (renamed from arch/arm/mach-tegra/tegra20/crypto.c)
checking file arch/arm/mach-tegra/crypto.h (renamed from arch/arm/mach-tegra/tegra20/crypto.h)
checking file arch/arm/mach-tegra/tegra20/Kconfig
checking file arch/arm/mach-tegra/tegra20/Makefile
checking file arch/arm/include/asm/arch-tegra/crypto.h
can't find file to patch at input line 3811
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/arch/arm/mach-tegra/crypto.c b/arch/arm/mach-tegra/crypto.c
|index 1efaa5c3ec..893da35e0b 100644
|--- a/arch/arm/mach-tegra/crypto.c
|+++ b/arch/arm/mach-tegra/crypto.c
--------------------------
File to patch: arch/arm/mach-tegra/tegra20/crypto.c
checking file arch/arm/mach-tegra/tegra20/crypto.c
The next patch would delete the file arch/arm/mach-tegra/crypto.h,
which does not exist!  Assume -R? [n] 
Apply anyway? [n] 
Skipping patch.
1 out of 1 hunk ignored
checking file arch/arm/mach-tegra/Kconfig
Hunk #1 succeeded at 224 (offset -5 lines).
checking file arch/arm/mach-tegra/tegra30/Makefile
checking file arch/arm/mach-tegra/tegra30/bct.c
checking file arch/arm/mach-tegra/tegra30/bct.h
checking file arch/arm/mach-tegra/Kconfig
Hunk #1 FAILED at 231.
1 out of 1 hunk FAILED
checking file arch/arm/mach-tegra/tegra20/Makefile
checking file arch/arm/mach-tegra/tegra20/bct.c
checking file arch/arm/mach-tegra/tegra20/bct.h
checking file doc/usage/cmd/ebtupdate.rst
tom@tom-ThinkPad-T580:~/denx/uboot-tegra$

-----Original Message-----
From: Svyatoslav Ryhel <clamor95@gmail.com> 
Sent: Tuesday, February 14, 2023 10:35 AM
To: Tom Warren <twarren@nvidia.com>; Marcel Ziswiler <marcel.ziswiler@toradex.com>; Allen Martin <amartin@nvidia.com>; Jagan Teki <jagan@amarulasolutions.com>; Lukasz Majewski <lukma@denx.de>; Marek Vasut <marex@denx.de>; Svyatoslav Ryhel <clamor95@gmail.com>; Ramin Khonsari <raminterex@yahoo.com>; Thierry Reding <thierry.reding@gmail.com>; Maxim Schwalm <maxim.schwalm@gmail.com>; Dmitry Osipenko <digetx@gmail.com>; Simon Glass <sjg@chromium.org>
Cc: u-boot@lists.denx.de
Subject: [PATCH v4 00/16] General Tegra improvements

External email: Use caution opening links or attachments


List of changes in patch set:
 - add missing EXTPERIPH clocks for t30
 - swap host1x and disp1 clock parents (as they should be)
 - add clk_id_to_pll_id and clock_decode_pair helpers to use
   dts deeper (in tegra clocks often go in pair child - parent)
 - include PLLD setup in T30 (DISP1 may use it as parent on
   some devices)
 - fix Tegra PWM parent clock inline with linux
 - Tegra SLINK: patch to accept any word length (unlike 8bit
   aligned which was before)
 - provide default USB gadget setup for existing Nvidia boards
 - add late init function to be able to configure pre-boot stage
   (like uncovering serial number or setting mac address)
 - create common pre-dm i2c write for PMIC (used on T30 and T124
   to configure basic PMIC voltages required to boot like cpu and
   core voltages)
 - expose crypto module for all Tegra SoCs and implement BCT patching
   (ability to update bootloader from u-boot on production devices
   without need in host PC)

---
Changelog from v3
 - added tested-by

Changelog from v2
 - fixed T114 TEGRA114_CLK_PLL_E_OUT0
 - adjusted pre-dm i2c write commit description
 - added description file for ebtupdate command
 - minor improvements of bct.c comments

Changelog from v1
 - rebased to latest u-boot master
 - PLLD setup for T30 moved specifically into T30 area
---

Maxim Schwalm (1):
  ARM: tegra: provide default USB gadget setup

Ramin Khonsari (1):
  ARM: tegra30: implement BCT patching

Svyatoslav Ryhel (14):
  tegra30: clock: add EXTPERIPH
  ARM: t20/t30: swap host1x and disp1 clock parents
  ARM: tegra: clock: add clk_id_to_pll_id helper
  ARM: tegra: clock: add clock_decode_pair helper
  ARM: tegra30: add PLLD to pll setup
  ARM: tegra: Fix Tegra PWM parent clock
  spi: tegra20_slink: accept any word length
  ARM: tegra: add late init support
  ARM: tegra: create common pre-dm i2c write
  board: tegra124: switch to updated pre-dm i2c write
  board: tegra30: switch to updated pre-dm i2c write
  ARM: tegra: expose crypto module for all Tegra SoCs
  ARM: tegra: crypto: extend crypto functional
  ARM: tegra20: implement BCT patching

 arch/arm/dts/tegra114.dtsi                    |  2 +-
 arch/arm/dts/tegra124.dtsi                    |  2 +-
 arch/arm/include/asm/arch-tegra/clock.h       | 21 +++++
 arch/arm/include/asm/arch-tegra/crypto.h      | 47 ++++++++++
 arch/arm/include/asm/arch-tegra/sys_proto.h   |  6 ++
 arch/arm/include/asm/arch-tegra/tegra_i2c.h   | 17 ++++
 .../include/asm/arch-tegra30/clock-tables.h   |  6 +-
 arch/arm/mach-tegra/Kconfig                   | 14 +++
 arch/arm/mach-tegra/Makefile                  |  1 +
 arch/arm/mach-tegra/board2.c                  |  2 +
 arch/arm/mach-tegra/clock.c                   | 23 +++++
 arch/arm/mach-tegra/cpu.h                     |  1 -
 arch/arm/mach-tegra/{tegra20 => }/crypto.c    | 63 +++++++++----
 arch/arm/mach-tegra/tegra114/clock.c          | 39 +++++++-
 arch/arm/mach-tegra/tegra124/clock.c          | 40 ++++++++-
 arch/arm/mach-tegra/tegra124/cpu.c            |  4 +
 arch/arm/mach-tegra/tegra20/Kconfig           |  1 +
 arch/arm/mach-tegra/tegra20/Makefile          |  7 +-
 arch/arm/mach-tegra/tegra20/bct.c             | 79 ++++++++++++++++
 arch/arm/mach-tegra/tegra20/bct.h             | 42 +++++++++
 arch/arm/mach-tegra/tegra20/clock.c           | 43 ++++++++-
 arch/arm/mach-tegra/tegra20/crypto.h          | 19 ----
 arch/arm/mach-tegra/tegra210/clock.c          | 39 +++++++-
 arch/arm/mach-tegra/tegra30/Kconfig           |  8 --
 arch/arm/mach-tegra/tegra30/Makefile          |  1 +
 arch/arm/mach-tegra/tegra30/bct.c             | 79 ++++++++++++++++
 arch/arm/mach-tegra/tegra30/bct.h             | 42 +++++++++
 arch/arm/mach-tegra/tegra30/clock.c           | 90 +++++++++++++++++--
 arch/arm/mach-tegra/tegra30/cpu.c             | 55 +-----------
 board/avionic-design/tec-ng/Makefile          |  4 +-
 board/avionic-design/tec-ng/tec-ng-spl.c      | 34 +++++++
 board/nvidia/beaver/Makefile                  |  2 +
 board/nvidia/beaver/beaver-spl.c              | 43 +++++++++
 board/nvidia/cardhu/Makefile                  |  4 +-
 board/nvidia/cardhu/cardhu-spl.c              | 43 +++++++++
 board/nvidia/venice2/as3722_init.c            | 65 +++++++++-----
 board/nvidia/venice2/as3722_init.h            | 43 ---------
 board/toradex/apalis-tk1/as3722_init.c        | 85 ++++++++++--------
 board/toradex/apalis-tk1/as3722_init.h        | 40 ---------
 board/toradex/apalis_t30/Makefile             |  2 +
 board/toradex/apalis_t30/apalis_t30-spl.c     | 34 +++++++
 board/toradex/colibri_t30/Makefile            |  2 +
 board/toradex/colibri_t30/colibri_t30-spl.c   | 34 +++++++
 configs/beaver_defconfig                      |  3 -
 configs/cei-tk1-som_defconfig                 |  3 -
 configs/dalmore_defconfig                     |  3 -
 configs/jetson-tk1_defconfig                  |  3 -
 configs/nyan-big_defconfig                    |  3 -
 configs/p2371-0000_defconfig                  |  3 -
 configs/p2371-2180_defconfig                  |  3 -
 configs/p2571_defconfig                       |  3 -
 configs/p3450-0000_defconfig                  |  3 -
 configs/venice2_defconfig                     |  3 -
 doc/usage/cmd/ebtupdate.rst                   | 70 +++++++++++++++
 drivers/pwm/tegra_pwm.c                       | 10 ++-
 drivers/spi/tegra20_slink.c                   | 19 ++--
 drivers/usb/gadget/Kconfig                    |  3 +
 57 files changed, 1051 insertions(+), 309 deletions(-)  create mode 100644 arch/arm/include/asm/arch-tegra/crypto.h
 rename arch/arm/mach-tegra/{tegra20 => }/crypto.c (68%)  create mode 100644 arch/arm/mach-tegra/tegra20/bct.c  create mode 100644 arch/arm/mach-tegra/tegra20/bct.h  delete mode 100644 arch/arm/mach-tegra/tegra20/crypto.h
 create mode 100644 arch/arm/mach-tegra/tegra30/bct.c  create mode 100644 arch/arm/mach-tegra/tegra30/bct.h  create mode 100644 board/avionic-design/tec-ng/tec-ng-spl.c
 create mode 100644 board/nvidia/beaver/beaver-spl.c  create mode 100644 board/nvidia/cardhu/cardhu-spl.c  delete mode 100644 board/nvidia/venice2/as3722_init.h
 delete mode 100644 board/toradex/apalis-tk1/as3722_init.h
 create mode 100644 board/toradex/apalis_t30/apalis_t30-spl.c
 create mode 100644 board/toradex/colibri_t30/colibri_t30-spl.c
 create mode 100644 doc/usage/cmd/ebtupdate.rst

--
2.37.2


^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH v4 00/16] General Tegra improvements
  2023-02-14 21:45 ` [PATCH v4 00/16] General Tegra improvements Tom Warren
@ 2023-02-15  7:26   ` Svyatoslav Ryhel
  2023-02-17  8:39   ` Svyatoslav Ryhel
  1 sibling, 0 replies; 28+ messages in thread
From: Svyatoslav Ryhel @ 2023-02-15  7:26 UTC (permalink / raw)
  To: Tom Warren; +Cc: u-boot

You are correct, crypto.c was moved from T20 to common mach-tegra, but
I have sent patches already on top on u-boot/master and rebase gave me
no errors.

Looks like commit
  ARM: tegra: crypto: extend crypto functional
was picked before
  ARM: tegra: expose crypto module for all Tegra SoCs
which caused the error you pointed to.

вт, 14 лют. 2023 р. о 23:45 Tom Warren <TWarren@nvidia.com> пише:
>
> <reducing audience>
>
> Svyatoslav,
>
> Taking TOT u-boot-tegra/master, and fast-forwarding to TOT u-boot/master, I then try to apply your 16 patch series and get the following failures (using patch). Note that I retargeted the crypto.c patch by hand to point to tegra20/crypto.c, which I believe one of your patches moves to arch/arm/tegra. PTAL.
>
> tom@tom-ThinkPad-T580:~/denx/uboot-tegra$ patch -p1 -i ~/Downloads/bundle-23303-Svyatoslav-16-v4.mbox  --dry-run
> checking file arch/arm/include/asm/arch-tegra30/clock-tables.h
> checking file arch/arm/mach-tegra/tegra30/clock.c
> checking file arch/arm/mach-tegra/tegra20/clock.c
> checking file arch/arm/mach-tegra/tegra30/clock.c
> checking file arch/arm/include/asm/arch-tegra/clock.h
> checking file arch/arm/mach-tegra/tegra114/clock.c
> checking file arch/arm/mach-tegra/tegra124/clock.c
> checking file arch/arm/mach-tegra/tegra20/clock.c
> checking file arch/arm/mach-tegra/tegra210/clock.c
> checking file arch/arm/mach-tegra/tegra30/clock.c
> checking file arch/arm/include/asm/arch-tegra/clock.h
> checking file arch/arm/mach-tegra/clock.c
> checking file arch/arm/mach-tegra/tegra30/clock.c
> Hunk #1 succeeded at 632 (offset -37 lines).
> checking file arch/arm/dts/tegra114.dtsi
> checking file arch/arm/dts/tegra124.dtsi
> checking file arch/arm/mach-tegra/tegra114/clock.c
> Hunk #1 succeeded at 745 (offset -37 lines).
> checking file arch/arm/mach-tegra/tegra124/clock.c
> Hunk #1 succeeded at 1170 (offset -38 lines).
> checking file arch/arm/mach-tegra/tegra20/clock.c
> Hunk #1 succeeded at 767 (offset -37 lines).
> checking file arch/arm/mach-tegra/tegra210/clock.c
> Hunk #1 succeeded at 1241 (offset -37 lines).
> checking file arch/arm/mach-tegra/tegra30/clock.c
> Hunk #1 succeeded at 806 (offset -78 lines).
> checking file drivers/pwm/tegra_pwm.c
> checking file drivers/spi/tegra20_slink.c
> checking file configs/beaver_defconfig
> checking file configs/cei-tk1-som_defconfig
> checking file configs/dalmore_defconfig
> checking file configs/jetson-tk1_defconfig
> checking file configs/nyan-big_defconfig
> checking file configs/p2371-0000_defconfig
> checking file configs/p2371-2180_defconfig
> checking file configs/p2571_defconfig
> checking file configs/p3450-0000_defconfig
> checking file configs/venice2_defconfig
> checking file drivers/usb/gadget/Kconfig
> checking file arch/arm/include/asm/arch-tegra/sys_proto.h
> checking file arch/arm/mach-tegra/board2.c
> checking file arch/arm/include/asm/arch-tegra/tegra_i2c.h
> checking file arch/arm/mach-tegra/cpu.h
> checking file arch/arm/mach-tegra/tegra124/cpu.c
> checking file arch/arm/mach-tegra/tegra30/cpu.c
> checking file board/nvidia/venice2/as3722_init.c
> checking file board/nvidia/venice2/as3722_init.h
> checking file board/toradex/apalis-tk1/as3722_init.c
> checking file board/toradex/apalis-tk1/as3722_init.h
> checking file arch/arm/mach-tegra/tegra30/Kconfig
> checking file arch/arm/mach-tegra/tegra30/cpu.c
> Hunk #1 FAILED at 15.
> Hunk #2 FAILED at 41.
> 2 out of 2 hunks FAILED
> checking file board/avionic-design/tec-ng/Makefile
> checking file board/avionic-design/tec-ng/tec-ng-spl.c
> checking file board/nvidia/beaver/Makefile
> checking file board/nvidia/beaver/beaver-spl.c
> checking file board/nvidia/cardhu/Makefile
> checking file board/nvidia/cardhu/cardhu-spl.c
> checking file board/toradex/apalis_t30/Makefile
> checking file board/toradex/apalis_t30/apalis_t30-spl.c
> checking file board/toradex/colibri_t30/Makefile
> checking file board/toradex/colibri_t30/colibri_t30-spl.c
> checking file arch/arm/mach-tegra/Kconfig
> checking file arch/arm/mach-tegra/Makefile
> checking file arch/arm/mach-tegra/crypto.c (renamed from arch/arm/mach-tegra/tegra20/crypto.c)
> checking file arch/arm/mach-tegra/crypto.h (renamed from arch/arm/mach-tegra/tegra20/crypto.h)
> checking file arch/arm/mach-tegra/tegra20/Kconfig
> checking file arch/arm/mach-tegra/tegra20/Makefile
> checking file arch/arm/include/asm/arch-tegra/crypto.h
> can't find file to patch at input line 3811
> Perhaps you used the wrong -p or --strip option?
> The text leading up to this was:
> --------------------------
> |diff --git a/arch/arm/mach-tegra/crypto.c b/arch/arm/mach-tegra/crypto.c
> |index 1efaa5c3ec..893da35e0b 100644
> |--- a/arch/arm/mach-tegra/crypto.c
> |+++ b/arch/arm/mach-tegra/crypto.c
> --------------------------
> File to patch: arch/arm/mach-tegra/tegra20/crypto.c
> checking file arch/arm/mach-tegra/tegra20/crypto.c
> The next patch would delete the file arch/arm/mach-tegra/crypto.h,
> which does not exist!  Assume -R? [n]
> Apply anyway? [n]
> Skipping patch.
> 1 out of 1 hunk ignored
> checking file arch/arm/mach-tegra/Kconfig
> Hunk #1 succeeded at 224 (offset -5 lines).
> checking file arch/arm/mach-tegra/tegra30/Makefile
> checking file arch/arm/mach-tegra/tegra30/bct.c
> checking file arch/arm/mach-tegra/tegra30/bct.h
> checking file arch/arm/mach-tegra/Kconfig
> Hunk #1 FAILED at 231.
> 1 out of 1 hunk FAILED
> checking file arch/arm/mach-tegra/tegra20/Makefile
> checking file arch/arm/mach-tegra/tegra20/bct.c
> checking file arch/arm/mach-tegra/tegra20/bct.h
> checking file doc/usage/cmd/ebtupdate.rst
> tom@tom-ThinkPad-T580:~/denx/uboot-tegra$
>
> -----Original Message-----
> From: Svyatoslav Ryhel <clamor95@gmail.com>
> Sent: Tuesday, February 14, 2023 10:35 AM
> To: Tom Warren <twarren@nvidia.com>; Marcel Ziswiler <marcel.ziswiler@toradex.com>; Allen Martin <amartin@nvidia.com>; Jagan Teki <jagan@amarulasolutions.com>; Lukasz Majewski <lukma@denx.de>; Marek Vasut <marex@denx.de>; Svyatoslav Ryhel <clamor95@gmail.com>; Ramin Khonsari <raminterex@yahoo.com>; Thierry Reding <thierry.reding@gmail.com>; Maxim Schwalm <maxim.schwalm@gmail.com>; Dmitry Osipenko <digetx@gmail.com>; Simon Glass <sjg@chromium.org>
> Cc: u-boot@lists.denx.de
> Subject: [PATCH v4 00/16] General Tegra improvements
>
> External email: Use caution opening links or attachments
>
>
> List of changes in patch set:
>  - add missing EXTPERIPH clocks for t30
>  - swap host1x and disp1 clock parents (as they should be)
>  - add clk_id_to_pll_id and clock_decode_pair helpers to use
>    dts deeper (in tegra clocks often go in pair child - parent)
>  - include PLLD setup in T30 (DISP1 may use it as parent on
>    some devices)
>  - fix Tegra PWM parent clock inline with linux
>  - Tegra SLINK: patch to accept any word length (unlike 8bit
>    aligned which was before)
>  - provide default USB gadget setup for existing Nvidia boards
>  - add late init function to be able to configure pre-boot stage
>    (like uncovering serial number or setting mac address)
>  - create common pre-dm i2c write for PMIC (used on T30 and T124
>    to configure basic PMIC voltages required to boot like cpu and
>    core voltages)
>  - expose crypto module for all Tegra SoCs and implement BCT patching
>    (ability to update bootloader from u-boot on production devices
>    without need in host PC)
>
> ---
> Changelog from v3
>  - added tested-by
>
> Changelog from v2
>  - fixed T114 TEGRA114_CLK_PLL_E_OUT0
>  - adjusted pre-dm i2c write commit description
>  - added description file for ebtupdate command
>  - minor improvements of bct.c comments
>
> Changelog from v1
>  - rebased to latest u-boot master
>  - PLLD setup for T30 moved specifically into T30 area
> ---
>
> Maxim Schwalm (1):
>   ARM: tegra: provide default USB gadget setup
>
> Ramin Khonsari (1):
>   ARM: tegra30: implement BCT patching
>
> Svyatoslav Ryhel (14):
>   tegra30: clock: add EXTPERIPH
>   ARM: t20/t30: swap host1x and disp1 clock parents
>   ARM: tegra: clock: add clk_id_to_pll_id helper
>   ARM: tegra: clock: add clock_decode_pair helper
>   ARM: tegra30: add PLLD to pll setup
>   ARM: tegra: Fix Tegra PWM parent clock
>   spi: tegra20_slink: accept any word length
>   ARM: tegra: add late init support
>   ARM: tegra: create common pre-dm i2c write
>   board: tegra124: switch to updated pre-dm i2c write
>   board: tegra30: switch to updated pre-dm i2c write
>   ARM: tegra: expose crypto module for all Tegra SoCs
>   ARM: tegra: crypto: extend crypto functional
>   ARM: tegra20: implement BCT patching
>
>  arch/arm/dts/tegra114.dtsi                    |  2 +-
>  arch/arm/dts/tegra124.dtsi                    |  2 +-
>  arch/arm/include/asm/arch-tegra/clock.h       | 21 +++++
>  arch/arm/include/asm/arch-tegra/crypto.h      | 47 ++++++++++
>  arch/arm/include/asm/arch-tegra/sys_proto.h   |  6 ++
>  arch/arm/include/asm/arch-tegra/tegra_i2c.h   | 17 ++++
>  .../include/asm/arch-tegra30/clock-tables.h   |  6 +-
>  arch/arm/mach-tegra/Kconfig                   | 14 +++
>  arch/arm/mach-tegra/Makefile                  |  1 +
>  arch/arm/mach-tegra/board2.c                  |  2 +
>  arch/arm/mach-tegra/clock.c                   | 23 +++++
>  arch/arm/mach-tegra/cpu.h                     |  1 -
>  arch/arm/mach-tegra/{tegra20 => }/crypto.c    | 63 +++++++++----
>  arch/arm/mach-tegra/tegra114/clock.c          | 39 +++++++-
>  arch/arm/mach-tegra/tegra124/clock.c          | 40 ++++++++-
>  arch/arm/mach-tegra/tegra124/cpu.c            |  4 +
>  arch/arm/mach-tegra/tegra20/Kconfig           |  1 +
>  arch/arm/mach-tegra/tegra20/Makefile          |  7 +-
>  arch/arm/mach-tegra/tegra20/bct.c             | 79 ++++++++++++++++
>  arch/arm/mach-tegra/tegra20/bct.h             | 42 +++++++++
>  arch/arm/mach-tegra/tegra20/clock.c           | 43 ++++++++-
>  arch/arm/mach-tegra/tegra20/crypto.h          | 19 ----
>  arch/arm/mach-tegra/tegra210/clock.c          | 39 +++++++-
>  arch/arm/mach-tegra/tegra30/Kconfig           |  8 --
>  arch/arm/mach-tegra/tegra30/Makefile          |  1 +
>  arch/arm/mach-tegra/tegra30/bct.c             | 79 ++++++++++++++++
>  arch/arm/mach-tegra/tegra30/bct.h             | 42 +++++++++
>  arch/arm/mach-tegra/tegra30/clock.c           | 90 +++++++++++++++++--
>  arch/arm/mach-tegra/tegra30/cpu.c             | 55 +-----------
>  board/avionic-design/tec-ng/Makefile          |  4 +-
>  board/avionic-design/tec-ng/tec-ng-spl.c      | 34 +++++++
>  board/nvidia/beaver/Makefile                  |  2 +
>  board/nvidia/beaver/beaver-spl.c              | 43 +++++++++
>  board/nvidia/cardhu/Makefile                  |  4 +-
>  board/nvidia/cardhu/cardhu-spl.c              | 43 +++++++++
>  board/nvidia/venice2/as3722_init.c            | 65 +++++++++-----
>  board/nvidia/venice2/as3722_init.h            | 43 ---------
>  board/toradex/apalis-tk1/as3722_init.c        | 85 ++++++++++--------
>  board/toradex/apalis-tk1/as3722_init.h        | 40 ---------
>  board/toradex/apalis_t30/Makefile             |  2 +
>  board/toradex/apalis_t30/apalis_t30-spl.c     | 34 +++++++
>  board/toradex/colibri_t30/Makefile            |  2 +
>  board/toradex/colibri_t30/colibri_t30-spl.c   | 34 +++++++
>  configs/beaver_defconfig                      |  3 -
>  configs/cei-tk1-som_defconfig                 |  3 -
>  configs/dalmore_defconfig                     |  3 -
>  configs/jetson-tk1_defconfig                  |  3 -
>  configs/nyan-big_defconfig                    |  3 -
>  configs/p2371-0000_defconfig                  |  3 -
>  configs/p2371-2180_defconfig                  |  3 -
>  configs/p2571_defconfig                       |  3 -
>  configs/p3450-0000_defconfig                  |  3 -
>  configs/venice2_defconfig                     |  3 -
>  doc/usage/cmd/ebtupdate.rst                   | 70 +++++++++++++++
>  drivers/pwm/tegra_pwm.c                       | 10 ++-
>  drivers/spi/tegra20_slink.c                   | 19 ++--
>  drivers/usb/gadget/Kconfig                    |  3 +
>  57 files changed, 1051 insertions(+), 309 deletions(-)  create mode 100644 arch/arm/include/asm/arch-tegra/crypto.h
>  rename arch/arm/mach-tegra/{tegra20 => }/crypto.c (68%)  create mode 100644 arch/arm/mach-tegra/tegra20/bct.c  create mode 100644 arch/arm/mach-tegra/tegra20/bct.h  delete mode 100644 arch/arm/mach-tegra/tegra20/crypto.h
>  create mode 100644 arch/arm/mach-tegra/tegra30/bct.c  create mode 100644 arch/arm/mach-tegra/tegra30/bct.h  create mode 100644 board/avionic-design/tec-ng/tec-ng-spl.c
>  create mode 100644 board/nvidia/beaver/beaver-spl.c  create mode 100644 board/nvidia/cardhu/cardhu-spl.c  delete mode 100644 board/nvidia/venice2/as3722_init.h
>  delete mode 100644 board/toradex/apalis-tk1/as3722_init.h
>  create mode 100644 board/toradex/apalis_t30/apalis_t30-spl.c
>  create mode 100644 board/toradex/colibri_t30/colibri_t30-spl.c
>  create mode 100644 doc/usage/cmd/ebtupdate.rst
>
> --
> 2.37.2
>

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH v4 00/16] General Tegra improvements
  2023-02-14 21:45 ` [PATCH v4 00/16] General Tegra improvements Tom Warren
  2023-02-15  7:26   ` Svyatoslav Ryhel
@ 2023-02-17  8:39   ` Svyatoslav Ryhel
  2023-02-17 15:57     ` Tom Warren
  1 sibling, 1 reply; 28+ messages in thread
From: Svyatoslav Ryhel @ 2023-02-17  8:39 UTC (permalink / raw)
  To: Tom Warren; +Cc: u-boot

You have NOT applied patch 13 ARM: tegra: expose crypto module for all
Tegra SoCs or applied it after patch 14 which brakes order. PTAL.

вт, 14 лют. 2023 р. о 23:45 Tom Warren <TWarren@nvidia.com> пише:
>
> <reducing audience>
>
> Svyatoslav,
>
> Taking TOT u-boot-tegra/master, and fast-forwarding to TOT u-boot/master, I then try to apply your 16 patch series and get the following failures (using patch). Note that I retargeted the crypto.c patch by hand to point to tegra20/crypto.c, which I believe one of your patches moves to arch/arm/tegra. PTAL.
>
> tom@tom-ThinkPad-T580:~/denx/uboot-tegra$ patch -p1 -i ~/Downloads/bundle-23303-Svyatoslav-16-v4.mbox  --dry-run
> checking file arch/arm/include/asm/arch-tegra30/clock-tables.h
> checking file arch/arm/mach-tegra/tegra30/clock.c
> checking file arch/arm/mach-tegra/tegra20/clock.c
> checking file arch/arm/mach-tegra/tegra30/clock.c
> checking file arch/arm/include/asm/arch-tegra/clock.h
> checking file arch/arm/mach-tegra/tegra114/clock.c
> checking file arch/arm/mach-tegra/tegra124/clock.c
> checking file arch/arm/mach-tegra/tegra20/clock.c
> checking file arch/arm/mach-tegra/tegra210/clock.c
> checking file arch/arm/mach-tegra/tegra30/clock.c
> checking file arch/arm/include/asm/arch-tegra/clock.h
> checking file arch/arm/mach-tegra/clock.c
> checking file arch/arm/mach-tegra/tegra30/clock.c
> Hunk #1 succeeded at 632 (offset -37 lines).
> checking file arch/arm/dts/tegra114.dtsi
> checking file arch/arm/dts/tegra124.dtsi
> checking file arch/arm/mach-tegra/tegra114/clock.c
> Hunk #1 succeeded at 745 (offset -37 lines).
> checking file arch/arm/mach-tegra/tegra124/clock.c
> Hunk #1 succeeded at 1170 (offset -38 lines).
> checking file arch/arm/mach-tegra/tegra20/clock.c
> Hunk #1 succeeded at 767 (offset -37 lines).
> checking file arch/arm/mach-tegra/tegra210/clock.c
> Hunk #1 succeeded at 1241 (offset -37 lines).
> checking file arch/arm/mach-tegra/tegra30/clock.c
> Hunk #1 succeeded at 806 (offset -78 lines).
> checking file drivers/pwm/tegra_pwm.c
> checking file drivers/spi/tegra20_slink.c
> checking file configs/beaver_defconfig
> checking file configs/cei-tk1-som_defconfig
> checking file configs/dalmore_defconfig
> checking file configs/jetson-tk1_defconfig
> checking file configs/nyan-big_defconfig
> checking file configs/p2371-0000_defconfig
> checking file configs/p2371-2180_defconfig
> checking file configs/p2571_defconfig
> checking file configs/p3450-0000_defconfig
> checking file configs/venice2_defconfig
> checking file drivers/usb/gadget/Kconfig
> checking file arch/arm/include/asm/arch-tegra/sys_proto.h
> checking file arch/arm/mach-tegra/board2.c
> checking file arch/arm/include/asm/arch-tegra/tegra_i2c.h
> checking file arch/arm/mach-tegra/cpu.h
> checking file arch/arm/mach-tegra/tegra124/cpu.c
> checking file arch/arm/mach-tegra/tegra30/cpu.c
> checking file board/nvidia/venice2/as3722_init.c
> checking file board/nvidia/venice2/as3722_init.h
> checking file board/toradex/apalis-tk1/as3722_init.c
> checking file board/toradex/apalis-tk1/as3722_init.h
> checking file arch/arm/mach-tegra/tegra30/Kconfig
> checking file arch/arm/mach-tegra/tegra30/cpu.c
> Hunk #1 FAILED at 15.
> Hunk #2 FAILED at 41.
> 2 out of 2 hunks FAILED
> checking file board/avionic-design/tec-ng/Makefile
> checking file board/avionic-design/tec-ng/tec-ng-spl.c
> checking file board/nvidia/beaver/Makefile
> checking file board/nvidia/beaver/beaver-spl.c
> checking file board/nvidia/cardhu/Makefile
> checking file board/nvidia/cardhu/cardhu-spl.c
> checking file board/toradex/apalis_t30/Makefile
> checking file board/toradex/apalis_t30/apalis_t30-spl.c
> checking file board/toradex/colibri_t30/Makefile
> checking file board/toradex/colibri_t30/colibri_t30-spl.c
> checking file arch/arm/mach-tegra/Kconfig
> checking file arch/arm/mach-tegra/Makefile
> checking file arch/arm/mach-tegra/crypto.c (renamed from arch/arm/mach-tegra/tegra20/crypto.c)
> checking file arch/arm/mach-tegra/crypto.h (renamed from arch/arm/mach-tegra/tegra20/crypto.h)
> checking file arch/arm/mach-tegra/tegra20/Kconfig
> checking file arch/arm/mach-tegra/tegra20/Makefile
> checking file arch/arm/include/asm/arch-tegra/crypto.h
> can't find file to patch at input line 3811
> Perhaps you used the wrong -p or --strip option?
> The text leading up to this was:
> --------------------------
> |diff --git a/arch/arm/mach-tegra/crypto.c b/arch/arm/mach-tegra/crypto.c
> |index 1efaa5c3ec..893da35e0b 100644
> |--- a/arch/arm/mach-tegra/crypto.c
> |+++ b/arch/arm/mach-tegra/crypto.c
> --------------------------
> File to patch: arch/arm/mach-tegra/tegra20/crypto.c
> checking file arch/arm/mach-tegra/tegra20/crypto.c
> The next patch would delete the file arch/arm/mach-tegra/crypto.h,
> which does not exist!  Assume -R? [n]
> Apply anyway? [n]
> Skipping patch.
> 1 out of 1 hunk ignored
> checking file arch/arm/mach-tegra/Kconfig
> Hunk #1 succeeded at 224 (offset -5 lines).
> checking file arch/arm/mach-tegra/tegra30/Makefile
> checking file arch/arm/mach-tegra/tegra30/bct.c
> checking file arch/arm/mach-tegra/tegra30/bct.h
> checking file arch/arm/mach-tegra/Kconfig
> Hunk #1 FAILED at 231.
> 1 out of 1 hunk FAILED
> checking file arch/arm/mach-tegra/tegra20/Makefile
> checking file arch/arm/mach-tegra/tegra20/bct.c
> checking file arch/arm/mach-tegra/tegra20/bct.h
> checking file doc/usage/cmd/ebtupdate.rst
> tom@tom-ThinkPad-T580:~/denx/uboot-tegra$
>
> -----Original Message-----
> From: Svyatoslav Ryhel <clamor95@gmail.com>
> Sent: Tuesday, February 14, 2023 10:35 AM
> To: Tom Warren <twarren@nvidia.com>; Marcel Ziswiler <marcel.ziswiler@toradex.com>; Allen Martin <amartin@nvidia.com>; Jagan Teki <jagan@amarulasolutions.com>; Lukasz Majewski <lukma@denx.de>; Marek Vasut <marex@denx.de>; Svyatoslav Ryhel <clamor95@gmail.com>; Ramin Khonsari <raminterex@yahoo.com>; Thierry Reding <thierry.reding@gmail.com>; Maxim Schwalm <maxim.schwalm@gmail.com>; Dmitry Osipenko <digetx@gmail.com>; Simon Glass <sjg@chromium.org>
> Cc: u-boot@lists.denx.de
> Subject: [PATCH v4 00/16] General Tegra improvements
>
> External email: Use caution opening links or attachments
>
>
> List of changes in patch set:
>  - add missing EXTPERIPH clocks for t30
>  - swap host1x and disp1 clock parents (as they should be)
>  - add clk_id_to_pll_id and clock_decode_pair helpers to use
>    dts deeper (in tegra clocks often go in pair child - parent)
>  - include PLLD setup in T30 (DISP1 may use it as parent on
>    some devices)
>  - fix Tegra PWM parent clock inline with linux
>  - Tegra SLINK: patch to accept any word length (unlike 8bit
>    aligned which was before)
>  - provide default USB gadget setup for existing Nvidia boards
>  - add late init function to be able to configure pre-boot stage
>    (like uncovering serial number or setting mac address)
>  - create common pre-dm i2c write for PMIC (used on T30 and T124
>    to configure basic PMIC voltages required to boot like cpu and
>    core voltages)
>  - expose crypto module for all Tegra SoCs and implement BCT patching
>    (ability to update bootloader from u-boot on production devices
>    without need in host PC)
>
> ---
> Changelog from v3
>  - added tested-by
>
> Changelog from v2
>  - fixed T114 TEGRA114_CLK_PLL_E_OUT0
>  - adjusted pre-dm i2c write commit description
>  - added description file for ebtupdate command
>  - minor improvements of bct.c comments
>
> Changelog from v1
>  - rebased to latest u-boot master
>  - PLLD setup for T30 moved specifically into T30 area
> ---
>
> Maxim Schwalm (1):
>   ARM: tegra: provide default USB gadget setup
>
> Ramin Khonsari (1):
>   ARM: tegra30: implement BCT patching
>
> Svyatoslav Ryhel (14):
>   tegra30: clock: add EXTPERIPH
>   ARM: t20/t30: swap host1x and disp1 clock parents
>   ARM: tegra: clock: add clk_id_to_pll_id helper
>   ARM: tegra: clock: add clock_decode_pair helper
>   ARM: tegra30: add PLLD to pll setup
>   ARM: tegra: Fix Tegra PWM parent clock
>   spi: tegra20_slink: accept any word length
>   ARM: tegra: add late init support
>   ARM: tegra: create common pre-dm i2c write
>   board: tegra124: switch to updated pre-dm i2c write
>   board: tegra30: switch to updated pre-dm i2c write
>   ARM: tegra: expose crypto module for all Tegra SoCs
>   ARM: tegra: crypto: extend crypto functional
>   ARM: tegra20: implement BCT patching
>
>  arch/arm/dts/tegra114.dtsi                    |  2 +-
>  arch/arm/dts/tegra124.dtsi                    |  2 +-
>  arch/arm/include/asm/arch-tegra/clock.h       | 21 +++++
>  arch/arm/include/asm/arch-tegra/crypto.h      | 47 ++++++++++
>  arch/arm/include/asm/arch-tegra/sys_proto.h   |  6 ++
>  arch/arm/include/asm/arch-tegra/tegra_i2c.h   | 17 ++++
>  .../include/asm/arch-tegra30/clock-tables.h   |  6 +-
>  arch/arm/mach-tegra/Kconfig                   | 14 +++
>  arch/arm/mach-tegra/Makefile                  |  1 +
>  arch/arm/mach-tegra/board2.c                  |  2 +
>  arch/arm/mach-tegra/clock.c                   | 23 +++++
>  arch/arm/mach-tegra/cpu.h                     |  1 -
>  arch/arm/mach-tegra/{tegra20 => }/crypto.c    | 63 +++++++++----
>  arch/arm/mach-tegra/tegra114/clock.c          | 39 +++++++-
>  arch/arm/mach-tegra/tegra124/clock.c          | 40 ++++++++-
>  arch/arm/mach-tegra/tegra124/cpu.c            |  4 +
>  arch/arm/mach-tegra/tegra20/Kconfig           |  1 +
>  arch/arm/mach-tegra/tegra20/Makefile          |  7 +-
>  arch/arm/mach-tegra/tegra20/bct.c             | 79 ++++++++++++++++
>  arch/arm/mach-tegra/tegra20/bct.h             | 42 +++++++++
>  arch/arm/mach-tegra/tegra20/clock.c           | 43 ++++++++-
>  arch/arm/mach-tegra/tegra20/crypto.h          | 19 ----
>  arch/arm/mach-tegra/tegra210/clock.c          | 39 +++++++-
>  arch/arm/mach-tegra/tegra30/Kconfig           |  8 --
>  arch/arm/mach-tegra/tegra30/Makefile          |  1 +
>  arch/arm/mach-tegra/tegra30/bct.c             | 79 ++++++++++++++++
>  arch/arm/mach-tegra/tegra30/bct.h             | 42 +++++++++
>  arch/arm/mach-tegra/tegra30/clock.c           | 90 +++++++++++++++++--
>  arch/arm/mach-tegra/tegra30/cpu.c             | 55 +-----------
>  board/avionic-design/tec-ng/Makefile          |  4 +-
>  board/avionic-design/tec-ng/tec-ng-spl.c      | 34 +++++++
>  board/nvidia/beaver/Makefile                  |  2 +
>  board/nvidia/beaver/beaver-spl.c              | 43 +++++++++
>  board/nvidia/cardhu/Makefile                  |  4 +-
>  board/nvidia/cardhu/cardhu-spl.c              | 43 +++++++++
>  board/nvidia/venice2/as3722_init.c            | 65 +++++++++-----
>  board/nvidia/venice2/as3722_init.h            | 43 ---------
>  board/toradex/apalis-tk1/as3722_init.c        | 85 ++++++++++--------
>  board/toradex/apalis-tk1/as3722_init.h        | 40 ---------
>  board/toradex/apalis_t30/Makefile             |  2 +
>  board/toradex/apalis_t30/apalis_t30-spl.c     | 34 +++++++
>  board/toradex/colibri_t30/Makefile            |  2 +
>  board/toradex/colibri_t30/colibri_t30-spl.c   | 34 +++++++
>  configs/beaver_defconfig                      |  3 -
>  configs/cei-tk1-som_defconfig                 |  3 -
>  configs/dalmore_defconfig                     |  3 -
>  configs/jetson-tk1_defconfig                  |  3 -
>  configs/nyan-big_defconfig                    |  3 -
>  configs/p2371-0000_defconfig                  |  3 -
>  configs/p2371-2180_defconfig                  |  3 -
>  configs/p2571_defconfig                       |  3 -
>  configs/p3450-0000_defconfig                  |  3 -
>  configs/venice2_defconfig                     |  3 -
>  doc/usage/cmd/ebtupdate.rst                   | 70 +++++++++++++++
>  drivers/pwm/tegra_pwm.c                       | 10 ++-
>  drivers/spi/tegra20_slink.c                   | 19 ++--
>  drivers/usb/gadget/Kconfig                    |  3 +
>  57 files changed, 1051 insertions(+), 309 deletions(-)  create mode 100644 arch/arm/include/asm/arch-tegra/crypto.h
>  rename arch/arm/mach-tegra/{tegra20 => }/crypto.c (68%)  create mode 100644 arch/arm/mach-tegra/tegra20/bct.c  create mode 100644 arch/arm/mach-tegra/tegra20/bct.h  delete mode 100644 arch/arm/mach-tegra/tegra20/crypto.h
>  create mode 100644 arch/arm/mach-tegra/tegra30/bct.c  create mode 100644 arch/arm/mach-tegra/tegra30/bct.h  create mode 100644 board/avionic-design/tec-ng/tec-ng-spl.c
>  create mode 100644 board/nvidia/beaver/beaver-spl.c  create mode 100644 board/nvidia/cardhu/cardhu-spl.c  delete mode 100644 board/nvidia/venice2/as3722_init.h
>  delete mode 100644 board/toradex/apalis-tk1/as3722_init.h
>  create mode 100644 board/toradex/apalis_t30/apalis_t30-spl.c
>  create mode 100644 board/toradex/colibri_t30/colibri_t30-spl.c
>  create mode 100644 doc/usage/cmd/ebtupdate.rst
>
> --
> 2.37.2
>

^ permalink raw reply	[flat|nested] 28+ messages in thread

* RE: [PATCH v4 00/16] General Tegra improvements
  2023-02-17  8:39   ` Svyatoslav Ryhel
@ 2023-02-17 15:57     ` Tom Warren
  2023-02-17 16:07       ` Svyatoslav Ryhel
  0 siblings, 1 reply; 28+ messages in thread
From: Tom Warren @ 2023-02-17 15:57 UTC (permalink / raw)
  To: Svyatoslav Ryhel; +Cc: u-boot

[-- Attachment #1: Type: text/plain, Size: 13584 bytes --]

I've got a bundle with your 16 patches, created using PatchWork/U-Boot, and the patches are ordered correctly within that bundle. Attached here - see if it works for you.

Tom

-----Original Message-----
From: Svyatoslav Ryhel <clamor95@gmail.com> 
Sent: Friday, February 17, 2023 1:39 AM
To: Tom Warren <TWarren@nvidia.com>
Cc: u-boot@lists.denx.de
Subject: Re: [PATCH v4 00/16] General Tegra improvements

External email: Use caution opening links or attachments


You have NOT applied patch 13 ARM: tegra: expose crypto module for all Tegra SoCs or applied it after patch 14 which brakes order. PTAL.

вт, 14 лют. 2023 р. о 23:45 Tom Warren <TWarren@nvidia.com> пише:
>
> <reducing audience>
>
> Svyatoslav,
>
> Taking TOT u-boot-tegra/master, and fast-forwarding to TOT u-boot/master, I then try to apply your 16 patch series and get the following failures (using patch). Note that I retargeted the crypto.c patch by hand to point to tegra20/crypto.c, which I believe one of your patches moves to arch/arm/tegra. PTAL.
>
> tom@tom-ThinkPad-T580:~/denx/uboot-tegra$ patch -p1 -i 
> ~/Downloads/bundle-23303-Svyatoslav-16-v4.mbox  --dry-run checking 
> file arch/arm/include/asm/arch-tegra30/clock-tables.h
> checking file arch/arm/mach-tegra/tegra30/clock.c
> checking file arch/arm/mach-tegra/tegra20/clock.c
> checking file arch/arm/mach-tegra/tegra30/clock.c
> checking file arch/arm/include/asm/arch-tegra/clock.h
> checking file arch/arm/mach-tegra/tegra114/clock.c
> checking file arch/arm/mach-tegra/tegra124/clock.c
> checking file arch/arm/mach-tegra/tegra20/clock.c
> checking file arch/arm/mach-tegra/tegra210/clock.c
> checking file arch/arm/mach-tegra/tegra30/clock.c
> checking file arch/arm/include/asm/arch-tegra/clock.h
> checking file arch/arm/mach-tegra/clock.c checking file 
> arch/arm/mach-tegra/tegra30/clock.c
> Hunk #1 succeeded at 632 (offset -37 lines).
> checking file arch/arm/dts/tegra114.dtsi checking file 
> arch/arm/dts/tegra124.dtsi checking file 
> arch/arm/mach-tegra/tegra114/clock.c
> Hunk #1 succeeded at 745 (offset -37 lines).
> checking file arch/arm/mach-tegra/tegra124/clock.c
> Hunk #1 succeeded at 1170 (offset -38 lines).
> checking file arch/arm/mach-tegra/tegra20/clock.c
> Hunk #1 succeeded at 767 (offset -37 lines).
> checking file arch/arm/mach-tegra/tegra210/clock.c
> Hunk #1 succeeded at 1241 (offset -37 lines).
> checking file arch/arm/mach-tegra/tegra30/clock.c
> Hunk #1 succeeded at 806 (offset -78 lines).
> checking file drivers/pwm/tegra_pwm.c
> checking file drivers/spi/tegra20_slink.c checking file 
> configs/beaver_defconfig checking file configs/cei-tk1-som_defconfig 
> checking file configs/dalmore_defconfig checking file 
> configs/jetson-tk1_defconfig checking file configs/nyan-big_defconfig 
> checking file configs/p2371-0000_defconfig checking file 
> configs/p2371-2180_defconfig checking file configs/p2571_defconfig 
> checking file configs/p3450-0000_defconfig checking file 
> configs/venice2_defconfig checking file drivers/usb/gadget/Kconfig 
> checking file arch/arm/include/asm/arch-tegra/sys_proto.h
> checking file arch/arm/mach-tegra/board2.c checking file 
> arch/arm/include/asm/arch-tegra/tegra_i2c.h
> checking file arch/arm/mach-tegra/cpu.h checking file 
> arch/arm/mach-tegra/tegra124/cpu.c
> checking file arch/arm/mach-tegra/tegra30/cpu.c checking file 
> board/nvidia/venice2/as3722_init.c
> checking file board/nvidia/venice2/as3722_init.h
> checking file board/toradex/apalis-tk1/as3722_init.c
> checking file board/toradex/apalis-tk1/as3722_init.h
> checking file arch/arm/mach-tegra/tegra30/Kconfig
> checking file arch/arm/mach-tegra/tegra30/cpu.c Hunk #1 FAILED at 15.
> Hunk #2 FAILED at 41.
> 2 out of 2 hunks FAILED
> checking file board/avionic-design/tec-ng/Makefile
> checking file board/avionic-design/tec-ng/tec-ng-spl.c
> checking file board/nvidia/beaver/Makefile checking file 
> board/nvidia/beaver/beaver-spl.c checking file 
> board/nvidia/cardhu/Makefile checking file 
> board/nvidia/cardhu/cardhu-spl.c checking file 
> board/toradex/apalis_t30/Makefile checking file 
> board/toradex/apalis_t30/apalis_t30-spl.c
> checking file board/toradex/colibri_t30/Makefile
> checking file board/toradex/colibri_t30/colibri_t30-spl.c
> checking file arch/arm/mach-tegra/Kconfig checking file 
> arch/arm/mach-tegra/Makefile checking file 
> arch/arm/mach-tegra/crypto.c (renamed from 
> arch/arm/mach-tegra/tegra20/crypto.c)
> checking file arch/arm/mach-tegra/crypto.h (renamed from 
> arch/arm/mach-tegra/tegra20/crypto.h)
> checking file arch/arm/mach-tegra/tegra20/Kconfig
> checking file arch/arm/mach-tegra/tegra20/Makefile
> checking file arch/arm/include/asm/arch-tegra/crypto.h
> can't find file to patch at input line 3811 Perhaps you used the wrong 
> -p or --strip option?
> The text leading up to this was:
> --------------------------
> |diff --git a/arch/arm/mach-tegra/crypto.c 
> |b/arch/arm/mach-tegra/crypto.c index 1efaa5c3ec..893da35e0b 100644
> |--- a/arch/arm/mach-tegra/crypto.c
> |+++ b/arch/arm/mach-tegra/crypto.c
> --------------------------
> File to patch: arch/arm/mach-tegra/tegra20/crypto.c
> checking file arch/arm/mach-tegra/tegra20/crypto.c
> The next patch would delete the file arch/arm/mach-tegra/crypto.h, 
> which does not exist!  Assume -R? [n] Apply anyway? [n] Skipping 
> patch.
> 1 out of 1 hunk ignored
> checking file arch/arm/mach-tegra/Kconfig Hunk #1 succeeded at 224 
> (offset -5 lines).
> checking file arch/arm/mach-tegra/tegra30/Makefile
> checking file arch/arm/mach-tegra/tegra30/bct.c checking file 
> arch/arm/mach-tegra/tegra30/bct.h checking file 
> arch/arm/mach-tegra/Kconfig Hunk #1 FAILED at 231.
> 1 out of 1 hunk FAILED
> checking file arch/arm/mach-tegra/tegra20/Makefile
> checking file arch/arm/mach-tegra/tegra20/bct.c checking file 
> arch/arm/mach-tegra/tegra20/bct.h checking file 
> doc/usage/cmd/ebtupdate.rst tom@tom-ThinkPad-T580:~/denx/uboot-tegra$
>
> -----Original Message-----
> From: Svyatoslav Ryhel <clamor95@gmail.com>
> Sent: Tuesday, February 14, 2023 10:35 AM
> To: Tom Warren <twarren@nvidia.com>; Marcel Ziswiler 
> <marcel.ziswiler@toradex.com>; Allen Martin <amartin@nvidia.com>; 
> Jagan Teki <jagan@amarulasolutions.com>; Lukasz Majewski 
> <lukma@denx.de>; Marek Vasut <marex@denx.de>; Svyatoslav Ryhel 
> <clamor95@gmail.com>; Ramin Khonsari <raminterex@yahoo.com>; Thierry 
> Reding <thierry.reding@gmail.com>; Maxim Schwalm 
> <maxim.schwalm@gmail.com>; Dmitry Osipenko <digetx@gmail.com>; Simon 
> Glass <sjg@chromium.org>
> Cc: u-boot@lists.denx.de
> Subject: [PATCH v4 00/16] General Tegra improvements
>
> External email: Use caution opening links or attachments
>
>
> List of changes in patch set:
>  - add missing EXTPERIPH clocks for t30
>  - swap host1x and disp1 clock parents (as they should be)
>  - add clk_id_to_pll_id and clock_decode_pair helpers to use
>    dts deeper (in tegra clocks often go in pair child - parent)
>  - include PLLD setup in T30 (DISP1 may use it as parent on
>    some devices)
>  - fix Tegra PWM parent clock inline with linux
>  - Tegra SLINK: patch to accept any word length (unlike 8bit
>    aligned which was before)
>  - provide default USB gadget setup for existing Nvidia boards
>  - add late init function to be able to configure pre-boot stage
>    (like uncovering serial number or setting mac address)
>  - create common pre-dm i2c write for PMIC (used on T30 and T124
>    to configure basic PMIC voltages required to boot like cpu and
>    core voltages)
>  - expose crypto module for all Tegra SoCs and implement BCT patching
>    (ability to update bootloader from u-boot on production devices
>    without need in host PC)
>
> ---
> Changelog from v3
>  - added tested-by
>
> Changelog from v2
>  - fixed T114 TEGRA114_CLK_PLL_E_OUT0
>  - adjusted pre-dm i2c write commit description
>  - added description file for ebtupdate command
>  - minor improvements of bct.c comments
>
> Changelog from v1
>  - rebased to latest u-boot master
>  - PLLD setup for T30 moved specifically into T30 area
> ---
>
> Maxim Schwalm (1):
>   ARM: tegra: provide default USB gadget setup
>
> Ramin Khonsari (1):
>   ARM: tegra30: implement BCT patching
>
> Svyatoslav Ryhel (14):
>   tegra30: clock: add EXTPERIPH
>   ARM: t20/t30: swap host1x and disp1 clock parents
>   ARM: tegra: clock: add clk_id_to_pll_id helper
>   ARM: tegra: clock: add clock_decode_pair helper
>   ARM: tegra30: add PLLD to pll setup
>   ARM: tegra: Fix Tegra PWM parent clock
>   spi: tegra20_slink: accept any word length
>   ARM: tegra: add late init support
>   ARM: tegra: create common pre-dm i2c write
>   board: tegra124: switch to updated pre-dm i2c write
>   board: tegra30: switch to updated pre-dm i2c write
>   ARM: tegra: expose crypto module for all Tegra SoCs
>   ARM: tegra: crypto: extend crypto functional
>   ARM: tegra20: implement BCT patching
>
>  arch/arm/dts/tegra114.dtsi                    |  2 +-
>  arch/arm/dts/tegra124.dtsi                    |  2 +-
>  arch/arm/include/asm/arch-tegra/clock.h       | 21 +++++
>  arch/arm/include/asm/arch-tegra/crypto.h      | 47 ++++++++++
>  arch/arm/include/asm/arch-tegra/sys_proto.h   |  6 ++
>  arch/arm/include/asm/arch-tegra/tegra_i2c.h   | 17 ++++
>  .../include/asm/arch-tegra30/clock-tables.h   |  6 +-
>  arch/arm/mach-tegra/Kconfig                   | 14 +++
>  arch/arm/mach-tegra/Makefile                  |  1 +
>  arch/arm/mach-tegra/board2.c                  |  2 +
>  arch/arm/mach-tegra/clock.c                   | 23 +++++
>  arch/arm/mach-tegra/cpu.h                     |  1 -
>  arch/arm/mach-tegra/{tegra20 => }/crypto.c    | 63 +++++++++----
>  arch/arm/mach-tegra/tegra114/clock.c          | 39 +++++++-
>  arch/arm/mach-tegra/tegra124/clock.c          | 40 ++++++++-
>  arch/arm/mach-tegra/tegra124/cpu.c            |  4 +
>  arch/arm/mach-tegra/tegra20/Kconfig           |  1 +
>  arch/arm/mach-tegra/tegra20/Makefile          |  7 +-
>  arch/arm/mach-tegra/tegra20/bct.c             | 79 ++++++++++++++++
>  arch/arm/mach-tegra/tegra20/bct.h             | 42 +++++++++
>  arch/arm/mach-tegra/tegra20/clock.c           | 43 ++++++++-
>  arch/arm/mach-tegra/tegra20/crypto.h          | 19 ----
>  arch/arm/mach-tegra/tegra210/clock.c          | 39 +++++++-
>  arch/arm/mach-tegra/tegra30/Kconfig           |  8 --
>  arch/arm/mach-tegra/tegra30/Makefile          |  1 +
>  arch/arm/mach-tegra/tegra30/bct.c             | 79 ++++++++++++++++
>  arch/arm/mach-tegra/tegra30/bct.h             | 42 +++++++++
>  arch/arm/mach-tegra/tegra30/clock.c           | 90 +++++++++++++++++--
>  arch/arm/mach-tegra/tegra30/cpu.c             | 55 +-----------
>  board/avionic-design/tec-ng/Makefile          |  4 +-
>  board/avionic-design/tec-ng/tec-ng-spl.c      | 34 +++++++
>  board/nvidia/beaver/Makefile                  |  2 +
>  board/nvidia/beaver/beaver-spl.c              | 43 +++++++++
>  board/nvidia/cardhu/Makefile                  |  4 +-
>  board/nvidia/cardhu/cardhu-spl.c              | 43 +++++++++
>  board/nvidia/venice2/as3722_init.c            | 65 +++++++++-----
>  board/nvidia/venice2/as3722_init.h            | 43 ---------
>  board/toradex/apalis-tk1/as3722_init.c        | 85 ++++++++++--------
>  board/toradex/apalis-tk1/as3722_init.h        | 40 ---------
>  board/toradex/apalis_t30/Makefile             |  2 +
>  board/toradex/apalis_t30/apalis_t30-spl.c     | 34 +++++++
>  board/toradex/colibri_t30/Makefile            |  2 +
>  board/toradex/colibri_t30/colibri_t30-spl.c   | 34 +++++++
>  configs/beaver_defconfig                      |  3 -
>  configs/cei-tk1-som_defconfig                 |  3 -
>  configs/dalmore_defconfig                     |  3 -
>  configs/jetson-tk1_defconfig                  |  3 -
>  configs/nyan-big_defconfig                    |  3 -
>  configs/p2371-0000_defconfig                  |  3 -
>  configs/p2371-2180_defconfig                  |  3 -
>  configs/p2571_defconfig                       |  3 -
>  configs/p3450-0000_defconfig                  |  3 -
>  configs/venice2_defconfig                     |  3 -
>  doc/usage/cmd/ebtupdate.rst                   | 70 +++++++++++++++
>  drivers/pwm/tegra_pwm.c                       | 10 ++-
>  drivers/spi/tegra20_slink.c                   | 19 ++--
>  drivers/usb/gadget/Kconfig                    |  3 +
>  57 files changed, 1051 insertions(+), 309 deletions(-)  create mode 
> 100644 arch/arm/include/asm/arch-tegra/crypto.h
>  rename arch/arm/mach-tegra/{tegra20 => }/crypto.c (68%)  create mode 
> 100644 arch/arm/mach-tegra/tegra20/bct.c  create mode 100644 
> arch/arm/mach-tegra/tegra20/bct.h  delete mode 100644 
> arch/arm/mach-tegra/tegra20/crypto.h
>  create mode 100644 arch/arm/mach-tegra/tegra30/bct.c  create mode 
> 100644 arch/arm/mach-tegra/tegra30/bct.h  create mode 100644 
> board/avionic-design/tec-ng/tec-ng-spl.c
>  create mode 100644 board/nvidia/beaver/beaver-spl.c  create mode 
> 100644 board/nvidia/cardhu/cardhu-spl.c  delete mode 100644 
> board/nvidia/venice2/as3722_init.h
>  delete mode 100644 board/toradex/apalis-tk1/as3722_init.h
>  create mode 100644 board/toradex/apalis_t30/apalis_t30-spl.c
>  create mode 100644 board/toradex/colibri_t30/colibri_t30-spl.c
>  create mode 100644 doc/usage/cmd/ebtupdate.rst
>
> --
> 2.37.2
>

[-- Attachment #2: bundle-23303-Svyatoslav-16-v4.mbox --]
[-- Type: application/octet-stream, Size: 187572 bytes --]

From patchwork Tue Feb 14 17:35:23 2023
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Svyatoslav Ryhel <clamor95@gmail.com>
X-Patchwork-Id: 1742536
X-Patchwork-Delegate: twarren@nvidia.com
Return-Path: <u-boot-bounces@lists.denx.de>
X-Original-To: incoming@patchwork.ozlabs.org
Delivered-To: patchwork-incoming@legolas.ozlabs.org
Authentication-Results: legolas.ozlabs.org;
 spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de
 (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de;
 envelope-from=u-boot-bounces@lists.denx.de; receiver=<UNKNOWN>)
Authentication-Results: legolas.ozlabs.org;
	dkim=pass (2048-bit key;
 unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256
 header.s=20210112 header.b=AMEJXZoc;
	dkim-atps=neutral
Received: from phobos.denx.de (phobos.denx.de
 [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384)
	(No client certificate requested)
	by legolas.ozlabs.org (Postfix) with ESMTPS id 4PGT0L0KFCz23r4
	for <incoming@patchwork.ozlabs.org>; Wed, 15 Feb 2023 04:36:34 +1100 (AEDT)
Received: from h2850616.stratoserver.net (localhost [IPv6:::1])
	by phobos.denx.de (Postfix) with ESMTP id E81A185994;
	Tue, 14 Feb 2023 18:36:12 +0100 (CET)
Authentication-Results: phobos.denx.de;
 dmarc=pass (p=none dis=none) header.from=gmail.com
Authentication-Results: phobos.denx.de;
 spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de
Authentication-Results: phobos.denx.de;
	dkim=pass (2048-bit key;
 unprotected) header.d=gmail.com header.i=@gmail.com header.b="AMEJXZoc";
	dkim-atps=neutral
Received: by phobos.denx.de (Postfix, from userid 109)
 id 39E5D859E0; Tue, 14 Feb 2023 18:36:08 +0100 (CET)
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de
X-Spam-Level: 
X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,
 DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT,
 FREEMAIL_FROM,SPF_HELO_NONE,SPF_PASS autolearn=unavailable
 autolearn_force=no version=3.4.2
Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com
 [IPv6:2a00:1450:4864:20::333])
 (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits))
 (No client certificate requested)
 by phobos.denx.de (Postfix) with ESMTPS id 263E185971
 for <u-boot@lists.denx.de>; Tue, 14 Feb 2023 18:36:01 +0100 (CET)
Authentication-Results: phobos.denx.de;
 dmarc=pass (p=none dis=none) header.from=gmail.com
Authentication-Results: phobos.denx.de;
 spf=pass smtp.mailfrom=clamor95@gmail.com
Received: by mail-wm1-x333.google.com with SMTP id
 bg5-20020a05600c3c8500b003e00c739ce4so12182002wmb.5
 for <u-boot@lists.denx.de>; Tue, 14 Feb 2023 09:36:01 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=Cr+rjleUafv9OkMSAU77wYaeUGyOd4w5Jfsech5484E=;
 b=AMEJXZoc1LvJaBbQ6/wgAk87qZtYqmdv0EmCKxXmJr71KjQuqks+Se6IbOC/5E+KQW
 0dM8wSdBVXwOEYOcIl+QlBnBa4qkCQXxPaZns4cllHCdIapuOjHhRd3ATU7hs5GlqMME
 9/QS8hVL35fKNMIwF75LrGe27t1WBRux2fv9lEB1jnsM6Cbd4w/xI8IDMoG4kBNUXWVI
 tXXL6DZ0AtNVt6gsryEis4/OuVDVrqkI8jq24+Nu/wJucmv4JR9v/lf4jz8vPBIU6FuF
 L1jBmz+OJYo0hB+GmyRopZWANaVqpAtAwuuWeofdvCfqEEzjRKVznbmTMZGb9x7z5YX5
 KVwQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=Cr+rjleUafv9OkMSAU77wYaeUGyOd4w5Jfsech5484E=;
 b=GLbl8vVljhCe8uIKZtxe91mQb7Yj9M6EcXBgOic4IQB0GuAHSZsdxErmyWErA+RhgG
 pyACJVA9amHLNYlDvRU8fAkcrpHZSsoG4EKx9B60Ca2HqwZzVIsnuYz8xE1/OiBGC+iN
 0Q7mmHkofww9tC/xsPousKwCoaJDwZP7sLeZonsSn/nalCfHChADo6Lh7Cvj+pqSG1c1
 LlHGrm+Ag0gEW4XdWJnkvjk6f3YsIuAgoBD+3fZc3A83HH7X37ZV6MNLFe67VOGLEKW5
 UBImDUEuXPKapwKH1XI4ilDpP/oN8eflJKgWHjkGaxekUpOT1T/3x27xObdU3sxHF+25
 D+zg==
X-Gm-Message-State: AO0yUKVTmya+VYwRifUErsHe+XcVpyB/glx4dTFMBRYL3v4UCQhmCHTu
 bV/HiJn21rkmVLYcKALOCIU=
X-Google-Smtp-Source: 
 AK7set/qMDoDVSUVs6I98GXjl2auzfM0LSz4XuMc+oRVzdODvdULr+JnDm0QAXIRCVPztkDuG4keTw==
X-Received: by 2002:a05:600c:920:b0:3dc:5362:134a with SMTP id
 m32-20020a05600c092000b003dc5362134amr2763842wmp.9.1676396160309;
 Tue, 14 Feb 2023 09:36:00 -0800 (PST)
Received: from xeon.. ([188.163.112.76]) by smtp.gmail.com with ESMTPSA id
 m23-20020a7bca57000000b003de8a1b06c0sm20787829wml.7.2023.02.14.09.35.59
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 14 Feb 2023 09:36:00 -0800 (PST)
From: Svyatoslav Ryhel <clamor95@gmail.com>
To: Tom Warren <twarren@nvidia.com>,
 Marcel Ziswiler <marcel.ziswiler@toradex.com>,
 Allen Martin <amartin@nvidia.com>, Jagan Teki <jagan@amarulasolutions.com>,
 Lukasz Majewski <lukma@denx.de>, Marek Vasut <marex@denx.de>,
 Svyatoslav Ryhel <clamor95@gmail.com>,
 Ramin Khonsari <raminterex@yahoo.com>,
 Thierry Reding <thierry.reding@gmail.com>,
 Maxim Schwalm <maxim.schwalm@gmail.com>,
 Dmitry Osipenko <digetx@gmail.com>, Simon Glass <sjg@chromium.org>
Cc: u-boot@lists.denx.de
Subject: [PATCH v4 01/16] tegra30: clock: add EXTPERIPH
Date: Tue, 14 Feb 2023 19:35:23 +0200
Message-Id: <20230214173538.6242-2-clamor95@gmail.com>
X-Mailer: git-send-email 2.37.2
In-Reply-To: <20230214173538.6242-1-clamor95@gmail.com>
References: <20230214173538.6242-1-clamor95@gmail.com>
MIME-Version: 1.0
X-BeenThere: u-boot@lists.denx.de
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: U-Boot discussion <u-boot.lists.denx.de>
List-Unsubscribe: <https://lists.denx.de/options/u-boot>,
 <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>
List-Archive: <https://lists.denx.de/pipermail/u-boot/>
List-Post: <mailto:u-boot@lists.denx.de>
List-Help: <mailto:u-boot-request@lists.denx.de?subject=help>
List-Subscribe: <https://lists.denx.de/listinfo/u-boot>,
 <mailto:u-boot-request@lists.denx.de?subject=subscribe>
Errors-To: u-boot-bounces@lists.denx.de
Sender: "U-Boot" <u-boot-bounces@lists.denx.de>
X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de
X-Virus-Status: Clean

This mappings were missing for some reason.

Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # LG P895 T30
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
 arch/arm/include/asm/arch-tegra30/clock-tables.h | 6 +++---
 arch/arm/mach-tegra/tegra30/clock.c              | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/arch/arm/include/asm/arch-tegra30/clock-tables.h b/arch/arm/include/asm/arch-tegra30/clock-tables.h
index 8588009c61..6c899ff64c 100644
--- a/arch/arm/include/asm/arch-tegra30/clock-tables.h
+++ b/arch/arm/include/asm/arch-tegra30/clock-tables.h
@@ -190,9 +190,9 @@ enum periph_id {
 	PERIPH_ID_ACTMON,
 
 	/* 24 */
-	PERIPH_ID_EX_RESERVED24,
-	PERIPH_ID_EX_RESERVED25,
-	PERIPH_ID_EX_RESERVED26,
+	PERIPH_ID_EXTPERIPH1,
+	PERIPH_ID_EXTPERIPH2,
+	PERIPH_ID_EXTPERIPH3,
 	PERIPH_ID_EX_RESERVED27,
 	PERIPH_ID_SATA,
 	PERIPH_ID_HDA,
diff --git a/arch/arm/mach-tegra/tegra30/clock.c b/arch/arm/mach-tegra/tegra30/clock.c
index 449b66e3b2..04ad5c504d 100644
--- a/arch/arm/mach-tegra/tegra30/clock.c
+++ b/arch/arm/mach-tegra/tegra30/clock.c
@@ -377,9 +377,9 @@ static s8 periph_id_to_internal_id[PERIPH_ID_COUNT] = {
 	PERIPHC_ACTMON,
 
 	/* 24 */
-	NONE(RESERVED24),
-	NONE(RESERVED25),
-	NONE(RESERVED26),
+	PERIPHC_EXTPERIPH1,
+	PERIPHC_EXTPERIPH2,
+	PERIPHC_EXTPERIPH3,
 	NONE(RESERVED27),
 	PERIPHC_SATA,
 	PERIPHC_HDA,

From patchwork Tue Feb 14 17:35:24 2023
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Svyatoslav Ryhel <clamor95@gmail.com>
X-Patchwork-Id: 1742537
X-Patchwork-Delegate: twarren@nvidia.com
Return-Path: <u-boot-bounces@lists.denx.de>
X-Original-To: incoming@patchwork.ozlabs.org
Delivered-To: patchwork-incoming@legolas.ozlabs.org
Authentication-Results: legolas.ozlabs.org;
 spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de
 (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de;
 envelope-from=u-boot-bounces@lists.denx.de; receiver=<UNKNOWN>)
Authentication-Results: legolas.ozlabs.org;
	dkim=pass (2048-bit key;
 unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256
 header.s=20210112 header.b=lubRXOTk;
	dkim-atps=neutral
Received: from phobos.denx.de (phobos.denx.de
 [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384)
	(No client certificate requested)
	by legolas.ozlabs.org (Postfix) with ESMTPS id 4PGT0X3WMrz23r4
	for <incoming@patchwork.ozlabs.org>; Wed, 15 Feb 2023 04:36:44 +1100 (AEDT)
Received: from h2850616.stratoserver.net (localhost [IPv6:::1])
	by phobos.denx.de (Postfix) with ESMTP id 01B6B859E6;
	Tue, 14 Feb 2023 18:36:17 +0100 (CET)
Authentication-Results: phobos.denx.de;
 dmarc=pass (p=none dis=none) header.from=gmail.com
Authentication-Results: phobos.denx.de;
 spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de
Authentication-Results: phobos.denx.de;
	dkim=pass (2048-bit key;
 unprotected) header.d=gmail.com header.i=@gmail.com header.b="lubRXOTk";
	dkim-atps=neutral
Received: by phobos.denx.de (Postfix, from userid 109)
 id E1FB68597A; Tue, 14 Feb 2023 18:36:07 +0100 (CET)
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de
X-Spam-Level: 
X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,
 DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT,
 FREEMAIL_FROM,SPF_HELO_NONE,SPF_PASS autolearn=unavailable
 autolearn_force=no version=3.4.2
Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com
 [IPv6:2a00:1450:4864:20::32c])
 (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits))
 (No client certificate requested)
 by phobos.denx.de (Postfix) with ESMTPS id 21C998597A
 for <u-boot@lists.denx.de>; Tue, 14 Feb 2023 18:36:02 +0100 (CET)
Authentication-Results: phobos.denx.de;
 dmarc=pass (p=none dis=none) header.from=gmail.com
Authentication-Results: phobos.denx.de;
 spf=pass smtp.mailfrom=clamor95@gmail.com
Received: by mail-wm1-x32c.google.com with SMTP id
 k8-20020a05600c1c8800b003dc57ea0dfeso14265371wms.0
 for <u-boot@lists.denx.de>; Tue, 14 Feb 2023 09:36:02 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=zBZrCCRRwH/zPlxhmVYOlj8yu5LBw8lTGHngQqzm/lU=;
 b=lubRXOTk057VJIutDzWhKMhzdS+yBDlrAtyM8TJVHLZ/ooazymWBokN4FYLcoBP/9q
 W66mulnj0Tp7b15RDi1kQX7AAh2C4ehTMH16UT/d6vCeKUwDcXWb0jgSFoBYaV79fy8z
 zMQl/WVpC/Fp7ADM82kMe5AOnA9JwToymodiGplIKFT8hBYfHMzAlWqV2elrga5dSJ0m
 2SM0pfweb7zDPy1GsNQCN0Ze38xnvK84UvnSMXtCGC+TeFF5C0JhJYXOsvqL2cUtwAqw
 +Vb8sItSbsU4z5WkFRsi6faI3AQa8xdSotb6tjUTRBJuUQdYJQzFqO9J3bdcBWznB9Vh
 J4jA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=zBZrCCRRwH/zPlxhmVYOlj8yu5LBw8lTGHngQqzm/lU=;
 b=J0iHIi3k6+9t7zJ0oqPm9SqcWIITT+dVq5hP10bNOV/CiVnZY7Y9PIYbWa5V5F66gS
 sX9ldD0b9IFtevcy2rCrasrbO1HYJ9LQW/gykFcIr5yXLmwyZ5GHp9gpdcu77ehd1YVk
 gjjxtXQrYyskXoqKB7C59V3nYS45GQ8+QscOSA3BYYbZ1lOMiRvVpHpoVEBakstLKJLb
 wLo3DbuEJbrGs1+oZ33CWtxZ98mBNmcEZRNvr71hnqH8MuBZ3WtVlxGoSqz6lu/QYzS8
 VEFeZ4GPrH0b8M1z3vwieU3i46ZmYUvtH0piBmrg7UJ2OdhfX/LeQGHKgI73BwsODUvE
 Hh/A==
X-Gm-Message-State: AO0yUKU3+xpwpG5Ioy3+7cXewGTkSUuJrSggzcGDUOeqPEILjpy1+wYF
 cucIUEf4G7OLPyva8KmljUU=
X-Google-Smtp-Source: 
 AK7set+dBva9sbecQE1QhSw3ZYaWxMWKNNNH4Qw2/Nqoeu6YexyfR9QhBsFMkay2FyhjCiDUoa1O4w==
X-Received: by 2002:a05:600c:492f:b0:3dc:440f:8e9d with SMTP id
 f47-20020a05600c492f00b003dc440f8e9dmr2721185wmp.0.1676396161416;
 Tue, 14 Feb 2023 09:36:01 -0800 (PST)
Received: from xeon.. ([188.163.112.76]) by smtp.gmail.com with ESMTPSA id
 m23-20020a7bca57000000b003de8a1b06c0sm20787829wml.7.2023.02.14.09.36.00
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 14 Feb 2023 09:36:01 -0800 (PST)
From: Svyatoslav Ryhel <clamor95@gmail.com>
To: Tom Warren <twarren@nvidia.com>,
 Marcel Ziswiler <marcel.ziswiler@toradex.com>,
 Allen Martin <amartin@nvidia.com>, Jagan Teki <jagan@amarulasolutions.com>,
 Lukasz Majewski <lukma@denx.de>, Marek Vasut <marex@denx.de>,
 Svyatoslav Ryhel <clamor95@gmail.com>,
 Ramin Khonsari <raminterex@yahoo.com>,
 Thierry Reding <thierry.reding@gmail.com>,
 Maxim Schwalm <maxim.schwalm@gmail.com>,
 Dmitry Osipenko <digetx@gmail.com>, Simon Glass <sjg@chromium.org>
Cc: u-boot@lists.denx.de
Subject: [PATCH v4 02/16] ARM: t20/t30: swap host1x and disp1 clock parents
Date: Tue, 14 Feb 2023 19:35:24 +0200
Message-Id: <20230214173538.6242-3-clamor95@gmail.com>
X-Mailer: git-send-email 2.37.2
In-Reply-To: <20230214173538.6242-1-clamor95@gmail.com>
References: <20230214173538.6242-1-clamor95@gmail.com>
MIME-Version: 1.0
X-BeenThere: u-boot@lists.denx.de
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: U-Boot discussion <u-boot.lists.denx.de>
List-Unsubscribe: <https://lists.denx.de/options/u-boot>,
 <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>
List-Archive: <https://lists.denx.de/pipermail/u-boot/>
List-Post: <mailto:u-boot@lists.denx.de>
List-Help: <mailto:u-boot-request@lists.denx.de?subject=help>
List-Subscribe: <https://lists.denx.de/listinfo/u-boot>,
 <mailto:u-boot-request@lists.denx.de?subject=subscribe>
Errors-To: u-boot-bounces@lists.denx.de
Sender: "U-Boot" <u-boot-bounces@lists.denx.de>
X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de
X-Virus-Status: Clean

According to mainline clock tables and TRM HOST1X
parent is PLLC, while DISP1 usually uses PLLP as
parent clock.

Tested-by: Andreas Westman Dorcsak <hedmoo@yahoo.com> # ASUS TF T30
Tested-by: Robert Eckelmann <longnoserob@gmail.com> # ASUS TF101 T20
Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # LG P895 T30
Tested-by: Thierry Reding <treding@nvidia.com> # Beaver T30
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 arch/arm/mach-tegra/tegra20/clock.c | 4 ++--
 arch/arm/mach-tegra/tegra30/clock.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/arm/mach-tegra/tegra20/clock.c b/arch/arm/mach-tegra/tegra20/clock.c
index 8c127430aa..0316073d1a 100644
--- a/arch/arm/mach-tegra/tegra20/clock.c
+++ b/arch/arm/mach-tegra/tegra20/clock.c
@@ -760,8 +760,8 @@ struct periph_clk_init periph_clk_init_table[] = {
 	{ PERIPH_ID_SBC2, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_SBC3, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_SBC4, CLOCK_ID_PERIPH },
-	{ PERIPH_ID_HOST1X, CLOCK_ID_PERIPH },
-	{ PERIPH_ID_DISP1, CLOCK_ID_CGENERAL },
+	{ PERIPH_ID_HOST1X, CLOCK_ID_CGENERAL },
+	{ PERIPH_ID_DISP1, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_NDFLASH, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_SDMMC1, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_SDMMC2, CLOCK_ID_PERIPH },
diff --git a/arch/arm/mach-tegra/tegra30/clock.c b/arch/arm/mach-tegra/tegra30/clock.c
index 04ad5c504d..e5c2fd542c 100644
--- a/arch/arm/mach-tegra/tegra30/clock.c
+++ b/arch/arm/mach-tegra/tegra30/clock.c
@@ -799,8 +799,8 @@ struct periph_clk_init periph_clk_init_table[] = {
 	{ PERIPH_ID_SBC4, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_SBC5, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_SBC6, CLOCK_ID_PERIPH },
-	{ PERIPH_ID_HOST1X, CLOCK_ID_PERIPH },
-	{ PERIPH_ID_DISP1, CLOCK_ID_CGENERAL },
+	{ PERIPH_ID_HOST1X, CLOCK_ID_CGENERAL },
+	{ PERIPH_ID_DISP1, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_NDFLASH, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_SDMMC1, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_SDMMC2, CLOCK_ID_PERIPH },

From patchwork Tue Feb 14 17:35:25 2023
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Svyatoslav Ryhel <clamor95@gmail.com>
X-Patchwork-Id: 1742538
X-Patchwork-Delegate: twarren@nvidia.com
Return-Path: <u-boot-bounces@lists.denx.de>
X-Original-To: incoming@patchwork.ozlabs.org
Delivered-To: patchwork-incoming@legolas.ozlabs.org
Authentication-Results: legolas.ozlabs.org;
 spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de
 (client-ip=85.214.62.61; helo=phobos.denx.de;
 envelope-from=u-boot-bounces@lists.denx.de; receiver=<UNKNOWN>)
Authentication-Results: legolas.ozlabs.org;
	dkim=pass (2048-bit key;
 unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256
 header.s=20210112 header.b=ALpx8yk2;
	dkim-atps=neutral
Received: from phobos.denx.de (phobos.denx.de [85.214.62.61])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (P-384))
	(No client certificate requested)
	by legolas.ozlabs.org (Postfix) with ESMTPS id 4PGT0r27C0z23r4
	for <incoming@patchwork.ozlabs.org>; Wed, 15 Feb 2023 04:37:00 +1100 (AEDT)
Received: from h2850616.stratoserver.net (localhost [IPv6:::1])
	by phobos.denx.de (Postfix) with ESMTP id 160148598A;
	Tue, 14 Feb 2023 18:36:24 +0100 (CET)
Authentication-Results: phobos.denx.de;
 dmarc=pass (p=none dis=none) header.from=gmail.com
Authentication-Results: phobos.denx.de;
 spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de
Authentication-Results: phobos.denx.de;
	dkim=pass (2048-bit key;
 unprotected) header.d=gmail.com header.i=@gmail.com header.b="ALpx8yk2";
	dkim-atps=neutral
Received: by phobos.denx.de (Postfix, from userid 109)
 id 92F5385989; Tue, 14 Feb 2023 18:36:10 +0100 (CET)
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de
X-Spam-Level: 
X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,
 DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT,
 FREEMAIL_FROM,SPF_HELO_NONE,SPF_PASS autolearn=unavailable
 autolearn_force=no version=3.4.2
Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com
 [IPv6:2a00:1450:4864:20::32a])
 (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits))
 (No client certificate requested)
 by phobos.denx.de (Postfix) with ESMTPS id 430C985932
 for <u-boot@lists.denx.de>; Tue, 14 Feb 2023 18:36:03 +0100 (CET)
Authentication-Results: phobos.denx.de;
 dmarc=pass (p=none dis=none) header.from=gmail.com
Authentication-Results: phobos.denx.de;
 spf=pass smtp.mailfrom=clamor95@gmail.com
Received: by mail-wm1-x32a.google.com with SMTP id
 j32-20020a05600c1c2000b003dc4fd6e61dso14236057wms.5
 for <u-boot@lists.denx.de>; Tue, 14 Feb 2023 09:36:03 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=LEsaLxoQ/LCXBSx/MNNhYL6yJyWz1u4rx3lbNXRTsIs=;
 b=ALpx8yk2KDQJptfna0bnwee5cNBO8E8R0k7eQyWypd1tkOcUHawvqBNwNNtB3U19Z2
 skdGS5FtMWQzYtqiOP4DGya8QOJ6PlbsDVEyvNPFwOSL2iGLws7q8AbKNV4OML//VA6E
 3ege/qVHiquTUr7NhDeQIft2wvYkwarZX5g/Os5qD8Tya+dT694xW3t72k2yeY6C36rP
 jb0+hgG0cXrwzwuNjfjPuPE5LMioQcBAYo6O1zujzw36+6+lTsYbDlf5njsz2mz8IHn/
 DzlYfpS1SxnQmzYyXWF8S9cOr8mK6Ilf3Ssj8WCgOfKkYZE8JmMdyhiWhRH2uMcvImtM
 r1iQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=LEsaLxoQ/LCXBSx/MNNhYL6yJyWz1u4rx3lbNXRTsIs=;
 b=BcVqM4LTtniTbm6vYPMS4a03U0K7KNVmEHhhiIrprP1xQ2pqj1aOYPr0ODW78YoaxE
 8gWZnM4ChbuzzWQ6hXDwdTEynDFD9Mo5j27PAJ3wE8a5aOaixpktaCZwDyi1I5bEzY5/
 +VrX/D1JF66KgDz3mSRCnoQAmbhPTX4RFBUDPGAJYAvvVKA/5ZPuXqKDlhpFkjSin2pt
 hFrFRZpdPn2s/J1Nm7INLZm+FGkI/xZ04hHWwHu2fZzXq/SuWVhYVxq1dfcFhflOW4p2
 DK6ZxDqbMcVeunF4avSIQAY0aNXx2cKkumtXaDMoCUs4J8FRT++45mbMcY8hWm19e8J0
 Br2w==
X-Gm-Message-State: AO0yUKXjkkcvpmDZv6sfrspx9CpYL4iyZcTC16hs+bUqGdhKqsSmszY8
 30gzMOf8WgM3SUvk7p0ohIJReZbUOpQXxA==
X-Google-Smtp-Source: 
 AK7set94xLdaQipAB49Yvm3bW/HeUWMCNsNqyKLs9zF+mj3EBGaQWd8gWts5oupFwns13VDOh5LZhg==
X-Received: by 2002:a05:600c:4395:b0:3df:94c3:4725 with SMTP id
 e21-20020a05600c439500b003df94c34725mr2678943wmn.38.1676396162538;
 Tue, 14 Feb 2023 09:36:02 -0800 (PST)
Received: from xeon.. ([188.163.112.76]) by smtp.gmail.com with ESMTPSA id
 m23-20020a7bca57000000b003de8a1b06c0sm20787829wml.7.2023.02.14.09.36.01
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 14 Feb 2023 09:36:02 -0800 (PST)
From: Svyatoslav Ryhel <clamor95@gmail.com>
To: Tom Warren <twarren@nvidia.com>,
 Marcel Ziswiler <marcel.ziswiler@toradex.com>,
 Allen Martin <amartin@nvidia.com>, Jagan Teki <jagan@amarulasolutions.com>,
 Lukasz Majewski <lukma@denx.de>, Marek Vasut <marex@denx.de>,
 Svyatoslav Ryhel <clamor95@gmail.com>,
 Ramin Khonsari <raminterex@yahoo.com>,
 Thierry Reding <thierry.reding@gmail.com>,
 Maxim Schwalm <maxim.schwalm@gmail.com>,
 Dmitry Osipenko <digetx@gmail.com>, Simon Glass <sjg@chromium.org>
Cc: u-boot@lists.denx.de
Subject: [PATCH v4 03/16] ARM: tegra: clock: add clk_id_to_pll_id helper
Date: Tue, 14 Feb 2023 19:35:25 +0200
Message-Id: <20230214173538.6242-4-clamor95@gmail.com>
X-Mailer: git-send-email 2.37.2
In-Reply-To: <20230214173538.6242-1-clamor95@gmail.com>
References: <20230214173538.6242-1-clamor95@gmail.com>
MIME-Version: 1.0
X-BeenThere: u-boot@lists.denx.de
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: U-Boot discussion <u-boot.lists.denx.de>
List-Unsubscribe: <https://lists.denx.de/options/u-boot>,
 <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>
List-Archive: <https://lists.denx.de/pipermail/u-boot/>
List-Post: <mailto:u-boot@lists.denx.de>
List-Help: <mailto:u-boot-request@lists.denx.de?subject=help>
List-Subscribe: <https://lists.denx.de/listinfo/u-boot>,
 <mailto:u-boot-request@lists.denx.de?subject=subscribe>
Errors-To: u-boot-bounces@lists.denx.de
Sender: "U-Boot" <u-boot-bounces@lists.denx.de>
X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de
X-Virus-Status: Clean

This function allows to convert a device tree clock ID to PLL ID.

Tested-by: Andreas Westman Dorcsak <hedmoo@yahoo.com> # ASUS TF T30
Tested-by: Robert Eckelmann <longnoserob@gmail.com> # ASUS TF101 T20
Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # HTC One X
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 arch/arm/include/asm/arch-tegra/clock.h |  8 ++++++
 arch/arm/mach-tegra/tegra114/clock.c    | 37 ++++++++++++++++++++++++
 arch/arm/mach-tegra/tegra124/clock.c    | 38 +++++++++++++++++++++++++
 arch/arm/mach-tegra/tegra20/clock.c     | 37 ++++++++++++++++++++++++
 arch/arm/mach-tegra/tegra210/clock.c    | 37 ++++++++++++++++++++++++
 arch/arm/mach-tegra/tegra30/clock.c     | 37 ++++++++++++++++++++++++
 6 files changed, 194 insertions(+)

diff --git a/arch/arm/include/asm/arch-tegra/clock.h b/arch/arm/include/asm/arch-tegra/clock.h
index 1dd5d0742c..2270501406 100644
--- a/arch/arm/include/asm/arch-tegra/clock.h
+++ b/arch/arm/include/asm/arch-tegra/clock.h
@@ -354,6 +354,14 @@ int get_periph_clock_source(enum periph_id periph_id,
  */
 enum periph_id clk_id_to_periph_id(int clk_id);
 
+/*
+ * Convert a device tree clock ID to our PLL ID.
+ *
+ * @param clk_id	Clock ID according to tegra device tree binding
+ * Return: clock ID, or CLOCK_ID_NONE if the clock ID is invalid
+ */
+enum clock_id clk_id_to_pll_id(int clk_id);
+
 /**
  * Set the output frequency you want for each PLL clock.
  * PLL output frequencies are programmed by setting their N, M and P values.
diff --git a/arch/arm/mach-tegra/tegra114/clock.c b/arch/arm/mach-tegra/tegra114/clock.c
index 143f86863f..15c2adc417 100644
--- a/arch/arm/mach-tegra/tegra114/clock.c
+++ b/arch/arm/mach-tegra/tegra114/clock.c
@@ -19,6 +19,8 @@
 #include <fdtdec.h>
 #include <linux/delay.h>
 
+#include <dt-bindings/clock/tegra114-car.h>
+
 /*
  * Clock types that we can use as a source. The Tegra114 has muxes for the
  * peripheral clocks, and in most cases there are four options for the clock
@@ -646,6 +648,41 @@ enum periph_id clk_id_to_periph_id(int clk_id)
 		return clk_id;
 	}
 }
+
+/*
+ * Convert a device tree clock ID to our PLL ID.
+ *
+ * @param clk_id	Clock ID according to tegra114 device tree binding
+ * Return: clock ID, or CLOCK_ID_NONE if the clock ID is invalid
+ */
+enum clock_id clk_id_to_pll_id(int clk_id)
+{
+	switch (clk_id) {
+	case TEGRA114_CLK_PLL_C:
+		return CLOCK_ID_CGENERAL;
+	case TEGRA114_CLK_PLL_M:
+		return CLOCK_ID_MEMORY;
+	case TEGRA114_CLK_PLL_P:
+		return CLOCK_ID_PERIPH;
+	case TEGRA114_CLK_PLL_A:
+		return CLOCK_ID_AUDIO;
+	case TEGRA114_CLK_PLL_U:
+		return CLOCK_ID_USB;
+	case TEGRA114_CLK_PLL_D:
+	case TEGRA114_CLK_PLL_D_OUT0:
+		return CLOCK_ID_DISPLAY;
+	case TEGRA114_CLK_PLL_X:
+		return CLOCK_ID_XCPU;
+	case TEGRA114_CLK_PLL_E_OUT0:
+		return CLOCK_ID_EPCI;
+	case TEGRA114_CLK_CLK_32K:
+		return CLOCK_ID_32KHZ;
+	case TEGRA114_CLK_CLK_M:
+		return CLOCK_ID_CLK_M;
+	default:
+		return CLOCK_ID_NONE;
+	}
+}
 #endif /* CONFIG_IS_ENABLED(OF_CONTROL) */
 
 void clock_early_init(void)
diff --git a/arch/arm/mach-tegra/tegra124/clock.c b/arch/arm/mach-tegra/tegra124/clock.c
index da38b26c27..415ba15e5d 100644
--- a/arch/arm/mach-tegra/tegra124/clock.c
+++ b/arch/arm/mach-tegra/tegra124/clock.c
@@ -19,6 +19,9 @@
 #include <fdtdec.h>
 #include <linux/delay.h>
 
+#include <dt-bindings/clock/tegra124-car.h>
+#include <dt-bindings/clock/tegra124-car-common.h>
+
 /*
  * Clock types that we can use as a source. The Tegra124 has muxes for the
  * peripheral clocks, and in most cases there are four options for the clock
@@ -826,6 +829,41 @@ enum periph_id clk_id_to_periph_id(int clk_id)
 		return clk_id;
 	}
 }
+
+/*
+ * Convert a device tree clock ID to our PLL ID.
+ *
+ * @param clk_id	Clock ID according to tegra124 device tree binding
+ * Return: clock ID, or CLOCK_ID_NONE if the clock ID is invalid
+ */
+enum clock_id clk_id_to_pll_id(int clk_id)
+{
+	switch (clk_id) {
+	case TEGRA124_CLK_PLL_C:
+		return CLOCK_ID_CGENERAL;
+	case TEGRA124_CLK_PLL_M:
+		return CLOCK_ID_MEMORY;
+	case TEGRA124_CLK_PLL_P:
+		return CLOCK_ID_PERIPH;
+	case TEGRA124_CLK_PLL_A:
+		return CLOCK_ID_AUDIO;
+	case TEGRA124_CLK_PLL_U:
+		return CLOCK_ID_USB;
+	case TEGRA124_CLK_PLL_D:
+	case TEGRA124_CLK_PLL_D_OUT0:
+		return CLOCK_ID_DISPLAY;
+	case TEGRA124_CLK_PLL_X:
+		return CLOCK_ID_XCPU;
+	case TEGRA124_CLK_PLL_E:
+		return CLOCK_ID_EPCI;
+	case TEGRA124_CLK_CLK_32K:
+		return CLOCK_ID_32KHZ;
+	case TEGRA124_CLK_CLK_M:
+		return CLOCK_ID_CLK_M;
+	default:
+		return CLOCK_ID_NONE;
+	}
+}
 #endif /* CONFIG_IS_ENABLED(OF_CONTROL) */
 
 void clock_early_init(void)
diff --git a/arch/arm/mach-tegra/tegra20/clock.c b/arch/arm/mach-tegra/tegra20/clock.c
index 0316073d1a..593622bfdc 100644
--- a/arch/arm/mach-tegra/tegra20/clock.c
+++ b/arch/arm/mach-tegra/tegra20/clock.c
@@ -20,6 +20,8 @@
 #include <fdtdec.h>
 #include <linux/delay.h>
 
+#include <dt-bindings/clock/tegra20-car.h>
+
 /*
  * Clock types that we can use as a source. The Tegra20 has muxes for the
  * peripheral clocks, and in most cases there are four options for the clock
@@ -578,6 +580,41 @@ enum periph_id clk_id_to_periph_id(int clk_id)
 		return clk_id;
 	}
 }
+
+/*
+ * Convert a device tree clock ID to our PLL ID.
+ *
+ * @param clk_id	Clock ID according to tegra20 device tree binding
+ * Return: clock ID, or CLOCK_ID_NONE if the clock ID is invalid
+ */
+enum clock_id clk_id_to_pll_id(int clk_id)
+{
+	switch (clk_id) {
+	case TEGRA20_CLK_PLL_C:
+		return CLOCK_ID_CGENERAL;
+	case TEGRA20_CLK_PLL_M:
+		return CLOCK_ID_MEMORY;
+	case TEGRA20_CLK_PLL_P:
+		return CLOCK_ID_PERIPH;
+	case TEGRA20_CLK_PLL_A:
+		return CLOCK_ID_AUDIO;
+	case TEGRA20_CLK_PLL_U:
+		return CLOCK_ID_USB;
+	case TEGRA20_CLK_PLL_D:
+	case TEGRA20_CLK_PLL_D_OUT0:
+		return CLOCK_ID_DISPLAY;
+	case TEGRA20_CLK_PLL_X:
+		return CLOCK_ID_XCPU;
+	case TEGRA20_CLK_PLL_E:
+		return CLOCK_ID_EPCI;
+	case TEGRA20_CLK_CLK_32K:
+		return CLOCK_ID_32KHZ;
+	case TEGRA20_CLK_CLK_M:
+		return CLOCK_ID_CLK_M;
+	default:
+		return CLOCK_ID_NONE;
+	}
+}
 #endif /* CONFIG_IS_ENABLED(OF_CONTROL) */
 
 void clock_early_init(void)
diff --git a/arch/arm/mach-tegra/tegra210/clock.c b/arch/arm/mach-tegra/tegra210/clock.c
index 330753f2ad..76fbfef580 100644
--- a/arch/arm/mach-tegra/tegra210/clock.c
+++ b/arch/arm/mach-tegra/tegra210/clock.c
@@ -22,6 +22,8 @@
 #include <linux/bitops.h>
 #include <linux/delay.h>
 
+#include <dt-bindings/clock/tegra210-car.h>
+
 /*
  * Clock types that we can use as a source. The Tegra210 has muxes for the
  * peripheral clocks, and in most cases there are four options for the clock
@@ -914,6 +916,41 @@ enum periph_id clk_id_to_periph_id(int clk_id)
 		return clk_id;
 	}
 }
+
+/*
+ * Convert a device tree clock ID to our PLL ID.
+ *
+ * @param clk_id	Clock ID according to tegra210 device tree binding
+ * Return: clock ID, or CLOCK_ID_NONE if the clock ID is invalid
+ */
+enum clock_id clk_id_to_pll_id(int clk_id)
+{
+	switch (clk_id) {
+	case TEGRA210_CLK_PLL_C:
+		return CLOCK_ID_CGENERAL;
+	case TEGRA210_CLK_PLL_M:
+		return CLOCK_ID_MEMORY;
+	case TEGRA210_CLK_PLL_P:
+		return CLOCK_ID_PERIPH;
+	case TEGRA210_CLK_PLL_A:
+		return CLOCK_ID_AUDIO;
+	case TEGRA210_CLK_PLL_U:
+		return CLOCK_ID_USB;
+	case TEGRA210_CLK_PLL_D:
+	case TEGRA210_CLK_PLL_D_OUT0:
+		return CLOCK_ID_DISPLAY;
+	case TEGRA210_CLK_PLL_X:
+		return CLOCK_ID_XCPU;
+	case TEGRA210_CLK_PLL_E:
+		return CLOCK_ID_EPCI;
+	case TEGRA210_CLK_CLK_32K:
+		return CLOCK_ID_32KHZ;
+	case TEGRA210_CLK_CLK_M:
+		return CLOCK_ID_CLK_M;
+	default:
+		return CLOCK_ID_NONE;
+	}
+}
 #endif /* CONFIG_OF_CONTROL */
 
 /*
diff --git a/arch/arm/mach-tegra/tegra30/clock.c b/arch/arm/mach-tegra/tegra30/clock.c
index e5c2fd542c..dcdd0d0978 100644
--- a/arch/arm/mach-tegra/tegra30/clock.c
+++ b/arch/arm/mach-tegra/tegra30/clock.c
@@ -19,6 +19,8 @@
 #include <fdtdec.h>
 #include <linux/delay.h>
 
+#include <dt-bindings/clock/tegra30-car.h>
+
 /*
  * Clock types that we can use as a source. The Tegra30 has muxes for the
  * peripheral clocks, and in most cases there are four options for the clock
@@ -628,6 +630,41 @@ enum periph_id clk_id_to_periph_id(int clk_id)
 		return clk_id;
 	}
 }
+
+/*
+ * Convert a device tree clock ID to our PLL ID.
+ *
+ * @param clk_id	Clock ID according to tegra30 device tree binding
+ * Return: clock ID, or CLOCK_ID_NONE if the clock ID is invalid
+ */
+enum clock_id clk_id_to_pll_id(int clk_id)
+{
+	switch (clk_id) {
+	case TEGRA30_CLK_PLL_C:
+		return CLOCK_ID_CGENERAL;
+	case TEGRA30_CLK_PLL_M:
+		return CLOCK_ID_MEMORY;
+	case TEGRA30_CLK_PLL_P:
+		return CLOCK_ID_PERIPH;
+	case TEGRA30_CLK_PLL_A:
+		return CLOCK_ID_AUDIO;
+	case TEGRA30_CLK_PLL_U:
+		return CLOCK_ID_USB;
+	case TEGRA30_CLK_PLL_D:
+	case TEGRA30_CLK_PLL_D_OUT0:
+		return CLOCK_ID_DISPLAY;
+	case TEGRA30_CLK_PLL_X:
+		return CLOCK_ID_XCPU;
+	case TEGRA30_CLK_PLL_E:
+		return CLOCK_ID_EPCI;
+	case TEGRA30_CLK_CLK_32K:
+		return CLOCK_ID_32KHZ;
+	case TEGRA30_CLK_CLK_M:
+		return CLOCK_ID_CLK_M;
+	default:
+		return CLOCK_ID_NONE;
+	}
+}
 #endif /* CONFIG_IS_ENABLED(OF_CONTROL) */
 
 void clock_early_init(void)

From patchwork Tue Feb 14 17:35:26 2023
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Svyatoslav Ryhel <clamor95@gmail.com>
X-Patchwork-Id: 1742539
X-Patchwork-Delegate: twarren@nvidia.com
Return-Path: <u-boot-bounces@lists.denx.de>
X-Original-To: incoming@patchwork.ozlabs.org
Delivered-To: patchwork-incoming@legolas.ozlabs.org
Authentication-Results: legolas.ozlabs.org;
 spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de
 (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de;
 envelope-from=u-boot-bounces@lists.denx.de; receiver=<UNKNOWN>)
Authentication-Results: legolas.ozlabs.org;
	dkim=pass (2048-bit key;
 unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256
 header.s=20210112 header.b=N41CP0Xo;
	dkim-atps=neutral
Received: from phobos.denx.de (phobos.denx.de
 [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (P-384))
	(No client certificate requested)
	by legolas.ozlabs.org (Postfix) with ESMTPS id 4PGT170Y7Vz23r4
	for <incoming@patchwork.ozlabs.org>; Wed, 15 Feb 2023 04:37:15 +1100 (AEDT)
Received: from h2850616.stratoserver.net (localhost [IPv6:::1])
	by phobos.denx.de (Postfix) with ESMTP id A9B6985988;
	Tue, 14 Feb 2023 18:36:26 +0100 (CET)
Authentication-Results: phobos.denx.de;
 dmarc=pass (p=none dis=none) header.from=gmail.com
Authentication-Results: phobos.denx.de;
 spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de
Authentication-Results: phobos.denx.de;
	dkim=pass (2048-bit key;
 unprotected) header.d=gmail.com header.i=@gmail.com header.b="N41CP0Xo";
	dkim-atps=neutral
Received: by phobos.denx.de (Postfix, from userid 109)
 id D7756859E6; Tue, 14 Feb 2023 18:36:10 +0100 (CET)
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de
X-Spam-Level: 
X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,
 DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT,
 FREEMAIL_FROM,SPF_HELO_NONE,SPF_PASS autolearn=unavailable
 autolearn_force=no version=3.4.2
Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com
 [IPv6:2a00:1450:4864:20::32d])
 (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits))
 (No client certificate requested)
 by phobos.denx.de (Postfix) with ESMTPS id 6F82C85988
 for <u-boot@lists.denx.de>; Tue, 14 Feb 2023 18:36:04 +0100 (CET)
Authentication-Results: phobos.denx.de;
 dmarc=pass (p=none dis=none) header.from=gmail.com
Authentication-Results: phobos.denx.de;
 spf=pass smtp.mailfrom=clamor95@gmail.com
Received: by mail-wm1-x32d.google.com with SMTP id
 l21-20020a05600c1d1500b003dfe462b7e4so1431835wms.0
 for <u-boot@lists.denx.de>; Tue, 14 Feb 2023 09:36:04 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=WGnOXk7F41+FUWj9KaPiLniOxcq6LrbPqdRniecgUus=;
 b=N41CP0XoJLG1G7+s+ecuqwkqM/48n1bNUplGHSJL5ztSX6VrakMVvlFL5GVYDBXc0l
 1PT1028v25yAZoYj12xUgtCL2xxaFuc9siKj8Y3pow36wRtXDQPhBdir2xip+TP8GYCj
 44YTz770zth9M2iD32UGXw6/HS6PkAV66E/5ihblEtw1ksywfJ2BwpIYE7WAR4X+fjUI
 3vXzwq+SHcAHRnZAAvFd694+TDs7dSS9vDI+ZsWnpZld09VIFhdcW4QG0NVOoiT7Z1w8
 mDG49whVVVj30uZgabc+6Scb4lgnW34CPryUW9fglDRZWL6wJzo6S9/DoQFZZ3o60JGe
 s7Vg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=WGnOXk7F41+FUWj9KaPiLniOxcq6LrbPqdRniecgUus=;
 b=xCabVVLURktxsiQwyW3LdPfBBazJ0WppEQJZW5e5Aruv7oEuPItA258GjQodQi4riu
 42jgZQ9qpP8WxDH9jatdPpTkOhJLgzgYhcWfAX24XoUHIVyGN7NYylY7c61+U8ora61z
 gVsIz3Qvy8TO8k22sM2JSQeidkycVm5cxrQZvCIPxS5MPt4czaj4uac0x3nifJzQ6ogC
 7G+cxLPI7cM/NM7jNwk2rbywbnFa6pHp7dnmmVIgwG1F4LFJGyCoGMaICuMPSYeeElMk
 HWSdUaC7H5PXuTlPbXMamomzbmZghigwxXBkKbQfZsz2vLxn42RgTa41Eaa5IRNcZl9c
 D6+g==
X-Gm-Message-State: AO0yUKXPN4jjTjBAOFurq8nCNxazwzh/GGg/ELGzBG3vV4lLS545P5ad
 FDbOTVOWjTjEUpEK9pKn9Og=
X-Google-Smtp-Source: 
 AK7set+kedwUdHEauS9wsWlXT70dcHeF1jOe/KgI+6H/rjNFdin52u8AfpIHYBgqh/NwB4NvCnL/Uw==
X-Received: by 2002:a05:600c:4f06:b0:3dc:433a:e952 with SMTP id
 l6-20020a05600c4f0600b003dc433ae952mr2867768wmq.33.1676396163695;
 Tue, 14 Feb 2023 09:36:03 -0800 (PST)
Received: from xeon.. ([188.163.112.76]) by smtp.gmail.com with ESMTPSA id
 m23-20020a7bca57000000b003de8a1b06c0sm20787829wml.7.2023.02.14.09.36.02
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 14 Feb 2023 09:36:03 -0800 (PST)
From: Svyatoslav Ryhel <clamor95@gmail.com>
To: Tom Warren <twarren@nvidia.com>,
 Marcel Ziswiler <marcel.ziswiler@toradex.com>,
 Allen Martin <amartin@nvidia.com>, Jagan Teki <jagan@amarulasolutions.com>,
 Lukasz Majewski <lukma@denx.de>, Marek Vasut <marex@denx.de>,
 Svyatoslav Ryhel <clamor95@gmail.com>,
 Ramin Khonsari <raminterex@yahoo.com>,
 Thierry Reding <thierry.reding@gmail.com>,
 Maxim Schwalm <maxim.schwalm@gmail.com>,
 Dmitry Osipenko <digetx@gmail.com>, Simon Glass <sjg@chromium.org>
Cc: u-boot@lists.denx.de
Subject: [PATCH v4 04/16] ARM: tegra: clock: add clock_decode_pair helper
Date: Tue, 14 Feb 2023 19:35:26 +0200
Message-Id: <20230214173538.6242-5-clamor95@gmail.com>
X-Mailer: git-send-email 2.37.2
In-Reply-To: <20230214173538.6242-1-clamor95@gmail.com>
References: <20230214173538.6242-1-clamor95@gmail.com>
MIME-Version: 1.0
X-BeenThere: u-boot@lists.denx.de
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: U-Boot discussion <u-boot.lists.denx.de>
List-Unsubscribe: <https://lists.denx.de/options/u-boot>,
 <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>
List-Archive: <https://lists.denx.de/pipermail/u-boot/>
List-Post: <mailto:u-boot@lists.denx.de>
List-Help: <mailto:u-boot-request@lists.denx.de?subject=help>
List-Subscribe: <https://lists.denx.de/listinfo/u-boot>,
 <mailto:u-boot-request@lists.denx.de?subject=subscribe>
Errors-To: u-boot-bounces@lists.denx.de
Sender: "U-Boot" <u-boot-bounces@lists.denx.de>
X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de
X-Virus-Status: Clean

Get periph clock id and its parent from device tree.
This works by looking up the peripheral's 'clocks' node and
reading out the second and fourth cells, which are the
peripheral and PLL clock numbers.

Tested-by: Andreas Westman Dorcsak <hedmoo@yahoo.com> # ASUS TF T30
Tested-by: Robert Eckelmann <longnoserob@gmail.com> # ASUS TF101 T20
Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # HTC One X
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 arch/arm/include/asm/arch-tegra/clock.h | 13 +++++++++++++
 arch/arm/mach-tegra/clock.c             | 23 +++++++++++++++++++++++
 2 files changed, 36 insertions(+)

diff --git a/arch/arm/include/asm/arch-tegra/clock.h b/arch/arm/include/asm/arch-tegra/clock.h
index 2270501406..61ef81e7fe 100644
--- a/arch/arm/include/asm/arch-tegra/clock.h
+++ b/arch/arm/include/asm/arch-tegra/clock.h
@@ -270,6 +270,19 @@ void clock_ll_start_uart(enum periph_id periph_id);
  */
 int clock_decode_periph_id(struct udevice *dev);
 
+/**
+ * Get periph clock id and its parent from device tree.
+ *
+ * This works by looking up the peripheral's 'clocks' node and reading out
+ * the second and fourth cells, which are the peripheral and PLL clock numbers.
+ *
+ * @param dev          udevice associated with FDT node
+ * @param clk_id       pointer to int array of 2 values
+ *                     first is periph clock, second is
+ *                     its PLL parent according to FDT.
+ */
+int clock_decode_pair(struct udevice *dev, int *clk_id);
+
 /**
  * Checks if the oscillator bypass is enabled (XOBP bit)
  *
diff --git a/arch/arm/mach-tegra/clock.c b/arch/arm/mach-tegra/clock.c
index 11bffc1701..966009f375 100644
--- a/arch/arm/mach-tegra/clock.c
+++ b/arch/arm/mach-tegra/clock.c
@@ -678,6 +678,29 @@ int clock_decode_periph_id(struct udevice *dev)
 	assert(clock_periph_id_isvalid(id));
 	return id;
 }
+
+/*
+ * Get periph clock id and its parent from device tree.
+ *
+ * @param dev		udevice associated with FDT node
+ * @param clk_id	pointer to u32 array of 2 values
+ *			first is periph clock, second is
+ *			its PLL parent according to FDT.
+ */
+int clock_decode_pair(struct udevice *dev, int *clk_id)
+{
+	u32 cell[4];
+	int err;
+
+	err = dev_read_u32_array(dev, "clocks", cell, ARRAY_SIZE(cell));
+	if (err)
+		return -EINVAL;
+
+	clk_id[0] = clk_id_to_periph_id(cell[1]);
+	clk_id[1] = clk_id_to_pll_id(cell[3]);
+
+	return 0;
+}
 #endif /* CONFIG_IS_ENABLED(OF_CONTROL) */
 
 int clock_verify(void)

From patchwork Tue Feb 14 17:35:27 2023
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Svyatoslav Ryhel <clamor95@gmail.com>
X-Patchwork-Id: 1742540
X-Patchwork-Delegate: twarren@nvidia.com
Return-Path: <u-boot-bounces@lists.denx.de>
X-Original-To: incoming@patchwork.ozlabs.org
Delivered-To: patchwork-incoming@legolas.ozlabs.org
Authentication-Results: legolas.ozlabs.org;
 spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de
 (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de;
 envelope-from=u-boot-bounces@lists.denx.de; receiver=<UNKNOWN>)
Authentication-Results: legolas.ozlabs.org;
	dkim=pass (2048-bit key;
 unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256
 header.s=20210112 header.b=jT9mmeDv;
	dkim-atps=neutral
Received: from phobos.denx.de (phobos.denx.de
 [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (P-384))
	(No client certificate requested)
	by legolas.ozlabs.org (Postfix) with ESMTPS id 4PGT1L3H7dz23r4
	for <incoming@patchwork.ozlabs.org>; Wed, 15 Feb 2023 04:37:26 +1100 (AEDT)
Received: from h2850616.stratoserver.net (localhost [IPv6:::1])
	by phobos.denx.de (Postfix) with ESMTP id ADA028597D;
	Tue, 14 Feb 2023 18:36:29 +0100 (CET)
Authentication-Results: phobos.denx.de;
 dmarc=pass (p=none dis=none) header.from=gmail.com
Authentication-Results: phobos.denx.de;
 spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de
Authentication-Results: phobos.denx.de;
	dkim=pass (2048-bit key;
 unprotected) header.d=gmail.com header.i=@gmail.com header.b="jT9mmeDv";
	dkim-atps=neutral
Received: by phobos.denx.de (Postfix, from userid 109)
 id DC3BC85918; Tue, 14 Feb 2023 18:36:12 +0100 (CET)
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de
X-Spam-Level: 
X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,
 DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT,
 FREEMAIL_FROM,SPF_HELO_NONE,SPF_PASS autolearn=unavailable
 autolearn_force=no version=3.4.2
Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com
 [IPv6:2a00:1450:4864:20::336])
 (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits))
 (No client certificate requested)
 by phobos.denx.de (Postfix) with ESMTPS id 8232F85918
 for <u-boot@lists.denx.de>; Tue, 14 Feb 2023 18:36:05 +0100 (CET)
Authentication-Results: phobos.denx.de;
 dmarc=pass (p=none dis=none) header.from=gmail.com
Authentication-Results: phobos.denx.de;
 spf=pass smtp.mailfrom=clamor95@gmail.com
Received: by mail-wm1-x336.google.com with SMTP id o36so11517650wms.1
 for <u-boot@lists.denx.de>; Tue, 14 Feb 2023 09:36:05 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=pEB0c+1SyD2Blyvlhf8A3aC4plwq+xgMikY5EQ68Ldo=;
 b=jT9mmeDvhhZh4hC+QCh9P28efPu5sUgiJacVMir2eSNh/Kfl/96OwgGVUa/T4WcZCt
 ibcCLuTohNTiEqmq86Vk3mxFc4tz5w0zPsi/seH5tZbKVIq3G3/VeVINCk4oq6lhftWP
 vzWGSvG9rbvmkb4x4IfBxAp1bhh3JL+YluNsOeat7aO+vNe8p9GEDPdfSHAIoyZIv75K
 J7uNcyK3P3O8d+BA/ID5LYQVOcdwbFT6v/pdMY9N5GPs/zDqXGUwMJXTNsBEwKImihW/
 +q3IHZfojFKFnAgQBI9QQZ+fUZUAk11Zt75+Vv+aTwZDwNkrz6uGB91OEVyiM+4gJohB
 jSQw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=pEB0c+1SyD2Blyvlhf8A3aC4plwq+xgMikY5EQ68Ldo=;
 b=Lq92IHzTo1nN5HaoVp95IvBYVslUjOTRQv6sBDjMPV0+H6oBtqbO64wkLGpAlAeEu0
 ov9egCWcxPIZHuGjmtB7VnynXle7/UiHUk2KxnmOyFSHAm1xRN9tTTKMwvNyOXUhvAuz
 Phweg7805ymGpZv1ElVZ+xeZ0TsYMPzPk9Oyz71FBLTVqgZcZNL8sczCL6mF14mY6lSA
 +PC/QDLT3vWqDN+dnksAKv6TSeP17gAgXfS+v3rDU18QgS7AJLIV0zIvKuKIlq9SeZim
 jVH9XyGjo6j9S3H/QwMVJ3A8YSrl5RFVbDiZEHNOjjtnJ1LMlhBjmlXfKXPHtnbb+jl9
 SXEQ==
X-Gm-Message-State: AO0yUKUheN5J0n42WseZ5reB8roiWmcBapvOUAo7DtjyyR0YBMOQycT9
 MvYTf2awXeGxw4YiMHvh9eI=
X-Google-Smtp-Source: 
 AK7set9Vf5sucANafN7Wtxs8e91Ti06mwRnl+uqq254ZdG75TxI5OLkR/ZXTK0Fu2VBug0u3DNab+w==
X-Received: by 2002:a05:600c:13ca:b0:3e1:374:8b66 with SMTP id
 e10-20020a05600c13ca00b003e103748b66mr2573827wmg.40.1676396164828;
 Tue, 14 Feb 2023 09:36:04 -0800 (PST)
Received: from xeon.. ([188.163.112.76]) by smtp.gmail.com with ESMTPSA id
 m23-20020a7bca57000000b003de8a1b06c0sm20787829wml.7.2023.02.14.09.36.03
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 14 Feb 2023 09:36:04 -0800 (PST)
From: Svyatoslav Ryhel <clamor95@gmail.com>
To: Tom Warren <twarren@nvidia.com>,
 Marcel Ziswiler <marcel.ziswiler@toradex.com>,
 Allen Martin <amartin@nvidia.com>, Jagan Teki <jagan@amarulasolutions.com>,
 Lukasz Majewski <lukma@denx.de>, Marek Vasut <marex@denx.de>,
 Svyatoslav Ryhel <clamor95@gmail.com>,
 Ramin Khonsari <raminterex@yahoo.com>,
 Thierry Reding <thierry.reding@gmail.com>,
 Maxim Schwalm <maxim.schwalm@gmail.com>,
 Dmitry Osipenko <digetx@gmail.com>, Simon Glass <sjg@chromium.org>
Cc: u-boot@lists.denx.de
Subject: [PATCH v4 05/16] ARM: tegra30: add PLLD to pll setup
Date: Tue, 14 Feb 2023 19:35:27 +0200
Message-Id: <20230214173538.6242-6-clamor95@gmail.com>
X-Mailer: git-send-email 2.37.2
In-Reply-To: <20230214173538.6242-1-clamor95@gmail.com>
References: <20230214173538.6242-1-clamor95@gmail.com>
MIME-Version: 1.0
X-BeenThere: u-boot@lists.denx.de
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: U-Boot discussion <u-boot.lists.denx.de>
List-Unsubscribe: <https://lists.denx.de/options/u-boot>,
 <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>
List-Archive: <https://lists.denx.de/pipermail/u-boot/>
List-Post: <mailto:u-boot@lists.denx.de>
List-Help: <mailto:u-boot-request@lists.denx.de?subject=help>
List-Subscribe: <https://lists.denx.de/listinfo/u-boot>,
 <mailto:u-boot-request@lists.denx.de?subject=subscribe>
Errors-To: u-boot-bounces@lists.denx.de
Sender: "U-Boot" <u-boot-bounces@lists.denx.de>
X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de
X-Virus-Status: Clean

On T30 unlike T20 dsi panels are wider used on devices
and PLLD is used as DISP1 parent more often, so lets
enable it as well for this cases.

Tested-by: Andreas Westman Dorcsak <hedmoo@yahoo.com> # ASUS TF700T T30
Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # HTC One X T30
Tested-by: Thierry Reding <treding@nvidia.com> # Beaver T30
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 arch/arm/mach-tegra/tegra30/clock.c | 41 +++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/arch/arm/mach-tegra/tegra30/clock.c b/arch/arm/mach-tegra/tegra30/clock.c
index dcdd0d0978..b66211ce94 100644
--- a/arch/arm/mach-tegra/tegra30/clock.c
+++ b/arch/arm/mach-tegra/tegra30/clock.c
@@ -669,7 +669,48 @@ enum clock_id clk_id_to_pll_id(int clk_id)
 
 void clock_early_init(void)
 {
+	struct clk_rst_ctlr *clkrst =
+		(struct clk_rst_ctlr *)NV_PA_CLK_RST_BASE;
+	struct clk_pll_info *pllinfo;
+	u32 data;
+
 	tegra30_set_up_pllp();
+
+	/*
+	 * PLLD output frequency set to 925Mhz
+	 */
+	switch (clock_get_osc_freq()) {
+	case CLOCK_OSC_FREQ_12_0: /* OSC is 12Mhz */
+	case CLOCK_OSC_FREQ_48_0: /* OSC is 48Mhz */
+		clock_set_rate(CLOCK_ID_DISPLAY, 925, 12, 0, 12);
+		break;
+
+	case CLOCK_OSC_FREQ_26_0: /* OSC is 26Mhz */
+		clock_set_rate(CLOCK_ID_DISPLAY, 925, 26, 0, 12);
+		break;
+
+	case CLOCK_OSC_FREQ_13_0: /* OSC is 13Mhz */
+	case CLOCK_OSC_FREQ_16_8: /* OSC is 16.8Mhz */
+		clock_set_rate(CLOCK_ID_DISPLAY, 925, 13, 0, 12);
+		break;
+
+	case CLOCK_OSC_FREQ_19_2:
+	case CLOCK_OSC_FREQ_38_4:
+	default:
+		/*
+		 * These are not supported. It is too early to print a
+		 * message and the UART likely won't work anyway due to the
+		 * oscillator being wrong.
+		 */
+		break;
+	}
+
+	/* PLLD_MISC: Set CLKENABLE, CPCON 12, LFCON 1, and enable lock */
+	pllinfo = &tegra_pll_info_table[CLOCK_ID_DISPLAY];
+	data = (12 << pllinfo->kcp_shift) | (1 << pllinfo->kvco_shift);
+	data |= (1 << PLLD_CLKENABLE) | (1 << pllinfo->lock_ena);
+	writel(data, &clkrst->crc_pll[CLOCK_ID_DISPLAY].pll_misc);
+	udelay(2);
 }
 
 void arch_timer_init(void)

From patchwork Tue Feb 14 17:35:28 2023
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Svyatoslav Ryhel <clamor95@gmail.com>
X-Patchwork-Id: 1742541
X-Patchwork-Delegate: twarren@nvidia.com
Return-Path: <u-boot-bounces@lists.denx.de>
X-Original-To: incoming@patchwork.ozlabs.org
Delivered-To: patchwork-incoming@legolas.ozlabs.org
Authentication-Results: legolas.ozlabs.org;
 spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de
 (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de;
 envelope-from=u-boot-bounces@lists.denx.de; receiver=<UNKNOWN>)
Authentication-Results: legolas.ozlabs.org;
	dkim=pass (2048-bit key;
 unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256
 header.s=20210112 header.b=HrannCQe;
	dkim-atps=neutral
Received: from phobos.denx.de (phobos.denx.de
 [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (P-384))
	(No client certificate requested)
	by legolas.ozlabs.org (Postfix) with ESMTPS id 4PGT1Z0R7Cz23r4
	for <incoming@patchwork.ozlabs.org>; Wed, 15 Feb 2023 04:37:38 +1100 (AEDT)
Received: from h2850616.stratoserver.net (localhost [IPv6:::1])
	by phobos.denx.de (Postfix) with ESMTP id AF3D3859E5;
	Tue, 14 Feb 2023 18:36:32 +0100 (CET)
Authentication-Results: phobos.denx.de;
 dmarc=pass (p=none dis=none) header.from=gmail.com
Authentication-Results: phobos.denx.de;
 spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de
Authentication-Results: phobos.denx.de;
	dkim=pass (2048-bit key;
 unprotected) header.d=gmail.com header.i=@gmail.com header.b="HrannCQe";
	dkim-atps=neutral
Received: by phobos.denx.de (Postfix, from userid 109)
 id D7603859EE; Tue, 14 Feb 2023 18:36:13 +0100 (CET)
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de
X-Spam-Level: 
X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,
 DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT,
 FREEMAIL_FROM,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no
 version=3.4.2
Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com
 [IPv6:2a00:1450:4864:20::333])
 (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits))
 (No client certificate requested)
 by phobos.denx.de (Postfix) with ESMTPS id 3834285996
 for <u-boot@lists.denx.de>; Tue, 14 Feb 2023 18:36:06 +0100 (CET)
Authentication-Results: phobos.denx.de;
 dmarc=pass (p=none dis=none) header.from=gmail.com
Authentication-Results: phobos.denx.de;
 spf=pass smtp.mailfrom=clamor95@gmail.com
Received: by mail-wm1-x333.google.com with SMTP id
 bg5-20020a05600c3c8500b003e00c739ce4so12182199wmb.5
 for <u-boot@lists.denx.de>; Tue, 14 Feb 2023 09:36:06 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=bqJJMKgdVVJoUeZp4MDIYRofuCB8LWeGLxIa844DvAM=;
 b=HrannCQeH3VDGXFH1PBGhOUsxB4h1/dqz2PNQJqxd1HYtqLPZ0bQtMtwOw1Bb+Wvgw
 eHFcsxj9nHjJm4QsvsjbfsR/i5UpuJyfaSC65tJ/MFJskoW8I1UB7nK6qE/ESv0Bsoxs
 UlAHqEUZMH2mzunkifN0zsPKg1HGJscQESMSsY9W1Cb3itwd81iQVFzl860EVRyJ+W30
 fpzrGquMBaAugnhcpKZ1ekj+ggGx46FfyLLfkfm8V7CPYGlefzpKk526rlim8mWOSjot
 QhGLGxLS6Zjvgx9ft7E3pTW8fXfu0PFGs0n6dOO0RPI72YjQdFL8pdz1eyY8kTqOB9U1
 QB/Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=bqJJMKgdVVJoUeZp4MDIYRofuCB8LWeGLxIa844DvAM=;
 b=WVL+U4gC7uzdz7ycYHodGygk1sezFLXdEVyItraWbVZKlTtR9wajy1Xw8WcaX+itWx
 nV/SPAWcPlXM/vpIct5FCnStzbr8v5VmMpFeUfvJqMRur3rE/uN7ZciZC5oDL33rDmA+
 nWO8NsjSi6GuM4pDwxgdD90jXjjyx5YcfLKAUB6AIe83bq0SLpUAznF00VhFrj4xKyej
 QdJkJI4D/4xi3Ey/EZQOTct6TpNSgUYLsrio2W8imdSwe+yFDLbimfcdFvWdd0psb6CE
 pzqV489cCEBsogxkn5x3l7dkYUuniyH9ibPa84CWa0JeYD9OajdB7pAPgBvWN9o/PEyK
 RmXA==
X-Gm-Message-State: AO0yUKV0bKW6JrZtx/it1LYNXcTn8lYkRuJ783O3Vq0z+wzSJneIOtTd
 BFqJqqCspHoBvIxnU2doLlM=
X-Google-Smtp-Source: 
 AK7set8C9x0oqmIZc33vxhOW2SkzDQVGiLUO/BUck8S5FMDBDxeiM4pVUym3cFANae2c6FsDgh1viw==
X-Received: by 2002:a05:600c:3d8c:b0:3da:f670:a199 with SMTP id
 bi12-20020a05600c3d8c00b003daf670a199mr2712079wmb.36.1676396165938;
 Tue, 14 Feb 2023 09:36:05 -0800 (PST)
Received: from xeon.. ([188.163.112.76]) by smtp.gmail.com with ESMTPSA id
 m23-20020a7bca57000000b003de8a1b06c0sm20787829wml.7.2023.02.14.09.36.04
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 14 Feb 2023 09:36:05 -0800 (PST)
From: Svyatoslav Ryhel <clamor95@gmail.com>
To: Tom Warren <twarren@nvidia.com>,
 Marcel Ziswiler <marcel.ziswiler@toradex.com>,
 Allen Martin <amartin@nvidia.com>, Jagan Teki <jagan@amarulasolutions.com>,
 Lukasz Majewski <lukma@denx.de>, Marek Vasut <marex@denx.de>,
 Svyatoslav Ryhel <clamor95@gmail.com>,
 Ramin Khonsari <raminterex@yahoo.com>,
 Thierry Reding <thierry.reding@gmail.com>,
 Maxim Schwalm <maxim.schwalm@gmail.com>,
 Dmitry Osipenko <digetx@gmail.com>, Simon Glass <sjg@chromium.org>
Cc: u-boot@lists.denx.de
Subject: [PATCH v4 06/16] ARM: tegra: Fix Tegra PWM parent clock
Date: Tue, 14 Feb 2023 19:35:28 +0200
Message-Id: <20230214173538.6242-7-clamor95@gmail.com>
X-Mailer: git-send-email 2.37.2
In-Reply-To: <20230214173538.6242-1-clamor95@gmail.com>
References: <20230214173538.6242-1-clamor95@gmail.com>
MIME-Version: 1.0
X-BeenThere: u-boot@lists.denx.de
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: U-Boot discussion <u-boot.lists.denx.de>
List-Unsubscribe: <https://lists.denx.de/options/u-boot>,
 <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>
List-Archive: <https://lists.denx.de/pipermail/u-boot/>
List-Post: <mailto:u-boot@lists.denx.de>
List-Help: <mailto:u-boot-request@lists.denx.de?subject=help>
List-Subscribe: <https://lists.denx.de/listinfo/u-boot>,
 <mailto:u-boot-request@lists.denx.de?subject=subscribe>
Errors-To: u-boot-bounces@lists.denx.de
Sender: "U-Boot" <u-boot-bounces@lists.denx.de>
X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de
X-Virus-Status: Clean

Default parent clock for the PWM on Tegra is a 32kHz clock and
is unable to support the requested PWM period.

Fix PWM support on Tegra20, Tegra30, Tegra114, Tegra124 and Tegra210 by
updating the parent clock for the PWM to be the PLL_P.

This commit is equivalent to Linux kernel commit:
https://lore.kernel.org/all/20221010100046.6477-1-jonathanh@nvidia.com/

Tested-by: Andreas Westman Dorcsak <hedmoo@yahoo.com> # ASUS TF T30
Tested-by: Robert Eckelmann <longnoserob@gmail.com> # ASUS TF101 T20
Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # ASUS TF201 T30
Tested-by: Thierry Reding <treding@nvidia.com> # T30 and T124
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 arch/arm/dts/tegra114.dtsi           |  2 +-
 arch/arm/dts/tegra124.dtsi           |  2 +-
 arch/arm/mach-tegra/tegra114/clock.c |  2 +-
 arch/arm/mach-tegra/tegra124/clock.c |  2 +-
 arch/arm/mach-tegra/tegra20/clock.c  |  2 +-
 arch/arm/mach-tegra/tegra210/clock.c |  2 +-
 arch/arm/mach-tegra/tegra30/clock.c  |  2 +-
 drivers/pwm/tegra_pwm.c              | 10 ++++++----
 8 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/arch/arm/dts/tegra114.dtsi b/arch/arm/dts/tegra114.dtsi
index 8932ea3afd..68ee7f3165 100644
--- a/arch/arm/dts/tegra114.dtsi
+++ b/arch/arm/dts/tegra114.dtsi
@@ -312,7 +312,7 @@
 	};
 
 	pwm: pwm@7000a000 {
-		compatible = "nvidia,tegra114-pwm", "nvidia,tegra20-pwm";
+		compatible = "nvidia,tegra114-pwm";
 		reg = <0x7000a000 0x100>;
 		#pwm-cells = <2>;
 		clocks = <&tegra_car TEGRA114_CLK_PWM>;
diff --git a/arch/arm/dts/tegra124.dtsi b/arch/arm/dts/tegra124.dtsi
index f473ba28e4..ffec9cae09 100644
--- a/arch/arm/dts/tegra124.dtsi
+++ b/arch/arm/dts/tegra124.dtsi
@@ -377,7 +377,7 @@
 	};
 
 	pwm: pwm@7000a000 {
-		compatible = "nvidia,tegra124-pwm", "nvidia,tegra20-pwm";
+		compatible = "nvidia,tegra124-pwm", "nvidia,tegra114-pwm";
 		reg = <0x7000a000 0x100>;
 		#pwm-cells = <2>;
 		clocks = <&tegra_car TEGRA124_CLK_PWM>;
diff --git a/arch/arm/mach-tegra/tegra114/clock.c b/arch/arm/mach-tegra/tegra114/clock.c
index 15c2adc417..8ad71f590f 100644
--- a/arch/arm/mach-tegra/tegra114/clock.c
+++ b/arch/arm/mach-tegra/tegra114/clock.c
@@ -782,7 +782,7 @@ struct periph_clk_init periph_clk_init_table[] = {
 	{ PERIPH_ID_SDMMC2, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_SDMMC3, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_SDMMC4, CLOCK_ID_PERIPH },
-	{ PERIPH_ID_PWM, CLOCK_ID_SFROM32KHZ },
+	{ PERIPH_ID_PWM, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_I2C1, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_I2C2, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_I2C3, CLOCK_ID_PERIPH },
diff --git a/arch/arm/mach-tegra/tegra124/clock.c b/arch/arm/mach-tegra/tegra124/clock.c
index 415ba15e5d..ca9549a318 100644
--- a/arch/arm/mach-tegra/tegra124/clock.c
+++ b/arch/arm/mach-tegra/tegra124/clock.c
@@ -1208,7 +1208,7 @@ struct periph_clk_init periph_clk_init_table[] = {
 	{ PERIPH_ID_SDMMC2, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_SDMMC3, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_SDMMC4, CLOCK_ID_PERIPH },
-	{ PERIPH_ID_PWM, CLOCK_ID_SFROM32KHZ },
+	{ PERIPH_ID_PWM, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_I2C1, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_I2C2, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_I2C3, CLOCK_ID_PERIPH },
diff --git a/arch/arm/mach-tegra/tegra20/clock.c b/arch/arm/mach-tegra/tegra20/clock.c
index 593622bfdc..067a9f1a2f 100644
--- a/arch/arm/mach-tegra/tegra20/clock.c
+++ b/arch/arm/mach-tegra/tegra20/clock.c
@@ -804,7 +804,7 @@ struct periph_clk_init periph_clk_init_table[] = {
 	{ PERIPH_ID_SDMMC2, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_SDMMC3, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_SDMMC4, CLOCK_ID_PERIPH },
-	{ PERIPH_ID_PWM, CLOCK_ID_SFROM32KHZ },
+	{ PERIPH_ID_PWM, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_DVC_I2C, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_I2C1, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_I2C2, CLOCK_ID_PERIPH },
diff --git a/arch/arm/mach-tegra/tegra210/clock.c b/arch/arm/mach-tegra/tegra210/clock.c
index 76fbfef580..900537afbe 100644
--- a/arch/arm/mach-tegra/tegra210/clock.c
+++ b/arch/arm/mach-tegra/tegra210/clock.c
@@ -1278,7 +1278,7 @@ struct periph_clk_init periph_clk_init_table[] = {
 	{ PERIPH_ID_SDMMC2, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_SDMMC3, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_SDMMC4, CLOCK_ID_PERIPH },
-	{ PERIPH_ID_PWM, CLOCK_ID_SFROM32KHZ },
+	{ PERIPH_ID_PWM, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_I2C1, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_I2C2, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_I2C3, CLOCK_ID_PERIPH },
diff --git a/arch/arm/mach-tegra/tegra30/clock.c b/arch/arm/mach-tegra/tegra30/clock.c
index b66211ce94..1dc9d09dba 100644
--- a/arch/arm/mach-tegra/tegra30/clock.c
+++ b/arch/arm/mach-tegra/tegra30/clock.c
@@ -884,7 +884,7 @@ struct periph_clk_init periph_clk_init_table[] = {
 	{ PERIPH_ID_SDMMC2, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_SDMMC3, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_SDMMC4, CLOCK_ID_PERIPH },
-	{ PERIPH_ID_PWM, CLOCK_ID_SFROM32KHZ },
+	{ PERIPH_ID_PWM, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_DVC_I2C, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_I2C1, CLOCK_ID_PERIPH },
 	{ PERIPH_ID_I2C2, CLOCK_ID_PERIPH },
diff --git a/drivers/pwm/tegra_pwm.c b/drivers/pwm/tegra_pwm.c
index 36c35c608b..95fc26458b 100644
--- a/drivers/pwm/tegra_pwm.c
+++ b/drivers/pwm/tegra_pwm.c
@@ -20,19 +20,21 @@ static int tegra_pwm_set_config(struct udevice *dev, uint channel,
 {
 	struct tegra_pwm_priv *priv = dev_get_priv(dev);
 	struct pwm_ctlr *regs = priv->regs;
+	const u32 pwm_max_freq = dev_get_driver_data(dev);
 	uint pulse_width;
 	u32 reg;
 
 	if (channel >= 4)
 		return -EINVAL;
 	debug("%s: Configure '%s' channel %u\n", __func__, dev->name, channel);
-	/* We ignore the period here and just use 32KHz */
-	clock_start_periph_pll(PERIPH_ID_PWM, CLOCK_ID_SFROM32KHZ, 32768);
+
+	clock_start_periph_pll(PERIPH_ID_PWM, CLOCK_ID_PERIPH, pwm_max_freq);
 
 	pulse_width = duty_ns * 255 / period_ns;
 
 	reg = pulse_width << PWM_WIDTH_SHIFT;
 	reg |= 1 << PWM_DIVIDER_SHIFT;
+	reg |= PWM_ENABLE_MASK;
 	writel(reg, &regs[channel].control);
 	debug("%s: pulse_width=%u\n", __func__, pulse_width);
 
@@ -68,8 +70,8 @@ static const struct pwm_ops tegra_pwm_ops = {
 };
 
 static const struct udevice_id tegra_pwm_ids[] = {
-	{ .compatible = "nvidia,tegra124-pwm" },
-	{ .compatible = "nvidia,tegra20-pwm" },
+	{ .compatible = "nvidia,tegra20-pwm", .data = 48 * 1000000 },
+	{ .compatible = "nvidia,tegra114-pwm", .data = 408 * 1000000 },
 	{ }
 };
 

From patchwork Tue Feb 14 17:35:29 2023
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Svyatoslav Ryhel <clamor95@gmail.com>
X-Patchwork-Id: 1742543
X-Patchwork-Delegate: twarren@nvidia.com
Return-Path: <u-boot-bounces@lists.denx.de>
X-Original-To: incoming@patchwork.ozlabs.org
Delivered-To: patchwork-incoming@legolas.ozlabs.org
Authentication-Results: legolas.ozlabs.org;
 spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de
 (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de;
 envelope-from=u-boot-bounces@lists.denx.de; receiver=<UNKNOWN>)
Authentication-Results: legolas.ozlabs.org;
	dkim=pass (2048-bit key;
 unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256
 header.s=20210112 header.b=D1ud6KAR;
	dkim-atps=neutral
Received: from phobos.denx.de (phobos.denx.de
 [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (P-384))
	(No client certificate requested)
	by legolas.ozlabs.org (Postfix) with ESMTPS id 4PGT1q3KTLz23r4
	for <incoming@patchwork.ozlabs.org>; Wed, 15 Feb 2023 04:37:51 +1100 (AEDT)
Received: from h2850616.stratoserver.net (localhost [IPv6:::1])
	by phobos.denx.de (Postfix) with ESMTP id 85500859E0;
	Tue, 14 Feb 2023 18:36:35 +0100 (CET)
Authentication-Results: phobos.denx.de;
 dmarc=pass (p=none dis=none) header.from=gmail.com
Authentication-Results: phobos.denx.de;
 spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de
Authentication-Results: phobos.denx.de;
	dkim=pass (2048-bit key;
 unprotected) header.d=gmail.com header.i=@gmail.com header.b="D1ud6KAR";
	dkim-atps=neutral
Received: by phobos.denx.de (Postfix, from userid 109)
 id 663AD85997; Tue, 14 Feb 2023 18:36:14 +0100 (CET)
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de
X-Spam-Level: 
X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,
 DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT,
 FREEMAIL_FROM,SPF_HELO_NONE,SPF_PASS autolearn=unavailable
 autolearn_force=no version=3.4.2
Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com
 [IPv6:2a00:1450:4864:20::32c])
 (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits))
 (No client certificate requested)
 by phobos.denx.de (Postfix) with ESMTPS id 084AF8597D
 for <u-boot@lists.denx.de>; Tue, 14 Feb 2023 18:36:08 +0100 (CET)
Authentication-Results: phobos.denx.de;
 dmarc=pass (p=none dis=none) header.from=gmail.com
Authentication-Results: phobos.denx.de;
 spf=pass smtp.mailfrom=clamor95@gmail.com
Received: by mail-wm1-x32c.google.com with SMTP id
 j29-20020a05600c1c1d00b003dc52fed235so12195123wms.1
 for <u-boot@lists.denx.de>; Tue, 14 Feb 2023 09:36:07 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=wp28/xkeLmwbhh2riWd4DCrf5Sy7liDDt0TXBFUSbTM=;
 b=D1ud6KAR/a5+X4pDO1y4SvN1BvUML72VT1onsgI5v6B/A/xk3Dg2m6SdEMzhMz6XwJ
 sZnx4c+sWblNiKLmnNExuQTCQ2/htLKlXLST3mgon2yssnAr9fVQGr9bXUORXbWMGa3C
 +TscxgLoOTA1HewVqaCQIuHOzdYleIxX8OFyOMki8wnh4SeCMJ0f2seXKsKiNkzxlkFf
 w6R8D5dVSISFpSIq5nHOoZp0w2tXonDKfFrYBW/+ugAg6GxLpTrq+Y2hSUO0bNFrX5zz
 G54h1znJmVQuS0A4NNR/PbQafCIwETNIsRyTHZ8AvMVqnu6JL3sqluxVky5m/FTR2V5m
 chKA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=wp28/xkeLmwbhh2riWd4DCrf5Sy7liDDt0TXBFUSbTM=;
 b=h5v+HJ/VnCmaMpQ0pt+/mXAFbnHltCrZ1Q1hWycCy4m3ruGRf3cQgmTM+Sae6u8Vsr
 xww99nn2iTQXZ1UmSHL9qVZzMHrXTTWHQHhiKjTNc+5aEWxWpEKwTZGOD9RbSYZuKPBP
 8ScNL3mz9KHKhnsFu+c865a/zP7CcFuZlMnuJedHlmyVV4Ylb1PJrULemcHEwmQ8AypW
 C02xZ9j4UMrrNHrWnUpr34X/gx9LTkWkfaDU4OHPCK7f2PTLh9nQZd+o0FfsKDnbcOS8
 NvDbRU/9EFlwsF/+GY92wk9AKzEPNByMwDEYEGgNq4mq3alcHo08pE0ztiJhnT8a9vdP
 rfdQ==
X-Gm-Message-State: AO0yUKWNKSwgDqT4tYLl8BL1iCVPfcyCfwmlgv4CEef6Z/RaxLM7/Gfi
 qXy8tJG1ACBubKITWZCY68M=
X-Google-Smtp-Source: 
 AK7set/BVi7Q4QFQZ+RBR70VZhk16tohTeVpGJ3ym4KeH7bixKaMzmpO73UyINbubOB5HRxJUildMA==
X-Received: by 2002:a05:600c:a0b:b0:3e1:e149:b67b with SMTP id
 z11-20020a05600c0a0b00b003e1e149b67bmr384797wmp.18.1676396167089;
 Tue, 14 Feb 2023 09:36:07 -0800 (PST)
Received: from xeon.. ([188.163.112.76]) by smtp.gmail.com with ESMTPSA id
 m23-20020a7bca57000000b003de8a1b06c0sm20787829wml.7.2023.02.14.09.36.06
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 14 Feb 2023 09:36:06 -0800 (PST)
From: Svyatoslav Ryhel <clamor95@gmail.com>
To: Tom Warren <twarren@nvidia.com>,
 Marcel Ziswiler <marcel.ziswiler@toradex.com>,
 Allen Martin <amartin@nvidia.com>, Jagan Teki <jagan@amarulasolutions.com>,
 Lukasz Majewski <lukma@denx.de>, Marek Vasut <marex@denx.de>,
 Svyatoslav Ryhel <clamor95@gmail.com>,
 Ramin Khonsari <raminterex@yahoo.com>,
 Thierry Reding <thierry.reding@gmail.com>,
 Maxim Schwalm <maxim.schwalm@gmail.com>,
 Dmitry Osipenko <digetx@gmail.com>, Simon Glass <sjg@chromium.org>
Cc: u-boot@lists.denx.de
Subject: [PATCH v4 07/16] spi: tegra20_slink: accept any word length
Date: Tue, 14 Feb 2023 19:35:29 +0200
Message-Id: <20230214173538.6242-8-clamor95@gmail.com>
X-Mailer: git-send-email 2.37.2
In-Reply-To: <20230214173538.6242-1-clamor95@gmail.com>
References: <20230214173538.6242-1-clamor95@gmail.com>
MIME-Version: 1.0
X-BeenThere: u-boot@lists.denx.de
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: U-Boot discussion <u-boot.lists.denx.de>
List-Unsubscribe: <https://lists.denx.de/options/u-boot>,
 <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>
List-Archive: <https://lists.denx.de/pipermail/u-boot/>
List-Post: <mailto:u-boot@lists.denx.de>
List-Help: <mailto:u-boot-request@lists.denx.de?subject=help>
List-Subscribe: <https://lists.denx.de/listinfo/u-boot>,
 <mailto:u-boot-request@lists.denx.de?subject=subscribe>
Errors-To: u-boot-bounces@lists.denx.de
Sender: "U-Boot" <u-boot-bounces@lists.denx.de>
X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de
X-Virus-Status: Clean

Original t20 slink could work with commands only
fully divisible by 8. This patch removes such
restriction, so commands of any bitlength now
can be passed and processed.

Tested-by: Andreas Westman Dorcsak <hedmoo@yahoo.com> # ASUS TF600T T30
Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # LG P895 T30
Tested-by: Thierry Reding <treding@nvidia.com> # T30 and T124
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 drivers/spi/tegra20_slink.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/drivers/spi/tegra20_slink.c b/drivers/spi/tegra20_slink.c
index 209ba8b0cc..d0e788539e 100644
--- a/drivers/spi/tegra20_slink.c
+++ b/drivers/spi/tegra20_slink.c
@@ -208,16 +208,14 @@ static int tegra30_spi_xfer(struct udevice *dev, unsigned int bitlen,
 	u32 reg, tmpdout, tmpdin = 0;
 	const u8 *dout = data_out;
 	u8 *din = data_in;
-	int num_bytes;
-	int ret;
+	int num_bytes, overflow;
+	int ret = 0;
 
 	debug("%s: slave %u:%u dout %p din %p bitlen %u\n",
 	      __func__, dev_seq(bus), spi_chip_select(dev), dout, din, bitlen);
-	if (bitlen % 8)
-		return -1;
-	num_bytes = bitlen / 8;
 
-	ret = 0;
+	num_bytes = DIV_ROUND_UP(bitlen, 8);
+	overflow = bitlen % 8;
 
 	reg = readl(&regs->status);
 	writel(reg, &regs->status);	/* Clear all SPI events via R/W */
@@ -254,8 +252,13 @@ static int tegra30_spi_xfer(struct udevice *dev, unsigned int bitlen,
 
 		num_bytes -= bytes;
 
-		clrsetbits_le32(&regs->command, SLINK_CMD_BIT_LENGTH_MASK,
-				bytes * 8 - 1);
+		if (overflow && !num_bytes)
+			clrsetbits_le32(&regs->command, SLINK_CMD_BIT_LENGTH_MASK,
+					(bytes - 1) * 8 + overflow - 1);
+		else
+			clrsetbits_le32(&regs->command, SLINK_CMD_BIT_LENGTH_MASK,
+					bytes * 8 - 1);
+
 		writel(tmpdout, &regs->tx_fifo);
 		setbits_le32(&regs->command, SLINK_CMD_GO);
 

From patchwork Tue Feb 14 17:35:30 2023
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Svyatoslav Ryhel <clamor95@gmail.com>
X-Patchwork-Id: 1742546
X-Patchwork-Delegate: twarren@nvidia.com
Return-Path: <u-boot-bounces@lists.denx.de>
X-Original-To: incoming@patchwork.ozlabs.org
Delivered-To: patchwork-incoming@legolas.ozlabs.org
Authentication-Results: legolas.ozlabs.org;
 spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de
 (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de;
 envelope-from=u-boot-bounces@lists.denx.de; receiver=<UNKNOWN>)
Authentication-Results: legolas.ozlabs.org;
	dkim=pass (2048-bit key;
 unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256
 header.s=20210112 header.b=OD7LrR1L;
	dkim-atps=neutral
Received: from phobos.denx.de (phobos.denx.de
 [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (P-384))
	(No client certificate requested)
	by legolas.ozlabs.org (Postfix) with ESMTPS id 4PGT2346wtz23r4
	for <incoming@patchwork.ozlabs.org>; Wed, 15 Feb 2023 04:38:03 +1100 (AEDT)
Received: from h2850616.stratoserver.net (localhost [IPv6:::1])
	by phobos.denx.de (Postfix) with ESMTP id 4108B859EE;
	Tue, 14 Feb 2023 18:36:38 +0100 (CET)
Authentication-Results: phobos.denx.de;
 dmarc=pass (p=none dis=none) header.from=gmail.com
Authentication-Results: phobos.denx.de;
 spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de
Authentication-Results: phobos.denx.de;
	dkim=pass (2048-bit key;
 unprotected) header.d=gmail.com header.i=@gmail.com header.b="OD7LrR1L";
	dkim-atps=neutral
Received: by phobos.denx.de (Postfix, from userid 109)
 id A9143859E5; Tue, 14 Feb 2023 18:36:18 +0100 (CET)
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de
X-Spam-Level: 
X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,
 DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT,
 FREEMAIL_FROM,SPF_HELO_NONE,SPF_PASS autolearn=unavailable
 autolearn_force=no version=3.4.2
Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com
 [IPv6:2a00:1450:4864:20::335])
 (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits))
 (No client certificate requested)
 by phobos.denx.de (Postfix) with ESMTPS id 3AC21859DB
 for <u-boot@lists.denx.de>; Tue, 14 Feb 2023 18:36:09 +0100 (CET)
Authentication-Results: phobos.denx.de;
 dmarc=pass (p=none dis=none) header.from=gmail.com
Authentication-Results: phobos.denx.de;
 spf=pass smtp.mailfrom=clamor95@gmail.com
Received: by mail-wm1-x335.google.com with SMTP id
 l37-20020a05600c1d2500b003dfe46a9801so12231169wms.0
 for <u-boot@lists.denx.de>; Tue, 14 Feb 2023 09:36:09 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=aEZRVIt6wpg7RGzG5UTWTOfPE2XHVsHJrSKdY0WEDdY=;
 b=OD7LrR1LaoWg+3D++0fAEFdqLpbWaBw19o7iqFZaaRzRo68hhLrJGr2ZgTgI6w8800
 zmP7Vs8gCHHVY22tDfPLAaqOpZC/TueNuZQQNdMcI1FDgJpI7pcgwJlYkN7E69Tb/Kre
 737Eb41hkoa+IuKWx6r69GSm9Bs8jTOF/2GJuMCz/tU4q4iGZMEz1m2aQpyuAwvmFnlw
 hrfEC87s1F+b3vRkqGGH+XrfIsAsoSJmw3MPjeM8lf9P0lY+twqyLi1zsQiO1p0Ucdt7
 g4wKm1Fs6wTkx71MrjaFMbhfblbfXywpRRQmmqAtlbVhs+wet+isUI4GoZJXNzYMQ13F
 /+Vg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=aEZRVIt6wpg7RGzG5UTWTOfPE2XHVsHJrSKdY0WEDdY=;
 b=2HBeoTSisguwu/8VeA/jjUD30ydbCari7bSlGA+K677+np9GGEFokhh4NvHTHN1zIz
 KDbUw4AQmIaotrnCcFkPUnLDDZRi0AIGA0Y3Gf/UjGkkqb28yAneARdEg9ZR1mVb3n+l
 XrZ555GBtkoqsKWKC4o7LMCyyszhICWyOhybwSOsl3l+qcLA9SKBvcN19mc+u/ZFJGy4
 fAXMPGU/Yiweh7VgKhnBNnxRj5GxFcKkNntYLK2zHELmy2cCuLRye4XloRnr50i2BD6s
 /eTB2PR5yc1KjV8ec8hkVZB+BF/65FRPBiVlk0I+He6aOJGhNxvVmqJkQj1gQAIhv2N6
 N6Ng==
X-Gm-Message-State: AO0yUKUjYXLQ3M5WbY6QPBW4EBnFV3kFE2c84bZk2Y2Q8mY1E5UfjRxL
 OhQ4l5fN3sZP8lf70d4z3cs=
X-Google-Smtp-Source: 
 AK7set9xKVaGVaHRAaIMOedZd22oE+X/HAMGzfc4E7YRH96bhaa+0NifKD9RbCu3HFW++X2ikJ7wIA==
X-Received: by 2002:a05:600c:4d15:b0:3df:dc0d:f0b3 with SMTP id
 u21-20020a05600c4d1500b003dfdc0df0b3mr2541835wmp.9.1676396168192;
 Tue, 14 Feb 2023 09:36:08 -0800 (PST)
Received: from xeon.. ([188.163.112.76]) by smtp.gmail.com with ESMTPSA id
 m23-20020a7bca57000000b003de8a1b06c0sm20787829wml.7.2023.02.14.09.36.07
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 14 Feb 2023 09:36:07 -0800 (PST)
From: Svyatoslav Ryhel <clamor95@gmail.com>
To: Tom Warren <twarren@nvidia.com>,
 Marcel Ziswiler <marcel.ziswiler@toradex.com>,
 Allen Martin <amartin@nvidia.com>, Jagan Teki <jagan@amarulasolutions.com>,
 Lukasz Majewski <lukma@denx.de>, Marek Vasut <marex@denx.de>,
 Svyatoslav Ryhel <clamor95@gmail.com>,
 Ramin Khonsari <raminterex@yahoo.com>,
 Thierry Reding <thierry.reding@gmail.com>,
 Maxim Schwalm <maxim.schwalm@gmail.com>,
 Dmitry Osipenko <digetx@gmail.com>, Simon Glass <sjg@chromium.org>
Cc: u-boot@lists.denx.de
Subject: [PATCH v4 08/16] ARM: tegra: provide default USB gadget setup
Date: Tue, 14 Feb 2023 19:35:30 +0200
Message-Id: <20230214173538.6242-9-clamor95@gmail.com>
X-Mailer: git-send-email 2.37.2
In-Reply-To: <20230214173538.6242-1-clamor95@gmail.com>
References: <20230214173538.6242-1-clamor95@gmail.com>
MIME-Version: 1.0
X-BeenThere: u-boot@lists.denx.de
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: U-Boot discussion <u-boot.lists.denx.de>
List-Unsubscribe: <https://lists.denx.de/options/u-boot>,
 <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>
List-Archive: <https://lists.denx.de/pipermail/u-boot/>
List-Post: <mailto:u-boot@lists.denx.de>
List-Help: <mailto:u-boot-request@lists.denx.de?subject=help>
List-Subscribe: <https://lists.denx.de/listinfo/u-boot>,
 <mailto:u-boot-request@lists.denx.de?subject=subscribe>
Errors-To: u-boot-bounces@lists.denx.de
Sender: "U-Boot" <u-boot-bounces@lists.denx.de>
X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de
X-Virus-Status: Clean

From: Maxim Schwalm <maxim.schwalm@gmail.com>

All Nvidia boards use the same manufacturer, vendor ID and product ID
for the gadgets. Make them the defaults to remove some boilerplate from
the defconfigs.

Inspired by commit e02687bda96c ("sunxi: provide default USB gadget
setup") which did the same for Allwinner boards.

Tested-by: Thierry Reding <treding@nvidia.com> # T30 and T124
Signed-off-by: Maxim Schwalm <maxim.schwalm@gmail.com>
---
 configs/beaver_defconfig      | 3 ---
 configs/cei-tk1-som_defconfig | 3 ---
 configs/dalmore_defconfig     | 3 ---
 configs/jetson-tk1_defconfig  | 3 ---
 configs/nyan-big_defconfig    | 3 ---
 configs/p2371-0000_defconfig  | 3 ---
 configs/p2371-2180_defconfig  | 3 ---
 configs/p2571_defconfig       | 3 ---
 configs/p3450-0000_defconfig  | 3 ---
 configs/venice2_defconfig     | 3 ---
 drivers/usb/gadget/Kconfig    | 3 +++
 11 files changed, 3 insertions(+), 30 deletions(-)

diff --git a/configs/beaver_defconfig b/configs/beaver_defconfig
index 0967367e6a..693ccb893d 100644
--- a/configs/beaver_defconfig
+++ b/configs/beaver_defconfig
@@ -64,8 +64,5 @@ CONFIG_USB_EHCI_TEGRA=y
 CONFIG_USB_HOST_ETHER=y
 CONFIG_USB_ETHER_ASIX=y
 CONFIG_USB_GADGET=y
-CONFIG_USB_GADGET_MANUFACTURER="NVIDIA"
-CONFIG_USB_GADGET_VENDOR_NUM=0x0955
-CONFIG_USB_GADGET_PRODUCT_NUM=0x701a
 CONFIG_CI_UDC=y
 CONFIG_USB_GADGET_DOWNLOAD=y
diff --git a/configs/cei-tk1-som_defconfig b/configs/cei-tk1-som_defconfig
index 0c4627aff0..6578ee83d9 100644
--- a/configs/cei-tk1-som_defconfig
+++ b/configs/cei-tk1-som_defconfig
@@ -70,8 +70,5 @@ CONFIG_USB_EHCI_TEGRA=y
 CONFIG_USB_HOST_ETHER=y
 CONFIG_USB_ETHER_ASIX=y
 CONFIG_USB_GADGET=y
-CONFIG_USB_GADGET_MANUFACTURER="NVIDIA"
-CONFIG_USB_GADGET_VENDOR_NUM=0x0955
-CONFIG_USB_GADGET_PRODUCT_NUM=0x701a
 CONFIG_CI_UDC=y
 CONFIG_USB_GADGET_DOWNLOAD=y
diff --git a/configs/dalmore_defconfig b/configs/dalmore_defconfig
index 5d29dae341..4507ddc84b 100644
--- a/configs/dalmore_defconfig
+++ b/configs/dalmore_defconfig
@@ -60,8 +60,5 @@ CONFIG_USB_EHCI_TEGRA=y
 CONFIG_USB_HOST_ETHER=y
 CONFIG_USB_ETHER_ASIX=y
 CONFIG_USB_GADGET=y
-CONFIG_USB_GADGET_MANUFACTURER="NVIDIA"
-CONFIG_USB_GADGET_VENDOR_NUM=0x0955
-CONFIG_USB_GADGET_PRODUCT_NUM=0x701a
 CONFIG_CI_UDC=y
 CONFIG_USB_GADGET_DOWNLOAD=y
diff --git a/configs/jetson-tk1_defconfig b/configs/jetson-tk1_defconfig
index d935e784ab..bcf45458a6 100644
--- a/configs/jetson-tk1_defconfig
+++ b/configs/jetson-tk1_defconfig
@@ -70,8 +70,5 @@ CONFIG_USB_EHCI_TEGRA=y
 CONFIG_USB_HOST_ETHER=y
 CONFIG_USB_ETHER_ASIX=y
 CONFIG_USB_GADGET=y
-CONFIG_USB_GADGET_MANUFACTURER="NVIDIA"
-CONFIG_USB_GADGET_VENDOR_NUM=0x0955
-CONFIG_USB_GADGET_PRODUCT_NUM=0x701a
 CONFIG_CI_UDC=y
 CONFIG_USB_GADGET_DOWNLOAD=y
diff --git a/configs/nyan-big_defconfig b/configs/nyan-big_defconfig
index e2e8bebf6d..fef9141d35 100644
--- a/configs/nyan-big_defconfig
+++ b/configs/nyan-big_defconfig
@@ -93,9 +93,6 @@ CONFIG_USB_EHCI_TEGRA=y
 CONFIG_USB_HOST_ETHER=y
 CONFIG_USB_ETHER_ASIX=y
 CONFIG_USB_GADGET=y
-CONFIG_USB_GADGET_MANUFACTURER="NVIDIA"
-CONFIG_USB_GADGET_VENDOR_NUM=0x0955
-CONFIG_USB_GADGET_PRODUCT_NUM=0x701a
 CONFIG_CI_UDC=y
 CONFIG_USB_GADGET_DOWNLOAD=y
 CONFIG_VIDEO=y
diff --git a/configs/p2371-0000_defconfig b/configs/p2371-0000_defconfig
index e8074914c8..2962a7db75 100644
--- a/configs/p2371-0000_defconfig
+++ b/configs/p2371-0000_defconfig
@@ -48,8 +48,5 @@ CONFIG_USB_EHCI_TEGRA=y
 CONFIG_USB_HOST_ETHER=y
 CONFIG_USB_ETHER_ASIX=y
 CONFIG_USB_GADGET=y
-CONFIG_USB_GADGET_MANUFACTURER="NVIDIA"
-CONFIG_USB_GADGET_VENDOR_NUM=0x0955
-CONFIG_USB_GADGET_PRODUCT_NUM=0x701a
 CONFIG_CI_UDC=y
 CONFIG_USB_GADGET_DOWNLOAD=y
diff --git a/configs/p2371-2180_defconfig b/configs/p2371-2180_defconfig
index ea62e18f73..6b44361b5b 100644
--- a/configs/p2371-2180_defconfig
+++ b/configs/p2371-2180_defconfig
@@ -57,8 +57,5 @@ CONFIG_USB_EHCI_TEGRA=y
 CONFIG_USB_HOST_ETHER=y
 CONFIG_USB_ETHER_ASIX=y
 CONFIG_USB_GADGET=y
-CONFIG_USB_GADGET_MANUFACTURER="NVIDIA"
-CONFIG_USB_GADGET_VENDOR_NUM=0x0955
-CONFIG_USB_GADGET_PRODUCT_NUM=0x701a
 CONFIG_CI_UDC=y
 CONFIG_USB_GADGET_DOWNLOAD=y
diff --git a/configs/p2571_defconfig b/configs/p2571_defconfig
index bc3fb3e5ae..00b0dc6109 100644
--- a/configs/p2571_defconfig
+++ b/configs/p2571_defconfig
@@ -49,8 +49,5 @@ CONFIG_USB_EHCI_TEGRA=y
 CONFIG_USB_HOST_ETHER=y
 CONFIG_USB_ETHER_ASIX=y
 CONFIG_USB_GADGET=y
-CONFIG_USB_GADGET_MANUFACTURER="NVIDIA"
-CONFIG_USB_GADGET_VENDOR_NUM=0x0955
-CONFIG_USB_GADGET_PRODUCT_NUM=0x701a
 CONFIG_CI_UDC=y
 CONFIG_USB_GADGET_DOWNLOAD=y
diff --git a/configs/p3450-0000_defconfig b/configs/p3450-0000_defconfig
index 8e16afde91..d35bea4220 100644
--- a/configs/p3450-0000_defconfig
+++ b/configs/p3450-0000_defconfig
@@ -61,8 +61,5 @@ CONFIG_USB_EHCI_TEGRA=y
 CONFIG_USB_HOST_ETHER=y
 CONFIG_USB_ETHER_ASIX=y
 CONFIG_USB_GADGET=y
-CONFIG_USB_GADGET_MANUFACTURER="NVIDIA"
-CONFIG_USB_GADGET_VENDOR_NUM=0x0955
-CONFIG_USB_GADGET_PRODUCT_NUM=0x701a
 CONFIG_CI_UDC=y
 CONFIG_USB_GADGET_DOWNLOAD=y
diff --git a/configs/venice2_defconfig b/configs/venice2_defconfig
index a754c20046..fe794b76ff 100644
--- a/configs/venice2_defconfig
+++ b/configs/venice2_defconfig
@@ -59,8 +59,5 @@ CONFIG_USB_EHCI_TEGRA=y
 CONFIG_USB_HOST_ETHER=y
 CONFIG_USB_ETHER_ASIX=y
 CONFIG_USB_GADGET=y
-CONFIG_USB_GADGET_MANUFACTURER="NVIDIA"
-CONFIG_USB_GADGET_VENDOR_NUM=0x0955
-CONFIG_USB_GADGET_PRODUCT_NUM=0x701a
 CONFIG_CI_UDC=y
 CONFIG_USB_GADGET_DOWNLOAD=y
diff --git a/drivers/usb/gadget/Kconfig b/drivers/usb/gadget/Kconfig
index e120efeb00..941f97c96d 100644
--- a/drivers/usb/gadget/Kconfig
+++ b/drivers/usb/gadget/Kconfig
@@ -40,6 +40,7 @@ if USB_GADGET
 
 config USB_GADGET_MANUFACTURER
 	string "Vendor name of the USB device"
+	default "NVIDIA" if ARCH_TEGRA
 	default "Allwinner Technology" if ARCH_SUNXI
 	default "Rockchip" if ARCH_ROCKCHIP
 	default "U-Boot"
@@ -49,6 +50,7 @@ config USB_GADGET_MANUFACTURER
 
 config USB_GADGET_VENDOR_NUM
 	hex "Vendor ID of the USB device"
+	default 0x0955 if ARCH_TEGRA
 	default 0x1f3a if ARCH_SUNXI
 	default 0x2207 if ARCH_ROCKCHIP
 	default 0x0
@@ -59,6 +61,7 @@ config USB_GADGET_VENDOR_NUM
 
 config USB_GADGET_PRODUCT_NUM
 	hex "Product ID of the USB device"
+	default 0x701a if ARCH_TEGRA
 	default 0x1010 if ARCH_SUNXI
 	default 0x310a if ROCKCHIP_RK3036
 	default 0x300a if ROCKCHIP_RK3066

From patchwork Tue Feb 14 17:35:31 2023
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Svyatoslav Ryhel <clamor95@gmail.com>
X-Patchwork-Id: 1742547
X-Patchwork-Delegate: twarren@nvidia.com
Return-Path: <u-boot-bounces@lists.denx.de>
X-Original-To: incoming@patchwork.ozlabs.org
Delivered-To: patchwork-incoming@legolas.ozlabs.org
Authentication-Results: legolas.ozlabs.org;
 spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de
 (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de;
 envelope-from=u-boot-bounces@lists.denx.de; receiver=<UNKNOWN>)
Authentication-Results: legolas.ozlabs.org;
	dkim=pass (2048-bit key;
 unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256
 header.s=20210112 header.b=j9sZIji4;
	dkim-atps=neutral
Received: from phobos.denx.de (phobos.denx.de
 [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (P-384))
	(No client certificate requested)
	by legolas.ozlabs.org (Postfix) with ESMTPS id 4PGT2H3xY5z23r4
	for <incoming@patchwork.ozlabs.org>; Wed, 15 Feb 2023 04:38:15 +1100 (AEDT)
Received: from h2850616.stratoserver.net (localhost [IPv6:::1])
	by phobos.denx.de (Postfix) with ESMTP id DBA45859F2;
	Tue, 14 Feb 2023 18:36:40 +0100 (CET)
Authentication-Results: phobos.denx.de;
 dmarc=pass (p=none dis=none) header.from=gmail.com
Authentication-Results: phobos.denx.de;
 spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de
Authentication-Results: phobos.denx.de;
	dkim=pass (2048-bit key;
 unprotected) header.d=gmail.com header.i=@gmail.com header.b="j9sZIji4";
	dkim-atps=neutral
Received: by phobos.denx.de (Postfix, from userid 109)
 id 646BA859F1; Tue, 14 Feb 2023 18:36:18 +0100 (CET)
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de
X-Spam-Level: 
X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,
 DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT,
 FREEMAIL_FROM,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no
 version=3.4.2
Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com
 [IPv6:2a00:1450:4864:20::32a])
 (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits))
 (No client certificate requested)
 by phobos.denx.de (Postfix) with ESMTPS id DFEA8859E5
 for <u-boot@lists.denx.de>; Tue, 14 Feb 2023 18:36:09 +0100 (CET)
Authentication-Results: phobos.denx.de;
 dmarc=pass (p=none dis=none) header.from=gmail.com
Authentication-Results: phobos.denx.de;
 spf=pass smtp.mailfrom=clamor95@gmail.com
Received: by mail-wm1-x32a.google.com with SMTP id he5so3685793wmb.3
 for <u-boot@lists.denx.de>; Tue, 14 Feb 2023 09:36:09 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=+vWFP4hZIPC4GvldRbRJyLgcXIXmacZjzAD6wm1ZwWs=;
 b=j9sZIji4yfb2UKFPwsH6qzW2VLIHS2xjpOs/Qj/V6aB7M4UcgUrm0byWI3RXkGrCol
 mqCbnW+oDxk+9cR+l3HJ7Cq96LQwrDcf5uUBa/DsR9Hhc1W+McZrP/89II77hnTgchV9
 TipECWQz9tvxgNuOS988FEQ/NYg/K1LFxV9J9HtY38W4z6dscEJSjoLE1S6rAnOR8wRD
 cX90O4uA0CEIppa2yWvkK8/if92CwBE0zwKSoRnJB0a8CJt37tO+bGsrvEEZvKNZbzVW
 KDddEqPyQ5pTiPUO6y+aYodbXVWh2avl1fac+Ogvxx4XbHyDRnZ4r/9uY1jDnzIvaq+r
 S6OA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=+vWFP4hZIPC4GvldRbRJyLgcXIXmacZjzAD6wm1ZwWs=;
 b=evKpqCbNiE6gImS43HWpjCUqe0JO2enIoWny4j8XVdFU56Hqwpy2l4aHChcLtXqbWQ
 7g+LtnEaYlrdNDtyjdB7i2P6ZHQrJb2SpOXtwrnt1Kjy0oGbNQg+lyFp+9ifLkNdor3j
 hqASF2+VQx71brrHNEvj+nN7I033bgJbC6rqui9KtdQrY5aaVrf+aF9aHNiaSCXLt4Bc
 8S6NgGLMKXiAnSPGl8gCm+8mjVz3NVchYA8ZoZ0ar9ftD4fMCbHYEY9yX9Q0mhTt1C2W
 5l2vLEwZc0lcPIS7UI9jNZURX54OjyVvZ/ROztcY3FO5MUqb8NjrviUD+7AxE71OxRnK
 BSaA==
X-Gm-Message-State: AO0yUKXO+GvpgHcrHqh7nw6y7Z9/vkPtiOceSzcgOUUpqEU371kw4fx4
 yBHHgbJWHYizG3fWweD2TZOjFb4LQiNTvQ==
X-Google-Smtp-Source: 
 AK7set80PDOsxgwhpN9diM8hUrLfJ2rJUMKsFUEz0BH0bsbGD8ZYj7Dv6A+TNTcVHPlcaMFpwPQPuQ==
X-Received: by 2002:a05:600c:a292:b0:3dc:2137:d67d with SMTP id
 hu18-20020a05600ca29200b003dc2137d67dmr2636400wmb.16.1676396169294;
 Tue, 14 Feb 2023 09:36:09 -0800 (PST)
Received: from xeon.. ([188.163.112.76]) by smtp.gmail.com with ESMTPSA id
 m23-20020a7bca57000000b003de8a1b06c0sm20787829wml.7.2023.02.14.09.36.08
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 14 Feb 2023 09:36:09 -0800 (PST)
From: Svyatoslav Ryhel <clamor95@gmail.com>
To: Tom Warren <twarren@nvidia.com>,
 Marcel Ziswiler <marcel.ziswiler@toradex.com>,
 Allen Martin <amartin@nvidia.com>, Jagan Teki <jagan@amarulasolutions.com>,
 Lukasz Majewski <lukma@denx.de>, Marek Vasut <marex@denx.de>,
 Svyatoslav Ryhel <clamor95@gmail.com>,
 Ramin Khonsari <raminterex@yahoo.com>,
 Thierry Reding <thierry.reding@gmail.com>,
 Maxim Schwalm <maxim.schwalm@gmail.com>,
 Dmitry Osipenko <digetx@gmail.com>, Simon Glass <sjg@chromium.org>
Cc: u-boot@lists.denx.de
Subject: [PATCH v4 09/16] ARM: tegra: add late init support
Date: Tue, 14 Feb 2023 19:35:31 +0200
Message-Id: <20230214173538.6242-10-clamor95@gmail.com>
X-Mailer: git-send-email 2.37.2
In-Reply-To: <20230214173538.6242-1-clamor95@gmail.com>
References: <20230214173538.6242-1-clamor95@gmail.com>
MIME-Version: 1.0
X-BeenThere: u-boot@lists.denx.de
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: U-Boot discussion <u-boot.lists.denx.de>
List-Unsubscribe: <https://lists.denx.de/options/u-boot>,
 <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>
List-Archive: <https://lists.denx.de/pipermail/u-boot/>
List-Post: <mailto:u-boot@lists.denx.de>
List-Help: <mailto:u-boot-request@lists.denx.de?subject=help>
List-Subscribe: <https://lists.denx.de/listinfo/u-boot>,
 <mailto:u-boot-request@lists.denx.de?subject=subscribe>
Errors-To: u-boot-bounces@lists.denx.de
Sender: "U-Boot" <u-boot-bounces@lists.denx.de>
X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de
X-Virus-Status: Clean

Late init function allows passing values like identifiers and
perform device specific configurations of pre-boot stage.

Tested-by: Andreas Westman Dorcsak <hedmoo@yahoo.com> # ASUS TF T30
Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # LG P895 T30
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 arch/arm/include/asm/arch-tegra/sys_proto.h | 6 ++++++
 arch/arm/mach-tegra/board2.c                | 2 ++
 2 files changed, 8 insertions(+)

diff --git a/arch/arm/include/asm/arch-tegra/sys_proto.h b/arch/arm/include/asm/arch-tegra/sys_proto.h
index c3a2673e6c..566666a9a0 100644
--- a/arch/arm/include/asm/arch-tegra/sys_proto.h
+++ b/arch/arm/include/asm/arch-tegra/sys_proto.h
@@ -31,4 +31,10 @@ int tegra_lcd_pmic_init(int board_id);
  */
 int nvidia_board_init(void);
 
+/**
+ * nvidia_board_late_init() - perform any board-specific
+ *			      init on late stages
+ */
+void nvidia_board_late_init(void);
+
 #endif
diff --git a/arch/arm/mach-tegra/board2.c b/arch/arm/mach-tegra/board2.c
index c7a45f4ff8..0df18360ca 100644
--- a/arch/arm/mach-tegra/board2.c
+++ b/arch/arm/mach-tegra/board2.c
@@ -56,6 +56,7 @@ __weak void gpio_early_init_uart(void) {}
 __weak void pin_mux_display(void) {}
 __weak void start_cpu_fan(void) {}
 __weak void cboot_late_init(void) {}
+__weak void nvidia_board_late_init(void) {}
 
 #if defined(CONFIG_TEGRA_NAND)
 __weak void pin_mux_nand(void)
@@ -267,6 +268,7 @@ int board_late_init(void)
 #endif
 	start_cpu_fan();
 	cboot_late_init();
+	nvidia_board_late_init();
 
 	return 0;
 }

From patchwork Tue Feb 14 17:35:32 2023
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Svyatoslav Ryhel <clamor95@gmail.com>
X-Patchwork-Id: 1742548
X-Patchwork-Delegate: twarren@nvidia.com
Return-Path: <u-boot-bounces@lists.denx.de>
X-Original-To: incoming@patchwork.ozlabs.org
Delivered-To: patchwork-incoming@legolas.ozlabs.org
Authentication-Results: legolas.ozlabs.org;
 spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de
 (client-ip=85.214.62.61; helo=phobos.denx.de;
 envelope-from=u-boot-bounces@lists.denx.de; receiver=<UNKNOWN>)
Authentication-Results: legolas.ozlabs.org;
	dkim=pass (2048-bit key;
 unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256
 header.s=20210112 header.b=fz16VnJ9;
	dkim-atps=neutral
Received: from phobos.denx.de (phobos.denx.de [85.214.62.61])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (P-384))
	(No client certificate requested)
	by legolas.ozlabs.org (Postfix) with ESMTPS id 4PGT2W30D6z23r4
	for <incoming@patchwork.ozlabs.org>; Wed, 15 Feb 2023 04:38:27 +1100 (AEDT)
Received: from h2850616.stratoserver.net (localhost [IPv6:::1])
	by phobos.denx.de (Postfix) with ESMTP id 2C3FA859FB;
	Tue, 14 Feb 2023 18:36:43 +0100 (CET)
Authentication-Results: phobos.denx.de;
 dmarc=pass (p=none dis=none) header.from=gmail.com
Authentication-Results: phobos.denx.de;
 spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de
Authentication-Results: phobos.denx.de;
	dkim=pass (2048-bit key;
 unprotected) header.d=gmail.com header.i=@gmail.com header.b="fz16VnJ9";
	dkim-atps=neutral
Received: by phobos.denx.de (Postfix, from userid 109)
 id 66BC1859DB; Tue, 14 Feb 2023 18:36:19 +0100 (CET)
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de
X-Spam-Level: 
X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,
 DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT,
 FREEMAIL_FROM,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no
 version=3.4.2
Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com
 [IPv6:2a00:1450:4864:20::32a])
 (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits))
 (No client certificate requested)
 by phobos.denx.de (Postfix) with ESMTPS id B1B0785932
 for <u-boot@lists.denx.de>; Tue, 14 Feb 2023 18:36:10 +0100 (CET)
Authentication-Results: phobos.denx.de;
 dmarc=pass (p=none dis=none) header.from=gmail.com
Authentication-Results: phobos.denx.de;
 spf=pass smtp.mailfrom=clamor95@gmail.com
Received: by mail-wm1-x32a.google.com with SMTP id he5so3685822wmb.3
 for <u-boot@lists.denx.de>; Tue, 14 Feb 2023 09:36:10 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=FUJhWw7J84Qg+KAvyzVuZKnueExMfFueTV01hyOorjk=;
 b=fz16VnJ9nwKyZYoLyf1dT81bKOAwhVRHQ4IeCq51YFVzrDbLmPIJCeP5hqq+f+g85Z
 ydhLXECsOcPweVDCcXg1wAwtAHTliTReT6XksxqzValLokP4k1uYQV02JRcHl50pJRMD
 jK+dsa0xhwGL5QouQLSyFhSb6wzQXqod3BY9iS7ILbHmkToS8mN/VKXaGcgo27fikeD8
 i2NDGH7RfiPAXVNKdSCWqnxVMiqmGCJ3dkcAJwqEBsc0ZE2CGM2zuQhg9a7yKz/RZ65T
 x+1empY+VRK3aKdTCGHn90XrhpvMQ34/w3oJsdcO8r5cEIOXI8RjK42C7ZPF6WFp0zKf
 /3fg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=FUJhWw7J84Qg+KAvyzVuZKnueExMfFueTV01hyOorjk=;
 b=jf2t0fqo9FKHQ8k7kT9ddwR6hVlYKSv1UZNtxNpYpleoNa86/sLp+B8Trpgid4gwZh
 JlhdZ/W0pvlNrtxEXyD4CYzJuUiCtWX2Ag5VqiTdFo8r/r0dfIyWEsGu+ST0vQGxkM1j
 hv3fvLZSQnadUrHlmGxdk3USCCvr0xfS1If7Sek9j1JhSdESS68z+4MOJz5zczaetwBa
 HtnPfs1g7+2P2pUSXC/jvuXP3E++SAliGGeMjsnB3Ik/kz4/waK2ccXmHG2l1XDNpHPC
 df2FtVhQKTe25FoZhOzPxluFKpwHOFWGRcwNH56uLMaqiRgRm8xQBRlk1KDyyj4RedeO
 cMHw==
X-Gm-Message-State: AO0yUKUOv0TvTcfTx2rMROKXSe2Yw+fjR9f7oA82WJewpYEMZRQYUJxl
 ZdwkANUKeuhAcyjpnRSEc2Q=
X-Google-Smtp-Source: 
 AK7set9JJXuH5utqPHiz6lM2mKiTyfBln4LVt2W5K9u/ZrDejojCdceA/57J1GVo8m/AvccBJA3r0w==
X-Received: by 2002:a05:600c:18a3:b0:3de:3ee3:4f6f with SMTP id
 x35-20020a05600c18a300b003de3ee34f6fmr2828264wmp.8.1676396170459;
 Tue, 14 Feb 2023 09:36:10 -0800 (PST)
Received: from xeon.. ([188.163.112.76]) by smtp.gmail.com with ESMTPSA id
 m23-20020a7bca57000000b003de8a1b06c0sm20787829wml.7.2023.02.14.09.36.09
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 14 Feb 2023 09:36:10 -0800 (PST)
From: Svyatoslav Ryhel <clamor95@gmail.com>
To: Tom Warren <twarren@nvidia.com>,
 Marcel Ziswiler <marcel.ziswiler@toradex.com>,
 Allen Martin <amartin@nvidia.com>, Jagan Teki <jagan@amarulasolutions.com>,
 Lukasz Majewski <lukma@denx.de>, Marek Vasut <marex@denx.de>,
 Svyatoslav Ryhel <clamor95@gmail.com>,
 Ramin Khonsari <raminterex@yahoo.com>,
 Thierry Reding <thierry.reding@gmail.com>,
 Maxim Schwalm <maxim.schwalm@gmail.com>,
 Dmitry Osipenko <digetx@gmail.com>, Simon Glass <sjg@chromium.org>
Cc: u-boot@lists.denx.de
Subject: [PATCH v4 10/16] ARM: tegra: create common pre-dm i2c write
Date: Tue, 14 Feb 2023 19:35:32 +0200
Message-Id: <20230214173538.6242-11-clamor95@gmail.com>
X-Mailer: git-send-email 2.37.2
In-Reply-To: <20230214173538.6242-1-clamor95@gmail.com>
References: <20230214173538.6242-1-clamor95@gmail.com>
MIME-Version: 1.0
X-BeenThere: u-boot@lists.denx.de
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: U-Boot discussion <u-boot.lists.denx.de>
List-Unsubscribe: <https://lists.denx.de/options/u-boot>,
 <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>
List-Archive: <https://lists.denx.de/pipermail/u-boot/>
List-Post: <mailto:u-boot@lists.denx.de>
List-Help: <mailto:u-boot-request@lists.denx.de?subject=help>
List-Subscribe: <https://lists.denx.de/listinfo/u-boot>,
 <mailto:u-boot-request@lists.denx.de?subject=subscribe>
Errors-To: u-boot-bounces@lists.denx.de
Sender: "U-Boot" <u-boot-bounces@lists.denx.de>
X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de
X-Virus-Status: Clean

This implementation allows pwr i2c writing on early SPL
stages when DM is not yet setup.

Such writing is needed to configure main voltages of PMIC
on early SPL for bootloader to boot properly.

Tested-by: Andreas Westman Dorcsak <hedmoo@yahoo.com> # ASUS TF T30
Tested-by: Robert Eckelmann <longnoserob@gmail.com> # ASUS TF101 T20
Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # LG P895 T30
Tested-by: Thierry Reding <treding@nvidia.com> # T30 and T124
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 arch/arm/include/asm/arch-tegra/tegra_i2c.h | 17 ++++++++++
 arch/arm/mach-tegra/cpu.h                   |  1 -
 arch/arm/mach-tegra/tegra124/cpu.c          |  4 +++
 arch/arm/mach-tegra/tegra30/cpu.c           | 37 +++++++--------------
 4 files changed, 33 insertions(+), 26 deletions(-)

diff --git a/arch/arm/include/asm/arch-tegra/tegra_i2c.h b/arch/arm/include/asm/arch-tegra/tegra_i2c.h
index c49f43251d..afec6bbdda 100644
--- a/arch/arm/include/asm/arch-tegra/tegra_i2c.h
+++ b/arch/arm/include/asm/arch-tegra/tegra_i2c.h
@@ -8,6 +8,7 @@
 #ifndef _TEGRA_I2C_H_
 #define _TEGRA_I2C_H_
 
+#include <asm/io.h>
 #include <asm/types.h>
 
 struct udevice;
@@ -154,4 +155,20 @@ struct i2c_ctlr {
  */
 int tegra_i2c_get_dvc_bus(struct udevice **busp);
 
+/* Pre-dm section used for initial setup of PMIC */
+#define I2C_SEND_2_BYTES		0x0A02
+
+static inline void tegra_i2c_ll_write(uint addr, uint data)
+{
+	struct i2c_ctlr *reg = (struct i2c_ctlr *)TEGRA_DVC_BASE;
+
+	writel(addr, &reg->cmd_addr0);
+	writel(0x2, &reg->cnfg);
+
+	writel(data, &reg->cmd_data1);
+	writel(I2C_SEND_2_BYTES, &reg->cnfg);
+}
+
+void pmic_enable_cpu_vdd(void);
+
 #endif	/* _TEGRA_I2C_H_ */
diff --git a/arch/arm/mach-tegra/cpu.h b/arch/arm/mach-tegra/cpu.h
index d541825441..006aae3d07 100644
--- a/arch/arm/mach-tegra/cpu.h
+++ b/arch/arm/mach-tegra/cpu.h
@@ -74,4 +74,3 @@ int tegra_get_chip(void);
 int tegra_get_sku_info(void);
 int tegra_get_chip_sku(void);
 void adjust_pllp_out_freqs(void);
-void pmic_enable_cpu_vdd(void);
diff --git a/arch/arm/mach-tegra/tegra124/cpu.c b/arch/arm/mach-tegra/tegra124/cpu.c
index d5f2683b26..b1bfe8fb5e 100644
--- a/arch/arm/mach-tegra/tegra124/cpu.c
+++ b/arch/arm/mach-tegra/tegra124/cpu.c
@@ -14,10 +14,14 @@
 #include <asm/arch/tegra.h>
 #include <asm/arch-tegra/clk_rst.h>
 #include <asm/arch-tegra/pmc.h>
+#include <asm/arch-tegra/tegra_i2c.h>
 #include <asm/arch-tegra/ap.h>
 #include <linux/delay.h>
 #include "../cpu.h"
 
+/* In case this function is not defined */
+__weak void pmic_enable_cpu_vdd(void) {}
+
 /* Tegra124-specific CPU init code */
 
 static void enable_cpu_power_rail(void)
diff --git a/arch/arm/mach-tegra/tegra30/cpu.c b/arch/arm/mach-tegra/tegra30/cpu.c
index 651edd27ee..6ac45af51a 100644
--- a/arch/arm/mach-tegra/tegra30/cpu.c
+++ b/arch/arm/mach-tegra/tegra30/cpu.c
@@ -15,23 +15,6 @@
 #include <linux/delay.h>
 #include "../cpu.h"
 
-/* Tegra30-specific CPU init code */
-void tegra_i2c_ll_write_addr(uint addr, uint config)
-{
-	struct i2c_ctlr *reg = (struct i2c_ctlr *)TEGRA_DVC_BASE;
-
-	writel(addr, &reg->cmd_addr0);
-	writel(config, &reg->cnfg);
-}
-
-void tegra_i2c_ll_write_data(uint data, uint config)
-{
-	struct i2c_ctlr *reg = (struct i2c_ctlr *)TEGRA_DVC_BASE;
-
-	writel(data, &reg->cmd_data1);
-	writel(config, &reg->cnfg);
-}
-
 #define TPS62366A_I2C_ADDR		0xC0
 #define TPS62366A_SET1_REG		0x01
 #define TPS62366A_SET1_DATA		(0x4600 | TPS62366A_SET1_REG)
@@ -45,7 +28,9 @@ void tegra_i2c_ll_write_data(uint data, uint config)
 #define TPS65911_VDDCTRL_SR_REG		0x27
 #define TPS65911_VDDCTRL_OP_DATA	(0x2400 | TPS65911_VDDCTRL_OP_REG)
 #define TPS65911_VDDCTRL_SR_DATA	(0x0100 | TPS65911_VDDCTRL_SR_REG)
-#define I2C_SEND_2_BYTES		0x0A02
+
+/* In case this function is not defined */
+__weak void pmic_enable_cpu_vdd(void) {}
 
 static void enable_cpu_power_rail(void)
 {
@@ -59,12 +44,12 @@ static void enable_cpu_power_rail(void)
 
 	/* Set VDD_CORE to 1.200V. */
 #ifdef CONFIG_TEGRA_VDD_CORE_TPS62366A_SET1
-	tegra_i2c_ll_write_addr(TPS62366A_I2C_ADDR, 2);
-	tegra_i2c_ll_write_data(TPS62366A_SET1_DATA, I2C_SEND_2_BYTES);
+	tegra_i2c_ll_write(TPS62366A_I2C_ADDR,
+			   TPS62366A_SET1_DATA);
 #endif
 #ifdef CONFIG_TEGRA_VDD_CORE_TPS62361B_SET3
-	tegra_i2c_ll_write_addr(TPS62361B_I2C_ADDR, 2);
-	tegra_i2c_ll_write_data(TPS62361B_SET3_DATA, I2C_SEND_2_BYTES);
+	tegra_i2c_ll_write(TPS62361B_I2C_ADDR,
+			   TPS62361B_SET3_DATA);
 #endif
 	udelay(1000);
 
@@ -72,10 +57,11 @@ static void enable_cpu_power_rail(void)
 	 * Bring up CPU VDD via the TPS65911x PMIC on the DVC I2C bus.
 	 * First set VDD to 1.0125V, then enable the VDD regulator.
 	 */
-	tegra_i2c_ll_write_addr(TPS65911_I2C_ADDR, 2);
-	tegra_i2c_ll_write_data(TPS65911_VDDCTRL_OP_DATA, I2C_SEND_2_BYTES);
+	tegra_i2c_ll_write(TPS65911_I2C_ADDR,
+			   TPS65911_VDDCTRL_OP_DATA);
 	udelay(1000);
-	tegra_i2c_ll_write_data(TPS65911_VDDCTRL_SR_DATA, I2C_SEND_2_BYTES);
+	tegra_i2c_ll_write(TPS65911_I2C_ADDR,
+			   TPS65911_VDDCTRL_SR_DATA);
 	udelay(10 * 1000);
 }
 
@@ -142,6 +128,7 @@ void start_cpu(u32 reset_vector)
 
 	/* Enable VDD_CPU */
 	enable_cpu_power_rail();
+	pmic_enable_cpu_vdd();
 
 	set_cpu_running(0);
 

From patchwork Tue Feb 14 17:35:33 2023
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Svyatoslav Ryhel <clamor95@gmail.com>
X-Patchwork-Id: 1742550
X-Patchwork-Delegate: twarren@nvidia.com
Return-Path: <u-boot-bounces@lists.denx.de>
X-Original-To: incoming@patchwork.ozlabs.org
Delivered-To: patchwork-incoming@legolas.ozlabs.org
Authentication-Results: legolas.ozlabs.org;
 spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de
 (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de;
 envelope-from=u-boot-bounces@lists.denx.de; receiver=<UNKNOWN>)
Authentication-Results: legolas.ozlabs.org;
	dkim=pass (2048-bit key;
 unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256
 header.s=20210112 header.b=R9c+xKBQ;
	dkim-atps=neutral
Received: from phobos.denx.de (phobos.denx.de
 [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (P-384))
	(No client certificate requested)
	by legolas.ozlabs.org (Postfix) with ESMTPS id 4PGT2l0RyTz23r4
	for <incoming@patchwork.ozlabs.org>; Wed, 15 Feb 2023 04:38:39 +1100 (AEDT)
Received: from h2850616.stratoserver.net (localhost [IPv6:::1])
	by phobos.denx.de (Postfix) with ESMTP id 45D0685A06;
	Tue, 14 Feb 2023 18:36:46 +0100 (CET)
Authentication-Results: phobos.denx.de;
 dmarc=pass (p=none dis=none) header.from=gmail.com
Authentication-Results: phobos.denx.de;
 spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de
Authentication-Results: phobos.denx.de;
	dkim=pass (2048-bit key;
 unprotected) header.d=gmail.com header.i=@gmail.com header.b="R9c+xKBQ";
	dkim-atps=neutral
Received: by phobos.denx.de (Postfix, from userid 109)
 id B21D48597A; Tue, 14 Feb 2023 18:36:23 +0100 (CET)
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de
X-Spam-Level: 
X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,
 DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT,
 FREEMAIL_FROM,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no
 version=3.4.2
Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com
 [IPv6:2a00:1450:4864:20::331])
 (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits))
 (No client certificate requested)
 by phobos.denx.de (Postfix) with ESMTPS id 5280885988
 for <u-boot@lists.denx.de>; Tue, 14 Feb 2023 18:36:12 +0100 (CET)
Authentication-Results: phobos.denx.de;
 dmarc=pass (p=none dis=none) header.from=gmail.com
Authentication-Results: phobos.denx.de;
 spf=pass smtp.mailfrom=clamor95@gmail.com
Received: by mail-wm1-x331.google.com with SMTP id
 m16-20020a05600c3b1000b003dc4050c94aso12188600wms.4
 for <u-boot@lists.denx.de>; Tue, 14 Feb 2023 09:36:12 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=sAX2elEzmZr4thPvPhOwXyQlOsTdn6CZXFbDFk7Z9jc=;
 b=R9c+xKBQ/uJZVwp8x3kFnDS+5nuzO/K2Xaaa1ymUU8K3rGdqUw2fL+254azxNHOu9Q
 nBPdIG5Wjro3s7zibVxkNpoRnUzOvu9pu0aHNtKEs8+XSQZNDufg1D/eKJQHit0Dtw+D
 HqnZ4lWH8+8QYkxIxcUzvvjMukXFVTJhqjTJJR7zZ5s+uCPCHCqtx01DsH5/h84hFomV
 s/DHKCblso/+LCvQOR7mbswpPWF+CFEhSLLPfv7Z2eSTZpmlwrVtWA9ocT8ndHShCzJ8
 ePreAw2pFe+4eKOU25qW2CzfeJOxxSFAJo9mo41X+E135sr2YARUTYkFi8mZibk2FgA0
 9KMA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=sAX2elEzmZr4thPvPhOwXyQlOsTdn6CZXFbDFk7Z9jc=;
 b=PxK52a3TDfLvA9fl0veoWsztvwX8DZG3g1ZdAz8dwQXAwObQJXxKljm/aUybyEmOZT
 wxv04/QoE0NHO4aAicG9XYAeoc9ez5VfVfWiYzwjeivxNv4GQy2cMRCAsZs7M4ggUGs2
 mYj8gdeSWLA4bVg5e97UYJxB+LGSJyXnbQP6V2IKmLZNUVHiszAWJ3fWYK3J/9ai6GY3
 rZfVgqSB4LGthYCumZhZfqePLt0rldMA2XZPeIgLIJLhSFhNV/9OSeULsKLYWYJ+Eg/7
 0gsAV47PPxHy4xGgTV+UAqtsaODvUW5g13vuq1UV0rJDAD+1CePd/mOp1ntcevxDNtrl
 c13Q==
X-Gm-Message-State: AO0yUKUtfP6Ryxke/gycOpHTC0m3TAiIFIMtxJuxpxH0DJDssLxScGPd
 yy1ROJv1khu6rU1KL/I7uvE=
X-Google-Smtp-Source: 
 AK7set8zbQHn5L1RVkAoC8oc4tTmDnRZKy5xLjDt+oxExEYPO2rYVB7ehkaOa64UxuB4PbS8rbtpbw==
X-Received: by 2002:a05:600c:2306:b0:3de:e8c5:d833 with SMTP id
 6-20020a05600c230600b003dee8c5d833mr2553334wmo.22.1676396171605;
 Tue, 14 Feb 2023 09:36:11 -0800 (PST)
Received: from xeon.. ([188.163.112.76]) by smtp.gmail.com with ESMTPSA id
 m23-20020a7bca57000000b003de8a1b06c0sm20787829wml.7.2023.02.14.09.36.10
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 14 Feb 2023 09:36:11 -0800 (PST)
From: Svyatoslav Ryhel <clamor95@gmail.com>
To: Tom Warren <twarren@nvidia.com>,
 Marcel Ziswiler <marcel.ziswiler@toradex.com>,
 Allen Martin <amartin@nvidia.com>, Jagan Teki <jagan@amarulasolutions.com>,
 Lukasz Majewski <lukma@denx.de>, Marek Vasut <marex@denx.de>,
 Svyatoslav Ryhel <clamor95@gmail.com>,
 Ramin Khonsari <raminterex@yahoo.com>,
 Thierry Reding <thierry.reding@gmail.com>,
 Maxim Schwalm <maxim.schwalm@gmail.com>,
 Dmitry Osipenko <digetx@gmail.com>, Simon Glass <sjg@chromium.org>
Cc: u-boot@lists.denx.de
Subject: [PATCH v4 11/16] board: tegra124: switch to updated pre-dm i2c write
Date: Tue, 14 Feb 2023 19:35:33 +0200
Message-Id: <20230214173538.6242-12-clamor95@gmail.com>
X-Mailer: git-send-email 2.37.2
In-Reply-To: <20230214173538.6242-1-clamor95@gmail.com>
References: <20230214173538.6242-1-clamor95@gmail.com>
MIME-Version: 1.0
X-BeenThere: u-boot@lists.denx.de
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: U-Boot discussion <u-boot.lists.denx.de>
List-Unsubscribe: <https://lists.denx.de/options/u-boot>,
 <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>
List-Archive: <https://lists.denx.de/pipermail/u-boot/>
List-Post: <mailto:u-boot@lists.denx.de>
List-Help: <mailto:u-boot-request@lists.denx.de?subject=help>
List-Subscribe: <https://lists.denx.de/listinfo/u-boot>,
 <mailto:u-boot-request@lists.denx.de?subject=subscribe>
Errors-To: u-boot-bounces@lists.denx.de
Sender: "U-Boot" <u-boot-bounces@lists.denx.de>
X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de
X-Virus-Status: Clean

Configure PMIC for early stages using updated i2c write.

Tested-by: Thierry Reding <treding@nvidia.com> # Jetson TK1 T124
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
 board/nvidia/venice2/as3722_init.c     | 65 ++++++++++++--------
 board/nvidia/venice2/as3722_init.h     | 43 -------------
 board/toradex/apalis-tk1/as3722_init.c | 85 ++++++++++++++------------
 board/toradex/apalis-tk1/as3722_init.h | 40 ------------
 4 files changed, 88 insertions(+), 145 deletions(-)
 delete mode 100644 board/nvidia/venice2/as3722_init.h
 delete mode 100644 board/toradex/apalis-tk1/as3722_init.h

diff --git a/board/nvidia/venice2/as3722_init.c b/board/nvidia/venice2/as3722_init.c
index ba676547d3..395bdd99c7 100644
--- a/board/nvidia/venice2/as3722_init.c
+++ b/board/nvidia/venice2/as3722_init.c
@@ -9,25 +9,42 @@
 #include <asm/io.h>
 #include <asm/arch-tegra/tegra_i2c.h>
 #include <linux/delay.h>
-#include "as3722_init.h"
 
-/* AS3722-PMIC-specific early init code - get CPU rails up, etc */
+/* AS3722-PMIC-specific early init regs */
 
-void tegra_i2c_ll_write_addr(uint addr, uint config)
-{
-	struct i2c_ctlr *reg = (struct i2c_ctlr *)TEGRA_DVC_BASE;
+#define AS3722_I2C_ADDR		0x80
 
-	writel(addr, &reg->cmd_addr0);
-	writel(config, &reg->cnfg);
-}
+#define AS3722_SD0VOLTAGE_REG	0x00	/* CPU */
+#define AS3722_SD1VOLTAGE_REG	0x01	/* CORE, already set by OTP */
+#define AS3722_SD6VOLTAGE_REG	0x06	/* GPU */
+#define AS3722_SDCONTROL_REG	0x4D
 
-void tegra_i2c_ll_write_data(uint data, uint config)
-{
-	struct i2c_ctlr *reg = (struct i2c_ctlr *)TEGRA_DVC_BASE;
+#define AS3722_LDO2VOLTAGE_REG	0x12	/* VPP_FUSE */
+#define AS3722_LDO6VOLTAGE_REG	0x16	/* VDD_SDMMC */
+#define AS3722_LDCONTROL_REG	0x4E
 
-	writel(data, &reg->cmd_data1);
-	writel(config, &reg->cnfg);
-}
+#if defined(CONFIG_TARGET_VENICE2)
+#define AS3722_SD0VOLTAGE_DATA	(0x2800 | AS3722_SD0VOLTAGE_REG)
+#else /* TK1 or Nyan-Big */
+#define AS3722_SD0VOLTAGE_DATA	(0x3C00 | AS3722_SD0VOLTAGE_REG)
+#endif
+#define AS3722_SD0CONTROL_DATA	(0x0100 | AS3722_SDCONTROL_REG)
+
+#if defined(CONFIG_TARGET_JETSON_TK1) || defined(CONFIG_TARGET_CEI_TK1_SOM)
+#define AS3722_SD1VOLTAGE_DATA	(0x2800 | AS3722_SD1VOLTAGE_REG)
+#define AS3722_SD1CONTROL_DATA	(0x0200 | AS3722_SDCONTROL_REG)
+#endif
+
+#define AS3722_SD6CONTROL_DATA	(0x4000 | AS3722_SDCONTROL_REG)
+#define AS3722_SD6VOLTAGE_DATA	(0x2800 | AS3722_SD6VOLTAGE_REG)
+
+#define AS3722_LDO2CONTROL_DATA	(0x0400 | AS3722_LDCONTROL_REG)
+#define AS3722_LDO2VOLTAGE_DATA	(0x1000 | AS3722_LDO2VOLTAGE_REG)
+
+#define AS3722_LDO6CONTROL_DATA	(0x4000 | AS3722_LDCONTROL_REG)
+#define AS3722_LDO6VOLTAGE_DATA	(0x3F00 | AS3722_LDO6VOLTAGE_REG)
+
+/* AS3722-PMIC-specific early init code - get CPU rails up, etc */
 
 void pmic_enable_cpu_vdd(void)
 {
@@ -37,8 +54,8 @@ void pmic_enable_cpu_vdd(void)
 	/* Set up VDD_CORE, for boards where OTP is incorrect*/
 	debug("%s: Setting VDD_CORE via AS3722 reg 1\n", __func__);
 	/* Configure VDD_CORE via the AS3722 PMIC on the PWR I2C bus */
-	tegra_i2c_ll_write_addr(AS3722_I2C_ADDR, 2);
-	tegra_i2c_ll_write_data(AS3722_SD1VOLTAGE_DATA, I2C_SEND_2_BYTES);
+	tegra_i2c_ll_write(AS3722_I2C_ADDR,
+			   AS3722_SD1VOLTAGE_DATA);
 	/*
 	 * Don't write SDCONTROL - it's already 0x7F, i.e. all SDs enabled.
 	 * tegra_i2c_ll_write_data(AS3722_SD1CONTROL_DATA, I2C_SEND_2_BYTES);
@@ -51,8 +68,8 @@ void pmic_enable_cpu_vdd(void)
 	 * Bring up VDD_CPU via the AS3722 PMIC on the PWR I2C bus.
 	 * First set VDD to 1.0V, then enable the VDD regulator.
 	 */
-	tegra_i2c_ll_write_addr(AS3722_I2C_ADDR, 2);
-	tegra_i2c_ll_write_data(AS3722_SD0VOLTAGE_DATA, I2C_SEND_2_BYTES);
+	tegra_i2c_ll_write(AS3722_I2C_ADDR,
+			   AS3722_SD0VOLTAGE_DATA);
 	/*
 	 * Don't write SDCONTROL - it's already 0x7F, i.e. all SDs enabled.
 	 * tegra_i2c_ll_write_data(AS3722_SD0CONTROL_DATA, I2C_SEND_2_BYTES);
@@ -64,8 +81,8 @@ void pmic_enable_cpu_vdd(void)
 	 * Bring up VDD_GPU via the AS3722 PMIC on the PWR I2C bus.
 	 * First set VDD to 1.0V, then enable the VDD regulator.
 	 */
-	tegra_i2c_ll_write_addr(AS3722_I2C_ADDR, 2);
-	tegra_i2c_ll_write_data(AS3722_SD6VOLTAGE_DATA, I2C_SEND_2_BYTES);
+	tegra_i2c_ll_write(AS3722_I2C_ADDR,
+			   AS3722_SD6VOLTAGE_DATA);
 	/*
 	 * Don't write SDCONTROL - it's already 0x7F, i.e. all SDs enabled.
 	 * tegra_i2c_ll_write_data(AS3722_SD6CONTROL_DATA, I2C_SEND_2_BYTES);
@@ -77,8 +94,8 @@ void pmic_enable_cpu_vdd(void)
 	 * Bring up VPP_FUSE via the AS3722 PMIC on the PWR I2C bus.
 	 * First set VDD to 1.2V, then enable the VDD regulator.
 	 */
-	tegra_i2c_ll_write_addr(AS3722_I2C_ADDR, 2);
-	tegra_i2c_ll_write_data(AS3722_LDO2VOLTAGE_DATA, I2C_SEND_2_BYTES);
+	tegra_i2c_ll_write(AS3722_I2C_ADDR,
+			   AS3722_LDO2VOLTAGE_DATA);
 	/*
 	 * Don't write LDCONTROL - it's already 0xFF, i.e. all LDOs enabled.
 	 * tegra_i2c_ll_write_data(AS3722_LDO2CONTROL_DATA, I2C_SEND_2_BYTES);
@@ -93,8 +110,8 @@ void pmic_enable_cpu_vdd(void)
 	 * NOTE: We do this early because doing it later seems to hose the CPU
 	 * power rail/partition startup. Need to debug.
 	 */
-	tegra_i2c_ll_write_addr(AS3722_I2C_ADDR, 2);
-	tegra_i2c_ll_write_data(AS3722_LDO6VOLTAGE_DATA, I2C_SEND_2_BYTES);
+	tegra_i2c_ll_write(AS3722_I2C_ADDR,
+			   AS3722_LDO6VOLTAGE_DATA);
 	/*
 	 * Don't write LDCONTROL - it's already 0xFF, i.e. all LDOs enabled.
 	 * tegra_i2c_ll_write_data(AS3722_LDO6CONTROL_DATA, I2C_SEND_2_BYTES);
diff --git a/board/nvidia/venice2/as3722_init.h b/board/nvidia/venice2/as3722_init.h
deleted file mode 100644
index 17e7d76ae7..0000000000
--- a/board/nvidia/venice2/as3722_init.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * (C) Copyright 2013
- * NVIDIA Corporation <www.nvidia.com>
- */
-
-/* AS3722-PMIC-specific early init regs */
-
-#define AS3722_I2C_ADDR		0x80
-
-#define AS3722_SD0VOLTAGE_REG	0x00	/* CPU */
-#define AS3722_SD1VOLTAGE_REG	0x01	/* CORE, already set by OTP */
-#define AS3722_SD6VOLTAGE_REG	0x06	/* GPU */
-#define AS3722_SDCONTROL_REG	0x4D
-
-#define AS3722_LDO2VOLTAGE_REG	0x12	/* VPP_FUSE */
-#define AS3722_LDO6VOLTAGE_REG	0x16	/* VDD_SDMMC */
-#define AS3722_LDCONTROL_REG	0x4E
-
-#if defined(CONFIG_TARGET_VENICE2)
-#define AS3722_SD0VOLTAGE_DATA	(0x2800 | AS3722_SD0VOLTAGE_REG)
-#else /* TK1 or Nyan-Big */
-#define AS3722_SD0VOLTAGE_DATA	(0x3C00 | AS3722_SD0VOLTAGE_REG)
-#endif
-#define AS3722_SD0CONTROL_DATA	(0x0100 | AS3722_SDCONTROL_REG)
-
-#if defined(CONFIG_TARGET_JETSON_TK1) || defined(CONFIG_TARGET_CEI_TK1_SOM)
-#define AS3722_SD1VOLTAGE_DATA	(0x2800 | AS3722_SD1VOLTAGE_REG)
-#define AS3722_SD1CONTROL_DATA	(0x0200 | AS3722_SDCONTROL_REG)
-#endif
-
-#define AS3722_SD6CONTROL_DATA	(0x4000 | AS3722_SDCONTROL_REG)
-#define AS3722_SD6VOLTAGE_DATA	(0x2800 | AS3722_SD6VOLTAGE_REG)
-
-#define AS3722_LDO2CONTROL_DATA	(0x0400 | AS3722_LDCONTROL_REG)
-#define AS3722_LDO2VOLTAGE_DATA	(0x1000 | AS3722_LDO2VOLTAGE_REG)
-
-#define AS3722_LDO6CONTROL_DATA	(0x4000 | AS3722_LDCONTROL_REG)
-#define AS3722_LDO6VOLTAGE_DATA	(0x3F00 | AS3722_LDO6VOLTAGE_REG)
-
-#define I2C_SEND_2_BYTES	0x0A02
-
-void pmic_enable_cpu_vdd(void);
diff --git a/board/toradex/apalis-tk1/as3722_init.c b/board/toradex/apalis-tk1/as3722_init.c
index 68169f5548..e9bd1028be 100644
--- a/board/toradex/apalis-tk1/as3722_init.c
+++ b/board/toradex/apalis-tk1/as3722_init.c
@@ -8,25 +8,40 @@
 #include <asm/io.h>
 #include <asm/arch-tegra/tegra_i2c.h>
 #include <linux/delay.h>
-#include "as3722_init.h"
 
-/* AS3722-PMIC-specific early init code - get CPU rails up, etc */
+/* AS3722-PMIC-specific early init regs */
 
-void tegra_i2c_ll_write_addr(uint addr, uint config)
-{
-	struct i2c_ctlr *reg = (struct i2c_ctlr *)TEGRA_DVC_BASE;
+#define AS3722_I2C_ADDR		0x80
 
-	writel(addr, &reg->cmd_addr0);
-	writel(config, &reg->cnfg);
-}
+#define AS3722_SD0VOLTAGE_REG	0x00	/* CPU */
+#define AS3722_SD1VOLTAGE_REG	0x01	/* CORE, already set by OTP */
+#define AS3722_SD6VOLTAGE_REG	0x06	/* GPU */
+#define AS3722_SDCONTROL_REG	0x4D
 
-void tegra_i2c_ll_write_data(uint data, uint config)
-{
-	struct i2c_ctlr *reg = (struct i2c_ctlr *)TEGRA_DVC_BASE;
+#define AS3722_LDO1VOLTAGE_REG	0x11	/* VDD_SDMMC1 */
+#define AS3722_LDO2VOLTAGE_REG	0x12	/* VPP_FUSE */
+#define AS3722_LDO6VOLTAGE_REG	0x16	/* VDD_SDMMC3 */
+#define AS3722_LDCONTROL_REG	0x4E
 
-	writel(data, &reg->cmd_data1);
-	writel(config, &reg->cnfg);
-}
+#define AS3722_SD0VOLTAGE_DATA	(0x3C00 | AS3722_SD0VOLTAGE_REG)
+#define AS3722_SD0CONTROL_DATA	(0x0100 | AS3722_SDCONTROL_REG)
+
+#define AS3722_SD1VOLTAGE_DATA	(0x3200 | AS3722_SD1VOLTAGE_REG)
+#define AS3722_SD1CONTROL_DATA	(0x0200 | AS3722_SDCONTROL_REG)
+
+#define AS3722_SD6CONTROL_DATA	(0x4000 | AS3722_SDCONTROL_REG)
+#define AS3722_SD6VOLTAGE_DATA	(0x2800 | AS3722_SD6VOLTAGE_REG)
+
+#define AS3722_LDO1CONTROL_DATA	(0x0200 | AS3722_LDCONTROL_REG)
+#define AS3722_LDO1VOLTAGE_DATA	(0x7F00 | AS3722_LDO1VOLTAGE_REG)
+
+#define AS3722_LDO2CONTROL_DATA	(0x0400 | AS3722_LDCONTROL_REG)
+#define AS3722_LDO2VOLTAGE_DATA	(0x1000 | AS3722_LDO2VOLTAGE_REG)
+
+#define AS3722_LDO6CONTROL_DATA	(0x4000 | AS3722_LDCONTROL_REG)
+#define AS3722_LDO6VOLTAGE_DATA	(0x3F00 | AS3722_LDO6VOLTAGE_REG)
+
+/* AS3722-PMIC-specific early init code - get CPU rails up, etc */
 
 void pmic_enable_cpu_vdd(void)
 {
@@ -36,8 +51,8 @@ void pmic_enable_cpu_vdd(void)
 	/* Set up VDD_CORE, for boards where OTP is incorrect*/
 	debug("%s: Setting VDD_CORE via AS3722 reg 1\n", __func__);
 	/* Configure VDD_CORE via the AS3722 PMIC on the PWR I2C bus */
-	tegra_i2c_ll_write_addr(AS3722_I2C_ADDR, 2);
-	tegra_i2c_ll_write_data(AS3722_SD1VOLTAGE_DATA, I2C_SEND_2_BYTES);
+	tegra_i2c_ll_write(AS3722_I2C_ADDR,
+			   AS3722_SD1VOLTAGE_DATA);
 	/*
 	 * Don't write SDCONTROL - it's already 0x7F, i.e. all SDs enabled.
 	 * tegra_i2c_ll_write_data(AS3722_SD1CONTROL_DATA, I2C_SEND_2_BYTES);
@@ -49,23 +64,17 @@ void pmic_enable_cpu_vdd(void)
 	 * Make sure all non-fused regulators are down.
 	 * That way we're in known state after software reboot from linux
 	 */
-	tegra_i2c_ll_write_addr(AS3722_I2C_ADDR, 2);
-	tegra_i2c_ll_write_data(0x0003, I2C_SEND_2_BYTES);
+	tegra_i2c_ll_write(AS3722_I2C_ADDR, 0x0003);
 	udelay(10 * 1000);
-	tegra_i2c_ll_write_addr(AS3722_I2C_ADDR, 2);
-	tegra_i2c_ll_write_data(0x0004, I2C_SEND_2_BYTES);
+	tegra_i2c_ll_write(AS3722_I2C_ADDR, 0x0004);
 	udelay(10 * 1000);
-	tegra_i2c_ll_write_addr(AS3722_I2C_ADDR, 2);
-	tegra_i2c_ll_write_data(0x001b, I2C_SEND_2_BYTES);
+	tegra_i2c_ll_write(AS3722_I2C_ADDR, 0x001b);
 	udelay(10 * 1000);
-	tegra_i2c_ll_write_addr(AS3722_I2C_ADDR, 2);
-	tegra_i2c_ll_write_data(0x0014, I2C_SEND_2_BYTES);
+	tegra_i2c_ll_write(AS3722_I2C_ADDR, 0x0014);
 	udelay(10 * 1000);
-	tegra_i2c_ll_write_addr(AS3722_I2C_ADDR, 2);
-	tegra_i2c_ll_write_data(0x001a, I2C_SEND_2_BYTES);
+	tegra_i2c_ll_write(AS3722_I2C_ADDR, 0x001a);
 	udelay(10 * 1000);
-	tegra_i2c_ll_write_addr(AS3722_I2C_ADDR, 2);
-	tegra_i2c_ll_write_data(0x0019, I2C_SEND_2_BYTES);
+	tegra_i2c_ll_write(AS3722_I2C_ADDR, 0x0019);
 	udelay(10 * 1000);
 
 	debug("%s: Setting VDD_CPU to 1.0V via AS3722 reg 0/4D\n", __func__);
@@ -73,8 +82,8 @@ void pmic_enable_cpu_vdd(void)
 	 * Bring up VDD_CPU via the AS3722 PMIC on the PWR I2C bus.
 	 * First set VDD to 1.0V, then enable the VDD regulator.
 	 */
-	tegra_i2c_ll_write_addr(AS3722_I2C_ADDR, 2);
-	tegra_i2c_ll_write_data(AS3722_SD0VOLTAGE_DATA, I2C_SEND_2_BYTES);
+	tegra_i2c_ll_write(AS3722_I2C_ADDR,
+			   AS3722_SD0VOLTAGE_DATA);
 	/*
 	 * Don't write SDCONTROL - it's already 0x7F, i.e. all SDs enabled.
 	 * tegra_i2c_ll_write_data(AS3722_SD0CONTROL_DATA, I2C_SEND_2_BYTES);
@@ -86,8 +95,8 @@ void pmic_enable_cpu_vdd(void)
 	 * Bring up VDD_GPU via the AS3722 PMIC on the PWR I2C bus.
 	 * First set VDD to 1.0V, then enable the VDD regulator.
 	 */
-	tegra_i2c_ll_write_addr(AS3722_I2C_ADDR, 2);
-	tegra_i2c_ll_write_data(AS3722_SD6VOLTAGE_DATA, I2C_SEND_2_BYTES);
+	tegra_i2c_ll_write(AS3722_I2C_ADDR,
+			   AS3722_SD6VOLTAGE_DATA);
 	/*
 	 * Don't write SDCONTROL - it's already 0x7F, i.e. all SDs enabled.
 	 * tegra_i2c_ll_write_data(AS3722_SD6CONTROL_DATA, I2C_SEND_2_BYTES);
@@ -99,8 +108,8 @@ void pmic_enable_cpu_vdd(void)
 	 * Bring up VPP_FUSE via the AS3722 PMIC on the PWR I2C bus.
 	 * First set VDD to 1.2V, then enable the VDD regulator.
 	 */
-	tegra_i2c_ll_write_addr(AS3722_I2C_ADDR, 2);
-	tegra_i2c_ll_write_data(AS3722_LDO2VOLTAGE_DATA, I2C_SEND_2_BYTES);
+	tegra_i2c_ll_write(AS3722_I2C_ADDR,
+			   AS3722_LDO2VOLTAGE_DATA);
 	/*
 	 * Don't write LDCONTROL - it's already 0xFF, i.e. all LDOs enabled.
 	 * tegra_i2c_ll_write_data(AS3722_LDO2CONTROL_DATA, I2C_SEND_2_BYTES);
@@ -115,8 +124,8 @@ void pmic_enable_cpu_vdd(void)
 	 * NOTE: We do this early because doing it later seems to hose the CPU
 	 * power rail/partition startup. Need to debug.
 	 */
-	tegra_i2c_ll_write_addr(AS3722_I2C_ADDR, 2);
-	tegra_i2c_ll_write_data(AS3722_LDO1VOLTAGE_DATA, I2C_SEND_2_BYTES);
+	tegra_i2c_ll_write(AS3722_I2C_ADDR,
+			   AS3722_LDO1VOLTAGE_DATA);
 	/*
 	 * Don't write LDCONTROL - it's already 0xFF, i.e. all LDOs enabled.
 	 * tegra_i2c_ll_write_data(AS3722_LDO1CONTROL_DATA, I2C_SEND_2_BYTES);
@@ -131,8 +140,8 @@ void pmic_enable_cpu_vdd(void)
 	 * NOTE: We do this early because doing it later seems to hose the CPU
 	 * power rail/partition startup. Need to debug.
 	 */
-	tegra_i2c_ll_write_addr(AS3722_I2C_ADDR, 2);
-	tegra_i2c_ll_write_data(AS3722_LDO6VOLTAGE_DATA, I2C_SEND_2_BYTES);
+	tegra_i2c_ll_write(AS3722_I2C_ADDR,
+			   AS3722_LDO6VOLTAGE_DATA);
 	/*
 	 * Don't write LDCONTROL - it's already 0xFF, i.e. all LDOs enabled.
 	 * tegra_i2c_ll_write_data(AS3722_LDO6CONTROL_DATA, I2C_SEND_2_BYTES);
diff --git a/board/toradex/apalis-tk1/as3722_init.h b/board/toradex/apalis-tk1/as3722_init.h
deleted file mode 100644
index 99836de966..0000000000
--- a/board/toradex/apalis-tk1/as3722_init.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * Copyright (c) 2012-2016 Toradex, Inc.
- */
-
-/* AS3722-PMIC-specific early init regs */
-
-#define AS3722_I2C_ADDR		0x80
-
-#define AS3722_SD0VOLTAGE_REG	0x00	/* CPU */
-#define AS3722_SD1VOLTAGE_REG	0x01	/* CORE, already set by OTP */
-#define AS3722_SD6VOLTAGE_REG	0x06	/* GPU */
-#define AS3722_SDCONTROL_REG	0x4D
-
-#define AS3722_LDO1VOLTAGE_REG	0x11	/* VDD_SDMMC1 */
-#define AS3722_LDO2VOLTAGE_REG	0x12	/* VPP_FUSE */
-#define AS3722_LDO6VOLTAGE_REG	0x16	/* VDD_SDMMC3 */
-#define AS3722_LDCONTROL_REG	0x4E
-
-#define AS3722_SD0VOLTAGE_DATA	(0x3C00 | AS3722_SD0VOLTAGE_REG)
-#define AS3722_SD0CONTROL_DATA	(0x0100 | AS3722_SDCONTROL_REG)
-
-#define AS3722_SD1VOLTAGE_DATA	(0x3200 | AS3722_SD1VOLTAGE_REG)
-#define AS3722_SD1CONTROL_DATA	(0x0200 | AS3722_SDCONTROL_REG)
-
-#define AS3722_SD6CONTROL_DATA	(0x4000 | AS3722_SDCONTROL_REG)
-#define AS3722_SD6VOLTAGE_DATA	(0x2800 | AS3722_SD6VOLTAGE_REG)
-
-#define AS3722_LDO1CONTROL_DATA	(0x0200 | AS3722_LDCONTROL_REG)
-#define AS3722_LDO1VOLTAGE_DATA	(0x7F00 | AS3722_LDO1VOLTAGE_REG)
-
-#define AS3722_LDO2CONTROL_DATA	(0x0400 | AS3722_LDCONTROL_REG)
-#define AS3722_LDO2VOLTAGE_DATA	(0x1000 | AS3722_LDO2VOLTAGE_REG)
-
-#define AS3722_LDO6CONTROL_DATA	(0x4000 | AS3722_LDCONTROL_REG)
-#define AS3722_LDO6VOLTAGE_DATA	(0x3F00 | AS3722_LDO6VOLTAGE_REG)
-
-#define I2C_SEND_2_BYTES	0x0A02
-
-void pmic_enable_cpu_vdd(void);

From patchwork Tue Feb 14 17:35:34 2023
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Svyatoslav Ryhel <clamor95@gmail.com>
X-Patchwork-Id: 1742551
X-Patchwork-Delegate: twarren@nvidia.com
Return-Path: <u-boot-bounces@lists.denx.de>
X-Original-To: incoming@patchwork.ozlabs.org
Delivered-To: patchwork-incoming@legolas.ozlabs.org
Authentication-Results: legolas.ozlabs.org;
 spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de
 (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de;
 envelope-from=u-boot-bounces@lists.denx.de; receiver=<UNKNOWN>)
Authentication-Results: legolas.ozlabs.org;
	dkim=pass (2048-bit key;
 unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256
 header.s=20210112 header.b=RF89Hpqg;
	dkim-atps=neutral
Received: from phobos.denx.de (phobos.denx.de
 [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (P-384))
	(No client certificate requested)
	by legolas.ozlabs.org (Postfix) with ESMTPS id 4PGT2y4d7mz23r4
	for <incoming@patchwork.ozlabs.org>; Wed, 15 Feb 2023 04:38:50 +1100 (AEDT)
Received: from h2850616.stratoserver.net (localhost [IPv6:::1])
	by phobos.denx.de (Postfix) with ESMTP id 78ECF85A0B;
	Tue, 14 Feb 2023 18:36:49 +0100 (CET)
Authentication-Results: phobos.denx.de;
 dmarc=pass (p=none dis=none) header.from=gmail.com
Authentication-Results: phobos.denx.de;
 spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de
Authentication-Results: phobos.denx.de;
	dkim=pass (2048-bit key;
 unprotected) header.d=gmail.com header.i=@gmail.com header.b="RF89Hpqg";
	dkim-atps=neutral
Received: by phobos.denx.de (Postfix, from userid 109)
 id A276D85989; Tue, 14 Feb 2023 18:36:24 +0100 (CET)
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de
X-Spam-Level: 
X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,
 DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT,
 FREEMAIL_FROM,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no
 version=3.4.2
Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com
 [IPv6:2a00:1450:4864:20::32c])
 (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits))
 (No client certificate requested)
 by phobos.denx.de (Postfix) with ESMTPS id 17D30859E9
 for <u-boot@lists.denx.de>; Tue, 14 Feb 2023 18:36:13 +0100 (CET)
Authentication-Results: phobos.denx.de;
 dmarc=pass (p=none dis=none) header.from=gmail.com
Authentication-Results: phobos.denx.de;
 spf=pass smtp.mailfrom=clamor95@gmail.com
Received: by mail-wm1-x32c.google.com with SMTP id
 k8-20020a05600c1c8800b003dc57ea0dfeso14265850wms.0
 for <u-boot@lists.denx.de>; Tue, 14 Feb 2023 09:36:13 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=WF10LD7DLePAoey5QEL1v80b40ZtSFsD9NNh9/RfTiI=;
 b=RF89Hpqgh2Q0jQzWCRC9OwvgH87ifdE8DPLUfaRwntZXt+IT7D8IMF5Njce3U4eBPU
 kT9mMAzb3FboMXXuYj05u1cNKhvGwb/j+87VHEKokqoW9q+A4QdH1ORfE7v6zNbwAHyp
 aqaSoXJv9jYXtUngMU6Q8H+h99ZTWsNlmgfOpUj/yNvzZCbmBoMkjk2ueOqsyms88XsR
 R5f8iCSPGslmtdIHuuQtN0XCH95pEYQ16iFtXEKkSME4Lv3aD8ZuST7B5cPEkXbsA8hC
 RjkcUEeAg8rdi7bRhElnqz4pz3e4N653hRwaBXNmufkZKixdMoUs4sKTiQ9bNd/zpgN/
 JO4Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=WF10LD7DLePAoey5QEL1v80b40ZtSFsD9NNh9/RfTiI=;
 b=AvwWyLIyyL9C++1bxW4/etTonG8val02spOc/FcgGaWzhMcLzS/Dyw9S8nXU01k1TZ
 3IQgIJ5zTCtSVRwhaqGke7l7fNWHnD5pkL0nT3z2wfraadu6pb00UMHdmrxbQN81gGjf
 IDEh0vHBTxaQXVmNvI/dhUcbrKLZ78HCtiBYhafcO2Ii3jvOKkcjVaOKTlhzBr4C0j8B
 toaYVAliAWB9zlQABv4xui340gXl8dLQoqWZCYupxU7G+QiYrB7nF18eKyZbgbldf+fw
 5QNo6E//7KAIYiTrABk2+xES8bEV0ikcItL5JL6rTdDgLsdZ+NJHltukxXbm1jzPaF46
 FpwQ==
X-Gm-Message-State: AO0yUKUa6Byeu+Ktq54o8ef1ZRSU8X8dJo9dB1YHU82CSBfsE29fcVrd
 r7QYZr6MAC46bXY1X6xzH+w=
X-Google-Smtp-Source: 
 AK7set/8AbZvD9Lj4CPE6C1+rxO0rem3Koq3dOjTBVG4uo0m/WZIyz4Repmg0tiLhtrVNbwAhNlk+A==
X-Received: by 2002:a05:600c:329b:b0:3dc:5674:66e6 with SMTP id
 t27-20020a05600c329b00b003dc567466e6mr2813929wmp.25.1676396172776;
 Tue, 14 Feb 2023 09:36:12 -0800 (PST)
Received: from xeon.. ([188.163.112.76]) by smtp.gmail.com with ESMTPSA id
 m23-20020a7bca57000000b003de8a1b06c0sm20787829wml.7.2023.02.14.09.36.11
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 14 Feb 2023 09:36:12 -0800 (PST)
From: Svyatoslav Ryhel <clamor95@gmail.com>
To: Tom Warren <twarren@nvidia.com>,
 Marcel Ziswiler <marcel.ziswiler@toradex.com>,
 Allen Martin <amartin@nvidia.com>, Jagan Teki <jagan@amarulasolutions.com>,
 Lukasz Majewski <lukma@denx.de>, Marek Vasut <marex@denx.de>,
 Svyatoslav Ryhel <clamor95@gmail.com>,
 Ramin Khonsari <raminterex@yahoo.com>,
 Thierry Reding <thierry.reding@gmail.com>,
 Maxim Schwalm <maxim.schwalm@gmail.com>,
 Dmitry Osipenko <digetx@gmail.com>, Simon Glass <sjg@chromium.org>
Cc: u-boot@lists.denx.de
Subject: [PATCH v4 12/16] board: tegra30: switch to updated pre-dm i2c write
Date: Tue, 14 Feb 2023 19:35:34 +0200
Message-Id: <20230214173538.6242-13-clamor95@gmail.com>
X-Mailer: git-send-email 2.37.2
In-Reply-To: <20230214173538.6242-1-clamor95@gmail.com>
References: <20230214173538.6242-1-clamor95@gmail.com>
MIME-Version: 1.0
X-BeenThere: u-boot@lists.denx.de
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: U-Boot discussion <u-boot.lists.denx.de>
List-Unsubscribe: <https://lists.denx.de/options/u-boot>,
 <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>
List-Archive: <https://lists.denx.de/pipermail/u-boot/>
List-Post: <mailto:u-boot@lists.denx.de>
List-Help: <mailto:u-boot-request@lists.denx.de?subject=help>
List-Subscribe: <https://lists.denx.de/listinfo/u-boot>,
 <mailto:u-boot-request@lists.denx.de?subject=subscribe>
Errors-To: u-boot-bounces@lists.denx.de
Sender: "U-Boot" <u-boot-bounces@lists.denx.de>
X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de
X-Virus-Status: Clean

Configure PMIC voltages for early stages using updated
early i2c write.

Tested-by: Thierry Reding <treding@nvidia.com> # Beaver T30
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---
 arch/arm/mach-tegra/tegra30/Kconfig         |  8 ----
 arch/arm/mach-tegra/tegra30/cpu.c           | 36 -----------------
 board/avionic-design/tec-ng/Makefile        |  4 +-
 board/avionic-design/tec-ng/tec-ng-spl.c    | 34 ++++++++++++++++
 board/nvidia/beaver/Makefile                |  2 +
 board/nvidia/beaver/beaver-spl.c            | 43 +++++++++++++++++++++
 board/nvidia/cardhu/Makefile                |  4 +-
 board/nvidia/cardhu/cardhu-spl.c            | 43 +++++++++++++++++++++
 board/toradex/apalis_t30/Makefile           |  2 +
 board/toradex/apalis_t30/apalis_t30-spl.c   | 34 ++++++++++++++++
 board/toradex/colibri_t30/Makefile          |  2 +
 board/toradex/colibri_t30/colibri_t30-spl.c | 34 ++++++++++++++++
 12 files changed, 200 insertions(+), 46 deletions(-)
 create mode 100644 board/avionic-design/tec-ng/tec-ng-spl.c
 create mode 100644 board/nvidia/beaver/beaver-spl.c
 create mode 100644 board/nvidia/cardhu/cardhu-spl.c
 create mode 100644 board/toradex/apalis_t30/apalis_t30-spl.c
 create mode 100644 board/toradex/colibri_t30/colibri_t30-spl.c

diff --git a/arch/arm/mach-tegra/tegra30/Kconfig b/arch/arm/mach-tegra/tegra30/Kconfig
index 5619d1cd42..85b8ce294f 100644
--- a/arch/arm/mach-tegra/tegra30/Kconfig
+++ b/arch/arm/mach-tegra/tegra30/Kconfig
@@ -1,11 +1,5 @@
 if TEGRA30
 
-config TEGRA_VDD_CORE_TPS62361B_SET3
-	bool
-
-config TEGRA_VDD_CORE_TPS62366A_SET1
-	bool
-
 choice
 	prompt "Tegra30 board select"
 	optional
@@ -17,12 +11,10 @@ config TARGET_APALIS_T30
 config TARGET_BEAVER
 	bool "NVIDIA Tegra30 Beaver evaluation board"
 	select BOARD_LATE_INIT
-	select TEGRA_VDD_CORE_TPS62366A_SET1
 
 config TARGET_CARDHU
 	bool "NVIDIA Tegra30 Cardhu evaluation board"
 	select BOARD_LATE_INIT
-	select TEGRA_VDD_CORE_TPS62361B_SET3
 
 config TARGET_COLIBRI_T30
 	bool "Toradex Colibri T30 board"
diff --git a/arch/arm/mach-tegra/tegra30/cpu.c b/arch/arm/mach-tegra/tegra30/cpu.c
index 6ac45af51a..60bbf13ea5 100644
--- a/arch/arm/mach-tegra/tegra30/cpu.c
+++ b/arch/arm/mach-tegra/tegra30/cpu.c
@@ -15,20 +15,6 @@
 #include <linux/delay.h>
 #include "../cpu.h"
 
-#define TPS62366A_I2C_ADDR		0xC0
-#define TPS62366A_SET1_REG		0x01
-#define TPS62366A_SET1_DATA		(0x4600 | TPS62366A_SET1_REG)
-
-#define TPS62361B_I2C_ADDR		0xC0
-#define TPS62361B_SET3_REG		0x03
-#define TPS62361B_SET3_DATA		(0x4600 | TPS62361B_SET3_REG)
-
-#define TPS65911_I2C_ADDR		0x5A
-#define TPS65911_VDDCTRL_OP_REG		0x28
-#define TPS65911_VDDCTRL_SR_REG		0x27
-#define TPS65911_VDDCTRL_OP_DATA	(0x2400 | TPS65911_VDDCTRL_OP_REG)
-#define TPS65911_VDDCTRL_SR_DATA	(0x0100 | TPS65911_VDDCTRL_SR_REG)
-
 /* In case this function is not defined */
 __weak void pmic_enable_cpu_vdd(void) {}
 
@@ -41,28 +27,6 @@ static void enable_cpu_power_rail(void)
 	reg = readl(&pmc->pmc_cntrl);
 	reg |= CPUPWRREQ_OE;
 	writel(reg, &pmc->pmc_cntrl);
-
-	/* Set VDD_CORE to 1.200V. */
-#ifdef CONFIG_TEGRA_VDD_CORE_TPS62366A_SET1
-	tegra_i2c_ll_write(TPS62366A_I2C_ADDR,
-			   TPS62366A_SET1_DATA);
-#endif
-#ifdef CONFIG_TEGRA_VDD_CORE_TPS62361B_SET3
-	tegra_i2c_ll_write(TPS62361B_I2C_ADDR,
-			   TPS62361B_SET3_DATA);
-#endif
-	udelay(1000);
-
-	/*
-	 * Bring up CPU VDD via the TPS65911x PMIC on the DVC I2C bus.
-	 * First set VDD to 1.0125V, then enable the VDD regulator.
-	 */
-	tegra_i2c_ll_write(TPS65911_I2C_ADDR,
-			   TPS65911_VDDCTRL_OP_DATA);
-	udelay(1000);
-	tegra_i2c_ll_write(TPS65911_I2C_ADDR,
-			   TPS65911_VDDCTRL_SR_DATA);
-	udelay(10 * 1000);
 }
 
 /**
diff --git a/board/avionic-design/tec-ng/Makefile b/board/avionic-design/tec-ng/Makefile
index 46df14d991..d6890e5797 100644
--- a/board/avionic-design/tec-ng/Makefile
+++ b/board/avionic-design/tec-ng/Makefile
@@ -3,4 +3,6 @@
 # (C) Copyright 2013
 # Avionic Design GmbH <www.avionic-design.de>
 
-obj-y	:= ../common/tamonten-ng.o
+obj-$(CONFIG_SPL_BUILD) += tec-ng-spl.o
+
+obj-y	+= ../common/tamonten-ng.o
diff --git a/board/avionic-design/tec-ng/tec-ng-spl.c b/board/avionic-design/tec-ng/tec-ng-spl.c
new file mode 100644
index 0000000000..6e54464183
--- /dev/null
+++ b/board/avionic-design/tec-ng/tec-ng-spl.c
@@ -0,0 +1,34 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ *  (C) Copyright 2010-2013
+ *  NVIDIA Corporation <www.nvidia.com>
+ *
+ *  (C) Copyright 2021
+ *  Svyatoslav Ryhel <clamor95@gmail.com>
+ */
+
+#include <common.h>
+#include <asm/arch-tegra/tegra_i2c.h>
+#include <linux/delay.h>
+
+/* I2C addr is in 8 bit */
+#define TPS65911_I2C_ADDR		0x5A
+#define TPS65911_VDDCTRL_OP_REG		0x28
+#define TPS65911_VDDCTRL_SR_REG		0x27
+#define TPS65911_VDDCTRL_OP_DATA	(0x2400 | TPS65911_VDDCTRL_OP_REG)
+#define TPS65911_VDDCTRL_SR_DATA	(0x0100 | TPS65911_VDDCTRL_SR_REG)
+
+void pmic_enable_cpu_vdd(void)
+{
+	/*
+	 * Bring up CPU VDD via the TPS65911x PMIC on the DVC I2C bus.
+	 * First set VDD to 1.0125V, then enable the VDD regulator.
+	 */
+	udelay(1000);
+	tegra_i2c_ll_write(TPS65911_I2C_ADDR,
+			   TPS65911_VDDCTRL_OP_DATA);
+	udelay(1000);
+	tegra_i2c_ll_write(TPS65911_I2C_ADDR,
+			   TPS65911_VDDCTRL_SR_DATA);
+	udelay(10 * 1000);
+}
diff --git a/board/nvidia/beaver/Makefile b/board/nvidia/beaver/Makefile
index 80cff3eb9c..5e9e70825c 100644
--- a/board/nvidia/beaver/Makefile
+++ b/board/nvidia/beaver/Makefile
@@ -2,4 +2,6 @@
 #
 # Copyright (c) 2010-2013, NVIDIA CORPORATION.  All rights reserved.
 
+obj-$(CONFIG_SPL_BUILD) += beaver-spl.o
+
 obj-y	= ../cardhu/cardhu.o
diff --git a/board/nvidia/beaver/beaver-spl.c b/board/nvidia/beaver/beaver-spl.c
new file mode 100644
index 0000000000..b5d0c14854
--- /dev/null
+++ b/board/nvidia/beaver/beaver-spl.c
@@ -0,0 +1,43 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ *  (C) Copyright 2010-2013
+ *  NVIDIA Corporation <www.nvidia.com>
+ *
+ *  (C) Copyright 2021
+ *  Svyatoslav Ryhel <clamor95@gmail.com>
+ */
+
+#include <common.h>
+#include <asm/arch-tegra/tegra_i2c.h>
+#include <linux/delay.h>
+
+/* I2C addr is in 8 bit */
+#define TPS65911_I2C_ADDR		0x5A
+#define TPS65911_VDDCTRL_OP_REG		0x28
+#define TPS65911_VDDCTRL_SR_REG		0x27
+#define TPS65911_VDDCTRL_OP_DATA	(0x2400 | TPS65911_VDDCTRL_OP_REG)
+#define TPS65911_VDDCTRL_SR_DATA	(0x0100 | TPS65911_VDDCTRL_SR_REG)
+
+#define TPS62366A_I2C_ADDR		0xC0
+#define TPS62366A_SET1_REG		0x01
+#define TPS62366A_SET1_DATA		(0x4600 | TPS62366A_SET1_REG)
+
+void pmic_enable_cpu_vdd(void)
+{
+	/* Set VDD_CORE to 1.200V. */
+	tegra_i2c_ll_write(TPS62366A_I2C_ADDR,
+			   TPS62366A_SET1_DATA);
+
+	udelay(1000);
+
+	/*
+	 * Bring up CPU VDD via the TPS65911x PMIC on the DVC I2C bus.
+	 * First set VDD to 1.0125V, then enable the VDD regulator.
+	 */
+	tegra_i2c_ll_write(TPS65911_I2C_ADDR,
+			   TPS65911_VDDCTRL_OP_DATA);
+	udelay(1000);
+	tegra_i2c_ll_write(TPS65911_I2C_ADDR,
+			   TPS65911_VDDCTRL_SR_DATA);
+	udelay(10 * 1000);
+}
diff --git a/board/nvidia/cardhu/Makefile b/board/nvidia/cardhu/Makefile
index 95971053d9..6f480cdfd3 100644
--- a/board/nvidia/cardhu/Makefile
+++ b/board/nvidia/cardhu/Makefile
@@ -3,4 +3,6 @@
 #  (C) Copyright 2010-2012
 #  NVIDIA Corporation <www.nvidia.com>
 
-obj-y	:= cardhu.o
+obj-$(CONFIG_SPL_BUILD) += cardhu-spl.o
+
+obj-y	+= cardhu.o
diff --git a/board/nvidia/cardhu/cardhu-spl.c b/board/nvidia/cardhu/cardhu-spl.c
new file mode 100644
index 0000000000..de2fa300f1
--- /dev/null
+++ b/board/nvidia/cardhu/cardhu-spl.c
@@ -0,0 +1,43 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ *  (C) Copyright 2010-2013
+ *  NVIDIA Corporation <www.nvidia.com>
+ *
+ *  (C) Copyright 2021
+ *  Svyatoslav Ryhel <clamor95@gmail.com>
+ */
+
+#include <common.h>
+#include <asm/arch-tegra/tegra_i2c.h>
+#include <linux/delay.h>
+
+/* I2C addr is in 8 bit */
+#define TPS65911_I2C_ADDR		0x5A
+#define TPS65911_VDDCTRL_OP_REG		0x28
+#define TPS65911_VDDCTRL_SR_REG		0x27
+#define TPS65911_VDDCTRL_OP_DATA	(0x2400 | TPS65911_VDDCTRL_OP_REG)
+#define TPS65911_VDDCTRL_SR_DATA	(0x0100 | TPS65911_VDDCTRL_SR_REG)
+
+#define TPS62361B_I2C_ADDR		0xC0
+#define TPS62361B_SET3_REG		0x03
+#define TPS62361B_SET3_DATA		(0x4600 | TPS62361B_SET3_REG)
+
+void pmic_enable_cpu_vdd(void)
+{
+	/* Set VDD_CORE to 1.200V. */
+	tegra_i2c_ll_write(TPS62361B_I2C_ADDR,
+			   TPS62361B_SET3_DATA);
+
+	udelay(1000);
+
+	/*
+	 * Bring up CPU VDD via the TPS65911x PMIC on the DVC I2C bus.
+	 * First set VDD to 1.0125V, then enable the VDD regulator.
+	 */
+	tegra_i2c_ll_write(TPS65911_I2C_ADDR,
+			   TPS65911_VDDCTRL_OP_DATA);
+	udelay(1000);
+	tegra_i2c_ll_write(TPS65911_I2C_ADDR,
+			   TPS65911_VDDCTRL_SR_DATA);
+	udelay(10 * 1000);
+}
diff --git a/board/toradex/apalis_t30/Makefile b/board/toradex/apalis_t30/Makefile
index 0ea3d8f217..eed607043f 100644
--- a/board/toradex/apalis_t30/Makefile
+++ b/board/toradex/apalis_t30/Makefile
@@ -1,4 +1,6 @@
 # Copyright (c) 2014 Marcel Ziswiler
 # SPDX-License-Identifier:      GPL-2.0+
 
+obj-$(CONFIG_SPL_BUILD) += apalis_t30-spl.o
+
 obj-y	+= apalis_t30.o
diff --git a/board/toradex/apalis_t30/apalis_t30-spl.c b/board/toradex/apalis_t30/apalis_t30-spl.c
new file mode 100644
index 0000000000..6e54464183
--- /dev/null
+++ b/board/toradex/apalis_t30/apalis_t30-spl.c
@@ -0,0 +1,34 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ *  (C) Copyright 2010-2013
+ *  NVIDIA Corporation <www.nvidia.com>
+ *
+ *  (C) Copyright 2021
+ *  Svyatoslav Ryhel <clamor95@gmail.com>
+ */
+
+#include <common.h>
+#include <asm/arch-tegra/tegra_i2c.h>
+#include <linux/delay.h>
+
+/* I2C addr is in 8 bit */
+#define TPS65911_I2C_ADDR		0x5A
+#define TPS65911_VDDCTRL_OP_REG		0x28
+#define TPS65911_VDDCTRL_SR_REG		0x27
+#define TPS65911_VDDCTRL_OP_DATA	(0x2400 | TPS65911_VDDCTRL_OP_REG)
+#define TPS65911_VDDCTRL_SR_DATA	(0x0100 | TPS65911_VDDCTRL_SR_REG)
+
+void pmic_enable_cpu_vdd(void)
+{
+	/*
+	 * Bring up CPU VDD via the TPS65911x PMIC on the DVC I2C bus.
+	 * First set VDD to 1.0125V, then enable the VDD regulator.
+	 */
+	udelay(1000);
+	tegra_i2c_ll_write(TPS65911_I2C_ADDR,
+			   TPS65911_VDDCTRL_OP_DATA);
+	udelay(1000);
+	tegra_i2c_ll_write(TPS65911_I2C_ADDR,
+			   TPS65911_VDDCTRL_SR_DATA);
+	udelay(10 * 1000);
+}
diff --git a/board/toradex/colibri_t30/Makefile b/board/toradex/colibri_t30/Makefile
index 4242902dae..8f333235b1 100644
--- a/board/toradex/colibri_t30/Makefile
+++ b/board/toradex/colibri_t30/Makefile
@@ -1,4 +1,6 @@
 # Copyright (c) 2013-2014 Stefan Agner
 # SPDX-License-Identifier:      GPL-2.0+
 
+obj-$(CONFIG_SPL_BUILD) += colibri_t30-spl.o
+
 obj-y	+= colibri_t30.o
diff --git a/board/toradex/colibri_t30/colibri_t30-spl.c b/board/toradex/colibri_t30/colibri_t30-spl.c
new file mode 100644
index 0000000000..6e54464183
--- /dev/null
+++ b/board/toradex/colibri_t30/colibri_t30-spl.c
@@ -0,0 +1,34 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ *  (C) Copyright 2010-2013
+ *  NVIDIA Corporation <www.nvidia.com>
+ *
+ *  (C) Copyright 2021
+ *  Svyatoslav Ryhel <clamor95@gmail.com>
+ */
+
+#include <common.h>
+#include <asm/arch-tegra/tegra_i2c.h>
+#include <linux/delay.h>
+
+/* I2C addr is in 8 bit */
+#define TPS65911_I2C_ADDR		0x5A
+#define TPS65911_VDDCTRL_OP_REG		0x28
+#define TPS65911_VDDCTRL_SR_REG		0x27
+#define TPS65911_VDDCTRL_OP_DATA	(0x2400 | TPS65911_VDDCTRL_OP_REG)
+#define TPS65911_VDDCTRL_SR_DATA	(0x0100 | TPS65911_VDDCTRL_SR_REG)
+
+void pmic_enable_cpu_vdd(void)
+{
+	/*
+	 * Bring up CPU VDD via the TPS65911x PMIC on the DVC I2C bus.
+	 * First set VDD to 1.0125V, then enable the VDD regulator.
+	 */
+	udelay(1000);
+	tegra_i2c_ll_write(TPS65911_I2C_ADDR,
+			   TPS65911_VDDCTRL_OP_DATA);
+	udelay(1000);
+	tegra_i2c_ll_write(TPS65911_I2C_ADDR,
+			   TPS65911_VDDCTRL_SR_DATA);
+	udelay(10 * 1000);
+}

From patchwork Tue Feb 14 17:35:35 2023
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Svyatoslav Ryhel <clamor95@gmail.com>
X-Patchwork-Id: 1742552
X-Patchwork-Delegate: twarren@nvidia.com
Return-Path: <u-boot-bounces@lists.denx.de>
X-Original-To: incoming@patchwork.ozlabs.org
Delivered-To: patchwork-incoming@legolas.ozlabs.org
Authentication-Results: legolas.ozlabs.org;
 spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de
 (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de;
 envelope-from=u-boot-bounces@lists.denx.de; receiver=<UNKNOWN>)
Authentication-Results: legolas.ozlabs.org;
	dkim=pass (2048-bit key;
 unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256
 header.s=20210112 header.b=NI4I1ny0;
	dkim-atps=neutral
Received: from phobos.denx.de (phobos.denx.de
 [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (P-384))
	(No client certificate requested)
	by legolas.ozlabs.org (Postfix) with ESMTPS id 4PGT396KwBz23r4
	for <incoming@patchwork.ozlabs.org>; Wed, 15 Feb 2023 04:39:01 +1100 (AEDT)
Received: from h2850616.stratoserver.net (localhost [IPv6:::1])
	by phobos.denx.de (Postfix) with ESMTP id 063A485A18;
	Tue, 14 Feb 2023 18:36:52 +0100 (CET)
Authentication-Results: phobos.denx.de;
 dmarc=pass (p=none dis=none) header.from=gmail.com
Authentication-Results: phobos.denx.de;
 spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de
Authentication-Results: phobos.denx.de;
	dkim=pass (2048-bit key;
 unprotected) header.d=gmail.com header.i=@gmail.com header.b="NI4I1ny0";
	dkim-atps=neutral
Received: by phobos.denx.de (Postfix, from userid 109)
 id B0BAE85979; Tue, 14 Feb 2023 18:36:27 +0100 (CET)
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de
X-Spam-Level: 
X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,
 DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT,
 FREEMAIL_FROM,SPF_HELO_NONE,SPF_PASS autolearn=unavailable
 autolearn_force=no version=3.4.2
Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com
 [IPv6:2a00:1450:4864:20::336])
 (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits))
 (No client certificate requested)
 by phobos.denx.de (Postfix) with ESMTPS id 58D8485981
 for <u-boot@lists.denx.de>; Tue, 14 Feb 2023 18:36:14 +0100 (CET)
Authentication-Results: phobos.denx.de;
 dmarc=pass (p=none dis=none) header.from=gmail.com
Authentication-Results: phobos.denx.de;
 spf=pass smtp.mailfrom=clamor95@gmail.com
Received: by mail-wm1-x336.google.com with SMTP id o36so11517912wms.1
 for <u-boot@lists.denx.de>; Tue, 14 Feb 2023 09:36:14 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=0KH9TNK7GAM9SVJRTr0ruGpITgObTzjqz3Xpr+YoHLk=;
 b=NI4I1ny0pVJPpSeCBc83KcI+ori7V2Lre6Y5g2aFVRp+Rfu981XzZT8P2XvgGE0Xac
 yZwg1SXOvYEw/3GUDoWpM6GssYhdrWWG5Ynk1w4jIQvVzjGCgjo7vGzpYISxzfeHxYwL
 PDkk4QFCVEOVv13yyTPMsVLqaurSoeLy4JwHtk97J3euguD4UjpdpNJlYLRtFd0RAyqq
 GFGKK2ejQf/D2w0c63o9CO6Pz1bDhCfeCZ/EqvPNIJMFzy6YNlapyqzHbHw+iDzBBBe5
 N3hMDx3q4Xu2uLfGiYawb2uFDB3HGFO/IPsD7dSEHgFXmAIquLr3P/LmpcIW/1qqrngJ
 fzOQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=0KH9TNK7GAM9SVJRTr0ruGpITgObTzjqz3Xpr+YoHLk=;
 b=eIdIma4eEbjbAUjvpJAZm8s+JThhQ5CmoNpV+dXtgxAI/W/mRMl2wE/nmqzZ1S2nOY
 JItx5eWysg60LbxOcbGHA2KGsKuW036sVJhu24QNkqZ03gr9ft4LzJFGC167ZOmVtN7x
 /WvIFizGgT/J5BPncs+2AkDPN1HFHKsxgRcLOzMCGELcrp5/oT72LQ0BKCn+qHt9pSFw
 kvPvZecooO7rfW9jIHH02RxzfImNSvwNE5hQBzsle388yqDpx8Te3q5gyUurcpTWgpFZ
 RXiDthCXpduKNJAvgrbwYXn8lkz2lbFlAfC6h/YudVDnZporrwBmCcHAYfZSpEh4qvW+
 lfLQ==
X-Gm-Message-State: AO0yUKXfTT83AFyR8s42l668yqT13tWANaK3cG7vhJcTYqTMLJ5GZJiZ
 ki5dRTC4b9tm7WZViEhkO4k=
X-Google-Smtp-Source: 
 AK7set/i3UPXVRGJ7eJNo/wCnmGjL7HdZ09Cr5l4FL8Wpm8nhvRmzWFwBWGx7O4aC3OYWCR7m5V7Vw==
X-Received: by 2002:a05:600c:154f:b0:3e1:df8d:e022 with SMTP id
 f15-20020a05600c154f00b003e1df8de022mr446810wmg.9.1676396173942;
 Tue, 14 Feb 2023 09:36:13 -0800 (PST)
Received: from xeon.. ([188.163.112.76]) by smtp.gmail.com with ESMTPSA id
 m23-20020a7bca57000000b003de8a1b06c0sm20787829wml.7.2023.02.14.09.36.12
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 14 Feb 2023 09:36:13 -0800 (PST)
From: Svyatoslav Ryhel <clamor95@gmail.com>
To: Tom Warren <twarren@nvidia.com>,
 Marcel Ziswiler <marcel.ziswiler@toradex.com>,
 Allen Martin <amartin@nvidia.com>, Jagan Teki <jagan@amarulasolutions.com>,
 Lukasz Majewski <lukma@denx.de>, Marek Vasut <marex@denx.de>,
 Svyatoslav Ryhel <clamor95@gmail.com>,
 Ramin Khonsari <raminterex@yahoo.com>,
 Thierry Reding <thierry.reding@gmail.com>,
 Maxim Schwalm <maxim.schwalm@gmail.com>,
 Dmitry Osipenko <digetx@gmail.com>, Simon Glass <sjg@chromium.org>
Cc: u-boot@lists.denx.de
Subject: [PATCH v4 13/16] ARM: tegra: expose crypto module for all Tegra SoCs
Date: Tue, 14 Feb 2023 19:35:35 +0200
Message-Id: <20230214173538.6242-14-clamor95@gmail.com>
X-Mailer: git-send-email 2.37.2
In-Reply-To: <20230214173538.6242-1-clamor95@gmail.com>
References: <20230214173538.6242-1-clamor95@gmail.com>
MIME-Version: 1.0
X-BeenThere: u-boot@lists.denx.de
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: U-Boot discussion <u-boot.lists.denx.de>
List-Unsubscribe: <https://lists.denx.de/options/u-boot>,
 <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>
List-Archive: <https://lists.denx.de/pipermail/u-boot/>
List-Post: <mailto:u-boot@lists.denx.de>
List-Help: <mailto:u-boot-request@lists.denx.de?subject=help>
List-Subscribe: <https://lists.denx.de/listinfo/u-boot>,
 <mailto:u-boot-request@lists.denx.de?subject=subscribe>
Errors-To: u-boot-bounces@lists.denx.de
Sender: "U-Boot" <u-boot-bounces@lists.denx.de>
X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de
X-Virus-Status: Clean

Move crypto module from T20 only into common Tegra dir.

Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 arch/arm/mach-tegra/Kconfig                | 5 +++++
 arch/arm/mach-tegra/Makefile               | 1 +
 arch/arm/mach-tegra/{tegra20 => }/crypto.c | 0
 arch/arm/mach-tegra/{tegra20 => }/crypto.h | 0
 arch/arm/mach-tegra/tegra20/Kconfig        | 1 +
 arch/arm/mach-tegra/tegra20/Makefile       | 2 +-
 6 files changed, 8 insertions(+), 1 deletion(-)
 rename arch/arm/mach-tegra/{tegra20 => }/crypto.c (100%)
 rename arch/arm/mach-tegra/{tegra20 => }/crypto.h (100%)

diff --git a/arch/arm/mach-tegra/Kconfig b/arch/arm/mach-tegra/Kconfig
index 4fc79ebadb..5b0cd92d9e 100644
--- a/arch/arm/mach-tegra/Kconfig
+++ b/arch/arm/mach-tegra/Kconfig
@@ -15,6 +15,11 @@ config SPL_SERIAL
 config TEGRA_CLKRST
 	bool
 
+config TEGRA_CRYPTO
+	bool "Tegra AES128 crypto module"
+	select AES
+	default n
+
 config TEGRA_GP_PADCTRL
 	bool
 
diff --git a/arch/arm/mach-tegra/Makefile b/arch/arm/mach-tegra/Makefile
index 7165d70a60..9147050b32 100644
--- a/arch/arm/mach-tegra/Makefile
+++ b/arch/arm/mach-tegra/Makefile
@@ -16,6 +16,7 @@ obj-$(CONFIG_TEGRA_GP_PADCTRL) += ap.o
 obj-y += board.o board2.o
 obj-y += cache.o
 obj-$(CONFIG_TEGRA_CLKRST) += clock.o
+obj-$(CONFIG_$(SPL_)TEGRA_CRYPTO) += crypto.o
 obj-$(CONFIG_TEGRA_PINCTRL) += pinmux-common.o
 obj-$(CONFIG_TEGRA_PMC) += powergate.o
 obj-y += xusb-padctl-dummy.o
diff --git a/arch/arm/mach-tegra/tegra20/crypto.c b/arch/arm/mach-tegra/crypto.c
similarity index 100%
rename from arch/arm/mach-tegra/tegra20/crypto.c
rename to arch/arm/mach-tegra/crypto.c
diff --git a/arch/arm/mach-tegra/tegra20/crypto.h b/arch/arm/mach-tegra/crypto.h
similarity index 100%
rename from arch/arm/mach-tegra/tegra20/crypto.h
rename to arch/arm/mach-tegra/crypto.h
diff --git a/arch/arm/mach-tegra/tegra20/Kconfig b/arch/arm/mach-tegra/tegra20/Kconfig
index 955786c0c4..57d11024bf 100644
--- a/arch/arm/mach-tegra/tegra20/Kconfig
+++ b/arch/arm/mach-tegra/tegra20/Kconfig
@@ -3,6 +3,7 @@ if TEGRA20
 config TEGRA_LP0
 	bool
 	select TEGRA_CLOCK_SCALING
+	select TEGRA_CRYPTO
 
 config TEGRA_PMU
 	bool
diff --git a/arch/arm/mach-tegra/tegra20/Makefile b/arch/arm/mach-tegra/tegra20/Makefile
index bb17c90cca..67454ff5f4 100644
--- a/arch/arm/mach-tegra/tegra20/Makefile
+++ b/arch/arm/mach-tegra/tegra20/Makefile
@@ -13,6 +13,6 @@ CFLAGS_warmboot_avp.o = -march=armv4t -U__LINUX_ARM_ARCH__ \
 CFLAGS_REMOVE_warmboot_avp.o := $(LTO_CFLAGS)
 
 obj-y	+= clock.o funcmux.o pinmux.o
-obj-$(CONFIG_TEGRA_LP0) += warmboot.o crypto.o warmboot_avp.o
+obj-$(CONFIG_TEGRA_LP0) += warmboot.o warmboot_avp.o
 obj-$(CONFIG_TEGRA_CLOCK_SCALING) += emc.o
 obj-$(CONFIG_TEGRA_PMU) += pmu.o

From patchwork Tue Feb 14 17:35:36 2023
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Svyatoslav Ryhel <clamor95@gmail.com>
X-Patchwork-Id: 1742555
X-Patchwork-Delegate: twarren@nvidia.com
Return-Path: <u-boot-bounces@lists.denx.de>
X-Original-To: incoming@patchwork.ozlabs.org
Delivered-To: patchwork-incoming@legolas.ozlabs.org
Authentication-Results: legolas.ozlabs.org;
 spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de
 (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de;
 envelope-from=u-boot-bounces@lists.denx.de; receiver=<UNKNOWN>)
Authentication-Results: legolas.ozlabs.org;
	dkim=pass (2048-bit key;
 unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256
 header.s=20210112 header.b=QlaimYGy;
	dkim-atps=neutral
Received: from phobos.denx.de (phobos.denx.de
 [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (P-384))
	(No client certificate requested)
	by legolas.ozlabs.org (Postfix) with ESMTPS id 4PGT7R4dFBz23hX
	for <incoming@patchwork.ozlabs.org>; Wed, 15 Feb 2023 04:42:43 +1100 (AEDT)
Received: from h2850616.stratoserver.net (localhost [IPv6:::1])
	by phobos.denx.de (Postfix) with ESMTP id 4215185971;
	Tue, 14 Feb 2023 18:42:39 +0100 (CET)
Authentication-Results: phobos.denx.de;
 dmarc=pass (p=none dis=none) header.from=gmail.com
Authentication-Results: phobos.denx.de;
 spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de
Authentication-Results: phobos.denx.de;
	dkim=pass (2048-bit key;
 unprotected) header.d=gmail.com header.i=@gmail.com header.b="QlaimYGy";
	dkim-atps=neutral
Received: by phobos.denx.de (Postfix, from userid 109)
 id 38F6E85918; Tue, 14 Feb 2023 18:42:38 +0100 (CET)
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de
X-Spam-Level: 
X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,
 DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT,
 FREEMAIL_FROM,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no
 version=3.4.2
Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com
 [IPv6:2a00:1450:4864:20::331])
 (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits))
 (No client certificate requested)
 by phobos.denx.de (Postfix) with ESMTPS id 610BA85970
 for <u-boot@lists.denx.de>; Tue, 14 Feb 2023 18:36:15 +0100 (CET)
Authentication-Results: phobos.denx.de;
 dmarc=pass (p=none dis=none) header.from=gmail.com
Authentication-Results: phobos.denx.de;
 spf=pass smtp.mailfrom=clamor95@gmail.com
Received: by mail-wm1-x331.google.com with SMTP id
 m16-20020a05600c3b1000b003dc4050c94aso12188713wms.4
 for <u-boot@lists.denx.de>; Tue, 14 Feb 2023 09:36:15 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=8msyuJGBvdoXq1TBp4pmgC2cqUFFX/07UKLosAMfi7s=;
 b=QlaimYGyUusqyEZhw7WgXlT7zf0uYxGxQ8tUebtIKbXKiYMrQVVds1odOl4xB/anEC
 IXJMedI6rdSQwn4KbCNLsPE0uWGSvecz2STULMBj1Tg/00YRZa5TWZS8q72dLNisSvqP
 1AR9+WP46IkDYLH1sksswBB5W5H37avoRQRXvor+PG4X21+JGqf/aXvD5s+CVTc7qPxr
 AxMPdokjp2i9DzcvghJPFmXg3aHY34/0EB0sHjGGk8nVKqKVIVCt/gQLGWhWTrD6E7Jr
 97qR2iftaJna4noggpknMvTEJaTFKKmNt/KVhjS9eOwTBDNjHDR4XSxT8Hbmw0kmebVk
 3f4Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=8msyuJGBvdoXq1TBp4pmgC2cqUFFX/07UKLosAMfi7s=;
 b=YMyQccUbK44pZWgesIJV85NFjQdW558+o5JifX0obK7y0mllnC7AnKpcgmvGQDsK2J
 gmFMcZAduPqcWX7EUjc3s+5u7O+Fj8Zu1RBW66kdSwWp6eGe3l7TllzfMvVOHqDopxYn
 Xn0WHR4Y5wjYPiR7gcQqzHvQE+leYFntw3gk3xfIwv98XbyR7GFUYsArD8uhwWSVJCTd
 XWvl8HoJBzhRQsoSOH3+C38Hu3PSfw5UywsoSQa+S1ZJBhnnZyNer+cQfKCgJCbM9Dw6
 n1s/8C220bFDANGGQ6jQRpy4DjO/CJvHwhPBzreD/6OubCfiWIfUlfY1hjoAVrGzd/cd
 AT9g==
X-Gm-Message-State: AO0yUKXXDhMlqs6VCJN0PdxyEeD/QoVAFy7FyWWxPqCWs+MWakupn7vU
 vuNjJ+CRqDC4DPCC8i3PTWc=
X-Google-Smtp-Source: 
 AK7set+b2f2Nf2S+te05VvmREq6sORnwIqd0JFkmijIe5N0HBm0i/t1TfiEpCuhivEAW3cXyRLrhEQ==
X-Received: by 2002:a05:600c:1607:b0:3e0:185:e93a with SMTP id
 m7-20020a05600c160700b003e00185e93amr2792734wmn.25.1676396175135;
 Tue, 14 Feb 2023 09:36:15 -0800 (PST)
Received: from xeon.. ([188.163.112.76]) by smtp.gmail.com with ESMTPSA id
 m23-20020a7bca57000000b003de8a1b06c0sm20787829wml.7.2023.02.14.09.36.14
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 14 Feb 2023 09:36:14 -0800 (PST)
From: Svyatoslav Ryhel <clamor95@gmail.com>
To: Tom Warren <twarren@nvidia.com>,
 Marcel Ziswiler <marcel.ziswiler@toradex.com>,
 Allen Martin <amartin@nvidia.com>, Jagan Teki <jagan@amarulasolutions.com>,
 Lukasz Majewski <lukma@denx.de>, Marek Vasut <marex@denx.de>,
 Svyatoslav Ryhel <clamor95@gmail.com>,
 Ramin Khonsari <raminterex@yahoo.com>,
 Thierry Reding <thierry.reding@gmail.com>,
 Maxim Schwalm <maxim.schwalm@gmail.com>,
 Dmitry Osipenko <digetx@gmail.com>, Simon Glass <sjg@chromium.org>
Cc: u-boot@lists.denx.de
Subject: [PATCH v4 14/16] ARM: tegra: crypto: extend crypto functional
Date: Tue, 14 Feb 2023 19:35:36 +0200
Message-Id: <20230214173538.6242-15-clamor95@gmail.com>
X-Mailer: git-send-email 2.37.2
In-Reply-To: <20230214173538.6242-1-clamor95@gmail.com>
References: <20230214173538.6242-1-clamor95@gmail.com>
MIME-Version: 1.0
X-BeenThere: u-boot@lists.denx.de
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: U-Boot discussion <u-boot.lists.denx.de>
List-Unsubscribe: <https://lists.denx.de/options/u-boot>,
 <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>
List-Archive: <https://lists.denx.de/pipermail/u-boot/>
List-Post: <mailto:u-boot@lists.denx.de>
List-Help: <mailto:u-boot-request@lists.denx.de?subject=help>
List-Subscribe: <https://lists.denx.de/listinfo/u-boot>,
 <mailto:u-boot-request@lists.denx.de?subject=subscribe>
Errors-To: u-boot-bounces@lists.denx.de
Sender: "U-Boot" <u-boot-bounces@lists.denx.de>
X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de
X-Virus-Status: Clean

Add support for encryption, decryption and signinig with
non-zero key saving backward compatibility.

Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 arch/arm/include/asm/arch-tegra/crypto.h | 47 ++++++++++++++++++
 arch/arm/mach-tegra/crypto.c             | 63 +++++++++++++++++-------
 arch/arm/mach-tegra/crypto.h             | 19 -------
 3 files changed, 91 insertions(+), 38 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-tegra/crypto.h
 delete mode 100644 arch/arm/mach-tegra/crypto.h

diff --git a/arch/arm/include/asm/arch-tegra/crypto.h b/arch/arm/include/asm/arch-tegra/crypto.h
new file mode 100644
index 0000000000..7646163b97
--- /dev/null
+++ b/arch/arm/include/asm/arch-tegra/crypto.h
@@ -0,0 +1,47 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2011 The Chromium OS Authors.
+ * (C) Copyright 2010 - 2011 NVIDIA Corporation <www.nvidia.com>
+ */
+
+#ifndef _CRYPTO_H_
+#define _CRYPTO_H_
+
+/**
+ * Sign a block of data
+ *
+ * \param source	Source data
+ * \param length	Size of source data
+ * \param signature	Destination address for signature, AES_KEY_LENGTH bytes
+ */
+int sign_data_block(u8 *source, unsigned int length, u8 *signature);
+
+/**
+ * Sign an encrypted block of data
+ *
+ * \param source	Source data
+ * \param length	Size of source data
+ * \param signature	Destination address for signature, AES_KEY_LENGTH bytes
+ * \param key		AES128 encryption key
+ */
+int sign_enc_data_block(u8 *source, unsigned int length, u8 *signature, u8 *key);
+
+/**
+ * Encrypt a block of data
+ *
+ * \param source	Source data
+ * \param length	Size of source data
+ * \param key		AES128 encryption key
+ */
+int encrypt_data_block(u8 *source, unsigned int length, u8 *key);
+
+/**
+ * Decrypt a block of data
+ *
+ * \param source	Source data
+ * \param length	Size of source data
+ * \param key		AES128 encryption key
+ */
+int decrypt_data_block(u8 *source, unsigned int length, u8 *key);
+
+#endif /* #ifndef _CRYPTO_H_ */
diff --git a/arch/arm/mach-tegra/crypto.c b/arch/arm/mach-tegra/crypto.c
index 1efaa5c3ec..893da35e0b 100644
--- a/arch/arm/mach-tegra/crypto.c
+++ b/arch/arm/mach-tegra/crypto.c
@@ -7,7 +7,7 @@
 #include <common.h>
 #include <log.h>
 #include <linux/errno.h>
-#include "crypto.h"
+#include <asm/arch-tegra/crypto.h>
 #include "uboot_aes.h"
 
 static u8 zero_key[16];
@@ -17,6 +17,7 @@ static u8 zero_key[16];
 enum security_op {
 	SECURITY_SIGN		= 1 << 0,	/* Sign the data */
 	SECURITY_ENCRYPT	= 1 << 1,	/* Encrypt the data */
+	SECURITY_DECRYPT	= 1 << 2,	/* Dectypt the data */
 };
 
 /**
@@ -54,7 +55,7 @@ static void sign_object(u8 *key, u8 *key_schedule, u8 *src, u8 *dst,
 	u8 left[AES128_KEY_LENGTH];
 	u8 k1[AES128_KEY_LENGTH];
 	u8 *cbc_chain_data;
-	unsigned i;
+	unsigned int i;
 
 	cbc_chain_data = zero_key;	/* Convenient array of 0's for IV */
 
@@ -92,7 +93,7 @@ static void sign_object(u8 *key, u8 *key_schedule, u8 *src, u8 *dst,
 }
 
 /**
- * Encrypt and sign a block of data (depending on security mode).
+ * Decrypt, encrypt or sign a block of data (depending on security mode).
  *
  * \param key		Input AES key, length AES128_KEY_LENGTH
  * \param oper		Security operations mask to perform (enum security_op)
@@ -100,44 +101,68 @@ static void sign_object(u8 *key, u8 *key_schedule, u8 *src, u8 *dst,
  * \param length	Size of source data
  * \param sig_dst	Destination address for signature, AES128_KEY_LENGTH bytes
  */
-static int encrypt_and_sign(u8 *key, enum security_op oper, u8 *src,
-			    u32 length, u8 *sig_dst)
+static int tegra_crypto_core(u8 *key, enum security_op oper, u8 *src,
+			     u32 length, u8 *sig_dst)
 {
 	u32 num_aes_blocks;
 	u8 key_schedule[AES128_EXPAND_KEY_LENGTH];
 	u8 iv[AES128_KEY_LENGTH] = {0};
 
-	debug("encrypt_and_sign: length = %d\n", length);
+	debug("%s: length = %d\n", __func__, length);
 
-	/*
-	 * The only need for a key is for signing/checksum purposes, so
-	 * if not encrypting, expand a key of 0s.
-	 */
-	aes_expand_key(oper & SECURITY_ENCRYPT ? key : zero_key,
-		       AES128_KEY_LENGTH, key_schedule);
+	aes_expand_key(key, AES128_KEY_LENGTH, key_schedule);
 
 	num_aes_blocks = (length + AES128_KEY_LENGTH - 1) / AES128_KEY_LENGTH;
 
+	if (oper & SECURITY_DECRYPT) {
+		/* Perform this in place, resulting in src being decrypted. */
+		debug("%s: begin decryption\n", __func__);
+		aes_cbc_decrypt_blocks(AES128_KEY_LENGTH, key_schedule, iv, src,
+				       src, num_aes_blocks);
+		debug("%s: end decryption\n", __func__);
+	}
+
 	if (oper & SECURITY_ENCRYPT) {
 		/* Perform this in place, resulting in src being encrypted. */
-		debug("encrypt_and_sign: begin encryption\n");
+		debug("%s: begin encryption\n", __func__);
 		aes_cbc_encrypt_blocks(AES128_KEY_LENGTH, key_schedule, iv, src,
 				       src, num_aes_blocks);
-		debug("encrypt_and_sign: end encryption\n");
+		debug("%s: end encryption\n", __func__);
 	}
 
 	if (oper & SECURITY_SIGN) {
 		/* encrypt the data, overwriting the result in signature. */
-		debug("encrypt_and_sign: begin signing\n");
+		debug("%s: begin signing\n", __func__);
 		sign_object(key, key_schedule, src, sig_dst, num_aes_blocks);
-		debug("encrypt_and_sign: end signing\n");
+		debug("%s: end signing\n", __func__);
 	}
 
 	return 0;
 }
 
-int sign_data_block(u8 *source, unsigned length, u8 *signature)
+/**
+ * Tegra crypto group
+ */
+int sign_data_block(u8 *source, unsigned int length, u8 *signature)
+{
+	return tegra_crypto_core(zero_key, SECURITY_SIGN, source,
+				 length, signature);
+}
+
+int sign_enc_data_block(u8 *source, unsigned int length, u8 *signature, u8 *key)
+{
+	return tegra_crypto_core(key, SECURITY_SIGN, source,
+				 length, signature);
+}
+
+int encrypt_data_block(u8 *source, unsigned int length, u8 *key)
+{
+	return tegra_crypto_core(key, SECURITY_ENCRYPT, source,
+				 length, NULL);
+}
+
+int decrypt_data_block(u8 *source, unsigned int length, u8 *key)
 {
-	return encrypt_and_sign(zero_key, SECURITY_SIGN, source,
-				length, signature);
+	return tegra_crypto_core(key, SECURITY_DECRYPT, source,
+				 length, NULL);
 }
diff --git a/arch/arm/mach-tegra/crypto.h b/arch/arm/mach-tegra/crypto.h
deleted file mode 100644
index a773d03fc7..0000000000
--- a/arch/arm/mach-tegra/crypto.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * Copyright (c) 2011 The Chromium OS Authors.
- * (C) Copyright 2010 - 2011 NVIDIA Corporation <www.nvidia.com>
- */
-
-#ifndef _CRYPTO_H_
-#define _CRYPTO_H_
-
-/**
- * Sign a block of data
- *
- * \param source	Source data
- * \param length	Size of source data
- * \param signature	Destination address for signature, AES_KEY_LENGTH bytes
- */
-int sign_data_block(u8 *source, unsigned length, u8 *signature);
-
-#endif /* #ifndef _CRYPTO_H_ */

From patchwork Tue Feb 14 17:35:37 2023
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Svyatoslav Ryhel <clamor95@gmail.com>
X-Patchwork-Id: 1742553
X-Patchwork-Delegate: twarren@nvidia.com
Return-Path: <u-boot-bounces@lists.denx.de>
X-Original-To: incoming@patchwork.ozlabs.org
Delivered-To: patchwork-incoming@legolas.ozlabs.org
Authentication-Results: legolas.ozlabs.org;
 spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de
 (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de;
 envelope-from=u-boot-bounces@lists.denx.de; receiver=<UNKNOWN>)
Authentication-Results: legolas.ozlabs.org;
	dkim=pass (2048-bit key;
 unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256
 header.s=20210112 header.b=lhJucjjm;
	dkim-atps=neutral
Received: from phobos.denx.de (phobos.denx.de
 [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (P-384))
	(No client certificate requested)
	by legolas.ozlabs.org (Postfix) with ESMTPS id 4PGT3j4NDkz23r4
	for <incoming@patchwork.ozlabs.org>; Wed, 15 Feb 2023 04:39:29 +1100 (AEDT)
Received: from h2850616.stratoserver.net (localhost [IPv6:::1])
	by phobos.denx.de (Postfix) with ESMTP id 8111585A09;
	Tue, 14 Feb 2023 18:36:54 +0100 (CET)
Authentication-Results: phobos.denx.de;
 dmarc=pass (p=none dis=none) header.from=gmail.com
Authentication-Results: phobos.denx.de;
 spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de
Authentication-Results: phobos.denx.de;
	dkim=pass (2048-bit key;
 unprotected) header.d=gmail.com header.i=@gmail.com header.b="lhJucjjm";
	dkim-atps=neutral
Received: by phobos.denx.de (Postfix, from userid 109)
 id 849DB8597A; Tue, 14 Feb 2023 18:36:29 +0100 (CET)
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de
X-Spam-Level: 
X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,
 DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT,
 FREEMAIL_FROM,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no
 version=3.4.2
Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com
 [IPv6:2a00:1450:4864:20::332])
 (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits))
 (No client certificate requested)
 by phobos.denx.de (Postfix) with ESMTPS id C054D859EE
 for <u-boot@lists.denx.de>; Tue, 14 Feb 2023 18:36:16 +0100 (CET)
Authentication-Results: phobos.denx.de;
 dmarc=pass (p=none dis=none) header.from=gmail.com
Authentication-Results: phobos.denx.de;
 spf=pass smtp.mailfrom=clamor95@gmail.com
Received: by mail-wm1-x332.google.com with SMTP id
 m20-20020a05600c3b1400b003e1e754657aso5797901wms.2
 for <u-boot@lists.denx.de>; Tue, 14 Feb 2023 09:36:16 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=Ju/cfW4+6Y9CQeciX6b1ok8t5NdAJY8rIGxD5XJiVwk=;
 b=lhJucjjm416qTIJTky8LeyoRS/2tBTAcUkEvmQz/eUSRioBt/iiYmnw824LHsAkhOx
 oC8kvL/P6sHUtDR3v13HbERj6ELOd1fV1kd9iJ+ozHTiV72d4ujUQtnz86wE0wTxArIe
 0Ib3qhdMLfDVzjjpPr+7hAJPpmdrsk2Uw8TII/c9SAUhKbVXFLhKI0LjaAXgzvt0+V92
 6ifSjxQ+nCak5idb5aVUS2gENynCc2buVdCyvNn5EOtWb0Hg7fAau1OUqzI2i7Rkt0ND
 xqMjnCMoVigAuKMDJBalPLMotRreGHkgsnVWe3WRPJ90JdGtgivP89VUb9uqJtq0zWoN
 buoA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=Ju/cfW4+6Y9CQeciX6b1ok8t5NdAJY8rIGxD5XJiVwk=;
 b=5viqZGEDW+IArPk+uc5YMFfFzMvtZI4rpLYy4f+A1F+IU+Hzl9U0xHhZELAImhCJ0V
 1POD4rRIb/dK2AIg0i28IX9ejsi7dGXk4j9Exjqs2UMUsljOLNko4A9kl5q8dWx4lpx4
 F6Peop2Z9+vs3v6Zr1lpMXynkhyI+YpoNYL07kPsBfX1O6cSVENrPsclN2mUkn7rosJ0
 WXe3OhDlu4vT4EJhX7xpmASllivixjzgQTGj/4EyMmyRlmWLorFqPVpnM4rvBKlYxDNu
 1Lvtdb0VeUrIbBTWJO7X2vsNA1hXeQ4CeQkAFMPRCwOIZzpTplvwlnmNv88jegVfFmya
 fm5A==
X-Gm-Message-State: AO0yUKU52w/tcsDeVDcMOLilrSV5FVh4TLYYxsh7c5qcfGExdHhnUDPF
 17mZcw7N6oHJBlCoCWy/xYU=
X-Google-Smtp-Source: 
 AK7set/xpVE4LZ9PnXFz4Vc+anFBuDnTmb0dGnA/OpP6WKU25C3aa+h1tsZT0RIwSvNSmRGROvKXHA==
X-Received: by 2002:a05:600c:3095:b0:3df:f860:3089 with SMTP id
 g21-20020a05600c309500b003dff8603089mr3410953wmn.32.1676396176252;
 Tue, 14 Feb 2023 09:36:16 -0800 (PST)
Received: from xeon.. ([188.163.112.76]) by smtp.gmail.com with ESMTPSA id
 m23-20020a7bca57000000b003de8a1b06c0sm20787829wml.7.2023.02.14.09.36.15
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 14 Feb 2023 09:36:16 -0800 (PST)
From: Svyatoslav Ryhel <clamor95@gmail.com>
To: Tom Warren <twarren@nvidia.com>,
 Marcel Ziswiler <marcel.ziswiler@toradex.com>,
 Allen Martin <amartin@nvidia.com>, Jagan Teki <jagan@amarulasolutions.com>,
 Lukasz Majewski <lukma@denx.de>, Marek Vasut <marex@denx.de>,
 Svyatoslav Ryhel <clamor95@gmail.com>,
 Ramin Khonsari <raminterex@yahoo.com>,
 Thierry Reding <thierry.reding@gmail.com>,
 Maxim Schwalm <maxim.schwalm@gmail.com>,
 Dmitry Osipenko <digetx@gmail.com>, Simon Glass <sjg@chromium.org>
Cc: u-boot@lists.denx.de
Subject: [PATCH v4 15/16] ARM: tegra30: implement BCT patching
Date: Tue, 14 Feb 2023 19:35:37 +0200
Message-Id: <20230214173538.6242-16-clamor95@gmail.com>
X-Mailer: git-send-email 2.37.2
In-Reply-To: <20230214173538.6242-1-clamor95@gmail.com>
References: <20230214173538.6242-1-clamor95@gmail.com>
MIME-Version: 1.0
X-BeenThere: u-boot@lists.denx.de
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: U-Boot discussion <u-boot.lists.denx.de>
List-Unsubscribe: <https://lists.denx.de/options/u-boot>,
 <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>
List-Archive: <https://lists.denx.de/pipermail/u-boot/>
List-Post: <mailto:u-boot@lists.denx.de>
List-Help: <mailto:u-boot-request@lists.denx.de?subject=help>
List-Subscribe: <https://lists.denx.de/listinfo/u-boot>,
 <mailto:u-boot-request@lists.denx.de?subject=subscribe>
Errors-To: u-boot-bounces@lists.denx.de
Sender: "U-Boot" <u-boot-bounces@lists.denx.de>
X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de
X-Virus-Status: Clean

From: Ramin Khonsari <raminterex@yahoo.com>

This function allows updating bootloader from u-boot
on production devices without need in host PC.

Be aware! It works only with re-crypted BCT.

Tested-by: Andreas Westman Dorcsak <hedmoo@yahoo.com> # ASUS TF T30
Tested-by: Svyatoslav Ryhel <clamor95@gmail.com> # LG P895 T30
Signed-off-by: Ramin Khonsari <raminterex@yahoo.com>
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 arch/arm/mach-tegra/Kconfig          |  9 ++++
 arch/arm/mach-tegra/tegra30/Makefile |  1 +
 arch/arm/mach-tegra/tegra30/bct.c    | 79 ++++++++++++++++++++++++++++
 arch/arm/mach-tegra/tegra30/bct.h    | 42 +++++++++++++++
 4 files changed, 131 insertions(+)
 create mode 100644 arch/arm/mach-tegra/tegra30/bct.c
 create mode 100644 arch/arm/mach-tegra/tegra30/bct.h

diff --git a/arch/arm/mach-tegra/Kconfig b/arch/arm/mach-tegra/Kconfig
index 5b0cd92d9e..8490d42a7b 100644
--- a/arch/arm/mach-tegra/Kconfig
+++ b/arch/arm/mach-tegra/Kconfig
@@ -229,4 +229,13 @@ config CMD_ENTERRCM
 	  for mechanical button actuators, or hooking up relays/... to the
 	  button.
 
+config CMD_EBTUPDATE
+	bool "Enable 'ebtupdate' command"
+	depends on TEGRA30
+	select TEGRA_CRYPTO
+	help
+	  Updating u-boot from within u-boot in rather complex or even
+	  impossible on production devices. To make it easier procedure of
+	  re-cryption was created. If your device was re-crypted choose Y.
+
 endif
diff --git a/arch/arm/mach-tegra/tegra30/Makefile b/arch/arm/mach-tegra/tegra30/Makefile
index 9f170576e7..28dd486d8d 100644
--- a/arch/arm/mach-tegra/tegra30/Makefile
+++ b/arch/arm/mach-tegra/tegra30/Makefile
@@ -3,5 +3,6 @@
 # Copyright (c) 2010-2012, NVIDIA CORPORATION.  All rights reserved.
 
 obj-$(CONFIG_SPL_BUILD) += cpu.o
+obj-$(CONFIG_$(SPL_)CMD_EBTUPDATE) += bct.o
 
 obj-y	+= clock.o funcmux.o pinmux.o
diff --git a/arch/arm/mach-tegra/tegra30/bct.c b/arch/arm/mach-tegra/tegra30/bct.c
new file mode 100644
index 0000000000..c56958da69
--- /dev/null
+++ b/arch/arm/mach-tegra/tegra30/bct.c
@@ -0,0 +1,79 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2022, Ramin <raminterex@yahoo.com>
+ * Copyright (c) 2022, Svyatoslav Ryhel <clamor95@gmail.com>
+ */
+
+#include <common.h>
+#include <command.h>
+#include <log.h>
+#include <asm/arch-tegra/crypto.h>
+#include "bct.h"
+#include "uboot_aes.h"
+
+/*
+ * @param  bct		boot config table start in RAM
+ * @param  ect		bootloader start in RAM
+ * @param  ebt_size	bootloader file size in bytes
+ * Return: 0, or 1 if failed
+ */
+static int bct_patch(u8 *bct, u8 *ebt, u32 ebt_size)
+{
+	struct nvboot_config_table *bct_tbl = NULL;
+	u8 ebt_hash[AES128_KEY_LENGTH] = { 0 };
+	u8 sbk[AES128_KEY_LENGTH] = { 0 };
+	u8 *bct_hash = bct;
+	int ret;
+
+	bct += BCT_HASH;
+
+	memcpy(sbk, (u8 *)(bct + BCT_LENGTH),
+	       NVBOOT_CMAC_AES_HASH_LENGTH * 4);
+
+	ret = decrypt_data_block(bct, BCT_LENGTH, sbk);
+	if (ret)
+		return 1;
+
+	ebt_size = roundup(ebt_size, EBT_ALIGNMENT);
+
+	ret = encrypt_data_block(ebt, ebt_size, sbk);
+	if (ret)
+		return 1;
+
+	ret = sign_enc_data_block(ebt, ebt_size, ebt_hash, sbk);
+	if (ret)
+		return 1;
+
+	bct_tbl = (struct nvboot_config_table *)bct;
+
+	memcpy((u8 *)&bct_tbl->bootloader[0].crypto_hash,
+	       ebt_hash, NVBOOT_CMAC_AES_HASH_LENGTH * 4);
+	bct_tbl->bootloader[0].entry_point = CONFIG_SPL_TEXT_BASE;
+	bct_tbl->bootloader[0].load_addr = CONFIG_SPL_TEXT_BASE;
+	bct_tbl->bootloader[0].length = ebt_size;
+
+	ret = encrypt_data_block(bct, BCT_LENGTH, sbk);
+	if (ret)
+		return 1;
+
+	ret = sign_enc_data_block(bct, BCT_LENGTH, bct_hash, sbk);
+	if (ret)
+		return 1;
+
+	return 0;
+}
+
+static int do_ebtupdate(struct cmd_tbl *cmdtp, int flag, int argc,
+			char *const argv[])
+{
+	u32 bct_addr = hextoul(argv[1], NULL);
+	u32 ebt_addr = hextoul(argv[2], NULL);
+	u32 ebt_size = hextoul(argv[3], NULL);
+
+	return bct_patch((u8 *)bct_addr, (u8 *)ebt_addr, ebt_size);
+}
+
+U_BOOT_CMD(ebtupdate,	4,	0,	do_ebtupdate,
+	   "update bootloader on re-crypted Tegra30 devices",
+	   ""
+);
diff --git a/arch/arm/mach-tegra/tegra30/bct.h b/arch/arm/mach-tegra/tegra30/bct.h
new file mode 100644
index 0000000000..9797384da3
--- /dev/null
+++ b/arch/arm/mach-tegra/tegra30/bct.h
@@ -0,0 +1,42 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+
+#ifndef _BCT_H_
+#define _BCT_H_
+
+/*
+ * Defines the BCT parametres for T30
+ */
+#define BCT_LENGTH		0x17E0
+#define BCT_HASH		0x10
+#define EBT_ALIGNMENT		0x10
+
+/*
+ * Defines the CMAC-AES-128 hash length in 32 bit words. (128 bits = 4 words)
+ */
+#define NVBOOT_CMAC_AES_HASH_LENGTH		4
+
+/*
+ * Defines the maximum number of bootloader descriptions in the BCT.
+ */
+#define NVBOOT_MAX_BOOTLOADERS			4
+
+struct nv_bootloader_info {
+	u32 version;
+	u32 start_blk;
+	u32 start_page;
+	u32 length;
+	u32 load_addr;
+	u32 entry_point;
+	u32 attribute;
+	u32 crypto_hash[NVBOOT_CMAC_AES_HASH_LENGTH];
+};
+
+struct nvboot_config_table {
+	u32 unused0[4];
+	u32 boot_data_version;
+	u32 unused1[972];
+	struct nv_bootloader_info bootloader[NVBOOT_MAX_BOOTLOADERS];
+	u32 unused2[508];
+};
+
+#endif /* _BCT_H_ */

From patchwork Tue Feb 14 17:35:38 2023
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: Svyatoslav Ryhel <clamor95@gmail.com>
X-Patchwork-Id: 1742554
X-Patchwork-Delegate: twarren@nvidia.com
Return-Path: <u-boot-bounces@lists.denx.de>
X-Original-To: incoming@patchwork.ozlabs.org
Delivered-To: patchwork-incoming@legolas.ozlabs.org
Authentication-Results: legolas.ozlabs.org;
 spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de
 (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de;
 envelope-from=u-boot-bounces@lists.denx.de; receiver=<UNKNOWN>)
Authentication-Results: legolas.ozlabs.org;
	dkim=pass (2048-bit key;
 unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256
 header.s=20210112 header.b=N2Tv7deE;
	dkim-atps=neutral
Received: from phobos.denx.de (phobos.denx.de
 [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (P-384))
	(No client certificate requested)
	by legolas.ozlabs.org (Postfix) with ESMTPS id 4PGT3v2615z23r4
	for <incoming@patchwork.ozlabs.org>; Wed, 15 Feb 2023 04:39:39 +1100 (AEDT)
Received: from h2850616.stratoserver.net (localhost [IPv6:::1])
	by phobos.denx.de (Postfix) with ESMTP id CCBA285A1E;
	Tue, 14 Feb 2023 18:37:06 +0100 (CET)
Authentication-Results: phobos.denx.de;
 dmarc=pass (p=none dis=none) header.from=gmail.com
Authentication-Results: phobos.denx.de;
 spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de
Authentication-Results: phobos.denx.de;
	dkim=pass (2048-bit key;
 unprotected) header.d=gmail.com header.i=@gmail.com header.b="N2Tv7deE";
	dkim-atps=neutral
Received: by phobos.denx.de (Postfix, from userid 109)
 id 58A82859EE; Tue, 14 Feb 2023 18:36:35 +0100 (CET)
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de
X-Spam-Level: 
X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,
 DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT,
 FREEMAIL_FROM,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no
 version=3.4.2
Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com
 [IPv6:2a00:1450:4864:20::32c])
 (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits))
 (No client certificate requested)
 by phobos.denx.de (Postfix) with ESMTPS id 5A6F28597A
 for <u-boot@lists.denx.de>; Tue, 14 Feb 2023 18:36:31 +0100 (CET)
Authentication-Results: phobos.denx.de;
 dmarc=pass (p=none dis=none) header.from=gmail.com
Authentication-Results: phobos.denx.de;
 spf=pass smtp.mailfrom=clamor95@gmail.com
Received: by mail-wm1-x32c.google.com with SMTP id z13so11508898wmp.2
 for <u-boot@lists.denx.de>; Tue, 14 Feb 2023 09:36:31 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:from:to:cc:subject:date
 :message-id:reply-to;
 bh=JCSxBwWWYyTCqlrBx0Bs/Ndl1I1ow/54oW7mjy3lEjk=;
 b=N2Tv7deEjEG+9jdeB4/VieBP1musfLyOiy5sNVGuKuyydD3+4ii2XU+Pkld7DxvNnK
 TaoQEVKO8+VRObpoQhkKOXFKtmNh8e0E/W7Hlpyt8UY96SD1HGDUNn7CqvJV7RAl5Jux
 Ltb6tBs9FIm6TIbc6ctlmdPfYZyctj3N2FZs48Z2HeJgz+2ipMmx9JEHXFb5Yavd4PS1
 RImQrPMsNQuCawPa4yoZ8HI4ROjz2VrD46pLRvXBwSR3ZYZIQvHwPXgLF7tn2dCzW4E/
 DakJCsUqeSzvchEWuv/HN7ef1t2uYWptWw8mbt6LS4FHfXdB+AedYgbx4pobV0nJ9iuo
 I2hA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=JCSxBwWWYyTCqlrBx0Bs/Ndl1I1ow/54oW7mjy3lEjk=;
 b=rX4zEG/loCyza8Qu0aR1VnbQ8HGzfHfGpMJdXpo0WfzFlaP3732ogrjOD+9dGh3iA8
 GWKSknqnThpV9zMg3oC/tvMPb1F65KfZtyQnz1p49Zj9a5KhjQZSEtcV6i+dwtV2jpex
 mS73bICwg44fbhLL/O5d0tEVL4eemYijXjbMOYRPOrvyrRF5YLrRMQWooU23xV0kMAXI
 f2zqJZhg1GNI2meqx9xQ55jDCCE2y2M9WGewGU4AtyyAmUEyFR4lmxOsbbaIL9g9XCqW
 K0pxXTUfaYvIlHLS9C+yMejAOvJD/d9IH6oXEwgPSzA/yaZOtLwIMExUERwr6Nz6n03Y
 h4GQ==
X-Gm-Message-State: AO0yUKW+o78TeAFTMvW5r2a3URlqRYfb3u0bCbrpOyWuec6ix1t202Nv
 ayGbK9N6fNUY6Ttef+0K9WE=
X-Google-Smtp-Source: 
 AK7set+RN04o0ZryCehnc4AcybyRUDXUk+8Y89MKJ3M7Zilzho/e254hx5ecdXlsDtV4Bfi3Cxc5AQ==
X-Received: by 2002:a05:600c:1c17:b0:3dc:de85:5007 with SMTP id
 j23-20020a05600c1c1700b003dcde855007mr2747337wms.21.1676396177398;
 Tue, 14 Feb 2023 09:36:17 -0800 (PST)
Received: from xeon.. ([188.163.112.76]) by smtp.gmail.com with ESMTPSA id
 m23-20020a7bca57000000b003de8a1b06c0sm20787829wml.7.2023.02.14.09.36.16
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 14 Feb 2023 09:36:17 -0800 (PST)
From: Svyatoslav Ryhel <clamor95@gmail.com>
To: Tom Warren <twarren@nvidia.com>,
 Marcel Ziswiler <marcel.ziswiler@toradex.com>,
 Allen Martin <amartin@nvidia.com>, Jagan Teki <jagan@amarulasolutions.com>,
 Lukasz Majewski <lukma@denx.de>, Marek Vasut <marex@denx.de>,
 Svyatoslav Ryhel <clamor95@gmail.com>,
 Ramin Khonsari <raminterex@yahoo.com>,
 Thierry Reding <thierry.reding@gmail.com>,
 Maxim Schwalm <maxim.schwalm@gmail.com>,
 Dmitry Osipenko <digetx@gmail.com>, Simon Glass <sjg@chromium.org>
Cc: u-boot@lists.denx.de
Subject: [PATCH v4 16/16] ARM: tegra20: implement BCT patching
Date: Tue, 14 Feb 2023 19:35:38 +0200
Message-Id: <20230214173538.6242-17-clamor95@gmail.com>
X-Mailer: git-send-email 2.37.2
In-Reply-To: <20230214173538.6242-1-clamor95@gmail.com>
References: <20230214173538.6242-1-clamor95@gmail.com>
MIME-Version: 1.0
X-BeenThere: u-boot@lists.denx.de
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: U-Boot discussion <u-boot.lists.denx.de>
List-Unsubscribe: <https://lists.denx.de/options/u-boot>,
 <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>
List-Archive: <https://lists.denx.de/pipermail/u-boot/>
List-Post: <mailto:u-boot@lists.denx.de>
List-Help: <mailto:u-boot-request@lists.denx.de?subject=help>
List-Subscribe: <https://lists.denx.de/listinfo/u-boot>,
 <mailto:u-boot-request@lists.denx.de?subject=subscribe>
Errors-To: u-boot-bounces@lists.denx.de
Sender: "U-Boot" <u-boot-bounces@lists.denx.de>
X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de
X-Virus-Status: Clean

This function allows updating bootloader from u-boot
on production devices without need in host PC.

Be aware! It works only with re-crypt BCT.

Tested-by: Robert Eckelmann <longnoserob@gmail.com> # ASUS TF101 T20
Signed-off-by: Ramin Khonsari <raminterex@yahoo.com>
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
---
 arch/arm/mach-tegra/Kconfig          |  2 +-
 arch/arm/mach-tegra/tegra20/Makefile |  5 +-
 arch/arm/mach-tegra/tegra20/bct.c    | 79 ++++++++++++++++++++++++++++
 arch/arm/mach-tegra/tegra20/bct.h    | 42 +++++++++++++++
 doc/usage/cmd/ebtupdate.rst          | 70 ++++++++++++++++++++++++
 5 files changed, 194 insertions(+), 4 deletions(-)
 create mode 100644 arch/arm/mach-tegra/tegra20/bct.c
 create mode 100644 arch/arm/mach-tegra/tegra20/bct.h
 create mode 100644 doc/usage/cmd/ebtupdate.rst

diff --git a/arch/arm/mach-tegra/Kconfig b/arch/arm/mach-tegra/Kconfig
index 8490d42a7b..464bd0798f 100644
--- a/arch/arm/mach-tegra/Kconfig
+++ b/arch/arm/mach-tegra/Kconfig
@@ -231,7 +231,7 @@ config CMD_ENTERRCM
 
 config CMD_EBTUPDATE
 	bool "Enable 'ebtupdate' command"
-	depends on TEGRA30
+	depends on TEGRA20 || TEGRA30
 	select TEGRA_CRYPTO
 	help
 	  Updating u-boot from within u-boot in rather complex or even
diff --git a/arch/arm/mach-tegra/tegra20/Makefile b/arch/arm/mach-tegra/tegra20/Makefile
index 67454ff5f4..991cabeec5 100644
--- a/arch/arm/mach-tegra/tegra20/Makefile
+++ b/arch/arm/mach-tegra/tegra20/Makefile
@@ -2,9 +2,8 @@
 #
 # (C) Copyright 2010,2011 Nvidia Corporation.
 
-ifdef CONFIG_SPL_BUILD
-obj-y	+= cpu.o
-endif
+obj-$(CONFIG_SPL_BUILD) += cpu.o
+obj-$(CONFIG_$(SPL_)CMD_EBTUPDATE) += bct.o
 
 # The AVP is ARMv4T architecture so we must use special compiler
 # flags for any startup files it might use.
diff --git a/arch/arm/mach-tegra/tegra20/bct.c b/arch/arm/mach-tegra/tegra20/bct.c
new file mode 100644
index 0000000000..5eb48990b6
--- /dev/null
+++ b/arch/arm/mach-tegra/tegra20/bct.c
@@ -0,0 +1,79 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2022, Ramin <raminterex@yahoo.com>
+ * Copyright (c) 2022, Svyatoslav Ryhel <clamor95@gmail.com>
+ */
+
+#include <common.h>
+#include <command.h>
+#include <log.h>
+#include <asm/arch-tegra/crypto.h>
+#include "bct.h"
+#include "uboot_aes.h"
+
+/*
+ * @param  bct		boot config table start in RAM
+ * @param  ect		bootloader start in RAM
+ * @param  ebt_size	bootloader file size in bytes
+ * Return: 0, or 1 if failed
+ */
+static int bct_patch(u8 *bct, u8 *ebt, u32 ebt_size)
+{
+	struct nvboot_config_table *bct_tbl = NULL;
+	u8 ebt_hash[AES128_KEY_LENGTH] = { 0 };
+	u8 sbk[AES128_KEY_LENGTH] = { 0 };
+	u8 *bct_hash = bct;
+	int ret;
+
+	bct += BCT_HASH;
+
+	memcpy(sbk, (u8 *)(bct + BCT_LENGTH),
+	       NVBOOT_CMAC_AES_HASH_LENGTH * 4);
+
+	ret = decrypt_data_block(bct, BCT_LENGTH, sbk);
+	if (ret)
+		return 1;
+
+	ebt_size = roundup(ebt_size, EBT_ALIGNMENT);
+
+	ret = encrypt_data_block(ebt, ebt_size, sbk);
+	if (ret)
+		return 1;
+
+	ret = sign_enc_data_block(ebt, ebt_size, ebt_hash, sbk);
+	if (ret)
+		return 1;
+
+	bct_tbl = (struct nvboot_config_table *)bct;
+
+	memcpy((u8 *)&bct_tbl->bootloader[0].crypto_hash,
+	       ebt_hash, NVBOOT_CMAC_AES_HASH_LENGTH * 4);
+	bct_tbl->bootloader[0].entry_point = CONFIG_SPL_TEXT_BASE;
+	bct_tbl->bootloader[0].load_addr = CONFIG_SPL_TEXT_BASE;
+	bct_tbl->bootloader[0].length = ebt_size;
+
+	ret = encrypt_data_block(bct, BCT_LENGTH, sbk);
+	if (ret)
+		return 1;
+
+	ret = sign_enc_data_block(bct, BCT_LENGTH, bct_hash, sbk);
+	if (ret)
+		return 1;
+
+	return 0;
+}
+
+static int do_ebtupdate(struct cmd_tbl *cmdtp, int flag, int argc,
+			char *const argv[])
+{
+	u32 bct_addr = hextoul(argv[1], NULL);
+	u32 ebt_addr = hextoul(argv[2], NULL);
+	u32 ebt_size = hextoul(argv[3], NULL);
+
+	return bct_patch((u8 *)bct_addr, (u8 *)ebt_addr, ebt_size);
+}
+
+U_BOOT_CMD(ebtupdate,	4,	0,	do_ebtupdate,
+	   "update bootloader on re-crypted Tegra20 devices",
+	   ""
+);
diff --git a/arch/arm/mach-tegra/tegra20/bct.h b/arch/arm/mach-tegra/tegra20/bct.h
new file mode 100644
index 0000000000..4b78aef7cf
--- /dev/null
+++ b/arch/arm/mach-tegra/tegra20/bct.h
@@ -0,0 +1,42 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+
+#ifndef _BCT_H_
+#define _BCT_H_
+
+/*
+ * Defines the BCT parametres for T20
+ */
+#define BCT_LENGTH		0xFE0
+#define BCT_HASH		0x10
+#define EBT_ALIGNMENT		0x10
+
+/*
+ * Defines the CMAC-AES-128 hash length in 32 bit words. (128 bits = 4 words)
+ */
+#define NVBOOT_CMAC_AES_HASH_LENGTH		4
+
+/*
+ * Defines the maximum number of bootloader descriptions in the BCT.
+ */
+#define NVBOOT_MAX_BOOTLOADERS			4
+
+struct nv_bootloader_info {
+	u32 version;
+	u32 start_blk;
+	u32 start_page;
+	u32 length;
+	u32 load_addr;
+	u32 entry_point;
+	u32 attribute;
+	u32 crypto_hash[NVBOOT_CMAC_AES_HASH_LENGTH];
+};
+
+struct nvboot_config_table {
+	u32 unused0[4];
+	u32 boot_data_version;
+	u32 unused1[668];
+	struct nv_bootloader_info bootloader[NVBOOT_MAX_BOOTLOADERS];
+	u32 unused2[508];
+};
+
+#endif /* _BCT_H_ */
diff --git a/doc/usage/cmd/ebtupdate.rst b/doc/usage/cmd/ebtupdate.rst
new file mode 100644
index 0000000000..d0905612c0
--- /dev/null
+++ b/doc/usage/cmd/ebtupdate.rst
@@ -0,0 +1,70 @@
+.. SPDX-License-Identifier: GPL-2.0+:
+
+ebtupdate command
+=============
+
+Synopsis
+--------
+
+::
+
+    ebtupdate [<bct> [<ebt>] [<size>]]
+
+Description
+-----------
+
+The "ebtupdate" command is used to self-update bootloader on Tegra 2 and Tegra 3
+production devices which were processed using re-cryption.
+
+The "ebtupdate" performs encryption of new bootloader and decryption, patching
+and re-encryption of BCT "in situ". After BCT and bootloader can be written in
+their respective places.
+
+bct
+    address of BCT block pre-loaded into RAM.
+
+ebt
+    address of the bootloader pre-loaded into RAM.
+
+size
+    size of the pre-loaded bootloader.
+
+Example
+-------
+
+This is the boot log of a LG Optimus Vu:
+
+::
+
+    => mmc dev 0 1
+    switch to partitions #1, OK
+    mmc0(part 1) is current device
+    => mmc read $kernel_addr_r 0 $boot_block_size
+    MMC read: dev # 0, block # 0, count 4096 ... 4096 blocks read: OK
+    => load mmc 0:1 $ramdisk_addr_r $bootloader_file
+    684783 bytes read in 44 ms (14.8 MiB/s)
+    => size mmc 0:1 $bootloader_file
+    => ebtupdate $kernel_addr_r $ramdisk_addr_r $filesize
+    => mmc dev 0 1
+    switch to partitions #1, OK
+    mmc0(part 1) is current device
+    => mmc write $kernel_addr_r 0 $boot_block_size
+    MMC write: dev # 0, block # 0, count 4096 ... 4096 blocks written: OK
+    => mmc dev 0 2
+    switch to partitions #2, OK
+    mmc0(part 2) is current device
+    => mmc write $ramdisk_addr_r 0 $boot_block_size
+    MMC write: dev # 0, block # 0, count 4096 ... 4096 blocks written: OK
+
+Configuration
+-------------
+
+The ebtupdate command is only available if CONFIG_CMD_EBTUPDATE=y and
+only on Tegra 2 and Tegra 3 configurations.
+
+Return value
+------------
+
+The return value $? is set to 0 (true) if everything went successfully. If an
+error occurs, the return value $? is set to 1 (false).
+

^ permalink raw reply related	[flat|nested] 28+ messages in thread

* Re: [PATCH v4 00/16] General Tegra improvements
  2023-02-17 15:57     ` Tom Warren
@ 2023-02-17 16:07       ` Svyatoslav Ryhel
  2023-02-17 16:21         ` Tom Warren
  0 siblings, 1 reply; 28+ messages in thread
From: Svyatoslav Ryhel @ 2023-02-17 16:07 UTC (permalink / raw)
  To: Tom Warren; +Cc: u-boot

I was able to git am it on top of u-boot/master without any errors

clamor@xeon:/media/clamor/work/u-boot$ git am bundle-23303-Svyatoslav-16-v4.mbox
Застосування: tegra30: clock: add EXTPERIPH
Застосування: ARM: t20/t30: swap host1x and disp1 clock parents
Застосування: ARM: tegra: clock: add clk_id_to_pll_id helper
Застосування: ARM: tegra: clock: add clock_decode_pair helper
Застосування: ARM: tegra30: add PLLD to pll setup
Застосування: ARM: tegra: Fix Tegra PWM parent clock
Застосування: spi: tegra20_slink: accept any word length
Застосування: ARM: tegra: provide default USB gadget setup
Застосування: ARM: tegra: add late init support
Застосування: ARM: tegra: create common pre-dm i2c write
Застосування: board: tegra124: switch to updated pre-dm i2c write
Застосування: board: tegra30: switch to updated pre-dm i2c write
Застосування: ARM: tegra: expose crypto module for all Tegra SoCs
Застосування: ARM: tegra: crypto: extend crypto functional
Застосування: ARM: tegra30: implement BCT patching
Застосування: ARM: tegra20: implement BCT patching
.git/rebase-apply/patch:249: new blank line at EOF.
+
warning: 1 рядок додав помилки в пробільних символах.
clamor@xeon:/media/clamor/work/u-boot$

пт, 17 лют. 2023 р. о 17:57 Tom Warren <TWarren@nvidia.com> пише:
>
> I've got a bundle with your 16 patches, created using PatchWork/U-Boot, and the patches are ordered correctly within that bundle. Attached here - see if it works for you.
>
> Tom
>
> -----Original Message-----
> From: Svyatoslav Ryhel <clamor95@gmail.com>
> Sent: Friday, February 17, 2023 1:39 AM
> To: Tom Warren <TWarren@nvidia.com>
> Cc: u-boot@lists.denx.de
> Subject: Re: [PATCH v4 00/16] General Tegra improvements
>
> External email: Use caution opening links or attachments
>
>
> You have NOT applied patch 13 ARM: tegra: expose crypto module for all Tegra SoCs or applied it after patch 14 which brakes order. PTAL.
>
> вт, 14 лют. 2023 р. о 23:45 Tom Warren <TWarren@nvidia.com> пише:
> >
> > <reducing audience>
> >
> > Svyatoslav,
> >
> > Taking TOT u-boot-tegra/master, and fast-forwarding to TOT u-boot/master, I then try to apply your 16 patch series and get the following failures (using patch). Note that I retargeted the crypto.c patch by hand to point to tegra20/crypto.c, which I believe one of your patches moves to arch/arm/tegra. PTAL.
> >
> > tom@tom-ThinkPad-T580:~/denx/uboot-tegra$ patch -p1 -i
> > ~/Downloads/bundle-23303-Svyatoslav-16-v4.mbox  --dry-run checking
> > file arch/arm/include/asm/arch-tegra30/clock-tables.h
> > checking file arch/arm/mach-tegra/tegra30/clock.c
> > checking file arch/arm/mach-tegra/tegra20/clock.c
> > checking file arch/arm/mach-tegra/tegra30/clock.c
> > checking file arch/arm/include/asm/arch-tegra/clock.h
> > checking file arch/arm/mach-tegra/tegra114/clock.c
> > checking file arch/arm/mach-tegra/tegra124/clock.c
> > checking file arch/arm/mach-tegra/tegra20/clock.c
> > checking file arch/arm/mach-tegra/tegra210/clock.c
> > checking file arch/arm/mach-tegra/tegra30/clock.c
> > checking file arch/arm/include/asm/arch-tegra/clock.h
> > checking file arch/arm/mach-tegra/clock.c checking file
> > arch/arm/mach-tegra/tegra30/clock.c
> > Hunk #1 succeeded at 632 (offset -37 lines).
> > checking file arch/arm/dts/tegra114.dtsi checking file
> > arch/arm/dts/tegra124.dtsi checking file
> > arch/arm/mach-tegra/tegra114/clock.c
> > Hunk #1 succeeded at 745 (offset -37 lines).
> > checking file arch/arm/mach-tegra/tegra124/clock.c
> > Hunk #1 succeeded at 1170 (offset -38 lines).
> > checking file arch/arm/mach-tegra/tegra20/clock.c
> > Hunk #1 succeeded at 767 (offset -37 lines).
> > checking file arch/arm/mach-tegra/tegra210/clock.c
> > Hunk #1 succeeded at 1241 (offset -37 lines).
> > checking file arch/arm/mach-tegra/tegra30/clock.c
> > Hunk #1 succeeded at 806 (offset -78 lines).
> > checking file drivers/pwm/tegra_pwm.c
> > checking file drivers/spi/tegra20_slink.c checking file
> > configs/beaver_defconfig checking file configs/cei-tk1-som_defconfig
> > checking file configs/dalmore_defconfig checking file
> > configs/jetson-tk1_defconfig checking file configs/nyan-big_defconfig
> > checking file configs/p2371-0000_defconfig checking file
> > configs/p2371-2180_defconfig checking file configs/p2571_defconfig
> > checking file configs/p3450-0000_defconfig checking file
> > configs/venice2_defconfig checking file drivers/usb/gadget/Kconfig
> > checking file arch/arm/include/asm/arch-tegra/sys_proto.h
> > checking file arch/arm/mach-tegra/board2.c checking file
> > arch/arm/include/asm/arch-tegra/tegra_i2c.h
> > checking file arch/arm/mach-tegra/cpu.h checking file
> > arch/arm/mach-tegra/tegra124/cpu.c
> > checking file arch/arm/mach-tegra/tegra30/cpu.c checking file
> > board/nvidia/venice2/as3722_init.c
> > checking file board/nvidia/venice2/as3722_init.h
> > checking file board/toradex/apalis-tk1/as3722_init.c
> > checking file board/toradex/apalis-tk1/as3722_init.h
> > checking file arch/arm/mach-tegra/tegra30/Kconfig
> > checking file arch/arm/mach-tegra/tegra30/cpu.c Hunk #1 FAILED at 15.
> > Hunk #2 FAILED at 41.
> > 2 out of 2 hunks FAILED
> > checking file board/avionic-design/tec-ng/Makefile
> > checking file board/avionic-design/tec-ng/tec-ng-spl.c
> > checking file board/nvidia/beaver/Makefile checking file
> > board/nvidia/beaver/beaver-spl.c checking file
> > board/nvidia/cardhu/Makefile checking file
> > board/nvidia/cardhu/cardhu-spl.c checking file
> > board/toradex/apalis_t30/Makefile checking file
> > board/toradex/apalis_t30/apalis_t30-spl.c
> > checking file board/toradex/colibri_t30/Makefile
> > checking file board/toradex/colibri_t30/colibri_t30-spl.c
> > checking file arch/arm/mach-tegra/Kconfig checking file
> > arch/arm/mach-tegra/Makefile checking file
> > arch/arm/mach-tegra/crypto.c (renamed from
> > arch/arm/mach-tegra/tegra20/crypto.c)
> > checking file arch/arm/mach-tegra/crypto.h (renamed from
> > arch/arm/mach-tegra/tegra20/crypto.h)
> > checking file arch/arm/mach-tegra/tegra20/Kconfig
> > checking file arch/arm/mach-tegra/tegra20/Makefile
> > checking file arch/arm/include/asm/arch-tegra/crypto.h
> > can't find file to patch at input line 3811 Perhaps you used the wrong
> > -p or --strip option?
> > The text leading up to this was:
> > --------------------------
> > |diff --git a/arch/arm/mach-tegra/crypto.c
> > |b/arch/arm/mach-tegra/crypto.c index 1efaa5c3ec..893da35e0b 100644
> > |--- a/arch/arm/mach-tegra/crypto.c
> > |+++ b/arch/arm/mach-tegra/crypto.c
> > --------------------------
> > File to patch: arch/arm/mach-tegra/tegra20/crypto.c
> > checking file arch/arm/mach-tegra/tegra20/crypto.c
> > The next patch would delete the file arch/arm/mach-tegra/crypto.h,
> > which does not exist!  Assume -R? [n] Apply anyway? [n] Skipping
> > patch.
> > 1 out of 1 hunk ignored
> > checking file arch/arm/mach-tegra/Kconfig Hunk #1 succeeded at 224
> > (offset -5 lines).
> > checking file arch/arm/mach-tegra/tegra30/Makefile
> > checking file arch/arm/mach-tegra/tegra30/bct.c checking file
> > arch/arm/mach-tegra/tegra30/bct.h checking file
> > arch/arm/mach-tegra/Kconfig Hunk #1 FAILED at 231.
> > 1 out of 1 hunk FAILED
> > checking file arch/arm/mach-tegra/tegra20/Makefile
> > checking file arch/arm/mach-tegra/tegra20/bct.c checking file
> > arch/arm/mach-tegra/tegra20/bct.h checking file
> > doc/usage/cmd/ebtupdate.rst tom@tom-ThinkPad-T580:~/denx/uboot-tegra$
> >
> > -----Original Message-----
> > From: Svyatoslav Ryhel <clamor95@gmail.com>
> > Sent: Tuesday, February 14, 2023 10:35 AM
> > To: Tom Warren <twarren@nvidia.com>; Marcel Ziswiler
> > <marcel.ziswiler@toradex.com>; Allen Martin <amartin@nvidia.com>;
> > Jagan Teki <jagan@amarulasolutions.com>; Lukasz Majewski
> > <lukma@denx.de>; Marek Vasut <marex@denx.de>; Svyatoslav Ryhel
> > <clamor95@gmail.com>; Ramin Khonsari <raminterex@yahoo.com>; Thierry
> > Reding <thierry.reding@gmail.com>; Maxim Schwalm
> > <maxim.schwalm@gmail.com>; Dmitry Osipenko <digetx@gmail.com>; Simon
> > Glass <sjg@chromium.org>
> > Cc: u-boot@lists.denx.de
> > Subject: [PATCH v4 00/16] General Tegra improvements
> >
> > External email: Use caution opening links or attachments
> >
> >
> > List of changes in patch set:
> >  - add missing EXTPERIPH clocks for t30
> >  - swap host1x and disp1 clock parents (as they should be)
> >  - add clk_id_to_pll_id and clock_decode_pair helpers to use
> >    dts deeper (in tegra clocks often go in pair child - parent)
> >  - include PLLD setup in T30 (DISP1 may use it as parent on
> >    some devices)
> >  - fix Tegra PWM parent clock inline with linux
> >  - Tegra SLINK: patch to accept any word length (unlike 8bit
> >    aligned which was before)
> >  - provide default USB gadget setup for existing Nvidia boards
> >  - add late init function to be able to configure pre-boot stage
> >    (like uncovering serial number or setting mac address)
> >  - create common pre-dm i2c write for PMIC (used on T30 and T124
> >    to configure basic PMIC voltages required to boot like cpu and
> >    core voltages)
> >  - expose crypto module for all Tegra SoCs and implement BCT patching
> >    (ability to update bootloader from u-boot on production devices
> >    without need in host PC)
> >
> > ---
> > Changelog from v3
> >  - added tested-by
> >
> > Changelog from v2
> >  - fixed T114 TEGRA114_CLK_PLL_E_OUT0
> >  - adjusted pre-dm i2c write commit description
> >  - added description file for ebtupdate command
> >  - minor improvements of bct.c comments
> >
> > Changelog from v1
> >  - rebased to latest u-boot master
> >  - PLLD setup for T30 moved specifically into T30 area
> > ---
> >
> > Maxim Schwalm (1):
> >   ARM: tegra: provide default USB gadget setup
> >
> > Ramin Khonsari (1):
> >   ARM: tegra30: implement BCT patching
> >
> > Svyatoslav Ryhel (14):
> >   tegra30: clock: add EXTPERIPH
> >   ARM: t20/t30: swap host1x and disp1 clock parents
> >   ARM: tegra: clock: add clk_id_to_pll_id helper
> >   ARM: tegra: clock: add clock_decode_pair helper
> >   ARM: tegra30: add PLLD to pll setup
> >   ARM: tegra: Fix Tegra PWM parent clock
> >   spi: tegra20_slink: accept any word length
> >   ARM: tegra: add late init support
> >   ARM: tegra: create common pre-dm i2c write
> >   board: tegra124: switch to updated pre-dm i2c write
> >   board: tegra30: switch to updated pre-dm i2c write
> >   ARM: tegra: expose crypto module for all Tegra SoCs
> >   ARM: tegra: crypto: extend crypto functional
> >   ARM: tegra20: implement BCT patching
> >
> >  arch/arm/dts/tegra114.dtsi                    |  2 +-
> >  arch/arm/dts/tegra124.dtsi                    |  2 +-
> >  arch/arm/include/asm/arch-tegra/clock.h       | 21 +++++
> >  arch/arm/include/asm/arch-tegra/crypto.h      | 47 ++++++++++
> >  arch/arm/include/asm/arch-tegra/sys_proto.h   |  6 ++
> >  arch/arm/include/asm/arch-tegra/tegra_i2c.h   | 17 ++++
> >  .../include/asm/arch-tegra30/clock-tables.h   |  6 +-
> >  arch/arm/mach-tegra/Kconfig                   | 14 +++
> >  arch/arm/mach-tegra/Makefile                  |  1 +
> >  arch/arm/mach-tegra/board2.c                  |  2 +
> >  arch/arm/mach-tegra/clock.c                   | 23 +++++
> >  arch/arm/mach-tegra/cpu.h                     |  1 -
> >  arch/arm/mach-tegra/{tegra20 => }/crypto.c    | 63 +++++++++----
> >  arch/arm/mach-tegra/tegra114/clock.c          | 39 +++++++-
> >  arch/arm/mach-tegra/tegra124/clock.c          | 40 ++++++++-
> >  arch/arm/mach-tegra/tegra124/cpu.c            |  4 +
> >  arch/arm/mach-tegra/tegra20/Kconfig           |  1 +
> >  arch/arm/mach-tegra/tegra20/Makefile          |  7 +-
> >  arch/arm/mach-tegra/tegra20/bct.c             | 79 ++++++++++++++++
> >  arch/arm/mach-tegra/tegra20/bct.h             | 42 +++++++++
> >  arch/arm/mach-tegra/tegra20/clock.c           | 43 ++++++++-
> >  arch/arm/mach-tegra/tegra20/crypto.h          | 19 ----
> >  arch/arm/mach-tegra/tegra210/clock.c          | 39 +++++++-
> >  arch/arm/mach-tegra/tegra30/Kconfig           |  8 --
> >  arch/arm/mach-tegra/tegra30/Makefile          |  1 +
> >  arch/arm/mach-tegra/tegra30/bct.c             | 79 ++++++++++++++++
> >  arch/arm/mach-tegra/tegra30/bct.h             | 42 +++++++++
> >  arch/arm/mach-tegra/tegra30/clock.c           | 90 +++++++++++++++++--
> >  arch/arm/mach-tegra/tegra30/cpu.c             | 55 +-----------
> >  board/avionic-design/tec-ng/Makefile          |  4 +-
> >  board/avionic-design/tec-ng/tec-ng-spl.c      | 34 +++++++
> >  board/nvidia/beaver/Makefile                  |  2 +
> >  board/nvidia/beaver/beaver-spl.c              | 43 +++++++++
> >  board/nvidia/cardhu/Makefile                  |  4 +-
> >  board/nvidia/cardhu/cardhu-spl.c              | 43 +++++++++
> >  board/nvidia/venice2/as3722_init.c            | 65 +++++++++-----
> >  board/nvidia/venice2/as3722_init.h            | 43 ---------
> >  board/toradex/apalis-tk1/as3722_init.c        | 85 ++++++++++--------
> >  board/toradex/apalis-tk1/as3722_init.h        | 40 ---------
> >  board/toradex/apalis_t30/Makefile             |  2 +
> >  board/toradex/apalis_t30/apalis_t30-spl.c     | 34 +++++++
> >  board/toradex/colibri_t30/Makefile            |  2 +
> >  board/toradex/colibri_t30/colibri_t30-spl.c   | 34 +++++++
> >  configs/beaver_defconfig                      |  3 -
> >  configs/cei-tk1-som_defconfig                 |  3 -
> >  configs/dalmore_defconfig                     |  3 -
> >  configs/jetson-tk1_defconfig                  |  3 -
> >  configs/nyan-big_defconfig                    |  3 -
> >  configs/p2371-0000_defconfig                  |  3 -
> >  configs/p2371-2180_defconfig                  |  3 -
> >  configs/p2571_defconfig                       |  3 -
> >  configs/p3450-0000_defconfig                  |  3 -
> >  configs/venice2_defconfig                     |  3 -
> >  doc/usage/cmd/ebtupdate.rst                   | 70 +++++++++++++++
> >  drivers/pwm/tegra_pwm.c                       | 10 ++-
> >  drivers/spi/tegra20_slink.c                   | 19 ++--
> >  drivers/usb/gadget/Kconfig                    |  3 +
> >  57 files changed, 1051 insertions(+), 309 deletions(-)  create mode
> > 100644 arch/arm/include/asm/arch-tegra/crypto.h
> >  rename arch/arm/mach-tegra/{tegra20 => }/crypto.c (68%)  create mode
> > 100644 arch/arm/mach-tegra/tegra20/bct.c  create mode 100644
> > arch/arm/mach-tegra/tegra20/bct.h  delete mode 100644
> > arch/arm/mach-tegra/tegra20/crypto.h
> >  create mode 100644 arch/arm/mach-tegra/tegra30/bct.c  create mode
> > 100644 arch/arm/mach-tegra/tegra30/bct.h  create mode 100644
> > board/avionic-design/tec-ng/tec-ng-spl.c
> >  create mode 100644 board/nvidia/beaver/beaver-spl.c  create mode
> > 100644 board/nvidia/cardhu/cardhu-spl.c  delete mode 100644
> > board/nvidia/venice2/as3722_init.h
> >  delete mode 100644 board/toradex/apalis-tk1/as3722_init.h
> >  create mode 100644 board/toradex/apalis_t30/apalis_t30-spl.c
> >  create mode 100644 board/toradex/colibri_t30/colibri_t30-spl.c
> >  create mode 100644 doc/usage/cmd/ebtupdate.rst
> >
> > --
> > 2.37.2
> >

^ permalink raw reply	[flat|nested] 28+ messages in thread

* RE: [PATCH v4 00/16] General Tegra improvements
  2023-02-17 16:07       ` Svyatoslav Ryhel
@ 2023-02-17 16:21         ` Tom Warren
  2023-02-17 16:27           ` Tom Warren
  0 siblings, 1 reply; 28+ messages in thread
From: Tom Warren @ 2023-02-17 16:21 UTC (permalink / raw)
  To: Svyatoslav Ryhel; +Cc: u-boot

OK, let me retry on u-boot-tegra/master.

-----Original Message-----
From: Svyatoslav Ryhel <clamor95@gmail.com> 
Sent: Friday, February 17, 2023 9:07 AM
To: Tom Warren <TWarren@nvidia.com>
Cc: u-boot@lists.denx.de
Subject: Re: [PATCH v4 00/16] General Tegra improvements

External email: Use caution opening links or attachments


I was able to git am it on top of u-boot/master without any errors

clamor@xeon:/media/clamor/work/u-boot$ git am bundle-23303-Svyatoslav-16-v4.mbox
Застосування: tegra30: clock: add EXTPERIPH
Застосування: ARM: t20/t30: swap host1x and disp1 clock parents
Застосування: ARM: tegra: clock: add clk_id_to_pll_id helper
Застосування: ARM: tegra: clock: add clock_decode_pair helper
Застосування: ARM: tegra30: add PLLD to pll setup
Застосування: ARM: tegra: Fix Tegra PWM parent clock
Застосування: spi: tegra20_slink: accept any word length
Застосування: ARM: tegra: provide default USB gadget setup
Застосування: ARM: tegra: add late init support
Застосування: ARM: tegra: create common pre-dm i2c write
Застосування: board: tegra124: switch to updated pre-dm i2c write
Застосування: board: tegra30: switch to updated pre-dm i2c write
Застосування: ARM: tegra: expose crypto module for all Tegra SoCs
Застосування: ARM: tegra: crypto: extend crypto functional
Застосування: ARM: tegra30: implement BCT patching
Застосування: ARM: tegra20: implement BCT patching
.git/rebase-apply/patch:249: new blank line at EOF.
+
warning: 1 рядок додав помилки в пробільних символах.
clamor@xeon:/media/clamor/work/u-boot$

пт, 17 лют. 2023 р. о 17:57 Tom Warren <TWarren@nvidia.com> пише:
>
> I've got a bundle with your 16 patches, created using PatchWork/U-Boot, and the patches are ordered correctly within that bundle. Attached here - see if it works for you.
>
> Tom
>
> -----Original Message-----
> From: Svyatoslav Ryhel <clamor95@gmail.com>
> Sent: Friday, February 17, 2023 1:39 AM
> To: Tom Warren <TWarren@nvidia.com>
> Cc: u-boot@lists.denx.de
> Subject: Re: [PATCH v4 00/16] General Tegra improvements
>
> External email: Use caution opening links or attachments
>
>
> You have NOT applied patch 13 ARM: tegra: expose crypto module for all Tegra SoCs or applied it after patch 14 which brakes order. PTAL.
>
> вт, 14 лют. 2023 р. о 23:45 Tom Warren <TWarren@nvidia.com> пише:
> >
> > <reducing audience>
> >
> > Svyatoslav,
> >
> > Taking TOT u-boot-tegra/master, and fast-forwarding to TOT u-boot/master, I then try to apply your 16 patch series and get the following failures (using patch). Note that I retargeted the crypto.c patch by hand to point to tegra20/crypto.c, which I believe one of your patches moves to arch/arm/tegra. PTAL.
> >
> > tom@tom-ThinkPad-T580:~/denx/uboot-tegra$ patch -p1 -i 
> > ~/Downloads/bundle-23303-Svyatoslav-16-v4.mbox  --dry-run checking 
> > file arch/arm/include/asm/arch-tegra30/clock-tables.h
> > checking file arch/arm/mach-tegra/tegra30/clock.c
> > checking file arch/arm/mach-tegra/tegra20/clock.c
> > checking file arch/arm/mach-tegra/tegra30/clock.c
> > checking file arch/arm/include/asm/arch-tegra/clock.h
> > checking file arch/arm/mach-tegra/tegra114/clock.c
> > checking file arch/arm/mach-tegra/tegra124/clock.c
> > checking file arch/arm/mach-tegra/tegra20/clock.c
> > checking file arch/arm/mach-tegra/tegra210/clock.c
> > checking file arch/arm/mach-tegra/tegra30/clock.c
> > checking file arch/arm/include/asm/arch-tegra/clock.h
> > checking file arch/arm/mach-tegra/clock.c checking file 
> > arch/arm/mach-tegra/tegra30/clock.c
> > Hunk #1 succeeded at 632 (offset -37 lines).
> > checking file arch/arm/dts/tegra114.dtsi checking file 
> > arch/arm/dts/tegra124.dtsi checking file 
> > arch/arm/mach-tegra/tegra114/clock.c
> > Hunk #1 succeeded at 745 (offset -37 lines).
> > checking file arch/arm/mach-tegra/tegra124/clock.c
> > Hunk #1 succeeded at 1170 (offset -38 lines).
> > checking file arch/arm/mach-tegra/tegra20/clock.c
> > Hunk #1 succeeded at 767 (offset -37 lines).
> > checking file arch/arm/mach-tegra/tegra210/clock.c
> > Hunk #1 succeeded at 1241 (offset -37 lines).
> > checking file arch/arm/mach-tegra/tegra30/clock.c
> > Hunk #1 succeeded at 806 (offset -78 lines).
> > checking file drivers/pwm/tegra_pwm.c checking file 
> > drivers/spi/tegra20_slink.c checking file configs/beaver_defconfig 
> > checking file configs/cei-tk1-som_defconfig checking file 
> > configs/dalmore_defconfig checking file configs/jetson-tk1_defconfig 
> > checking file configs/nyan-big_defconfig checking file 
> > configs/p2371-0000_defconfig checking file 
> > configs/p2371-2180_defconfig checking file configs/p2571_defconfig 
> > checking file configs/p3450-0000_defconfig checking file 
> > configs/venice2_defconfig checking file drivers/usb/gadget/Kconfig 
> > checking file arch/arm/include/asm/arch-tegra/sys_proto.h
> > checking file arch/arm/mach-tegra/board2.c checking file 
> > arch/arm/include/asm/arch-tegra/tegra_i2c.h
> > checking file arch/arm/mach-tegra/cpu.h checking file 
> > arch/arm/mach-tegra/tegra124/cpu.c
> > checking file arch/arm/mach-tegra/tegra30/cpu.c checking file 
> > board/nvidia/venice2/as3722_init.c
> > checking file board/nvidia/venice2/as3722_init.h
> > checking file board/toradex/apalis-tk1/as3722_init.c
> > checking file board/toradex/apalis-tk1/as3722_init.h
> > checking file arch/arm/mach-tegra/tegra30/Kconfig
> > checking file arch/arm/mach-tegra/tegra30/cpu.c Hunk #1 FAILED at 15.
> > Hunk #2 FAILED at 41.
> > 2 out of 2 hunks FAILED
> > checking file board/avionic-design/tec-ng/Makefile
> > checking file board/avionic-design/tec-ng/tec-ng-spl.c
> > checking file board/nvidia/beaver/Makefile checking file 
> > board/nvidia/beaver/beaver-spl.c checking file 
> > board/nvidia/cardhu/Makefile checking file 
> > board/nvidia/cardhu/cardhu-spl.c checking file 
> > board/toradex/apalis_t30/Makefile checking file 
> > board/toradex/apalis_t30/apalis_t30-spl.c
> > checking file board/toradex/colibri_t30/Makefile
> > checking file board/toradex/colibri_t30/colibri_t30-spl.c
> > checking file arch/arm/mach-tegra/Kconfig checking file 
> > arch/arm/mach-tegra/Makefile checking file 
> > arch/arm/mach-tegra/crypto.c (renamed from
> > arch/arm/mach-tegra/tegra20/crypto.c)
> > checking file arch/arm/mach-tegra/crypto.h (renamed from
> > arch/arm/mach-tegra/tegra20/crypto.h)
> > checking file arch/arm/mach-tegra/tegra20/Kconfig
> > checking file arch/arm/mach-tegra/tegra20/Makefile
> > checking file arch/arm/include/asm/arch-tegra/crypto.h
> > can't find file to patch at input line 3811 Perhaps you used the 
> > wrong -p or --strip option?
> > The text leading up to this was:
> > --------------------------
> > |diff --git a/arch/arm/mach-tegra/crypto.c 
> > |b/arch/arm/mach-tegra/crypto.c index 1efaa5c3ec..893da35e0b 100644
> > |--- a/arch/arm/mach-tegra/crypto.c
> > |+++ b/arch/arm/mach-tegra/crypto.c
> > --------------------------
> > File to patch: arch/arm/mach-tegra/tegra20/crypto.c
> > checking file arch/arm/mach-tegra/tegra20/crypto.c
> > The next patch would delete the file arch/arm/mach-tegra/crypto.h, 
> > which does not exist!  Assume -R? [n] Apply anyway? [n] Skipping 
> > patch.
> > 1 out of 1 hunk ignored
> > checking file arch/arm/mach-tegra/Kconfig Hunk #1 succeeded at 224 
> > (offset -5 lines).
> > checking file arch/arm/mach-tegra/tegra30/Makefile
> > checking file arch/arm/mach-tegra/tegra30/bct.c checking file 
> > arch/arm/mach-tegra/tegra30/bct.h checking file 
> > arch/arm/mach-tegra/Kconfig Hunk #1 FAILED at 231.
> > 1 out of 1 hunk FAILED
> > checking file arch/arm/mach-tegra/tegra20/Makefile
> > checking file arch/arm/mach-tegra/tegra20/bct.c checking file 
> > arch/arm/mach-tegra/tegra20/bct.h checking file 
> > doc/usage/cmd/ebtupdate.rst 
> > tom@tom-ThinkPad-T580:~/denx/uboot-tegra$
> >
> > -----Original Message-----
> > From: Svyatoslav Ryhel <clamor95@gmail.com>
> > Sent: Tuesday, February 14, 2023 10:35 AM
> > To: Tom Warren <twarren@nvidia.com>; Marcel Ziswiler 
> > <marcel.ziswiler@toradex.com>; Allen Martin <amartin@nvidia.com>; 
> > Jagan Teki <jagan@amarulasolutions.com>; Lukasz Majewski 
> > <lukma@denx.de>; Marek Vasut <marex@denx.de>; Svyatoslav Ryhel 
> > <clamor95@gmail.com>; Ramin Khonsari <raminterex@yahoo.com>; Thierry 
> > Reding <thierry.reding@gmail.com>; Maxim Schwalm 
> > <maxim.schwalm@gmail.com>; Dmitry Osipenko <digetx@gmail.com>; Simon 
> > Glass <sjg@chromium.org>
> > Cc: u-boot@lists.denx.de
> > Subject: [PATCH v4 00/16] General Tegra improvements
> >
> > External email: Use caution opening links or attachments
> >
> >
> > List of changes in patch set:
> >  - add missing EXTPERIPH clocks for t30
> >  - swap host1x and disp1 clock parents (as they should be)
> >  - add clk_id_to_pll_id and clock_decode_pair helpers to use
> >    dts deeper (in tegra clocks often go in pair child - parent)
> >  - include PLLD setup in T30 (DISP1 may use it as parent on
> >    some devices)
> >  - fix Tegra PWM parent clock inline with linux
> >  - Tegra SLINK: patch to accept any word length (unlike 8bit
> >    aligned which was before)
> >  - provide default USB gadget setup for existing Nvidia boards
> >  - add late init function to be able to configure pre-boot stage
> >    (like uncovering serial number or setting mac address)
> >  - create common pre-dm i2c write for PMIC (used on T30 and T124
> >    to configure basic PMIC voltages required to boot like cpu and
> >    core voltages)
> >  - expose crypto module for all Tegra SoCs and implement BCT patching
> >    (ability to update bootloader from u-boot on production devices
> >    without need in host PC)
> >
> > ---
> > Changelog from v3
> >  - added tested-by
> >
> > Changelog from v2
> >  - fixed T114 TEGRA114_CLK_PLL_E_OUT0
> >  - adjusted pre-dm i2c write commit description
> >  - added description file for ebtupdate command
> >  - minor improvements of bct.c comments
> >
> > Changelog from v1
> >  - rebased to latest u-boot master
> >  - PLLD setup for T30 moved specifically into T30 area
> > ---
> >
> > Maxim Schwalm (1):
> >   ARM: tegra: provide default USB gadget setup
> >
> > Ramin Khonsari (1):
> >   ARM: tegra30: implement BCT patching
> >
> > Svyatoslav Ryhel (14):
> >   tegra30: clock: add EXTPERIPH
> >   ARM: t20/t30: swap host1x and disp1 clock parents
> >   ARM: tegra: clock: add clk_id_to_pll_id helper
> >   ARM: tegra: clock: add clock_decode_pair helper
> >   ARM: tegra30: add PLLD to pll setup
> >   ARM: tegra: Fix Tegra PWM parent clock
> >   spi: tegra20_slink: accept any word length
> >   ARM: tegra: add late init support
> >   ARM: tegra: create common pre-dm i2c write
> >   board: tegra124: switch to updated pre-dm i2c write
> >   board: tegra30: switch to updated pre-dm i2c write
> >   ARM: tegra: expose crypto module for all Tegra SoCs
> >   ARM: tegra: crypto: extend crypto functional
> >   ARM: tegra20: implement BCT patching
> >
> >  arch/arm/dts/tegra114.dtsi                    |  2 +-
> >  arch/arm/dts/tegra124.dtsi                    |  2 +-
> >  arch/arm/include/asm/arch-tegra/clock.h       | 21 +++++
> >  arch/arm/include/asm/arch-tegra/crypto.h      | 47 ++++++++++
> >  arch/arm/include/asm/arch-tegra/sys_proto.h   |  6 ++
> >  arch/arm/include/asm/arch-tegra/tegra_i2c.h   | 17 ++++
> >  .../include/asm/arch-tegra30/clock-tables.h   |  6 +-
> >  arch/arm/mach-tegra/Kconfig                   | 14 +++
> >  arch/arm/mach-tegra/Makefile                  |  1 +
> >  arch/arm/mach-tegra/board2.c                  |  2 +
> >  arch/arm/mach-tegra/clock.c                   | 23 +++++
> >  arch/arm/mach-tegra/cpu.h                     |  1 -
> >  arch/arm/mach-tegra/{tegra20 => }/crypto.c    | 63 +++++++++----
> >  arch/arm/mach-tegra/tegra114/clock.c          | 39 +++++++-
> >  arch/arm/mach-tegra/tegra124/clock.c          | 40 ++++++++-
> >  arch/arm/mach-tegra/tegra124/cpu.c            |  4 +
> >  arch/arm/mach-tegra/tegra20/Kconfig           |  1 +
> >  arch/arm/mach-tegra/tegra20/Makefile          |  7 +-
> >  arch/arm/mach-tegra/tegra20/bct.c             | 79 ++++++++++++++++
> >  arch/arm/mach-tegra/tegra20/bct.h             | 42 +++++++++
> >  arch/arm/mach-tegra/tegra20/clock.c           | 43 ++++++++-
> >  arch/arm/mach-tegra/tegra20/crypto.h          | 19 ----
> >  arch/arm/mach-tegra/tegra210/clock.c          | 39 +++++++-
> >  arch/arm/mach-tegra/tegra30/Kconfig           |  8 --
> >  arch/arm/mach-tegra/tegra30/Makefile          |  1 +
> >  arch/arm/mach-tegra/tegra30/bct.c             | 79 ++++++++++++++++
> >  arch/arm/mach-tegra/tegra30/bct.h             | 42 +++++++++
> >  arch/arm/mach-tegra/tegra30/clock.c           | 90 +++++++++++++++++--
> >  arch/arm/mach-tegra/tegra30/cpu.c             | 55 +-----------
> >  board/avionic-design/tec-ng/Makefile          |  4 +-
> >  board/avionic-design/tec-ng/tec-ng-spl.c      | 34 +++++++
> >  board/nvidia/beaver/Makefile                  |  2 +
> >  board/nvidia/beaver/beaver-spl.c              | 43 +++++++++
> >  board/nvidia/cardhu/Makefile                  |  4 +-
> >  board/nvidia/cardhu/cardhu-spl.c              | 43 +++++++++
> >  board/nvidia/venice2/as3722_init.c            | 65 +++++++++-----
> >  board/nvidia/venice2/as3722_init.h            | 43 ---------
> >  board/toradex/apalis-tk1/as3722_init.c        | 85 ++++++++++--------
> >  board/toradex/apalis-tk1/as3722_init.h        | 40 ---------
> >  board/toradex/apalis_t30/Makefile             |  2 +
> >  board/toradex/apalis_t30/apalis_t30-spl.c     | 34 +++++++
> >  board/toradex/colibri_t30/Makefile            |  2 +
> >  board/toradex/colibri_t30/colibri_t30-spl.c   | 34 +++++++
> >  configs/beaver_defconfig                      |  3 -
> >  configs/cei-tk1-som_defconfig                 |  3 -
> >  configs/dalmore_defconfig                     |  3 -
> >  configs/jetson-tk1_defconfig                  |  3 -
> >  configs/nyan-big_defconfig                    |  3 -
> >  configs/p2371-0000_defconfig                  |  3 -
> >  configs/p2371-2180_defconfig                  |  3 -
> >  configs/p2571_defconfig                       |  3 -
> >  configs/p3450-0000_defconfig                  |  3 -
> >  configs/venice2_defconfig                     |  3 -
> >  doc/usage/cmd/ebtupdate.rst                   | 70 +++++++++++++++
> >  drivers/pwm/tegra_pwm.c                       | 10 ++-
> >  drivers/spi/tegra20_slink.c                   | 19 ++--
> >  drivers/usb/gadget/Kconfig                    |  3 +
> >  57 files changed, 1051 insertions(+), 309 deletions(-)  create mode
> > 100644 arch/arm/include/asm/arch-tegra/crypto.h
> >  rename arch/arm/mach-tegra/{tegra20 => }/crypto.c (68%)  create 
> > mode
> > 100644 arch/arm/mach-tegra/tegra20/bct.c  create mode 100644 
> > arch/arm/mach-tegra/tegra20/bct.h  delete mode 100644 
> > arch/arm/mach-tegra/tegra20/crypto.h
> >  create mode 100644 arch/arm/mach-tegra/tegra30/bct.c  create mode
> > 100644 arch/arm/mach-tegra/tegra30/bct.h  create mode 100644 
> > board/avionic-design/tec-ng/tec-ng-spl.c
> >  create mode 100644 board/nvidia/beaver/beaver-spl.c  create mode
> > 100644 board/nvidia/cardhu/cardhu-spl.c  delete mode 100644 
> > board/nvidia/venice2/as3722_init.h
> >  delete mode 100644 board/toradex/apalis-tk1/as3722_init.h
> >  create mode 100644 board/toradex/apalis_t30/apalis_t30-spl.c
> >  create mode 100644 board/toradex/colibri_t30/colibri_t30-spl.c
> >  create mode 100644 doc/usage/cmd/ebtupdate.rst
> >
> > --
> > 2.37.2
> >

^ permalink raw reply	[flat|nested] 28+ messages in thread

* RE: [PATCH v4 00/16] General Tegra improvements
  2023-02-17 16:21         ` Tom Warren
@ 2023-02-17 16:27           ` Tom Warren
  2023-02-17 16:35             ` Svyatoslav Ryhel
  2023-02-21  7:59             ` Svyatoslav Ryhel
  0 siblings, 2 replies; 28+ messages in thread
From: Tom Warren @ 2023-02-17 16:27 UTC (permalink / raw)
  To: Svyatoslav Ryhel; +Cc: u-boot

OK, now it's working fine on top of u-boot-tegra/master, and rebasing that result against u-boot/master TOT is fine, too. Sorry - don't know what I did wrong before.
I'll run buildman on it and then get a PR out to TomR if it all looks good.

Thanks!

-----Original Message-----
From: Tom Warren 
Sent: Friday, February 17, 2023 9:22 AM
To: Svyatoslav Ryhel <clamor95@gmail.com>
Cc: u-boot@lists.denx.de
Subject: RE: [PATCH v4 00/16] General Tegra improvements

OK, let me retry on u-boot-tegra/master.

-----Original Message-----
From: Svyatoslav Ryhel <clamor95@gmail.com>
Sent: Friday, February 17, 2023 9:07 AM
To: Tom Warren <TWarren@nvidia.com>
Cc: u-boot@lists.denx.de
Subject: Re: [PATCH v4 00/16] General Tegra improvements

External email: Use caution opening links or attachments


I was able to git am it on top of u-boot/master without any errors

clamor@xeon:/media/clamor/work/u-boot$ git am bundle-23303-Svyatoslav-16-v4.mbox
Застосування: tegra30: clock: add EXTPERIPH
Застосування: ARM: t20/t30: swap host1x and disp1 clock parents
Застосування: ARM: tegra: clock: add clk_id_to_pll_id helper
Застосування: ARM: tegra: clock: add clock_decode_pair helper
Застосування: ARM: tegra30: add PLLD to pll setup
Застосування: ARM: tegra: Fix Tegra PWM parent clock
Застосування: spi: tegra20_slink: accept any word length
Застосування: ARM: tegra: provide default USB gadget setup
Застосування: ARM: tegra: add late init support
Застосування: ARM: tegra: create common pre-dm i2c write
Застосування: board: tegra124: switch to updated pre-dm i2c write
Застосування: board: tegra30: switch to updated pre-dm i2c write
Застосування: ARM: tegra: expose crypto module for all Tegra SoCs
Застосування: ARM: tegra: crypto: extend crypto functional
Застосування: ARM: tegra30: implement BCT patching
Застосування: ARM: tegra20: implement BCT patching
.git/rebase-apply/patch:249: new blank line at EOF.
+
warning: 1 рядок додав помилки в пробільних символах.
clamor@xeon:/media/clamor/work/u-boot$

пт, 17 лют. 2023 р. о 17:57 Tom Warren <TWarren@nvidia.com> пише:
>
> I've got a bundle with your 16 patches, created using PatchWork/U-Boot, and the patches are ordered correctly within that bundle. Attached here - see if it works for you.
>
> Tom
>
> -----Original Message-----
> From: Svyatoslav Ryhel <clamor95@gmail.com>
> Sent: Friday, February 17, 2023 1:39 AM
> To: Tom Warren <TWarren@nvidia.com>
> Cc: u-boot@lists.denx.de
> Subject: Re: [PATCH v4 00/16] General Tegra improvements
>
> External email: Use caution opening links or attachments
>
>
> You have NOT applied patch 13 ARM: tegra: expose crypto module for all Tegra SoCs or applied it after patch 14 which brakes order. PTAL.
>
> вт, 14 лют. 2023 р. о 23:45 Tom Warren <TWarren@nvidia.com> пише:
> >
> > <reducing audience>
> >
> > Svyatoslav,
> >
> > Taking TOT u-boot-tegra/master, and fast-forwarding to TOT u-boot/master, I then try to apply your 16 patch series and get the following failures (using patch). Note that I retargeted the crypto.c patch by hand to point to tegra20/crypto.c, which I believe one of your patches moves to arch/arm/tegra. PTAL.
> >
> > tom@tom-ThinkPad-T580:~/denx/uboot-tegra$ patch -p1 -i 
> > ~/Downloads/bundle-23303-Svyatoslav-16-v4.mbox  --dry-run checking 
> > file arch/arm/include/asm/arch-tegra30/clock-tables.h
> > checking file arch/arm/mach-tegra/tegra30/clock.c
> > checking file arch/arm/mach-tegra/tegra20/clock.c
> > checking file arch/arm/mach-tegra/tegra30/clock.c
> > checking file arch/arm/include/asm/arch-tegra/clock.h
> > checking file arch/arm/mach-tegra/tegra114/clock.c
> > checking file arch/arm/mach-tegra/tegra124/clock.c
> > checking file arch/arm/mach-tegra/tegra20/clock.c
> > checking file arch/arm/mach-tegra/tegra210/clock.c
> > checking file arch/arm/mach-tegra/tegra30/clock.c
> > checking file arch/arm/include/asm/arch-tegra/clock.h
> > checking file arch/arm/mach-tegra/clock.c checking file 
> > arch/arm/mach-tegra/tegra30/clock.c
> > Hunk #1 succeeded at 632 (offset -37 lines).
> > checking file arch/arm/dts/tegra114.dtsi checking file 
> > arch/arm/dts/tegra124.dtsi checking file 
> > arch/arm/mach-tegra/tegra114/clock.c
> > Hunk #1 succeeded at 745 (offset -37 lines).
> > checking file arch/arm/mach-tegra/tegra124/clock.c
> > Hunk #1 succeeded at 1170 (offset -38 lines).
> > checking file arch/arm/mach-tegra/tegra20/clock.c
> > Hunk #1 succeeded at 767 (offset -37 lines).
> > checking file arch/arm/mach-tegra/tegra210/clock.c
> > Hunk #1 succeeded at 1241 (offset -37 lines).
> > checking file arch/arm/mach-tegra/tegra30/clock.c
> > Hunk #1 succeeded at 806 (offset -78 lines).
> > checking file drivers/pwm/tegra_pwm.c checking file 
> > drivers/spi/tegra20_slink.c checking file configs/beaver_defconfig 
> > checking file configs/cei-tk1-som_defconfig checking file 
> > configs/dalmore_defconfig checking file configs/jetson-tk1_defconfig 
> > checking file configs/nyan-big_defconfig checking file 
> > configs/p2371-0000_defconfig checking file 
> > configs/p2371-2180_defconfig checking file configs/p2571_defconfig 
> > checking file configs/p3450-0000_defconfig checking file 
> > configs/venice2_defconfig checking file drivers/usb/gadget/Kconfig 
> > checking file arch/arm/include/asm/arch-tegra/sys_proto.h
> > checking file arch/arm/mach-tegra/board2.c checking file 
> > arch/arm/include/asm/arch-tegra/tegra_i2c.h
> > checking file arch/arm/mach-tegra/cpu.h checking file 
> > arch/arm/mach-tegra/tegra124/cpu.c
> > checking file arch/arm/mach-tegra/tegra30/cpu.c checking file 
> > board/nvidia/venice2/as3722_init.c
> > checking file board/nvidia/venice2/as3722_init.h
> > checking file board/toradex/apalis-tk1/as3722_init.c
> > checking file board/toradex/apalis-tk1/as3722_init.h
> > checking file arch/arm/mach-tegra/tegra30/Kconfig
> > checking file arch/arm/mach-tegra/tegra30/cpu.c Hunk #1 FAILED at 15.
> > Hunk #2 FAILED at 41.
> > 2 out of 2 hunks FAILED
> > checking file board/avionic-design/tec-ng/Makefile
> > checking file board/avionic-design/tec-ng/tec-ng-spl.c
> > checking file board/nvidia/beaver/Makefile checking file 
> > board/nvidia/beaver/beaver-spl.c checking file 
> > board/nvidia/cardhu/Makefile checking file 
> > board/nvidia/cardhu/cardhu-spl.c checking file 
> > board/toradex/apalis_t30/Makefile checking file 
> > board/toradex/apalis_t30/apalis_t30-spl.c
> > checking file board/toradex/colibri_t30/Makefile
> > checking file board/toradex/colibri_t30/colibri_t30-spl.c
> > checking file arch/arm/mach-tegra/Kconfig checking file 
> > arch/arm/mach-tegra/Makefile checking file 
> > arch/arm/mach-tegra/crypto.c (renamed from
> > arch/arm/mach-tegra/tegra20/crypto.c)
> > checking file arch/arm/mach-tegra/crypto.h (renamed from
> > arch/arm/mach-tegra/tegra20/crypto.h)
> > checking file arch/arm/mach-tegra/tegra20/Kconfig
> > checking file arch/arm/mach-tegra/tegra20/Makefile
> > checking file arch/arm/include/asm/arch-tegra/crypto.h
> > can't find file to patch at input line 3811 Perhaps you used the 
> > wrong -p or --strip option?
> > The text leading up to this was:
> > --------------------------
> > |diff --git a/arch/arm/mach-tegra/crypto.c 
> > |b/arch/arm/mach-tegra/crypto.c index 1efaa5c3ec..893da35e0b 100644
> > |--- a/arch/arm/mach-tegra/crypto.c
> > |+++ b/arch/arm/mach-tegra/crypto.c
> > --------------------------
> > File to patch: arch/arm/mach-tegra/tegra20/crypto.c
> > checking file arch/arm/mach-tegra/tegra20/crypto.c
> > The next patch would delete the file arch/arm/mach-tegra/crypto.h, 
> > which does not exist!  Assume -R? [n] Apply anyway? [n] Skipping 
> > patch.
> > 1 out of 1 hunk ignored
> > checking file arch/arm/mach-tegra/Kconfig Hunk #1 succeeded at 224 
> > (offset -5 lines).
> > checking file arch/arm/mach-tegra/tegra30/Makefile
> > checking file arch/arm/mach-tegra/tegra30/bct.c checking file 
> > arch/arm/mach-tegra/tegra30/bct.h checking file 
> > arch/arm/mach-tegra/Kconfig Hunk #1 FAILED at 231.
> > 1 out of 1 hunk FAILED
> > checking file arch/arm/mach-tegra/tegra20/Makefile
> > checking file arch/arm/mach-tegra/tegra20/bct.c checking file 
> > arch/arm/mach-tegra/tegra20/bct.h checking file 
> > doc/usage/cmd/ebtupdate.rst 
> > tom@tom-ThinkPad-T580:~/denx/uboot-tegra$
> >
> > -----Original Message-----
> > From: Svyatoslav Ryhel <clamor95@gmail.com>
> > Sent: Tuesday, February 14, 2023 10:35 AM
> > To: Tom Warren <twarren@nvidia.com>; Marcel Ziswiler 
> > <marcel.ziswiler@toradex.com>; Allen Martin <amartin@nvidia.com>; 
> > Jagan Teki <jagan@amarulasolutions.com>; Lukasz Majewski 
> > <lukma@denx.de>; Marek Vasut <marex@denx.de>; Svyatoslav Ryhel 
> > <clamor95@gmail.com>; Ramin Khonsari <raminterex@yahoo.com>; Thierry 
> > Reding <thierry.reding@gmail.com>; Maxim Schwalm 
> > <maxim.schwalm@gmail.com>; Dmitry Osipenko <digetx@gmail.com>; Simon 
> > Glass <sjg@chromium.org>
> > Cc: u-boot@lists.denx.de
> > Subject: [PATCH v4 00/16] General Tegra improvements
> >
> > External email: Use caution opening links or attachments
> >
> >
> > List of changes in patch set:
> >  - add missing EXTPERIPH clocks for t30
> >  - swap host1x and disp1 clock parents (as they should be)
> >  - add clk_id_to_pll_id and clock_decode_pair helpers to use
> >    dts deeper (in tegra clocks often go in pair child - parent)
> >  - include PLLD setup in T30 (DISP1 may use it as parent on
> >    some devices)
> >  - fix Tegra PWM parent clock inline with linux
> >  - Tegra SLINK: patch to accept any word length (unlike 8bit
> >    aligned which was before)
> >  - provide default USB gadget setup for existing Nvidia boards
> >  - add late init function to be able to configure pre-boot stage
> >    (like uncovering serial number or setting mac address)
> >  - create common pre-dm i2c write for PMIC (used on T30 and T124
> >    to configure basic PMIC voltages required to boot like cpu and
> >    core voltages)
> >  - expose crypto module for all Tegra SoCs and implement BCT patching
> >    (ability to update bootloader from u-boot on production devices
> >    without need in host PC)
> >
> > ---
> > Changelog from v3
> >  - added tested-by
> >
> > Changelog from v2
> >  - fixed T114 TEGRA114_CLK_PLL_E_OUT0
> >  - adjusted pre-dm i2c write commit description
> >  - added description file for ebtupdate command
> >  - minor improvements of bct.c comments
> >
> > Changelog from v1
> >  - rebased to latest u-boot master
> >  - PLLD setup for T30 moved specifically into T30 area
> > ---
> >
> > Maxim Schwalm (1):
> >   ARM: tegra: provide default USB gadget setup
> >
> > Ramin Khonsari (1):
> >   ARM: tegra30: implement BCT patching
> >
> > Svyatoslav Ryhel (14):
> >   tegra30: clock: add EXTPERIPH
> >   ARM: t20/t30: swap host1x and disp1 clock parents
> >   ARM: tegra: clock: add clk_id_to_pll_id helper
> >   ARM: tegra: clock: add clock_decode_pair helper
> >   ARM: tegra30: add PLLD to pll setup
> >   ARM: tegra: Fix Tegra PWM parent clock
> >   spi: tegra20_slink: accept any word length
> >   ARM: tegra: add late init support
> >   ARM: tegra: create common pre-dm i2c write
> >   board: tegra124: switch to updated pre-dm i2c write
> >   board: tegra30: switch to updated pre-dm i2c write
> >   ARM: tegra: expose crypto module for all Tegra SoCs
> >   ARM: tegra: crypto: extend crypto functional
> >   ARM: tegra20: implement BCT patching
> >
> >  arch/arm/dts/tegra114.dtsi                    |  2 +-
> >  arch/arm/dts/tegra124.dtsi                    |  2 +-
> >  arch/arm/include/asm/arch-tegra/clock.h       | 21 +++++
> >  arch/arm/include/asm/arch-tegra/crypto.h      | 47 ++++++++++
> >  arch/arm/include/asm/arch-tegra/sys_proto.h   |  6 ++
> >  arch/arm/include/asm/arch-tegra/tegra_i2c.h   | 17 ++++
> >  .../include/asm/arch-tegra30/clock-tables.h   |  6 +-
> >  arch/arm/mach-tegra/Kconfig                   | 14 +++
> >  arch/arm/mach-tegra/Makefile                  |  1 +
> >  arch/arm/mach-tegra/board2.c                  |  2 +
> >  arch/arm/mach-tegra/clock.c                   | 23 +++++
> >  arch/arm/mach-tegra/cpu.h                     |  1 -
> >  arch/arm/mach-tegra/{tegra20 => }/crypto.c    | 63 +++++++++----
> >  arch/arm/mach-tegra/tegra114/clock.c          | 39 +++++++-
> >  arch/arm/mach-tegra/tegra124/clock.c          | 40 ++++++++-
> >  arch/arm/mach-tegra/tegra124/cpu.c            |  4 +
> >  arch/arm/mach-tegra/tegra20/Kconfig           |  1 +
> >  arch/arm/mach-tegra/tegra20/Makefile          |  7 +-
> >  arch/arm/mach-tegra/tegra20/bct.c             | 79 ++++++++++++++++
> >  arch/arm/mach-tegra/tegra20/bct.h             | 42 +++++++++
> >  arch/arm/mach-tegra/tegra20/clock.c           | 43 ++++++++-
> >  arch/arm/mach-tegra/tegra20/crypto.h          | 19 ----
> >  arch/arm/mach-tegra/tegra210/clock.c          | 39 +++++++-
> >  arch/arm/mach-tegra/tegra30/Kconfig           |  8 --
> >  arch/arm/mach-tegra/tegra30/Makefile          |  1 +
> >  arch/arm/mach-tegra/tegra30/bct.c             | 79 ++++++++++++++++
> >  arch/arm/mach-tegra/tegra30/bct.h             | 42 +++++++++
> >  arch/arm/mach-tegra/tegra30/clock.c           | 90 +++++++++++++++++--
> >  arch/arm/mach-tegra/tegra30/cpu.c             | 55 +-----------
> >  board/avionic-design/tec-ng/Makefile          |  4 +-
> >  board/avionic-design/tec-ng/tec-ng-spl.c      | 34 +++++++
> >  board/nvidia/beaver/Makefile                  |  2 +
> >  board/nvidia/beaver/beaver-spl.c              | 43 +++++++++
> >  board/nvidia/cardhu/Makefile                  |  4 +-
> >  board/nvidia/cardhu/cardhu-spl.c              | 43 +++++++++
> >  board/nvidia/venice2/as3722_init.c            | 65 +++++++++-----
> >  board/nvidia/venice2/as3722_init.h            | 43 ---------
> >  board/toradex/apalis-tk1/as3722_init.c        | 85 ++++++++++--------
> >  board/toradex/apalis-tk1/as3722_init.h        | 40 ---------
> >  board/toradex/apalis_t30/Makefile             |  2 +
> >  board/toradex/apalis_t30/apalis_t30-spl.c     | 34 +++++++
> >  board/toradex/colibri_t30/Makefile            |  2 +
> >  board/toradex/colibri_t30/colibri_t30-spl.c   | 34 +++++++
> >  configs/beaver_defconfig                      |  3 -
> >  configs/cei-tk1-som_defconfig                 |  3 -
> >  configs/dalmore_defconfig                     |  3 -
> >  configs/jetson-tk1_defconfig                  |  3 -
> >  configs/nyan-big_defconfig                    |  3 -
> >  configs/p2371-0000_defconfig                  |  3 -
> >  configs/p2371-2180_defconfig                  |  3 -
> >  configs/p2571_defconfig                       |  3 -
> >  configs/p3450-0000_defconfig                  |  3 -
> >  configs/venice2_defconfig                     |  3 -
> >  doc/usage/cmd/ebtupdate.rst                   | 70 +++++++++++++++
> >  drivers/pwm/tegra_pwm.c                       | 10 ++-
> >  drivers/spi/tegra20_slink.c                   | 19 ++--
> >  drivers/usb/gadget/Kconfig                    |  3 +
> >  57 files changed, 1051 insertions(+), 309 deletions(-)  create mode
> > 100644 arch/arm/include/asm/arch-tegra/crypto.h
> >  rename arch/arm/mach-tegra/{tegra20 => }/crypto.c (68%)  create 
> > mode
> > 100644 arch/arm/mach-tegra/tegra20/bct.c  create mode 100644 
> > arch/arm/mach-tegra/tegra20/bct.h  delete mode 100644 
> > arch/arm/mach-tegra/tegra20/crypto.h
> >  create mode 100644 arch/arm/mach-tegra/tegra30/bct.c  create mode
> > 100644 arch/arm/mach-tegra/tegra30/bct.h  create mode 100644 
> > board/avionic-design/tec-ng/tec-ng-spl.c
> >  create mode 100644 board/nvidia/beaver/beaver-spl.c  create mode
> > 100644 board/nvidia/cardhu/cardhu-spl.c  delete mode 100644 
> > board/nvidia/venice2/as3722_init.h
> >  delete mode 100644 board/toradex/apalis-tk1/as3722_init.h
> >  create mode 100644 board/toradex/apalis_t30/apalis_t30-spl.c
> >  create mode 100644 board/toradex/colibri_t30/colibri_t30-spl.c
> >  create mode 100644 doc/usage/cmd/ebtupdate.rst
> >
> > --
> > 2.37.2
> >

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH v4 00/16] General Tegra improvements
  2023-02-17 16:27           ` Tom Warren
@ 2023-02-17 16:35             ` Svyatoslav Ryhel
  2023-02-21  7:59             ` Svyatoslav Ryhel
  1 sibling, 0 replies; 28+ messages in thread
From: Svyatoslav Ryhel @ 2023-02-17 16:35 UTC (permalink / raw)
  To: Tom Warren; +Cc: u-boot

No problem, it is nice that the second attempt passed smoothly.

Thank you!

Best regards,
Svyatoslav R.

P. S. I am a bit hesitant about DC related patch set I wanted to send
next. I would like to include a T30 DSI driver into it but it seems to
be partially broken. May I write to you directly with a description of
the state I have reached? Maybe you could advise in which direction I
should look?

пт, 17 лют. 2023 р. о 18:27 Tom Warren <TWarren@nvidia.com> пише:
>
> OK, now it's working fine on top of u-boot-tegra/master, and rebasing that result against u-boot/master TOT is fine, too. Sorry - don't know what I did wrong before.
> I'll run buildman on it and then get a PR out to TomR if it all looks good.
>
> Thanks!
>
> -----Original Message-----
> From: Tom Warren
> Sent: Friday, February 17, 2023 9:22 AM
> To: Svyatoslav Ryhel <clamor95@gmail.com>
> Cc: u-boot@lists.denx.de
> Subject: RE: [PATCH v4 00/16] General Tegra improvements
>
> OK, let me retry on u-boot-tegra/master.
>
> -----Original Message-----
> From: Svyatoslav Ryhel <clamor95@gmail.com>
> Sent: Friday, February 17, 2023 9:07 AM
> To: Tom Warren <TWarren@nvidia.com>
> Cc: u-boot@lists.denx.de
> Subject: Re: [PATCH v4 00/16] General Tegra improvements
>
> External email: Use caution opening links or attachments
>
>
> I was able to git am it on top of u-boot/master without any errors
>
> clamor@xeon:/media/clamor/work/u-boot$ git am bundle-23303-Svyatoslav-16-v4.mbox
> Застосування: tegra30: clock: add EXTPERIPH
> Застосування: ARM: t20/t30: swap host1x and disp1 clock parents
> Застосування: ARM: tegra: clock: add clk_id_to_pll_id helper
> Застосування: ARM: tegra: clock: add clock_decode_pair helper
> Застосування: ARM: tegra30: add PLLD to pll setup
> Застосування: ARM: tegra: Fix Tegra PWM parent clock
> Застосування: spi: tegra20_slink: accept any word length
> Застосування: ARM: tegra: provide default USB gadget setup
> Застосування: ARM: tegra: add late init support
> Застосування: ARM: tegra: create common pre-dm i2c write
> Застосування: board: tegra124: switch to updated pre-dm i2c write
> Застосування: board: tegra30: switch to updated pre-dm i2c write
> Застосування: ARM: tegra: expose crypto module for all Tegra SoCs
> Застосування: ARM: tegra: crypto: extend crypto functional
> Застосування: ARM: tegra30: implement BCT patching
> Застосування: ARM: tegra20: implement BCT patching
> .git/rebase-apply/patch:249: new blank line at EOF.
> +
> warning: 1 рядок додав помилки в пробільних символах.
> clamor@xeon:/media/clamor/work/u-boot$
>
> пт, 17 лют. 2023 р. о 17:57 Tom Warren <TWarren@nvidia.com> пише:
> >
> > I've got a bundle with your 16 patches, created using PatchWork/U-Boot, and the patches are ordered correctly within that bundle. Attached here - see if it works for you.
> >
> > Tom
> >
> > -----Original Message-----
> > From: Svyatoslav Ryhel <clamor95@gmail.com>
> > Sent: Friday, February 17, 2023 1:39 AM
> > To: Tom Warren <TWarren@nvidia.com>
> > Cc: u-boot@lists.denx.de
> > Subject: Re: [PATCH v4 00/16] General Tegra improvements
> >
> > External email: Use caution opening links or attachments
> >
> >
> > You have NOT applied patch 13 ARM: tegra: expose crypto module for all Tegra SoCs or applied it after patch 14 which brakes order. PTAL.
> >
> > вт, 14 лют. 2023 р. о 23:45 Tom Warren <TWarren@nvidia.com> пише:
> > >
> > > <reducing audience>
> > >
> > > Svyatoslav,
> > >
> > > Taking TOT u-boot-tegra/master, and fast-forwarding to TOT u-boot/master, I then try to apply your 16 patch series and get the following failures (using patch). Note that I retargeted the crypto.c patch by hand to point to tegra20/crypto.c, which I believe one of your patches moves to arch/arm/tegra. PTAL.
> > >
> > > tom@tom-ThinkPad-T580:~/denx/uboot-tegra$ patch -p1 -i
> > > ~/Downloads/bundle-23303-Svyatoslav-16-v4.mbox  --dry-run checking
> > > file arch/arm/include/asm/arch-tegra30/clock-tables.h
> > > checking file arch/arm/mach-tegra/tegra30/clock.c
> > > checking file arch/arm/mach-tegra/tegra20/clock.c
> > > checking file arch/arm/mach-tegra/tegra30/clock.c
> > > checking file arch/arm/include/asm/arch-tegra/clock.h
> > > checking file arch/arm/mach-tegra/tegra114/clock.c
> > > checking file arch/arm/mach-tegra/tegra124/clock.c
> > > checking file arch/arm/mach-tegra/tegra20/clock.c
> > > checking file arch/arm/mach-tegra/tegra210/clock.c
> > > checking file arch/arm/mach-tegra/tegra30/clock.c
> > > checking file arch/arm/include/asm/arch-tegra/clock.h
> > > checking file arch/arm/mach-tegra/clock.c checking file
> > > arch/arm/mach-tegra/tegra30/clock.c
> > > Hunk #1 succeeded at 632 (offset -37 lines).
> > > checking file arch/arm/dts/tegra114.dtsi checking file
> > > arch/arm/dts/tegra124.dtsi checking file
> > > arch/arm/mach-tegra/tegra114/clock.c
> > > Hunk #1 succeeded at 745 (offset -37 lines).
> > > checking file arch/arm/mach-tegra/tegra124/clock.c
> > > Hunk #1 succeeded at 1170 (offset -38 lines).
> > > checking file arch/arm/mach-tegra/tegra20/clock.c
> > > Hunk #1 succeeded at 767 (offset -37 lines).
> > > checking file arch/arm/mach-tegra/tegra210/clock.c
> > > Hunk #1 succeeded at 1241 (offset -37 lines).
> > > checking file arch/arm/mach-tegra/tegra30/clock.c
> > > Hunk #1 succeeded at 806 (offset -78 lines).
> > > checking file drivers/pwm/tegra_pwm.c checking file
> > > drivers/spi/tegra20_slink.c checking file configs/beaver_defconfig
> > > checking file configs/cei-tk1-som_defconfig checking file
> > > configs/dalmore_defconfig checking file configs/jetson-tk1_defconfig
> > > checking file configs/nyan-big_defconfig checking file
> > > configs/p2371-0000_defconfig checking file
> > > configs/p2371-2180_defconfig checking file configs/p2571_defconfig
> > > checking file configs/p3450-0000_defconfig checking file
> > > configs/venice2_defconfig checking file drivers/usb/gadget/Kconfig
> > > checking file arch/arm/include/asm/arch-tegra/sys_proto.h
> > > checking file arch/arm/mach-tegra/board2.c checking file
> > > arch/arm/include/asm/arch-tegra/tegra_i2c.h
> > > checking file arch/arm/mach-tegra/cpu.h checking file
> > > arch/arm/mach-tegra/tegra124/cpu.c
> > > checking file arch/arm/mach-tegra/tegra30/cpu.c checking file
> > > board/nvidia/venice2/as3722_init.c
> > > checking file board/nvidia/venice2/as3722_init.h
> > > checking file board/toradex/apalis-tk1/as3722_init.c
> > > checking file board/toradex/apalis-tk1/as3722_init.h
> > > checking file arch/arm/mach-tegra/tegra30/Kconfig
> > > checking file arch/arm/mach-tegra/tegra30/cpu.c Hunk #1 FAILED at 15.
> > > Hunk #2 FAILED at 41.
> > > 2 out of 2 hunks FAILED
> > > checking file board/avionic-design/tec-ng/Makefile
> > > checking file board/avionic-design/tec-ng/tec-ng-spl.c
> > > checking file board/nvidia/beaver/Makefile checking file
> > > board/nvidia/beaver/beaver-spl.c checking file
> > > board/nvidia/cardhu/Makefile checking file
> > > board/nvidia/cardhu/cardhu-spl.c checking file
> > > board/toradex/apalis_t30/Makefile checking file
> > > board/toradex/apalis_t30/apalis_t30-spl.c
> > > checking file board/toradex/colibri_t30/Makefile
> > > checking file board/toradex/colibri_t30/colibri_t30-spl.c
> > > checking file arch/arm/mach-tegra/Kconfig checking file
> > > arch/arm/mach-tegra/Makefile checking file
> > > arch/arm/mach-tegra/crypto.c (renamed from
> > > arch/arm/mach-tegra/tegra20/crypto.c)
> > > checking file arch/arm/mach-tegra/crypto.h (renamed from
> > > arch/arm/mach-tegra/tegra20/crypto.h)
> > > checking file arch/arm/mach-tegra/tegra20/Kconfig
> > > checking file arch/arm/mach-tegra/tegra20/Makefile
> > > checking file arch/arm/include/asm/arch-tegra/crypto.h
> > > can't find file to patch at input line 3811 Perhaps you used the
> > > wrong -p or --strip option?
> > > The text leading up to this was:
> > > --------------------------
> > > |diff --git a/arch/arm/mach-tegra/crypto.c
> > > |b/arch/arm/mach-tegra/crypto.c index 1efaa5c3ec..893da35e0b 100644
> > > |--- a/arch/arm/mach-tegra/crypto.c
> > > |+++ b/arch/arm/mach-tegra/crypto.c
> > > --------------------------
> > > File to patch: arch/arm/mach-tegra/tegra20/crypto.c
> > > checking file arch/arm/mach-tegra/tegra20/crypto.c
> > > The next patch would delete the file arch/arm/mach-tegra/crypto.h,
> > > which does not exist!  Assume -R? [n] Apply anyway? [n] Skipping
> > > patch.
> > > 1 out of 1 hunk ignored
> > > checking file arch/arm/mach-tegra/Kconfig Hunk #1 succeeded at 224
> > > (offset -5 lines).
> > > checking file arch/arm/mach-tegra/tegra30/Makefile
> > > checking file arch/arm/mach-tegra/tegra30/bct.c checking file
> > > arch/arm/mach-tegra/tegra30/bct.h checking file
> > > arch/arm/mach-tegra/Kconfig Hunk #1 FAILED at 231.
> > > 1 out of 1 hunk FAILED
> > > checking file arch/arm/mach-tegra/tegra20/Makefile
> > > checking file arch/arm/mach-tegra/tegra20/bct.c checking file
> > > arch/arm/mach-tegra/tegra20/bct.h checking file
> > > doc/usage/cmd/ebtupdate.rst
> > > tom@tom-ThinkPad-T580:~/denx/uboot-tegra$
> > >
> > > -----Original Message-----
> > > From: Svyatoslav Ryhel <clamor95@gmail.com>
> > > Sent: Tuesday, February 14, 2023 10:35 AM
> > > To: Tom Warren <twarren@nvidia.com>; Marcel Ziswiler
> > > <marcel.ziswiler@toradex.com>; Allen Martin <amartin@nvidia.com>;
> > > Jagan Teki <jagan@amarulasolutions.com>; Lukasz Majewski
> > > <lukma@denx.de>; Marek Vasut <marex@denx.de>; Svyatoslav Ryhel
> > > <clamor95@gmail.com>; Ramin Khonsari <raminterex@yahoo.com>; Thierry
> > > Reding <thierry.reding@gmail.com>; Maxim Schwalm
> > > <maxim.schwalm@gmail.com>; Dmitry Osipenko <digetx@gmail.com>; Simon
> > > Glass <sjg@chromium.org>
> > > Cc: u-boot@lists.denx.de
> > > Subject: [PATCH v4 00/16] General Tegra improvements
> > >
> > > External email: Use caution opening links or attachments
> > >
> > >
> > > List of changes in patch set:
> > >  - add missing EXTPERIPH clocks for t30
> > >  - swap host1x and disp1 clock parents (as they should be)
> > >  - add clk_id_to_pll_id and clock_decode_pair helpers to use
> > >    dts deeper (in tegra clocks often go in pair child - parent)
> > >  - include PLLD setup in T30 (DISP1 may use it as parent on
> > >    some devices)
> > >  - fix Tegra PWM parent clock inline with linux
> > >  - Tegra SLINK: patch to accept any word length (unlike 8bit
> > >    aligned which was before)
> > >  - provide default USB gadget setup for existing Nvidia boards
> > >  - add late init function to be able to configure pre-boot stage
> > >    (like uncovering serial number or setting mac address)
> > >  - create common pre-dm i2c write for PMIC (used on T30 and T124
> > >    to configure basic PMIC voltages required to boot like cpu and
> > >    core voltages)
> > >  - expose crypto module for all Tegra SoCs and implement BCT patching
> > >    (ability to update bootloader from u-boot on production devices
> > >    without need in host PC)
> > >
> > > ---
> > > Changelog from v3
> > >  - added tested-by
> > >
> > > Changelog from v2
> > >  - fixed T114 TEGRA114_CLK_PLL_E_OUT0
> > >  - adjusted pre-dm i2c write commit description
> > >  - added description file for ebtupdate command
> > >  - minor improvements of bct.c comments
> > >
> > > Changelog from v1
> > >  - rebased to latest u-boot master
> > >  - PLLD setup for T30 moved specifically into T30 area
> > > ---
> > >
> > > Maxim Schwalm (1):
> > >   ARM: tegra: provide default USB gadget setup
> > >
> > > Ramin Khonsari (1):
> > >   ARM: tegra30: implement BCT patching
> > >
> > > Svyatoslav Ryhel (14):
> > >   tegra30: clock: add EXTPERIPH
> > >   ARM: t20/t30: swap host1x and disp1 clock parents
> > >   ARM: tegra: clock: add clk_id_to_pll_id helper
> > >   ARM: tegra: clock: add clock_decode_pair helper
> > >   ARM: tegra30: add PLLD to pll setup
> > >   ARM: tegra: Fix Tegra PWM parent clock
> > >   spi: tegra20_slink: accept any word length
> > >   ARM: tegra: add late init support
> > >   ARM: tegra: create common pre-dm i2c write
> > >   board: tegra124: switch to updated pre-dm i2c write
> > >   board: tegra30: switch to updated pre-dm i2c write
> > >   ARM: tegra: expose crypto module for all Tegra SoCs
> > >   ARM: tegra: crypto: extend crypto functional
> > >   ARM: tegra20: implement BCT patching
> > >
> > >  arch/arm/dts/tegra114.dtsi                    |  2 +-
> > >  arch/arm/dts/tegra124.dtsi                    |  2 +-
> > >  arch/arm/include/asm/arch-tegra/clock.h       | 21 +++++
> > >  arch/arm/include/asm/arch-tegra/crypto.h      | 47 ++++++++++
> > >  arch/arm/include/asm/arch-tegra/sys_proto.h   |  6 ++
> > >  arch/arm/include/asm/arch-tegra/tegra_i2c.h   | 17 ++++
> > >  .../include/asm/arch-tegra30/clock-tables.h   |  6 +-
> > >  arch/arm/mach-tegra/Kconfig                   | 14 +++
> > >  arch/arm/mach-tegra/Makefile                  |  1 +
> > >  arch/arm/mach-tegra/board2.c                  |  2 +
> > >  arch/arm/mach-tegra/clock.c                   | 23 +++++
> > >  arch/arm/mach-tegra/cpu.h                     |  1 -
> > >  arch/arm/mach-tegra/{tegra20 => }/crypto.c    | 63 +++++++++----
> > >  arch/arm/mach-tegra/tegra114/clock.c          | 39 +++++++-
> > >  arch/arm/mach-tegra/tegra124/clock.c          | 40 ++++++++-
> > >  arch/arm/mach-tegra/tegra124/cpu.c            |  4 +
> > >  arch/arm/mach-tegra/tegra20/Kconfig           |  1 +
> > >  arch/arm/mach-tegra/tegra20/Makefile          |  7 +-
> > >  arch/arm/mach-tegra/tegra20/bct.c             | 79 ++++++++++++++++
> > >  arch/arm/mach-tegra/tegra20/bct.h             | 42 +++++++++
> > >  arch/arm/mach-tegra/tegra20/clock.c           | 43 ++++++++-
> > >  arch/arm/mach-tegra/tegra20/crypto.h          | 19 ----
> > >  arch/arm/mach-tegra/tegra210/clock.c          | 39 +++++++-
> > >  arch/arm/mach-tegra/tegra30/Kconfig           |  8 --
> > >  arch/arm/mach-tegra/tegra30/Makefile          |  1 +
> > >  arch/arm/mach-tegra/tegra30/bct.c             | 79 ++++++++++++++++
> > >  arch/arm/mach-tegra/tegra30/bct.h             | 42 +++++++++
> > >  arch/arm/mach-tegra/tegra30/clock.c           | 90 +++++++++++++++++--
> > >  arch/arm/mach-tegra/tegra30/cpu.c             | 55 +-----------
> > >  board/avionic-design/tec-ng/Makefile          |  4 +-
> > >  board/avionic-design/tec-ng/tec-ng-spl.c      | 34 +++++++
> > >  board/nvidia/beaver/Makefile                  |  2 +
> > >  board/nvidia/beaver/beaver-spl.c              | 43 +++++++++
> > >  board/nvidia/cardhu/Makefile                  |  4 +-
> > >  board/nvidia/cardhu/cardhu-spl.c              | 43 +++++++++
> > >  board/nvidia/venice2/as3722_init.c            | 65 +++++++++-----
> > >  board/nvidia/venice2/as3722_init.h            | 43 ---------
> > >  board/toradex/apalis-tk1/as3722_init.c        | 85 ++++++++++--------
> > >  board/toradex/apalis-tk1/as3722_init.h        | 40 ---------
> > >  board/toradex/apalis_t30/Makefile             |  2 +
> > >  board/toradex/apalis_t30/apalis_t30-spl.c     | 34 +++++++
> > >  board/toradex/colibri_t30/Makefile            |  2 +
> > >  board/toradex/colibri_t30/colibri_t30-spl.c   | 34 +++++++
> > >  configs/beaver_defconfig                      |  3 -
> > >  configs/cei-tk1-som_defconfig                 |  3 -
> > >  configs/dalmore_defconfig                     |  3 -
> > >  configs/jetson-tk1_defconfig                  |  3 -
> > >  configs/nyan-big_defconfig                    |  3 -
> > >  configs/p2371-0000_defconfig                  |  3 -
> > >  configs/p2371-2180_defconfig                  |  3 -
> > >  configs/p2571_defconfig                       |  3 -
> > >  configs/p3450-0000_defconfig                  |  3 -
> > >  configs/venice2_defconfig                     |  3 -
> > >  doc/usage/cmd/ebtupdate.rst                   | 70 +++++++++++++++
> > >  drivers/pwm/tegra_pwm.c                       | 10 ++-
> > >  drivers/spi/tegra20_slink.c                   | 19 ++--
> > >  drivers/usb/gadget/Kconfig                    |  3 +
> > >  57 files changed, 1051 insertions(+), 309 deletions(-)  create mode
> > > 100644 arch/arm/include/asm/arch-tegra/crypto.h
> > >  rename arch/arm/mach-tegra/{tegra20 => }/crypto.c (68%)  create
> > > mode
> > > 100644 arch/arm/mach-tegra/tegra20/bct.c  create mode 100644
> > > arch/arm/mach-tegra/tegra20/bct.h  delete mode 100644
> > > arch/arm/mach-tegra/tegra20/crypto.h
> > >  create mode 100644 arch/arm/mach-tegra/tegra30/bct.c  create mode
> > > 100644 arch/arm/mach-tegra/tegra30/bct.h  create mode 100644
> > > board/avionic-design/tec-ng/tec-ng-spl.c
> > >  create mode 100644 board/nvidia/beaver/beaver-spl.c  create mode
> > > 100644 board/nvidia/cardhu/cardhu-spl.c  delete mode 100644
> > > board/nvidia/venice2/as3722_init.h
> > >  delete mode 100644 board/toradex/apalis-tk1/as3722_init.h
> > >  create mode 100644 board/toradex/apalis_t30/apalis_t30-spl.c
> > >  create mode 100644 board/toradex/colibri_t30/colibri_t30-spl.c
> > >  create mode 100644 doc/usage/cmd/ebtupdate.rst
> > >
> > > --
> > > 2.37.2
> > >

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH v4 00/16] General Tegra improvements
  2023-02-17 16:27           ` Tom Warren
  2023-02-17 16:35             ` Svyatoslav Ryhel
@ 2023-02-21  7:59             ` Svyatoslav Ryhel
  2023-02-21 16:09               ` Tom Warren
  1 sibling, 1 reply; 28+ messages in thread
From: Svyatoslav Ryhel @ 2023-02-21  7:59 UTC (permalink / raw)
  To: Tom Warren; +Cc: u-boot

Greetings! Did buildman run smoothly?

I have fixed DSI support and DC related patches are already sent.

Best regards,
Svyatoslav R.

пт, 17 лют. 2023 р. о 18:27 Tom Warren <TWarren@nvidia.com> пише:
>
> OK, now it's working fine on top of u-boot-tegra/master, and rebasing that result against u-boot/master TOT is fine, too. Sorry - don't know what I did wrong before.
> I'll run buildman on it and then get a PR out to TomR if it all looks good.
>
> Thanks!
>
> -----Original Message-----
> From: Tom Warren
> Sent: Friday, February 17, 2023 9:22 AM
> To: Svyatoslav Ryhel <clamor95@gmail.com>
> Cc: u-boot@lists.denx.de
> Subject: RE: [PATCH v4 00/16] General Tegra improvements
>
> OK, let me retry on u-boot-tegra/master.
>
> -----Original Message-----
> From: Svyatoslav Ryhel <clamor95@gmail.com>
> Sent: Friday, February 17, 2023 9:07 AM
> To: Tom Warren <TWarren@nvidia.com>
> Cc: u-boot@lists.denx.de
> Subject: Re: [PATCH v4 00/16] General Tegra improvements
>
> External email: Use caution opening links or attachments
>
>
> I was able to git am it on top of u-boot/master without any errors
>
> clamor@xeon:/media/clamor/work/u-boot$ git am bundle-23303-Svyatoslav-16-v4.mbox
> Застосування: tegra30: clock: add EXTPERIPH
> Застосування: ARM: t20/t30: swap host1x and disp1 clock parents
> Застосування: ARM: tegra: clock: add clk_id_to_pll_id helper
> Застосування: ARM: tegra: clock: add clock_decode_pair helper
> Застосування: ARM: tegra30: add PLLD to pll setup
> Застосування: ARM: tegra: Fix Tegra PWM parent clock
> Застосування: spi: tegra20_slink: accept any word length
> Застосування: ARM: tegra: provide default USB gadget setup
> Застосування: ARM: tegra: add late init support
> Застосування: ARM: tegra: create common pre-dm i2c write
> Застосування: board: tegra124: switch to updated pre-dm i2c write
> Застосування: board: tegra30: switch to updated pre-dm i2c write
> Застосування: ARM: tegra: expose crypto module for all Tegra SoCs
> Застосування: ARM: tegra: crypto: extend crypto functional
> Застосування: ARM: tegra30: implement BCT patching
> Застосування: ARM: tegra20: implement BCT patching
> .git/rebase-apply/patch:249: new blank line at EOF.
> +
> warning: 1 рядок додав помилки в пробільних символах.
> clamor@xeon:/media/clamor/work/u-boot$
>
> пт, 17 лют. 2023 р. о 17:57 Tom Warren <TWarren@nvidia.com> пише:
> >
> > I've got a bundle with your 16 patches, created using PatchWork/U-Boot, and the patches are ordered correctly within that bundle. Attached here - see if it works for you.
> >
> > Tom
> >
> > -----Original Message-----
> > From: Svyatoslav Ryhel <clamor95@gmail.com>
> > Sent: Friday, February 17, 2023 1:39 AM
> > To: Tom Warren <TWarren@nvidia.com>
> > Cc: u-boot@lists.denx.de
> > Subject: Re: [PATCH v4 00/16] General Tegra improvements
> >
> > External email: Use caution opening links or attachments
> >
> >
> > You have NOT applied patch 13 ARM: tegra: expose crypto module for all Tegra SoCs or applied it after patch 14 which brakes order. PTAL.
> >
> > вт, 14 лют. 2023 р. о 23:45 Tom Warren <TWarren@nvidia.com> пише:
> > >
> > > <reducing audience>
> > >
> > > Svyatoslav,
> > >
> > > Taking TOT u-boot-tegra/master, and fast-forwarding to TOT u-boot/master, I then try to apply your 16 patch series and get the following failures (using patch). Note that I retargeted the crypto.c patch by hand to point to tegra20/crypto.c, which I believe one of your patches moves to arch/arm/tegra. PTAL.
> > >
> > > tom@tom-ThinkPad-T580:~/denx/uboot-tegra$ patch -p1 -i
> > > ~/Downloads/bundle-23303-Svyatoslav-16-v4.mbox  --dry-run checking
> > > file arch/arm/include/asm/arch-tegra30/clock-tables.h
> > > checking file arch/arm/mach-tegra/tegra30/clock.c
> > > checking file arch/arm/mach-tegra/tegra20/clock.c
> > > checking file arch/arm/mach-tegra/tegra30/clock.c
> > > checking file arch/arm/include/asm/arch-tegra/clock.h
> > > checking file arch/arm/mach-tegra/tegra114/clock.c
> > > checking file arch/arm/mach-tegra/tegra124/clock.c
> > > checking file arch/arm/mach-tegra/tegra20/clock.c
> > > checking file arch/arm/mach-tegra/tegra210/clock.c
> > > checking file arch/arm/mach-tegra/tegra30/clock.c
> > > checking file arch/arm/include/asm/arch-tegra/clock.h
> > > checking file arch/arm/mach-tegra/clock.c checking file
> > > arch/arm/mach-tegra/tegra30/clock.c
> > > Hunk #1 succeeded at 632 (offset -37 lines).
> > > checking file arch/arm/dts/tegra114.dtsi checking file
> > > arch/arm/dts/tegra124.dtsi checking file
> > > arch/arm/mach-tegra/tegra114/clock.c
> > > Hunk #1 succeeded at 745 (offset -37 lines).
> > > checking file arch/arm/mach-tegra/tegra124/clock.c
> > > Hunk #1 succeeded at 1170 (offset -38 lines).
> > > checking file arch/arm/mach-tegra/tegra20/clock.c
> > > Hunk #1 succeeded at 767 (offset -37 lines).
> > > checking file arch/arm/mach-tegra/tegra210/clock.c
> > > Hunk #1 succeeded at 1241 (offset -37 lines).
> > > checking file arch/arm/mach-tegra/tegra30/clock.c
> > > Hunk #1 succeeded at 806 (offset -78 lines).
> > > checking file drivers/pwm/tegra_pwm.c checking file
> > > drivers/spi/tegra20_slink.c checking file configs/beaver_defconfig
> > > checking file configs/cei-tk1-som_defconfig checking file
> > > configs/dalmore_defconfig checking file configs/jetson-tk1_defconfig
> > > checking file configs/nyan-big_defconfig checking file
> > > configs/p2371-0000_defconfig checking file
> > > configs/p2371-2180_defconfig checking file configs/p2571_defconfig
> > > checking file configs/p3450-0000_defconfig checking file
> > > configs/venice2_defconfig checking file drivers/usb/gadget/Kconfig
> > > checking file arch/arm/include/asm/arch-tegra/sys_proto.h
> > > checking file arch/arm/mach-tegra/board2.c checking file
> > > arch/arm/include/asm/arch-tegra/tegra_i2c.h
> > > checking file arch/arm/mach-tegra/cpu.h checking file
> > > arch/arm/mach-tegra/tegra124/cpu.c
> > > checking file arch/arm/mach-tegra/tegra30/cpu.c checking file
> > > board/nvidia/venice2/as3722_init.c
> > > checking file board/nvidia/venice2/as3722_init.h
> > > checking file board/toradex/apalis-tk1/as3722_init.c
> > > checking file board/toradex/apalis-tk1/as3722_init.h
> > > checking file arch/arm/mach-tegra/tegra30/Kconfig
> > > checking file arch/arm/mach-tegra/tegra30/cpu.c Hunk #1 FAILED at 15.
> > > Hunk #2 FAILED at 41.
> > > 2 out of 2 hunks FAILED
> > > checking file board/avionic-design/tec-ng/Makefile
> > > checking file board/avionic-design/tec-ng/tec-ng-spl.c
> > > checking file board/nvidia/beaver/Makefile checking file
> > > board/nvidia/beaver/beaver-spl.c checking file
> > > board/nvidia/cardhu/Makefile checking file
> > > board/nvidia/cardhu/cardhu-spl.c checking file
> > > board/toradex/apalis_t30/Makefile checking file
> > > board/toradex/apalis_t30/apalis_t30-spl.c
> > > checking file board/toradex/colibri_t30/Makefile
> > > checking file board/toradex/colibri_t30/colibri_t30-spl.c
> > > checking file arch/arm/mach-tegra/Kconfig checking file
> > > arch/arm/mach-tegra/Makefile checking file
> > > arch/arm/mach-tegra/crypto.c (renamed from
> > > arch/arm/mach-tegra/tegra20/crypto.c)
> > > checking file arch/arm/mach-tegra/crypto.h (renamed from
> > > arch/arm/mach-tegra/tegra20/crypto.h)
> > > checking file arch/arm/mach-tegra/tegra20/Kconfig
> > > checking file arch/arm/mach-tegra/tegra20/Makefile
> > > checking file arch/arm/include/asm/arch-tegra/crypto.h
> > > can't find file to patch at input line 3811 Perhaps you used the
> > > wrong -p or --strip option?
> > > The text leading up to this was:
> > > --------------------------
> > > |diff --git a/arch/arm/mach-tegra/crypto.c
> > > |b/arch/arm/mach-tegra/crypto.c index 1efaa5c3ec..893da35e0b 100644
> > > |--- a/arch/arm/mach-tegra/crypto.c
> > > |+++ b/arch/arm/mach-tegra/crypto.c
> > > --------------------------
> > > File to patch: arch/arm/mach-tegra/tegra20/crypto.c
> > > checking file arch/arm/mach-tegra/tegra20/crypto.c
> > > The next patch would delete the file arch/arm/mach-tegra/crypto.h,
> > > which does not exist!  Assume -R? [n] Apply anyway? [n] Skipping
> > > patch.
> > > 1 out of 1 hunk ignored
> > > checking file arch/arm/mach-tegra/Kconfig Hunk #1 succeeded at 224
> > > (offset -5 lines).
> > > checking file arch/arm/mach-tegra/tegra30/Makefile
> > > checking file arch/arm/mach-tegra/tegra30/bct.c checking file
> > > arch/arm/mach-tegra/tegra30/bct.h checking file
> > > arch/arm/mach-tegra/Kconfig Hunk #1 FAILED at 231.
> > > 1 out of 1 hunk FAILED
> > > checking file arch/arm/mach-tegra/tegra20/Makefile
> > > checking file arch/arm/mach-tegra/tegra20/bct.c checking file
> > > arch/arm/mach-tegra/tegra20/bct.h checking file
> > > doc/usage/cmd/ebtupdate.rst
> > > tom@tom-ThinkPad-T580:~/denx/uboot-tegra$
> > >
> > > -----Original Message-----
> > > From: Svyatoslav Ryhel <clamor95@gmail.com>
> > > Sent: Tuesday, February 14, 2023 10:35 AM
> > > To: Tom Warren <twarren@nvidia.com>; Marcel Ziswiler
> > > <marcel.ziswiler@toradex.com>; Allen Martin <amartin@nvidia.com>;
> > > Jagan Teki <jagan@amarulasolutions.com>; Lukasz Majewski
> > > <lukma@denx.de>; Marek Vasut <marex@denx.de>; Svyatoslav Ryhel
> > > <clamor95@gmail.com>; Ramin Khonsari <raminterex@yahoo.com>; Thierry
> > > Reding <thierry.reding@gmail.com>; Maxim Schwalm
> > > <maxim.schwalm@gmail.com>; Dmitry Osipenko <digetx@gmail.com>; Simon
> > > Glass <sjg@chromium.org>
> > > Cc: u-boot@lists.denx.de
> > > Subject: [PATCH v4 00/16] General Tegra improvements
> > >
> > > External email: Use caution opening links or attachments
> > >
> > >
> > > List of changes in patch set:
> > >  - add missing EXTPERIPH clocks for t30
> > >  - swap host1x and disp1 clock parents (as they should be)
> > >  - add clk_id_to_pll_id and clock_decode_pair helpers to use
> > >    dts deeper (in tegra clocks often go in pair child - parent)
> > >  - include PLLD setup in T30 (DISP1 may use it as parent on
> > >    some devices)
> > >  - fix Tegra PWM parent clock inline with linux
> > >  - Tegra SLINK: patch to accept any word length (unlike 8bit
> > >    aligned which was before)
> > >  - provide default USB gadget setup for existing Nvidia boards
> > >  - add late init function to be able to configure pre-boot stage
> > >    (like uncovering serial number or setting mac address)
> > >  - create common pre-dm i2c write for PMIC (used on T30 and T124
> > >    to configure basic PMIC voltages required to boot like cpu and
> > >    core voltages)
> > >  - expose crypto module for all Tegra SoCs and implement BCT patching
> > >    (ability to update bootloader from u-boot on production devices
> > >    without need in host PC)
> > >
> > > ---
> > > Changelog from v3
> > >  - added tested-by
> > >
> > > Changelog from v2
> > >  - fixed T114 TEGRA114_CLK_PLL_E_OUT0
> > >  - adjusted pre-dm i2c write commit description
> > >  - added description file for ebtupdate command
> > >  - minor improvements of bct.c comments
> > >
> > > Changelog from v1
> > >  - rebased to latest u-boot master
> > >  - PLLD setup for T30 moved specifically into T30 area
> > > ---
> > >
> > > Maxim Schwalm (1):
> > >   ARM: tegra: provide default USB gadget setup
> > >
> > > Ramin Khonsari (1):
> > >   ARM: tegra30: implement BCT patching
> > >
> > > Svyatoslav Ryhel (14):
> > >   tegra30: clock: add EXTPERIPH
> > >   ARM: t20/t30: swap host1x and disp1 clock parents
> > >   ARM: tegra: clock: add clk_id_to_pll_id helper
> > >   ARM: tegra: clock: add clock_decode_pair helper
> > >   ARM: tegra30: add PLLD to pll setup
> > >   ARM: tegra: Fix Tegra PWM parent clock
> > >   spi: tegra20_slink: accept any word length
> > >   ARM: tegra: add late init support
> > >   ARM: tegra: create common pre-dm i2c write
> > >   board: tegra124: switch to updated pre-dm i2c write
> > >   board: tegra30: switch to updated pre-dm i2c write
> > >   ARM: tegra: expose crypto module for all Tegra SoCs
> > >   ARM: tegra: crypto: extend crypto functional
> > >   ARM: tegra20: implement BCT patching
> > >
> > >  arch/arm/dts/tegra114.dtsi                    |  2 +-
> > >  arch/arm/dts/tegra124.dtsi                    |  2 +-
> > >  arch/arm/include/asm/arch-tegra/clock.h       | 21 +++++
> > >  arch/arm/include/asm/arch-tegra/crypto.h      | 47 ++++++++++
> > >  arch/arm/include/asm/arch-tegra/sys_proto.h   |  6 ++
> > >  arch/arm/include/asm/arch-tegra/tegra_i2c.h   | 17 ++++
> > >  .../include/asm/arch-tegra30/clock-tables.h   |  6 +-
> > >  arch/arm/mach-tegra/Kconfig                   | 14 +++
> > >  arch/arm/mach-tegra/Makefile                  |  1 +
> > >  arch/arm/mach-tegra/board2.c                  |  2 +
> > >  arch/arm/mach-tegra/clock.c                   | 23 +++++
> > >  arch/arm/mach-tegra/cpu.h                     |  1 -
> > >  arch/arm/mach-tegra/{tegra20 => }/crypto.c    | 63 +++++++++----
> > >  arch/arm/mach-tegra/tegra114/clock.c          | 39 +++++++-
> > >  arch/arm/mach-tegra/tegra124/clock.c          | 40 ++++++++-
> > >  arch/arm/mach-tegra/tegra124/cpu.c            |  4 +
> > >  arch/arm/mach-tegra/tegra20/Kconfig           |  1 +
> > >  arch/arm/mach-tegra/tegra20/Makefile          |  7 +-
> > >  arch/arm/mach-tegra/tegra20/bct.c             | 79 ++++++++++++++++
> > >  arch/arm/mach-tegra/tegra20/bct.h             | 42 +++++++++
> > >  arch/arm/mach-tegra/tegra20/clock.c           | 43 ++++++++-
> > >  arch/arm/mach-tegra/tegra20/crypto.h          | 19 ----
> > >  arch/arm/mach-tegra/tegra210/clock.c          | 39 +++++++-
> > >  arch/arm/mach-tegra/tegra30/Kconfig           |  8 --
> > >  arch/arm/mach-tegra/tegra30/Makefile          |  1 +
> > >  arch/arm/mach-tegra/tegra30/bct.c             | 79 ++++++++++++++++
> > >  arch/arm/mach-tegra/tegra30/bct.h             | 42 +++++++++
> > >  arch/arm/mach-tegra/tegra30/clock.c           | 90 +++++++++++++++++--
> > >  arch/arm/mach-tegra/tegra30/cpu.c             | 55 +-----------
> > >  board/avionic-design/tec-ng/Makefile          |  4 +-
> > >  board/avionic-design/tec-ng/tec-ng-spl.c      | 34 +++++++
> > >  board/nvidia/beaver/Makefile                  |  2 +
> > >  board/nvidia/beaver/beaver-spl.c              | 43 +++++++++
> > >  board/nvidia/cardhu/Makefile                  |  4 +-
> > >  board/nvidia/cardhu/cardhu-spl.c              | 43 +++++++++
> > >  board/nvidia/venice2/as3722_init.c            | 65 +++++++++-----
> > >  board/nvidia/venice2/as3722_init.h            | 43 ---------
> > >  board/toradex/apalis-tk1/as3722_init.c        | 85 ++++++++++--------
> > >  board/toradex/apalis-tk1/as3722_init.h        | 40 ---------
> > >  board/toradex/apalis_t30/Makefile             |  2 +
> > >  board/toradex/apalis_t30/apalis_t30-spl.c     | 34 +++++++
> > >  board/toradex/colibri_t30/Makefile            |  2 +
> > >  board/toradex/colibri_t30/colibri_t30-spl.c   | 34 +++++++
> > >  configs/beaver_defconfig                      |  3 -
> > >  configs/cei-tk1-som_defconfig                 |  3 -
> > >  configs/dalmore_defconfig                     |  3 -
> > >  configs/jetson-tk1_defconfig                  |  3 -
> > >  configs/nyan-big_defconfig                    |  3 -
> > >  configs/p2371-0000_defconfig                  |  3 -
> > >  configs/p2371-2180_defconfig                  |  3 -
> > >  configs/p2571_defconfig                       |  3 -
> > >  configs/p3450-0000_defconfig                  |  3 -
> > >  configs/venice2_defconfig                     |  3 -
> > >  doc/usage/cmd/ebtupdate.rst                   | 70 +++++++++++++++
> > >  drivers/pwm/tegra_pwm.c                       | 10 ++-
> > >  drivers/spi/tegra20_slink.c                   | 19 ++--
> > >  drivers/usb/gadget/Kconfig                    |  3 +
> > >  57 files changed, 1051 insertions(+), 309 deletions(-)  create mode
> > > 100644 arch/arm/include/asm/arch-tegra/crypto.h
> > >  rename arch/arm/mach-tegra/{tegra20 => }/crypto.c (68%)  create
> > > mode
> > > 100644 arch/arm/mach-tegra/tegra20/bct.c  create mode 100644
> > > arch/arm/mach-tegra/tegra20/bct.h  delete mode 100644
> > > arch/arm/mach-tegra/tegra20/crypto.h
> > >  create mode 100644 arch/arm/mach-tegra/tegra30/bct.c  create mode
> > > 100644 arch/arm/mach-tegra/tegra30/bct.h  create mode 100644
> > > board/avionic-design/tec-ng/tec-ng-spl.c
> > >  create mode 100644 board/nvidia/beaver/beaver-spl.c  create mode
> > > 100644 board/nvidia/cardhu/cardhu-spl.c  delete mode 100644
> > > board/nvidia/venice2/as3722_init.h
> > >  delete mode 100644 board/toradex/apalis-tk1/as3722_init.h
> > >  create mode 100644 board/toradex/apalis_t30/apalis_t30-spl.c
> > >  create mode 100644 board/toradex/colibri_t30/colibri_t30-spl.c
> > >  create mode 100644 doc/usage/cmd/ebtupdate.rst
> > >
> > > --
> > > 2.37.2
> > >

^ permalink raw reply	[flat|nested] 28+ messages in thread

* RE: [PATCH v4 00/16] General Tegra improvements
  2023-02-21  7:59             ` Svyatoslav Ryhel
@ 2023-02-21 16:09               ` Tom Warren
  2023-02-21 16:15                 ` Svyatoslav Ryhel
  0 siblings, 1 reply; 28+ messages in thread
From: Tom Warren @ 2023-02-21 16:09 UTC (permalink / raw)
  To: Svyatoslav Ryhel; +Cc: u-boot

Buildman ran fine on TOT u-boot-tegra/master rebased w/TOT u-boot/master on Friday. I'll send a PR today.

I'll look at merging your new DC 11-patch series later in the week. If we could get any ACKs/Tested-By/Reviewed-By's in ASAP that would be great.

Tom

-----Original Message-----
From: Svyatoslav Ryhel <clamor95@gmail.com> 
Sent: Tuesday, February 21, 2023 1:00 AM
To: Tom Warren <TWarren@nvidia.com>
Cc: u-boot@lists.denx.de
Subject: Re: [PATCH v4 00/16] General Tegra improvements

External email: Use caution opening links or attachments


Greetings! Did buildman run smoothly?

I have fixed DSI support and DC related patches are already sent.

Best regards,
Svyatoslav R.

пт, 17 лют. 2023 р. о 18:27 Tom Warren <TWarren@nvidia.com> пише:
>
> OK, now it's working fine on top of u-boot-tegra/master, and rebasing that result against u-boot/master TOT is fine, too. Sorry - don't know what I did wrong before.
> I'll run buildman on it and then get a PR out to TomR if it all looks good.
>
> Thanks!
>
> -----Original Message-----
> From: Tom Warren
> Sent: Friday, February 17, 2023 9:22 AM
> To: Svyatoslav Ryhel <clamor95@gmail.com>
> Cc: u-boot@lists.denx.de
> Subject: RE: [PATCH v4 00/16] General Tegra improvements
>
> OK, let me retry on u-boot-tegra/master.
>
> -----Original Message-----
> From: Svyatoslav Ryhel <clamor95@gmail.com>
> Sent: Friday, February 17, 2023 9:07 AM
> To: Tom Warren <TWarren@nvidia.com>
> Cc: u-boot@lists.denx.de
> Subject: Re: [PATCH v4 00/16] General Tegra improvements
>
> External email: Use caution opening links or attachments
>
>
> I was able to git am it on top of u-boot/master without any errors
>
> clamor@xeon:/media/clamor/work/u-boot$ git am 
> bundle-23303-Svyatoslav-16-v4.mbox
> Застосування: tegra30: clock: add EXTPERIPH
> Застосування: ARM: t20/t30: swap host1x and disp1 clock parents
> Застосування: ARM: tegra: clock: add clk_id_to_pll_id helper
> Застосування: ARM: tegra: clock: add clock_decode_pair helper
> Застосування: ARM: tegra30: add PLLD to pll setup
> Застосування: ARM: tegra: Fix Tegra PWM parent clock
> Застосування: spi: tegra20_slink: accept any word length
> Застосування: ARM: tegra: provide default USB gadget setup
> Застосування: ARM: tegra: add late init support
> Застосування: ARM: tegra: create common pre-dm i2c write
> Застосування: board: tegra124: switch to updated pre-dm i2c write
> Застосування: board: tegra30: switch to updated pre-dm i2c write
> Застосування: ARM: tegra: expose crypto module for all Tegra SoCs
> Застосування: ARM: tegra: crypto: extend crypto functional
> Застосування: ARM: tegra30: implement BCT patching
> Застосування: ARM: tegra20: implement BCT patching
> .git/rebase-apply/patch:249: new blank line at EOF.
> +
> warning: 1 рядок додав помилки в пробільних символах.
> clamor@xeon:/media/clamor/work/u-boot$
>
> пт, 17 лют. 2023 р. о 17:57 Tom Warren <TWarren@nvidia.com> пише:
> >
> > I've got a bundle with your 16 patches, created using PatchWork/U-Boot, and the patches are ordered correctly within that bundle. Attached here - see if it works for you.
> >
> > Tom
> >
> > -----Original Message-----
> > From: Svyatoslav Ryhel <clamor95@gmail.com>
> > Sent: Friday, February 17, 2023 1:39 AM
> > To: Tom Warren <TWarren@nvidia.com>
> > Cc: u-boot@lists.denx.de
> > Subject: Re: [PATCH v4 00/16] General Tegra improvements
> >
> > External email: Use caution opening links or attachments
> >
> >
> > You have NOT applied patch 13 ARM: tegra: expose crypto module for all Tegra SoCs or applied it after patch 14 which brakes order. PTAL.
> >
> > вт, 14 лют. 2023 р. о 23:45 Tom Warren <TWarren@nvidia.com> пише:
> > >
> > > <reducing audience>
> > >
> > > Svyatoslav,
> > >
> > > Taking TOT u-boot-tegra/master, and fast-forwarding to TOT u-boot/master, I then try to apply your 16 patch series and get the following failures (using patch). Note that I retargeted the crypto.c patch by hand to point to tegra20/crypto.c, which I believe one of your patches moves to arch/arm/tegra. PTAL.
> > >
> > > tom@tom-ThinkPad-T580:~/denx/uboot-tegra$ patch -p1 -i 
> > > ~/Downloads/bundle-23303-Svyatoslav-16-v4.mbox  --dry-run checking 
> > > file arch/arm/include/asm/arch-tegra30/clock-tables.h
> > > checking file arch/arm/mach-tegra/tegra30/clock.c
> > > checking file arch/arm/mach-tegra/tegra20/clock.c
> > > checking file arch/arm/mach-tegra/tegra30/clock.c
> > > checking file arch/arm/include/asm/arch-tegra/clock.h
> > > checking file arch/arm/mach-tegra/tegra114/clock.c
> > > checking file arch/arm/mach-tegra/tegra124/clock.c
> > > checking file arch/arm/mach-tegra/tegra20/clock.c
> > > checking file arch/arm/mach-tegra/tegra210/clock.c
> > > checking file arch/arm/mach-tegra/tegra30/clock.c
> > > checking file arch/arm/include/asm/arch-tegra/clock.h
> > > checking file arch/arm/mach-tegra/clock.c checking file 
> > > arch/arm/mach-tegra/tegra30/clock.c
> > > Hunk #1 succeeded at 632 (offset -37 lines).
> > > checking file arch/arm/dts/tegra114.dtsi checking file 
> > > arch/arm/dts/tegra124.dtsi checking file 
> > > arch/arm/mach-tegra/tegra114/clock.c
> > > Hunk #1 succeeded at 745 (offset -37 lines).
> > > checking file arch/arm/mach-tegra/tegra124/clock.c
> > > Hunk #1 succeeded at 1170 (offset -38 lines).
> > > checking file arch/arm/mach-tegra/tegra20/clock.c
> > > Hunk #1 succeeded at 767 (offset -37 lines).
> > > checking file arch/arm/mach-tegra/tegra210/clock.c
> > > Hunk #1 succeeded at 1241 (offset -37 lines).
> > > checking file arch/arm/mach-tegra/tegra30/clock.c
> > > Hunk #1 succeeded at 806 (offset -78 lines).
> > > checking file drivers/pwm/tegra_pwm.c checking file 
> > > drivers/spi/tegra20_slink.c checking file configs/beaver_defconfig 
> > > checking file configs/cei-tk1-som_defconfig checking file 
> > > configs/dalmore_defconfig checking file 
> > > configs/jetson-tk1_defconfig checking file 
> > > configs/nyan-big_defconfig checking file 
> > > configs/p2371-0000_defconfig checking file 
> > > configs/p2371-2180_defconfig checking file configs/p2571_defconfig 
> > > checking file configs/p3450-0000_defconfig checking file 
> > > configs/venice2_defconfig checking file drivers/usb/gadget/Kconfig 
> > > checking file arch/arm/include/asm/arch-tegra/sys_proto.h
> > > checking file arch/arm/mach-tegra/board2.c checking file 
> > > arch/arm/include/asm/arch-tegra/tegra_i2c.h
> > > checking file arch/arm/mach-tegra/cpu.h checking file 
> > > arch/arm/mach-tegra/tegra124/cpu.c
> > > checking file arch/arm/mach-tegra/tegra30/cpu.c checking file 
> > > board/nvidia/venice2/as3722_init.c
> > > checking file board/nvidia/venice2/as3722_init.h
> > > checking file board/toradex/apalis-tk1/as3722_init.c
> > > checking file board/toradex/apalis-tk1/as3722_init.h
> > > checking file arch/arm/mach-tegra/tegra30/Kconfig
> > > checking file arch/arm/mach-tegra/tegra30/cpu.c Hunk #1 FAILED at 15.
> > > Hunk #2 FAILED at 41.
> > > 2 out of 2 hunks FAILED
> > > checking file board/avionic-design/tec-ng/Makefile
> > > checking file board/avionic-design/tec-ng/tec-ng-spl.c
> > > checking file board/nvidia/beaver/Makefile checking file 
> > > board/nvidia/beaver/beaver-spl.c checking file 
> > > board/nvidia/cardhu/Makefile checking file 
> > > board/nvidia/cardhu/cardhu-spl.c checking file 
> > > board/toradex/apalis_t30/Makefile checking file 
> > > board/toradex/apalis_t30/apalis_t30-spl.c
> > > checking file board/toradex/colibri_t30/Makefile
> > > checking file board/toradex/colibri_t30/colibri_t30-spl.c
> > > checking file arch/arm/mach-tegra/Kconfig checking file 
> > > arch/arm/mach-tegra/Makefile checking file 
> > > arch/arm/mach-tegra/crypto.c (renamed from
> > > arch/arm/mach-tegra/tegra20/crypto.c)
> > > checking file arch/arm/mach-tegra/crypto.h (renamed from
> > > arch/arm/mach-tegra/tegra20/crypto.h)
> > > checking file arch/arm/mach-tegra/tegra20/Kconfig
> > > checking file arch/arm/mach-tegra/tegra20/Makefile
> > > checking file arch/arm/include/asm/arch-tegra/crypto.h
> > > can't find file to patch at input line 3811 Perhaps you used the 
> > > wrong -p or --strip option?
> > > The text leading up to this was:
> > > --------------------------
> > > |diff --git a/arch/arm/mach-tegra/crypto.c 
> > > |b/arch/arm/mach-tegra/crypto.c index 1efaa5c3ec..893da35e0b 
> > > |100644
> > > |--- a/arch/arm/mach-tegra/crypto.c
> > > |+++ b/arch/arm/mach-tegra/crypto.c
> > > --------------------------
> > > File to patch: arch/arm/mach-tegra/tegra20/crypto.c
> > > checking file arch/arm/mach-tegra/tegra20/crypto.c
> > > The next patch would delete the file arch/arm/mach-tegra/crypto.h, 
> > > which does not exist!  Assume -R? [n] Apply anyway? [n] Skipping 
> > > patch.
> > > 1 out of 1 hunk ignored
> > > checking file arch/arm/mach-tegra/Kconfig Hunk #1 succeeded at 224 
> > > (offset -5 lines).
> > > checking file arch/arm/mach-tegra/tegra30/Makefile
> > > checking file arch/arm/mach-tegra/tegra30/bct.c checking file 
> > > arch/arm/mach-tegra/tegra30/bct.h checking file 
> > > arch/arm/mach-tegra/Kconfig Hunk #1 FAILED at 231.
> > > 1 out of 1 hunk FAILED
> > > checking file arch/arm/mach-tegra/tegra20/Makefile
> > > checking file arch/arm/mach-tegra/tegra20/bct.c checking file 
> > > arch/arm/mach-tegra/tegra20/bct.h checking file 
> > > doc/usage/cmd/ebtupdate.rst 
> > > tom@tom-ThinkPad-T580:~/denx/uboot-tegra$
> > >
> > > -----Original Message-----
> > > From: Svyatoslav Ryhel <clamor95@gmail.com>
> > > Sent: Tuesday, February 14, 2023 10:35 AM
> > > To: Tom Warren <twarren@nvidia.com>; Marcel Ziswiler 
> > > <marcel.ziswiler@toradex.com>; Allen Martin <amartin@nvidia.com>; 
> > > Jagan Teki <jagan@amarulasolutions.com>; Lukasz Majewski 
> > > <lukma@denx.de>; Marek Vasut <marex@denx.de>; Svyatoslav Ryhel 
> > > <clamor95@gmail.com>; Ramin Khonsari <raminterex@yahoo.com>; 
> > > Thierry Reding <thierry.reding@gmail.com>; Maxim Schwalm 
> > > <maxim.schwalm@gmail.com>; Dmitry Osipenko <digetx@gmail.com>; 
> > > Simon Glass <sjg@chromium.org>
> > > Cc: u-boot@lists.denx.de
> > > Subject: [PATCH v4 00/16] General Tegra improvements
> > >
> > > External email: Use caution opening links or attachments
> > >
> > >
> > > List of changes in patch set:
> > >  - add missing EXTPERIPH clocks for t30
> > >  - swap host1x and disp1 clock parents (as they should be)
> > >  - add clk_id_to_pll_id and clock_decode_pair helpers to use
> > >    dts deeper (in tegra clocks often go in pair child - parent)
> > >  - include PLLD setup in T30 (DISP1 may use it as parent on
> > >    some devices)
> > >  - fix Tegra PWM parent clock inline with linux
> > >  - Tegra SLINK: patch to accept any word length (unlike 8bit
> > >    aligned which was before)
> > >  - provide default USB gadget setup for existing Nvidia boards
> > >  - add late init function to be able to configure pre-boot stage
> > >    (like uncovering serial number or setting mac address)
> > >  - create common pre-dm i2c write for PMIC (used on T30 and T124
> > >    to configure basic PMIC voltages required to boot like cpu and
> > >    core voltages)
> > >  - expose crypto module for all Tegra SoCs and implement BCT patching
> > >    (ability to update bootloader from u-boot on production devices
> > >    without need in host PC)
> > >
> > > ---
> > > Changelog from v3
> > >  - added tested-by
> > >
> > > Changelog from v2
> > >  - fixed T114 TEGRA114_CLK_PLL_E_OUT0
> > >  - adjusted pre-dm i2c write commit description
> > >  - added description file for ebtupdate command
> > >  - minor improvements of bct.c comments
> > >
> > > Changelog from v1
> > >  - rebased to latest u-boot master
> > >  - PLLD setup for T30 moved specifically into T30 area
> > > ---
> > >
> > > Maxim Schwalm (1):
> > >   ARM: tegra: provide default USB gadget setup
> > >
> > > Ramin Khonsari (1):
> > >   ARM: tegra30: implement BCT patching
> > >
> > > Svyatoslav Ryhel (14):
> > >   tegra30: clock: add EXTPERIPH
> > >   ARM: t20/t30: swap host1x and disp1 clock parents
> > >   ARM: tegra: clock: add clk_id_to_pll_id helper
> > >   ARM: tegra: clock: add clock_decode_pair helper
> > >   ARM: tegra30: add PLLD to pll setup
> > >   ARM: tegra: Fix Tegra PWM parent clock
> > >   spi: tegra20_slink: accept any word length
> > >   ARM: tegra: add late init support
> > >   ARM: tegra: create common pre-dm i2c write
> > >   board: tegra124: switch to updated pre-dm i2c write
> > >   board: tegra30: switch to updated pre-dm i2c write
> > >   ARM: tegra: expose crypto module for all Tegra SoCs
> > >   ARM: tegra: crypto: extend crypto functional
> > >   ARM: tegra20: implement BCT patching
> > >
> > >  arch/arm/dts/tegra114.dtsi                    |  2 +-
> > >  arch/arm/dts/tegra124.dtsi                    |  2 +-
> > >  arch/arm/include/asm/arch-tegra/clock.h       | 21 +++++
> > >  arch/arm/include/asm/arch-tegra/crypto.h      | 47 ++++++++++
> > >  arch/arm/include/asm/arch-tegra/sys_proto.h   |  6 ++
> > >  arch/arm/include/asm/arch-tegra/tegra_i2c.h   | 17 ++++
> > >  .../include/asm/arch-tegra30/clock-tables.h   |  6 +-
> > >  arch/arm/mach-tegra/Kconfig                   | 14 +++
> > >  arch/arm/mach-tegra/Makefile                  |  1 +
> > >  arch/arm/mach-tegra/board2.c                  |  2 +
> > >  arch/arm/mach-tegra/clock.c                   | 23 +++++
> > >  arch/arm/mach-tegra/cpu.h                     |  1 -
> > >  arch/arm/mach-tegra/{tegra20 => }/crypto.c    | 63 +++++++++----
> > >  arch/arm/mach-tegra/tegra114/clock.c          | 39 +++++++-
> > >  arch/arm/mach-tegra/tegra124/clock.c          | 40 ++++++++-
> > >  arch/arm/mach-tegra/tegra124/cpu.c            |  4 +
> > >  arch/arm/mach-tegra/tegra20/Kconfig           |  1 +
> > >  arch/arm/mach-tegra/tegra20/Makefile          |  7 +-
> > >  arch/arm/mach-tegra/tegra20/bct.c             | 79 ++++++++++++++++
> > >  arch/arm/mach-tegra/tegra20/bct.h             | 42 +++++++++
> > >  arch/arm/mach-tegra/tegra20/clock.c           | 43 ++++++++-
> > >  arch/arm/mach-tegra/tegra20/crypto.h          | 19 ----
> > >  arch/arm/mach-tegra/tegra210/clock.c          | 39 +++++++-
> > >  arch/arm/mach-tegra/tegra30/Kconfig           |  8 --
> > >  arch/arm/mach-tegra/tegra30/Makefile          |  1 +
> > >  arch/arm/mach-tegra/tegra30/bct.c             | 79 ++++++++++++++++
> > >  arch/arm/mach-tegra/tegra30/bct.h             | 42 +++++++++
> > >  arch/arm/mach-tegra/tegra30/clock.c           | 90 +++++++++++++++++--
> > >  arch/arm/mach-tegra/tegra30/cpu.c             | 55 +-----------
> > >  board/avionic-design/tec-ng/Makefile          |  4 +-
> > >  board/avionic-design/tec-ng/tec-ng-spl.c      | 34 +++++++
> > >  board/nvidia/beaver/Makefile                  |  2 +
> > >  board/nvidia/beaver/beaver-spl.c              | 43 +++++++++
> > >  board/nvidia/cardhu/Makefile                  |  4 +-
> > >  board/nvidia/cardhu/cardhu-spl.c              | 43 +++++++++
> > >  board/nvidia/venice2/as3722_init.c            | 65 +++++++++-----
> > >  board/nvidia/venice2/as3722_init.h            | 43 ---------
> > >  board/toradex/apalis-tk1/as3722_init.c        | 85 ++++++++++--------
> > >  board/toradex/apalis-tk1/as3722_init.h        | 40 ---------
> > >  board/toradex/apalis_t30/Makefile             |  2 +
> > >  board/toradex/apalis_t30/apalis_t30-spl.c     | 34 +++++++
> > >  board/toradex/colibri_t30/Makefile            |  2 +
> > >  board/toradex/colibri_t30/colibri_t30-spl.c   | 34 +++++++
> > >  configs/beaver_defconfig                      |  3 -
> > >  configs/cei-tk1-som_defconfig                 |  3 -
> > >  configs/dalmore_defconfig                     |  3 -
> > >  configs/jetson-tk1_defconfig                  |  3 -
> > >  configs/nyan-big_defconfig                    |  3 -
> > >  configs/p2371-0000_defconfig                  |  3 -
> > >  configs/p2371-2180_defconfig                  |  3 -
> > >  configs/p2571_defconfig                       |  3 -
> > >  configs/p3450-0000_defconfig                  |  3 -
> > >  configs/venice2_defconfig                     |  3 -
> > >  doc/usage/cmd/ebtupdate.rst                   | 70 +++++++++++++++
> > >  drivers/pwm/tegra_pwm.c                       | 10 ++-
> > >  drivers/spi/tegra20_slink.c                   | 19 ++--
> > >  drivers/usb/gadget/Kconfig                    |  3 +
> > >  57 files changed, 1051 insertions(+), 309 deletions(-)  create 
> > > mode
> > > 100644 arch/arm/include/asm/arch-tegra/crypto.h
> > >  rename arch/arm/mach-tegra/{tegra20 => }/crypto.c (68%)  create 
> > > mode
> > > 100644 arch/arm/mach-tegra/tegra20/bct.c  create mode 100644 
> > > arch/arm/mach-tegra/tegra20/bct.h  delete mode 100644 
> > > arch/arm/mach-tegra/tegra20/crypto.h
> > >  create mode 100644 arch/arm/mach-tegra/tegra30/bct.c  create mode
> > > 100644 arch/arm/mach-tegra/tegra30/bct.h  create mode 100644 
> > > board/avionic-design/tec-ng/tec-ng-spl.c
> > >  create mode 100644 board/nvidia/beaver/beaver-spl.c  create mode
> > > 100644 board/nvidia/cardhu/cardhu-spl.c  delete mode 100644 
> > > board/nvidia/venice2/as3722_init.h
> > >  delete mode 100644 board/toradex/apalis-tk1/as3722_init.h
> > >  create mode 100644 board/toradex/apalis_t30/apalis_t30-spl.c
> > >  create mode 100644 board/toradex/colibri_t30/colibri_t30-spl.c
> > >  create mode 100644 doc/usage/cmd/ebtupdate.rst
> > >
> > > --
> > > 2.37.2
> > >

^ permalink raw reply	[flat|nested] 28+ messages in thread

* Re: [PATCH v4 00/16] General Tegra improvements
  2023-02-21 16:09               ` Tom Warren
@ 2023-02-21 16:15                 ` Svyatoslav Ryhel
  0 siblings, 0 replies; 28+ messages in thread
From: Svyatoslav Ryhel @ 2023-02-21 16:15 UTC (permalink / raw)
  To: Tom Warren; +Cc: u-boot

Thanks in advance!

I would love to get any ACKs/Tested-By/Reviewed-By's but most likely
no one, apart from the Transformers community and me, relies so much
on display drivers in u-boot. Most likely this is why it was barely
set and only for T20.

Best regards,
Svyatoslav R.

вт, 21 лют. 2023 р. о 18:09 Tom Warren <TWarren@nvidia.com> пише:
>
> Buildman ran fine on TOT u-boot-tegra/master rebased w/TOT u-boot/master on Friday. I'll send a PR today.
>
> I'll look at merging your new DC 11-patch series later in the week. If we could get any ACKs/Tested-By/Reviewed-By's in ASAP that would be great.
>
> Tom
>
> -----Original Message-----
> From: Svyatoslav Ryhel <clamor95@gmail.com>
> Sent: Tuesday, February 21, 2023 1:00 AM
> To: Tom Warren <TWarren@nvidia.com>
> Cc: u-boot@lists.denx.de
> Subject: Re: [PATCH v4 00/16] General Tegra improvements
>
> External email: Use caution opening links or attachments
>
>
> Greetings! Did buildman run smoothly?
>
> I have fixed DSI support and DC related patches are already sent.
>
> Best regards,
> Svyatoslav R.
>
> пт, 17 лют. 2023 р. о 18:27 Tom Warren <TWarren@nvidia.com> пише:
> >
> > OK, now it's working fine on top of u-boot-tegra/master, and rebasing that result against u-boot/master TOT is fine, too. Sorry - don't know what I did wrong before.
> > I'll run buildman on it and then get a PR out to TomR if it all looks good.
> >
> > Thanks!
> >
> > -----Original Message-----
> > From: Tom Warren
> > Sent: Friday, February 17, 2023 9:22 AM
> > To: Svyatoslav Ryhel <clamor95@gmail.com>
> > Cc: u-boot@lists.denx.de
> > Subject: RE: [PATCH v4 00/16] General Tegra improvements
> >
> > OK, let me retry on u-boot-tegra/master.
> >
> > -----Original Message-----
> > From: Svyatoslav Ryhel <clamor95@gmail.com>
> > Sent: Friday, February 17, 2023 9:07 AM
> > To: Tom Warren <TWarren@nvidia.com>
> > Cc: u-boot@lists.denx.de
> > Subject: Re: [PATCH v4 00/16] General Tegra improvements
> >
> > External email: Use caution opening links or attachments
> >
> >
> > I was able to git am it on top of u-boot/master without any errors
> >
> > clamor@xeon:/media/clamor/work/u-boot$ git am
> > bundle-23303-Svyatoslav-16-v4.mbox
> > Застосування: tegra30: clock: add EXTPERIPH
> > Застосування: ARM: t20/t30: swap host1x and disp1 clock parents
> > Застосування: ARM: tegra: clock: add clk_id_to_pll_id helper
> > Застосування: ARM: tegra: clock: add clock_decode_pair helper
> > Застосування: ARM: tegra30: add PLLD to pll setup
> > Застосування: ARM: tegra: Fix Tegra PWM parent clock
> > Застосування: spi: tegra20_slink: accept any word length
> > Застосування: ARM: tegra: provide default USB gadget setup
> > Застосування: ARM: tegra: add late init support
> > Застосування: ARM: tegra: create common pre-dm i2c write
> > Застосування: board: tegra124: switch to updated pre-dm i2c write
> > Застосування: board: tegra30: switch to updated pre-dm i2c write
> > Застосування: ARM: tegra: expose crypto module for all Tegra SoCs
> > Застосування: ARM: tegra: crypto: extend crypto functional
> > Застосування: ARM: tegra30: implement BCT patching
> > Застосування: ARM: tegra20: implement BCT patching
> > .git/rebase-apply/patch:249: new blank line at EOF.
> > +
> > warning: 1 рядок додав помилки в пробільних символах.
> > clamor@xeon:/media/clamor/work/u-boot$
> >
> > пт, 17 лют. 2023 р. о 17:57 Tom Warren <TWarren@nvidia.com> пише:
> > >
> > > I've got a bundle with your 16 patches, created using PatchWork/U-Boot, and the patches are ordered correctly within that bundle. Attached here - see if it works for you.
> > >
> > > Tom
> > >
> > > -----Original Message-----
> > > From: Svyatoslav Ryhel <clamor95@gmail.com>
> > > Sent: Friday, February 17, 2023 1:39 AM
> > > To: Tom Warren <TWarren@nvidia.com>
> > > Cc: u-boot@lists.denx.de
> > > Subject: Re: [PATCH v4 00/16] General Tegra improvements
> > >
> > > External email: Use caution opening links or attachments
> > >
> > >
> > > You have NOT applied patch 13 ARM: tegra: expose crypto module for all Tegra SoCs or applied it after patch 14 which brakes order. PTAL.
> > >
> > > вт, 14 лют. 2023 р. о 23:45 Tom Warren <TWarren@nvidia.com> пише:
> > > >
> > > > <reducing audience>
> > > >
> > > > Svyatoslav,
> > > >
> > > > Taking TOT u-boot-tegra/master, and fast-forwarding to TOT u-boot/master, I then try to apply your 16 patch series and get the following failures (using patch). Note that I retargeted the crypto.c patch by hand to point to tegra20/crypto.c, which I believe one of your patches moves to arch/arm/tegra. PTAL.
> > > >
> > > > tom@tom-ThinkPad-T580:~/denx/uboot-tegra$ patch -p1 -i
> > > > ~/Downloads/bundle-23303-Svyatoslav-16-v4.mbox  --dry-run checking
> > > > file arch/arm/include/asm/arch-tegra30/clock-tables.h
> > > > checking file arch/arm/mach-tegra/tegra30/clock.c
> > > > checking file arch/arm/mach-tegra/tegra20/clock.c
> > > > checking file arch/arm/mach-tegra/tegra30/clock.c
> > > > checking file arch/arm/include/asm/arch-tegra/clock.h
> > > > checking file arch/arm/mach-tegra/tegra114/clock.c
> > > > checking file arch/arm/mach-tegra/tegra124/clock.c
> > > > checking file arch/arm/mach-tegra/tegra20/clock.c
> > > > checking file arch/arm/mach-tegra/tegra210/clock.c
> > > > checking file arch/arm/mach-tegra/tegra30/clock.c
> > > > checking file arch/arm/include/asm/arch-tegra/clock.h
> > > > checking file arch/arm/mach-tegra/clock.c checking file
> > > > arch/arm/mach-tegra/tegra30/clock.c
> > > > Hunk #1 succeeded at 632 (offset -37 lines).
> > > > checking file arch/arm/dts/tegra114.dtsi checking file
> > > > arch/arm/dts/tegra124.dtsi checking file
> > > > arch/arm/mach-tegra/tegra114/clock.c
> > > > Hunk #1 succeeded at 745 (offset -37 lines).
> > > > checking file arch/arm/mach-tegra/tegra124/clock.c
> > > > Hunk #1 succeeded at 1170 (offset -38 lines).
> > > > checking file arch/arm/mach-tegra/tegra20/clock.c
> > > > Hunk #1 succeeded at 767 (offset -37 lines).
> > > > checking file arch/arm/mach-tegra/tegra210/clock.c
> > > > Hunk #1 succeeded at 1241 (offset -37 lines).
> > > > checking file arch/arm/mach-tegra/tegra30/clock.c
> > > > Hunk #1 succeeded at 806 (offset -78 lines).
> > > > checking file drivers/pwm/tegra_pwm.c checking file
> > > > drivers/spi/tegra20_slink.c checking file configs/beaver_defconfig
> > > > checking file configs/cei-tk1-som_defconfig checking file
> > > > configs/dalmore_defconfig checking file
> > > > configs/jetson-tk1_defconfig checking file
> > > > configs/nyan-big_defconfig checking file
> > > > configs/p2371-0000_defconfig checking file
> > > > configs/p2371-2180_defconfig checking file configs/p2571_defconfig
> > > > checking file configs/p3450-0000_defconfig checking file
> > > > configs/venice2_defconfig checking file drivers/usb/gadget/Kconfig
> > > > checking file arch/arm/include/asm/arch-tegra/sys_proto.h
> > > > checking file arch/arm/mach-tegra/board2.c checking file
> > > > arch/arm/include/asm/arch-tegra/tegra_i2c.h
> > > > checking file arch/arm/mach-tegra/cpu.h checking file
> > > > arch/arm/mach-tegra/tegra124/cpu.c
> > > > checking file arch/arm/mach-tegra/tegra30/cpu.c checking file
> > > > board/nvidia/venice2/as3722_init.c
> > > > checking file board/nvidia/venice2/as3722_init.h
> > > > checking file board/toradex/apalis-tk1/as3722_init.c
> > > > checking file board/toradex/apalis-tk1/as3722_init.h
> > > > checking file arch/arm/mach-tegra/tegra30/Kconfig
> > > > checking file arch/arm/mach-tegra/tegra30/cpu.c Hunk #1 FAILED at 15.
> > > > Hunk #2 FAILED at 41.
> > > > 2 out of 2 hunks FAILED
> > > > checking file board/avionic-design/tec-ng/Makefile
> > > > checking file board/avionic-design/tec-ng/tec-ng-spl.c
> > > > checking file board/nvidia/beaver/Makefile checking file
> > > > board/nvidia/beaver/beaver-spl.c checking file
> > > > board/nvidia/cardhu/Makefile checking file
> > > > board/nvidia/cardhu/cardhu-spl.c checking file
> > > > board/toradex/apalis_t30/Makefile checking file
> > > > board/toradex/apalis_t30/apalis_t30-spl.c
> > > > checking file board/toradex/colibri_t30/Makefile
> > > > checking file board/toradex/colibri_t30/colibri_t30-spl.c
> > > > checking file arch/arm/mach-tegra/Kconfig checking file
> > > > arch/arm/mach-tegra/Makefile checking file
> > > > arch/arm/mach-tegra/crypto.c (renamed from
> > > > arch/arm/mach-tegra/tegra20/crypto.c)
> > > > checking file arch/arm/mach-tegra/crypto.h (renamed from
> > > > arch/arm/mach-tegra/tegra20/crypto.h)
> > > > checking file arch/arm/mach-tegra/tegra20/Kconfig
> > > > checking file arch/arm/mach-tegra/tegra20/Makefile
> > > > checking file arch/arm/include/asm/arch-tegra/crypto.h
> > > > can't find file to patch at input line 3811 Perhaps you used the
> > > > wrong -p or --strip option?
> > > > The text leading up to this was:
> > > > --------------------------
> > > > |diff --git a/arch/arm/mach-tegra/crypto.c
> > > > |b/arch/arm/mach-tegra/crypto.c index 1efaa5c3ec..893da35e0b
> > > > |100644
> > > > |--- a/arch/arm/mach-tegra/crypto.c
> > > > |+++ b/arch/arm/mach-tegra/crypto.c
> > > > --------------------------
> > > > File to patch: arch/arm/mach-tegra/tegra20/crypto.c
> > > > checking file arch/arm/mach-tegra/tegra20/crypto.c
> > > > The next patch would delete the file arch/arm/mach-tegra/crypto.h,
> > > > which does not exist!  Assume -R? [n] Apply anyway? [n] Skipping
> > > > patch.
> > > > 1 out of 1 hunk ignored
> > > > checking file arch/arm/mach-tegra/Kconfig Hunk #1 succeeded at 224
> > > > (offset -5 lines).
> > > > checking file arch/arm/mach-tegra/tegra30/Makefile
> > > > checking file arch/arm/mach-tegra/tegra30/bct.c checking file
> > > > arch/arm/mach-tegra/tegra30/bct.h checking file
> > > > arch/arm/mach-tegra/Kconfig Hunk #1 FAILED at 231.
> > > > 1 out of 1 hunk FAILED
> > > > checking file arch/arm/mach-tegra/tegra20/Makefile
> > > > checking file arch/arm/mach-tegra/tegra20/bct.c checking file
> > > > arch/arm/mach-tegra/tegra20/bct.h checking file
> > > > doc/usage/cmd/ebtupdate.rst
> > > > tom@tom-ThinkPad-T580:~/denx/uboot-tegra$
> > > >
> > > > -----Original Message-----
> > > > From: Svyatoslav Ryhel <clamor95@gmail.com>
> > > > Sent: Tuesday, February 14, 2023 10:35 AM
> > > > To: Tom Warren <twarren@nvidia.com>; Marcel Ziswiler
> > > > <marcel.ziswiler@toradex.com>; Allen Martin <amartin@nvidia.com>;
> > > > Jagan Teki <jagan@amarulasolutions.com>; Lukasz Majewski
> > > > <lukma@denx.de>; Marek Vasut <marex@denx.de>; Svyatoslav Ryhel
> > > > <clamor95@gmail.com>; Ramin Khonsari <raminterex@yahoo.com>;
> > > > Thierry Reding <thierry.reding@gmail.com>; Maxim Schwalm
> > > > <maxim.schwalm@gmail.com>; Dmitry Osipenko <digetx@gmail.com>;
> > > > Simon Glass <sjg@chromium.org>
> > > > Cc: u-boot@lists.denx.de
> > > > Subject: [PATCH v4 00/16] General Tegra improvements
> > > >
> > > > External email: Use caution opening links or attachments
> > > >
> > > >
> > > > List of changes in patch set:
> > > >  - add missing EXTPERIPH clocks for t30
> > > >  - swap host1x and disp1 clock parents (as they should be)
> > > >  - add clk_id_to_pll_id and clock_decode_pair helpers to use
> > > >    dts deeper (in tegra clocks often go in pair child - parent)
> > > >  - include PLLD setup in T30 (DISP1 may use it as parent on
> > > >    some devices)
> > > >  - fix Tegra PWM parent clock inline with linux
> > > >  - Tegra SLINK: patch to accept any word length (unlike 8bit
> > > >    aligned which was before)
> > > >  - provide default USB gadget setup for existing Nvidia boards
> > > >  - add late init function to be able to configure pre-boot stage
> > > >    (like uncovering serial number or setting mac address)
> > > >  - create common pre-dm i2c write for PMIC (used on T30 and T124
> > > >    to configure basic PMIC voltages required to boot like cpu and
> > > >    core voltages)
> > > >  - expose crypto module for all Tegra SoCs and implement BCT patching
> > > >    (ability to update bootloader from u-boot on production devices
> > > >    without need in host PC)
> > > >
> > > > ---
> > > > Changelog from v3
> > > >  - added tested-by
> > > >
> > > > Changelog from v2
> > > >  - fixed T114 TEGRA114_CLK_PLL_E_OUT0
> > > >  - adjusted pre-dm i2c write commit description
> > > >  - added description file for ebtupdate command
> > > >  - minor improvements of bct.c comments
> > > >
> > > > Changelog from v1
> > > >  - rebased to latest u-boot master
> > > >  - PLLD setup for T30 moved specifically into T30 area
> > > > ---
> > > >
> > > > Maxim Schwalm (1):
> > > >   ARM: tegra: provide default USB gadget setup
> > > >
> > > > Ramin Khonsari (1):
> > > >   ARM: tegra30: implement BCT patching
> > > >
> > > > Svyatoslav Ryhel (14):
> > > >   tegra30: clock: add EXTPERIPH
> > > >   ARM: t20/t30: swap host1x and disp1 clock parents
> > > >   ARM: tegra: clock: add clk_id_to_pll_id helper
> > > >   ARM: tegra: clock: add clock_decode_pair helper
> > > >   ARM: tegra30: add PLLD to pll setup
> > > >   ARM: tegra: Fix Tegra PWM parent clock
> > > >   spi: tegra20_slink: accept any word length
> > > >   ARM: tegra: add late init support
> > > >   ARM: tegra: create common pre-dm i2c write
> > > >   board: tegra124: switch to updated pre-dm i2c write
> > > >   board: tegra30: switch to updated pre-dm i2c write
> > > >   ARM: tegra: expose crypto module for all Tegra SoCs
> > > >   ARM: tegra: crypto: extend crypto functional
> > > >   ARM: tegra20: implement BCT patching
> > > >
> > > >  arch/arm/dts/tegra114.dtsi                    |  2 +-
> > > >  arch/arm/dts/tegra124.dtsi                    |  2 +-
> > > >  arch/arm/include/asm/arch-tegra/clock.h       | 21 +++++
> > > >  arch/arm/include/asm/arch-tegra/crypto.h      | 47 ++++++++++
> > > >  arch/arm/include/asm/arch-tegra/sys_proto.h   |  6 ++
> > > >  arch/arm/include/asm/arch-tegra/tegra_i2c.h   | 17 ++++
> > > >  .../include/asm/arch-tegra30/clock-tables.h   |  6 +-
> > > >  arch/arm/mach-tegra/Kconfig                   | 14 +++
> > > >  arch/arm/mach-tegra/Makefile                  |  1 +
> > > >  arch/arm/mach-tegra/board2.c                  |  2 +
> > > >  arch/arm/mach-tegra/clock.c                   | 23 +++++
> > > >  arch/arm/mach-tegra/cpu.h                     |  1 -
> > > >  arch/arm/mach-tegra/{tegra20 => }/crypto.c    | 63 +++++++++----
> > > >  arch/arm/mach-tegra/tegra114/clock.c          | 39 +++++++-
> > > >  arch/arm/mach-tegra/tegra124/clock.c          | 40 ++++++++-
> > > >  arch/arm/mach-tegra/tegra124/cpu.c            |  4 +
> > > >  arch/arm/mach-tegra/tegra20/Kconfig           |  1 +
> > > >  arch/arm/mach-tegra/tegra20/Makefile          |  7 +-
> > > >  arch/arm/mach-tegra/tegra20/bct.c             | 79 ++++++++++++++++
> > > >  arch/arm/mach-tegra/tegra20/bct.h             | 42 +++++++++
> > > >  arch/arm/mach-tegra/tegra20/clock.c           | 43 ++++++++-
> > > >  arch/arm/mach-tegra/tegra20/crypto.h          | 19 ----
> > > >  arch/arm/mach-tegra/tegra210/clock.c          | 39 +++++++-
> > > >  arch/arm/mach-tegra/tegra30/Kconfig           |  8 --
> > > >  arch/arm/mach-tegra/tegra30/Makefile          |  1 +
> > > >  arch/arm/mach-tegra/tegra30/bct.c             | 79 ++++++++++++++++
> > > >  arch/arm/mach-tegra/tegra30/bct.h             | 42 +++++++++
> > > >  arch/arm/mach-tegra/tegra30/clock.c           | 90 +++++++++++++++++--
> > > >  arch/arm/mach-tegra/tegra30/cpu.c             | 55 +-----------
> > > >  board/avionic-design/tec-ng/Makefile          |  4 +-
> > > >  board/avionic-design/tec-ng/tec-ng-spl.c      | 34 +++++++
> > > >  board/nvidia/beaver/Makefile                  |  2 +
> > > >  board/nvidia/beaver/beaver-spl.c              | 43 +++++++++
> > > >  board/nvidia/cardhu/Makefile                  |  4 +-
> > > >  board/nvidia/cardhu/cardhu-spl.c              | 43 +++++++++
> > > >  board/nvidia/venice2/as3722_init.c            | 65 +++++++++-----
> > > >  board/nvidia/venice2/as3722_init.h            | 43 ---------
> > > >  board/toradex/apalis-tk1/as3722_init.c        | 85 ++++++++++--------
> > > >  board/toradex/apalis-tk1/as3722_init.h        | 40 ---------
> > > >  board/toradex/apalis_t30/Makefile             |  2 +
> > > >  board/toradex/apalis_t30/apalis_t30-spl.c     | 34 +++++++
> > > >  board/toradex/colibri_t30/Makefile            |  2 +
> > > >  board/toradex/colibri_t30/colibri_t30-spl.c   | 34 +++++++
> > > >  configs/beaver_defconfig                      |  3 -
> > > >  configs/cei-tk1-som_defconfig                 |  3 -
> > > >  configs/dalmore_defconfig                     |  3 -
> > > >  configs/jetson-tk1_defconfig                  |  3 -
> > > >  configs/nyan-big_defconfig                    |  3 -
> > > >  configs/p2371-0000_defconfig                  |  3 -
> > > >  configs/p2371-2180_defconfig                  |  3 -
> > > >  configs/p2571_defconfig                       |  3 -
> > > >  configs/p3450-0000_defconfig                  |  3 -
> > > >  configs/venice2_defconfig                     |  3 -
> > > >  doc/usage/cmd/ebtupdate.rst                   | 70 +++++++++++++++
> > > >  drivers/pwm/tegra_pwm.c                       | 10 ++-
> > > >  drivers/spi/tegra20_slink.c                   | 19 ++--
> > > >  drivers/usb/gadget/Kconfig                    |  3 +
> > > >  57 files changed, 1051 insertions(+), 309 deletions(-)  create
> > > > mode
> > > > 100644 arch/arm/include/asm/arch-tegra/crypto.h
> > > >  rename arch/arm/mach-tegra/{tegra20 => }/crypto.c (68%)  create
> > > > mode
> > > > 100644 arch/arm/mach-tegra/tegra20/bct.c  create mode 100644
> > > > arch/arm/mach-tegra/tegra20/bct.h  delete mode 100644
> > > > arch/arm/mach-tegra/tegra20/crypto.h
> > > >  create mode 100644 arch/arm/mach-tegra/tegra30/bct.c  create mode
> > > > 100644 arch/arm/mach-tegra/tegra30/bct.h  create mode 100644
> > > > board/avionic-design/tec-ng/tec-ng-spl.c
> > > >  create mode 100644 board/nvidia/beaver/beaver-spl.c  create mode
> > > > 100644 board/nvidia/cardhu/cardhu-spl.c  delete mode 100644
> > > > board/nvidia/venice2/as3722_init.h
> > > >  delete mode 100644 board/toradex/apalis-tk1/as3722_init.h
> > > >  create mode 100644 board/toradex/apalis_t30/apalis_t30-spl.c
> > > >  create mode 100644 board/toradex/colibri_t30/colibri_t30-spl.c
> > > >  create mode 100644 doc/usage/cmd/ebtupdate.rst
> > > >
> > > > --
> > > > 2.37.2
> > > >

^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2023-02-21 16:15 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-14 17:35 [PATCH v4 00/16] General Tegra improvements Svyatoslav Ryhel
2023-02-14 17:35 ` [PATCH v4 01/16] tegra30: clock: add EXTPERIPH Svyatoslav Ryhel
2023-02-14 17:35 ` [PATCH v4 02/16] ARM: t20/t30: swap host1x and disp1 clock parents Svyatoslav Ryhel
2023-02-14 17:35 ` [PATCH v4 03/16] ARM: tegra: clock: add clk_id_to_pll_id helper Svyatoslav Ryhel
2023-02-14 17:35 ` [PATCH v4 04/16] ARM: tegra: clock: add clock_decode_pair helper Svyatoslav Ryhel
2023-02-14 17:35 ` [PATCH v4 05/16] ARM: tegra30: add PLLD to pll setup Svyatoslav Ryhel
2023-02-14 17:35 ` [PATCH v4 06/16] ARM: tegra: Fix Tegra PWM parent clock Svyatoslav Ryhel
2023-02-14 17:35 ` [PATCH v4 07/16] spi: tegra20_slink: accept any word length Svyatoslav Ryhel
2023-02-14 17:35 ` [PATCH v4 08/16] ARM: tegra: provide default USB gadget setup Svyatoslav Ryhel
2023-02-14 17:35 ` [PATCH v4 09/16] ARM: tegra: add late init support Svyatoslav Ryhel
2023-02-14 17:35 ` [PATCH v4 10/16] ARM: tegra: create common pre-dm i2c write Svyatoslav Ryhel
2023-02-14 17:35 ` [PATCH v4 11/16] board: tegra124: switch to updated " Svyatoslav Ryhel
2023-02-14 17:35 ` [PATCH v4 12/16] board: tegra30: " Svyatoslav Ryhel
2023-02-14 17:35 ` [PATCH v4 13/16] ARM: tegra: expose crypto module for all Tegra SoCs Svyatoslav Ryhel
2023-02-14 17:35 ` [PATCH v4 14/16] ARM: tegra: crypto: extend crypto functional Svyatoslav Ryhel
2023-02-14 17:35 ` [PATCH v4 15/16] ARM: tegra30: implement BCT patching Svyatoslav Ryhel
2023-02-14 17:35 ` [PATCH v4 16/16] ARM: tegra20: " Svyatoslav Ryhel
2023-02-14 21:45 ` [PATCH v4 00/16] General Tegra improvements Tom Warren
2023-02-15  7:26   ` Svyatoslav Ryhel
2023-02-17  8:39   ` Svyatoslav Ryhel
2023-02-17 15:57     ` Tom Warren
2023-02-17 16:07       ` Svyatoslav Ryhel
2023-02-17 16:21         ` Tom Warren
2023-02-17 16:27           ` Tom Warren
2023-02-17 16:35             ` Svyatoslav Ryhel
2023-02-21  7:59             ` Svyatoslav Ryhel
2023-02-21 16:09               ` Tom Warren
2023-02-21 16:15                 ` Svyatoslav Ryhel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.