| 1 |
|
| 2 |
|
| 3 |
#include <console/console.h> |
| 4 |
#include <delay.h> |
| 5 |
#include <device/i2c_simple.h> |
| 6 |
#include <reset.h> |
| 7 |
#include <stdint.h> |
| 8 |
|
| 9 |
#include "pmic.h" |
| 10 |
|
| 11 |
enum { |
| 12 |
MAX77620_I2C_ADDR = 0x3c |
| 13 |
}; |
| 14 |
|
| 15 |
struct max77620_init_reg { |
| 16 |
u8 reg; |
| 17 |
u8 val; |
| 18 |
u8 delay; |
| 19 |
}; |
| 20 |
|
| 21 |
static void pmic_write_reg(unsigned int bus, uint8_t reg, uint8_t val, int delay) |
| 22 |
{ |
| 23 |
if (i2c_writeb(bus, MAX77620_I2C_ADDR, reg, val)) { |
| 24 |
printk(BIOS_ERR, "%s: reg = 0x%02X, value = 0x%02X failed!\n", |
| 25 |
__func__, reg, val); |
| 26 |
|
| 27 |
board_reset(); |
| 28 |
} else { |
| 29 |
if (delay) |
| 30 |
udelay(500); |
| 31 |
} |
| 32 |
} |
| 33 |
|
| 34 |
void pmic_init(unsigned int bus) |
| 35 |
{ |
| 36 |
|
| 37 |
pmic_write_reg(bus, MAX77620_GPIO5_REG, 0x09, 1); |
| 38 |
|
| 39 |
|
| 40 |
pmic_write_reg(bus, MAX77620_GPIO1_REG, 0x09, 1); |
| 41 |
|
| 42 |
|
| 43 |
pmic_write_reg(bus, MAX77620_AME_GPIO, 0x1c, 1); |
| 44 |
|
| 45 |
|
| 46 |
pmic_write_reg(bus, MAX77620_CNFG2SD_REG, 0x04, 1); |
| 47 |
|
| 48 |
pmic_write_reg(bus, MAX77620_SD1_REG, 0x2a, 1); |
| 49 |
|
| 50 |
|
| 51 |
pmic_write_reg(bus, MAX77620_CNFG1_L2_REG, 0xf2, 1); |
| 52 |
|
| 53 |
|
| 54 |
pmic_write_reg(bus, MAX77620_CNFG1_L1_REG, 0xca, 1); |
| 55 |
|
| 56 |
printk(BIOS_DEBUG, "PMIC init done\n"); |
| 57 |
} |