Skip to content

Commit

Permalink
rebase onto 2024q4 release
Browse files Browse the repository at this point in the history
Signed-off-by: Yannic Moog <[email protected]>
  • Loading branch information
ymoog committed Jan 17, 2025
1 parent 8bf5af3 commit 7d44ed5
Show file tree
Hide file tree
Showing 8 changed files with 323 additions and 314 deletions.
1 change: 1 addition & 0 deletions boards/mcimx95libra/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#define BOARD_SWI_IRQn Reserved110_IRQn /*!< SWI IRQ */
#define BOARD_HAS_WDOG /*!< Has a watchdog */
#define BOARD_HAS_PMIC /*!< Has a PMIC */
#define BOARD_PMIC_RESUME_TICKS ((20U * 32768U) / 10000U) /*!< 2ms in 32K ticks */
/** @} */

/*!
Expand Down
36 changes: 18 additions & 18 deletions boards/mcimx95libra/sm/brd_sm.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,18 +412,18 @@ int32_t BRD_SM_PmicInfoGet(uint32_t idx, uint8_t *devAddr, uint8_t **info,
/* Call PMIC driver to get info */
switch (idx) {
case 0U:
*devAddr = pf09Dev.devAddr;
if (!PF09_PmicInfoGet(&pf09Dev, info, len))
*devAddr = g_pf09Dev.devAddr;
if (!PF09_PmicInfoGet(&g_pf09Dev, info, len))
status = SM_ERR_HARDWARE_ERROR;
break;
case 1U:
*devAddr = pf5301Dev.devAddr;
if (!PF53_PmicInfoGet(&pf5301Dev, info, len))
*devAddr = g_pf5301Dev.devAddr;
if (!PF53_PmicInfoGet(&g_pf5301Dev, info, len))
status = SM_ERR_HARDWARE_ERROR;
break;
case 2U:
*devAddr = pf5302Dev.devAddr;
if (!PF53_PmicInfoGet(&pf5302Dev, info, len))
*devAddr = g_pf5302Dev.devAddr;
if (!PF53_PmicInfoGet(&g_pf5302Dev, info, len))
status = SM_ERR_HARDWARE_ERROR;
break;
default:
Expand All @@ -444,16 +444,16 @@ int32_t BRD_SM_PmicWrite(uint8_t devAddr, uint8_t regAddr, uint8_t val,
int32_t status = SM_ERR_SUCCESS;

/* Call PF09 driver write data */
if (devAddr == pf09Dev.devAddr) {
if (!PF09_PmicWrite(&pf09Dev, regAddr, val, mask))
if (devAddr == g_pf09Dev.devAddr) {
if (!PF09_PmicWrite(&g_pf09Dev, regAddr, val, mask))
status = SM_ERR_HARDWARE_ERROR;
} else if (devAddr == pf5301Dev.devAddr) {
} else if (devAddr == g_pf5301Dev.devAddr) {
/* Call PF5301 driver write data */
if (!PF53_PmicWrite(&pf5301Dev, regAddr, val, mask))
if (!PF53_PmicWrite(&g_pf5301Dev, regAddr, val, mask))
status = SM_ERR_HARDWARE_ERROR;
} else if (devAddr == pf5302Dev.devAddr) {
} else if (devAddr == g_pf5302Dev.devAddr) {
/* Call PF5302 driver write data */
if (!PF53_PmicWrite(&pf5302Dev, regAddr, val, mask))
if (!PF53_PmicWrite(&g_pf5302Dev, regAddr, val, mask))
status = SM_ERR_HARDWARE_ERROR;
} else {
/* Invalid device address */
Expand All @@ -472,16 +472,16 @@ int32_t BRD_SM_PmicRead(uint8_t devAddr, uint8_t regAddr, uint8_t *val)
int32_t status = SM_ERR_SUCCESS;

/* Call PF09 driver read data */
if (devAddr == pf09Dev.devAddr) {
if (!PF09_PmicRead(&pf09Dev, regAddr, val))
if (devAddr == g_pf09Dev.devAddr) {
if (!PF09_PmicRead(&g_pf09Dev, regAddr, val))
status = SM_ERR_HARDWARE_ERROR;
} else if (devAddr == pf5301Dev.devAddr) {
} else if (devAddr == g_pf5301Dev.devAddr) {
/* Call PF5301 driver read data */
if (!PF53_PmicRead(&pf5301Dev, regAddr, val))
if (!PF53_PmicRead(&g_pf5301Dev, regAddr, val))
status = SM_ERR_HARDWARE_ERROR;
} else if (devAddr == pf5302Dev.devAddr) {
} else if (devAddr == g_pf5302Dev.devAddr) {
/* Call PF5302 driver read data */
if (!PF53_PmicRead(&pf5302Dev, regAddr, val))
if (!PF53_PmicRead(&g_pf5302Dev, regAddr, val))
status = SM_ERR_HARDWARE_ERROR;
} else {
/* Invalid device address */
Expand Down
45 changes: 24 additions & 21 deletions boards/mcimx95libra/sm/brd_sm_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,11 @@
/* Local variables */

/* Global variables */
PF09_Type g_pf09Dev;
PF53_Type g_pf5301Dev;
PF53_Type g_pf5302Dev;

PF09_Type pf09Dev;
PF53_Type pf5301Dev;
PF53_Type pf5302Dev;

irq_prio_info_t s_brdIrqPrioInfo[BOARD_NUM_IRQ_PRIO_IDX] =
irq_prio_info_t g_brdIrqPrioInfo[BOARD_NUM_IRQ_PRIO_IDX] =
{
[BOARD_IRQ_PRIO_IDX_GPIO1_0] =
{
Expand All @@ -72,6 +71,10 @@ irq_prio_info_t s_brdIrqPrioInfo[BOARD_NUM_IRQ_PRIO_IDX] =
}
};

bool g_pca2131Used = false;

uint32_t g_pmicFaultFlags = 0U;

/* Local functions */

static void BRD_SM_Pf09Handler(void);
Expand All @@ -86,29 +89,29 @@ int32_t BRD_SM_SerialDevicesInit(void)

if (status == SM_ERR_SUCCESS) {
/* Fill in PF09 PMIC handle */
pf09Dev.i2cBase = s_i2cBases[BOARD_I2C_INSTANCE];
pf09Dev.devAddr = BOARD_PF09_DEV_ADDR;
pf09Dev.crcEn = true;
g_pf09Dev.i2cBase = s_i2cBases[BOARD_I2C_INSTANCE];
g_pf09Dev.devAddr = BOARD_PF09_DEV_ADDR;
g_pf09Dev.crcEn = true;

/* Inialize PF09 PMIC */
if (!PF09_Init(&pf09Dev))
if (!PF09_Init(&g_pf09Dev))
status = SM_ERR_HARDWARE_ERROR;

/* Disable XRESET monitor in STANDBY */
if (status == SM_ERR_SUCCESS) {
if (!PF09_XrstStbyEnable(&pf09Dev, false))
if (!PF09_XrstStbyEnable(&g_pf09Dev, false))
status = SM_ERR_HARDWARE_ERROR;
}

/* Disable voltage monitor 1 */
if (status == SM_ERR_SUCCESS) {
if (!PF09_MonitorEnable(&pf09Dev, PF09_VMON1, false))
if (!PF09_MonitorEnable(&g_pf09Dev, PF09_VMON1, false))
status = SM_ERR_HARDWARE_ERROR;
}

/* Disable voltage monitor 2 */
if (status == SM_ERR_SUCCESS) {
if (!PF09_MonitorEnable(&pf09Dev, PF09_VMON2, false))
if (!PF09_MonitorEnable(&g_pf09Dev, PF09_VMON2, false))
status = SM_ERR_HARDWARE_ERROR;
}

Expand All @@ -119,7 +122,7 @@ int32_t BRD_SM_SerialDevicesInit(void)
[PF09_MASK_IDX_STATUS1] = 0x08U
};

if (!PF09_IntEnable(&pf09Dev, mask, PF09_MASK_LEN, false))
if (!PF09_IntEnable(&g_pf09Dev, mask, PF09_MASK_LEN, false))
status = SM_ERR_HARDWARE_ERROR;
}

Expand All @@ -130,21 +133,21 @@ int32_t BRD_SM_SerialDevicesInit(void)

if (status == SM_ERR_SUCCESS) {
/* Fill in PF5301 PMIC handle */
pf5301Dev.i2cBase = s_i2cBases[BOARD_I2C_INSTANCE];
pf5301Dev.devAddr = BOARD_PF5301_DEV_ADDR;
g_pf5301Dev.i2cBase = s_i2cBases[BOARD_I2C_INSTANCE];
g_pf5301Dev.devAddr = BOARD_PF5301_DEV_ADDR;

/* Inialize PF0901 PMIC */
if (!PF53_Init(&pf5301Dev))
if (!PF53_Init(&g_pf5301Dev))
status = SM_ERR_HARDWARE_ERROR;
}

if (status == SM_ERR_SUCCESS) {
/* Fill in PF5302 PMIC handle */
pf5302Dev.i2cBase = s_i2cBases[BOARD_I2C_INSTANCE];
pf5302Dev.devAddr = BOARD_PF5302_DEV_ADDR;
g_pf5302Dev.i2cBase = s_i2cBases[BOARD_I2C_INSTANCE];
g_pf5302Dev.devAddr = BOARD_PF5302_DEV_ADDR;

/* Inialize PF0901 PMIC */
if (!PF53_Init(&pf5302Dev))
if (!PF53_Init(&g_pf5302Dev))
status = SM_ERR_HARDWARE_ERROR;
}

Expand Down Expand Up @@ -193,10 +196,10 @@ static void BRD_SM_Pf09Handler(void)
uint8_t stat[PF09_MASK_LEN] = { 0 };

/* Read status of interrupts */
(void) PF09_IntStatus(&pf09Dev, stat, PF09_MASK_LEN);
(void) PF09_IntStatus(&g_pf09Dev, stat, PF09_MASK_LEN);

/* Clear pending */
(void) PF09_IntClear(&pf09Dev, stat, PF09_MASK_LEN);
(void) PF09_IntClear(&g_pf09Dev, stat, PF09_MASK_LEN);

/* Handle pending temp interrupts */
if ((stat[PF09_MASK_IDX_STATUS2] & 0x0FU) != 0U)
Expand Down
8 changes: 4 additions & 4 deletions boards/mcimx95libra/sm/brd_sm_handlers.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,16 @@
/* External variables */

/*! Handle to acces PF09 */
extern PF09_Type pf09Dev;
extern PF09_Type g_pf09Dev;

/*! Handle to acces PF5301 */
extern PF53_Type pf5301Dev;
extern PF53_Type g_pf5301Dev;

/*! Handle to acces PF5302 */
extern PF53_Type pf5302Dev;
extern PF53_Type g_pf5302Dev;

/*! Array of dynamic priority info for board IRQs */
extern irq_prio_info_t s_brdIrqPrioInfo[BOARD_NUM_IRQ_PRIO_IDX];
extern irq_prio_info_t g_brdIrqPrioInfo[BOARD_NUM_IRQ_PRIO_IDX];

/* Functions */

Expand Down
12 changes: 6 additions & 6 deletions boards/mcimx95libra/sm/brd_sm_sensor.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,13 @@ int32_t BRD_SM_SensorReadingGet(uint32_t sensorId, int64_t *sensorValue,
switch (sensorId)
{
case BRD_SM_SENSOR_TEMP_PF09:
rc = PF09_TempGet(&pf09Dev, &temp);
rc = PF09_TempGet(&g_pf09Dev, &temp);
break;
case BRD_SM_SENSOR_TEMP_PF5301:
rc = PF53_TempGet(&pf5301Dev, &temp);
rc = PF53_TempGet(&g_pf5301Dev, &temp);
break;
default:
rc = PF53_TempGet(&pf5302Dev, &temp);
rc = PF53_TempGet(&g_pf5302Dev, &temp);
break;
}

Expand Down Expand Up @@ -230,7 +230,7 @@ int32_t BRD_SM_SensorTripPointSet(uint32_t sensorId, uint8_t tripPoint,
{
if (eventControl == DEV_SM_SENSOR_TP_NONE)
{
if (!PF09_TempAlarmSet(&pf09Dev, 500))
if (!PF09_TempAlarmSet(&g_pf09Dev, 500))
{
status = SM_ERR_HARDWARE_ERROR;
}
Expand All @@ -239,7 +239,7 @@ int32_t BRD_SM_SensorTripPointSet(uint32_t sensorId, uint8_t tripPoint,
{
int32_t temp = (int32_t) value;

if (!PF09_TempAlarmSet(&pf09Dev, temp))
if (!PF09_TempAlarmSet(&g_pf09Dev, temp))
{
status = SM_ERR_HARDWARE_ERROR;
}
Expand Down Expand Up @@ -304,7 +304,7 @@ int32_t BRD_SM_SensorEnable(uint32_t sensorId, bool enable,
if ((sensorId == BRD_SM_SENSOR_TEMP_PF09)
&& !sensorEnb[brdSensorId])
{
if (!PF09_TempAlarmSet(&pf09Dev, 500))
if (!PF09_TempAlarmSet(&g_pf09Dev, 500))
{
status = SM_ERR_HARDWARE_ERROR;
}
Expand Down
Loading

0 comments on commit 7d44ed5

Please sign in to comment.