coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
pmic.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
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 
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  /* Reset the board on any PMIC write error */
27  board_reset();
28  } else {
29  if (delay)
30  udelay(500);
31  }
32 }
33 
34 void pmic_init(unsigned int bus)
35 {
36  /* Setup/Enable GPIO5 - VDD_CPU_REG_EN */
38 
39  /* Setup/Enable GPIO1 - VDD_HDMI_5V0_BST_EN -- ??? */
41 
42  /* GPIO 0,1,5,6,7 = GPIO, 2,3,4 = alt mode */
44 
45  /* Disable SD1 Remote Sense, Set SD1 for LPDDR4 to 1.125v? */
47 
49 
50  /* CNFG1_L2 = 0xF2 for 3.3v, enabled */
52 
53  /* CNFG1_L1 = 0xCA for 1.05v, enabled */
55 
56  printk(BIOS_DEBUG, "PMIC init done\n");
57 }
#define printk(level,...)
Definition: stdlib.h:16
void delay(unsigned int secs)
Definition: delay.c:8
@ MAX77620_I2C_ADDR
Definition: pmic.c:12
void pmic_init(unsigned int bus)
Definition: pmic.c:34
static void pmic_write_reg(unsigned int bus, uint8_t reg, uint8_t val, int delay)
Definition: pmic.c:21
#define MAX77620_GPIO5_REG
Definition: pmic.h:37
#define MAX77620_CNFG1_L2_REG
Definition: pmic.h:16
#define MAX77620_CNFG2SD_REG
Definition: pmic.h:10
#define MAX77620_AME_GPIO
Definition: pmic.h:43
#define MAX77620_SD1_REG
Definition: pmic.h:7
#define MAX77620_CNFG1_L1_REG
Definition: pmic.h:14
#define MAX77620_GPIO1_REG
Definition: pmic.h:33
static int i2c_writeb(unsigned int bus, uint8_t slave, uint8_t reg, uint8_t data)
Write a byte with one segment in one frame.
Definition: i2c_simple.h:131
__noreturn void board_reset(void)
Definition: reset.c:8
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
Definition: loglevel.h:72
uint8_t u8
Definition: stdint.h:45
unsigned char uint8_t
Definition: stdint.h:8
Definition: device.h:76
u8 val
Definition: sys.c:300
void udelay(uint32_t us)
Definition: udelay.c:15