uart_qmsi: Use qm_uart_*_context API
Remove the Zephyr implementation and update the uart_qmsi driver to use new QMSI PM APIs. Jira: ZEP-998 Change-Id: I418e6384c16e374e9062820e12648a2d524a312d Signed-off-by: JuanX Solano Menacho <juanx.solano.menacho@intel.com>
This commit is contained in:
parent
f8130521e2
commit
8a287b1016
1 changed files with 12 additions and 66 deletions
|
@ -62,23 +62,13 @@ struct uart_qmsi_drv_data {
|
|||
|
||||
#define uart_qmsi_set_power_state(...)
|
||||
#else
|
||||
struct uart_context_t {
|
||||
uint32_t ier; /**< Interrupt Enable Register. */
|
||||
uint32_t dlh; /**< Divisor Latch High. */
|
||||
uint32_t dll; /**< Divisor Latch Low. */
|
||||
uint32_t lcr; /**< Line Control. */
|
||||
uint32_t mcr; /**< Modem Control. */
|
||||
uint32_t scr; /**< Scratchpad. */
|
||||
uint32_t htx; /**< Halt Transmission. */
|
||||
uint32_t dlf; /**< Divisor Latch Fraction. */
|
||||
uint32_t int_uart_mask; /**< Interrupt Mask. */
|
||||
};
|
||||
|
||||
struct uart_qmsi_drv_data {
|
||||
uart_irq_callback_t user_cb;
|
||||
uint8_t iir_cache;
|
||||
struct uart_context_t ctx_save;
|
||||
uint32_t device_power_state;
|
||||
#ifdef CONFIG_SYS_POWER_DEEP_SLEEP
|
||||
qm_uart_context_t ctx;
|
||||
#endif
|
||||
};
|
||||
|
||||
static void uart_qmsi_set_power_state(struct device *dev, uint32_t power_state)
|
||||
|
@ -95,35 +85,17 @@ static uint32_t uart_qmsi_get_power_state(struct device *dev)
|
|||
return context->device_power_state;
|
||||
}
|
||||
|
||||
#ifdef CONFIG_SYS_POWER_DEEP_SLEEP
|
||||
static int uart_suspend_device(struct device *dev)
|
||||
{
|
||||
const struct uart_qmsi_config_info *config = dev->config->config_info;
|
||||
struct uart_qmsi_drv_data *drv_data = dev->driver_data;
|
||||
|
||||
if (device_busy_check(dev)) {
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
const struct uart_qmsi_config_info *config = dev->config->config_info;
|
||||
qm_uart_reg_t *const regs = QM_UART[config->instance];
|
||||
struct uart_qmsi_drv_data *drv_data = dev->driver_data;
|
||||
struct uart_context_t *const ctx_save = &drv_data->ctx_save;
|
||||
|
||||
if (config->instance == QM_UART_0) {
|
||||
ctx_save->int_uart_mask = QM_INTERRUPT_ROUTER->uart_0_int_mask;
|
||||
} else {
|
||||
ctx_save->int_uart_mask = QM_INTERRUPT_ROUTER->uart_1_int_mask;
|
||||
}
|
||||
|
||||
ctx_save->ier = regs->ier_dlh;
|
||||
ctx_save->lcr = regs->lcr;
|
||||
ctx_save->mcr = regs->mcr;
|
||||
ctx_save->scr = regs->scr;
|
||||
ctx_save->htx = regs->htx;
|
||||
ctx_save->dlf = regs->dlf;
|
||||
|
||||
/* When DLAB is set, DLL and DLH registers can be accessed. */
|
||||
regs->lcr |= QM_UART_LCR_DLAB;
|
||||
ctx_save->dlh = regs->ier_dlh;
|
||||
ctx_save->dll = regs->rbr_thr_dll;
|
||||
regs->lcr &= ~QM_UART_LCR_DLAB;
|
||||
qm_uart_save_context(config->instance, &drv_data->ctx);
|
||||
|
||||
uart_qmsi_set_power_state(dev, DEVICE_PM_SUSPEND_STATE);
|
||||
|
||||
|
@ -133,45 +105,17 @@ static int uart_suspend_device(struct device *dev)
|
|||
static int uart_resume_device_from_suspend(struct device *dev)
|
||||
{
|
||||
const struct uart_qmsi_config_info *config = dev->config->config_info;
|
||||
qm_uart_reg_t *const regs = QM_UART[config->instance];
|
||||
struct uart_qmsi_drv_data *drv_data = dev->driver_data;
|
||||
struct uart_context_t *const ctx_save = &drv_data->ctx_save;
|
||||
|
||||
clk_periph_enable(config->clock_gate);
|
||||
|
||||
if (config->instance == QM_UART_0) {
|
||||
QM_INTERRUPT_ROUTER->uart_0_int_mask = ctx_save->int_uart_mask;
|
||||
} else {
|
||||
QM_INTERRUPT_ROUTER->uart_1_int_mask = ctx_save->int_uart_mask;
|
||||
}
|
||||
|
||||
/* When DLAB is set, DLL and DLH registers can be accessed. */
|
||||
regs->lcr |= QM_UART_LCR_DLAB;
|
||||
regs->ier_dlh = ctx_save->dlh;
|
||||
regs->rbr_thr_dll = ctx_save->dll;
|
||||
regs->lcr &= ~QM_UART_LCR_DLAB;
|
||||
|
||||
regs->ier_dlh = ctx_save->ier;
|
||||
regs->lcr = ctx_save->lcr;
|
||||
regs->mcr = ctx_save->mcr;
|
||||
regs->scr = ctx_save->scr;
|
||||
regs->htx = ctx_save->htx;
|
||||
regs->dlf = ctx_save->dlf;
|
||||
|
||||
/*
|
||||
* FIFO control register cannot be read back,
|
||||
* default config is applied for this register.
|
||||
* Application will need to restore its own parameters.
|
||||
*/
|
||||
regs->iir_fcr =
|
||||
(QM_UART_FCR_FIFOE | QM_UART_FCR_RFIFOR |
|
||||
QM_UART_FCR_XFIFOR |
|
||||
QM_UART_FCR_DEFAULT_TX_RX_THRESHOLD);
|
||||
qm_uart_restore_context(config->instance, &drv_data->ctx);
|
||||
|
||||
uart_qmsi_set_power_state(dev, DEVICE_PM_ACTIVE_STATE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Implements the driver control management functionality
|
||||
|
@ -181,11 +125,13 @@ static int uart_qmsi_device_ctrl(struct device *dev, uint32_t ctrl_command,
|
|||
void *context)
|
||||
{
|
||||
if (ctrl_command == DEVICE_PM_SET_POWER_STATE) {
|
||||
#ifdef CONFIG_SYS_POWER_DEEP_SLEEP
|
||||
if (*((uint32_t *)context) == DEVICE_PM_SUSPEND_STATE) {
|
||||
return uart_suspend_device(dev);
|
||||
} else if (*((uint32_t *)context) == DEVICE_PM_ACTIVE_STATE) {
|
||||
return uart_resume_device_from_suspend(dev);
|
||||
}
|
||||
#endif
|
||||
} else if (ctrl_command == DEVICE_PM_GET_POWER_STATE) {
|
||||
*((uint32_t *)context) = uart_qmsi_get_power_state(dev);
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue