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-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) #include <linux/ide.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) #define DRV_NAME "ide-4drives"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) static bool probe_4drives;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) module_param_named(probe, probe_4drives, bool, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) MODULE_PARM_DESC(probe, "probe for generic IDE chipset with 4 drives/port");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) static void ide_4drives_init_dev(ide_drive_t *drive)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 	if (drive->hwif->channel)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 		drive->select ^= 0x20;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) static const struct ide_port_ops ide_4drives_port_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 	.init_dev		= ide_4drives_init_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) static const struct ide_port_info ide_4drives_port_info = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 	.port_ops		= &ide_4drives_port_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 	.host_flags		= IDE_HFLAG_SERIALIZE | IDE_HFLAG_NO_DMA |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 				  IDE_HFLAG_4DRIVES,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 	.chipset		= ide_4drives,
^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 int __init ide_4drives_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 	unsigned long base = 0x1f0, ctl = 0x3f6;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 	struct ide_hw hw, *hws[] = { &hw, &hw };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 	if (probe_4drives == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 		return -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 	if (!request_region(base, 8, DRV_NAME)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 		printk(KERN_ERR "%s: I/O resource 0x%lX-0x%lX not free.\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 				DRV_NAME, base, base + 7);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 		return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 	if (!request_region(ctl, 1, DRV_NAME)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 		printk(KERN_ERR "%s: I/O resource 0x%lX not free.\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 				DRV_NAME, ctl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 		release_region(base, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 		return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 	memset(&hw, 0, sizeof(hw));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 	ide_std_init_ports(&hw, base, ctl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 	hw.irq = 14;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 	return ide_host_add(&ide_4drives_port_info, hws, 2, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) module_init(ide_4drives_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) MODULE_AUTHOR("Bartlomiej Zolnierkiewicz");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) MODULE_DESCRIPTION("generic IDE chipset with 4 drives/port support");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) MODULE_LICENSE("GPL");