mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-13 08:27:23 +00:00
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>
This commit is contained in:
parent
c2543a21df
commit
2af4d0f49f
3 changed files with 66 additions and 2 deletions
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <command.h>
|
#include <command.h>
|
||||||
|
#include <i2c.h>
|
||||||
#include <asm/arch/cpu.h>
|
#include <asm/arch/cpu.h>
|
||||||
#include <asm/arch/kirkwood.h>
|
#include <asm/arch/kirkwood.h>
|
||||||
#include <asm/arch/mpp.h>
|
#include <asm/arch/mpp.h>
|
||||||
|
@ -92,8 +93,59 @@ int board_init(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CONFIG_MISC_INIT_R)
|
#if defined(CONFIG_MISC_INIT_R)
|
||||||
|
|
||||||
|
#if defined(CONFIG_CMD_I2C) && defined(CONFIG_SYS_I2C_G762_ADDR)
|
||||||
|
/*
|
||||||
|
* Start I2C fan (GMT G762 controller)
|
||||||
|
*/
|
||||||
|
static void init_fan(void)
|
||||||
|
{
|
||||||
|
u8 data;
|
||||||
|
|
||||||
|
i2c_set_bus_num(0);
|
||||||
|
|
||||||
|
/* Enable open-loop and PWM modes */
|
||||||
|
data = 0x20;
|
||||||
|
if (i2c_write(CONFIG_SYS_I2C_G762_ADDR,
|
||||||
|
G762_REG_FAN_CMD1, 1, &data, 1) != 0)
|
||||||
|
goto err;
|
||||||
|
data = 0;
|
||||||
|
if (i2c_write(CONFIG_SYS_I2C_G762_ADDR,
|
||||||
|
G762_REG_SET_CNT, 1, &data, 1) != 0)
|
||||||
|
goto err;
|
||||||
|
/*
|
||||||
|
* RPM to PWM (set_out register) fan speed conversion array:
|
||||||
|
* 0 0x00
|
||||||
|
* 1500 0x04
|
||||||
|
* 2800 0x08
|
||||||
|
* 3400 0x0C
|
||||||
|
* 3700 0x10
|
||||||
|
* 4400 0x20
|
||||||
|
* 4700 0x30
|
||||||
|
* 4800 0x50
|
||||||
|
* 5200 0x80
|
||||||
|
* 5400 0xC0
|
||||||
|
* 5500 0xFF
|
||||||
|
*
|
||||||
|
* Start fan at low speed (2800 RPM):
|
||||||
|
*/
|
||||||
|
data = 0x08;
|
||||||
|
if (i2c_write(CONFIG_SYS_I2C_G762_ADDR,
|
||||||
|
G762_REG_SET_OUT, 1, &data, 1) != 0)
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
return;
|
||||||
|
err:
|
||||||
|
printf("Error: failed to start I2C fan @%02x\n",
|
||||||
|
CONFIG_SYS_I2C_G762_ADDR);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
static void init_fan(void) {}
|
||||||
|
#endif /* CONFIG_CMD_I2C && CONFIG_SYS_I2C_G762_ADDR */
|
||||||
|
|
||||||
int misc_init_r(void)
|
int misc_init_r(void)
|
||||||
{
|
{
|
||||||
|
init_fan();
|
||||||
#if defined(CONFIG_CMD_I2C) && defined(CONFIG_SYS_I2C_EEPROM_ADDR)
|
#if defined(CONFIG_CMD_I2C) && defined(CONFIG_SYS_I2C_EEPROM_ADDR)
|
||||||
if (!getenv("ethaddr")) {
|
if (!getenv("ethaddr")) {
|
||||||
uchar mac[6];
|
uchar mac[6];
|
||||||
|
@ -103,7 +155,7 @@ int misc_init_r(void)
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* CONFIG_MISC_INIT_R */
|
||||||
|
|
||||||
#if defined(CONFIG_CMD_NET) && defined(CONFIG_RESET_PHY_R)
|
#if defined(CONFIG_CMD_NET) && defined(CONFIG_RESET_PHY_R)
|
||||||
/* Configure and initialize PHY */
|
/* Configure and initialize PHY */
|
||||||
|
|
|
@ -32,4 +32,9 @@
|
||||||
/* Buttons */
|
/* Buttons */
|
||||||
#define NET2BIG_V2_GPIO_PUSH_BUTTON 34
|
#define NET2BIG_V2_GPIO_PUSH_BUTTON 34
|
||||||
|
|
||||||
|
/* GMT G762 registers (I2C fan controller) */
|
||||||
|
#define G762_REG_SET_CNT 0x00
|
||||||
|
#define G762_REG_SET_OUT 0x03
|
||||||
|
#define G762_REG_FAN_CMD1 0x04
|
||||||
|
|
||||||
#endif /* NET2BIG_V2_H */
|
#endif /* NET2BIG_V2_H */
|
||||||
|
|
|
@ -119,11 +119,15 @@
|
||||||
#define CONFIG_SYS_PROMPT "ns2> "
|
#define CONFIG_SYS_PROMPT "ns2> "
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Enable platform initialisation via misc_init_r() function
|
||||||
|
*/
|
||||||
|
#define CONFIG_MISC_INIT_R
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ethernet Driver configuration
|
* Ethernet Driver configuration
|
||||||
*/
|
*/
|
||||||
#ifdef CONFIG_CMD_NET
|
#ifdef CONFIG_CMD_NET
|
||||||
#define CONFIG_MISC_INIT_R /* Call misc_init_r() to initialize MAC address */
|
|
||||||
#define CONFIG_MVGBE_PORTS {1, 0} /* enable port 0 only */
|
#define CONFIG_MVGBE_PORTS {1, 0} /* enable port 0 only */
|
||||||
#define CONFIG_NETCONSOLE
|
#define CONFIG_NETCONSOLE
|
||||||
#endif
|
#endif
|
||||||
|
@ -153,6 +157,9 @@
|
||||||
#define CONFIG_SYS_I2C_EEPROM_ADDR 0x50
|
#define CONFIG_SYS_I2C_EEPROM_ADDR 0x50
|
||||||
#define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 4 /* 16-byte page size */
|
#define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 4 /* 16-byte page size */
|
||||||
#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1 /* 8-bit device address */
|
#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN 1 /* 8-bit device address */
|
||||||
|
#if defined(CONFIG_NET2BIG_V2)
|
||||||
|
#define CONFIG_SYS_I2C_G762_ADDR 0x3e
|
||||||
|
#endif
|
||||||
#endif /* CONFIG_CMD_I2C */
|
#endif /* CONFIG_CMD_I2C */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue