Lines Matching +full:mux +full:- +full:int +full:- +full:port

1 // SPDX-License-Identifier: GPL-2.0+
3 ** mux.c:
4 ** serial driver for the Mux console found in some PA-RISC servers.
7 ** (c) Copyright 2002 Hewlett-Packard Company
9 ** This Driver currently only supports the console (port 0) on the MUX.
11 ** functionality of the MUX.
26 #include <asm/parisc-device.h>
45 static unsigned int port_cnt __read_mostly;
47 struct uart_port port; member
48 int enabled;
63 #define UART_PUT_CHAR(p, c) __raw_writel((c), (p)->membase + IO_DATA_REG_OFFSET)
64 #define UART_GET_FIFO_CNT(p) __raw_readl((p)->membase + IO_DCOUNT_REG_OFFSET)
67 * get_mux_port_count - Get the number of available ports on the Mux.
70 * This function is used to determine the number of ports the Mux
71 * supports. The IODC data reports the number of ports the Mux
72 * can support, but there are cases where not all the Mux ports
74 * return the true port count.
76 static int __init get_mux_port_count(struct parisc_device *dev) in get_mux_port_count()
78 int status; in get_mux_port_count()
82 /* If this is the built-in Mux for the K-Class (Eole CAP/MUX), in get_mux_port_count()
83 * we only need to allocate resources for 1 port since the in get_mux_port_count()
86 if(dev->id.hversion == 0x15) in get_mux_port_count()
89 status = pdc_iodc_read(&bytecnt, dev->hpa.start, 0, iodc_data, 32); in get_mux_port_count()
97 * mux_tx_empty - Check if the transmitter fifo is empty.
98 * @port: Ptr to the uart_port.
100 * This function test if the transmitter fifo for the port
101 * described by 'port' is empty. If it is empty, this function
104 static unsigned int mux_tx_empty(struct uart_port *port) in mux_tx_empty() argument
106 return UART_GET_FIFO_CNT(port) ? 0 : TIOCSER_TEMT; in mux_tx_empty()
110 * mux_set_mctrl - Set the current state of the modem control inputs.
114 * The Serial MUX does not support CTS, DCD or DSR so this function
117 static void mux_set_mctrl(struct uart_port *port, unsigned int mctrl) in mux_set_mctrl() argument
122 * mux_get_mctrl - Returns the current state of modem control inputs.
123 * @port: Ptr to the uart_port.
125 * The Serial MUX does not support CTS, DCD or DSR so these lines are
128 static unsigned int mux_get_mctrl(struct uart_port *port) in mux_get_mctrl() argument
134 * mux_stop_tx - Stop transmitting characters.
135 * @port: Ptr to the uart_port.
137 * The Serial MUX does not support this function.
139 static void mux_stop_tx(struct uart_port *port) in mux_stop_tx() argument
144 * mux_start_tx - Start transmitting characters.
145 * @port: Ptr to the uart_port.
147 * The Serial Mux does not support this function.
149 static void mux_start_tx(struct uart_port *port) in mux_start_tx() argument
154 * mux_stop_rx - Stop receiving characters.
155 * @port: Ptr to the uart_port.
157 * The Serial Mux does not support this function.
159 static void mux_stop_rx(struct uart_port *port) in mux_stop_rx() argument
164 * mux_break_ctl - Control the transmitssion of a break signal.
165 * @port: Ptr to the uart_port.
168 * The Serial Mux does not support this function.
170 static void mux_break_ctl(struct uart_port *port, int break_state) in mux_break_ctl() argument
174 static void mux_tx_done(struct uart_port *port) in mux_tx_done() argument
177 while (UART_GET_FIFO_CNT(port)) in mux_tx_done()
182 * mux_write - Write chars to the mux fifo.
183 * @port: Ptr to the uart_port.
186 * the mux fifo.
188 static void mux_write(struct uart_port *port) in mux_write() argument
192 uart_port_tx_limited(port, ch, in mux_write()
193 port->fifosize - UART_GET_FIFO_CNT(port), in mux_write()
195 UART_PUT_CHAR(port, ch), in mux_write()
196 mux_tx_done(port)); in mux_write()
200 * mux_read - Read chars from the mux fifo.
201 * @port: Ptr to the uart_port.
203 * This reads all available data from the mux's fifo and pushes
206 static void mux_read(struct uart_port *port) in mux_read() argument
208 struct tty_port *tport = &port->state->port; in mux_read()
209 int data; in mux_read()
210 __u32 start_count = port->icount.rx; in mux_read()
213 data = __raw_readl(port->membase + IO_DATA_REG_OFFSET); in mux_read()
221 port->icount.rx++; in mux_read()
224 port->icount.brk++; in mux_read()
225 if(uart_handle_break(port)) in mux_read()
229 if (uart_handle_sysrq_char(port, data & 0xffu)) in mux_read()
235 if (start_count != port->icount.rx) in mux_read()
240 * mux_startup - Initialize the port.
241 * @port: Ptr to the uart_port.
243 * Grab any resources needed for this port and start the
244 * mux timer.
246 static int mux_startup(struct uart_port *port) in mux_startup() argument
248 mux_ports[port->line].enabled = 1; in mux_startup()
253 * mux_shutdown - Disable the port.
254 * @port: Ptr to the uart_port.
256 * Release any resources needed for the port.
258 static void mux_shutdown(struct uart_port *port) in mux_shutdown() argument
260 mux_ports[port->line].enabled = 0; in mux_shutdown()
264 * mux_set_termios - Chane port parameters.
265 * @port: Ptr to the uart_port.
269 * The Serial Mux does not support this function.
272 mux_set_termios(struct uart_port *port, struct ktermios *termios, in mux_set_termios() argument
278 * mux_type - Describe the port.
279 * @port: Ptr to the uart_port.
282 * specified port.
284 static const char *mux_type(struct uart_port *port) in mux_type() argument
286 return "Mux"; in mux_type()
290 * mux_release_port - Release memory and IO regions.
291 * @port: Ptr to the uart_port.
294 * the port.
296 static void mux_release_port(struct uart_port *port) in mux_release_port() argument
301 * mux_request_port - Request memory and IO regions.
302 * @port: Ptr to the uart_port.
304 * Request any memory and IO region resources required by the port.
306 * returns, and it should return -EBUSY on failure.
308 static int mux_request_port(struct uart_port *port) in mux_request_port() argument
314 * mux_config_port - Perform port autoconfiguration.
315 * @port: Ptr to the uart_port.
318 * Perform any autoconfiguration steps for the port. This function is
319 * called if the UPF_BOOT_AUTOCONF flag is specified for the port.
324 static void mux_config_port(struct uart_port *port, int type) in mux_config_port() argument
326 port->type = PORT_MUX; in mux_config_port()
330 * mux_verify_port - Verify the port information.
331 * @port: Ptr to the uart_port.
334 * Verify the new serial port information contained within serinfo is
335 * suitable for this port type.
337 static int mux_verify_port(struct uart_port *port, struct serial_struct *ser) in mux_verify_port() argument
339 if(port->membase == NULL) in mux_verify_port()
340 return -EINVAL; in mux_verify_port()
346 * mux_drv_poll - Mux poll function.
349 * This function periodically polls the Serial MUX to check for new data.
353 int i; in mux_poll()
359 mux_read(&mux_ports[i].port); in mux_poll()
360 mux_write(&mux_ports[i].port); in mux_poll()
371 while(UART_GET_FIFO_CNT(&mux_ports[0].port)) in mux_console_write()
374 while(count--) { in mux_console_write()
376 UART_PUT_CHAR(&mux_ports[0].port, '\r'); in mux_console_write()
378 UART_PUT_CHAR(&mux_ports[0].port, *s++); in mux_console_write()
383 static int mux_console_setup(struct console *co, char *options) in mux_console_setup()
422 * mux_probe - Determine if the Serial Mux should claim this device.
425 * Deterimine if the Serial Mux should claim this chip (return 0)
428 static int __init mux_probe(struct parisc_device *dev) in mux_probe()
430 int i, status; in mux_probe()
432 int port_count = get_mux_port_count(dev); in mux_probe()
433 printk(KERN_INFO "Serial mux driver (%d ports) Revision: 0.6\n", port_count); in mux_probe()
435 dev_set_drvdata(&dev->dev, (void *)(long)port_count); in mux_probe()
436 request_mem_region(dev->hpa.start + MUX_OFFSET, in mux_probe()
437 port_count * MUX_LINE_OFFSET, "Mux"); in mux_probe()
444 printk(KERN_ERR "Serial mux: Unable to register driver.\n"); in mux_probe()
450 struct uart_port *port = &mux_ports[port_cnt].port; in mux_probe() local
451 port->iobase = 0; in mux_probe()
452 port->mapbase = dev->hpa.start + MUX_OFFSET + in mux_probe()
454 port->membase = ioremap(port->mapbase, MUX_LINE_OFFSET); in mux_probe()
455 port->iotype = UPIO_MEM; in mux_probe()
456 port->type = PORT_MUX; in mux_probe()
457 port->irq = 0; in mux_probe()
458 port->uartclk = 0; in mux_probe()
459 port->fifosize = MUX_FIFO_SIZE; in mux_probe()
460 port->ops = &mux_pops; in mux_probe()
461 port->flags = UPF_BOOT_AUTOCONF; in mux_probe()
462 port->line = port_cnt; in mux_probe()
463 port->has_sysrq = IS_ENABLED(CONFIG_SERIAL_MUX_CONSOLE); in mux_probe()
465 spin_lock_init(&port->lock); in mux_probe()
467 status = uart_add_one_port(&mux_driver, port); in mux_probe()
476 int i, j; in mux_remove()
477 int port_count = (long)dev_get_drvdata(&dev->dev); in mux_remove()
479 /* Find Port 0 for this card in the mux_ports list. */ in mux_remove()
481 if(mux_ports[i].port.mapbase == dev->hpa.start + MUX_OFFSET) in mux_remove()
486 /* Release the resources associated with each port on the device. */ in mux_remove()
488 struct uart_port *port = &mux_ports[i].port; in mux_remove() local
490 uart_remove_one_port(&mux_driver, port); in mux_remove()
491 if(port->membase) in mux_remove()
492 iounmap(port->membase); in mux_remove()
495 release_mem_region(dev->hpa.start + MUX_OFFSET, port_count * MUX_LINE_OFFSET); in mux_remove()
499 * the serial port detection in the proper order. The idea is we always
500 * want the builtin mux to be detected before addin mux cards, so we
501 * specifically probe for the builtin mux cards first.
503 * This table only contains the parisc_device_id of known builtin mux
504 * devices. All other mux cards will be detected by the generic mux_tbl.
507 { HPHW_A_DIRECT, HVERSION_REV_ANY_ID, 0x15, 0x0000D }, /* All K-class */
535 * mux_init - Serial MUX initialization procedure.
537 * Register the Serial MUX driver.
539 static int __init mux_init(void) in mux_init()
545 /* Start the Mux timer */ in mux_init()
558 * mux_exit - Serial MUX cleanup procedure.
560 * Unregister the Serial MUX driver from the tty layer.
564 /* Delete the Mux timer. */ in mux_exit()
581 MODULE_DESCRIPTION("Serial MUX driver");