hc
2024-11-01 2f529f9b558ca1c1bd74be7437a84e4711743404
kernel/drivers/tty/serial/amba-pl011.c
....@@ -1887,6 +1887,8 @@
18871887
18881888 pl011_disable_uart(uap);
18891889
1890
+ if (IS_ENABLED(CONFIG_RAW_PRINTK))
1891
+ clk_disable(uap->clk);
18901892 /*
18911893 * Shut down the clock producer
18921894 */
....@@ -2194,6 +2196,37 @@
21942196 pl011_write(ch, uap, REG_DR);
21952197 }
21962198
2199
+#ifdef CONFIG_RAW_PRINTK
2200
+
2201
+static void
2202
+pl011_console_write_raw(struct console *co, const char *s, unsigned int count)
2203
+{
2204
+ struct uart_amba_port *uap = amba_ports[co->index];
2205
+ unsigned int old_cr = 0, new_cr;
2206
+
2207
+ if (!uap->vendor->always_enabled) {
2208
+ old_cr = pl011_read(uap, REG_CR);
2209
+ new_cr = old_cr & ~UART011_CR_CTSEN;
2210
+ new_cr |= UART01x_CR_UARTEN | UART011_CR_TXE;
2211
+ pl011_write(new_cr, uap, REG_CR);
2212
+ }
2213
+
2214
+ while (count-- > 0) {
2215
+ if (*s == '\n')
2216
+ pl011_console_putchar(&uap->port, '\r');
2217
+ pl011_console_putchar(&uap->port, *s++);
2218
+ }
2219
+
2220
+ while ((pl011_read(uap, REG_FR) ^ uap->vendor->inv_fr)
2221
+ & uap->vendor->fr_busy)
2222
+ cpu_relax();
2223
+
2224
+ if (!uap->vendor->always_enabled)
2225
+ pl011_write(old_cr, uap, REG_CR);
2226
+}
2227
+
2228
+#endif /* !CONFIG_RAW_PRINTK */
2229
+
21972230 static void
21982231 pl011_console_write(struct console *co, const char *s, unsigned int count)
21992232 {
....@@ -2323,6 +2356,9 @@
23232356 pl011_console_get_options(uap, &baud, &parity, &bits);
23242357 }
23252358
2359
+ if (IS_ENABLED(CONFIG_RAW_PRINTK))
2360
+ clk_enable(uap->clk);
2361
+
23262362 return uart_set_options(&uap->port, co, baud, parity, bits, flow);
23272363 }
23282364
....@@ -2393,6 +2429,9 @@
23932429 .device = uart_console_device,
23942430 .setup = pl011_console_setup,
23952431 .match = pl011_console_match,
2432
+#ifdef CONFIG_RAW_PRINTK
2433
+ .write_raw = pl011_console_write_raw,
2434
+#endif
23962435 .flags = CON_PRINTBUFFER | CON_ANYTIME,
23972436 .index = -1,
23982437 .data = &amba_reg,