forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-02-19 1c055e55a242a33e574e48be530e06770a210dcd
kernel/drivers/tty/serial/pmac_zilog.c
....@@ -61,10 +61,6 @@
6161 #define of_machine_is_compatible(x) (0)
6262 #endif
6363
64
-#if defined (CONFIG_SERIAL_PMACZILOG_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
65
-#define SUPPORT_SYSRQ
66
-#endif
67
-
6864 #include <linux/serial.h>
6965 #include <linux/serial_core.h>
7066
....@@ -217,9 +213,10 @@
217213 }
218214
219215 static bool pmz_receive_chars(struct uart_pmac_port *uap)
216
+ __must_hold(&uap->port.lock)
220217 {
221218 struct tty_port *port;
222
- unsigned char ch, r1, drop, error, flag;
219
+ unsigned char ch, r1, drop, flag;
223220 int loops = 0;
224221
225222 /* Sanity check, make sure the old bug is no longer happening */
....@@ -231,7 +228,6 @@
231228 port = &uap->port.state->port;
232229
233230 while (1) {
234
- error = 0;
235231 drop = 0;
236232
237233 r1 = read_zsreg(uap, R1);
....@@ -273,7 +269,6 @@
273269 uap->port.icount.rx++;
274270
275271 if (r1 & (PAR_ERR | Rx_OVR | CRC_ERR | BRK_ABRT)) {
276
- error = 1;
277272 if (r1 & BRK_ABRT) {
278273 pmz_debug("pmz: got break !\n");
279274 r1 &= ~(PAR_ERR | CRC_ERR);
....@@ -1566,9 +1561,9 @@
15661561 * to work around bugs in ancient Apple device-trees
15671562 */
15681563 if (macio_request_resources(uap->dev, "pmac_zilog"))
1569
- printk(KERN_WARNING "%s: Failed to request resource"
1564
+ printk(KERN_WARNING "%pOFn: Failed to request resource"
15701565 ", port still active\n",
1571
- uap->node->name);
1566
+ uap->node);
15721567 else
15731568 uap->flags |= PMACZILOG_FLAG_RSRC_REQUESTED;
15741569
....@@ -1649,10 +1644,10 @@
16491644 * TODO: Add routines with proper locking to do that...
16501645 */
16511646 node_a = node_b = NULL;
1652
- for (np = NULL; (np = of_get_next_child(node_p, np)) != NULL;) {
1653
- if (strncmp(np->name, "ch-a", 4) == 0)
1647
+ for_each_child_of_node(node_p, np) {
1648
+ if (of_node_name_prefix(np, "ch-a"))
16541649 node_a = of_node_get(np);
1655
- else if (strncmp(np->name, "ch-b", 4) == 0)
1650
+ else if (of_node_name_prefix(np, "ch-b"))
16561651 node_b = of_node_get(np);
16571652 }
16581653 if (!node_a && !node_b) {
....@@ -1698,22 +1693,26 @@
16981693
16991694 #else
17001695
1696
+/* On PCI PowerMacs, pmz_probe() does an explicit search of the OpenFirmware
1697
+ * tree to obtain the device_nodes needed to start the console before the
1698
+ * macio driver. On Macs without OpenFirmware, global platform_devices take
1699
+ * the place of those device_nodes.
1700
+ */
17011701 extern struct platform_device scc_a_pdev, scc_b_pdev;
17021702
17031703 static int __init pmz_init_port(struct uart_pmac_port *uap)
17041704 {
1705
- struct resource *r_ports;
1706
- int irq;
1705
+ struct resource *r_ports, *r_irq;
17071706
17081707 r_ports = platform_get_resource(uap->pdev, IORESOURCE_MEM, 0);
1709
- irq = platform_get_irq(uap->pdev, 0);
1710
- if (!r_ports || irq <= 0)
1708
+ r_irq = platform_get_resource(uap->pdev, IORESOURCE_IRQ, 0);
1709
+ if (!r_ports || !r_irq)
17111710 return -ENODEV;
17121711
17131712 uap->port.mapbase = r_ports->start;
17141713 uap->port.membase = (unsigned char __iomem *) r_ports->start;
17151714 uap->port.iotype = UPIO_MEM;
1716
- uap->port.irq = irq;
1715
+ uap->port.irq = r_irq->start;
17171716 uap->port.uartclk = ZS_CLOCK;
17181717 uap->port.fifosize = 1;
17191718 uap->port.ops = &pmz_pops;
....@@ -1723,6 +1722,7 @@
17231722 uap->control_reg = uap->port.membase;
17241723 uap->data_reg = uap->control_reg + 4;
17251724 uap->port_type = 0;
1725
+ uap->port.has_sysrq = IS_ENABLED(CONFIG_SERIAL_PMACZILOG_CONSOLE);
17261726
17271727 pmz_convert_to_zs(uap, CS8, 0, 9600);
17281728