cs89x0.c (8dd06ef34b6e2f41b29fbf5fc1663780f2524285) | cs89x0.c (47fd22f2b84765a2f7e3f150282497b902624547) |
---|---|
1/* cs89x0.c: A Crystal Semiconductor (Now Cirrus Logic) CS89[02]0 2 * driver for linux. 3 * Written 1996 by Russell Nelson, with reference to skeleton.c 4 * written 1993-1994 by Donald Becker. 5 * 6 * This software may be used and distributed according to the terms 7 * of the GNU General Public License, incorporated herein by reference. 8 * --- 90 unchanged lines hidden (view full) --- 99 * The CLPS eval board has the Cirrus chip at 0x80090300, in ARM IO space, 100 * but it is possible that a Cirrus board could be plugged into the ISA 101 * slots. 102 */ 103/* The cs8900 has 4 IRQ pins, software selectable. cs8900_irq_map maps 104 * them to system IRQ numbers. This mapping is card specific and is set to 105 * the configuration of the Cirrus Eval board for this chip. 106 */ | 1/* cs89x0.c: A Crystal Semiconductor (Now Cirrus Logic) CS89[02]0 2 * driver for linux. 3 * Written 1996 by Russell Nelson, with reference to skeleton.c 4 * written 1993-1994 by Donald Becker. 5 * 6 * This software may be used and distributed according to the terms 7 * of the GNU General Public License, incorporated herein by reference. 8 * --- 90 unchanged lines hidden (view full) --- 99 * The CLPS eval board has the Cirrus chip at 0x80090300, in ARM IO space, 100 * but it is possible that a Cirrus board could be plugged into the ISA 101 * slots. 102 */ 103/* The cs8900 has 4 IRQ pins, software selectable. cs8900_irq_map maps 104 * them to system IRQ numbers. This mapping is card specific and is set to 105 * the configuration of the Cirrus Eval board for this chip. 106 */ |
107#ifndef CONFIG_CS89x0_PLATFORM | 107#if IS_ENABLED(CONFIG_CS89x0_ISA) |
108static unsigned int netcard_portlist[] __used __initdata = { 109 0x300, 0x320, 0x340, 0x360, 0x200, 0x220, 0x240, 110 0x260, 0x280, 0x2a0, 0x2c0, 0x2e0, 0 111}; 112static unsigned int cs8900_irq_map[] = { 113 10, 11, 12, 5 114}; 115#endif --- 171 unchanged lines hidden (view full) --- 287} 288 289static void 290write_irq(struct net_device *dev, int chip_type, int irq) 291{ 292 int i; 293 294 if (chip_type == CS8900) { | 108static unsigned int netcard_portlist[] __used __initdata = { 109 0x300, 0x320, 0x340, 0x360, 0x200, 0x220, 0x240, 110 0x260, 0x280, 0x2a0, 0x2c0, 0x2e0, 0 111}; 112static unsigned int cs8900_irq_map[] = { 113 10, 11, 12, 5 114}; 115#endif --- 171 unchanged lines hidden (view full) --- 287} 288 289static void 290write_irq(struct net_device *dev, int chip_type, int irq) 291{ 292 int i; 293 294 if (chip_type == CS8900) { |
295#ifndef CONFIG_CS89x0_PLATFORM | 295#if IS_ENABLED(CONFIG_CS89x0_ISA) |
296 /* Search the mapping table for the corresponding IRQ pin. */ 297 for (i = 0; i != ARRAY_SIZE(cs8900_irq_map); i++) 298 if (cs8900_irq_map[i] == irq) 299 break; 300 /* Not found */ 301 if (i == ARRAY_SIZE(cs8900_irq_map)) 302 i = 3; 303#else --- 550 unchanged lines hidden (view full) --- 854 855 if (i >= CS8920_NO_INTS) { 856 writereg(dev, PP_BusCTL, 0); /* disable interrupts. */ 857 pr_err("can't get an interrupt\n"); 858 ret = -EAGAIN; 859 goto bad_out; 860 } 861 } else { | 296 /* Search the mapping table for the corresponding IRQ pin. */ 297 for (i = 0; i != ARRAY_SIZE(cs8900_irq_map); i++) 298 if (cs8900_irq_map[i] == irq) 299 break; 300 /* Not found */ 301 if (i == ARRAY_SIZE(cs8900_irq_map)) 302 i = 3; 303#else --- 550 unchanged lines hidden (view full) --- 854 855 if (i >= CS8920_NO_INTS) { 856 writereg(dev, PP_BusCTL, 0); /* disable interrupts. */ 857 pr_err("can't get an interrupt\n"); 858 ret = -EAGAIN; 859 goto bad_out; 860 } 861 } else { |
862#if !defined(CONFIG_CS89x0_PLATFORM) | 862#if IS_ENABLED(CONFIG_CS89x0_ISA) |
863 if (((1 << dev->irq) & lp->irq_map) == 0) { 864 pr_err("%s: IRQ %d is not in our map of allowable IRQs, which is %x\n", 865 dev->name, dev->irq, lp->irq_map); 866 ret = -EAGAIN; 867 goto bad_out; 868 } 869#endif 870/* FIXME: Cirrus' release had this: */ --- 647 unchanged lines hidden (view full) --- 1518 if (lp->chip_type != CS8900 && 1519 /* Check if the ISA IRQ has been set */ 1520 (i = readreg(dev, PP_CS8920_ISAINT) & 0xff, 1521 (i != 0 && i < CS8920_NO_INTS))) { 1522 if (!dev->irq) 1523 dev->irq = i; 1524 } else { 1525 i = lp->isa_config & INT_NO_MASK; | 863 if (((1 << dev->irq) & lp->irq_map) == 0) { 864 pr_err("%s: IRQ %d is not in our map of allowable IRQs, which is %x\n", 865 dev->name, dev->irq, lp->irq_map); 866 ret = -EAGAIN; 867 goto bad_out; 868 } 869#endif 870/* FIXME: Cirrus' release had this: */ --- 647 unchanged lines hidden (view full) --- 1518 if (lp->chip_type != CS8900 && 1519 /* Check if the ISA IRQ has been set */ 1520 (i = readreg(dev, PP_CS8920_ISAINT) & 0xff, 1521 (i != 0 && i < CS8920_NO_INTS))) { 1522 if (!dev->irq) 1523 dev->irq = i; 1524 } else { 1525 i = lp->isa_config & INT_NO_MASK; |
1526#ifndef CONFIG_CS89x0_PLATFORM | 1526#if IS_ENABLED(CONFIG_CS89x0_ISA) |
1527 if (lp->chip_type == CS8900) { 1528 /* Translate the IRQ using the IRQ mapping table. */ 1529 if (i >= ARRAY_SIZE(cs8900_irq_map)) 1530 pr_err("invalid ISA interrupt number %d\n", i); 1531 else 1532 i = cs8900_irq_map[i]; 1533 1534 lp->irq_map = CS8900_IRQ_MAP; /* fixed IRQ map for CS8900 */ --- 36 unchanged lines hidden (view full) --- 1571 goto out2; 1572 return 0; 1573out2: 1574 iowrite16(PP_ChipID, lp->virt_addr + ADD_PORT); 1575out1: 1576 return retval; 1577} 1578 | 1527 if (lp->chip_type == CS8900) { 1528 /* Translate the IRQ using the IRQ mapping table. */ 1529 if (i >= ARRAY_SIZE(cs8900_irq_map)) 1530 pr_err("invalid ISA interrupt number %d\n", i); 1531 else 1532 i = cs8900_irq_map[i]; 1533 1534 lp->irq_map = CS8900_IRQ_MAP; /* fixed IRQ map for CS8900 */ --- 36 unchanged lines hidden (view full) --- 1571 goto out2; 1572 return 0; 1573out2: 1574 iowrite16(PP_ChipID, lp->virt_addr + ADD_PORT); 1575out1: 1576 return retval; 1577} 1578 |
1579#ifndef CONFIG_CS89x0_PLATFORM | 1579#if IS_ENABLED(CONFIG_CS89x0_ISA) |
1580/* 1581 * This function converts the I/O port address used by the cs89x0_probe() and 1582 * init_module() functions to the I/O memory address used by the 1583 * cs89x0_probe1() function. 1584 */ 1585static int __init 1586cs89x0_ioport_probe(struct net_device *dev, unsigned long ioport, int modular) 1587{ --- 89 unchanged lines hidden (view full) --- 1677 if (err) 1678 goto out; 1679 return dev; 1680out: 1681 free_netdev(dev); 1682 pr_warn("no cs8900 or cs8920 detected. Be sure to disable PnP with SETUP\n"); 1683 return ERR_PTR(err); 1684} | 1580/* 1581 * This function converts the I/O port address used by the cs89x0_probe() and 1582 * init_module() functions to the I/O memory address used by the 1583 * cs89x0_probe1() function. 1584 */ 1585static int __init 1586cs89x0_ioport_probe(struct net_device *dev, unsigned long ioport, int modular) 1587{ --- 89 unchanged lines hidden (view full) --- 1677 if (err) 1678 goto out; 1679 return dev; 1680out: 1681 free_netdev(dev); 1682 pr_warn("no cs8900 or cs8920 detected. Be sure to disable PnP with SETUP\n"); 1683 return ERR_PTR(err); 1684} |
1685#endif 1686#endif 1687 1688#if defined(MODULE) && !defined(CONFIG_CS89x0_PLATFORM) 1689 | 1685#else |
1690static struct net_device *dev_cs89x0; 1691 1692/* Support the 'debug' module parm even if we're compiled for non-debug to 1693 * avoid breaking someone's startup scripts 1694 */ 1695 1696static int io; 1697static int irq; --- 56 unchanged lines hidden (view full) --- 1754 * media type specified is supported (circuitry is present) 1755 * if memory address is > 1MB, then required mem decode hw is present 1756 * if 10B-2, then agent other than driver will enable DC/DC converter 1757 * (hw or software util) 1758 */ 1759 1760int __init init_module(void) 1761{ | 1686static struct net_device *dev_cs89x0; 1687 1688/* Support the 'debug' module parm even if we're compiled for non-debug to 1689 * avoid breaking someone's startup scripts 1690 */ 1691 1692static int io; 1693static int irq; --- 56 unchanged lines hidden (view full) --- 1750 * media type specified is supported (circuitry is present) 1751 * if memory address is > 1MB, then required mem decode hw is present 1752 * if 10B-2, then agent other than driver will enable DC/DC converter 1753 * (hw or software util) 1754 */ 1755 1756int __init init_module(void) 1757{ |
1762 struct net_device *dev = alloc_etherdev(sizeof(struct net_local)); | 1758 struct net_device *dev; |
1763 struct net_local *lp; 1764 int ret = 0; 1765 1766#if DEBUGGING 1767 net_debug = debug; 1768#else 1769 debug = 0; 1770#endif | 1759 struct net_local *lp; 1760 int ret = 0; 1761 1762#if DEBUGGING 1763 net_debug = debug; 1764#else 1765 debug = 0; 1766#endif |
1767 dev = alloc_etherdev(sizeof(struct net_local)); |
|
1771 if (!dev) 1772 return -ENOMEM; 1773 1774 dev->irq = irq; 1775 dev->base_addr = io; 1776 lp = netdev_priv(dev); 1777 1778#if ALLOW_DMA --- 54 unchanged lines hidden (view full) --- 1833 struct net_local *lp = netdev_priv(dev_cs89x0); 1834 1835 unregister_netdev(dev_cs89x0); 1836 iowrite16(PP_ChipID, lp->virt_addr + ADD_PORT); 1837 ioport_unmap(lp->virt_addr); 1838 release_region(dev_cs89x0->base_addr, NETCARD_IO_EXTENT); 1839 free_netdev(dev_cs89x0); 1840} | 1768 if (!dev) 1769 return -ENOMEM; 1770 1771 dev->irq = irq; 1772 dev->base_addr = io; 1773 lp = netdev_priv(dev); 1774 1775#if ALLOW_DMA --- 54 unchanged lines hidden (view full) --- 1830 struct net_local *lp = netdev_priv(dev_cs89x0); 1831 1832 unregister_netdev(dev_cs89x0); 1833 iowrite16(PP_ChipID, lp->virt_addr + ADD_PORT); 1834 ioport_unmap(lp->virt_addr); 1835 release_region(dev_cs89x0->base_addr, NETCARD_IO_EXTENT); 1836 free_netdev(dev_cs89x0); 1837} |
1841#endif /* MODULE && !CONFIG_CS89x0_PLATFORM */ | 1838#endif /* MODULE */ 1839#endif /* CONFIG_CS89x0_ISA */ |
1842 | 1840 |
1843#ifdef CONFIG_CS89x0_PLATFORM | 1841#if IS_ENABLED(CONFIG_CS89x0_PLATFORM) |
1844static int __init cs89x0_platform_probe(struct platform_device *pdev) 1845{ 1846 struct net_device *dev = alloc_etherdev(sizeof(struct net_local)); 1847 void __iomem *virt_addr; 1848 int err; 1849 1850 if (!dev) 1851 return -ENOMEM; --- 63 unchanged lines hidden --- | 1842static int __init cs89x0_platform_probe(struct platform_device *pdev) 1843{ 1844 struct net_device *dev = alloc_etherdev(sizeof(struct net_local)); 1845 void __iomem *virt_addr; 1846 int err; 1847 1848 if (!dev) 1849 return -ENOMEM; --- 63 unchanged lines hidden --- |