Skip to contentSkip to conversation

arm: fsl: common: Improve NXP VID driver PMBus support

PATCH New Wasim Khan 1 participant 1 message Feb 8, 2021

lore
Share & tools
lore

Wasim Khan

author
#0 lore raw

PATCH v5 1/1 arm: fsl: common: Improve NXP VID driver PMBus support

From: Stephen Carlson <[email protected]>

This patch adds support for more PMBus compatible devices to the NXP drivers for its QorIQ family devices. At runtime, the voltage regulator is queried over I2C, and the required voltage multiplier determined. This change supports the DIRECT and LINEAR PMBus voltage reporting modes.

Previously, the driver only supported a few specific devices such as the IR36021 and LTC3882, so this change allows the QorIQ series to be used with a much larger variety of core voltage regulator devices.

checkpatch warning "Use if (IS_DEFINED (...))" was ignored to maintain consistency with the existing code.

---
Changes in v5:
- fix compilation issues on ls2080a_emu and ls2080a_simu
- fix compilation issues on powerpc platforms

Changes in v4:
- Included upstream commit ada19fd2
- compilation fix for platforms using IR36021
- read_voltage() fix for devices using INA220
- compilation fix for ls1088
- removed soc_get_fuse_vid() support for ls1028

 board/freescale/common/Kconfig          |  27 +-
 board/freescale/common/vid.c            | 820 ++++++++++--------------
 board/freescale/common/vid.h            |  11 +-
 board/freescale/ls1088a/ls1088a.c       |  40 ++
 board/freescale/ls2080ardb/ls2080ardb.c |  42 ++
 board/freescale/lx2160a/lx2160a.c       |  42 ++
 include/configs/ls1088aqds.h            |   6 -
 include/configs/ls1088ardb.h            |   8 +-
 8 files changed, 477 insertions(+), 519 deletions(-)
board/freescale/common/Kconfig +23 -4
index 1b1fd69cb2..17db755951 100644
@@ -21,18 +21,37 @@ config CMD_ESBC_VALIDATE
 	    esbc_validate - validate signature using RSA verification
 	    esbc_halt - put the core in spin loop (Secure Boot Only)
 
+config VID
+	depends on DM_I2C
+	bool "Enable Freescale VID"
+	help
+	 This option enables setting core voltage based on individual
+	 values saved in SoC fuses.
+
 config VOL_MONITOR_LTC3882_READ
 	depends on VID
 	bool "Enable the LTC3882 voltage monitor read"
-	default n
 	help
 	 This option enables LTC3882 voltage monitor read
-	 functionality. It is used by common VID driver.
+	 functionality. It is used by the common VID driver.
 
 config VOL_MONITOR_LTC3882_SET
 	depends on VID
 	bool "Enable the LTC3882 voltage monitor set"
-	default n
 	help
 	 This option enables LTC3882 voltage monitor set
-	 functionality. It is used by common VID driver.
+	 functionality. It is used by the common VID driver.
+
+config VOL_MONITOR_ISL68233_READ
+	depends on VID
+	bool "Enable the ISL68233 voltage monitor read"
+	help
+	 This option enables ISL68233 voltage monitor read
+	 functionality. It is used by the common VID driver.
+
+config VOL_MONITOR_ISL68233_SET
+	depends on VID
+	bool "Enable the ISL68233 voltage monitor set"
+	help
+	 This option enables ISL68233 voltage monitor set
+	 functionality. It is used by the common VID driver.
board/freescale/common/vid.c +322 -498

1,073 lines not on this page · raw message

board/freescale/common/vid.h +7 -4
index 5bbaecace4..b34c080b4b 100644
@@ -7,16 +7,17 @@
 #ifndef __VID_H_
 #define __VID_H_
 
+/* IR36021 command codes */
 #define IR36021_LOOP1_MANUAL_ID_OFFSET	0x6A
 #define IR36021_LOOP1_VOUT_OFFSET	0x9A
 #define IR36021_MFR_ID_OFFSET		0x92
 #define IR36021_MFR_ID			0x43
-#define IR36021_INTEL_MODE_OOFSET	0x14
+#define IR36021_INTEL_MODE_OFFSET	0x14
 #define IR36021_MODE_MASK		0x20
 #define IR36021_INTEL_MODE		0x00
 #define IR36021_AMD_MODE		0x20
 
-/* step the IR regulator in 5mV increments */
+/* Step the IR regulator in 5mV increments */
 #define IR_VDD_STEP_DOWN		5
 #define IR_VDD_STEP_UP			5
 
@@ -50,15 +51,16 @@
 #define VDD_MV_MAX			925
 #endif
 
