uboot-sifiveu: add bootloader package for SiFive Ux40 boards
[openwrt/staging/hauke.git] / package / boot / uboot-sifiveu / patches / 0005-board-sifive-spl-Set-remote-thermal-of-TMP451-to-85-.patch
1 From 07f84ed283b913cbdf87181ae2ed65467d923df5 Mon Sep 17 00:00:00 2001
2 From: Vincent Chen <vincent.chen@sifive.com>
3 Date: Mon, 24 Jan 2022 02:57:40 -0800
4 Subject: [PATCH 2/2] board: sifive: spl: Set remote thermal of TMP451 to 85
5 deg C for the unmatched board
6
7 For TMP451 on the unmatched board, the default value of the remote
8 thermal threshold is 108 deg C. This commit initilizes it to 85 deg C at SPL.
9 ---
10 board/sifive/unmatched/spl.c | 29 +++++++++++++++++++++++++++++
11 drivers/misc/Kconfig | 10 ++++++++++
12 include/configs/sifive-unmatched.h | 4 ++++
13 scripts/config_whitelist.txt | 1 +
14 4 files changed, 44 insertions(+)
15
16 --- a/board/sifive/unmatched/spl.c
17 +++ b/board/sifive/unmatched/spl.c
18 @@ -10,6 +10,8 @@
19 #include <spl.h>
20 #include <misc.h>
21 #include <log.h>
22 +#include <config.h>
23 +#include <i2c.h>
24 #include <linux/delay.h>
25 #include <linux/io.h>
26 #include <asm/gpio.h>
27 @@ -26,6 +28,27 @@
28 #define MODE_SELECT_SD 0xb
29 #define MODE_SELECT_MASK GENMASK(3, 0)
30
31 +#define TMP451_REMOTE_THERM_LIMIT_REG_OFFSET 0x19
32 +#define TMP451_REMOTE_THERM_LIMIT_INIT_VALUE 0x55
33 +
34 +static inline int init_tmp451_remote_therm_limit(void)
35 +{
36 + struct udevice *dev;
37 + unsigned char r_therm_limit = TMP451_REMOTE_THERM_LIMIT_INIT_VALUE;
38 + int ret;
39 +
40 + ret = i2c_get_chip_for_busnum(CONFIG_SYS_TMP451_BUS_NUM,
41 + CONFIG_SYS_I2C_TMP451_ADDR,
42 + CONFIG_SYS_I2C_TMP451_ADDR_LEN,
43 + &dev);
44 +
45 + if (!ret)
46 + ret = dm_i2c_write(dev, TMP451_REMOTE_THERM_LIMIT_REG_OFFSET,
47 + &r_therm_limit,
48 + sizeof(unsigned char));
49 + return ret;
50 +}
51 +
52 static inline int spl_reset_device_by_gpio(const char *label, int pin, int low_width)
53 {
54 int ret;
55 @@ -92,6 +115,12 @@ int spl_board_init_f(void)
56
57 pwm_device_init();
58
59 + ret = init_tmp451_remote_therm_limit();
60 + if (ret) {
61 + debug("TMP451 remote THERM limit init failed: %d\n", ret);
62 + goto end;
63 + }
64 +
65 ret = spl_gemgxl_init();
66 if (ret) {
67 debug("Gigabit ethernet PHY (VSC8541) init failed: %d\n", ret);
68 --- a/drivers/misc/Kconfig
69 +++ b/drivers/misc/Kconfig
70 @@ -536,8 +536,18 @@ config SYS_I2C_EEPROM_ADDR
71 depends on ID_EEPROM || I2C_EEPROM || SPL_I2C_EEPROM || CMD_EEPROM || ENV_IS_IN_EEPROM
72 default 0
73
74 +config SYS_I2C_TMP451_ADDR
75 + hex "Chip address of the TMP451 device"
76 + default 0
77 +
78 if I2C_EEPROM
79
80 +config SYS_I2C_TMP451_ADDR_LEN
81 + int "Length in bytes of the TMP451 memory array address"
82 + default 1
83 + help
84 + Note: This is NOT the chip address length!
85 +
86 config SYS_I2C_EEPROM_ADDR_OVERFLOW
87 hex "EEPROM Address Overflow"
88 default 0x0
89 --- a/include/configs/sifive-unmatched.h
90 +++ b/include/configs/sifive-unmatched.h
91 @@ -15,6 +15,10 @@
92
93 #define CONFIG_STANDALONE_LOAD_ADDR 0x80200000
94
95 +#define CONFIG_SYS_TMP451_BUS_NUM 0
96 +#define CONFIG_SYS_I2C_TMP451_ADDR 0x4c
97 +#define CONFIG_SYS_I2C_TMP451_ADDR_LEN 0x1
98 +
99 /* Environment options */
100
101 #define BOOT_TARGET_DEVICES(func) \
102 --- a/scripts/config_whitelist.txt
103 +++ b/scripts/config_whitelist.txt
104 @@ -1268,6 +1268,7 @@ CONFIG_SYS_TIMER_BASE
105 CONFIG_SYS_TIMER_COUNTER
106 CONFIG_SYS_TIMER_COUNTS_DOWN
107 CONFIG_SYS_TIMER_RATE
108 +CONFIG_SYS_TMP451_BUS_NUM
109 CONFIG_SYS_TMPVIRT
110 CONFIG_SYS_TSEC1_OFFSET
111 CONFIG_SYS_TX_ETH_BUFFER