forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f9004dbfff8a3fbbd7e2a88c8a4327c7f2f8e5b2
kernel/arch/arm/mach-lpc32xx/serial.c
....@@ -1,19 +1,10 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * arch/arm/mach-lpc32xx/serial.c
34 *
45 * Author: Kevin Wells <kevin.wells@nxp.com>
56 *
67 * Copyright (C) 2010 NXP Semiconductors
7
- *
8
- * This program is free software; you can redistribute it and/or modify
9
- * it under the terms of the GNU General Public License as published by
10
- * the Free Software Foundation; either version 2 of the License, or
11
- * (at your option) any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
- * GNU General Public License for more details.
178 */
189
1910 #include <linux/kernel.h>
....@@ -25,8 +16,7 @@
2516 #include <linux/clk.h>
2617 #include <linux/io.h>
2718
28
-#include <mach/hardware.h>
29
-#include <mach/platform.h>
19
+#include "lpc32xx.h"
3020 #include "common.h"
3121
3222 #define LPC32XX_SUART_FIFO_SIZE 64
....@@ -69,6 +59,36 @@
6959 },
7060 };
7161
62
+/* LPC3250 Errata HSUART.1: Hang workaround via loopback mode on inactivity */
63
+void lpc32xx_loopback_set(resource_size_t mapbase, int state)
64
+{
65
+ int bit;
66
+ u32 tmp;
67
+
68
+ switch (mapbase) {
69
+ case LPC32XX_HS_UART1_BASE:
70
+ bit = 0;
71
+ break;
72
+ case LPC32XX_HS_UART2_BASE:
73
+ bit = 1;
74
+ break;
75
+ case LPC32XX_HS_UART7_BASE:
76
+ bit = 6;
77
+ break;
78
+ default:
79
+ WARN(1, "lpc32xx_hs: Warning: Unknown port at %08x\n", mapbase);
80
+ return;
81
+ }
82
+
83
+ tmp = readl(LPC32XX_UARTCTL_CLOOP);
84
+ if (state)
85
+ tmp |= (1 << bit);
86
+ else
87
+ tmp &= ~(1 << bit);
88
+ writel(tmp, LPC32XX_UARTCTL_CLOOP);
89
+}
90
+EXPORT_SYMBOL_GPL(lpc32xx_loopback_set);
91
+
7292 void __init lpc32xx_serial_init(void)
7393 {
7494 u32 tmp, clkmodes = 0;