Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

+38 -31
+30
arch/arm/mach-lpc32xx/serial.c
··· 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 93 void __init lpc32xx_serial_init(void) 64 94 { 65 95 u32 tmp, clkmodes = 0;
+4 -31
drivers/tty/serial/lpc32xx_hs.c
··· 25 25 #include <linux/irq.h> 26 26 #include <linux/gpio.h> 27 27 #include <linux/of.h> 28 + #include <linux/sizes.h> 29 + #include <linux/soc/nxp/lpc32xx-misc.h> 28 30 29 31 /* 30 32 * High Speed UART register offsets ··· 80 78 #define LPC32XX_HSU_TX_TL4B (0x1 << 0) 81 79 #define LPC32XX_HSU_TX_TL8B (0x2 << 0) 82 80 #define LPC32XX_HSU_TX_TL16B (0x3 << 0) 81 + 82 + #define LPC32XX_MAIN_OSC_FREQ 13000000 83 83 84 84 #define MODNAME "lpc32xx_hsuart" 85 85 ··· 152 148 spin_unlock(&up->port.lock); 153 149 local_irq_restore(flags); 154 150 } 155 - 156 - static void lpc32xx_loopback_set(resource_size_t mapbase, int state); 157 151 158 152 static int __init lpc32xx_hsuart_console_setup(struct console *co, 159 153 char *options) ··· 437 435 tmp &= ~LPC32XX_HSU_BREAK; 438 436 writel(tmp, LPC32XX_HSUART_CTRL(port->membase)); 439 437 spin_unlock_irqrestore(&port->lock, flags); 440 - } 441 - 442 - /* LPC3250 Errata HSUART.1: Hang workaround via loopback mode on inactivity */ 443 - static void lpc32xx_loopback_set(resource_size_t mapbase, int state) 444 - { 445 - int bit; 446 - u32 tmp; 447 - 448 - switch (mapbase) { 449 - case LPC32XX_HS_UART1_BASE: 450 - bit = 0; 451 - break; 452 - case LPC32XX_HS_UART2_BASE: 453 - bit = 1; 454 - break; 455 - case LPC32XX_HS_UART7_BASE: 456 - bit = 6; 457 - break; 458 - default: 459 - WARN(1, "lpc32xx_hs: Warning: Unknown port at %08x\n", mapbase); 460 - return; 461 - } 462 - 463 - tmp = readl(LPC32XX_UARTCTL_CLOOP); 464 - if (state) 465 - tmp |= (1 << bit); 466 - else 467 - tmp &= ~(1 << bit); 468 - writel(tmp, LPC32XX_UARTCTL_CLOOP); 469 438 } 470 439 471 440 /* port->lock is not held. */
+4
include/linux/soc/nxp/lpc32xx-misc.h
··· 14 14 #ifdef CONFIG_ARCH_LPC32XX 15 15 extern u32 lpc32xx_return_iram(void __iomem **mapbase, dma_addr_t *dmaaddr); 16 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 18 #else 18 19 static inline u32 lpc32xx_return_iram(void __iomem **mapbase, dma_addr_t *dmaaddr) 19 20 { ··· 23 22 return 0; 24 23 } 25 24 static inline void lpc32xx_set_phy_interface_mode(phy_interface_t mode) 25 + { 26 + } 27 + static inline void lpc32xx_loopback_set(resource_size_t mapbase, int state) 26 28 { 27 29 } 28 30 #endif