Skip to contentSkip to conversation

misc: Add AVS class 0 support for AM6

PATCH Superseded Keerthy 2 participants 13 messages Oct 21, 2019 – Oct 24, 2019

Subsystems (4)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Keerthy

author
#0 lore raw

v2 cover misc: Add AVS class 0 support for AM6

Adaptive Voltage Scaling is a technology used in TI SoCs to optimize the operating voltage based on characterization data written to efuse during production.

Add support for Adaptive Voltage scaling class 0 support for AM6 family of devices. Adaptive voltage scaling class 0 implies that optimized voltage values for a particular OPP of a particular voltage domain are read from Efuse and programmed on the pmic/regulator.

Tested on AM654-EVM for MPU @800 MHz.

Changes in v2:

* Avoided creation of new uclass. AVS driver is now under misc.

Keerthy (2):
arm: mach-k3: am6_init: Initialize AVS class 0
clk: clk-ti-sci: Notify AVS driver upon setting clock rate

Tero Kristo (8):
misc: k3_avs: add driver for K3 Adaptive Voltage Scaling Class 0
power: regulator: tps6236x: add support for tps6236x regulators
arm: dts: k3-am65: Add VTM node
arm: dts: k3-am654-r5-base-board: enable wkup_i2c0 driver for spl
arm: dts: k3-am654-r5-base-board: add supply rail for MPU
arm: dts: k3-am654-r5-base-board: enable wkup_vtm0 node and link in
supplies
configs: am65x_evm_r5_defconfig: Enable TPS62363 regulator support
configs: am65x_evm_r5_defconfig: Enable AVS class 0 support

 arch/arm/dts/k3-am65-wakeup.dtsi             |   7 +
 arch/arm/dts/k3-am654-r5-base-board.dts      |  20 +
 arch/arm/mach-k3/am6_init.c                  |   7 +
 configs/am65x_evm_r5_defconfig               |   2 +
 drivers/clk/clk-ti-sci.c                     |   5 +
 drivers/misc/Kconfig                         |   9 +
 drivers/misc/Makefile                        |   1 +
 drivers/misc/k3_avs.c                        | 366 +++++++++++++++++++
 drivers/power/regulator/Kconfig              |  10 +
 drivers/power/regulator/Makefile             |   1 +
 drivers/power/regulator/tps62360_regulator.c | 123 +++++++
 include/k3-avs.h                             |  28 ++
 12 files changed, 579 insertions(+)
 create mode 100644 drivers/misc/k3_avs.c
 create mode 100644 drivers/power/regulator/tps62360_regulator.c
 create mode 100644 include/k3-avs.h
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH v2 1/10 misc: k3_avs: add driver for K3 Adaptive Voltage Scaling Class 0

From: Tero Kristo <[email protected]>

Adaptive Voltage Scaling is a technology used in TI SoCs to optimize the operating voltage based on characterization data written to efuse during production. Add a driver to support this feature for K3 line of SoCs, initially for AM65x.

---

Changes in v2:

* Avoided creation of new UCLASS & placed the driver under misc.

 drivers/misc/Kconfig  |   9 ++
 drivers/misc/Makefile |   1 +
 drivers/misc/k3_avs.c | 366 ++++++++++++++++++++++++++++++++++++++++++
 include/k3-avs.h      |  28 ++++
 4 files changed, 404 insertions(+)
 create mode 100644 drivers/misc/k3_avs.c
 create mode 100644 include/k3-avs.h
drivers/misc/Kconfig +9 -0
index ba50893b43..f6147238a4 100644
@@ -412,4 +412,13 @@ config IHS_FPGA
 	  by the devices. This driver supports both CON and CPU variants of the
 	  devices, depending on the device tree entry.
 
+config K3_AVS0
+	depends on ARCH_K3 && SPL_DM_REGULATOR
+	bool "AVS class 0 support for K3 devices"
+	help
+	  K3 devices have the optimized voltage values for the main voltage
+	  domains stored in efuse within the VTM IP. This driver reads the
+	  optimized voltage from the efuse, so that it can be programmed
+	  to the PMIC on board.
+
 endmenu
