linux/drivers/uio/uio_aec.c
<<
lue=lue=luo/spa4.1luospa4 class="lxr_search">lue=lue=lue=lue= typ Search.1 lue=luo/spa4.1e=luoinput typ le=1 odiv id/ /1o/a>ospa4 class="comment">/*o/spa4.1/ /2o/a>ospa4 class="comment"> * uio_aec.c -- simple driver for Adrienne Electronics Corp time code PCI deviceo/spa4.1/ /3o/a>ospa4 class="comment"> *o/spa4.1/ /4o/a>ospa4 class="comment"> * Copyright (C) 2008 Brandon Philips <brandon@ifup.org>o/spa4.1/ /5o/a>ospa4 class="comment"> *o/spa4.1/ /6o/a>ospa4 class="comment"> * This program is free software; you ca4 redistribute it and/or modify ito/spa4.1/ /7o/a>ospa4 class="comment"> * under the terms of the GNU General Public License verson> 2 as publishedo/spa4.1/ /8o/a>ospa4 class="comment"> * by the Free Software Founda v4.o/spa4.1/ /9o/a>ospa4 class="comment"> *o/spa4.1/ a>ospa4 class="comment"> * This program is distributed in the hope that it will be useful,o/spa4.1/ 11o/a>ospa4 class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty ofo/spa4.1/ 12o/a>ospa4 class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theo/spa4.1/ 13o/a>ospa4 class="comment"> * GNU General Public License for more details.o/spa4.1/ 14o/a>ospa4 class="comment"> *o/spa4.1/ 15o/a>ospa4 class="comment"> * You should have received a copy of the GNU General Public License alongo/spa4.1/ 16o/a>ospa4 class="comment"> * with this program; if not, write to the Free Software Founda v4, Inc., 5n spa4.1/ 17o/a>ospa4 class="comment"> * Temple Place, Suite 330, Bostv4, MA 02111-1307, USA.o/spa4.1/ 18o/a>ospa4 class="comment"> */o/spa4.1/ 19o/a>1/ 2 a>#include <linux/kernel.h a>>1/ 21 a>#include <linux/module.h a>>1/ 22 a>#include <linux/pci.h a>>1/ 23 a>#include <linux/init.h a>>1/ 24 a>#include <linux/interrupt.h a>>1/ 25 a>#include <linux/cdev.h a>>1/ 26 a>#include <linux/fs.h a>>1/ 27 a>#include <linux/io.h a>>1/ 28 a>#include <linux/uaccess.h a>>1/ 29 a>#include <linux/uio_driver.h a>>1/ 3 a>#include <linux/slab.h a>>1/ 31o/a>1/ 32 a>#define/oa href="+code=PCI_VENDOR_ID_AEC" class="sref">PCI_VENDOR_ID_AEC a> 0xaecb1/ 33 a>#define/oa href="+code=PCI_DEVICE_ID_AEC_VITCLTC" class="sref">PCI_DEVICE_ID_AEC_VITCLTC a> 0x62501/ 34o/a>1/ 35 a>#define/oa href="+code=INT_ENABLE_ADDR" class="sref">INT_ENABLE_ADDR a> 0xFC1/ 36 a>#define/oa href="+code=INT_ENABLE" class="sref">INT_ENABLE a> 0x101/ 37 a>#define/oa href="+code=INT_DISABLE" class="sref">INT_DISABLE a> 0x01/ 38o/a>1/ 39 a>#define/oa href="+code=INT_MASK_ADDR" class="sref">INT_MASK_ADDR a> 0x2E1/ 40 a>#define/oa href="+code=INT_MASK_ALL" class="sref">INT_MASK_ALL a> 0x3F1/ 41o/a>1/ 42 a>#define/oa href="+code=INTA_DRVR_ADDR" class="sref">INTA_DRVR_ADDR a> 0xFE1/ 43 a>#define/oa href="+code=INTA_ENABLED_FLAG" class="sref">INTA_ENABLED_FLAG a> 0x081/ 44 a>#define/oa href="+code=INTA_FLAG" class="sref">INTA_FLAG a> 0x011/ 45o/a>1/ 46 a>#define/oa href="+code=MAILBOX" class="sref">MAILBOX a> 0x0F1/ 47o/a>1/ 48o/a>static struct/oa href="+code=pci_device_id" class="sref">pci_device_id a> oa href="+code=ids" class="sref">ids a>[] = {1/ 49 a> {/oa href="+code=PCI_DEVICE" class="sref">PCI_DEVICE a>(oa href="+code=PCI_VENDOR_ID_AEC" class="sref">PCI_VENDOR_ID_AEC a>,/oa href="+code=PCI_DEVICE_ID_AEC_VITCLTC" class="sref">PCI_DEVICE_ID_AEC_VITCLTC a>), },1/ 50 a> {/0, }1/ 51o/a>};1/ 52o/a>oa href="+code=MODULE_DEVICE_TABLE" class="sref">MODULE_DEVICE_TABLE a>(oa href="+code=pci" class="sref">pci a>,/oa href="+code=ids" class="sref">ids a>);1/ 53o/a>1/ 54o/a>static oa href="+code=irqreturn_t" class="sref">irqreturn_t a> oa href="+code=aectc_irq" class="sref">aectc_irq a>(int/oa href="+code=irq" class="sref">irq a>, struct/oa href="+code=uio_info" class="sref">uio_info a> *oa href="+code=dev_info" class="sref">dev_info a>)1/ 55o/a>{1/ 56 a> void/oa href="+code=__iomem" class="sref">__iomem a> *oa href="+code=int_flag" class="sref">int_flag a> =/oa href="+code=dev_info" class="sref">dev_info a>->oa href="+code=priv" class="sref">priv a> +/oa href="+code=INTA_DRVR_ADDR" class="sref">INTA_DRVR_ADDR a>;1/ 57 a> unsigned char/oa href="+code=status" class="sref">status a> =/oa href="+code=ioread8" class="sref">ioread8 a>(oa href="+code=int_flag" class="sref">int_flag a>);1/ 58o/a>1/ 59o/a>1/ 60 a> if ((oa href="+code=status" class="sref">status a> &/oa href="+code=INTA_ENABLED_FLAG" class="sref">INTA_ENABLED_FLAG a>) &&/(oa href="+code=status" class="sref">status a> &/oa href="+code=INTA_FLAG" class="sref">INTA_FLAG a>)) {1/ 61 a> ospa4 class="comment">/* applica v4 writes 0x00 to 0x2F to get next interrupt */o/spa4.1/ 62 a> oa href="+code=status" class="sref">status a> =/oa href="+code=ioread8" class="sref">ioread8 a>(oa href="+code=dev_info" class="sref">dev_info a>->oa href="+code=priv" class="sref">priv a> +/oa href="+code=MAILBOX" class="sref">MAILBOX a>);1/ 63 a> return oa href="+code=IRQ_HANDLED" class="sref">IRQ_HANDLED a>;1/ 64 a> }1/ 65o/a>1/ 66 a> return oa href="+code=IRQ_NONE" class="sref">IRQ_NONE a>;1/ 67 a>}1/ 68o/a>1/ 69o/a>static void/oa href="+code=print_board_data" class="sref">print_board_data a>(struct/oa href="+code=pci_dev" class="sref">pci_dev a> *oa href="+code=pdev" class="sref">pdev a>, struct/oa href="+code=uio_info" class="sref">uio_info a> *oa href="+code=i" class="sref">i a>)1/ 70o/a>{1/ 71 a> oa href="+code=dev_info" class="sref">dev_info a>(&oa href="+code=pdev" class="sref">pdev a>->oa href="+code=dev" class="sref">dev a>, ospa4 class="string">"PCI-TC board vendor: %x%x number: %x%x"o/spa4.1/ 72 a> ospa4 class="string">" revison>: %c%c\n"o/spa4.,1/ 73 a> oa href="+code=ioread8" class="sref">ioread8 a>(oa href="+code=i" class="sref">i a>->oa href="+code=priv" class="sref">priv a> +/0x01),1/ 74 a> oa href="+code=ioread8" class="sref">ioread8 a>(oa href="+code=i" class="sref">i a>->oa href="+code=priv" class="sref">priv a> +/0x00),1/ 75 a> oa href="+code=ioread8" class="sref">ioread8 a>(oa href="+code=i" class="sref">i a>->oa href="+code=priv" class="sref">priv a> +/0x03),1/ 76 a> oa href="+code=ioread8" class="sref">ioread8 a>(oa href="+code=i" class="sref">i a>->oa href="+code=priv" class="sref">priv a> +/0x02),1/ 77 a> oa href="+code=ioread8" class="sref">ioread8 a>(oa href="+code=i" class="sref">i a>->oa href="+code=priv" class="sref">priv a> +/0x06),1/ 78 a> oa href="+code=ioread8" class="sref">ioread8 a>(oa href="+code=i" class="sref">i a>->oa href="+code=priv" class="sref">priv a> +/0x07));1/ 79 a>}1/ 80o/a>1/ 81o/a>static int/oa href="+code=probe" class="sref">probe a>(struct/oa href="+code=pci_dev" class="sref">pci_dev a> *oa href="+code=pdev" class="sref">pdev a>, const struct/oa href="+code=pci_device_id" class="sref">pci_device_id a> *oa href="+code=id" class="sref">id a>)1/ 82o/a>{1/ 83 a> struct/oa href="+code=uio_info" class="sref">uio_info a> *oa href="+code=info" class="sref">info a>;1/ 84 a> int/oa href="+code=ret" class="sref">ret a>;1/ 85o/a>1/ 86 a> oa href="+code=info" class="sref">info a> =/oa href="+code=kzalloc" class="sref">kzalloc a>(sizeof(struct/oa href="+code=uio_info" class="sref">uio_info a>),/oa href="+code=GFP_KERNEL" class="sref">GFP_KERNEL a>);1/ 87 a> if (!oa href="+code=info" class="sref">info a>)1/ 88 a> return -oa href="+code=ENOMEM" class="sref">ENOMEM a>;1/ 89o/a>1/ 90 a> if (oa href="+code=pci_enable_device" class="sref">pci_enable_device a>(oa href="+code=pdev" class="sref">pdev a>))1/ 91 a> goto/oa href="+code=out_free" class="sref">out_free a>;1/ 92o/a>1/ 93 a> if (oa href="+code=pci_request_regon>s" class="sref">pci_request_regon>s a>(oa href="+code=pdev" class="sref">pdev a>, ospa4 class="string">"aectc"o/spa4.))1/ 94 a> goto/oa href="+code=out_disable" class="sref">out_disable a>;1/ 95o/a>1/ 96 a> oa href="+code=info" class="sref">info a>->oa href="+code=nam " class="sref">nam a> =/ospa4 class="string">"aectc"o/spa4.;1/ 97 a> oa href="+code=info" class="sref">info a>->oa href="+code=port" class="sref">port a>[0].oa href="+code=start" class="sref">start a> =/oa href="+code=pci_resource_start" class="sref">pci_resource_start a>(oa href="+code=pdev" class="sref">pdev a>, 0);1/ 98 a> if (!oa href="+code=info" class="sref">info a>->oa href="+code=port" class="sref">port a>[0].oa href="+code=start" class="sref">start a>)1/ 99 a> goto/oa href="+code=out_release" class="sref">out_release a>;1/100 a> oa href="+code=info" class="sref">info a>->oa href="+code=priv" class="sref">priv a> =/oa href="+code=pci_iomap" class="sref">pci_iomap a>(oa href="+code=pdev" class="sref">pdev a>, 0, 0);1/101 a> if (!oa href="+code=info" class="sref">info a>->oa href="+code=priv" class="sref">priv a>)1/102 a> goto/oa href="+code=out_release" class="sref">out_release a>;1/103 a> oa href="+code=info" class="sref">info a>->oa href="+code=port" class="sref">port a>[0].oa href="+code=size" class="sref">size a> =/oa href="+code=pci_resource_len" class="sref">pci_resource_len a>(oa href="+code=pdev" class="sref">pdev a>, 0);1/104 a> oa href="+code=info" class="sref">info a>->oa href="+code=port" class="sref">port a>[0].oa href="+code=porttyp " class="sref">porttyp a> =/oa href="+code=UIO_PORT_GPIO" class="sref">UIO_PORT_GPIO a>;1/105o/a>1/106 a> oa href="+code=info" class="sref">info a>->oa href="+code=verson>" class="sref">verson> a> =/ospa4 class="string">"0.0.1"o/spa4.;1/107 a> oa href="+code=info" class="sref">info a>->oa href="+code=irq" class="sref">irq a> =/oa href="+code=pdev" class="sref">pdev a>->oa href="+code=irq" class="sref">irq a>;1/108 a> oa href="+code=info" class="sref">info a>->oa href="+code=irq_flags" class="sref">irq_flags a> =/oa href="+code=IRQF_SHARED" class="sref">IRQF_SHARED a>;1/109 a> oa href="+code=info" class="sref">info a>->oa href="+code=handler" class="sref">handler a> =/oa href="+code=aectc_irq" class="sref">aectc_irq a>;1/110o/a>1/111 a> oa href="+code=print_board_data" class="sref">print_board_data a>(oa href="+code=pdev" class="sref">pdev a>, oa href="+code=info" class="sref">info a>);1/112 a> oa href="+code=ret" class="sref">ret a> =/oa href="+code=uio_regoster_device" class="sref">uio_regoster_device a>(&oa href="+code=pdev" class="sref">pdev a>->oa href="+code=dev" class="sref">dev a>, oa href="+code=info" class="sref">info a>);1/113 a> if (oa href="+code=ret" class="sref">ret a>)1/114 a> goto/oa href="+code=out_unmap" class="sref">out_unmap a>;1/115o/a>1/116 a> oa href="+code=iowrite32" class="sref">iowrite32 a>(oa href="+code=INT_ENABLE" class="sref">INT_ENABLE a>, oa href="+code=info" class="sref">info a>->oa href="+code=priv" class="sref">priv a> +/oa href="+code=INT_ENABLE_ADDR" class="sref">INT_ENABLE_ADDR a>);1/117 a> oa href="+code=iowrite8" class="sref">iowrite8 a>(oa href="+code=INT_MASK_ALL" class="sref">INT_MASK_ALL a>, oa href="+code=info" class="sref">info a>->oa href="+code=priv" class="sref">priv a> +/oa href="+code=INT_MASK_ADDR" class="sref">INT_MASK_ADDR a>);1/118 a> if (!(oa href="+code=ioread8" class="sref">ioread8 a>(oa href="+code=info" class="sref">info a>->oa href="+code=priv" class="sref">priv a> +/oa href="+code=INTA_DRVR_ADDR" class="sref">INTA_DRVR_ADDR a>)1/119 a> &/oa href="+code=INTA_ENABLED_FLAG" class="sref">INTA_ENABLED_FLAG a>))1/120 a> oa href="+code=dev_err" class="sref">dev_err a>(&oa href="+code=pdev" class="sref">pdev a>->oa href="+code=dev" class="sref">dev a>, ospa4 class="string">"aectc: interrupts not enabled\n"o/spa4.);1/121o/a>1/122 a> oa href="+code=pci_set_drvdata" class="sref">pci_set_drvdata a>(oa href="+code=pdev" class="sref">pdev a>, oa href="+code=info" class="sref">info a>);1/123o/a>1/124 a> return 0;1/125o/a>1/126 a>oa href="+code=out_unmap" class="sref">out_unmap a>:1/127 a> oa href="+code=pci_iounmap" class="sref">pci_iounmap a>(oa href="+code=pdev" class="sref">pdev a>, oa href="+code=info" class="sref">info a>->oa href="+code=priv" class="sref">priv a>);1/128 a>oa href="+code=out_release" class="sref">out_release a>:1/129 a> oa href="+code=pci_release_regon>s" class="sref">pci_release_regon>s a>(oa href="+code=pdev" class="sref">pdev a>);1/13 a>oa href="+code=out_disable" class="sref">out_disable a>:1/131 a> oa href="+code=pci_disable_device" class="sref">pci_disable_device a>(oa href="+code=pdev" class="sref">pdev a>);1/132o/a>oa href="+code=out_free" class="sref">out_free a>:1/133 a> oa href="+code=kfree" class="sref">kfree a>(oa href="+code=info" class="sref">info a>);1/134 a> return -oa href="+code=ENODEV" class="sref">ENODEV a>;1/135 a>}1/136 a>1/137 a>static void/oa href="+code=remove" class="sref">remove a>(struct/oa href="+code=pci_dev" class="sref">pci_dev a> *oa href="+code=pdev" class="sref">pdev a>)1/138o/a>{1/139 a> struct/oa href="+code=uio_info" class="sref">uio_info a> *oa href="+code=info" class="sref">info a> =/oa href="+code=pci_get_drvdata" class="sref">pci_get_drvdata a>(oa href="+code=pdev" class="sref">pdev a>);1/140o/a>1/141 a> ospa4 class="comment">/* disable interrupts */o/spa4.1/142 a> oa href="+code=iowrite8" class="sref">iowrite8 a>(oa href="+code=INT_DISABLE" class="sref">INT_DISABLE a>, oa href="+code=info" class="sref">info a>->oa href="+code=priv" class="sref">priv a> +/oa href="+code=INT_MASK_ADDR" class="sref">INT_MASK_ADDR a>);1/143 a> oa href="+code=iowrite32" class="sref">iowrite32 a>(oa href="+code=INT_DISABLE" class="sref">INT_DISABLE a>, oa href="+code=info" class="sref">info a>->oa href="+code=priv" class="sref">priv a> +/oa href="+code=INT_ENABLE_ADDR" class="sref">INT_ENABLE_ADDR a>);1/144 a> ospa4 class="comment">/* read mailbox to ensure board drops irq */o/spa4.1/145 a> oa href="+code=ioread8" class="sref">ioread8 a>(oa href="+code=info" class="sref">info a>->oa href="+code=priv" class="sref">priv a> +/oa href="+code=MAILBOX" class="sref">MAILBOX a>);1/146 a>1/147 a> oa href="+code=uio_unregoster_device" class="sref">uio_unregoster_device a>(oa href="+code=info" class="sref">info a>);1/148 a> oa href="+code=pci_release_regon>s" class="sref">pci_release_regon>s a>(oa href="+code=pdev" class="sref">pdev a>);1/149 a> oa href="+code=pci_disable_device" class="sref">pci_disable_device a>(oa href="+code=pdev" class="sref">pdev a>);1/150 a> oa href="+code=pci_set_drvdata" class="sref">pci_set_drvdata a>(oa href="+code=pdev" class="sref">pdev a>, oa href="+code=NULL" class="sref">NULL a>);1/151 a> oa href="+code=iounmap" class="sref">iounmap a>(oa href="+code=info" class="sref">info a>->oa href="+code=priv" class="sref">priv a>);1/152o/a>1/153 a> oa href="+code=kfree" class="sref">kfree a>(oa href="+code=info" class="sref">info a>);1/154o/a>}1/155o/a>1/156 a>static struct/oa href="+code=pci_driver" class="sref">pci_driver a> oa href="+code=pci_driver" class="sref">pci_driver a> = {1/157 a> .oa href="+code=nam " class="sref">nam a> =/ospa4 class="string">"aectc"o/spa4.,1/158 a> .oa href="+code=id_table" class="sref">id_table a> =/oa href="+code=ids" class="sref">ids a>,1/159 a> .oa href="+code=probe" class="sref">probe a> =/oa href="+code=probe" class="sref">probe a>,1/160 a> .oa href="+code=remove" class="sref">remove a> =/oa href="+code=remove" class="sref">remove a>,1/161o/a>};1/162o/a>1/163 a>static int/oa href="+code=__init" class="sref">__init a> oa href="+code=aectc_init" class="sref">aectc_init a>(void)1/164 a>{1/165 a> return oa href="+code=pci_regoster_driver" class="sref">pci_regoster_driver a>(&oa href="+code=pci_driver" class="sref">pci_driver a>);1/166 a>}1/167o/a>1/168o/a>static void/oa href="+code=__exit" class="sref">__exit a> oa href="+code=aectc_exit" class="sref">aectc_exit a>(void)1/169o/a>{1/170 a> oa href="+code=pci_unregoster_driver" class="sref">pci_unregoster_driver a>(&oa href="+code=pci_driver" class="sref">pci_driver a>);1/171 a>}1/172o/a>1/173 a>oa href="+code=MODULE_LICENSE" class="sref">MODULE_LICENSE a>(ospa4 class="string">"GPL"o/spa4.);1/174o/a>1/175 a>oa href="+code=module_init" class="sref">module_init a>(oa href="+code=aectc_init" class="sref">aectc_init a>);1/176 a>oa href="+code=module_exit" class="sref">module_exit a>(oa href="+code=aectc_exit" class="sref">aectc_exit a>);1/177 a> The original LXR/uio/uio_ by the href="+coE" class="sref">M a>(oac_exit" class="NSE a>( the href="+coE" class="sref">M a>(oac(oa href="+code=aectc_exit" class="sree.net(oaojiv.s/lxoE"M a>5" cumodyline" .c#L1expericlasf">7" clashrefode=aectcam lxo@l="dr.noline.ass="NSE a>( the hresubf="+coE" lxo.l="dr.no kindly hosnam refode=aectc_exit" www.redpill-l="oao.no">Redpill L="oao ASline" oaovic.c#of L="uxf">idult4o/clas operass="s sers="ls since 1995.ass="NSE /bodySE /html cla