1 /* uio_ehci_pci - UIO driver for PCI EHCI devices */
2 /* This only implements MMIO access (no interrupts). */
3 /* SPDX-License-Identifier: GPL-2.0-only */
5 #include <linux/device.h>
6 #include <linux/module.h>
8 #include <linux/uio_driver.h>
10 #define DRIVER_VERSION "0.0.1"
11 #define DRIVER_AUTHOR "Nico Huber <nico.h@gmx.de>"
12 #define DRIVER_DESC "UIO driver for PCI EHCI devices"
13 #define DRIVER_TAG "uio_ehci_pci"
15 static int probe(struct pci_dev
*const pci_dev
,
16 const struct pci_device_id
*const did
)
18 struct uio_info
*info
;
21 ret
= pci_enable_device(pci_dev
);
25 ret
= pci_request_regions(pci_dev
, DRIVER_TAG
);
29 info
= kzalloc(sizeof(struct uio_info
), GFP_KERNEL
);
35 info
->name
= DRIVER_TAG
;
36 info
->version
= DRIVER_VERSION
;
38 info
->mem
[0].name
= "EHCI MMIO area";
39 info
->mem
[0].addr
= pci_resource_start(pci_dev
, 0);
40 if (!info
->mem
[0].addr
) {
44 info
->mem
[0].size
= pci_resource_len(pci_dev
, 0);
45 info
->mem
[0].memtype
= UIO_MEM_PHYS
;
47 ret
= uio_register_device(&pci_dev
->dev
, info
);
50 pci_set_drvdata(pci_dev
, info
);
56 pci_release_regions(pci_dev
);
58 pci_disable_device(pci_dev
);
63 static void remove(struct pci_dev
*const pci_dev
)
65 struct uio_info
*const info
= pci_get_drvdata(pci_dev
);
67 uio_unregister_device(info
);
69 pci_release_regions(pci_dev
);
70 pci_disable_device(pci_dev
);
73 static DEFINE_PCI_DEVICE_TABLE(ehci_pci_ids
) = {
74 { PCI_DEVICE(0x8086, 0x27cc) },
78 static struct pci_driver uio_ehci_pci_driver
= {
80 .id_table
= ehci_pci_ids
,
85 module_pci_driver(uio_ehci_pci_driver
);
86 MODULE_VERSION(DRIVER_VERSION
);
87 MODULE_LICENSE("GPL v2");
88 MODULE_AUTHOR(DRIVER_AUTHOR
);
89 MODULE_DESCRIPTION(DRIVER_DESC
);