Commit d82d4ff0 authored by Yann Gautier's avatar Yann Gautier
Browse files

stm32mp1: update I2C and PMIC drivers



Regulator configuration at boot takes more information from DT.
I2C configuration from DT is done in I2C driver.
I2C driver manages more transfer modes.
The min voltage of buck1 should also be increased to 1.2V,
else the platform does not boot.

Heavily modifies stm32_i2c.c since many functions move inside the source
file to remove redundant declarations.

Change-Id: I0bee5d776cf3ff15e687427cd6abc06ab237d025
Signed-off-by: default avatarYann Gautier <yann.gautier@st.com>
Signed-off-by: default avatarEtienne Carriere <etienne.carriere@st.com>
Signed-off-by: default avatarLionel Debieve <lionel.debieve@st.com>
Signed-off-by: default avatarNicolas LE BAYON <nicolas.le.bayon@st.com>
parent dfdb057a
...@@ -700,7 +700,7 @@ static void stm32mp1_refresh_restore(struct stm32mp1_ddrctl *ctl, ...@@ -700,7 +700,7 @@ static void stm32mp1_refresh_restore(struct stm32mp1_ddrctl *ctl,
static int board_ddr_power_init(enum ddr_type ddr_type) static int board_ddr_power_init(enum ddr_type ddr_type)
{ {
if (dt_check_pmic()) { if (dt_pmic_status() > 0) {
return pmic_ddr_power_init(ddr_type); return pmic_ddr_power_init(ddr_type);
} }
......
This diff is collapsed.
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
*/ */
#include <errno.h> #include <errno.h>
#include <stdbool.h>
#include <libfdt.h> #include <libfdt.h>
...@@ -13,19 +12,12 @@ ...@@ -13,19 +12,12 @@
#include <common/debug.h> #include <common/debug.h>
#include <drivers/delay_timer.h> #include <drivers/delay_timer.h>
#include <drivers/st/stm32_i2c.h>
#include <drivers/st/stm32mp_pmic.h> #include <drivers/st/stm32mp_pmic.h>
#include <drivers/st/stm32_gpio.h>
#include <drivers/st/stpmic1.h> #include <drivers/st/stpmic1.h>
#include <lib/mmio.h> #include <lib/mmio.h>
#include <lib/utils_def.h> #include <lib/utils_def.h>
/* I2C Timing hard-coded value, for I2C clock source is HSI at 64MHz */
#define I2C_TIMING 0x10D07DB5
#define I2C_TIMEOUT 0xFFFFF
#define MASK_RESET_BUCK3 BIT(2)
#define STPMIC1_LDO12356_OUTPUT_MASK (uint8_t)(GENMASK(6, 2)) #define STPMIC1_LDO12356_OUTPUT_MASK (uint8_t)(GENMASK(6, 2))
#define STPMIC1_LDO12356_OUTPUT_SHIFT 2 #define STPMIC1_LDO12356_OUTPUT_SHIFT 2
#define STPMIC1_LDO3_MODE (uint8_t)(BIT(7)) #define STPMIC1_LDO3_MODE (uint8_t)(BIT(7))
...@@ -45,25 +37,29 @@ static int dt_get_pmic_node(void *fdt) ...@@ -45,25 +37,29 @@ static int dt_get_pmic_node(void *fdt)
return fdt_node_offset_by_compatible(fdt, -1, "st,stpmic1"); return fdt_node_offset_by_compatible(fdt, -1, "st,stpmic1");
} }
bool dt_check_pmic(void) int dt_pmic_status(void)
{ {
int node; int node;
void *fdt; void *fdt;
if (fdt_get_address(&fdt) == 0) { if (fdt_get_address(&fdt) == 0) {
return false; return -ENOENT;
} }
node = dt_get_pmic_node(fdt); node = dt_get_pmic_node(fdt);
if (node < 0) { if (node <= 0) {
VERBOSE("%s: No PMIC node found in DT\n", __func__); return -FDT_ERR_NOTFOUND;
return false;
} }
return fdt_get_status(node); return fdt_get_status(node);
} }
static int dt_pmic_i2c_config(struct dt_node_info *i2c_info) /*
* Get PMIC and its I2C bus configuration from the device tree.
* Return 0 on success, negative on error, 1 if no PMIC node is found.
*/
static int dt_pmic_i2c_config(struct dt_node_info *i2c_info,
struct stm32_i2c_init_s *init)
{ {
int pmic_node, i2c_node; int pmic_node, i2c_node;
void *fdt; void *fdt;
...@@ -75,7 +71,7 @@ static int dt_pmic_i2c_config(struct dt_node_info *i2c_info) ...@@ -75,7 +71,7 @@ static int dt_pmic_i2c_config(struct dt_node_info *i2c_info)
pmic_node = dt_get_pmic_node(fdt); pmic_node = dt_get_pmic_node(fdt);
if (pmic_node < 0) { if (pmic_node < 0) {
return -FDT_ERR_NOTFOUND; return 1;
} }
cuint = fdt_getprop(fdt, pmic_node, "reg", NULL); cuint = fdt_getprop(fdt, pmic_node, "reg", NULL);
...@@ -98,10 +94,10 @@ static int dt_pmic_i2c_config(struct dt_node_info *i2c_info) ...@@ -98,10 +94,10 @@ static int dt_pmic_i2c_config(struct dt_node_info *i2c_info)
return -FDT_ERR_NOTFOUND; return -FDT_ERR_NOTFOUND;
} }
return dt_set_pinctrl_config(i2c_node); return stm32_i2c_get_setup_from_fdt(fdt, i2c_node, init);
} }
int dt_pmic_enable_boot_on_regulators(void) int dt_pmic_configure_boot_on_regulators(void)
{ {
int pmic_node, regulators_node, regulator_node; int pmic_node, regulators_node, regulator_node;
void *fdt; void *fdt;
...@@ -119,14 +115,40 @@ int dt_pmic_enable_boot_on_regulators(void) ...@@ -119,14 +115,40 @@ int dt_pmic_enable_boot_on_regulators(void)
fdt_for_each_subnode(regulator_node, fdt, regulators_node) { fdt_for_each_subnode(regulator_node, fdt, regulators_node) {
const fdt32_t *cuint; const fdt32_t *cuint;
const char *node_name; const char *node_name = fdt_get_name(fdt, regulator_node, NULL);
uint16_t voltage; uint16_t voltage;
int status;
#if defined(IMAGE_BL2)
if ((fdt_getprop(fdt, regulator_node, "regulator-boot-on",
NULL) == NULL) &&
(fdt_getprop(fdt, regulator_node, "regulator-always-on",
NULL) == NULL)) {
#else
if (fdt_getprop(fdt, regulator_node, "regulator-boot-on", if (fdt_getprop(fdt, regulator_node, "regulator-boot-on",
NULL) == NULL) { NULL) == NULL) {
#endif
continue; continue;
} }
if (fdt_getprop(fdt, regulator_node, "regulator-pull-down",
NULL) != NULL) {
status = stpmic1_regulator_pull_down_set(node_name);
if (status != 0) {
return status;
}
}
if (fdt_getprop(fdt, regulator_node, "st,mask-reset",
NULL) != NULL) {
status = stpmic1_regulator_mask_reset_set(node_name);
if (status != 0) {
return status;
}
}
cuint = fdt_getprop(fdt, regulator_node, cuint = fdt_getprop(fdt, regulator_node,
"regulator-min-microvolt", NULL); "regulator-min-microvolt", NULL);
if (cuint == NULL) { if (cuint == NULL) {
...@@ -135,17 +157,13 @@ int dt_pmic_enable_boot_on_regulators(void) ...@@ -135,17 +157,13 @@ int dt_pmic_enable_boot_on_regulators(void)
/* DT uses microvolts, whereas driver awaits millivolts */ /* DT uses microvolts, whereas driver awaits millivolts */
voltage = (uint16_t)(fdt32_to_cpu(*cuint) / 1000U); voltage = (uint16_t)(fdt32_to_cpu(*cuint) / 1000U);
node_name = fdt_get_name(fdt, regulator_node, NULL);
if (stpmic1_is_regulator_enabled(node_name) == 0U) {
int status;
status = stpmic1_regulator_voltage_set(node_name, status = stpmic1_regulator_voltage_set(node_name, voltage);
voltage);
if (status != 0) { if (status != 0) {
return status; return status;
} }
if (stpmic1_is_regulator_enabled(node_name) == 0U) {
status = stpmic1_regulator_enable(node_name); status = stpmic1_regulator_enable(node_name);
if (status != 0) { if (status != 0) {
return status; return status;
...@@ -156,77 +174,77 @@ int dt_pmic_enable_boot_on_regulators(void) ...@@ -156,77 +174,77 @@ int dt_pmic_enable_boot_on_regulators(void)
return 0; return 0;
} }
void initialize_pmic_i2c(void) bool initialize_pmic_i2c(void)
{ {
int ret; int ret;
struct dt_node_info i2c_info; struct dt_node_info i2c_info;
struct i2c_handle_s *i2c = &i2c_handle;
struct stm32_i2c_init_s i2c_init;
if (dt_pmic_i2c_config(&i2c_info) != 0) { ret = dt_pmic_i2c_config(&i2c_info, &i2c_init);
ERROR("I2C configuration failed\n"); if (ret < 0) {
ERROR("I2C configuration failed %d\n", ret);
panic(); panic();
} }
if (stm32mp_clk_enable((uint32_t)i2c_info.clock) < 0) { if (ret != 0) {
ERROR("I2C clock enable failed\n"); return false;
panic();
} }
/* Initialize PMIC I2C */ /* Initialize PMIC I2C */
i2c_handle.i2c_base_addr = i2c_info.base; i2c->i2c_base_addr = i2c_info.base;
i2c_handle.i2c_init.timing = I2C_TIMING; i2c->dt_status = i2c_info.status;
i2c_handle.i2c_init.own_address1 = pmic_i2c_addr; i2c->clock = i2c_info.clock;
i2c_handle.i2c_init.addressing_mode = I2C_ADDRESSINGMODE_7BIT; i2c_init.own_address1 = pmic_i2c_addr;
i2c_handle.i2c_init.dual_address_mode = I2C_DUALADDRESS_DISABLE; i2c_init.addressing_mode = I2C_ADDRESSINGMODE_7BIT;
i2c_handle.i2c_init.own_address2 = 0; i2c_init.dual_address_mode = I2C_DUALADDRESS_DISABLE;
i2c_handle.i2c_init.own_address2_masks = I2C_OAR2_OA2NOMASK; i2c_init.own_address2 = 0;
i2c_handle.i2c_init.general_call_mode = I2C_GENERALCALL_DISABLE; i2c_init.own_address2_masks = I2C_OAR2_OA2NOMASK;
i2c_handle.i2c_init.no_stretch_mode = I2C_NOSTRETCH_DISABLE; i2c_init.general_call_mode = I2C_GENERALCALL_DISABLE;
i2c_init.no_stretch_mode = I2C_NOSTRETCH_DISABLE;
ret = stm32_i2c_init(&i2c_handle); i2c_init.analog_filter = 1;
i2c_init.digital_filter_coef = 0;
ret = stm32_i2c_init(i2c, &i2c_init);
if (ret != 0) { if (ret != 0) {
ERROR("Cannot initialize I2C %x (%d)\n", ERROR("Cannot initialize I2C %x (%d)\n",
i2c_handle.i2c_base_addr, ret); i2c->i2c_base_addr, ret);
panic(); panic();
} }
ret = stm32_i2c_config_analog_filter(&i2c_handle, if (!stm32_i2c_is_device_ready(i2c, pmic_i2c_addr, 1,
I2C_ANALOGFILTER_ENABLE); I2C_TIMEOUT_BUSY_MS)) {
if (ret != 0) { ERROR("I2C device not ready\n");
ERROR("Cannot initialize I2C analog filter (%d)\n", ret);
panic(); panic();
} }
ret = stm32_i2c_is_device_ready(&i2c_handle, (uint16_t)pmic_i2c_addr, 1, stpmic1_bind_i2c(i2c, (uint16_t)pmic_i2c_addr);
I2C_TIMEOUT);
if (ret != 0) {
ERROR("I2C device not ready (%d)\n", ret);
panic();
}
stpmic1_bind_i2c(&i2c_handle, (uint16_t)pmic_i2c_addr); return true;
} }
void initialize_pmic(void) void initialize_pmic(void)
{ {
int status; unsigned long pmic_version;
uint8_t read_val;
initialize_pmic_i2c(); if (!initialize_pmic_i2c()) {
VERBOSE("No PMIC\n");
return;
}
status = stpmic1_register_read(VERSION_STATUS_REG, &read_val); if (stpmic1_get_version(&pmic_version) != 0) {
if (status != 0) { ERROR("Failed to access PMIC\n");
panic(); panic();
} }
INFO("PMIC version = 0x%x\n", read_val); INFO("PMIC version = 0x%02lx\n", pmic_version);
stpmic1_dump_regulators();
/* Keep VDD on during the reset cycle */ #if defined(IMAGE_BL2)
status = stpmic1_register_update(MASK_RESET_BUCK_REG, if (dt_pmic_configure_boot_on_regulators() != 0) {
MASK_RESET_BUCK3,
MASK_RESET_BUCK3);
if (status != 0) {
panic(); panic();
} };
#endif
} }
int pmic_ddr_power_init(enum ddr_type ddr_type) int pmic_ddr_power_init(enum ddr_type ddr_type)
......
...@@ -8,7 +8,8 @@ ...@@ -8,7 +8,8 @@
#include <common/debug.h> #include <common/debug.h>
#include <drivers/st/stpmic1.h> #include <drivers/st/stpmic1.h>
#include <plat/common/platform.h>
#define I2C_TIMEOUT_MS 25
struct regul_struct { struct regul_struct {
const char *dt_node_name; const char *dt_node_name;
...@@ -677,8 +678,9 @@ int stpmic1_regulator_voltage_get(const char *name) ...@@ -677,8 +678,9 @@ int stpmic1_regulator_voltage_get(const char *name)
int stpmic1_register_read(uint8_t register_id, uint8_t *value) int stpmic1_register_read(uint8_t register_id, uint8_t *value)
{ {
return stm32_i2c_mem_read(pmic_i2c_handle, pmic_i2c_addr, return stm32_i2c_mem_read(pmic_i2c_handle, pmic_i2c_addr,
(uint16_t)register_id, I2C_MEMADD_SIZE_8BIT, (uint16_t)register_id,
value, 1, 100000); I2C_MEMADD_SIZE_8BIT, value,
1, I2C_TIMEOUT_MS);
} }
int stpmic1_register_write(uint8_t register_id, uint8_t value) int stpmic1_register_write(uint8_t register_id, uint8_t value)
...@@ -687,7 +689,8 @@ int stpmic1_register_write(uint8_t register_id, uint8_t value) ...@@ -687,7 +689,8 @@ int stpmic1_register_write(uint8_t register_id, uint8_t value)
status = stm32_i2c_mem_write(pmic_i2c_handle, pmic_i2c_addr, status = stm32_i2c_mem_write(pmic_i2c_handle, pmic_i2c_addr,
(uint16_t)register_id, (uint16_t)register_id,
I2C_MEMADD_SIZE_8BIT, &value, 1, 100000); I2C_MEMADD_SIZE_8BIT, &value,
1, I2C_TIMEOUT_MS);
#if ENABLE_ASSERTIONS #if ENABLE_ASSERTIONS
if (status != 0) { if (status != 0) {
......
...@@ -55,7 +55,7 @@ ...@@ -55,7 +55,7 @@
vddcore: buck1 { vddcore: buck1 {
regulator-name = "vddcore"; regulator-name = "vddcore";
regulator-min-microvolt = <800000>; regulator-min-microvolt = <1200000>;
regulator-max-microvolt = <1350000>; regulator-max-microvolt = <1350000>;
regulator-always-on; regulator-always-on;
regulator-initial-mode = <0>; regulator-initial-mode = <0>;
......
/* /*
* Copyright (c) 2016-2018, STMicroelectronics - All Rights Reserved * Copyright (c) 2016-2019, STMicroelectronics - All Rights Reserved
* *
* SPDX-License-Identifier: BSD-3-Clause * SPDX-License-Identifier: BSD-3-Clause
*/ */
...@@ -111,94 +111,113 @@ ...@@ -111,94 +111,113 @@
#define I2C_ICR_TIMOUTCF BIT(12) #define I2C_ICR_TIMOUTCF BIT(12)
#define I2C_ICR_ALERTCF BIT(13) #define I2C_ICR_ALERTCF BIT(13)
struct stm32_i2c_init_s { enum i2c_speed_e {
uint32_t timing; /* Specifies the I2C_TIMINGR_register value I2C_SPEED_STANDARD, /* 100 kHz */
* This parameter is calculated by referring I2C_SPEED_FAST, /* 400 kHz */
* to I2C initialization section in Reference I2C_SPEED_FAST_PLUS, /* 1 MHz */
* manual. };
*/
uint32_t own_address1; /* Specifies the first device own address. #define STANDARD_RATE 100000
* This parameter can be a 7-bit or 10-bit #define FAST_RATE 400000
* address. #define FAST_PLUS_RATE 1000000
struct stm32_i2c_init_s {
uint32_t own_address1; /*
* Specifies the first device own
* address. This parameter can be a
* 7-bit or 10-bit address.
*/ */
uint32_t addressing_mode; /* Specifies if 7-bit or 10-bit addressing uint32_t addressing_mode; /*
* mode is selected. * Specifies if 7-bit or 10-bit
* This parameter can be a value of @ref * addressing mode is selected.
* I2C_ADDRESSING_MODE. * This parameter can be a value of
* @ref I2C_ADDRESSING_MODE.
*/ */
uint32_t dual_address_mode; /* Specifies if dual addressing mode is uint32_t dual_address_mode; /*
* Specifies if dual addressing mode is
* selected. * selected.
* This parameter can be a value of @ref * This parameter can be a value of @ref
* I2C_DUAL_ADDRESSING_MODE. * I2C_DUAL_ADDRESSING_MODE.
*/ */
uint32_t own_address2; /* Specifies the second device own address uint32_t own_address2; /*
* if dual addressing mode is selected. * Specifies the second device own
* This parameter can be a 7-bit address. * address if dual addressing mode is
* selected. This parameter can be a
* 7-bit address.
*/ */
uint32_t own_address2_masks; /* Specifies the acknowledge mask address uint32_t own_address2_masks; /*
* second device own address if dual * Specifies the acknowledge mask
* addressing mode is selected. * address second device own address
* if dual addressing mode is selected
* This parameter can be a value of @ref * This parameter can be a value of @ref
* I2C_OWN_ADDRESS2_MASKS. * I2C_OWN_ADDRESS2_MASKS.
*/ */
uint32_t general_call_mode; /* Specifies if general call mode is uint32_t general_call_mode; /*
* Specifies if general call mode is
* selected. * selected.
* This parameter can be a value of @ref * This parameter can be a value of @ref
* I2C_GENERAL_CALL_ADDRESSING_MODE. * I2C_GENERAL_CALL_ADDRESSING_MODE.
*/ */
uint32_t no_stretch_mode; /* Specifies if nostretch mode is uint32_t no_stretch_mode; /*
* Specifies if nostretch mode is
* selected. * selected.
* This parameter can be a value of @ref * This parameter can be a value of @ref
* I2C_NOSTRETCH_MODE. * I2C_NOSTRETCH_MODE.
*/ */
}; uint32_t rise_time; /*
* Specifies the SCL clock pin rising
enum i2c_state_e { * time in nanoseconds.
I2C_STATE_RESET = 0x00U, /* Peripheral is not yet
* initialized.
*/
I2C_STATE_READY = 0x20U, /* Peripheral Initialized
* and ready for use.
*/
I2C_STATE_BUSY = 0x24U, /* An internal process is
* ongoing.
*/ */
I2C_STATE_BUSY_TX = 0x21U, /* Data Transmission process
* is ongoing. uint32_t fall_time; /*
*/ * Specifies the SCL clock pin falling
I2C_STATE_BUSY_RX = 0x22U, /* Data Reception process * time in nanoseconds.
* is ongoing.
*/ */
I2C_STATE_LISTEN = 0x28U, /* Address Listen Mode is
* ongoing. enum i2c_speed_e speed_mode; /*
* Specifies the I2C clock source
* frequency mode.
* This parameter can be a value of @ref
* i2c_speed_mode_e.
*/ */
I2C_STATE_BUSY_TX_LISTEN = 0x29U, /* Address Listen Mode
* and Data Transmission int analog_filter; /*
* process is ongoing. * Specifies if the I2C analog noise
* filter is selected.
* This parameter can be 0 (filter
* off), all other values mean filter
* on.
*/ */
I2C_STATE_BUSY_RX_LISTEN = 0x2AU, /* Address Listen Mode
* and Data Reception uint8_t digital_filter_coef; /*
* process is ongoing. * Specifies the I2C digital noise
* filter coefficient.
* This parameter can be a value
* between 0 and
* STM32_I2C_DIGITAL_FILTER_MAX.
*/ */
I2C_STATE_ABORT = 0x60U, /* Abort user request ongoing. */ };
I2C_STATE_TIMEOUT = 0xA0U, /* Timeout state. */
I2C_STATE_ERROR = 0xE0U /* Error. */
enum i2c_state_e {
I2C_STATE_RESET = 0x00U, /* Not yet initialized */
I2C_STATE_READY = 0x20U, /* Ready for use */
I2C_STATE_BUSY = 0x24U, /* Internal process ongoing */
I2C_STATE_BUSY_TX = 0x21U, /* Data Transmission ongoing */
I2C_STATE_BUSY_RX = 0x22U, /* Data Reception ongoing */
}; };
enum i2c_mode_e { enum i2c_mode_e {
I2C_MODE_NONE = 0x00U, /* No I2C communication on going. */ I2C_MODE_NONE = 0x00U, /* No active communication */
I2C_MODE_MASTER = 0x10U, /* I2C communication is in Master Mode. */ I2C_MODE_MASTER = 0x10U, /* Communication in Master Mode */
I2C_MODE_SLAVE = 0x20U, /* I2C communication is in Slave Mode. */ I2C_MODE_SLAVE = 0x20U, /* Communication in Slave Mode */
I2C_MODE_MEM = 0x40U /* I2C communication is in Memory Mode. */ I2C_MODE_MEM = 0x40U /* Communication in Memory Mode */
}; };
...@@ -213,25 +232,11 @@ enum i2c_mode_e { ...@@ -213,25 +232,11 @@ enum i2c_mode_e {
struct i2c_handle_s { struct i2c_handle_s {
uint32_t i2c_base_addr; /* Registers base address */ uint32_t i2c_base_addr; /* Registers base address */
unsigned int dt_status; /* DT nsec/sec status */
struct stm32_i2c_init_s i2c_init; /* Communication parameters */ unsigned int clock; /* Clock reference */
uint8_t *p_buff; /* Pointer to transfer buffer */
uint16_t xfer_size; /* Transfer size */
uint16_t xfer_count; /* Transfer counter */
uint32_t prev_state; /* Communication previous
* state
*/
uint8_t lock; /* Locking object */ uint8_t lock; /* Locking object */
enum i2c_state_e i2c_state; /* Communication state */ enum i2c_state_e i2c_state; /* Communication state */
enum i2c_mode_e i2c_mode; /* Communication mode */ enum i2c_mode_e i2c_mode; /* Communication mode */
uint32_t i2c_err; /* Error code */ uint32_t i2c_err; /* Error code */
}; };
...@@ -281,21 +286,36 @@ struct i2c_handle_s { ...@@ -281,21 +286,36 @@ struct i2c_handle_s {
I2C_CR2_NBYTES | I2C_CR2_RELOAD | \ I2C_CR2_NBYTES | I2C_CR2_RELOAD | \
I2C_CR2_RD_WRN) I2C_CR2_RD_WRN)
#define I2C_ANALOGFILTER_ENABLE ((uint32_t)0x00000000U) #define I2C_TIMEOUT_BUSY_MS 25U
#define I2C_ANALOGFILTER_DISABLE I2C_CR1_ANFOFF
int stm32_i2c_init(struct i2c_handle_s *hi2c); #define I2C_ANALOGFILTER_ENABLE 0x00000000U
#define I2C_ANALOGFILTER_DISABLE I2C_CR1_ANFOFF
/* STM32 specific defines */
#define STM32_I2C_RISE_TIME_DEFAULT 25 /* ns */
#define STM32_I2C_FALL_TIME_DEFAULT 10 /* ns */
#define STM32_I2C_SPEED_DEFAULT I2C_SPEED_STANDARD
#define STM32_I2C_ANALOG_FILTER_DELAY_MIN 50 /* ns */
#define STM32_I2C_ANALOG_FILTER_DELAY_MAX 260 /* ns */
#define STM32_I2C_DIGITAL_FILTER_MAX 16
int stm32_i2c_get_setup_from_fdt(void *fdt, int node,
struct stm32_i2c_init_s *init);
int stm32_i2c_init(struct i2c_handle_s *hi2c,
struct stm32_i2c_init_s *init_data);
int stm32_i2c_mem_write(struct i2c_handle_s *hi2c, uint16_t dev_addr, int stm32_i2c_mem_write(struct i2c_handle_s *hi2c, uint16_t dev_addr,
uint16_t mem_addr, uint16_t mem_add_size, uint16_t mem_addr, uint16_t mem_add_size,
uint8_t *p_data, uint16_t size, uint32_t timeout); uint8_t *p_data, uint16_t size, uint32_t timeout_ms);
int stm32_i2c_mem_read(struct i2c_handle_s *hi2c, uint16_t dev_addr, int stm32_i2c_mem_read(struct i2c_handle_s *hi2c, uint16_t dev_addr,
uint16_t mem_addr, uint16_t mem_add_size, uint16_t mem_addr, uint16_t mem_add_size,
uint8_t *p_data, uint16_t size, uint32_t timeout); uint8_t *p_data, uint16_t size, uint32_t timeout_ms);
int stm32_i2c_is_device_ready(struct i2c_handle_s *hi2c, uint16_t dev_addr, int stm32_i2c_master_transmit(struct i2c_handle_s *hi2c, uint16_t dev_addr,
uint32_t trials, uint32_t timeout); uint8_t *p_data, uint16_t size,
uint32_t timeout_ms);
int stm32_i2c_config_analog_filter(struct i2c_handle_s *hi2c, int stm32_i2c_master_receive(struct i2c_handle_s *hi2c, uint16_t dev_addr,
uint32_t analog_filter); uint8_t *p_data, uint16_t size,
uint32_t timeout_ms);
bool stm32_i2c_is_device_ready(struct i2c_handle_s *hi2c, uint16_t dev_addr,
uint32_t trials, uint32_t timeout_ms);
#endif /* STM32_I2C_H */ #endif /* STM32_I2C_H */
...@@ -11,10 +11,41 @@ ...@@ -11,10 +11,41 @@
#include <platform_def.h> #include <platform_def.h>
bool dt_check_pmic(void); /*
int dt_pmic_enable_boot_on_regulators(void); * dt_pmic_status - Check PMIC status from device tree
void initialize_pmic_i2c(void); *
* Returns the status of the PMIC (secure, non-secure), or a negative value on
* error
*/
int dt_pmic_status(void);
/*
* dt_pmic_configure_boot_on_regulators - Configure boot-on and always-on
* regulators from device tree configuration
*
* Returns 0 on success, and negative values on errors
*/
int dt_pmic_configure_boot_on_regulators(void);
/*
* initialize_pmic_i2c - Initialize I2C for the PMIC control
*
* Returns true if PMIC is available, false if not found, panics on errors
*/
bool initialize_pmic_i2c(void);
/*
* initialize_pmic - Main PMIC initialization function, called at platform init
*
* Panics on errors
*/
void initialize_pmic(void); void initialize_pmic(void);
/*
* pmic_ddr_power_init - Initialize regulators required for DDR
*
* Returns 0 on success, and negative values on errors
*/
int pmic_ddr_power_init(enum ddr_type ddr_type); int pmic_ddr_power_init(enum ddr_type ddr_type);
#endif /* STM32MP_PMIC_H */ #endif /* STM32MP_PMIC_H */
...@@ -126,7 +126,7 @@ void bl2_platform_setup(void) ...@@ -126,7 +126,7 @@ void bl2_platform_setup(void)
{ {
int ret; int ret;
if (dt_check_pmic()) { if (dt_pmic_status() > 0) {
initialize_pmic(); initialize_pmic();
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment