Commit e5b57c03 authored by Felipe Balbi's avatar Felipe Balbi Committed by Greg Kroah-Hartman

serial: omap: define helpers for pdata function pointers

this patch is in preparation to a few other changes
which will align on the prototype for function
pointers passed through pdata.

It also helps cleaning up the driver a little by
agregating checks for pdata in a single location.
Tested-by: default avatarShubhrajyoti D <shubhrajyoti@ti.com>
Acked-by: default avatarSantosh Shilimkar <santosh.shilimkar@ti.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent c990f351
...@@ -102,6 +102,40 @@ static inline void serial_omap_clear_fifos(struct uart_omap_port *up) ...@@ -102,6 +102,40 @@ static inline void serial_omap_clear_fifos(struct uart_omap_port *up)
serial_out(up, UART_FCR, 0); serial_out(up, UART_FCR, 0);
} }
static int serial_omap_get_context_loss_count(struct uart_omap_port *up)
{
struct omap_uart_port_info *pdata = up->pdev->dev.platform_data;
if (!pdata->get_context_loss_count)
return 0;
return pdata->get_context_loss_count(&up->pdev->dev);
}
static void serial_omap_set_forceidle(struct uart_omap_port *up)
{
struct omap_uart_port_info *pdata = up->pdev->dev.platform_data;
if (pdata->set_forceidle)
pdata->set_forceidle(up->pdev);
}
static void serial_omap_set_noidle(struct uart_omap_port *up)
{
struct omap_uart_port_info *pdata = up->pdev->dev.platform_data;
if (pdata->set_noidle)
pdata->set_noidle(up->pdev);
}
static void serial_omap_enable_wakeup(struct uart_omap_port *up, bool enable)
{
struct omap_uart_port_info *pdata = up->pdev->dev.platform_data;
if (pdata->enable_wakeup)
pdata->enable_wakeup(up->pdev, enable);
}
/* /*
* serial_omap_get_divisor - calculate divisor value * serial_omap_get_divisor - calculate divisor value
* @port: uart port info * @port: uart port info
...@@ -178,8 +212,8 @@ static void serial_omap_stop_tx(struct uart_port *port) ...@@ -178,8 +212,8 @@ static void serial_omap_stop_tx(struct uart_port *port)
serial_out(up, UART_IER, up->ier); serial_out(up, UART_IER, up->ier);
} }
if (!up->use_dma && pdata && pdata->set_forceidle) if (!up->use_dma && pdata)
pdata->set_forceidle(up->pdev); serial_omap_set_forceidle(up);
pm_runtime_mark_last_busy(&up->pdev->dev); pm_runtime_mark_last_busy(&up->pdev->dev);
pm_runtime_put_autosuspend(&up->pdev->dev); pm_runtime_put_autosuspend(&up->pdev->dev);
...@@ -309,7 +343,6 @@ static inline void serial_omap_enable_ier_thri(struct uart_omap_port *up) ...@@ -309,7 +343,6 @@ static inline void serial_omap_enable_ier_thri(struct uart_omap_port *up)
static void serial_omap_start_tx(struct uart_port *port) static void serial_omap_start_tx(struct uart_port *port)
{ {
struct uart_omap_port *up = to_uart_omap_port(port); struct uart_omap_port *up = to_uart_omap_port(port);
struct omap_uart_port_info *pdata = up->pdev->dev.platform_data;
struct circ_buf *xmit; struct circ_buf *xmit;
unsigned int start; unsigned int start;
int ret = 0; int ret = 0;
...@@ -317,8 +350,7 @@ static void serial_omap_start_tx(struct uart_port *port) ...@@ -317,8 +350,7 @@ static void serial_omap_start_tx(struct uart_port *port)
if (!up->use_dma) { if (!up->use_dma) {
pm_runtime_get_sync(&up->pdev->dev); pm_runtime_get_sync(&up->pdev->dev);
serial_omap_enable_ier_thri(up); serial_omap_enable_ier_thri(up);
if (pdata && pdata->set_noidle) serial_omap_set_noidle(up);
pdata->set_noidle(up->pdev);
pm_runtime_mark_last_busy(&up->pdev->dev); pm_runtime_mark_last_busy(&up->pdev->dev);
pm_runtime_put_autosuspend(&up->pdev->dev); pm_runtime_put_autosuspend(&up->pdev->dev);
return; return;
...@@ -1681,28 +1713,26 @@ static int serial_omap_runtime_suspend(struct device *dev) ...@@ -1681,28 +1713,26 @@ static int serial_omap_runtime_suspend(struct device *dev)
if (!up) if (!up)
return -EINVAL; return -EINVAL;
if (!pdata || !pdata->enable_wakeup) if (!pdata)
return 0; return 0;
if (pdata->get_context_loss_count) up->context_loss_cnt = serial_omap_get_context_loss_count(up);
up->context_loss_cnt = pdata->get_context_loss_count(dev);
if (device_may_wakeup(dev)) { if (device_may_wakeup(dev)) {
if (!up->wakeups_enabled) { if (!up->wakeups_enabled) {
pdata->enable_wakeup(up->pdev, true); serial_omap_enable_wakeup(up, true);
up->wakeups_enabled = true; up->wakeups_enabled = true;
} }
} else { } else {
if (up->wakeups_enabled) { if (up->wakeups_enabled) {
pdata->enable_wakeup(up->pdev, false); serial_omap_enable_wakeup(up, false);
up->wakeups_enabled = false; up->wakeups_enabled = false;
} }
} }
/* Errata i291 */ /* Errata i291 */
if (up->use_dma && pdata->set_forceidle && if (up->use_dma && (up->errata & UART_ERRATA_i291_DMA_FORCEIDLE))
(up->errata & UART_ERRATA_i291_DMA_FORCEIDLE)) serial_omap_set_forceidle(up);
pdata->set_forceidle(up->pdev);
up->latency = PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE; up->latency = PM_QOS_CPU_DMA_LAT_DEFAULT_VALUE;
schedule_work(&up->qos_work); schedule_work(&up->qos_work);
...@@ -1716,17 +1746,15 @@ static int serial_omap_runtime_resume(struct device *dev) ...@@ -1716,17 +1746,15 @@ static int serial_omap_runtime_resume(struct device *dev)
struct omap_uart_port_info *pdata = dev->platform_data; struct omap_uart_port_info *pdata = dev->platform_data;
if (up && pdata) { if (up && pdata) {
if (pdata->get_context_loss_count) { u32 loss_cnt = serial_omap_get_context_loss_count(up);
u32 loss_cnt = pdata->get_context_loss_count(dev);
if (up->context_loss_cnt != loss_cnt) if (up->context_loss_cnt != loss_cnt)
serial_omap_restore_context(up); serial_omap_restore_context(up);
}
/* Errata i291 */ /* Errata i291 */
if (up->use_dma && pdata->set_noidle && if ((up->errata & UART_ERRATA_i291_DMA_FORCEIDLE) &&
(up->errata & UART_ERRATA_i291_DMA_FORCEIDLE)) up->use_dma)
pdata->set_noidle(up->pdev); serial_omap_set_noidle(up);
up->latency = up->calc_latency; up->latency = up->calc_latency;
schedule_work(&up->qos_work); schedule_work(&up->qos_work);
......
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