serial: qcom-geni: Use geni_se_set_perf_level() for baud rate perf level

The driver implements its own helper to select the performance level
corresponding to a requested baud rate. The helper duplicates
functionality already provided by geni_se_set_perf_level() in the GENI
core.

Replace the local implementation with the common helper and remove the
associated duplicate definitions and code. This consolidates
performance-level management in the GENI framework and reduces driver
specific code.

Signed-off-by: Praveen Talari <praveen.talari@oss.qualcomm.com>
Link: https://patch.msgid.link/20260801-reuse_common_geni_framework_helpers-v2-3-13753256ef71@oss.qualcomm.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Praveen Talari 2026-08-01 11:18:17 +05:30 committed by Greg Kroah-Hartman
parent 4b3f927b74
commit f56b8eef48

View File

@ -109,14 +109,12 @@
#define DMA_RX_BUF_SIZE 2048
static DEFINE_IDA(port_ida);
#define DOMAIN_IDX_POWER 0
#define DOMAIN_IDX_PERF 1
struct qcom_geni_device_data {
bool console;
enum geni_se_xfer_mode mode;
int (*resources_init)(struct geni_se *se);
int (*set_rate)(struct uart_port *uport, unsigned int baud);
int (*set_rate)(struct geni_se *se, unsigned long baud);
int (*power_on)(struct geni_se *se);
int (*power_off)(struct geni_se *se);
};
@ -1440,9 +1438,10 @@ static int qcom_geni_serial_startup(struct uart_port *uport)
return 0;
}
static int geni_serial_set_rate(struct uart_port *uport, unsigned int baud)
static int geni_serial_set_rate(struct geni_se *se, unsigned long baud)
{
struct qcom_geni_serial_port *port = to_dev_port(uport);
struct qcom_geni_serial_port *port = dev_get_drvdata(se->dev);
struct uart_port *uport = &port->uport;
unsigned long clk_rate;
unsigned int avg_bw_core, clk_idx;
unsigned int clk_div;
@ -1458,7 +1457,7 @@ static int geni_serial_set_rate(struct uart_port *uport, unsigned int baud)
ret = geni_se_clk_freq_match(&port->se, baud * sampling_rate, &clk_idx, &clk_rate, false);
if (ret) {
dev_err(port->se.dev, "Failed to find src clk for baud rate: %d ret: %d\n",
dev_err(port->se.dev, "Failed to find src clk for baud rate: %lu ret: %d\n",
baud, ret);
return ret;
}
@ -1496,42 +1495,6 @@ static int geni_serial_set_rate(struct uart_port *uport, unsigned int baud)
return 0;
}
static int geni_serial_set_level(struct uart_port *uport, unsigned int baud)
{
struct qcom_geni_serial_port *port = to_dev_port(uport);
struct device *perf_dev = port->se.pd_list->pd_devs[DOMAIN_IDX_PERF];
/*
* The performance protocol sets UART communication
* speeds by selecting different performance levels
* through the OPP framework.
*
* Supported perf levels for baudrates in firmware are below
* +---------------------+--------------------+
* | Perf level value | Baudrate values |
* +---------------------+--------------------+
* | 300 | 300 |
* | 1200 | 1200 |
* | 2400 | 2400 |
* | 4800 | 4800 |
* | 9600 | 9600 |
* | 19200 | 19200 |
* | 38400 | 38400 |
* | 57600 | 57600 |
* | 115200 | 115200 |
* | 230400 | 230400 |
* | 460800 | 460800 |
* | 921600 | 921600 |
* | 2000000 | 2000000 |
* | 3000000 | 3000000 |
* | 3200000 | 3200000 |
* | 4000000 | 4000000 |
* +---------------------+--------------------+
*/
return dev_pm_opp_set_level(perf_dev, baud);
}
static void qcom_geni_serial_set_termios(struct uart_port *uport,
struct ktermios *termios,
const struct ktermios *old)
@ -1550,7 +1513,7 @@ static void qcom_geni_serial_set_termios(struct uart_port *uport,
/* baud rate */
baud = uart_get_baud_rate(uport, termios, old, 300, 8000000);
ret = port->dev_data->set_rate(uport, baud);
ret = port->dev_data->set_rate(&port->se, baud);
if (ret)
return;
@ -2161,7 +2124,7 @@ static const struct qcom_geni_device_data sa8255p_qcom_geni_console_data = {
.console = true,
.mode = GENI_SE_FIFO,
.resources_init = geni_se_domain_attach,
.set_rate = geni_serial_set_level,
.set_rate = geni_se_set_perf_level,
};
#endif
@ -2178,7 +2141,7 @@ static const struct qcom_geni_device_data sa8255p_qcom_geni_uart_data = {
.console = false,
.mode = GENI_SE_DMA,
.resources_init = geni_se_domain_attach,
.set_rate = geni_serial_set_level,
.set_rate = geni_se_set_perf_level,
};
static const struct dev_pm_ops qcom_geni_serial_pm_ops = {