ixp4xx-npe.c (bc4d7eafb7ad590f546b58c40cd7856990fbb303) | ixp4xx-npe.c (0b458d7b10f83eb34b84957e6cf47cee2a97bc49) |
---|---|
1/* 2 * Intel IXP4xx Network Processor Engine driver for Linux 3 * 4 * Copyright (C) 2007 Krzysztof Halasa <khc@pm.waw.pl> 5 * 6 * This program is free software; you can redistribute it and/or modify it 7 * under the terms of version 2 of the GNU General Public License 8 * as published by the Free Software Foundation. --- 141 unchanged lines hidden (view full) --- 150 { ECS_DBG_CTXT_REG_1, 0x00000000 }, 151 { ECS_DBG_CTXT_REG_2, 0x001E0000 }, 152 { ECS_INSTRUCT_REG, 0x1003C00F }, 153}; 154 155static struct npe npe_tab[NPE_COUNT] = { 156 { 157 .id = 0, | 1/* 2 * Intel IXP4xx Network Processor Engine driver for Linux 3 * 4 * Copyright (C) 2007 Krzysztof Halasa <khc@pm.waw.pl> 5 * 6 * This program is free software; you can redistribute it and/or modify it 7 * under the terms of version 2 of the GNU General Public License 8 * as published by the Free Software Foundation. --- 141 unchanged lines hidden (view full) --- 150 { ECS_DBG_CTXT_REG_1, 0x00000000 }, 151 { ECS_DBG_CTXT_REG_2, 0x001E0000 }, 152 { ECS_INSTRUCT_REG, 0x1003C00F }, 153}; 154 155static struct npe npe_tab[NPE_COUNT] = { 156 { 157 .id = 0, |
158 .regs = (struct npe_regs __iomem *)IXP4XX_NPEA_BASE_VIRT, 159 .regs_phys = IXP4XX_NPEA_BASE_PHYS, | |
160 }, { 161 .id = 1, | 158 }, { 159 .id = 1, |
162 .regs = (struct npe_regs __iomem *)IXP4XX_NPEB_BASE_VIRT, 163 .regs_phys = IXP4XX_NPEB_BASE_PHYS, | |
164 }, { 165 .id = 2, | 160 }, { 161 .id = 2, |
166 .regs = (struct npe_regs __iomem *)IXP4XX_NPEC_BASE_VIRT, 167 .regs_phys = IXP4XX_NPEC_BASE_PHYS, | |
168 } 169}; 170 171int npe_running(struct npe *npe) 172{ 173 return (__raw_readl(&npe->regs->exec_status_cmd) & STAT_RUN) != 0; 174} 175 --- 506 unchanged lines hidden (view full) --- 682void npe_release(struct npe *npe) 683{ 684 module_put(THIS_MODULE); 685} 686 687static int ixp4xx_npe_probe(struct platform_device *pdev) 688{ 689 int i, found = 0; | 162 } 163}; 164 165int npe_running(struct npe *npe) 166{ 167 return (__raw_readl(&npe->regs->exec_status_cmd) & STAT_RUN) != 0; 168} 169 --- 506 unchanged lines hidden (view full) --- 676void npe_release(struct npe *npe) 677{ 678 module_put(THIS_MODULE); 679} 680 681static int ixp4xx_npe_probe(struct platform_device *pdev) 682{ 683 int i, found = 0; |
684 struct device *dev = &pdev->dev; 685 struct resource *res; |
|
690 691 for (i = 0; i < NPE_COUNT; i++) { 692 struct npe *npe = &npe_tab[i]; | 686 687 for (i = 0; i < NPE_COUNT; i++) { 688 struct npe *npe = &npe_tab[i]; |
689 690 res = platform_get_resource(pdev, IORESOURCE_MEM, i); 691 if (!res) 692 return -ENODEV; 693 |
|
693 if (!(ixp4xx_read_feature_bits() & | 694 if (!(ixp4xx_read_feature_bits() & |
694 (IXP4XX_FEATURE_RESET_NPEA << i))) | 695 (IXP4XX_FEATURE_RESET_NPEA << i))) { 696 dev_info(dev, "NPE%d at 0x%08x-0x%08x not available\n", 697 i, res->start, res->end); |
695 continue; /* NPE already disabled or not present */ | 698 continue; /* NPE already disabled or not present */ |
696 if (!(npe->mem_res = request_mem_region(npe->regs_phys, 697 REGS_SIZE, 698 npe_name(npe)))) { 699 print_npe(KERN_ERR, npe, 700 "failed to request memory region\n"); 701 continue; | |
702 } | 699 } |
700 npe->regs = devm_ioremap_resource(dev, res); 701 if (!npe->regs) 702 return -ENOMEM; |
|
703 | 703 |
704 if (npe_reset(npe)) | 704 if (npe_reset(npe)) { 705 dev_info(dev, "NPE%d at 0x%08x-0x%08x does not reset\n", 706 i, res->start, res->end); |
705 continue; | 707 continue; |
708 } |
|
706 npe->valid = 1; | 709 npe->valid = 1; |
710 dev_info(dev, "NPE%d at 0x%08x-0x%08x registered\n", 711 i, res->start, res->end); |
|
707 found++; 708 } 709 710 if (!found) 711 return -ENODEV; 712 return 0; 713} 714 715static int ixp4xx_npe_remove(struct platform_device *pdev) 716{ 717 int i; 718 719 for (i = 0; i < NPE_COUNT; i++) | 712 found++; 713 } 714 715 if (!found) 716 return -ENODEV; 717 return 0; 718} 719 720static int ixp4xx_npe_remove(struct platform_device *pdev) 721{ 722 int i; 723 724 for (i = 0; i < NPE_COUNT; i++) |
720 if (npe_tab[i].mem_res) { | 725 if (npe_tab[i].regs) { |
721 npe_reset(&npe_tab[i]); | 726 npe_reset(&npe_tab[i]); |
722 release_resource(npe_tab[i].mem_res); | |
723 } 724 725 return 0; 726} 727 728static struct platform_driver ixp4xx_npe_driver = { 729 .driver = { 730 .name = "ixp4xx-npe", --- 20 unchanged lines hidden --- | 727 } 728 729 return 0; 730} 731 732static struct platform_driver ixp4xx_npe_driver = { 733 .driver = { 734 .name = "ixp4xx-npe", --- 20 unchanged lines hidden --- |