aboutsummaryrefslogtreecommitdiff
path: root/package/boot/uboot-sifiveu/patches/0005-board-sifive-spl-Set-remote-thermal-of-TMP451-to-85-.patch
blob: dc0d04151faae19de58115c0454764c0e443eb96 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
From 07f84ed283b913cbdf87181ae2ed65467d923df5 Mon Sep 17 00:00:00 2001
From: Vincent Chen <vincent.chen@sifive.com>
Date: Mon, 24 Jan 2022 02:57:40 -0800
Subject: [PATCH 2/2] board: sifive: spl: Set remote thermal of TMP451 to 85
 deg C for the unmatched board

For TMP451 on the unmatched board, the default value of the remote
thermal threshold is 108 deg C. This commit initilizes it to 85 deg C at SPL.
---
 board/sifive/unmatched/spl.c       | 29 +++++++++++++++++++++++++++++
 drivers/misc/Kconfig               | 10 ++++++++++
 include/configs/sifive-unmatched.h |  4 ++++
 scripts/config_whitelist.txt       |  1 +
 4 files changed, 44 insertions(+)

--- a/board/sifive/unmatched/spl.c
+++ b/board/sifive/unmatched/spl.c
@@ -10,6 +10,8 @@
 #include <spl.h>
 #include <misc.h>
 #include <log.h>
+#include <config.h>
+#include <i2c.h>
 #include <linux/delay.h>
 #include <linux/io.h>
 #include <asm/gpio.h>
@@ -26,6 +28,27 @@
 #define MODE_SELECT_SD		0xb
 #define MODE_SELECT_MASK	GENMASK(3, 0)
 
+#define TMP451_REMOTE_THERM_LIMIT_REG_OFFSET	0x19
+#define TMP451_REMOTE_THERM_LIMIT_INIT_VALUE	0x55
+
+static inline int init_tmp451_remote_therm_limit(void)
+{
+	struct udevice *dev;
+	unsigned char r_therm_limit = TMP451_REMOTE_THERM_LIMIT_INIT_VALUE;
+	int ret;
+
+	ret = i2c_get_chip_for_busnum(CONFIG_SYS_TMP451_BUS_NUM,
+				      CONFIG_SYS_I2C_TMP451_ADDR,
+				      CONFIG_SYS_I2C_TMP451_ADDR_LEN,
+				      &dev);
+
+	if (!ret)
+		ret = dm_i2c_write(dev, TMP451_REMOTE_THERM_LIMIT_REG_OFFSET,
+				   &r_therm_limit,
+				   sizeof(unsigned char));
+	return ret;
+}
+
 static inline int spl_reset_device_by_gpio(const char *label, int pin, int low_width)
 {
 	int ret;
@@ -92,6 +115,12 @@ int spl_board_init_f(void)
 
 	pwm_device_init();
 
+	ret = init_tmp451_remote_therm_limit();
+	if (ret) {
+		debug("TMP451 remote THERM limit init failed: %d\n", ret);
+		goto end;
+	}
+
 	ret = spl_gemgxl_init();
 	if (ret) {
 		debug("Gigabit ethernet PHY (VSC8541) init failed: %d\n", ret);
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -536,8 +536,18 @@ config SYS_I2C_EEPROM_ADDR
 	depends on ID_EEPROM || I2C_EEPROM || SPL_I2C_EEPROM || CMD_EEPROM || ENV_IS_IN_EEPROM
 	default 0
 
+config SYS_I2C_TMP451_ADDR
+	hex "Chip address of the TMP451 device"
+	default 0
+
 if I2C_EEPROM
 
+config SYS_I2C_TMP451_ADDR_LEN
+	int "Length in bytes of the TMP451 memory array address"
+	default 1
+	help
+	  Note: This is NOT the chip address length!
+
 config SYS_I2C_EEPROM_ADDR_OVERFLOW
 	hex "EEPROM Address Overflow"
 	default 0x0
--- a/include/configs/sifive-unmatched.h
+++ b/include/configs/sifive-unmatched.h
@@ -15,6 +15,10 @@
 
 #define CONFIG_STANDALONE_LOAD_ADDR	0x80200000
 
+#define CONFIG_SYS_TMP451_BUS_NUM	0
+#define CONFIG_SYS_I2C_TMP451_ADDR	0x4c
+#define CONFIG_SYS_I2C_TMP451_ADDR_LEN	0x1
+
 /* Environment options */
 
 #define BOOT_TARGET_DEVICES(func) \
--- a/scripts/config_whitelist.txt
+++ b/scripts/config_whitelist.txt
@@ -1268,6 +1268,7 @@ CONFIG_SYS_TIMER_BASE
 CONFIG_SYS_TIMER_COUNTER
 CONFIG_SYS_TIMER_COUNTS_DOWN
 CONFIG_SYS_TIMER_RATE
+CONFIG_SYS_TMP451_BUS_NUM
 CONFIG_SYS_TMPVIRT
 CONFIG_SYS_TSEC1_OFFSET
 CONFIG_SYS_TX_ETH_BUFFER