diff options
Diffstat (limited to 'drivers/char')
-rw-r--r-- | drivers/char/mxser_new.c | 276 |
1 files changed, 109 insertions, 167 deletions
diff --git a/drivers/char/mxser_new.c b/drivers/char/mxser_new.c index e665dfccd956..82cb420b4d68 100644 --- a/drivers/char/mxser_new.c +++ b/drivers/char/mxser_new.c | |||
@@ -84,97 +84,11 @@ | |||
84 | #define CI134_ASIC_ID 3 | 84 | #define CI134_ASIC_ID 3 |
85 | #define CI104J_ASIC_ID 5 | 85 | #define CI104J_ASIC_ID 5 |
86 | 86 | ||
87 | enum { | 87 | #define MXSER_HIGHBAUD 1 |
88 | MXSER_BOARD_C168_ISA = 1, | 88 | #define MXSER_HAS2 2 |
89 | MXSER_BOARD_C104_ISA, | ||
90 | MXSER_BOARD_CI104J, | ||
91 | MXSER_BOARD_C168_PCI, | ||
92 | MXSER_BOARD_C104_PCI, | ||
93 | MXSER_BOARD_C102_ISA, | ||
94 | MXSER_BOARD_CI132, | ||
95 | MXSER_BOARD_CI134, | ||
96 | MXSER_BOARD_CP132, | ||
97 | MXSER_BOARD_CP114, | ||
98 | MXSER_BOARD_CT114, | ||
99 | MXSER_BOARD_CP102, | ||
100 | MXSER_BOARD_CP104U, | ||
101 | MXSER_BOARD_CP168U, | ||
102 | MXSER_BOARD_CP132U, | ||
103 | MXSER_BOARD_CP134U, | ||
104 | MXSER_BOARD_CP104JU, | ||
105 | MXSER_BOARD_RC7000, | ||
106 | MXSER_BOARD_CP118U, | ||
107 | MXSER_BOARD_CP102UL, | ||
108 | MXSER_BOARD_CP102U, | ||
109 | MXSER_BOARD_CP118EL, | ||
110 | MXSER_BOARD_CP168EL, | ||
111 | MXSER_BOARD_CP104EL | ||
112 | }; | ||
113 | |||
114 | static char *mxser_brdname[] = { | ||
115 | "C168 series", | ||
116 | "C104 series", | ||
117 | "CI-104J series", | ||
118 | "C168H/PCI series", | ||
119 | "C104H/PCI series", | ||
120 | "C102 series", | ||
121 | "CI-132 series", | ||
122 | "CI-134 series", | ||
123 | "CP-132 series", | ||
124 | "CP-114 series", | ||
125 | "CT-114 series", | ||
126 | "CP-102 series", | ||
127 | "CP-104U series", | ||
128 | "CP-168U series", | ||
129 | "CP-132U series", | ||
130 | "CP-134U series", | ||
131 | "CP-104JU series", | ||
132 | "Moxa UC7000 Serial", | ||
133 | "CP-118U series", | ||
134 | "CP-102UL series", | ||
135 | "CP-102U series", | ||
136 | "CP-118EL series", | ||
137 | "CP-168EL series", | ||
138 | "CP-104EL series" | ||
139 | }; | ||
140 | |||
141 | static int mxser_numports[] = { | ||
142 | 8, /* C168-ISA */ | ||
143 | 4, /* C104-ISA */ | ||
144 | 4, /* CI104J */ | ||
145 | 8, /* C168-PCI */ | ||
146 | 4, /* C104-PCI */ | ||
147 | 2, /* C102-ISA */ | ||
148 | 2, /* CI132 */ | ||
149 | 4, /* CI134 */ | ||
150 | 2, /* CP132 */ | ||
151 | 4, /* CP114 */ | ||
152 | 4, /* CT114 */ | ||
153 | 2, /* CP102 */ | ||
154 | 4, /* CP104U */ | ||
155 | 8, /* CP168U */ | ||
156 | 2, /* CP132U */ | ||
157 | 4, /* CP134U */ | ||
158 | 4, /* CP104JU */ | ||
159 | 8, /* RC7000 */ | ||
160 | 8, /* CP118U */ | ||
161 | 2, /* CP102UL */ | ||
162 | 2, /* CP102U */ | ||
163 | 8, /* CP118EL */ | ||
164 | 8, /* CP168EL */ | ||
165 | 4 /* CP104EL */ | ||
166 | }; | ||
167 | |||
168 | #define UART_TYPE_NUM 2 | ||
169 | |||
170 | static const unsigned int Gmoxa_uart_id[UART_TYPE_NUM] = { | ||
171 | MOXA_MUST_MU150_HWID, | ||
172 | MOXA_MUST_MU860_HWID | ||
173 | }; | ||
174 | 89 | ||
175 | /* This is only for PCI */ | 90 | /* This is only for PCI */ |
176 | #define UART_INFO_NUM 3 | 91 | static const struct { |
177 | struct mxpciuart_info { | ||
178 | int type; | 92 | int type; |
179 | int tx_fifo; | 93 | int tx_fifo; |
180 | int rx_fifo; | 94 | int rx_fifo; |
@@ -183,51 +97,85 @@ struct mxpciuart_info { | |||
183 | int rx_trigger; | 97 | int rx_trigger; |
184 | int rx_low_water; | 98 | int rx_low_water; |
185 | long max_baud; | 99 | long max_baud; |
186 | }; | 100 | } Gpci_uart_info[] = { |
187 | |||
188 | static const struct mxpciuart_info Gpci_uart_info[UART_INFO_NUM] = { | ||
189 | {MOXA_OTHER_UART, 16, 16, 16, 14, 14, 1, 921600L}, | 101 | {MOXA_OTHER_UART, 16, 16, 16, 14, 14, 1, 921600L}, |
190 | {MOXA_MUST_MU150_HWID, 64, 64, 64, 48, 48, 16, 230400L}, | 102 | {MOXA_MUST_MU150_HWID, 64, 64, 64, 48, 48, 16, 230400L}, |
191 | {MOXA_MUST_MU860_HWID, 128, 128, 128, 96, 96, 32, 921600L} | 103 | {MOXA_MUST_MU860_HWID, 128, 128, 128, 96, 96, 32, 921600L} |
192 | }; | 104 | }; |
105 | #define UART_INFO_NUM ARRAY_SIZE(Gpci_uart_info) | ||
106 | |||
107 | struct mxser_cardinfo { | ||
108 | unsigned int nports; | ||
109 | char *name; | ||
110 | unsigned int flags; | ||
111 | }; | ||
112 | |||
113 | static const struct mxser_cardinfo mxser_cards[] = { | ||
114 | { 8, "C168 series", }, /* C168-ISA */ | ||
115 | { 4, "C104 series", }, /* C104-ISA */ | ||
116 | { 4, "CI-104J series", }, /* CI104J */ | ||
117 | { 8, "C168H/PCI series", }, /* C168-PCI */ | ||
118 | { 4, "C104H/PCI series", }, /* C104-PCI */ | ||
119 | { 4, "C102 series", MXSER_HAS2 }, /* C102-ISA */ | ||
120 | { 4, "CI-132 series", MXSER_HAS2 }, /* CI132 */ | ||
121 | { 4, "CI-134 series", }, /* CI134 */ | ||
122 | { 2, "CP-132 series", }, /* CP132 */ | ||
123 | { 4, "CP-114 series", }, /* CP114 */ | ||
124 | { 4, "CT-114 series", }, /* CT114 */ | ||
125 | { 2, "CP-102 series", MXSER_HIGHBAUD }, /* CP102 */ | ||
126 | { 4, "CP-104U series", }, /* CP104U */ | ||
127 | { 8, "CP-168U series", }, /* CP168U */ | ||
128 | { 2, "CP-132U series", }, /* CP132U */ | ||
129 | { 4, "CP-134U series", }, /* CP134U */ | ||
130 | { 4, "CP-104JU series", }, /* CP104JU */ | ||
131 | { 8, "Moxa UC7000 Serial", }, /* RC7000 */ | ||
132 | { 8, "CP-118U series", }, /* CP118U */ | ||
133 | { 2, "CP-102UL series", }, /* CP102UL */ | ||
134 | { 2, "CP-102U series", }, /* CP102U */ | ||
135 | { 8, "CP-118EL series", }, /* CP118EL */ | ||
136 | { 8, "CP-168EL series", }, /* CP168EL */ | ||
137 | { 4, "CP-104EL series", } /* CP104EL */ | ||
138 | }; | ||
193 | 139 | ||
140 | /* driver_data correspond to the lines in the structure above | ||
141 | see also ISA probe function before you change something */ | ||
194 | static struct pci_device_id mxser_pcibrds[] = { | 142 | static struct pci_device_id mxser_pcibrds[] = { |
195 | { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_C168), | 143 | { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_C168), |
196 | .driver_data = MXSER_BOARD_C168_PCI }, | 144 | .driver_data = 3 }, |
197 | { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_C104), | 145 | { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_C104), |
198 | .driver_data = MXSER_BOARD_C104_PCI }, | 146 | .driver_data = 4 }, |
199 | { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP132), | 147 | { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP132), |
200 | .driver_data = MXSER_BOARD_CP132 }, | 148 | .driver_data = 8 }, |
201 | { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP114), | 149 | { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP114), |
202 | .driver_data = MXSER_BOARD_CP114 }, | 150 | .driver_data = 9 }, |
203 | { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CT114), | 151 | { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CT114), |
204 | .driver_data = MXSER_BOARD_CT114 }, | 152 | .driver_data = 10 }, |
205 | { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP102), | 153 | { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP102), |
206 | .driver_data = MXSER_BOARD_CP102 }, | 154 | .driver_data = 11 }, |
207 | { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP104U), | 155 | { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP104U), |
208 | .driver_data = MXSER_BOARD_CP104U }, | 156 | .driver_data = 12 }, |
209 | { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP168U), | 157 | { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP168U), |
210 | .driver_data = MXSER_BOARD_CP168U }, | 158 | .driver_data = 13 }, |
211 | { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP132U), | 159 | { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP132U), |
212 | .driver_data = MXSER_BOARD_CP132U }, | 160 | .driver_data = 14 }, |
213 | { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP134U), | 161 | { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP134U), |
214 | .driver_data = MXSER_BOARD_CP134U }, | 162 | .driver_data = 15 }, |
215 | { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP104JU), | 163 | { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP104JU), |
216 | .driver_data = MXSER_BOARD_CP104JU }, | 164 | .driver_data = 16 }, |
217 | { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_RC7000), | 165 | { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_RC7000), |
218 | .driver_data = MXSER_BOARD_RC7000 }, | 166 | .driver_data = 17 }, |
219 | { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP118U), | 167 | { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP118U), |
220 | .driver_data = MXSER_BOARD_CP118U }, | 168 | .driver_data = 18 }, |
221 | { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP102UL), | 169 | { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP102UL), |
222 | .driver_data = MXSER_BOARD_CP102UL }, | 170 | .driver_data = 19 }, |
223 | { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP102U), | 171 | { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP102U), |
224 | .driver_data = MXSER_BOARD_CP102U }, | 172 | .driver_data = 20 }, |
225 | { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP118EL), | 173 | { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP118EL), |
226 | .driver_data = MXSER_BOARD_CP118EL }, | 174 | .driver_data = 21 }, |
227 | { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP168EL), | 175 | { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP168EL), |
228 | .driver_data = MXSER_BOARD_CP168EL }, | 176 | .driver_data = 22 }, |
229 | { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP104EL), | 177 | { PCI_DEVICE(PCI_VENDOR_ID_MOXA, PCI_DEVICE_ID_MOXA_CP104EL), |
230 | .driver_data = MXSER_BOARD_CP104EL }, | 178 | .driver_data = 23 }, |
231 | { } | 179 | { } |
232 | }; | 180 | }; |
233 | MODULE_DEVICE_TABLE(pci, mxser_pcibrds); | 181 | MODULE_DEVICE_TABLE(pci, mxser_pcibrds); |
@@ -338,8 +286,7 @@ struct mxser_board { | |||
338 | struct pci_dev *pdev; /* temporary (until pci probing) */ | 286 | struct pci_dev *pdev; /* temporary (until pci probing) */ |
339 | 287 | ||
340 | int irq; | 288 | int irq; |
341 | int board_type; | 289 | const struct mxser_cardinfo *info; |
342 | unsigned int nports; | ||
343 | unsigned long vector; | 290 | unsigned long vector; |
344 | unsigned long vector_mask; | 291 | unsigned long vector_mask; |
345 | 292 | ||
@@ -392,8 +339,8 @@ static int CheckIsMoxaMust(int io) | |||
392 | } | 339 | } |
393 | 340 | ||
394 | GET_MOXA_MUST_HARDWARE_ID(io, &hwid); | 341 | GET_MOXA_MUST_HARDWARE_ID(io, &hwid); |
395 | for (i = 0; i < UART_TYPE_NUM; i++) { | 342 | for (i = 1; i < UART_INFO_NUM; i++) { /* 0 = OTHER_UART */ |
396 | if (hwid == Gmoxa_uart_id[i]) | 343 | if (hwid == Gpci_uart_info[i].type) |
397 | return (int)hwid; | 344 | return (int)hwid; |
398 | } | 345 | } |
399 | return MOXA_OTHER_UART; | 346 | return MOXA_OTHER_UART; |
@@ -2447,7 +2394,7 @@ static irqreturn_t mxser_interrupt(int irq, void *dev_id, struct pt_regs *regs) | |||
2447 | goto irq_stop; | 2394 | goto irq_stop; |
2448 | if (brd == NULL) | 2395 | if (brd == NULL) |
2449 | goto irq_stop; | 2396 | goto irq_stop; |
2450 | max = mxser_numports[brd->board_type - 1]; | 2397 | max = brd->info->nports; |
2451 | while (1) { | 2398 | while (1) { |
2452 | irqbits = inb(brd->vector) & brd->vector_mask; | 2399 | irqbits = inb(brd->vector) & brd->vector_mask; |
2453 | if (irqbits == brd->vector_mask) | 2400 | if (irqbits == brd->vector_mask) |
@@ -2574,7 +2521,7 @@ static void mxser_release_res(struct mxser_board *brd, unsigned int irq) | |||
2574 | pci_release_region(pdev, 3); | 2521 | pci_release_region(pdev, 3); |
2575 | pci_dev_put(pdev); | 2522 | pci_dev_put(pdev); |
2576 | } else { | 2523 | } else { |
2577 | release_region(brd->ports[0].ioaddr, 8 * brd->nports); | 2524 | release_region(brd->ports[0].ioaddr, 8 * brd->info->nports); |
2578 | release_region(brd->vector, 1); | 2525 | release_region(brd->vector, 1); |
2579 | } | 2526 | } |
2580 | } | 2527 | } |
@@ -2587,7 +2534,7 @@ static int __devinit mxser_initbrd(struct mxser_board *brd) | |||
2587 | 2534 | ||
2588 | printk(KERN_INFO "max. baud rate = %d bps.\n", brd->ports[0].max_baud); | 2535 | printk(KERN_INFO "max. baud rate = %d bps.\n", brd->ports[0].max_baud); |
2589 | 2536 | ||
2590 | for (i = 0; i < brd->nports; i++) { | 2537 | for (i = 0; i < brd->info->nports; i++) { |
2591 | info = &brd->ports[i]; | 2538 | info = &brd->ports[i]; |
2592 | info->board = brd; | 2539 | info->board = brd; |
2593 | info->stop_rx = 0; | 2540 | info->stop_rx = 0; |
@@ -2628,7 +2575,7 @@ static int __devinit mxser_initbrd(struct mxser_board *brd) | |||
2628 | if (retval) { | 2575 | if (retval) { |
2629 | printk(KERN_ERR "Board %s: Request irq failed, IRQ (%d) may " | 2576 | printk(KERN_ERR "Board %s: Request irq failed, IRQ (%d) may " |
2630 | "conflict with another device.\n", | 2577 | "conflict with another device.\n", |
2631 | mxser_brdname[brd->board_type - 1], brd->irq); | 2578 | brd->info->name, brd->irq); |
2632 | /* We hold resources, we need to release them. */ | 2579 | /* We hold resources, we need to release them. */ |
2633 | mxser_release_res(brd, 0); | 2580 | mxser_release_res(brd, 0); |
2634 | return retval; | 2581 | return retval; |
@@ -2645,40 +2592,44 @@ static int __init mxser_get_ISA_conf(int cap, struct mxser_board *brd) | |||
2645 | brd->chip_flag = MOXA_OTHER_UART; | 2592 | brd->chip_flag = MOXA_OTHER_UART; |
2646 | 2593 | ||
2647 | id = mxser_read_register(cap, regs); | 2594 | id = mxser_read_register(cap, regs); |
2648 | if (id == C168_ASIC_ID) { | 2595 | switch (id) { |
2649 | brd->board_type = MXSER_BOARD_C168_ISA; | 2596 | case C168_ASIC_ID: |
2650 | brd->nports = 8; | 2597 | brd->info = &mxser_cards[0]; |
2651 | } else if (id == C104_ASIC_ID) { | 2598 | break; |
2652 | brd->board_type = MXSER_BOARD_C104_ISA; | 2599 | case C104_ASIC_ID: |
2653 | brd->nports = 4; | 2600 | brd->info = &mxser_cards[1]; |
2654 | } else if (id == C102_ASIC_ID) { | 2601 | break; |
2655 | brd->board_type = MXSER_BOARD_C102_ISA; | 2602 | case CI104J_ASIC_ID: |
2656 | brd->nports = 2; | 2603 | brd->info = &mxser_cards[2]; |
2657 | } else if (id == CI132_ASIC_ID) { | 2604 | break; |
2658 | brd->board_type = MXSER_BOARD_CI132; | 2605 | case C102_ASIC_ID: |
2659 | brd->nports = 2; | 2606 | brd->info = &mxser_cards[5]; |
2660 | } else if (id == CI134_ASIC_ID) { | 2607 | break; |
2661 | brd->board_type = MXSER_BOARD_CI134; | 2608 | case CI132_ASIC_ID: |
2662 | brd->nports = 4; | 2609 | brd->info = &mxser_cards[6]; |
2663 | } else if (id == CI104J_ASIC_ID) { | 2610 | break; |
2664 | brd->board_type = MXSER_BOARD_CI104J; | 2611 | case CI134_ASIC_ID: |
2665 | brd->nports = 4; | 2612 | brd->info = &mxser_cards[7]; |
2666 | } else | 2613 | break; |
2614 | default: | ||
2667 | return 0; | 2615 | return 0; |
2616 | } | ||
2668 | 2617 | ||
2669 | irq = 0; | 2618 | irq = 0; |
2670 | if (brd->nports == 2) { | 2619 | /* some ISA cards have 2 ports, but we want to see them as 4-port (why?) |
2620 | Flag-hack checks if configuration should be read as 2-port here. */ | ||
2621 | if (brd->info->nports == 2 || (brd->info->flags & MXSER_HAS2)) { | ||
2671 | irq = regs[9] & 0xF000; | 2622 | irq = regs[9] & 0xF000; |
2672 | irq = irq | (irq >> 4); | 2623 | irq = irq | (irq >> 4); |
2673 | if (irq != (regs[9] & 0xFF00)) | 2624 | if (irq != (regs[9] & 0xFF00)) |
2674 | return MXSER_ERR_IRQ_CONFLIT; | 2625 | return MXSER_ERR_IRQ_CONFLIT; |
2675 | } else if (brd->nports == 4) { | 2626 | } else if (brd->info->nports == 4) { |
2676 | irq = regs[9] & 0xF000; | 2627 | irq = regs[9] & 0xF000; |
2677 | irq = irq | (irq >> 4); | 2628 | irq = irq | (irq >> 4); |
2678 | irq = irq | (irq >> 8); | 2629 | irq = irq | (irq >> 8); |
2679 | if (irq != regs[9]) | 2630 | if (irq != regs[9]) |
2680 | return MXSER_ERR_IRQ_CONFLIT; | 2631 | return MXSER_ERR_IRQ_CONFLIT; |
2681 | } else if (brd->nports == 8) { | 2632 | } else if (brd->info->nports == 8) { |
2682 | irq = regs[9] & 0xF000; | 2633 | irq = regs[9] & 0xF000; |
2683 | irq = irq | (irq >> 4); | 2634 | irq = irq | (irq >> 4); |
2684 | irq = irq | (irq >> 8); | 2635 | irq = irq | (irq >> 8); |
@@ -2718,35 +2669,31 @@ static int __init mxser_get_ISA_conf(int cap, struct mxser_board *brd) | |||
2718 | brd->uart_type = PORT_16550A; | 2669 | brd->uart_type = PORT_16550A; |
2719 | else | 2670 | else |
2720 | brd->uart_type = PORT_16450; | 2671 | brd->uart_type = PORT_16450; |
2721 | if (id == 1) | 2672 | if (!request_region(brd->ports[0].ioaddr, 8 * brd->info->nports, |
2722 | brd->nports = 8; | 2673 | "mxser(IO)")) |
2723 | else | ||
2724 | brd->nports = 4; | ||
2725 | if (!request_region(brd->ports[0].ioaddr, 8 * brd->nports, "mxser(IO)")) | ||
2726 | return MXSER_ERR_IOADDR; | 2674 | return MXSER_ERR_IOADDR; |
2727 | if (!request_region(brd->vector, 1, "mxser(vector)")) { | 2675 | if (!request_region(brd->vector, 1, "mxser(vector)")) { |
2728 | release_region(brd->ports[0].ioaddr, 8 * brd->nports); | 2676 | release_region(brd->ports[0].ioaddr, 8 * brd->info->nports); |
2729 | return MXSER_ERR_VECTOR; | 2677 | return MXSER_ERR_VECTOR; |
2730 | } | 2678 | } |
2731 | return brd->nports; | 2679 | return brd->info->nports; |
2732 | } | 2680 | } |
2733 | 2681 | ||
2734 | static int __init mxser_get_PCI_conf(int board_type, struct mxser_board *brd, | 2682 | static int __init mxser_get_PCI_conf(const struct pci_device_id *ent, |
2735 | struct pci_dev *pdev) | 2683 | struct mxser_board *brd, struct pci_dev *pdev) |
2736 | { | 2684 | { |
2737 | unsigned int i, j; | 2685 | unsigned int i, j; |
2738 | unsigned long ioaddress; | 2686 | unsigned long ioaddress; |
2739 | int retval; | 2687 | int retval; |
2740 | 2688 | ||
2741 | /* io address */ | 2689 | /* io address */ |
2742 | brd->board_type = board_type; | 2690 | brd->info = &mxser_cards[ent->driver_data]; |
2743 | brd->nports = mxser_numports[board_type - 1]; | ||
2744 | ioaddress = pci_resource_start(pdev, 2); | 2691 | ioaddress = pci_resource_start(pdev, 2); |
2745 | retval = pci_request_region(pdev, 2, "mxser(IO)"); | 2692 | retval = pci_request_region(pdev, 2, "mxser(IO)"); |
2746 | if (retval) | 2693 | if (retval) |
2747 | goto err; | 2694 | goto err; |
2748 | 2695 | ||
2749 | for (i = 0; i < brd->nports; i++) | 2696 | for (i = 0; i < brd->info->nports; i++) |
2750 | brd->ports[i].ioaddr = ioaddress + 8 * i; | 2697 | brd->ports[i].ioaddr = ioaddress + 8 * i; |
2751 | 2698 | ||
2752 | /* vector */ | 2699 | /* vector */ |
@@ -2763,14 +2710,14 @@ static int __init mxser_get_PCI_conf(int board_type, struct mxser_board *brd, | |||
2763 | brd->uart_type = PORT_16550A; | 2710 | brd->uart_type = PORT_16550A; |
2764 | brd->vector_mask = 0; | 2711 | brd->vector_mask = 0; |
2765 | 2712 | ||
2766 | for (i = 0; i < brd->nports; i++) { | 2713 | for (i = 0; i < brd->info->nports; i++) { |
2767 | for (j = 0; j < UART_INFO_NUM; j++) { | 2714 | for (j = 0; j < UART_INFO_NUM; j++) { |
2768 | if (Gpci_uart_info[j].type == brd->chip_flag) { | 2715 | if (Gpci_uart_info[j].type == brd->chip_flag) { |
2769 | brd->ports[i].max_baud = | 2716 | brd->ports[i].max_baud = |
2770 | Gpci_uart_info[j].max_baud; | 2717 | Gpci_uart_info[j].max_baud; |
2771 | 2718 | ||
2772 | /* exception....CP-102 */ | 2719 | /* exception....CP-102 */ |
2773 | if (board_type == MXSER_BOARD_CP102) | 2720 | if (brd->info->flags & MXSER_HIGHBAUD) |
2774 | brd->ports[i].max_baud = 921600; | 2721 | brd->ports[i].max_baud = 921600; |
2775 | break; | 2722 | break; |
2776 | } | 2723 | } |
@@ -2778,7 +2725,7 @@ static int __init mxser_get_PCI_conf(int board_type, struct mxser_board *brd, | |||
2778 | } | 2725 | } |
2779 | 2726 | ||
2780 | if (brd->chip_flag == MOXA_MUST_MU860_HWID) { | 2727 | if (brd->chip_flag == MOXA_MUST_MU860_HWID) { |
2781 | for (i = 0; i < brd->nports; i++) { | 2728 | for (i = 0; i < brd->info->nports; i++) { |
2782 | if (i < 4) | 2729 | if (i < 4) |
2783 | brd->ports[i].opmode_ioaddr = ioaddress + 4; | 2730 | brd->ports[i].opmode_ioaddr = ioaddress + 4; |
2784 | else | 2731 | else |
@@ -2788,7 +2735,7 @@ static int __init mxser_get_PCI_conf(int board_type, struct mxser_board *brd, | |||
2788 | outb(0, ioaddress + 0x0c); /* default set to RS232 mode */ | 2735 | outb(0, ioaddress + 0x0c); /* default set to RS232 mode */ |
2789 | } | 2736 | } |
2790 | 2737 | ||
2791 | for (i = 0; i < brd->nports; i++) { | 2738 | for (i = 0; i < brd->info->nports; i++) { |
2792 | brd->vector_mask |= (1 << i); | 2739 | brd->vector_mask |= (1 << i); |
2793 | brd->ports[i].baud_base = 921600; | 2740 | brd->ports[i].baud_base = 921600; |
2794 | } | 2741 | } |
@@ -2814,9 +2761,6 @@ static int __init mxser_module_init(void) | |||
2814 | return -ENOMEM; | 2761 | return -ENOMEM; |
2815 | spin_lock_init(&gm_lock); | 2762 | spin_lock_init(&gm_lock); |
2816 | 2763 | ||
2817 | for (i = 0; i < MXSER_BOARDS; i++) | ||
2818 | mxser_boards[i].board_type = -1; | ||
2819 | |||
2820 | printk(KERN_INFO "MOXA Smartio/Industio family driver version %s\n", | 2764 | printk(KERN_INFO "MOXA Smartio/Industio family driver version %s\n", |
2821 | MXSER_VERSION); | 2765 | MXSER_VERSION); |
2822 | 2766 | ||
@@ -2863,8 +2807,7 @@ static int __init mxser_module_init(void) | |||
2863 | if (retval != 0) | 2807 | if (retval != 0) |
2864 | printk(KERN_INFO "Found MOXA %s board " | 2808 | printk(KERN_INFO "Found MOXA %s board " |
2865 | "(CAP=0x%x)\n", | 2809 | "(CAP=0x%x)\n", |
2866 | mxser_brdname[brd->board_type - 1], | 2810 | brd->info->name, ioaddr[b]); |
2867 | ioaddr[b]); | ||
2868 | 2811 | ||
2869 | if (retval <= 0) { | 2812 | if (retval <= 0) { |
2870 | if (retval == MXSER_ERR_IRQ) | 2813 | if (retval == MXSER_ERR_IRQ) |
@@ -2892,7 +2835,7 @@ static int __init mxser_module_init(void) | |||
2892 | if (mxser_initbrd(brd) < 0) | 2835 | if (mxser_initbrd(brd) < 0) |
2893 | continue; | 2836 | continue; |
2894 | 2837 | ||
2895 | for (i = 0; i < brd->nports; i++) | 2838 | for (i = 0; i < brd->info->nports; i++) |
2896 | tty_register_device(mxvar_sdriver, | 2839 | tty_register_device(mxvar_sdriver, |
2897 | m * MXSER_PORTS_PER_BOARD + i, NULL); | 2840 | m * MXSER_PORTS_PER_BOARD + i, NULL); |
2898 | 2841 | ||
@@ -2910,7 +2853,7 @@ static int __init mxser_module_init(void) | |||
2910 | continue; | 2853 | continue; |
2911 | } | 2854 | } |
2912 | printk(KERN_INFO "Found MOXA %s board(BusNo=%d,DevNo=%d)\n", | 2855 | printk(KERN_INFO "Found MOXA %s board(BusNo=%d,DevNo=%d)\n", |
2913 | mxser_brdname[(int) (mxser_pcibrds[b].driver_data) - 1], | 2856 | mxser_cards[mxser_pcibrds[b].driver_data].name, |
2914 | pdev->bus->number, PCI_SLOT(pdev->devfn)); | 2857 | pdev->bus->number, PCI_SLOT(pdev->devfn)); |
2915 | if (m >= MXSER_BOARDS) | 2858 | if (m >= MXSER_BOARDS) |
2916 | printk(KERN_ERR | 2859 | printk(KERN_ERR |
@@ -2925,8 +2868,7 @@ static int __init mxser_module_init(void) | |||
2925 | } | 2868 | } |
2926 | brd = &mxser_boards[m]; | 2869 | brd = &mxser_boards[m]; |
2927 | brd->pdev = pdev; | 2870 | brd->pdev = pdev; |
2928 | retval = mxser_get_PCI_conf( | 2871 | retval = mxser_get_PCI_conf(&mxser_pcibrds[b], |
2929 | (int)mxser_pcibrds[b].driver_data, | ||
2930 | brd, pdev); | 2872 | brd, pdev); |
2931 | if (retval < 0) { | 2873 | if (retval < 0) { |
2932 | if (retval == MXSER_ERR_IRQ) | 2874 | if (retval == MXSER_ERR_IRQ) |
@@ -2950,7 +2892,7 @@ static int __init mxser_module_init(void) | |||
2950 | /* mxser_initbrd will hook ISR. */ | 2892 | /* mxser_initbrd will hook ISR. */ |
2951 | if (mxser_initbrd(brd) < 0) | 2893 | if (mxser_initbrd(brd) < 0) |
2952 | continue; | 2894 | continue; |
2953 | for (i = 0; i < brd->nports; i++) | 2895 | for (i = 0; i < brd->info->nports; i++) |
2954 | tty_register_device(mxvar_sdriver, | 2896 | tty_register_device(mxvar_sdriver, |
2955 | m * MXSER_PORTS_PER_BOARD + i, | 2897 | m * MXSER_PORTS_PER_BOARD + i, |
2956 | &pdev->dev); | 2898 | &pdev->dev); |
@@ -2989,7 +2931,7 @@ static void __exit mxser_module_exit(void) | |||
2989 | put_tty_driver(mxvar_sdriver); | 2931 | put_tty_driver(mxvar_sdriver); |
2990 | 2932 | ||
2991 | for (i = 0; i < MXSER_BOARDS; i++) | 2933 | for (i = 0; i < MXSER_BOARDS; i++) |
2992 | if (mxser_boards[i].board_type != -1) | 2934 | if (mxser_boards[i].info != NULL) |
2993 | mxser_release_res(&mxser_boards[i], 1); | 2935 | mxser_release_res(&mxser_boards[i], 1); |
2994 | 2936 | ||
2995 | pr_debug("Done.\n"); | 2937 | pr_debug("Done.\n"); |