From f7b892e07284c6760257a9dca875b4d4554e018a Mon Sep 17 00:00:00 2001 From: Juha Kortesalmi Date: Tue, 22 Oct 2024 14:01:40 +0300 Subject: [PATCH] SW_MA PMIC sequence for 9230 Signed-off-by: Juha Kortesalmi --- .../internal/requests/nrfs_pmic_reqs.h | 2 + nrfs/include/internal/services/nrfs_pmic.h | 12 ++++ nrfs/include/services/nrfs_pmic.h | 40 +++++++++++++ nrfs/src/services/nrfs_pmic.c | 58 +++++++++++++++++++ 4 files changed, 112 insertions(+) diff --git a/nrfs/include/internal/requests/nrfs_pmic_reqs.h b/nrfs/include/internal/requests/nrfs_pmic_reqs.h index 9ae420d8..a8874db3 100644 --- a/nrfs/include/internal/requests/nrfs_pmic_reqs.h +++ b/nrfs/include/internal/requests/nrfs_pmic_reqs.h @@ -24,6 +24,8 @@ enum { NRFS_PMIC_PWM_GHOST_AVOID = NRFS_REQUEST_ID_DEF(NRFS_SERVICE_ID_PMIC, 0x08), NRFS_PMIC_TEST_IF = NRFS_REQUEST_ID_DEF(NRFS_SERVICE_ID_PMIC, 0x09), NRFS_PMIC_INFO = NRFS_REQUEST_ID_DEF(NRFS_SERVICE_ID_PMIC, 0x0A), + NRFS_PMIC_MA_IO_ON = NRFS_REQUEST_ID_DEF(NRFS_SERVICE_ID_PMIC, 0x0B), + NRFS_PMIC_MA_IO_OFF = NRFS_REQUEST_ID_DEF(NRFS_SERVICE_ID_PMIC, 0x0C) }; #ifdef __cplusplus diff --git a/nrfs/include/internal/services/nrfs_pmic.h b/nrfs/include/internal/services/nrfs_pmic.h index 032f5747..57895f54 100644 --- a/nrfs/include/internal/services/nrfs_pmic.h +++ b/nrfs/include/internal/services/nrfs_pmic.h @@ -115,6 +115,18 @@ typedef struct __NRFS_PACKED { nrfs_ctx_t ctx; /**< Context of the message. */ } nrfs_pmic_pwm_ghost_avoid_req_t; +/** @brief PMIC MA I/O Power ON request structure. */ +typedef struct __NRFS_PACKED { + nrfs_hdr_t hdr; /**< Header of the message. */ + nrfs_ctx_t ctx; /**< Context of the message. */ +} nrfs_pmic_ma_io_on_req_t; + +/** @brief PMIC MA I/O Power OFF request structure. */ +typedef struct __NRFS_PACKED { + nrfs_hdr_t hdr; /**< Header of the message. */ + nrfs_ctx_t ctx; /**< Context of the message. */ +} nrfs_pmic_ma_io_off_req_t; + /** @brief PMIC TEST IF request structure. */ typedef struct __NRFS_PACKED { nrfs_hdr_t hdr; /**< Header of the message. */ diff --git a/nrfs/include/services/nrfs_pmic.h b/nrfs/include/services/nrfs_pmic.h index 35050eac..59fa5dd5 100644 --- a/nrfs/include/services/nrfs_pmic.h +++ b/nrfs/include/services/nrfs_pmic.h @@ -223,6 +223,46 @@ nrfs_err_t nrfs_pmic_pwm_ghost_avoid_set(void * p_context); */ nrfs_err_t nrfs_pmic_pwm_ghost_avoid_set_no_rsp(void); +/** + * @brief Function for requesting MA (Modem and Application) I/O power on + * + * @param[in] p_context Pointer to the context to be associated with request. + * + * @retval NRFS_SUCCESS Request sent successfully. + * @retval NRFS_ERR_INVALID_STATE Service is uninitialized. + * @retval NRFS_ERR_IPC Backend returned error during request sending. + */ +nrfs_err_t nrfs_pmic_ma_io_on(void * p_context); + +/** + * @brief Function for requesting MA (Modem and Application) I/O power on with no response + * + * @retval NRFS_SUCCESS Request sent successfully. + * @retval NRFS_ERR_INVALID_STATE Service is uninitialized. + * @retval NRFS_ERR_IPC Backend returned error during request sending. + */ +nrfs_err_t nrfs_pmic_ma_io_on_no_rsp(void); + +/** + * @brief Function for requesting MA (Modem and Application) I/O power off + * + * @param[in] p_context Pointer to the context to be associated with request. + * + * @retval NRFS_SUCCESS Request sent successfully. + * @retval NRFS_ERR_INVALID_STATE Service is uninitialized. + * @retval NRFS_ERR_IPC Backend returned error during request sending. + */ +nrfs_err_t nrfs_pmic_ma_io_off(void * p_context); + +/** + * @brief Function for requesting MA (Modem and Application) I/O power off with no response + * + * @retval NRFS_SUCCESS Request sent successfully. + * @retval NRFS_ERR_INVALID_STATE Service is uninitialized. + * @retval NRFS_ERR_IPC Backend returned error during request sending. + */ +nrfs_err_t nrfs_pmic_ma_io_off_no_rsp(void); + /** * @brief Function for checking PMIC existence * diff --git a/nrfs/src/services/nrfs_pmic.c b/nrfs/src/services/nrfs_pmic.c index c8f61ce4..bb2cda5c 100644 --- a/nrfs/src/services/nrfs_pmic.c +++ b/nrfs/src/services/nrfs_pmic.c @@ -260,6 +260,62 @@ nrfs_err_t nrfs_pmic_pwm_ghost_avoid_set_no_rsp(void) return nrfs_backend_send(&req, sizeof(req)); } +nrfs_err_t nrfs_pmic_ma_io_on(void * p_context) +{ + if (!m_cb.is_initialized) { + return NRFS_ERR_INVALID_STATE; + } + + nrfs_pmic_ma_io_on_req_t req; + + NRFS_SERVICE_HDR_FILL(&req, NRFS_PMIC_MA_IO_ON); + req.ctx.ctx = (uint32_t)p_context; + + return nrfs_backend_send(&req, sizeof(req)); +} + +nrfs_err_t nrfs_pmic_ma_io_on_no_rsp(void) +{ + if (!m_cb.is_initialized) { + return NRFS_ERR_INVALID_STATE; + } + + nrfs_pmic_ma_io_on_req_t req; + + NRFS_SERVICE_HDR_FILL(&req, NRFS_PMIC_MA_IO_ON); + NRFS_HDR_NO_RSP_SET(&req.hdr); + + return nrfs_backend_send(&req, sizeof(req)); +} + +nrfs_err_t nrfs_pmic_ma_io_off(void * p_context) +{ + if (!m_cb.is_initialized) { + return NRFS_ERR_INVALID_STATE; + } + + nrfs_pmic_ma_io_off_req_t req; + + NRFS_SERVICE_HDR_FILL(&req, NRFS_PMIC_MA_IO_OFF); + req.ctx.ctx = (uint32_t)p_context; + + return nrfs_backend_send(&req, sizeof(req)); +} + +nrfs_err_t nrfs_pmic_ma_io_off_no_rsp(void) +{ + if (!m_cb.is_initialized) { + return NRFS_ERR_INVALID_STATE; + } + + nrfs_pmic_ma_io_off_req_t req; + + NRFS_SERVICE_HDR_FILL(&req, NRFS_PMIC_MA_IO_OFF); + NRFS_HDR_NO_RSP_SET(&req.hdr); + + return nrfs_backend_send(&req, sizeof(req)); +} + nrfs_err_t nrfs_pmic_test_if_read(uint16_t addr, void *p_context) { if (!m_cb.is_initialized) { @@ -332,6 +388,8 @@ void nrfs_pmic_service_notify(void *p_notification, size_t size) case NRFS_PMIC_BLE_RADIO_OFF: case NRFS_PMIC_PWM_DEFAULT: case NRFS_PMIC_PWM_GHOST_AVOID: + case NRFS_PMIC_MA_IO_ON: + case NRFS_PMIC_MA_IO_OFF: evt.type = NRFS_PMIC_EVT_APPLIED; m_cb.handler(&evt, (void *)p_data->ctx.ctx); break;