diff options
author | Arnd Bergmann <arnd@arndb.de> | 2019-08-09 10:40:37 -0400 |
---|---|---|
committer | Arnd Bergmann <arnd@arndb.de> | 2019-08-15 15:34:02 -0400 |
commit | ffba29c9ebd0977dbf77bf6064776716a51b8ae5 (patch) | |
tree | c6d42d43db9fd1800228073b61d4abc27485bbc9 | |
parent | 35974a7cc23c5deb5597c0a42183172498c4a0a8 (diff) |
serial: lpc32xx: allow compile testing
The lpc32xx_loopback_set() function in hte lpc32xx_hs driver is the
one thing that relies on platform header files. Move that into the
core platform code so we only need a variable declaration for it,
and enable COMPILE_TEST building.
Link: https://lore.kernel.org/r/20190809144043.476786-12-arnd@arndb.de
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
-rw-r--r-- | arch/arm/mach-lpc32xx/serial.c | 30 | ||||
-rw-r--r-- | drivers/tty/serial/lpc32xx_hs.c | 35 | ||||
-rw-r--r-- | include/linux/soc/nxp/lpc32xx-misc.h | 4 |
3 files changed, 38 insertions, 31 deletions
diff --git a/arch/arm/mach-lpc32xx/serial.c b/arch/arm/mach-lpc32xx/serial.c index 3f9b30df9f0e..cfb35e5691cd 100644 --- a/arch/arm/mach-lpc32xx/serial.c +++ b/arch/arm/mach-lpc32xx/serial.c | |||
@@ -60,6 +60,36 @@ static struct uartinit uartinit_data[] __initdata = { | |||
60 | }, | 60 | }, |
61 | }; | 61 | }; |
62 | 62 | ||
63 | /* LPC3250 Errata HSUART.1: Hang workaround via loopback mode on inactivity */ | ||
64 | void lpc32xx_loopback_set(resource_size_t mapbase, int state) | ||
65 | { | ||
66 | int bit; | ||
67 | u32 tmp; | ||
68 | |||
69 | switch (mapbase) { | ||
70 | case LPC32XX_HS_UART1_BASE: | ||
71 | bit = 0; | ||
72 | break; | ||
73 | case LPC32XX_HS_UART2_BASE: | ||
74 | bit = 1; | ||
75 | break; | ||
76 | case LPC32XX_HS_UART7_BASE: | ||
77 | bit = 6; | ||
78 | break; | ||
79 | default: | ||
80 | WARN(1, "lpc32xx_hs: Warning: Unknown port at %08x\n", mapbase); | ||
81 | return; | ||
82 | } | ||
83 | |||
84 | tmp = readl(LPC32XX_UARTCTL_CLOOP); | ||
85 | if (state) | ||
86 | tmp |= (1 << bit); | ||
87 | else | ||
88 | tmp &= ~(1 << bit); | ||
89 | writel(tmp, LPC32XX_UARTCTL_CLOOP); | ||
90 | } | ||
91 | EXPORT_SYMBOL_GPL(lpc32xx_loopback_set); | ||
92 | |||
63 | void __init lpc32xx_serial_init(void) | 93 | void __init lpc32xx_serial_init(void) |
64 | { | 94 | { |
65 | u32 tmp, clkmodes = 0; | 95 | u32 tmp, clkmodes = 0; |
diff --git a/drivers/tty/serial/lpc32xx_hs.c b/drivers/tty/serial/lpc32xx_hs.c index 7f14cd8fac47..d3843f722182 100644 --- a/drivers/tty/serial/lpc32xx_hs.c +++ b/drivers/tty/serial/lpc32xx_hs.c | |||
@@ -25,6 +25,8 @@ | |||
25 | #include <linux/irq.h> | 25 | #include <linux/irq.h> |
26 | #include <linux/gpio.h> | 26 | #include <linux/gpio.h> |
27 | #include <linux/of.h> | 27 | #include <linux/of.h> |
28 | #include <linux/sizes.h> | ||
29 | #include <linux/soc/nxp/lpc32xx-misc.h> | ||
28 | 30 | ||
29 | /* | 31 | /* |
30 | * High Speed UART register offsets | 32 | * High Speed UART register offsets |
@@ -79,6 +81,8 @@ | |||
79 | #define LPC32XX_HSU_TX_TL8B (0x2 << 0) | 81 | #define LPC32XX_HSU_TX_TL8B (0x2 << 0) |
80 | #define LPC32XX_HSU_TX_TL16B (0x3 << 0) | 82 | #define LPC32XX_HSU_TX_TL16B (0x3 << 0) |
81 | 83 | ||
84 | #define LPC32XX_MAIN_OSC_FREQ 13000000 | ||
85 | |||
82 | #define MODNAME "lpc32xx_hsuart" | 86 | #define MODNAME "lpc32xx_hsuart" |
83 | 87 | ||
84 | struct lpc32xx_hsuart_port { | 88 | struct lpc32xx_hsuart_port { |
@@ -149,8 +153,6 @@ static void lpc32xx_hsuart_console_write(struct console *co, const char *s, | |||
149 | local_irq_restore(flags); | 153 | local_irq_restore(flags); |
150 | } | 154 | } |
151 | 155 | ||
152 | static void lpc32xx_loopback_set(resource_size_t mapbase, int state); | ||
153 | |||
154 | static int __init lpc32xx_hsuart_console_setup(struct console *co, | 156 | static int __init lpc32xx_hsuart_console_setup(struct console *co, |
155 | char *options) | 157 | char *options) |
156 | { | 158 | { |
@@ -437,35 +439,6 @@ static void serial_lpc32xx_break_ctl(struct uart_port *port, | |||
437 | spin_unlock_irqrestore(&port->lock, flags); | 439 | spin_unlock_irqrestore(&port->lock, flags); |
438 | } | 440 | } |
439 | 441 | ||
440 | /* LPC3250 Errata HSUART.1: Hang workaround via loopback mode on inactivity */ | ||
441 | static void lpc32xx_loopback_set(resource_size_t mapbase, int state) | ||
442 | { | ||
443 | int bit; | ||
444 | u32 tmp; | ||
445 | |||
446 | switch (mapbase) { | ||
447 | case LPC32XX_HS_UART1_BASE: | ||
448 | bit = 0; | ||
449 | break; | ||
450 | case LPC32XX_HS_UART2_BASE: | ||
451 | bit = 1; | ||
452 | break; | ||
453 | case LPC32XX_HS_UART7_BASE: | ||
454 | bit = 6; | ||
455 | break; | ||
456 | default: | ||
457 | WARN(1, "lpc32xx_hs: Warning: Unknown port at %08x\n", mapbase); | ||
458 | return; | ||
459 | } | ||
460 | |||
461 | tmp = readl(LPC32XX_UARTCTL_CLOOP); | ||
462 | if (state) | ||
463 | tmp |= (1 << bit); | ||
464 | else | ||
465 | tmp &= ~(1 << bit); | ||
466 | writel(tmp, LPC32XX_UARTCTL_CLOOP); | ||
467 | } | ||
468 | |||
469 | /* port->lock is not held. */ | 442 | /* port->lock is not held. */ |
470 | static int serial_lpc32xx_startup(struct uart_port *port) | 443 | static int serial_lpc32xx_startup(struct uart_port *port) |
471 | { | 444 | { |
diff --git a/include/linux/soc/nxp/lpc32xx-misc.h b/include/linux/soc/nxp/lpc32xx-misc.h index af4f82f6cf3b..699c6f1e3aab 100644 --- a/include/linux/soc/nxp/lpc32xx-misc.h +++ b/include/linux/soc/nxp/lpc32xx-misc.h | |||
@@ -14,6 +14,7 @@ | |||
14 | #ifdef CONFIG_ARCH_LPC32XX | 14 | #ifdef CONFIG_ARCH_LPC32XX |
15 | extern u32 lpc32xx_return_iram(void __iomem **mapbase, dma_addr_t *dmaaddr); | 15 | extern u32 lpc32xx_return_iram(void __iomem **mapbase, dma_addr_t *dmaaddr); |
16 | extern void lpc32xx_set_phy_interface_mode(phy_interface_t mode); | 16 | extern void lpc32xx_set_phy_interface_mode(phy_interface_t mode); |
17 | extern void lpc32xx_loopback_set(resource_size_t mapbase, int state); | ||
17 | #else | 18 | #else |
18 | static inline u32 lpc32xx_return_iram(void __iomem **mapbase, dma_addr_t *dmaaddr) | 19 | static inline u32 lpc32xx_return_iram(void __iomem **mapbase, dma_addr_t *dmaaddr) |
19 | { | 20 | { |
@@ -24,6 +25,9 @@ static inline u32 lpc32xx_return_iram(void __iomem **mapbase, dma_addr_t *dmaadd | |||
24 | static inline void lpc32xx_set_phy_interface_mode(phy_interface_t mode) | 25 | static inline void lpc32xx_set_phy_interface_mode(phy_interface_t mode) |
25 | { | 26 | { |
26 | } | 27 | } |
28 | static inline void lpc32xx_loopback_set(resource_size_t mapbase, int state) | ||
29 | { | ||
30 | } | ||
27 | #endif | 31 | #endif |
28 | 32 | ||
29 | #endif /* __SOC_LPC32XX_MISC_H */ | 33 | #endif /* __SOC_LPC32XX_MISC_H */ |