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) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2)  * Linux driver attachment glue for aic7770 based controllers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Copyright (c) 2000-2003 Adaptec Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * Redistribution and use in source and binary forms, with or without
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  * modification, are permitted provided that the following conditions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * are met:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  * 1. Redistributions of source code must retain the above copyright
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  *    notice, this list of conditions, and the following disclaimer,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  *    without modification.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14)  *    substantially similar to the "NO WARRANTY" disclaimer below
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15)  *    ("Disclaimer") and any redistribution must be conditioned upon
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16)  *    including a substantially similar Disclaimer requirement for further
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17)  *    binary redistribution.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18)  * 3. Neither the names of the above-listed copyright holders nor the names
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19)  *    of any contributors may be used to endorse or promote products derived
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  *    from this software without specific prior written permission.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  * Alternatively, this software may be distributed under the terms of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  * GNU General Public License ("GPL") version 2 as published by the Free
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  * Software Foundation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  * NO WARRANTY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28)  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29)  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30)  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31)  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32)  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33)  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34)  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37)  * POSSIBILITY OF SUCH DAMAGES.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39)  * $Id: //depot/aic7xxx/linux/drivers/scsi/aic7xxx/aic7770_osm.c#14 $
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) #include "aic7xxx_osm.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) #include <linux/device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) #include <linux/eisa.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) aic7770_map_registers(struct ahc_softc *ahc, u_int port)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	 * Lock out other contenders for our i/o space.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	if (!request_region(port, AHC_EISA_IOSIZE, "aic7xxx"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 		return (ENOMEM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	ahc->tag = BUS_SPACE_PIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	ahc->bsh.ioport = port;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	return (0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) aic7770_map_int(struct ahc_softc *ahc, u_int irq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	int shared;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	shared = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	if ((ahc->flags & AHC_EDGE_INTERRUPT) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 		shared = IRQF_SHARED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	error = request_irq(irq, ahc_linux_isr, shared, "aic7xxx", ahc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	if (error == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 		ahc->platform_data->irq = irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	return (-error);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) aic7770_probe(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	struct eisa_device *edev = to_eisa_device(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	u_int eisaBase = edev->base_addr+AHC_EISA_SLOT_OFFSET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	struct	ahc_softc *ahc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	char	buf[80];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	char   *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	int	error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	sprintf(buf, "ahc_eisa:%d", eisaBase >> 12);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	name = kstrdup(buf, GFP_ATOMIC);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	if (name == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 		return (ENOMEM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	ahc = ahc_alloc(&aic7xxx_driver_template, name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	if (ahc == NULL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 		return (ENOMEM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	ahc->dev = dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 	error = aic7770_config(ahc, aic7770_ident_table + edev->id.driver_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 			       eisaBase);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 	if (error != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		ahc->bsh.ioport = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 		ahc_free(ahc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 		return (error);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)  	dev_set_drvdata(dev, ahc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	error = ahc_linux_register_host(ahc, &aic7xxx_driver_template);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	return (error);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) aic7770_remove(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	struct ahc_softc *ahc = dev_get_drvdata(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	u_long s;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	if (ahc->platform_data && ahc->platform_data->host)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 			scsi_remove_host(ahc->platform_data->host);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	ahc_lock(ahc, &s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	ahc_intr_enable(ahc, FALSE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	ahc_unlock(ahc, &s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	ahc_free(ahc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)  
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) static struct eisa_device_id aic7770_ids[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 	{ "ADP7771", 0 }, /* AHA 274x */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	{ "ADP7756", 1 }, /* AHA 284x BIOS enabled */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	{ "ADP7757", 2 }, /* AHA 284x BIOS disabled */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	{ "ADP7782", 3 }, /* AHA 274x Olivetti OEM */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	{ "ADP7783", 4 }, /* AHA 274x Olivetti OEM (Differential) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	{ "ADP7770", 5 }, /* AIC7770 generic */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	{ "" }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) MODULE_DEVICE_TABLE(eisa, aic7770_ids);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) static struct eisa_driver aic7770_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	.id_table	= aic7770_ids,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	.driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 		.name   = "aic7xxx",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 		.probe  = aic7770_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 		.remove = aic7770_remove,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)   
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) ahc_linux_eisa_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	return eisa_driver_register(&aic7770_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)   
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) ahc_linux_eisa_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	eisa_driver_unregister(&aic7770_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) }