mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 02:50:49 +09:00
BACKPORT: tty: serial: qcom-geni-serial: use of_device_id data
Instead of checking the device compatible in probe(), assign the
device-specific data to struct of_device_id. We'll use it later when
providing SE DMA support.
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Reviewed-by: Konrad Dybcio <konrad.dybcio@linaro.org>
Link: https://lore.kernel.org/r/20221229155030.418800-13-brgl@bgdev.pl
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Bug: 370629635
Change-Id: I3116f17cf59cefb3d065c402a1dd54fd19686dba
(cherry picked from commit 40ec6d41c8)
Signed-off-by: Praveen Talari <quic_ptalari@quicinc.com>
This commit is contained in:
committed by
Treehugger Robot
parent
3ebd383e35
commit
61df751af7
@@ -95,6 +95,11 @@
|
|||||||
/* We always configure 4 bytes per FIFO word */
|
/* We always configure 4 bytes per FIFO word */
|
||||||
#define BYTES_PER_FIFO_WORD 4U
|
#define BYTES_PER_FIFO_WORD 4U
|
||||||
|
|
||||||
|
struct qcom_geni_device_data {
|
||||||
|
bool console;
|
||||||
|
void (*handle_rx)(struct uart_port *uport, u32 bytes, bool drop);
|
||||||
|
};
|
||||||
|
|
||||||
struct qcom_geni_private_data {
|
struct qcom_geni_private_data {
|
||||||
/* NOTE: earlycon port will have NULL here */
|
/* NOTE: earlycon port will have NULL here */
|
||||||
struct uart_driver *drv;
|
struct uart_driver *drv;
|
||||||
@@ -115,7 +120,6 @@ struct qcom_geni_serial_port {
|
|||||||
u32 rx_fifo_depth;
|
u32 rx_fifo_depth;
|
||||||
bool setup;
|
bool setup;
|
||||||
unsigned long clk_rate;
|
unsigned long clk_rate;
|
||||||
void (*handle_rx)(struct uart_port *uport, u32 bytes, bool drop);
|
|
||||||
unsigned int baud;
|
unsigned int baud;
|
||||||
void *rx_fifo;
|
void *rx_fifo;
|
||||||
u32 loopback;
|
u32 loopback;
|
||||||
@@ -127,6 +131,7 @@ struct qcom_geni_serial_port {
|
|||||||
bool cts_rts_swap;
|
bool cts_rts_swap;
|
||||||
|
|
||||||
struct qcom_geni_private_data private_data;
|
struct qcom_geni_private_data private_data;
|
||||||
|
const struct qcom_geni_device_data *dev_data;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct uart_ops qcom_geni_console_pops;
|
static const struct uart_ops qcom_geni_console_pops;
|
||||||
@@ -640,7 +645,7 @@ static void qcom_geni_serial_handle_rx(struct uart_port *uport, bool drop)
|
|||||||
total_bytes += last_word_byte_cnt;
|
total_bytes += last_word_byte_cnt;
|
||||||
else
|
else
|
||||||
total_bytes += BYTES_PER_FIFO_WORD;
|
total_bytes += BYTES_PER_FIFO_WORD;
|
||||||
port->handle_rx(uport, total_bytes, drop);
|
port->dev_data->handle_rx(uport, total_bytes, drop);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void qcom_geni_serial_stop_rx(struct uart_port *uport)
|
static void qcom_geni_serial_stop_rx(struct uart_port *uport)
|
||||||
@@ -1364,13 +1369,14 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
|
|||||||
struct uart_port *uport;
|
struct uart_port *uport;
|
||||||
struct resource *res;
|
struct resource *res;
|
||||||
int irq;
|
int irq;
|
||||||
bool console = false;
|
|
||||||
struct uart_driver *drv;
|
struct uart_driver *drv;
|
||||||
|
const struct qcom_geni_device_data *data;
|
||||||
|
|
||||||
if (of_device_is_compatible(pdev->dev.of_node, "qcom,geni-debug-uart"))
|
data = of_device_get_match_data(&pdev->dev);
|
||||||
console = true;
|
if (!data)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
if (console) {
|
if (data->console) {
|
||||||
drv = &qcom_geni_console_driver;
|
drv = &qcom_geni_console_driver;
|
||||||
line = of_alias_get_id(pdev->dev.of_node, "serial");
|
line = of_alias_get_id(pdev->dev.of_node, "serial");
|
||||||
} else {
|
} else {
|
||||||
@@ -1380,7 +1386,7 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
|
|||||||
line = of_alias_get_id(pdev->dev.of_node, "hsuart");
|
line = of_alias_get_id(pdev->dev.of_node, "hsuart");
|
||||||
}
|
}
|
||||||
|
|
||||||
port = get_port_from_line(line, console);
|
port = get_port_from_line(line, data->console);
|
||||||
if (IS_ERR(port)) {
|
if (IS_ERR(port)) {
|
||||||
dev_err(&pdev->dev, "Invalid line %d\n", line);
|
dev_err(&pdev->dev, "Invalid line %d\n", line);
|
||||||
return PTR_ERR(port);
|
return PTR_ERR(port);
|
||||||
@@ -1392,6 +1398,7 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
|
|||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
uport->dev = &pdev->dev;
|
uport->dev = &pdev->dev;
|
||||||
|
port->dev_data = data;
|
||||||
port->se.dev = &pdev->dev;
|
port->se.dev = &pdev->dev;
|
||||||
port->se.wrapper = dev_get_drvdata(pdev->dev.parent);
|
port->se.wrapper = dev_get_drvdata(pdev->dev.parent);
|
||||||
port->se.clk = devm_clk_get(&pdev->dev, "se");
|
port->se.clk = devm_clk_get(&pdev->dev, "se");
|
||||||
@@ -1410,7 +1417,7 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
|
|||||||
port->rx_fifo_depth = DEF_FIFO_DEPTH_WORDS;
|
port->rx_fifo_depth = DEF_FIFO_DEPTH_WORDS;
|
||||||
port->tx_fifo_width = DEF_FIFO_WIDTH_BITS;
|
port->tx_fifo_width = DEF_FIFO_WIDTH_BITS;
|
||||||
|
|
||||||
if (!console) {
|
if (!data->console) {
|
||||||
port->rx_fifo = devm_kcalloc(uport->dev,
|
port->rx_fifo = devm_kcalloc(uport->dev,
|
||||||
port->rx_fifo_depth, sizeof(u32), GFP_KERNEL);
|
port->rx_fifo_depth, sizeof(u32), GFP_KERNEL);
|
||||||
if (!port->rx_fifo)
|
if (!port->rx_fifo)
|
||||||
@@ -1440,7 +1447,7 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
|
|||||||
uport->irq = irq;
|
uport->irq = irq;
|
||||||
uport->has_sysrq = IS_ENABLED(CONFIG_SERIAL_QCOM_GENI_CONSOLE);
|
uport->has_sysrq = IS_ENABLED(CONFIG_SERIAL_QCOM_GENI_CONSOLE);
|
||||||
|
|
||||||
if (!console)
|
if (!data->console)
|
||||||
port->wakeup_irq = platform_get_irq_optional(pdev, 1);
|
port->wakeup_irq = platform_get_irq_optional(pdev, 1);
|
||||||
|
|
||||||
if (of_property_read_bool(pdev->dev.of_node, "rx-tx-swap"))
|
if (of_property_read_bool(pdev->dev.of_node, "rx-tx-swap"))
|
||||||
@@ -1462,7 +1469,6 @@ static int qcom_geni_serial_probe(struct platform_device *pdev)
|
|||||||
port->private_data.drv = drv;
|
port->private_data.drv = drv;
|
||||||
uport->private_data = &port->private_data;
|
uport->private_data = &port->private_data;
|
||||||
platform_set_drvdata(pdev, port);
|
platform_set_drvdata(pdev, port);
|
||||||
port->handle_rx = console ? handle_rx_console : handle_rx_uart;
|
|
||||||
|
|
||||||
irq_set_status_flags(uport->irq, IRQ_NOAUTOEN);
|
irq_set_status_flags(uport->irq, IRQ_NOAUTOEN);
|
||||||
ret = devm_request_irq(uport->dev, uport->irq, qcom_geni_serial_isr,
|
ret = devm_request_irq(uport->dev, uport->irq, qcom_geni_serial_isr,
|
||||||
@@ -1566,6 +1572,16 @@ static int qcom_geni_serial_sys_hib_resume(struct device *dev)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const struct qcom_geni_device_data qcom_geni_console_data = {
|
||||||
|
.console = true,
|
||||||
|
.handle_rx = handle_rx_console,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct qcom_geni_device_data qcom_geni_uart_data = {
|
||||||
|
.console = false,
|
||||||
|
.handle_rx = handle_rx_uart,
|
||||||
|
};
|
||||||
|
|
||||||
static const struct dev_pm_ops qcom_geni_serial_pm_ops = {
|
static const struct dev_pm_ops qcom_geni_serial_pm_ops = {
|
||||||
.suspend = pm_sleep_ptr(qcom_geni_serial_sys_suspend),
|
.suspend = pm_sleep_ptr(qcom_geni_serial_sys_suspend),
|
||||||
.resume = pm_sleep_ptr(qcom_geni_serial_sys_resume),
|
.resume = pm_sleep_ptr(qcom_geni_serial_sys_resume),
|
||||||
@@ -1576,8 +1592,14 @@ static const struct dev_pm_ops qcom_geni_serial_pm_ops = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static const struct of_device_id qcom_geni_serial_match_table[] = {
|
static const struct of_device_id qcom_geni_serial_match_table[] = {
|
||||||
{ .compatible = "qcom,geni-debug-uart", },
|
{
|
||||||
{ .compatible = "qcom,geni-uart", },
|
.compatible = "qcom,geni-debug-uart",
|
||||||
|
.data = &qcom_geni_console_data,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.compatible = "qcom,geni-uart",
|
||||||
|
.data = &qcom_geni_uart_data,
|
||||||
|
},
|
||||||
{}
|
{}
|
||||||
};
|
};
|
||||||
MODULE_DEVICE_TABLE(of, qcom_geni_serial_match_table);
|
MODULE_DEVICE_TABLE(of, qcom_geni_serial_match_table);
|
||||||
|
|||||||
Reference in New Issue
Block a user