drivers/misc/Makefile +1 -0
index 0001d105ba..74d01ef392 100644
@@ -65,3 +65,4 @@ obj-$(CONFIG_TWL4030_LED) += twl4030_led.o
 obj-$(CONFIG_VEXPRESS_CONFIG) += vexpress_config.o
 obj-$(CONFIG_WINBOND_W83627) += winbond_w83627.o
 obj-$(CONFIG_JZ4780_EFUSE) += jz4780_efuse.o
+obj-$(CONFIG_K3_AVS0) += k3_avs.o
drivers/misc/k3_avs.c new file +366 -0

366 lines not on this page · raw message

include/k3-avs.h new file +28 -0
new file mode 100644
index 0000000000..9867481617
@@ -0,0 +1,28 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Texas Instruments' K3 Adaptive Voltage Scaling driver
+ *
+ * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
+ *      Tero Kristo <[email protected]>
+ *
+ */
+
+#ifndef _K3_AVS0_
+#define _K3_AVS0_
+
+#define AM6_VDD_WKUP		0
+#define AM6_VDD_MCU		1
+#define AM6_VDD_CORE		2
+#define AM6_VDD_MPU0		3
+#define AM6_VDD_MPU1		4
+
+#define NUM_OPPS		4
+
+#define AM6_OPP_NOM		1
+#define AM6_OPP_OD		2
+#define AM6_OPP_TURBO		3
+
+int k3_avs_set_opp(struct udevice *dev, int vdd_id, int opp_id);
+int k3_avs_notify_freq(int dev_id, int clk_id, u32 freq);
+
+#endif
Signature · 1 line
2.17.1
author
#2 lore raw

PATCH v2 2/10 arm: mach-k3: am6_init: Initialize AVS class 0

In reply to Keerthy

Initialize AVS class 0 so that mpu voltage rail is programmed to the AVS class 0 compensated value.

---

Changes in v2:

* Now that AVS is misc device do not go by default ID 0 and rely on uclass_get_device_by_driver to get the right device.

 arch/arm/mach-k3/am6_init.c | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm/mach-k3/am6_init.c +7 -0
index 0b564f7bd1..99edcd9a24 100644
@@ -116,6 +116,13 @@ void board_init_f(ulong dummy)
 	/* Perform EEPROM-based board detection */
 	do_board_detect();
 
+#if defined(CONFIG_CPU_V7R) && defined(CONFIG_K3_AVS0)
+	ret = uclass_get_device_by_driver(UCLASS_MISC, DM_GET_DRIVER(k3_avs),
+					  &dev);
+	if (ret)
+		printf("AVS init failed: %d\n", ret);
+#endif
+
 #ifdef CONFIG_K3_AM654_DDRSS
 	ret = uclass_get_device(UCLASS_RAM, 0, &dev);
 	if (ret)
Signature · 1 line
2.17.1
author
#3 lore raw

PATCH v2 3/10 clk: clk-ti-sci: Notify AVS driver upon setting clock rate

In reply to Keerthy

Notify AVS driver upon setting clock rate so that voltage is changed accordingly.

---
 drivers/clk/clk-ti-sci.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/clk/clk-ti-sci.c +5 -0
index c25415d410..478349f22f 100644
@@ -13,6 +13,7 @@
 #include <errno.h>
 #include <clk-uclass.h>
 #include <linux/soc/ti/ti_sci_protocol.h>
+#include <k3-avs.h>
 
 /**
  * struct ti_sci_clk_data - clock controller information structure
@@ -101,6 +102,10 @@ static ulong ti_sci_clk_set_rate(struct clk *clk, ulong rate)
 
 	debug("%s(clk=%p, rate=%lu)\n", __func__, clk, rate);
 
+#ifdef CONFIG_K3_AVS0
+	k3_avs_notify_freq(clk->id, clk->data, rate);
+#endif
+
 	/* Ask for exact frequency by using same value for min/target/max */
 	ret = cops->set_freq(sci, clk->id, clk->data, rate, rate, rate);
 	if (ret)
Signature · 1 line
2.17.1
author
#4 lore raw

PATCH v2 4/10 power: regulator: tps6236x: add support for tps6236x regulators

In reply to Keerthy

From: Tero Kristo <[email protected]>

TPS6236x is a family of step down DC-DC converters optimized for battery powered portable applications for a small solution size. Add a regulator driver for supporting these devices.

---
 drivers/power/regulator/Kconfig              |  10 ++
 drivers/power/regulator/Makefile             |   1 +
 drivers/power/regulator/tps62360_regulator.c | 123 +++++++++++++++++++
 3 files changed, 134 insertions(+)
 create mode 100644 drivers/power/regulator/tps62360_regulator.c
drivers/power/regulator/Kconfig +10 -0
index 9aa00fad42..56d68ee40e 100644
@@ -273,6 +273,16 @@ config DM_REGULATOR_TPS65910
 	regulator types of the TPS65910 (BUCK, BOOST and LDO). It implements
 	the get/set api for value and enable.
 
+config DM_REGULATOR_TPS62360
+	bool "Enable driver for TPS6236x Power Regulator"
+	depends on DM_REGULATOR
+	help
+	The TPS6236X DC/DC step down converter provides a single output
+	power line peaking at 3A current. This driver supports all four
+	variants of the chip (TPS62360, TPS62361, TPS62362, TPS62363). It
+	implements the get/set api for value only, as the power line is
+	always on.
+
 config DM_REGULATOR_STPMIC1
 	bool "Enable driver for STPMIC1 regulators"
 	depends on DM_REGULATOR && PMIC_STPMIC1
drivers/power/regulator/Makefile +1 -0
index 6a3d4bbee4..9198841b4f 100644
@@ -26,4 +26,5 @@ obj-$(CONFIG_$(SPL_)DM_REGULATOR_LP873X) += lp873x_regulator.o
 obj-$(CONFIG_$(SPL_)DM_REGULATOR_LP87565) += lp87565_regulator.o
 obj-$(CONFIG_$(SPL_)DM_REGULATOR_STM32_VREFBUF) += stm32-vrefbuf.o
 obj-$(CONFIG_DM_REGULATOR_TPS65910) += tps65910_regulator.o
+obj-$(CONFIG_DM_REGULATOR_TPS62360) += tps62360_regulator.o
 obj-$(CONFIG_$(SPL_)DM_REGULATOR_STPMIC1) += stpmic1.o
drivers/power/regulator/tps62360_regulator.c new file +123 -0

123 lines not on this page · raw message

Signature · 1 line
2.17.1
author
#5 lore raw

PATCH v2 5/10 arm: dts: k3-am65: Add VTM node

In reply to Keerthy

From: Tero Kristo <[email protected]>

Add VTM node for voltage and thermal management. For u-boot, this is needed for supporting AVS class 0, as the efuse values for the OPPs are stored under the VTM.

---
 arch/arm/dts/k3-am65-wakeup.dtsi | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm/dts/k3-am65-wakeup.dtsi +7 -0
index 2676d6035b..5d050c6fd8 100644
@@ -62,4 +62,11 @@
 		clocks = <&k3_clks 115 1>;
 		power-domains = <&k3_pds 115 TI_SCI_PD_EXCLUSIVE>;
 	};
+
+	wkup_vtm0: wkup_vtm at 42050000 {
+		compatible = "ti,am654-vtm", "ti,am654-avs";
+		reg = <0x42050000 0x25c>;
+		power-domains = <&k3_pds 80>;
+		#thermal-sensor-cells = <1>;
+	};
 };
Signature · 1 line
2.17.1
#6 lore raw

PATCH v2 5/10 arm: dts: k3-am65: Add VTM node

Quoted 17 lines · Keerthy

From: Tero Kristo <[email protected]>

