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)  * Copyright (c) 1996-2002 Russell King.
^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) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #include <linux/blkdev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/ide.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <asm/ecard.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) static const struct ide_port_info rapide_port_info = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 	.host_flags		= IDE_HFLAG_MMIO | IDE_HFLAG_NO_DMA,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 	.chipset		= ide_generic,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) static void rapide_setup_ports(struct ide_hw *hw, void __iomem *base,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 			       void __iomem *ctrl, unsigned int sz, int irq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	unsigned long port = (unsigned long)base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	for (i = 0; i <= 7; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 		hw->io_ports_array[i] = port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 		port += sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	hw->io_ports.ctl_addr = (unsigned long)ctrl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	hw->irq = irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) static int rapide_probe(struct expansion_card *ec, const struct ecard_id *id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	void __iomem *base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	struct ide_host *host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	struct ide_hw hw, *hws[] = { &hw };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	ret = ecard_request_resources(ec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	base = ecardm_iomap(ec, ECARD_RES_MEMC, 0, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	if (!base) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 		ret = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 		goto release;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	memset(&hw, 0, sizeof(hw));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	rapide_setup_ports(&hw, base, base + 0x818, 1 << 6, ec->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	hw.dev = &ec->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	ret = ide_host_add(&rapide_port_info, hws, 1, &host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 		goto release;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	ecard_set_drvdata(ec, host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61)  release:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	ecard_release_resources(ec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63)  out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) static void rapide_remove(struct expansion_card *ec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	struct ide_host *host = ecard_get_drvdata(ec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	ecard_set_drvdata(ec, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	ide_host_remove(host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	ecard_release_resources(ec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) static struct ecard_id rapide_ids[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	{ MANU_YELLOWSTONE, PROD_YELLOWSTONE_RAPIDE32 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	{ 0xffff, 0xffff }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) static struct ecard_driver rapide_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	.probe		= rapide_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	.remove		= rapide_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	.id_table	= rapide_ids,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	.drv = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 		.name	= "rapide",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) static int __init rapide_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	return ecard_register_driver(&rapide_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) static void __exit rapide_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	ecard_remove_driver(&rapide_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) MODULE_DESCRIPTION("Yellowstone RAPIDE driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) module_init(rapide_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) module_exit(rapide_exit);