* updated libkcddb (21.12.1 -> 21.12.2), untested
[t2-trunk.git] / architecture / riscv64 / package / u-boot / 0013-board-sifive-spl-Set-remote-thermal-of-TMP451-to-85-.patch
blobd4a2dc4ab101abfe8c917d4569c47f1cd10203a9
1 From 6265d23e2f9fdc0e33074a28d52a894b6be2b19d Mon Sep 17 00:00:00 2001
2 From: Vincent Chen <vincent.chen@sifive.com>
3 Date: Mon, 17 May 2021 16:21:13 +0800
4 Subject: [PATCH 13/16] board: sifive: spl: Set remote thermal of TMP451 to 85
5 deg C for the unmatched board
7 For TMP451 on the unmatched board, the default value of the remote thermal
8 threshold is 108 deg C. This commit initilizes it to 85 deg C at SPL.
10 Signed-off-by: Vincent Chen <vincent.chen@sifive.com>
11 ---
12 board/sifive/unmatched/spl.c | 29 +++++++++++++++++++++++++++++
13 drivers/misc/Kconfig | 10 ++++++++++
14 include/configs/sifive-unmatched.h | 3 +++
15 scripts/config_whitelist.txt | 1 +
16 4 files changed, 43 insertions(+)
18 diff --git a/board/sifive/unmatched/spl.c b/board/sifive/unmatched/spl.c
19 index 3c3b22d..7d59ca0 100644
20 --- a/board/sifive/unmatched/spl.c
21 +++ b/board/sifive/unmatched/spl.c
22 @@ -10,6 +10,8 @@
23 #include <spl.h>
24 #include <misc.h>
25 #include <log.h>
26 +#include <config.h>
27 +#include <i2c.h>
28 #include <linux/delay.h>
29 #include <linux/io.h>
30 #include <asm/gpio.h>
31 @@ -25,6 +27,27 @@
32 #define MODE_SELECT_SD 0xb
33 #define MODE_SELECT_MASK GENMASK(3, 0)
35 +#define TMP451_REMOTE_THERM_LIMIT_REG_OFFSET 0x19
36 +#define TMP451_RETMOE_THERM_LIMIT_INIT_VALUE 0x55
38 +static inline int init_tmp451_remote_therm_limit(void)
40 + struct udevice *dev;
41 + unsigned char r_therm_limit = TMP451_RETMOE_THERM_LIMIT_INIT_VALUE;
42 + int ret;
44 + ret = i2c_get_chip_for_busnum(CONFIG_SYS_TMP451_BUS_NUM,
45 + CONFIG_SYS_I2C_TMP451_ADDR,
46 + CONFIG_SYS_I2C_TMP451_ADDR_LEN,
47 + &dev);
49 + if (!ret)
50 + ret = dm_i2c_write(dev, TMP451_REMOTE_THERM_LIMIT_REG_OFFSET,
51 + &r_therm_limit,
52 + sizeof(unsigned char));
53 + return ret;
56 static inline int spl_reset_device_by_gpio(const char *label, int pin, int low_width)
58 int ret;
59 @@ -91,6 +114,12 @@ int spl_board_init_f(void)
61 pwm_device_init();
63 + ret = init_tmp451_remote_therm_limit();
64 + if (ret) {
65 + debug("TMP451 remote THERM limit init failed: %d\n", ret);
66 + goto end;
67 + }
69 ret = spl_gemgxl_init();
70 if (ret) {
71 debug("Gigabit ethernet PHY (VSC8541) init failed: %d\n", ret);
72 diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
73 index 997b713..2878313 100644
74 --- a/drivers/misc/Kconfig
75 +++ b/drivers/misc/Kconfig
76 @@ -404,6 +404,10 @@ config SYS_I2C_EEPROM_ADDR
77 hex "Chip address of the EEPROM device"
78 default 0
80 +config SYS_I2C_TMP451_ADDR
81 + hex "Chip address of the TMP451 device"
82 + default 0
84 config SYS_I2C_EEPROM_BUS
85 int "I2C bus of the EEPROM device."
86 default 0
87 @@ -429,6 +433,12 @@ config SYS_I2C_EEPROM_ADDR_LEN
88 help
89 Note: This is NOT the chip address length!
91 +config SYS_I2C_TMP451_ADDR_LEN
92 + int "Length in bytes of the TMP451 memory array address"
93 + default 1
94 + help
95 + Note: This is NOT the chip address length!
97 config SYS_I2C_EEPROM_ADDR_OVERFLOW
98 hex "EEPROM Address Overflow"
99 default 0
100 diff --git a/include/configs/sifive-unmatched.h b/include/configs/sifive-unmatched.h
101 index fd93e89..f75cf9b 100644
102 --- a/include/configs/sifive-unmatched.h
103 +++ b/include/configs/sifive-unmatched.h
104 @@ -88,6 +88,9 @@
105 #define CONFIG_SYS_EEPROM_BUS_NUM 0
106 #define CONFIG_SYS_I2C_EEPROM_ADDR 0x54
107 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 0x1
108 +#define CONFIG_SYS_TMP451_BUS_NUM 0
109 +#define CONFIG_SYS_I2C_TMP451_ADDR 0x4c
110 +#define CONFIG_SYS_I2C_TMP451_ADDR_LEN 0x1
112 #define CONFIG_ID_EEPROM
114 diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt
115 index 3dbcc04..a0005fe 100644
116 --- a/scripts/config_whitelist.txt
117 +++ b/scripts/config_whitelist.txt
118 @@ -3550,6 +3550,7 @@ CONFIG_SYS_TIMER_COUNTER
119 CONFIG_SYS_TIMER_COUNTS_DOWN
120 CONFIG_SYS_TIMER_PRESCALER
121 CONFIG_SYS_TIMER_RATE
122 +CONFIG_SYS_TMP451_BUS_NUM
123 CONFIG_SYS_TMPVIRT
124 CONFIG_SYS_TMRINTR_MASK
125 CONFIG_SYS_TMRINTR_NO
127 2.7.4