Add VTM node for voltage and thermal management. For u-boot, this is needed for supporting AVS class 0, as the efuse values for the OPPs are stored under the VTM.

---
 arch/arm/dts/k3-am65-wakeup.dtsi | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm/dts/k3-am65-wakeup.dtsi +0 -0
index 2676d6035b..5d050c6fd8 100644

arch/arm/dts/k3-am65-wakeup.dtsi line 71

Quoted 10 lines
arch/arm/dts/k3-am65-wakeup.dtsi +7 -0
@@ -62,4 +62,11 @@
 		clocks = <&k3_clks 115 1>;
 		power-domains = <&k3_pds 115 TI_SCI_PD_EXCLUSIVE>;
 	};
+
+	wkup_vtm0: wkup_vtm at 42050000 {
+		compatible = "ti,am654-vtm", "ti,am654-avs";
+		reg = <0x42050000 0x25c>;
+		power-domains = <&k3_pds 80>;
+		#thermal-sensor-cells = <1>;
+	};

Is this going to be used in kernel? If not can you move this to r5-base board?

Thanks and regards,
Lokesh

Quoted 2 lines
arch/arm/dts/k3-am65-wakeup.dtsi +0 -0
 };
author
#7 lore raw

PATCH v2 5/10 arm: dts: k3-am65: Add VTM node

Quoted 24 lines · Lokesh Vutla
Quoted 21 lines · Keerthy

From: Tero Kristo <[email protected]>

Add VTM node for voltage and thermal management. For u-boot, this is needed for supporting AVS class 0, as the efuse values for the OPPs are stored under the VTM.

---
  arch/arm/dts/k3-am65-wakeup.dtsi | 7 +++++++
  1 file changed, 7 insertions(+)
arch/arm/dts/k3-am65-wakeup.dtsi +1 -0
index 2676d6035b..5d050c6fd8 100644
@@ -62,4 +62,11 @@
  		clocks = <&k3_clks 115 1>;
  		power-domains = <&k3_pds 115 TI_SCI_PD_EXCLUSIVE>;
  	};
+
Quoted 8 lines

arch/arm/dts/k3-am65-wakeup.dtsi line 71

Quoted 6 lines
arch/arm/dts/k3-am65-wakeup.dtsi +6 -0
+	wkup_vtm0: wkup_vtm at 42050000 {
+		compatible = "ti,am654-vtm", "ti,am654-avs";
+		reg = <0x42050000 0x25c>;
+		power-domains = <&k3_pds 80>;
+		#thermal-sensor-cells = <1>;
+	};

Is this going to be used in kernel? If not can you move this to r5-base board?

This could be potentially used for thermal in kernel. As of now this is not. So yes i will move this to r5-base board.

Thanks,
Keerthy

Quoted 6 lines

Thanks and regards,
Lokesh

Quoted 2 lines
arch/arm/dts/k3-am65-wakeup.dtsi +0 -0
  };
author
#8 lore raw

PATCH v2 6/10 arm: dts: k3-am654-r5-base-board: enable wkup_i2c0 driver for spl

In reply to Keerthy

From: Tero Kristo <[email protected]>

Enable wkup_i2c0 as this is needed for voltage control.

---
 arch/arm/dts/k3-am654-r5-base-board.dts | 1 +
 1 file changed, 1 insertion(+)
arch/arm/dts/k3-am654-r5-base-board.dts +1 -0
index e31ed4fe64..a2c6c5a49d 100644
@@ -211,4 +211,5 @@
 	pinctrl-names = "default";
 	pinctrl-0 = <&wkup_i2c0_pins_default>;
 	clock-frequency = <400000>;
+	u-boot,dm-spl;
 };
Signature · 1 line
2.17.1
author
#9 lore raw

PATCH v2 7/10 arm: dts: k3-am654-r5-base-board: add supply rail for MPU

In reply to Keerthy

From: Tero Kristo <[email protected]>

MPU voltage on AM65x-evm is controlled via the TPS62363 chip attached to i2c0 bus. Add device node for this so that it can be controlled via a regulator driver.

