aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/serial
diff options
context:
space:
mode:
authorRyan Bradetich <rbradetich@gmail.com>2006-11-09 22:08:45 -0500
committerKyle McMartin <kyle@ubuntu.com>2006-12-08 00:34:29 -0500
commit614254458452d09ea0376862160662f2a6075ab9 (patch)
tree8600e8e6b3a738b92e5f982010eeb3e6f5a98b3f /drivers/serial
parent752b940359089ee1bcaceeb5c62d626a92586ba2 (diff)
[PARISC] [MUX] Correctly report the number of available ports
This patch adds a new function to return the actual number of ports available. Some of the built-in Muxes return the number of supported ports, but not all of these port are available for use. Signed-off-by: Ryan Bradetich <rbrad@parisc-linux.org> Signed-off-by: Kyle McMartin <kyle@parisc-linux.org>
Diffstat (limited to 'drivers/serial')
-rw-r--r--drivers/serial/mux.c42
1 files changed, 31 insertions, 11 deletions
diff --git a/drivers/serial/mux.c b/drivers/serial/mux.c
index 87269cca9c7c..f5b17f5333fb 100644
--- a/drivers/serial/mux.c
+++ b/drivers/serial/mux.c
@@ -70,7 +70,35 @@ static struct timer_list mux_timer;
70 70
71#define UART_PUT_CHAR(p, c) __raw_writel((c), (p)->membase + IO_DATA_REG_OFFSET) 71#define UART_PUT_CHAR(p, c) __raw_writel((c), (p)->membase + IO_DATA_REG_OFFSET)
72#define UART_GET_FIFO_CNT(p) __raw_readl((p)->membase + IO_DCOUNT_REG_OFFSET) 72#define UART_GET_FIFO_CNT(p) __raw_readl((p)->membase + IO_DCOUNT_REG_OFFSET)
73#define GET_MUX_PORTS(iodc_data) ((((iodc_data)[4] & 0xf0) >> 4) * 8) + 8 73
74/**
75 * get_mux_port_count - Get the number of available ports on the Mux.
76 * @dev: The parisc device.
77 *
78 * This function is used to determine the number of ports the Mux
79 * supports. The IODC data reports the number of ports the Mux
80 * can support, but there are cases where not all the Mux ports
81 * are connected. This function can override the IODC and
82 * return the true port count.
83 */
84static int __init get_mux_port_count(struct parisc_device *dev)
85{
86 u8 iodc_data[32];
87 unsigned long bytecnt;
88
89 int status = pdc_iodc_read(&bytecnt, dev->hpa.start, 0, iodc_data, 32);
90 BUG_ON(status != PDC_OK);
91
92 /* If this is the built-in Mux for the K-Class (Eole CAP/MUX),
93 * we only need to allocate resources for 1 port since the
94 * other 7 ports are not connected.
95 */
96 if(((iodc_data[0] << 4) | ((iodc_data[1] & 0xf0) >> 4)) == 0x15)
97 return 1;
98
99 /* Return the number of ports specified in the iodc data. */
100 return ((((iodc_data)[4] & 0xf0) >> 4) * 8) + 8;
101}
74 102
75/** 103/**
76 * mux_tx_empty - Check if the transmitter fifo is empty. 104 * mux_tx_empty - Check if the transmitter fifo is empty.
@@ -442,17 +470,9 @@ static struct uart_ops mux_pops = {
442 */ 470 */
443static int __init mux_probe(struct parisc_device *dev) 471static int __init mux_probe(struct parisc_device *dev)
444{ 472{
445 int i, status, port_count; 473 int i, status;
446 u8 iodc_data[32];
447 unsigned long bytecnt;
448
449 status = pdc_iodc_read(&bytecnt, dev->hpa.start, 0, iodc_data, 32);
450 if(status != PDC_OK) {
451 printk(KERN_ERR "Serial mux: Unable to read IODC.\n");
452 return 1;
453 }
454 474
455 port_count = GET_MUX_PORTS(iodc_data); 475 int port_count = get_mux_port_count(dev);
456 printk(KERN_INFO "Serial mux driver (%d ports) Revision: 0.6\n", port_count); 476 printk(KERN_INFO "Serial mux driver (%d ports) Revision: 0.6\n", port_count);
457 477
458 dev_set_drvdata(&dev->dev, (void *)(long)port_count); 478 dev_set_drvdata(&dev->dev, (void *)(long)port_count);