Multiple Mux Cards.
PATCH 1/1 Multiple Mux Cards.
Hello All,
The Mux driver did not properly handle multiple Mux cards in the system. One of the biggest problems I ran into on the E-35 is the detection of other
Mux cards happens before the detection of the built-in Mux card. This
caused problems because the console would be be ttyB0 without the additional Mux card, and ttyB16 with the additional Mux card.
The patch is still rough, but I wanted to present the proof-of-concept patch I came up with to solve the problem to this list for review.
Basically the patch checks to see if the console on the PAGE0 address is a Mux. If it is, it calculates the number of ports that are available on the
Mux and reserves these ports before registering the driver. The other
information (iomem resources, etc) are still done when the devices is actually probed.
Let me know what you think :)
Thanks!
- Ryan
drivers/serial/mux.c +106 -46
@@ -27,6 +27,7 @@#include <linux/device.h> #include <asm/io.h> #include <asm/irq.h> +#include <asm/pdc.h> #include <asm/parisc-device.h> #ifdef CONFIG_MAGIC_SYSRQ
@@ -472,59 +473,47 @@ static struct mux_card * __init get_new_ }/** -* mux_probe - Determine if the Serial Mux should claim this device. -* @dev: The parisc device. +* get_mux_port_count - Get the number of ports the MUX supports. +* @hpa: The HPA of the MUX device. * -* Deterimine if the Serial Mux should claim this chip (return 0) -* or not (return 1). +* This function reads the IODC to determine the number of ports +* the MUX supports. */ -static int __init mux_probe (struct parisc_device *dev) +static int __init get_mux_port_count (unsigned int hpa) { -int i, status, ports; +int status;u8 iodc_data[32 ];unsigned long bytecnt; -struct uart_port *port; -struct mux_card *card; - status =pdc_iodc_read (&bytecnt, dev->hpa.start,0 , iodc_data,32 ); -if (status !=PDC_OK ) { -printk (KERN_ERR "Serial mux: Unable to read IODC.\n" ); -return 1 ; - } + status =pdc_iodc_read (&bytecnt, hpa,0 , iodc_data,32 ); +BUG_ON (status !=PDC_OK ); - ports =GET_MUX_PORTS (iodc_data); -printk (KERN_INFO "Serial mux driver (%d ports) Revision: 0.4\n" , ports); - - card =get_new_mux_card (); -if (card ==NULL ) -return 1 ; - - card->dev = dev; - card->port_count = ports; -request_mem_region (card->dev->hpa.start +MUX_OFFSET , - card->port_count *MUX_LINE_OFFSET ,"Mux" ); - -if (!port_cnt) { - mux_driver.cons =MUX_CONSOLE ; +return GET_MUX_PORTS (iodc_data); +} - status =uart_register_driver (&mux_driver); -if (status) { -printk (KERN_ERR "Serial mux: Unable to register driver.\n" ); -return 1 ; - } +/** +* setup_mux_ports - Setup all the mux portse. +* @hpa: The HPA of the MUX device. +* +* This function is used to initialize all the ports for the given mux +* and register the ports with the serial core driver. +*/ +static int __init setup_mux_ports (unsigned int hpa,unsigned int num_ports) +{ +int i, status; +struct uart_port *port; -init_timer (&mux_timer); - mux_timer.function = mux_poll; +if (port_cnt ==0 ) { +printk (KERN_INFO "Serial mux driver. Revision: 0.5\n" ); } -for (i =0 ; i < ports; ++i, ++port_cnt) { +for (i =0 ; i < num_ports; ++i, ++port_cnt) { port = &mux_ports[port_cnt].port; - port->iobase =0 ; - port->mapbase = dev->hpa.start +MUX_OFFSET + - (i *MUX_LINE_OFFSET ); - port->membase =ioremap_nocache (port->mapbase,MUX_LINE_OFFSET ); - port->iotype =UPIO_MEM ; - port->type =PORT_MUX ; + port->iobase =0 ; + port->mapbase = hpa +MUX_OFFSET + (i *MUX_LINE_OFFSET ); + port->membase =ioremap_nocache (port->mapbase,MUX_LINE_OFFSET ); + port->iotype =UPIO_MEM ; + port->type =PORT_MUX ; port->irq =NO_IRQ ; port->uartclk =0 ; port->fifosize =MUX_FIFO_SIZE ;
@@ -543,10 +532,30 @@ static int __init mux_probe(struct parisBUG_ON (status); } -#ifdef CONFIG_SERIAL_MUX_CONSOLE -register_console (&mux_console); -#endif -mod_timer (&mux_timer, jiffies +MUX_POLL_DELAY ); +return 0 ; +} + +/** +* mux_probe - Determine if the Serial Mux should claim this device. +* @dev: The parisc device. +* +* Deterimine if the Serial Mux should claim this chip (return 0) +* or not (return 1). +*/ +static int __init mux_probe (struct parisc_device *dev) +{ +int port_count =get_mux_port_count (dev->hpa.start); +struct mux_card *card =get_new_mux_card (); +if (card ==NULL ) +return 1 ; + + card->dev = dev; + card->port_count = port_count; +request_mem_region (card->dev->hpa.start +MUX_OFFSET , + card->port_count *MUX_LINE_OFFSET ,"Mux" ); + +if (dev->hpa.start !=PAGE0 ->mem_cons.hpa) +setup_mux_ports (dev->hpa.start, port_count);return 0 ; }
@@ -565,13 +574,64 @@ static struct parisc_driver serial_mux_d };/** +* console_is_mux - Determines if the console is a MUX device. +* +* This function checks the PAGE0 console device to determine +* if the device is a MUX. +*/ +static int __init console_is_mux (void ) +{ +int status; +u8 iodc_data[32 ]; +unsigned long bytecnt; + + status =pdc_iodc_read (&bytecnt,PAGE0 ->mem_cons.hpa,0 , iodc_data,32 ); +BUG_ON (status !=PDC_OK ); + +if ((iodc_data[3 ] &0x1f ) !=HPHW_A_DIRECT ) +return 0 ; + +if (((iodc_data[4 ] &0xf ) <<16 | (iodc_data[5 ] <<8 ) | iodc_data[6 ]) !=0x000D ) +return 0 ; + +return 1 ; +} + + +/** * mux_init - Serial MUX initalization procedure. * * Register the Serial MUX driver. */ static int __init mux_init (void ) { -return register_parisc_driver (&serial_mux_driver); +int status; + +#ifdef CONFIG_SERIAL_MUX_CONSOLE + mux_driver.cons =MUX_CONSOLE ; +#endif + +/* If the console is a MUX, setup the mux ports that belong to the +* console before registering the serial_mux_driver. This prevents +* the ports from being assigned in the wrong order if the system +* has multiple MUX cards installed. +*/ +if (console_is_mux ()) { + status =uart_register_driver (&mux_driver); +BUG_ON (status); + +setup_mux_ports (PAGE0 ->mem_cons.hpa,get_mux_port_count (PAGE0 ->mem_cons.hpa)); +register_console (&mux_console); + } + + status =register_parisc_driver (&serial_mux_driver); +if (status ==0 && port_cnt >0 ) { +init_timer (&mux_timer); + mux_timer.function = mux_poll; +mod_timer (&mux_timer, jiffies +MUX_POLL_DELAY ); + } + +return status; }/**
_______________________________________________
parisc-linux mailing list
[email protected]
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux