Commit 2af4d0f49f80a52d50191f0ec451944b1853113e
Committed by
Prafulla Wadaskar
1 parent
c2543a21df
Exists in
master
and in
53 other branches
net2big_v2: initialize I2C fan at startup
This patch ensures minimal cooling for the net2big_v2 by automatically starting the I2C fan (GMT G762) at low speed (2800 RPM). Signed-off-by: Simon Guinot <simon.guinot@sequanux.org> Acked-by: Prafulla Wadaskar <prafulla@marvell.com>
Showing 3 changed files with 66 additions and 2 deletions Side-by-side Diff
board/LaCie/net2big_v2/net2big_v2.c
... | ... | @@ -22,6 +22,7 @@ |
22 | 22 | |
23 | 23 | #include <common.h> |
24 | 24 | #include <command.h> |
25 | +#include <i2c.h> | |
25 | 26 | #include <asm/arch/cpu.h> |
26 | 27 | #include <asm/arch/kirkwood.h> |
27 | 28 | #include <asm/arch/mpp.h> |
28 | 29 | |
... | ... | @@ -92,8 +93,59 @@ |
92 | 93 | } |
93 | 94 | |
94 | 95 | #if defined(CONFIG_MISC_INIT_R) |
96 | + | |
97 | +#if defined(CONFIG_CMD_I2C) && defined(CONFIG_SYS_I2C_G762_ADDR) | |
98 | +/* | |
99 | + * Start I2C fan (GMT G762 controller) | |
100 | + */ | |
101 | +static void init_fan(void) | |
102 | +{ | |
103 | + u8 data; | |
104 | + | |
105 | + i2c_set_bus_num(0); | |
106 | + | |
107 | + /* Enable open-loop and PWM modes */ | |
108 | + data = 0x20; | |
109 | + if (i2c_write(CONFIG_SYS_I2C_G762_ADDR, | |
110 | + G762_REG_FAN_CMD1, 1, &data, 1) != 0) | |
111 | + goto err; | |
112 | + data = 0; | |
113 | + if (i2c_write(CONFIG_SYS_I2C_G762_ADDR, | |
114 | + G762_REG_SET_CNT, 1, &data, 1) != 0) | |
115 | + goto err; | |
116 | + /* | |
117 | + * RPM to PWM (set_out register) fan speed conversion array: | |
118 | + * 0 0x00 | |
119 | + * 1500 0x04 | |
120 | + * 2800 0x08 | |
121 | + * 3400 0x0C | |
122 | + * 3700 0x10 | |
123 | + * 4400 0x20 | |
124 | + * 4700 0x30 | |
125 | + * 4800 0x50 | |
126 | + * 5200 0x80 | |
127 | + * 5400 0xC0 | |
128 | + * 5500 0xFF | |
129 | + * | |
130 | + * Start fan at low speed (2800 RPM): | |
131 | + */ | |
132 | + data = 0x08; | |
133 | + if (i2c_write(CONFIG_SYS_I2C_G762_ADDR, | |
134 | + G762_REG_SET_OUT, 1, &data, 1) != 0) | |
135 | + goto err; | |
136 | + | |
137 | + return; | |
138 | +err: | |
139 | + printf("Error: failed to start I2C fan @%02x\n", | |
140 | + CONFIG_SYS_I2C_G762_ADDR); | |
141 | +} | |
142 | +#else | |
143 | +static void init_fan(void) {} | |
144 | +#endif /* CONFIG_CMD_I2C && CONFIG_SYS_I2C_G762_ADDR */ | |
145 | + | |
95 | 146 | int misc_init_r(void) |
96 | 147 | { |
148 | + init_fan(); | |
97 | 149 | #if defined(CONFIG_CMD_I2C) && defined(CONFIG_SYS_I2C_EEPROM_ADDR) |
98 | 150 | if (!getenv("ethaddr")) { |
99 | 151 | uchar mac[6]; |
... | ... | @@ -103,7 +155,7 @@ |
103 | 155 | #endif |
104 | 156 | return 0; |
105 | 157 | } |
106 | -#endif | |
158 | +#endif /* CONFIG_MISC_INIT_R */ | |
107 | 159 | |
108 | 160 | #if defined(CONFIG_CMD_NET) && defined(CONFIG_RESET_PHY_R) |
109 | 161 | /* Configure and initialize PHY */ |
board/LaCie/net2big_v2/net2big_v2.h
include/configs/lacie_kw.h
... | ... | @@ -120,10 +120,14 @@ |
120 | 120 | #endif |
121 | 121 | |
122 | 122 | /* |
123 | + * Enable platform initialisation via misc_init_r() function | |
124 | + */ | |
125 | +#define CONFIG_MISC_INIT_R | |
126 | + | |
127 | +/* | |
123 | 128 | * Ethernet Driver configuration |
124 | 129 | */ |
125 | 130 | #ifdef CONFIG_CMD_NET |
126 | -#define CONFIG_MISC_INIT_R /* Call misc_init_r() to initialize MAC address */ | |
127 | 131 | #define CONFIG_MVGBE_PORTS {1, 0} /* enable port 0 only */ |
128 | 132 | #define CONFIG_NETCONSOLE |
129 | 133 | #endif |
... | ... | @@ -153,6 +157,9 @@ |
153 | 157 | #define CONFIG_SYS_I2C_EEPROM_ADDR 0x50 |
154 | 158 | #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 4 /* 16-byte page size */ |
155 | 159 | #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1 /* 8-bit device address */ |
160 | +#if defined(CONFIG_NET2BIG_V2) | |
161 | +#define CONFIG_SYS_I2C_G762_ADDR 0x3e | |
162 | +#endif | |
156 | 163 | #endif /* CONFIG_CMD_I2C */ |
157 | 164 | |
158 | 165 | /* |