aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/cyclades.c
diff options
context:
space:
mode:
authorJiri Slaby <jirislaby@gmail.com>2009-06-11 07:29:27 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2009-06-11 11:50:57 -0400
commit97e87f8ebe978e881c7325ba490574bd5500b133 (patch)
tree272dea45cc1a3d020a9290c46fbdf7ec866fbd34 /drivers/char/cyclades.c
parent5ba5a5d21204f61ff655b322a90ed91c75194e4b (diff)
tty: cyclades, plx9060 casts cleanup
Remove ugly all-over-the-code casts of ctl_addr to 9060 space. Add an union to the cyclades_card structure, which contains a pointer to both 9050 and 9060 spaces. The 9050 space layout is unknown, so let it still as a void __iomem pointer. Signed-off-by: Jiri Slaby <jirislaby@gmail.com> Signed-off-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char/cyclades.c')
-rw-r--r--drivers/char/cyclades.c65
1 files changed, 33 insertions, 32 deletions
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c
index ccf68a9e24b7..2cbf74134f1b 100644
--- a/drivers/char/cyclades.c
+++ b/drivers/char/cyclades.c
@@ -666,12 +666,10 @@ static void cy_send_xchar(struct tty_struct *tty, char ch);
666#define IS_CYC_Z(card) ((card).num_chips == (unsigned int)-1) 666#define IS_CYC_Z(card) ((card).num_chips == (unsigned int)-1)
667 667
668#define Z_FPGA_CHECK(card) \ 668#define Z_FPGA_CHECK(card) \
669 ((readl(&((struct RUNTIME_9060 __iomem *) \ 669 ((readl(&(card).ctl_addr.p9060->init_ctrl) & (1<<17)) != 0)
670 ((card).ctl_addr))->init_ctrl) & (1<<17)) != 0)
671 670
672#define ISZLOADED(card) (((ZO_V1 == readl(&((struct RUNTIME_9060 __iomem *) \ 671#define ISZLOADED(card) (((ZO_V1 == readl(&(card).ctl_addr.p9060->mail_box_0)) \
673 ((card).ctl_addr))->mail_box_0)) || \ 672 || Z_FPGA_CHECK(card)) && \
674 Z_FPGA_CHECK(card)) && \
675 (ZFIRM_ID == readl(&((struct FIRM_ID __iomem *) \ 673 (ZFIRM_ID == readl(&((struct FIRM_ID __iomem *) \
676 ((card).base_addr+ID_ADDRESS))->signature))) 674 ((card).base_addr+ID_ADDRESS))->signature)))
677 675
@@ -1400,14 +1398,12 @@ cyz_fetch_msg(struct cyclades_card *cinfo,
1400 zfw_ctrl = cinfo->base_addr + (readl(&firm_id->zfwctrl_addr) & 0xfffff); 1398 zfw_ctrl = cinfo->base_addr + (readl(&firm_id->zfwctrl_addr) & 0xfffff);
1401 board_ctrl = &zfw_ctrl->board_ctrl; 1399 board_ctrl = &zfw_ctrl->board_ctrl;
1402 1400
1403 loc_doorbell = readl(&((struct RUNTIME_9060 __iomem *) 1401 loc_doorbell = readl(&cinfo->ctl_addr.p9060->loc_doorbell);
1404 (cinfo->ctl_addr))->loc_doorbell);
1405 if (loc_doorbell) { 1402 if (loc_doorbell) {
1406 *cmd = (char)(0xff & loc_doorbell); 1403 *cmd = (char)(0xff & loc_doorbell);
1407 *channel = readl(&board_ctrl->fwcmd_channel); 1404 *channel = readl(&board_ctrl->fwcmd_channel);
1408 *param = (__u32) readl(&board_ctrl->fwcmd_param); 1405 *param = (__u32) readl(&board_ctrl->fwcmd_param);
1409 cy_writel(&((struct RUNTIME_9060 __iomem *)(cinfo->ctl_addr))-> 1406 cy_writel(&cinfo->ctl_addr.p9060->loc_doorbell, 0xffffffff);
1410 loc_doorbell, 0xffffffff);
1411 return 1; 1407 return 1;
1412 } 1408 }
1413 return 0; 1409 return 0;
@@ -1431,8 +1427,7 @@ cyz_issue_cmd(struct cyclades_card *cinfo,
1431 board_ctrl = &zfw_ctrl->board_ctrl; 1427 board_ctrl = &zfw_ctrl->board_ctrl;
1432 1428
1433 index = 0; 1429 index = 0;
1434 pci_doorbell = 1430 pci_doorbell = &cinfo->ctl_addr.p9060->pci_doorbell;
1435 &((struct RUNTIME_9060 __iomem *)(cinfo->ctl_addr))->pci_doorbell;
1436 while ((readl(pci_doorbell) & 0xff) != 0) { 1431 while ((readl(pci_doorbell) & 0xff) != 0) {
1437 if (index++ == 1000) 1432 if (index++ == 1000)
1438 return (int)(readl(pci_doorbell) & 0xff); 1433 return (int)(readl(pci_doorbell) & 0xff);
@@ -1635,8 +1630,7 @@ static void cyz_handle_cmd(struct cyclades_card *cinfo)
1635 zfw_ctrl = cinfo->base_addr + (readl(&firm_id->zfwctrl_addr) & 0xfffff); 1630 zfw_ctrl = cinfo->base_addr + (readl(&firm_id->zfwctrl_addr) & 0xfffff);
1636 board_ctrl = &zfw_ctrl->board_ctrl; 1631 board_ctrl = &zfw_ctrl->board_ctrl;
1637 fw_ver = readl(&board_ctrl->fw_version); 1632 fw_ver = readl(&board_ctrl->fw_version);
1638 hw_ver = readl(&((struct RUNTIME_9060 __iomem *)(cinfo->ctl_addr))-> 1633 hw_ver = readl(&cinfo->ctl_addr.p9060->mail_box_0);
1639 mail_box_0);
1640 1634
1641 while (cyz_fetch_msg(cinfo, &channel, &cmd, &param) == 1) { 1635 while (cyz_fetch_msg(cinfo, &channel, &cmd, &param) == 1) {
1642 special_count = 0; 1636 special_count = 0;
@@ -2394,8 +2388,8 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
2394 struct FIRM_ID __iomem *firm_id = cinfo->base_addr + ID_ADDRESS; 2388 struct FIRM_ID __iomem *firm_id = cinfo->base_addr + ID_ADDRESS;
2395 2389
2396 if (!ISZLOADED(*cinfo)) { 2390 if (!ISZLOADED(*cinfo)) {
2397 if (((ZE_V1 == readl(&((struct RUNTIME_9060 __iomem *) 2391 if (((ZE_V1 == readl(&cinfo->ctl_addr.p9060->
2398 (cinfo->ctl_addr))->mail_box_0)) && 2392 mail_box_0)) &&
2399 Z_FPGA_CHECK(*cinfo)) && 2393 Z_FPGA_CHECK(*cinfo)) &&
2400 (ZFIRM_HLT == readl( 2394 (ZFIRM_HLT == readl(
2401 &firm_id->signature))) { 2395 &firm_id->signature))) {
@@ -2417,6 +2411,7 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
2417 if (!cinfo->intr_enabled) { 2411 if (!cinfo->intr_enabled) {
2418 struct ZFW_CTRL __iomem *zfw_ctrl; 2412 struct ZFW_CTRL __iomem *zfw_ctrl;
2419 struct BOARD_CTRL __iomem *board_ctrl; 2413 struct BOARD_CTRL __iomem *board_ctrl;
2414 u16 intr;
2420 2415
2421 zfw_ctrl = cinfo->base_addr + 2416 zfw_ctrl = cinfo->base_addr +
2422 (readl(&firm_id->zfwctrl_addr) & 2417 (readl(&firm_id->zfwctrl_addr) &
@@ -2425,8 +2420,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
2425 board_ctrl = &zfw_ctrl->board_ctrl; 2420 board_ctrl = &zfw_ctrl->board_ctrl;
2426 2421
2427 /* Enable interrupts on the PLX chip */ 2422 /* Enable interrupts on the PLX chip */
2428 cy_writew(cinfo->ctl_addr + 0x68, 2423 intr = readw(&cinfo->ctl_addr.p9060->
2429 readw(cinfo->ctl_addr + 0x68) | 0x0900); 2424 intr_ctrl_stat) | 0x0900;
2425 cy_writew(&cinfo->ctl_addr.p9060->
2426 intr_ctrl_stat, intr);
2430 /* Enable interrupts on the FW */ 2427 /* Enable interrupts on the FW */
2431 retval = cyz_issue_cmd(cinfo, 0, 2428 retval = cyz_issue_cmd(cinfo, 0,
2432 C_CM_IRQ_ENBL, 0L); 2429 C_CM_IRQ_ENBL, 0L);
@@ -4347,8 +4344,7 @@ static int __devinit cy_init_card(struct cyclades_card *cinfo)
4347 spin_lock_init(&cinfo->card_lock); 4344 spin_lock_init(&cinfo->card_lock);
4348 4345
4349 if (IS_CYC_Z(*cinfo)) { /* Cyclades-Z */ 4346 if (IS_CYC_Z(*cinfo)) { /* Cyclades-Z */
4350 mailbox = readl(&((struct RUNTIME_9060 __iomem *) 4347 mailbox = readl(&cinfo->ctl_addr.p9060->mail_box_0);
4351 cinfo->ctl_addr)->mail_box_0);
4352 nports = (mailbox == ZE_V1) ? ZE_V1_NPORTS : 8; 4348 nports = (mailbox == ZE_V1) ? ZE_V1_NPORTS : 8;
4353 cinfo->intr_enabled = 0; 4349 cinfo->intr_enabled = 0;
4354 cinfo->nports = 0; /* Will be correctly set later, after 4350 cinfo->nports = 0; /* Will be correctly set later, after
@@ -4613,7 +4609,7 @@ static int __init cy_detect_isa(void)
4613 4609
4614 /* set cy_card */ 4610 /* set cy_card */
4615 cy_card[j].base_addr = cy_isa_address; 4611 cy_card[j].base_addr = cy_isa_address;
4616 cy_card[j].ctl_addr = NULL; 4612 cy_card[j].ctl_addr.p9050 = NULL;
4617 cy_card[j].irq = (int)cy_isa_irq; 4613 cy_card[j].irq = (int)cy_isa_irq;
4618 cy_card[j].bus_index = 0; 4614 cy_card[j].bus_index = 0;
4619 cy_card[j].first_line = cy_next_channel; 4615 cy_card[j].first_line = cy_next_channel;
@@ -5013,7 +5009,8 @@ static int __devinit cy_pci_probe(struct pci_dev *pdev,
5013 } 5009 }
5014 5010
5015 /* Disable interrupts on the PLX before resetting it */ 5011 /* Disable interrupts on the PLX before resetting it */
5016 cy_writew(addr0 + 0x68, readw(addr0 + 0x68) & ~0x0900); 5012 cy_writew(&ctl_addr->intr_ctrl_stat,
5013 readw(&ctl_addr->intr_ctrl_stat) & ~0x0900);
5017 5014
5018 plx_init(pdev, irq, addr0); 5015 plx_init(pdev, irq, addr0);
5019 5016
@@ -5109,7 +5106,7 @@ static int __devinit cy_pci_probe(struct pci_dev *pdev,
5109 5106
5110 /* set cy_card */ 5107 /* set cy_card */
5111 cy_card[card_no].base_addr = addr2; 5108 cy_card[card_no].base_addr = addr2;
5112 cy_card[card_no].ctl_addr = addr0; 5109 cy_card[card_no].ctl_addr.p9050 = addr0;
5113 cy_card[card_no].irq = irq; 5110 cy_card[card_no].irq = irq;
5114 cy_card[card_no].bus_index = 1; 5111 cy_card[card_no].bus_index = 1;
5115 cy_card[card_no].first_line = cy_next_channel; 5112 cy_card[card_no].first_line = cy_next_channel;
@@ -5125,17 +5122,20 @@ static int __devinit cy_pci_probe(struct pci_dev *pdev,
5125 plx_ver = readb(addr2 + CyPLX_VER) & 0x0f; 5122 plx_ver = readb(addr2 + CyPLX_VER) & 0x0f;
5126 switch (plx_ver) { 5123 switch (plx_ver) {
5127 case PLX_9050: 5124 case PLX_9050:
5128
5129 cy_writeb(addr0 + 0x4c, 0x43); 5125 cy_writeb(addr0 + 0x4c, 0x43);
5130 break; 5126 break;
5131 5127
5132 case PLX_9060: 5128 case PLX_9060:
5133 case PLX_9080: 5129 case PLX_9080:
5134 default: /* Old boards, use PLX_9060 */ 5130 default: /* Old boards, use PLX_9060 */
5135 plx_init(pdev, irq, addr0); 5131 {
5136 cy_writew(addr0 + 0x68, readw(addr0 + 0x68) | 0x0900); 5132 struct RUNTIME_9060 __iomem *ctl_addr = addr0;
5133 plx_init(pdev, irq, ctl_addr);
5134 cy_writew(&ctl_addr->intr_ctrl_stat,
5135 readw(&ctl_addr->intr_ctrl_stat) | 0x0900);
5137 break; 5136 break;
5138 } 5137 }
5138 }
5139 } 5139 }
5140 5140
5141 dev_info(&pdev->dev, "%s/PCI #%d found: %d channels starting from " 5141 dev_info(&pdev->dev, "%s/PCI #%d found: %d channels starting from "
@@ -5168,17 +5168,18 @@ static void __devexit cy_pci_remove(struct pci_dev *pdev)
5168 /* non-Z with old PLX */ 5168 /* non-Z with old PLX */
5169 if (!IS_CYC_Z(*cinfo) && (readb(cinfo->base_addr + CyPLX_VER) & 0x0f) == 5169 if (!IS_CYC_Z(*cinfo) && (readb(cinfo->base_addr + CyPLX_VER) & 0x0f) ==
5170 PLX_9050) 5170 PLX_9050)
5171 cy_writeb(cinfo->ctl_addr + 0x4c, 0); 5171 cy_writeb(cinfo->ctl_addr.p9050 + 0x4c, 0);
5172 else 5172 else
5173#ifndef CONFIG_CYZ_INTR 5173#ifndef CONFIG_CYZ_INTR
5174 if (!IS_CYC_Z(*cinfo)) 5174 if (!IS_CYC_Z(*cinfo))
5175#endif 5175#endif
5176 cy_writew(cinfo->ctl_addr + 0x68, 5176 cy_writew(&cinfo->ctl_addr.p9060->intr_ctrl_stat,
5177 readw(cinfo->ctl_addr + 0x68) & ~0x0900); 5177 readw(&cinfo->ctl_addr.p9060->intr_ctrl_stat) &
5178 ~0x0900);
5178 5179
5179 iounmap(cinfo->base_addr); 5180 iounmap(cinfo->base_addr);
5180 if (cinfo->ctl_addr) 5181 if (cinfo->ctl_addr.p9050)
5181 iounmap(cinfo->ctl_addr); 5182 iounmap(cinfo->ctl_addr.p9050);
5182 if (cinfo->irq 5183 if (cinfo->irq
5183#ifndef CONFIG_CYZ_INTR 5184#ifndef CONFIG_CYZ_INTR
5184 && !IS_CYC_Z(*cinfo) 5185 && !IS_CYC_Z(*cinfo)
@@ -5373,8 +5374,8 @@ static void __exit cy_cleanup_module(void)
5373 /* clear interrupt */ 5374 /* clear interrupt */
5374 cy_writeb(card->base_addr + Cy_ClrIntr, 0); 5375 cy_writeb(card->base_addr + Cy_ClrIntr, 0);
5375 iounmap(card->base_addr); 5376 iounmap(card->base_addr);
5376 if (card->ctl_addr) 5377 if (card->ctl_addr.p9050)
5377 iounmap(card->ctl_addr); 5378 iounmap(card->ctl_addr.p9050);
5378 if (card->irq 5379 if (card->irq
5379#ifndef CONFIG_CYZ_INTR 5380#ifndef CONFIG_CYZ_INTR
5380 && !IS_CYC_Z(*card) 5381 && !IS_CYC_Z(*card)