* [PATCH v1 00/12] serial: cpm_uart: Cleanup and refactoring
@ 2023-08-03 13:56 Christophe Leroy
2023-08-03 13:56 ` [PATCH v1 01/12] serial: cpm_uart: Avoid suspicious locking Christophe Leroy
` (11 more replies)
0 siblings, 12 replies; 13+ messages in thread
From: Christophe Leroy @ 2023-08-03 13:56 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby, Michael Ellerman, Nicholas Piggin,
Timur Tabi
Cc: linuxppc-dev, linux-kernel, linux-serial
This series is a dust removal and cleanup of cpm_uart serial driver.
After cleaning up things we see that CPM1 and CPM2 have so much in
common that it is not worth keeping separate code.
Once refactoring is done, there is only one .c and one .h in cpm_uart/
subdirectory so its worth getting rid of cpm_uart/ subdir.
The last part leads to the complete removal of include/linux/fs_uart_pd.h
Christophe Leroy (12):
serial: cpm_uart: Avoid suspicious locking
serial: cpm_uart: Remove stale prototypes and table and macros
serial: cpm_uart: Stop using fs_uart_id enum
serial: cpm_uart: Use get_baudrate() instead of uart_baudrate()
serial: cpm_uart: Deduplicate cpm_set_{brg/smc_fcr/scc_fcr}()
serial: cpm_uart: Deduplicate cpm_line_cr_cmd()
serial: cpm_uart: Refactor cpm_uart_allocbuf()/cpm_uart_freebuf()
serial: cpm_uart: Refactor cpm_uart_[un]map_pram()
serial: cpm_uart: Remove cpm_uart/ subdirectory
serial: cpm_uart: Remove stale prototype in powerpc/fsl_soc.c
serial: cpm_uart: Don't include fs_uart_pd.h when not needed
serial: cpm_uart: Remove linux/fs_uart_pd.h
arch/powerpc/include/asm/fs_pd.h | 10 --
arch/powerpc/platforms/8xx/mpc885ads_setup.c | 1 -
arch/powerpc/platforms/8xx/tqm8xx_setup.c | 1 -
arch/powerpc/sysdev/fsl_soc.c | 2 -
drivers/tty/serial/Makefile | 2 +-
.../{cpm_uart/cpm_uart_core.c => cpm_uart.c} | 157 ++++++++++++++++--
drivers/tty/serial/{cpm_uart => }/cpm_uart.h | 38 +----
drivers/tty/serial/cpm_uart/Makefile | 12 --
drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c | 122 --------------
drivers/tty/serial/cpm_uart/cpm_uart_cpm1.h | 33 ----
drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c | 156 -----------------
drivers/tty/serial/cpm_uart/cpm_uart_cpm2.h | 33 ----
drivers/tty/serial/ucc_uart.c | 1 -
include/linux/fs_uart_pd.h | 71 --------
14 files changed, 145 insertions(+), 494 deletions(-)
rename drivers/tty/serial/{cpm_uart/cpm_uart_core.c => cpm_uart.c} (90%)
rename drivers/tty/serial/{cpm_uart => }/cpm_uart.h (64%)
delete mode 100644 drivers/tty/serial/cpm_uart/Makefile
delete mode 100644 drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c
delete mode 100644 drivers/tty/serial/cpm_uart/cpm_uart_cpm1.h
delete mode 100644 drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c
delete mode 100644 drivers/tty/serial/cpm_uart/cpm_uart_cpm2.h
delete mode 100644 include/linux/fs_uart_pd.h
--
2.41.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v1 01/12] serial: cpm_uart: Avoid suspicious locking
2023-08-03 13:56 [PATCH v1 00/12] serial: cpm_uart: Cleanup and refactoring Christophe Leroy
@ 2023-08-03 13:56 ` Christophe Leroy
2023-08-03 13:56 ` [PATCH v1 02/12] serial: cpm_uart: Remove stale prototypes and table and macros Christophe Leroy
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Christophe Leroy @ 2023-08-03 13:56 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby, Michael Ellerman, Nicholas Piggin,
Timur Tabi
Cc: linuxppc-dev, linux-kernel, linux-serial
CHECK drivers/tty/serial/cpm_uart/cpm_uart_core.c
drivers/tty/serial/cpm_uart/cpm_uart_core.c:1271:39: warning: context imbalance in 'cpm_uart_console_write' - unexpected unlock
Allthough 'nolock' is not expected to change, sparse find the following
form suspicious:
if (unlikely(nolock)) {
local_irq_save(flags);
} else {
spin_lock_irqsave(&pinfo->port.lock, flags);
}
cpm_uart_early_write(pinfo, s, count, true);
if (unlikely(nolock)) {
local_irq_restore(flags);
} else {
spin_unlock_irqrestore(&pinfo->port.lock, flags);
}
Rewrite it a more obvious form:
if (unlikely(oops_in_progress)) {
local_irq_save(flags);
cpm_uart_early_write(pinfo, s, count, true);
local_irq_restore(flags);
} else {
spin_lock_irqsave(&pinfo->port.lock, flags);
cpm_uart_early_write(pinfo, s, count, true);
spin_unlock_irqrestore(&pinfo->port.lock, flags);
}
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
drivers/tty/serial/cpm_uart/cpm_uart_core.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
index 66afa9bea6bf..71366a4cea22 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
@@ -1255,19 +1255,14 @@ static void cpm_uart_console_write(struct console *co, const char *s,
{
struct uart_cpm_port *pinfo = &cpm_uart_ports[co->index];
unsigned long flags;
- int nolock = oops_in_progress;
- if (unlikely(nolock)) {
+ if (unlikely(oops_in_progress)) {
local_irq_save(flags);
- } else {
- spin_lock_irqsave(&pinfo->port.lock, flags);
- }
-
- cpm_uart_early_write(pinfo, s, count, true);
-
- if (unlikely(nolock)) {
+ cpm_uart_early_write(pinfo, s, count, true);
local_irq_restore(flags);
} else {
+ spin_lock_irqsave(&pinfo->port.lock, flags);
+ cpm_uart_early_write(pinfo, s, count, true);
spin_unlock_irqrestore(&pinfo->port.lock, flags);
}
}
--
2.41.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v1 02/12] serial: cpm_uart: Remove stale prototypes and table and macros
2023-08-03 13:56 [PATCH v1 00/12] serial: cpm_uart: Cleanup and refactoring Christophe Leroy
2023-08-03 13:56 ` [PATCH v1 01/12] serial: cpm_uart: Avoid suspicious locking Christophe Leroy
@ 2023-08-03 13:56 ` Christophe Leroy
2023-08-03 13:56 ` [PATCH v1 03/12] serial: cpm_uart: Stop using fs_uart_id enum Christophe Leroy
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Christophe Leroy @ 2023-08-03 13:56 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby, Michael Ellerman, Nicholas Piggin,
Timur Tabi
Cc: linuxppc-dev, linux-kernel, linux-serial
cpm_uart_init_portdesc()
smc1_lineif()
smc2_lineif()
scc1_lineif()
scc2_lineif()
scc3_lineif()
scc4_lineif()
Those functions were removed by commit 0b2a2e5b7747 ("cpm_uart: Remove
!CONFIG_PPC_CPM_NEW_BINDING code"). Remove stale prototypes.
UART_SMC{1..2} and UART_SCC{1..4} and SCC_WAIT_CLOSING macros are not
used anymore since the above commit.
cpm_uart_ports[] isn't used outside cpm_uart_core.c since the
same commit, so make it static.
cpm_uart_init_smc() and cpm_uart_init_scc() don't need a forward
declaration.
FLAG_DISCARDING and IS_DISCARDING have never been used since at
least 2.6.12 and the start of git repository for kernel.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
drivers/tty/serial/cpm_uart/cpm_uart.h | 21 ---------------------
drivers/tty/serial/cpm_uart/cpm_uart_core.c | 4 +---
2 files changed, 1 insertion(+), 24 deletions(-)
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart.h b/drivers/tty/serial/cpm_uart/cpm_uart.h
index 46c03ed71c31..687b48fc6fb6 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart.h
+++ b/drivers/tty/serial/cpm_uart/cpm_uart.h
@@ -25,18 +25,9 @@ struct gpio_desc;
#define SERIAL_CPM_MINOR 46
#define IS_SMC(pinfo) (pinfo->flags & FLAG_SMC)
-#define IS_DISCARDING(pinfo) (pinfo->flags & FLAG_DISCARDING)
-#define FLAG_DISCARDING 0x00000004 /* when set, don't discard */
#define FLAG_SMC 0x00000002
#define FLAG_CONSOLE 0x00000001
-#define UART_SMC1 fsid_smc1_uart
-#define UART_SMC2 fsid_smc2_uart
-#define UART_SCC1 fsid_scc1_uart
-#define UART_SCC2 fsid_scc2_uart
-#define UART_SCC3 fsid_scc3_uart
-#define UART_SCC4 fsid_scc4_uart
-
#define UART_NR fs_uart_nr
#define RX_NUM_FIFO 4
@@ -44,8 +35,6 @@ struct gpio_desc;
#define TX_NUM_FIFO 4
#define TX_BUF_SIZE 32
-#define SCC_WAIT_CLOSING 100
-
#define GPIO_CTS 0
#define GPIO_RTS 1
#define GPIO_DCD 2
@@ -85,24 +74,14 @@ struct uart_cpm_port {
struct gpio_desc *gpios[NUM_GPIOS];
};
-extern struct uart_cpm_port cpm_uart_ports[UART_NR];
-
/* these are located in their respective files */
void cpm_line_cr_cmd(struct uart_cpm_port *port, int cmd);
void __iomem *cpm_uart_map_pram(struct uart_cpm_port *port,
struct device_node *np);
void cpm_uart_unmap_pram(struct uart_cpm_port *port, void __iomem *pram);
-int cpm_uart_init_portdesc(void);
int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned int is_con);
void cpm_uart_freebuf(struct uart_cpm_port *pinfo);
-void smc1_lineif(struct uart_cpm_port *pinfo);
-void smc2_lineif(struct uart_cpm_port *pinfo);
-void scc1_lineif(struct uart_cpm_port *pinfo);
-void scc2_lineif(struct uart_cpm_port *pinfo);
-void scc3_lineif(struct uart_cpm_port *pinfo);
-void scc4_lineif(struct uart_cpm_port *pinfo);
-
/*
virtual to phys transtalion
*/
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
index 71366a4cea22..d804dd4019c0 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
@@ -48,8 +48,6 @@
/**************************************************************/
static int cpm_uart_tx_pump(struct uart_port *port);
-static void cpm_uart_init_smc(struct uart_cpm_port *pinfo);
-static void cpm_uart_init_scc(struct uart_cpm_port *pinfo);
static void cpm_uart_initbd(struct uart_cpm_port *pinfo);
/**************************************************************/
@@ -1128,7 +1126,7 @@ static const struct uart_ops cpm_uart_pops = {
#endif
};
-struct uart_cpm_port cpm_uart_ports[UART_NR];
+static struct uart_cpm_port cpm_uart_ports[UART_NR];
static int cpm_uart_init_port(struct device_node *np,
struct uart_cpm_port *pinfo)
--
2.41.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v1 03/12] serial: cpm_uart: Stop using fs_uart_id enum
2023-08-03 13:56 [PATCH v1 00/12] serial: cpm_uart: Cleanup and refactoring Christophe Leroy
2023-08-03 13:56 ` [PATCH v1 01/12] serial: cpm_uart: Avoid suspicious locking Christophe Leroy
2023-08-03 13:56 ` [PATCH v1 02/12] serial: cpm_uart: Remove stale prototypes and table and macros Christophe Leroy
@ 2023-08-03 13:56 ` Christophe Leroy
2023-08-03 13:56 ` [PATCH v1 04/12] serial: cpm_uart: Use get_baudrate() instead of uart_baudrate() Christophe Leroy
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Christophe Leroy @ 2023-08-03 13:56 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby, Michael Ellerman, Nicholas Piggin,
Timur Tabi
Cc: linuxppc-dev, linux-kernel, linux-serial
Using an enum indirection to define numeric macros is
pointless. Directly use the wanted numeric value.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
drivers/tty/serial/cpm_uart/cpm_uart.h | 3 +--
drivers/tty/serial/cpm_uart/cpm_uart_core.c | 1 -
2 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart.h b/drivers/tty/serial/cpm_uart/cpm_uart.h
index 687b48fc6fb6..c220700df693 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart.h
+++ b/drivers/tty/serial/cpm_uart/cpm_uart.h
@@ -11,7 +11,6 @@
#define CPM_UART_H
#include <linux/platform_device.h>
-#include <linux/fs_uart_pd.h>
struct gpio_desc;
@@ -28,7 +27,7 @@ struct gpio_desc;
#define FLAG_SMC 0x00000002
#define FLAG_CONSOLE 0x00000001
-#define UART_NR fs_uart_nr
+#define UART_NR 6
#define RX_NUM_FIFO 4
#define RX_BUF_SIZE 32
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
index d804dd4019c0..c5a896f79d80 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
@@ -26,7 +26,6 @@
#include <linux/device.h>
#include <linux/memblock.h>
#include <linux/dma-mapping.h>
-#include <linux/fs_uart_pd.h>
#include <linux/of_address.h>
#include <linux/of_irq.h>
#include <linux/of_platform.h>
--
2.41.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v1 04/12] serial: cpm_uart: Use get_baudrate() instead of uart_baudrate()
2023-08-03 13:56 [PATCH v1 00/12] serial: cpm_uart: Cleanup and refactoring Christophe Leroy
` (2 preceding siblings ...)
2023-08-03 13:56 ` [PATCH v1 03/12] serial: cpm_uart: Stop using fs_uart_id enum Christophe Leroy
@ 2023-08-03 13:56 ` Christophe Leroy
2023-08-03 13:56 ` [PATCH v1 05/12] serial: cpm_uart: Deduplicate cpm_set_{brg/smc_fcr/scc_fcr}() Christophe Leroy
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Christophe Leroy @ 2023-08-03 13:56 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby, Michael Ellerman, Nicholas Piggin,
Timur Tabi
Cc: linuxppc-dev, linux-kernel, linux-serial
uart_baudrate() is just a trivial wrapper to get_baudrate().
Use get_baudrate() directly and remove assignment in if condition.
And also remove uart_clock() which is not used since
commit 0b2a2e5b7747 ("cpm_uart: Remove !CONFIG_PPC_CPM_NEW_BINDING
code")
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
arch/powerpc/include/asm/fs_pd.h | 10 ----------
drivers/tty/serial/cpm_uart/cpm_uart_core.c | 6 ++++--
2 files changed, 4 insertions(+), 12 deletions(-)
diff --git a/arch/powerpc/include/asm/fs_pd.h b/arch/powerpc/include/asm/fs_pd.h
index 8def56ec05c6..7b61b80f212d 100644
--- a/arch/powerpc/include/asm/fs_pd.h
+++ b/arch/powerpc/include/asm/fs_pd.h
@@ -36,14 +36,4 @@ extern immap_t __iomem *mpc8xx_immr;
#define immr_unmap(addr) do {} while (0)
#endif
-static inline int uart_baudrate(void)
-{
- return get_baudrate();
-}
-
-static inline int uart_clock(void)
-{
- return ppc_proc_freq;
-}
-
#endif
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
index c5a896f79d80..36bac4390c13 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
@@ -32,10 +32,11 @@
#include <linux/gpio/consumer.h>
#include <linux/clk.h>
+#include <sysdev/fsl_soc.h>
+
#include <asm/io.h>
#include <asm/irq.h>
#include <asm/delay.h>
-#include <asm/fs_pd.h>
#include <asm/udbg.h>
#include <linux/serial_core.h>
@@ -1311,7 +1312,8 @@ static int __init cpm_uart_console_setup(struct console *co, char *options)
if (options) {
uart_parse_options(options, &baud, &parity, &bits, &flow);
} else {
- if ((baud = uart_baudrate()) == -1)
+ baud = get_baudrate();
+ if (baud == -1)
baud = 9600;
}
--
2.41.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v1 05/12] serial: cpm_uart: Deduplicate cpm_set_{brg/smc_fcr/scc_fcr}()
2023-08-03 13:56 [PATCH v1 00/12] serial: cpm_uart: Cleanup and refactoring Christophe Leroy
` (3 preceding siblings ...)
2023-08-03 13:56 ` [PATCH v1 04/12] serial: cpm_uart: Use get_baudrate() instead of uart_baudrate() Christophe Leroy
@ 2023-08-03 13:56 ` Christophe Leroy
2023-08-03 13:56 ` [PATCH v1 06/12] serial: cpm_uart: Deduplicate cpm_line_cr_cmd() Christophe Leroy
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Christophe Leroy @ 2023-08-03 13:56 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby, Michael Ellerman, Nicholas Piggin,
Timur Tabi
Cc: linuxppc-dev, linux-kernel, linux-serial
CPMFCR_EB is the same as SMC_EB and is defined
for both CPM1 and CPM2.
CPMFCR_GBL is defined as 0 for CPM1.
Therefore the CPM2 version of cpm_set_scc_fcr() and
cpm_set_smc_fcr() can be used on both CPM1 and CPM2.
And cpm_set_brg() is already identical and just a
wrapper of cpm_setbrg().
In addition those three fonctions are only called once
from cpm_uart_core.c, so just replace the calls with
the content of the CPM2 versions of them.
And DPRAM_BASE is identical so can go in cpm_uart.h. While
moving it, use cpm_muram_addr() directly instead of the
cpm_dpram_addr() macro and remove __force tag which isn't needed.
Then cpm_uart_cpm1.h and cpm_uart_cpm2.h go away.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
drivers/tty/serial/cpm_uart/cpm_uart.h | 6 ++--
drivers/tty/serial/cpm_uart/cpm_uart_core.c | 8 +++--
drivers/tty/serial/cpm_uart/cpm_uart_cpm1.h | 33 ---------------------
drivers/tty/serial/cpm_uart/cpm_uart_cpm2.h | 33 ---------------------
4 files changed, 9 insertions(+), 71 deletions(-)
delete mode 100644 drivers/tty/serial/cpm_uart/cpm_uart_cpm1.h
delete mode 100644 drivers/tty/serial/cpm_uart/cpm_uart_cpm2.h
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart.h b/drivers/tty/serial/cpm_uart/cpm_uart.h
index c220700df693..81c1c5f97d19 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart.h
+++ b/drivers/tty/serial/cpm_uart/cpm_uart.h
@@ -15,11 +15,13 @@
struct gpio_desc;
#if defined(CONFIG_CPM2)
-#include "cpm_uart_cpm2.h"
+#include "asm/cpm2.h"
#elif defined(CONFIG_CPM1)
-#include "cpm_uart_cpm1.h"
+#include "asm/cpm1.h"
#endif
+#define DPRAM_BASE ((u8 __iomem *)cpm_muram_addr(0))
+
#define SERIAL_CPM_MAJOR 204
#define SERIAL_CPM_MINOR 46
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
index 36bac4390c13..743892c0e143 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
@@ -603,7 +603,7 @@ static void cpm_uart_set_termios(struct uart_port *port,
if (pinfo->clk)
clk_set_rate(pinfo->clk, baud);
else
- cpm_set_brg(pinfo->brg - 1, baud);
+ cpm_setbrg(pinfo->brg - 1, baud);
spin_unlock_irqrestore(&port->lock, flags);
}
@@ -769,7 +769,8 @@ static void cpm_uart_init_scc(struct uart_cpm_port *pinfo)
* parameter ram.
*/
- cpm_set_scc_fcr(sup);
+ out_8(&sup->scc_genscc.scc_rfcr, CPMFCR_GBL | CPMFCR_EB);
+ out_8(&sup->scc_genscc.scc_tfcr, CPMFCR_GBL | CPMFCR_EB);
out_be16(&sup->scc_genscc.scc_mrblr, pinfo->rx_fifosize);
out_be16(&sup->scc_maxidl, 0x10);
@@ -840,7 +841,8 @@ static void cpm_uart_init_smc(struct uart_cpm_port *pinfo)
/* Set up the uart parameters in the
* parameter ram.
*/
- cpm_set_smc_fcr(up);
+ out_8(&up->smc_rfcr, CPMFCR_GBL | CPMFCR_EB);
+ out_8(&up->smc_tfcr, CPMFCR_GBL | CPMFCR_EB);
/* Using idle character time requires some additional tuning. */
out_be16(&up->smc_mrblr, pinfo->rx_fifosize);
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_cpm1.h b/drivers/tty/serial/cpm_uart/cpm_uart_cpm1.h
deleted file mode 100644
index 18ec0849918a..000000000000
--- a/drivers/tty/serial/cpm_uart/cpm_uart_cpm1.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Driver for CPM (SCC/SMC) serial ports
- *
- * definitions for cpm1
- *
- */
-
-#ifndef CPM_UART_CPM1_H
-#define CPM_UART_CPM1_H
-
-#include <asm/cpm1.h>
-
-static inline void cpm_set_brg(int brg, int baud)
-{
- cpm_setbrg(brg, baud);
-}
-
-static inline void cpm_set_scc_fcr(scc_uart_t __iomem * sup)
-{
- out_8(&sup->scc_genscc.scc_rfcr, SMC_EB);
- out_8(&sup->scc_genscc.scc_tfcr, SMC_EB);
-}
-
-static inline void cpm_set_smc_fcr(smc_uart_t __iomem * up)
-{
- out_8(&up->smc_rfcr, SMC_EB);
- out_8(&up->smc_tfcr, SMC_EB);
-}
-
-#define DPRAM_BASE ((u8 __iomem __force *)cpm_dpram_addr(0))
-
-#endif
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.h b/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.h
deleted file mode 100644
index 051a8509c3e5..000000000000
--- a/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/*
- * Driver for CPM (SCC/SMC) serial ports
- *
- * definitions for cpm2
- *
- */
-
-#ifndef CPM_UART_CPM2_H
-#define CPM_UART_CPM2_H
-
-#include <asm/cpm2.h>
-
-static inline void cpm_set_brg(int brg, int baud)
-{
- cpm_setbrg(brg, baud);
-}
-
-static inline void cpm_set_scc_fcr(scc_uart_t __iomem *sup)
-{
- out_8(&sup->scc_genscc.scc_rfcr, CPMFCR_GBL | CPMFCR_EB);
- out_8(&sup->scc_genscc.scc_tfcr, CPMFCR_GBL | CPMFCR_EB);
-}
-
-static inline void cpm_set_smc_fcr(smc_uart_t __iomem *up)
-{
- out_8(&up->smc_rfcr, CPMFCR_GBL | CPMFCR_EB);
- out_8(&up->smc_tfcr, CPMFCR_GBL | CPMFCR_EB);
-}
-
-#define DPRAM_BASE ((u8 __iomem __force *)cpm_dpram_addr(0))
-
-#endif
--
2.41.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v1 06/12] serial: cpm_uart: Deduplicate cpm_line_cr_cmd()
2023-08-03 13:56 [PATCH v1 00/12] serial: cpm_uart: Cleanup and refactoring Christophe Leroy
` (4 preceding siblings ...)
2023-08-03 13:56 ` [PATCH v1 05/12] serial: cpm_uart: Deduplicate cpm_set_{brg/smc_fcr/scc_fcr}() Christophe Leroy
@ 2023-08-03 13:56 ` Christophe Leroy
2023-08-03 13:56 ` [PATCH v1 07/12] serial: cpm_uart: Refactor cpm_uart_allocbuf()/cpm_uart_freebuf() Christophe Leroy
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Christophe Leroy @ 2023-08-03 13:56 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby, Michael Ellerman, Nicholas Piggin,
Timur Tabi
Cc: linuxppc-dev, linux-kernel, linux-serial
cpm_line_cr_cmd() is identical for CPM1 and CPM2 and
is used only in cpm_uart_core.c. Move it there.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
drivers/tty/serial/cpm_uart/cpm_uart.h | 1 -
drivers/tty/serial/cpm_uart/cpm_uart_core.c | 5 +++++
drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c | 5 -----
drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c | 5 -----
4 files changed, 5 insertions(+), 11 deletions(-)
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart.h b/drivers/tty/serial/cpm_uart/cpm_uart.h
index 81c1c5f97d19..1b5523474ab4 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart.h
+++ b/drivers/tty/serial/cpm_uart/cpm_uart.h
@@ -76,7 +76,6 @@ struct uart_cpm_port {
};
/* these are located in their respective files */
-void cpm_line_cr_cmd(struct uart_cpm_port *port, int cmd);
void __iomem *cpm_uart_map_pram(struct uart_cpm_port *port,
struct device_node *np);
void cpm_uart_unmap_pram(struct uart_cpm_port *port, void __iomem *pram);
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
index 743892c0e143..e6f3e4da3144 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
@@ -54,6 +54,11 @@ static void cpm_uart_initbd(struct uart_cpm_port *pinfo);
#define HW_BUF_SPD_THRESHOLD 2400
+static void cpm_line_cr_cmd(struct uart_cpm_port *port, int cmd)
+{
+ cpm_command(port->command, cmd);
+}
+
/*
* Check, if transmit buffers are processed
*/
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c b/drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c
index 56fc527015cb..b5680376ff3c 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c
@@ -36,11 +36,6 @@
/**************************************************************/
-void cpm_line_cr_cmd(struct uart_cpm_port *port, int cmd)
-{
- cpm_command(port->command, cmd);
-}
-
void __iomem *cpm_uart_map_pram(struct uart_cpm_port *port,
struct device_node *np)
{
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c b/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c
index 108af254e8f3..35f539fcfde8 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c
@@ -33,11 +33,6 @@
/**************************************************************/
-void cpm_line_cr_cmd(struct uart_cpm_port *port, int cmd)
-{
- cpm_command(port->command, cmd);
-}
-
void __iomem *cpm_uart_map_pram(struct uart_cpm_port *port,
struct device_node *np)
{
--
2.41.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v1 07/12] serial: cpm_uart: Refactor cpm_uart_allocbuf()/cpm_uart_freebuf()
2023-08-03 13:56 [PATCH v1 00/12] serial: cpm_uart: Cleanup and refactoring Christophe Leroy
` (5 preceding siblings ...)
2023-08-03 13:56 ` [PATCH v1 06/12] serial: cpm_uart: Deduplicate cpm_line_cr_cmd() Christophe Leroy
@ 2023-08-03 13:56 ` Christophe Leroy
2023-08-03 13:56 ` [PATCH v1 08/12] serial: cpm_uart: Refactor cpm_uart_[un]map_pram() Christophe Leroy
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Christophe Leroy @ 2023-08-03 13:56 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby, Michael Ellerman, Nicholas Piggin,
Timur Tabi
Cc: linuxppc-dev, linux-kernel, linux-serial
cpm_uart_freebuf() is identical for CPM1 and CPM2.
cpm_uart_allocbuf() only has a small difference between CPM1 and CPM2
as shown below:
CPM1:
if (is_con) {
/* was hostalloc but changed cause it blows away the */
/* large tlb mapping when pinning the kernel area */
mem_addr = (u8 *) cpm_dpram_addr(cpm_dpalloc(memsz, 8));
dma_addr = (u32)cpm_dpram_phys(mem_addr);
} else
mem_addr = dma_alloc_coherent(pinfo->port.dev, memsz, &dma_addr,
GFP_KERNEL);
CPM2:
if (is_con) {
mem_addr = kzalloc(memsz, GFP_NOWAIT);
dma_addr = virt_to_bus(mem_addr);
}
else
mem_addr = dma_alloc_coherent(pinfo->port.dev, memsz, &dma_addr,
GFP_KERNEL);
Refactor this by using IS_ENABLED(CONFIG_CPM1)
and move both functions in cpm_uart_core.c as they are used only there.
While doing this, add the necessary casts to silence sparse for the CPM1
part. This is because a dma alloc is not expected to be an iomem but
for CPM1 as we use DPRAM this is seen as iomem.
Also replace calls to cpm_dpxxxx() by relevant cpm_muram_xxxx() calls.
This is needed at least for cpm_dpram_phys() which is only defined
for CPM1. Just do the same for all so that cpm_dpxxxx() macros can get
droped in the future.
To silence checkpatch, replace printk(KERN_ERR by pr_err( and display
function name instead of hard coded filename. Also replace
mem_addr == NULL by !mem_addr.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
drivers/tty/serial/cpm_uart/cpm_uart.h | 2 -
drivers/tty/serial/cpm_uart/cpm_uart_core.c | 72 +++++++++++++++++++++
drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c | 69 --------------------
drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c | 69 --------------------
4 files changed, 72 insertions(+), 140 deletions(-)
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart.h b/drivers/tty/serial/cpm_uart/cpm_uart.h
index 1b5523474ab4..6d6046d45bec 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart.h
+++ b/drivers/tty/serial/cpm_uart/cpm_uart.h
@@ -79,8 +79,6 @@ struct uart_cpm_port {
void __iomem *cpm_uart_map_pram(struct uart_cpm_port *port,
struct device_node *np);
void cpm_uart_unmap_pram(struct uart_cpm_port *port, void __iomem *pram);
-int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned int is_con);
-void cpm_uart_freebuf(struct uart_cpm_port *pinfo);
/*
virtual to phys transtalion
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
index e6f3e4da3144..fa5466518536 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
@@ -868,6 +868,78 @@ static void cpm_uart_init_smc(struct uart_cpm_port *pinfo)
setbits16(&sp->smc_smcmr, SMCMR_REN | SMCMR_TEN);
}
+/*
+ * Allocate DP-Ram and memory buffers. We need to allocate a transmit and
+ * receive buffer descriptors from dual port ram, and a character
+ * buffer area from host mem. If we are allocating for the console we need
+ * to do it from bootmem
+ */
+static int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned int is_con)
+{
+ int dpmemsz, memsz;
+ u8 __iomem *dp_mem;
+ unsigned long dp_offset;
+ u8 *mem_addr;
+ dma_addr_t dma_addr = 0;
+
+ pr_debug("CPM uart[%d]:allocbuf\n", pinfo->port.line);
+
+ dpmemsz = sizeof(cbd_t) * (pinfo->rx_nrfifos + pinfo->tx_nrfifos);
+ dp_offset = cpm_muram_alloc(dpmemsz, 8);
+ if (IS_ERR_VALUE(dp_offset)) {
+ pr_err("%s: could not allocate buffer descriptors\n", __func__);
+ return -ENOMEM;
+ }
+
+ dp_mem = cpm_muram_addr(dp_offset);
+
+ memsz = L1_CACHE_ALIGN(pinfo->rx_nrfifos * pinfo->rx_fifosize) +
+ L1_CACHE_ALIGN(pinfo->tx_nrfifos * pinfo->tx_fifosize);
+ if (IS_ENABLED(CONFIG_CPM1) && is_con) {
+ /* was hostalloc but changed cause it blows away the */
+ /* large tlb mapping when pinning the kernel area */
+ mem_addr = (u8 __force *)cpm_muram_addr(cpm_muram_alloc(memsz, 8));
+ dma_addr = cpm_muram_dma((void __iomem *)mem_addr);
+ } else if (is_con) {
+ mem_addr = kzalloc(memsz, GFP_NOWAIT);
+ dma_addr = virt_to_bus(mem_addr);
+ } else {
+ mem_addr = dma_alloc_coherent(pinfo->port.dev, memsz, &dma_addr,
+ GFP_KERNEL);
+ }
+
+ if (!mem_addr) {
+ cpm_muram_free(dp_offset);
+ pr_err("%s: could not allocate coherent memory\n", __func__);
+ return -ENOMEM;
+ }
+
+ pinfo->dp_addr = dp_offset;
+ pinfo->mem_addr = mem_addr;
+ pinfo->dma_addr = dma_addr;
+ pinfo->mem_size = memsz;
+
+ pinfo->rx_buf = mem_addr;
+ pinfo->tx_buf = pinfo->rx_buf + L1_CACHE_ALIGN(pinfo->rx_nrfifos
+ * pinfo->rx_fifosize);
+
+ pinfo->rx_bd_base = (cbd_t __iomem *)dp_mem;
+ pinfo->tx_bd_base = pinfo->rx_bd_base + pinfo->rx_nrfifos;
+
+ return 0;
+}
+
+static void cpm_uart_freebuf(struct uart_cpm_port *pinfo)
+{
+ dma_free_coherent(pinfo->port.dev, L1_CACHE_ALIGN(pinfo->rx_nrfifos *
+ pinfo->rx_fifosize) +
+ L1_CACHE_ALIGN(pinfo->tx_nrfifos *
+ pinfo->tx_fifosize), (void __force *)pinfo->mem_addr,
+ pinfo->dma_addr);
+
+ cpm_muram_free(pinfo->dp_addr);
+}
+
/*
* Initialize port. This is called from early_console stuff
* so we have to be careful here !
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c b/drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c
index b5680376ff3c..3fe436dc2f95 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c
@@ -46,72 +46,3 @@ void cpm_uart_unmap_pram(struct uart_cpm_port *port, void __iomem *pram)
{
iounmap(pram);
}
-
-/*
- * Allocate DP-Ram and memory buffers. We need to allocate a transmit and
- * receive buffer descriptors from dual port ram, and a character
- * buffer area from host mem. If we are allocating for the console we need
- * to do it from bootmem
- */
-int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned int is_con)
-{
- int dpmemsz, memsz;
- u8 *dp_mem;
- unsigned long dp_offset;
- u8 *mem_addr;
- dma_addr_t dma_addr = 0;
-
- pr_debug("CPM uart[%d]:allocbuf\n", pinfo->port.line);
-
- dpmemsz = sizeof(cbd_t) * (pinfo->rx_nrfifos + pinfo->tx_nrfifos);
- dp_offset = cpm_dpalloc(dpmemsz, 8);
- if (IS_ERR_VALUE(dp_offset)) {
- printk(KERN_ERR
- "cpm_uart_cpm1.c: could not allocate buffer descriptors\n");
- return -ENOMEM;
- }
- dp_mem = cpm_dpram_addr(dp_offset);
-
- memsz = L1_CACHE_ALIGN(pinfo->rx_nrfifos * pinfo->rx_fifosize) +
- L1_CACHE_ALIGN(pinfo->tx_nrfifos * pinfo->tx_fifosize);
- if (is_con) {
- /* was hostalloc but changed cause it blows away the */
- /* large tlb mapping when pinning the kernel area */
- mem_addr = (u8 *) cpm_dpram_addr(cpm_dpalloc(memsz, 8));
- dma_addr = (u32)cpm_dpram_phys(mem_addr);
- } else
- mem_addr = dma_alloc_coherent(pinfo->port.dev, memsz, &dma_addr,
- GFP_KERNEL);
-
- if (mem_addr == NULL) {
- cpm_dpfree(dp_offset);
- printk(KERN_ERR
- "cpm_uart_cpm1.c: could not allocate coherent memory\n");
- return -ENOMEM;
- }
-
- pinfo->dp_addr = dp_offset;
- pinfo->mem_addr = mem_addr; /* virtual address*/
- pinfo->dma_addr = dma_addr; /* physical address*/
- pinfo->mem_size = memsz;
-
- pinfo->rx_buf = mem_addr;
- pinfo->tx_buf = pinfo->rx_buf + L1_CACHE_ALIGN(pinfo->rx_nrfifos
- * pinfo->rx_fifosize);
-
- pinfo->rx_bd_base = (cbd_t __iomem __force *)dp_mem;
- pinfo->tx_bd_base = pinfo->rx_bd_base + pinfo->rx_nrfifos;
-
- return 0;
-}
-
-void cpm_uart_freebuf(struct uart_cpm_port *pinfo)
-{
- dma_free_coherent(pinfo->port.dev, L1_CACHE_ALIGN(pinfo->rx_nrfifos *
- pinfo->rx_fifosize) +
- L1_CACHE_ALIGN(pinfo->tx_nrfifos *
- pinfo->tx_fifosize), pinfo->mem_addr,
- pinfo->dma_addr);
-
- cpm_dpfree(pinfo->dp_addr);
-}
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c b/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c
index 35f539fcfde8..09d46255aa9d 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c
@@ -80,72 +80,3 @@ void cpm_uart_unmap_pram(struct uart_cpm_port *port, void __iomem *pram)
if (!IS_SMC(port))
iounmap(pram);
}
-
-/*
- * Allocate DP-Ram and memory buffers. We need to allocate a transmit and
- * receive buffer descriptors from dual port ram, and a character
- * buffer area from host mem. If we are allocating for the console we need
- * to do it from bootmem
- */
-int cpm_uart_allocbuf(struct uart_cpm_port *pinfo, unsigned int is_con)
-{
- int dpmemsz, memsz;
- u8 __iomem *dp_mem;
- unsigned long dp_offset;
- u8 *mem_addr;
- dma_addr_t dma_addr = 0;
-
- pr_debug("CPM uart[%d]:allocbuf\n", pinfo->port.line);
-
- dpmemsz = sizeof(cbd_t) * (pinfo->rx_nrfifos + pinfo->tx_nrfifos);
- dp_offset = cpm_dpalloc(dpmemsz, 8);
- if (IS_ERR_VALUE(dp_offset)) {
- printk(KERN_ERR
- "cpm_uart_cpm.c: could not allocate buffer descriptors\n");
- return -ENOMEM;
- }
-
- dp_mem = cpm_dpram_addr(dp_offset);
-
- memsz = L1_CACHE_ALIGN(pinfo->rx_nrfifos * pinfo->rx_fifosize) +
- L1_CACHE_ALIGN(pinfo->tx_nrfifos * pinfo->tx_fifosize);
- if (is_con) {
- mem_addr = kzalloc(memsz, GFP_NOWAIT);
- dma_addr = virt_to_bus(mem_addr);
- }
- else
- mem_addr = dma_alloc_coherent(pinfo->port.dev, memsz, &dma_addr,
- GFP_KERNEL);
-
- if (mem_addr == NULL) {
- cpm_dpfree(dp_offset);
- printk(KERN_ERR
- "cpm_uart_cpm.c: could not allocate coherent memory\n");
- return -ENOMEM;
- }
-
- pinfo->dp_addr = dp_offset;
- pinfo->mem_addr = mem_addr;
- pinfo->dma_addr = dma_addr;
- pinfo->mem_size = memsz;
-
- pinfo->rx_buf = mem_addr;
- pinfo->tx_buf = pinfo->rx_buf + L1_CACHE_ALIGN(pinfo->rx_nrfifos
- * pinfo->rx_fifosize);
-
- pinfo->rx_bd_base = (cbd_t __iomem *)dp_mem;
- pinfo->tx_bd_base = pinfo->rx_bd_base + pinfo->rx_nrfifos;
-
- return 0;
-}
-
-void cpm_uart_freebuf(struct uart_cpm_port *pinfo)
-{
- dma_free_coherent(pinfo->port.dev, L1_CACHE_ALIGN(pinfo->rx_nrfifos *
- pinfo->rx_fifosize) +
- L1_CACHE_ALIGN(pinfo->tx_nrfifos *
- pinfo->tx_fifosize), (void __force *)pinfo->mem_addr,
- pinfo->dma_addr);
-
- cpm_dpfree(pinfo->dp_addr);
-}
--
2.41.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v1 08/12] serial: cpm_uart: Refactor cpm_uart_[un]map_pram()
2023-08-03 13:56 [PATCH v1 00/12] serial: cpm_uart: Cleanup and refactoring Christophe Leroy
` (6 preceding siblings ...)
2023-08-03 13:56 ` [PATCH v1 07/12] serial: cpm_uart: Refactor cpm_uart_allocbuf()/cpm_uart_freebuf() Christophe Leroy
@ 2023-08-03 13:56 ` Christophe Leroy
2023-08-03 13:56 ` [PATCH v1 09/12] serial: cpm_uart: Remove cpm_uart/ subdirectory Christophe Leroy
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Christophe Leroy @ 2023-08-03 13:56 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby, Michael Ellerman, Nicholas Piggin,
Timur Tabi
Cc: linuxppc-dev, linux-kernel, linux-serial
cpm_uart_map_pram() and cpm_uart_unmap_pram() are very
similar for CPM1 and CPM2.
On CPM1 cpm_uart_map_pram() uses of_iomap() while CPM2 uses
of_address_to_resource()/ioremap(). CPM2 version will also
work on CPM1.
On CPM2 cpm_uart_map_pram() and cpm_uart_unmap_pram() has a special
handling for SMC. Just gate it by an IS_ENABLED(CONFIG_CPM2).
So move the CPM2 version into cpm_uart_core.c which is the only
user of those two fonctions and refactor to also handle CPM1 as
mentionned above.
PROFF_SMC_SIZE is only defined for SMC2 and used only there. To make
it simple, just use the numerical value 64, this is the only place
it is used and anyway there's already the same numerical value for
the alignment.
Use cpm_muram_alloc() instead of cpm_dpalloc() macro.
Then cpm_uart_cpm1.c and cpm_uart_cpm2.c are now empty and go away.
Replace printk(KERN_WARN by pr_warn( to make checkpatch happier.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
drivers/tty/serial/cpm_uart/Makefile | 8 +-
drivers/tty/serial/cpm_uart/cpm_uart.h | 5 --
drivers/tty/serial/cpm_uart/cpm_uart_core.c | 48 ++++++++++++
drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c | 48 ------------
drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c | 82 ---------------------
5 files changed, 49 insertions(+), 142 deletions(-)
delete mode 100644 drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c
delete mode 100644 drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c
diff --git a/drivers/tty/serial/cpm_uart/Makefile b/drivers/tty/serial/cpm_uart/Makefile
index 3f3a6ed02ed4..91f202fa5251 100644
--- a/drivers/tty/serial/cpm_uart/Makefile
+++ b/drivers/tty/serial/cpm_uart/Makefile
@@ -3,10 +3,4 @@
# Makefile for the Motorola 8xx FEC ethernet controller
#
-obj-$(CONFIG_SERIAL_CPM) += cpm_uart.o
-
-# Select the correct platform objects.
-cpm_uart-objs-$(CONFIG_CPM2) += cpm_uart_cpm2.o
-cpm_uart-objs-$(CONFIG_CPM1) += cpm_uart_cpm1.o
-
-cpm_uart-objs := cpm_uart_core.o $(cpm_uart-objs-y)
+obj-$(CONFIG_SERIAL_CPM) += cpm_uart_core.o
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart.h b/drivers/tty/serial/cpm_uart/cpm_uart.h
index 6d6046d45bec..37bb6e976e03 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart.h
+++ b/drivers/tty/serial/cpm_uart/cpm_uart.h
@@ -75,11 +75,6 @@ struct uart_cpm_port {
struct gpio_desc *gpios[NUM_GPIOS];
};
-/* these are located in their respective files */
-void __iomem *cpm_uart_map_pram(struct uart_cpm_port *port,
- struct device_node *np);
-void cpm_uart_unmap_pram(struct uart_cpm_port *port, void __iomem *pram);
-
/*
virtual to phys transtalion
*/
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
index fa5466518536..626423022d62 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
@@ -1207,6 +1207,54 @@ static const struct uart_ops cpm_uart_pops = {
static struct uart_cpm_port cpm_uart_ports[UART_NR];
+static void __iomem *cpm_uart_map_pram(struct uart_cpm_port *port,
+ struct device_node *np)
+{
+ void __iomem *pram;
+ unsigned long offset;
+ struct resource res;
+ resource_size_t len;
+
+ /* Don't remap parameter RAM if it has already been initialized
+ * during console setup.
+ */
+ if (IS_SMC(port) && port->smcup)
+ return port->smcup;
+ else if (!IS_SMC(port) && port->sccup)
+ return port->sccup;
+
+ if (of_address_to_resource(np, 1, &res))
+ return NULL;
+
+ len = resource_size(&res);
+ pram = ioremap(res.start, len);
+ if (!pram)
+ return NULL;
+
+ if (!IS_ENABLED(CONFIG_CPM2) || !IS_SMC(port))
+ return pram;
+
+ if (len != 2) {
+ pr_warn("cpm_uart[%d]: device tree references "
+ "SMC pram, using boot loader/wrapper pram mapping. "
+ "Please fix your device tree to reference the pram "
+ "base register instead.\n",
+ port->port.line);
+ return pram;
+ }
+
+ offset = cpm_muram_alloc(64, 64);
+ out_be16(pram, offset);
+ iounmap(pram);
+ return cpm_muram_addr(offset);
+}
+
+static void cpm_uart_unmap_pram(struct uart_cpm_port *port, void __iomem *pram)
+{
+ if (!IS_ENABLED(CONFIG_CPM2) || !IS_SMC(port))
+ iounmap(pram);
+}
+
static int cpm_uart_init_port(struct device_node *np,
struct uart_cpm_port *pinfo)
{
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c b/drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c
deleted file mode 100644
index 3fe436dc2f95..000000000000
--- a/drivers/tty/serial/cpm_uart/cpm_uart_cpm1.c
+++ /dev/null
@@ -1,48 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Driver for CPM (SCC/SMC) serial ports; CPM1 definitions
- *
- * Maintainer: Kumar Gala (galak@kernel.crashing.org) (CPM2)
- * Pantelis Antoniou (panto@intracom.gr) (CPM1)
- *
- * Copyright (C) 2004 Freescale Semiconductor, Inc.
- * (C) 2004 Intracom, S.A.
- * (C) 2006 MontaVista Software, Inc.
- * Vitaly Bordug <vbordug@ru.mvista.com>
- */
-
-#include <linux/module.h>
-#include <linux/tty.h>
-#include <linux/gfp.h>
-#include <linux/ioport.h>
-#include <linux/serial.h>
-#include <linux/console.h>
-#include <linux/sysrq.h>
-#include <linux/device.h>
-#include <linux/memblock.h>
-#include <linux/dma-mapping.h>
-
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/fs_pd.h>
-
-#include <linux/serial_core.h>
-#include <linux/kernel.h>
-
-#include <linux/of.h>
-#include <linux/of_address.h>
-
-#include "cpm_uart.h"
-
-/**************************************************************/
-
-void __iomem *cpm_uart_map_pram(struct uart_cpm_port *port,
- struct device_node *np)
-{
- return of_iomap(np, 1);
-}
-
-void cpm_uart_unmap_pram(struct uart_cpm_port *port, void __iomem *pram)
-{
- iounmap(pram);
-}
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c b/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c
deleted file mode 100644
index 09d46255aa9d..000000000000
--- a/drivers/tty/serial/cpm_uart/cpm_uart_cpm2.c
+++ /dev/null
@@ -1,82 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Driver for CPM (SCC/SMC) serial ports; CPM2 definitions
- *
- * Maintainer: Kumar Gala (galak@kernel.crashing.org) (CPM2)
- * Pantelis Antoniou (panto@intracom.gr) (CPM1)
- *
- * Copyright (C) 2004 Freescale Semiconductor, Inc.
- * (C) 2004 Intracom, S.A.
- * (C) 2006 MontaVista Software, Inc.
- * Vitaly Bordug <vbordug@ru.mvista.com>
- */
-
-#include <linux/module.h>
-#include <linux/tty.h>
-#include <linux/ioport.h>
-#include <linux/slab.h>
-#include <linux/serial.h>
-#include <linux/console.h>
-#include <linux/sysrq.h>
-#include <linux/device.h>
-#include <linux/memblock.h>
-#include <linux/dma-mapping.h>
-
-#include <asm/io.h>
-#include <asm/irq.h>
-#include <asm/fs_pd.h>
-
-#include <linux/serial_core.h>
-#include <linux/kernel.h>
-
-#include "cpm_uart.h"
-
-/**************************************************************/
-
-void __iomem *cpm_uart_map_pram(struct uart_cpm_port *port,
- struct device_node *np)
-{
- void __iomem *pram;
- unsigned long offset;
- struct resource res;
- resource_size_t len;
-
- /* Don't remap parameter RAM if it has already been initialized
- * during console setup.
- */
- if (IS_SMC(port) && port->smcup)
- return port->smcup;
- else if (!IS_SMC(port) && port->sccup)
- return port->sccup;
-
- if (of_address_to_resource(np, 1, &res))
- return NULL;
-
- len = resource_size(&res);
- pram = ioremap(res.start, len);
- if (!pram)
- return NULL;
-
- if (!IS_SMC(port))
- return pram;
-
- if (len != 2) {
- printk(KERN_WARNING "cpm_uart[%d]: device tree references "
- "SMC pram, using boot loader/wrapper pram mapping. "
- "Please fix your device tree to reference the pram "
- "base register instead.\n",
- port->port.line);
- return pram;
- }
-
- offset = cpm_dpalloc(PROFF_SMC_SIZE, 64);
- out_be16(pram, offset);
- iounmap(pram);
- return cpm_muram_addr(offset);
-}
-
-void cpm_uart_unmap_pram(struct uart_cpm_port *port, void __iomem *pram)
-{
- if (!IS_SMC(port))
- iounmap(pram);
-}
--
2.41.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v1 09/12] serial: cpm_uart: Remove cpm_uart/ subdirectory
2023-08-03 13:56 [PATCH v1 00/12] serial: cpm_uart: Cleanup and refactoring Christophe Leroy
` (7 preceding siblings ...)
2023-08-03 13:56 ` [PATCH v1 08/12] serial: cpm_uart: Refactor cpm_uart_[un]map_pram() Christophe Leroy
@ 2023-08-03 13:56 ` Christophe Leroy
2023-08-03 13:56 ` [PATCH v1 10/12] serial: cpm_uart: Remove stale prototype in powerpc/fsl_soc.c Christophe Leroy
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: Christophe Leroy @ 2023-08-03 13:56 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby, Michael Ellerman, Nicholas Piggin,
Timur Tabi
Cc: linuxppc-dev, linux-kernel, linux-serial
cpm_uart/ subdirectory only has cpm_uart_core.c and cpm_uart.h now.
Move them up and remove cpm_uart/ directory while renaming
cpm_uart_core.c as cpm_uart.c
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
drivers/tty/serial/Makefile | 2 +-
drivers/tty/serial/{cpm_uart/cpm_uart_core.c => cpm_uart.c} | 0
drivers/tty/serial/{cpm_uart => }/cpm_uart.h | 0
drivers/tty/serial/cpm_uart/Makefile | 6 ------
4 files changed, 1 insertion(+), 7 deletions(-)
rename drivers/tty/serial/{cpm_uart/cpm_uart_core.c => cpm_uart.c} (100%)
rename drivers/tty/serial/{cpm_uart => }/cpm_uart.h (100%)
delete mode 100644 drivers/tty/serial/cpm_uart/Makefile
diff --git a/drivers/tty/serial/Makefile b/drivers/tty/serial/Makefile
index d4123469583d..138abbc89738 100644
--- a/drivers/tty/serial/Makefile
+++ b/drivers/tty/serial/Makefile
@@ -41,7 +41,7 @@ obj-$(CONFIG_SERIAL_HS_LPC32XX) += lpc32xx_hs.o
obj-$(CONFIG_SERIAL_DZ) += dz.o
obj-$(CONFIG_SERIAL_ZS) += zs.o
obj-$(CONFIG_SERIAL_SH_SCI) += sh-sci.o
-obj-$(CONFIG_SERIAL_CPM) += cpm_uart/
+obj-$(CONFIG_SERIAL_CPM) += cpm_uart.o
obj-$(CONFIG_SERIAL_IMX) += imx.o
obj-$(CONFIG_SERIAL_IMX_EARLYCON) += imx_earlycon.o
obj-$(CONFIG_SERIAL_MPC52xx) += mpc52xx_uart.o
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c b/drivers/tty/serial/cpm_uart.c
similarity index 100%
rename from drivers/tty/serial/cpm_uart/cpm_uart_core.c
rename to drivers/tty/serial/cpm_uart.c
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart.h b/drivers/tty/serial/cpm_uart.h
similarity index 100%
rename from drivers/tty/serial/cpm_uart/cpm_uart.h
rename to drivers/tty/serial/cpm_uart.h
diff --git a/drivers/tty/serial/cpm_uart/Makefile b/drivers/tty/serial/cpm_uart/Makefile
deleted file mode 100644
index 91f202fa5251..000000000000
--- a/drivers/tty/serial/cpm_uart/Makefile
+++ /dev/null
@@ -1,6 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-#
-# Makefile for the Motorola 8xx FEC ethernet controller
-#
-
-obj-$(CONFIG_SERIAL_CPM) += cpm_uart_core.o
--
2.41.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v1 10/12] serial: cpm_uart: Remove stale prototype in powerpc/fsl_soc.c
2023-08-03 13:56 [PATCH v1 00/12] serial: cpm_uart: Cleanup and refactoring Christophe Leroy
` (8 preceding siblings ...)
2023-08-03 13:56 ` [PATCH v1 09/12] serial: cpm_uart: Remove cpm_uart/ subdirectory Christophe Leroy
@ 2023-08-03 13:56 ` Christophe Leroy
2023-08-03 13:56 ` [PATCH v1 11/12] serial: cpm_uart: Don't include fs_uart_pd.h when not needed Christophe Leroy
2023-08-03 13:56 ` [PATCH v1 12/12] serial: cpm_uart: Remove linux/fs_uart_pd.h Christophe Leroy
11 siblings, 0 replies; 13+ messages in thread
From: Christophe Leroy @ 2023-08-03 13:56 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby, Michael Ellerman, Nicholas Piggin,
Timur Tabi
Cc: linuxppc-dev, linux-kernel, linux-serial
Commit 0b5cf10691eb ("[POWERPC] 8xx: Convert mpc866ads to the new
device binding.") removed last definition of init_smc_ioports().
Remove it.
And don't include anymore fs_uart_pd.h which is only included to
provide fs_uart_platform_info structure.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
arch/powerpc/sysdev/fsl_soc.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
index e71b3ede147e..46431c4daaed 100644
--- a/arch/powerpc/sysdev/fsl_soc.c
+++ b/arch/powerpc/sysdev/fsl_soc.c
@@ -23,7 +23,6 @@
#include <linux/spi/spi.h>
#include <linux/fsl_devices.h>
#include <linux/fs_enet_pd.h>
-#include <linux/fs_uart_pd.h>
#include <linux/reboot.h>
#include <linux/atomic.h>
@@ -38,7 +37,6 @@
extern void init_fcc_ioports(struct fs_platform_info*);
extern void init_fec_ioports(struct fs_platform_info*);
-extern void init_smc_ioports(struct fs_uart_platform_info*);
static phys_addr_t immrbase = -1;
phys_addr_t get_immrbase(void)
--
2.41.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v1 11/12] serial: cpm_uart: Don't include fs_uart_pd.h when not needed
2023-08-03 13:56 [PATCH v1 00/12] serial: cpm_uart: Cleanup and refactoring Christophe Leroy
` (9 preceding siblings ...)
2023-08-03 13:56 ` [PATCH v1 10/12] serial: cpm_uart: Remove stale prototype in powerpc/fsl_soc.c Christophe Leroy
@ 2023-08-03 13:56 ` Christophe Leroy
2023-08-03 13:56 ` [PATCH v1 12/12] serial: cpm_uart: Remove linux/fs_uart_pd.h Christophe Leroy
11 siblings, 0 replies; 13+ messages in thread
From: Christophe Leroy @ 2023-08-03 13:56 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby, Michael Ellerman, Nicholas Piggin,
Timur Tabi
Cc: linuxppc-dev, linux-kernel, linux-serial
Remove inclusion of fs_uart_pd.h from all files not using
anything from that file.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
arch/powerpc/platforms/8xx/mpc885ads_setup.c | 1 -
arch/powerpc/platforms/8xx/tqm8xx_setup.c | 1 -
drivers/tty/serial/ucc_uart.c | 1 -
3 files changed, 3 deletions(-)
diff --git a/arch/powerpc/platforms/8xx/mpc885ads_setup.c b/arch/powerpc/platforms/8xx/mpc885ads_setup.c
index 2fc7cacbcd96..6ecc7fa2a816 100644
--- a/arch/powerpc/platforms/8xx/mpc885ads_setup.c
+++ b/arch/powerpc/platforms/8xx/mpc885ads_setup.c
@@ -22,7 +22,6 @@
#include <linux/delay.h>
#include <linux/fs_enet_pd.h>
-#include <linux/fs_uart_pd.h>
#include <linux/fsl_devices.h>
#include <linux/mii.h>
#include <linux/of_address.h>
diff --git a/arch/powerpc/platforms/8xx/tqm8xx_setup.c b/arch/powerpc/platforms/8xx/tqm8xx_setup.c
index 7d8eb50bb9cd..a451f5003abd 100644
--- a/arch/powerpc/platforms/8xx/tqm8xx_setup.c
+++ b/arch/powerpc/platforms/8xx/tqm8xx_setup.c
@@ -25,7 +25,6 @@
#include <linux/delay.h>
#include <linux/fs_enet_pd.h>
-#include <linux/fs_uart_pd.h>
#include <linux/fsl_devices.h>
#include <linux/mii.h>
#include <linux/of_fdt.h>
diff --git a/drivers/tty/serial/ucc_uart.c b/drivers/tty/serial/ucc_uart.c
index 404230c1ebb2..6995c10938a8 100644
--- a/drivers/tty/serial/ucc_uart.c
+++ b/drivers/tty/serial/ucc_uart.c
@@ -28,7 +28,6 @@
#include <linux/of_platform.h>
#include <linux/dma-mapping.h>
-#include <linux/fs_uart_pd.h>
#include <soc/fsl/qe/ucc_slow.h>
#include <linux/firmware.h>
--
2.41.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v1 12/12] serial: cpm_uart: Remove linux/fs_uart_pd.h
2023-08-03 13:56 [PATCH v1 00/12] serial: cpm_uart: Cleanup and refactoring Christophe Leroy
` (10 preceding siblings ...)
2023-08-03 13:56 ` [PATCH v1 11/12] serial: cpm_uart: Don't include fs_uart_pd.h when not needed Christophe Leroy
@ 2023-08-03 13:56 ` Christophe Leroy
11 siblings, 0 replies; 13+ messages in thread
From: Christophe Leroy @ 2023-08-03 13:56 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby, Michael Ellerman, Nicholas Piggin,
Timur Tabi
Cc: linuxppc-dev, linux-kernel, linux-serial
linux/fs_uart_pd.h is not used anymore. Remove it.
Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
---
include/linux/fs_uart_pd.h | 71 --------------------------------------
1 file changed, 71 deletions(-)
delete mode 100644 include/linux/fs_uart_pd.h
diff --git a/include/linux/fs_uart_pd.h b/include/linux/fs_uart_pd.h
deleted file mode 100644
index 36b61ff39277..000000000000
--- a/include/linux/fs_uart_pd.h
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Platform information definitions for the CPM Uart driver.
- *
- * 2006 (c) MontaVista Software, Inc.
- * Vitaly Bordug <vbordug@ru.mvista.com>
- *
- * This file is licensed under the terms of the GNU General Public License
- * version 2. This program is licensed "as is" without any warranty of any
- * kind, whether express or implied.
- */
-
-#ifndef FS_UART_PD_H
-#define FS_UART_PD_H
-
-#include <asm/types.h>
-
-enum fs_uart_id {
- fsid_smc1_uart,
- fsid_smc2_uart,
- fsid_scc1_uart,
- fsid_scc2_uart,
- fsid_scc3_uart,
- fsid_scc4_uart,
- fs_uart_nr,
-};
-
-static inline int fs_uart_id_scc2fsid(int id)
-{
- return fsid_scc1_uart + id - 1;
-}
-
-static inline int fs_uart_id_fsid2scc(int id)
-{
- return id - fsid_scc1_uart + 1;
-}
-
-static inline int fs_uart_id_smc2fsid(int id)
-{
- return fsid_smc1_uart + id - 1;
-}
-
-static inline int fs_uart_id_fsid2smc(int id)
-{
- return id - fsid_smc1_uart + 1;
-}
-
-struct fs_uart_platform_info {
- void(*init_ioports)(struct fs_uart_platform_info *);
- /* device specific information */
- int fs_no; /* controller index */
- char fs_type[4]; /* controller type */
- u32 uart_clk;
- u8 tx_num_fifo;
- u8 tx_buf_size;
- u8 rx_num_fifo;
- u8 rx_buf_size;
- u8 brg;
- u8 clk_rx;
- u8 clk_tx;
-};
-
-static inline int fs_uart_get_id(struct fs_uart_platform_info *fpi)
-{
- if(strstr(fpi->fs_type, "SMC"))
- return fs_uart_id_smc2fsid(fpi->fs_no);
- if(strstr(fpi->fs_type, "SCC"))
- return fs_uart_id_scc2fsid(fpi->fs_no);
- return fpi->fs_no;
-}
-
-#endif
--
2.41.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
end of thread, other threads:[~2023-08-03 14:03 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-03 13:56 [PATCH v1 00/12] serial: cpm_uart: Cleanup and refactoring Christophe Leroy
2023-08-03 13:56 ` [PATCH v1 01/12] serial: cpm_uart: Avoid suspicious locking Christophe Leroy
2023-08-03 13:56 ` [PATCH v1 02/12] serial: cpm_uart: Remove stale prototypes and table and macros Christophe Leroy
2023-08-03 13:56 ` [PATCH v1 03/12] serial: cpm_uart: Stop using fs_uart_id enum Christophe Leroy
2023-08-03 13:56 ` [PATCH v1 04/12] serial: cpm_uart: Use get_baudrate() instead of uart_baudrate() Christophe Leroy
2023-08-03 13:56 ` [PATCH v1 05/12] serial: cpm_uart: Deduplicate cpm_set_{brg/smc_fcr/scc_fcr}() Christophe Leroy
2023-08-03 13:56 ` [PATCH v1 06/12] serial: cpm_uart: Deduplicate cpm_line_cr_cmd() Christophe Leroy
2023-08-03 13:56 ` [PATCH v1 07/12] serial: cpm_uart: Refactor cpm_uart_allocbuf()/cpm_uart_freebuf() Christophe Leroy
2023-08-03 13:56 ` [PATCH v1 08/12] serial: cpm_uart: Refactor cpm_uart_[un]map_pram() Christophe Leroy
2023-08-03 13:56 ` [PATCH v1 09/12] serial: cpm_uart: Remove cpm_uart/ subdirectory Christophe Leroy
2023-08-03 13:56 ` [PATCH v1 10/12] serial: cpm_uart: Remove stale prototype in powerpc/fsl_soc.c Christophe Leroy
2023-08-03 13:56 ` [PATCH v1 11/12] serial: cpm_uart: Don't include fs_uart_pd.h when not needed Christophe Leroy
2023-08-03 13:56 ` [PATCH v1 12/12] serial: cpm_uart: Remove linux/fs_uart_pd.h Christophe Leroy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).