-#if defined(CONFIG_TARGET_LX2160AQDS) || defined(CONFIG_TARGET_LX2162AQDS) || \
-defined(CONFIG_TARGET_LX2160ARDB)
 /* PM Bus commands code for LTC3882*/
 #define PWM_CHANNEL0                    0x0
 #define PMBUS_CMD_PAGE                  0x0
 #define PMBUS_CMD_READ_VOUT             0x8B
+#define PMBUS_CMD_VOUT_MODE			0x20
 #define PMBUS_CMD_VOUT_COMMAND          0x21
 #define PMBUS_CMD_PAGE_PLUS_WRITE       0x05
 
+#if defined(CONFIG_TARGET_LX2160AQDS) || defined(CONFIG_TARGET_LX2162AQDS) || \
+defined(CONFIG_TARGET_LX2160ARDB)
 /* Voltage monitor on channel 2*/
 #define I2C_VOL_MONITOR_BUS_V_OFFSET	0x2
 #define I2C_VOL_MONITOR_BUS_V_OVF	0x1
@@ -68,5 +70,6 @@ defined(CONFIG_TARGET_LX2160ARDB)
 #endif
 
 int adjust_vdd(ulong vdd_override);
+u16 soc_get_fuse_vid(int vid_index);
 
 #endif  /* __VID_H_ */
board/freescale/ls1088a/ls1088a.c +40 -0
index 5d19702a05..2dba62c524 100644
@@ -185,6 +185,46 @@ int init_func_vid(void)
 
 	return 0;
 }
+
+u16 soc_get_fuse_vid(int vid_index)
+{
+	static const u16 vdd[32] = {
+		10250,
+		9875,
+		9750,
+		0,      /* reserved */
+		0,      /* reserved */
+		0,      /* reserved */
+		0,      /* reserved */
+		0,      /* reserved */
+		9000,
+		0,      /* reserved */
+		0,      /* reserved */
+		0,      /* reserved */
+		0,      /* reserved */
+		0,      /* reserved */
+		0,      /* reserved */
+		0,      /* reserved */
+		10000,  /* 1.0000V */
+		10125,
+		10250,
+		0,      /* reserved */
+		0,      /* reserved */
+		0,      /* reserved */
+		0,      /* reserved */
+		0,      /* reserved */
+		0,      /* reserved */
+		0,      /* reserved */
+		0,      /* reserved */
+		0,      /* reserved */
+		0,      /* reserved */
+		0,      /* reserved */
+		0,      /* reserved */
+		0,      /* reserved */
+	};
+
+	return vdd[vid_index];
+};
 #endif
 
 int is_pb_board(void)
board/freescale/ls2080ardb/ls2080ardb.c +42 -0

48 lines not on this page · raw message

board/freescale/lx2160a/lx2160a.c +42 -0

48 lines not on this page · raw message

include/configs/ls1088aqds.h +0 -6
index b92ec14c69..a2b21c697f 100644
@@ -326,12 +326,6 @@ unsigned long get_board_ddr_clk(void);
 #define CONFIG_VOL_MONITOR_LTC3882_SET
 #define CONFIG_VOL_MONITOR_LTC3882_READ
 
-/* PM Bus commands code for LTC3882*/
-#define PMBUS_CMD_PAGE                  0x0
-#define PMBUS_CMD_READ_VOUT             0x8B
-#define PMBUS_CMD_PAGE_PLUS_WRITE       0x05
-#define PMBUS_CMD_VOUT_COMMAND          0x21
-
 #define PWM_CHANNEL0                    0x0
 
 /*
include/configs/ls1088ardb.h +1 -7
index f59a9f5574..6f36dd417a 100644
@@ -203,7 +203,7 @@
 
 #define CONFIG_SYS_LS_MC_BOOT_TIMEOUT_MS 5000
 
-#define I2C_MUX_CH_VOL_MONITOR          0xA
+#define I2C_MUX_CH_VOL_MONITOR         0xA
 /* Voltage monitor on channel 2*/
 #define I2C_VOL_MONITOR_ADDR           0x63
 #define I2C_VOL_MONITOR_BUS_V_OFFSET   0x2
@@ -221,12 +221,6 @@
 #define CONFIG_VOL_MONITOR_LTC3882_SET
 #define CONFIG_VOL_MONITOR_LTC3882_READ
 
-/* PM Bus commands code for LTC3882*/
-#define PMBUS_CMD_PAGE                  0x0
-#define PMBUS_CMD_READ_VOUT             0x8B
-#define PMBUS_CMD_PAGE_PLUS_WRITE       0x05
-#define PMBUS_CMD_VOUT_COMMAND          0x21
-
 #define PWM_CHANNEL0                    0x0
 
 /*
Signature · 1 line
2.25.1