---
 arch/arm/dts/k3-am654-r5-base-board.dts | 13 +++++++++++++
 1 file changed, 13 insertions(+)
arch/arm/dts/k3-am654-r5-base-board.dts +13 -0
index a2c6c5a49d..d6bd5def59 100644
@@ -212,4 +212,17 @@
 	pinctrl-0 = <&wkup_i2c0_pins_default>;
 	clock-frequency = <400000>;
 	u-boot,dm-spl;
+
+	vdd_mpu: tps62363 at 60 {
+		compatible = "ti,tps62363";
+		reg = <0x60>;
+		regulator-name = "VDD_MPU";
+		regulator-min-microvolt = <500000>;
+		regulator-max-microvolt = <1770000>;
+		regulator-always-on;
+		regulator-boot-on;
+		ti,vsel0-state-high;
+		ti,vsel1-state-high;
+		u-boot,dm-spl;
+	};
 };
Signature · 1 line
2.17.1
author
#10 lore raw

PATCH v2 8/10 arm: dts: k3-am654-r5-base-board: enable wkup_vtm0 node and link in supplies

In reply to Keerthy

From: Tero Kristo <[email protected]>

Link the vdd-supplies for the voltage domains under the VTM node. Also, enable the node under SPL. This will enable the AVS class 0 support on am65x-evm board.

---
 arch/arm/dts/k3-am654-r5-base-board.dts | 6 ++++++
 1 file changed, 6 insertions(+)
arch/arm/dts/k3-am654-r5-base-board.dts +6 -0
index d6bd5def59..0d924d0aae 100644
@@ -131,6 +131,12 @@
 	power-domains = <&k3_pds 146 TI_SCI_PD_SHARED>;
 };
 
+&wkup_vtm0 {
+	vdd-supply-3 = <&vdd_mpu>;
+	vdd-supply-4 = <&vdd_mpu>;
+	u-boot,dm-spl;
+};
+
 &wkup_pmx0 {
 	u-boot,dm-spl;
 	wkup_uart0_pins_default: wkup_uart0_pins_default {
Signature · 1 line
2.17.1
author
#11 lore raw

PATCH v2 9/10 configs: am65x_evm_r5_defconfig: Enable TPS62363 regulator support

In reply to Keerthy

From: Tero Kristo <[email protected]>

TPS62363 is used to control the MPU_VDD voltage, so enable the driver for this.

---
 configs/am65x_evm_r5_defconfig | 1 +
 1 file changed, 1 insertion(+)
configs/am65x_evm_r5_defconfig +1 -0
index d0619e9b7a..a721b24ba4 100644
@@ -84,6 +84,7 @@ CONFIG_DM_REGULATOR=y
 CONFIG_SPL_DM_REGULATOR=y
 CONFIG_DM_REGULATOR_GPIO=y
 CONFIG_SPL_DM_REGULATOR_GPIO=y
+CONFIG_DM_REGULATOR_TPS62360=y
 CONFIG_RAM=y
 CONFIG_SPL_RAM=y
 CONFIG_K3_SYSTEM_CONTROLLER=y
Signature · 1 line
2.17.1
author
#12 lore raw

PATCH v2 10/10 configs: am65x_evm_r5_defconfig: Enable AVS class 0 support

In reply to Keerthy

From: Tero Kristo <[email protected]>

Enable AVS class 0 support for the R5 SPL bootloader.

---
 configs/am65x_evm_r5_defconfig | 1 +
 1 file changed, 1 insertion(+)
configs/am65x_evm_r5_defconfig +1 -0
index a721b24ba4..4f122808de 100644
@@ -99,3 +99,4 @@ CONFIG_TIMER=y
 CONFIG_SPL_TIMER=y
 CONFIG_OMAP_TIMER=y
 CONFIG_FS_FAT_MAX_CLUSTSIZE=16384
+CONFIG_K3_AVS0=y
Signature · 1 line
2.17.1