Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *  Copyright (c) 2001 Vojtech Pavlik
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * EMU10k1 - SB Live / Audigy - gameport driver for Linux
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <asm/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/ioport.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/gameport.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/pci.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) MODULE_DESCRIPTION("EMU10k1 gameport driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) struct emu {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	struct pci_dev *dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	struct gameport *gameport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	int io;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	int size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) static const struct pci_device_id emu_tbl[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	{ 0x1102, 0x7002, PCI_ANY_ID, PCI_ANY_ID }, /* SB Live gameport */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	{ 0x1102, 0x7003, PCI_ANY_ID, PCI_ANY_ID }, /* Audigy gameport */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	{ 0x1102, 0x7004, PCI_ANY_ID, PCI_ANY_ID }, /* Dell SB Live */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	{ 0x1102, 0x7005, PCI_ANY_ID, PCI_ANY_ID }, /* Audigy LS gameport */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	{ 0, }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) MODULE_DEVICE_TABLE(pci, emu_tbl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) static int emu_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	struct emu *emu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	struct gameport *port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	emu = kzalloc(sizeof(struct emu), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	port = gameport_allocate_port();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	if (!emu || !port) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 		printk(KERN_ERR "emu10k1-gp: Memory allocation failed\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 		error = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 		goto err_out_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	error = pci_enable_device(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 		goto err_out_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	emu->io = pci_resource_start(pdev, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	emu->size = pci_resource_len(pdev, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	emu->dev = pdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	emu->gameport = port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	gameport_set_name(port, "EMU10K1");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	gameport_set_phys(port, "pci%s/gameport0", pci_name(pdev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	port->dev.parent = &pdev->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	port->io = emu->io;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	if (!request_region(emu->io, emu->size, "emu10k1-gp")) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 		printk(KERN_ERR "emu10k1-gp: unable to grab region 0x%x-0x%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 			emu->io, emu->io + emu->size - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 		error = -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 		goto err_out_disable_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	pci_set_drvdata(pdev, emu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	gameport_register_port(port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85)  err_out_disable_dev:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	pci_disable_device(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87)  err_out_free:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	gameport_free_port(port);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	kfree(emu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) static void emu_remove(struct pci_dev *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	struct emu *emu = pci_get_drvdata(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	gameport_unregister_port(emu->gameport);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	release_region(emu->io, emu->size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	kfree(emu);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	pci_disable_device(pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) static struct pci_driver emu_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)         .name =         "Emu10k1_gameport",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)         .id_table =     emu_tbl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)         .probe =        emu_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	.remove =	emu_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) module_pci_driver(emu_driver);