Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d6cbbad7 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by James Bottomley
Browse files

[SCSI] aic7xxx: clean up eisa support



 - the eisa layer only probes when it's actually safe, no need for
   a driver option
 - store the id table directly in linux format instead of convering
   at runtime

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent 8eb37942
Loading
Loading
Loading
Loading
+63 −112
Original line number Original line Diff line number Diff line
@@ -44,88 +44,46 @@
#include <linux/device.h>
#include <linux/device.h>
#include <linux/eisa.h>
#include <linux/eisa.h>


#define EISA_MFCTR_CHAR0(ID) (char)(((ID>>26) & 0x1F) | '@')  /* Bits 26-30 */
#define EISA_MFCTR_CHAR1(ID) (char)(((ID>>21) & 0x1F) | '@')  /* Bits 21-25 */
#define EISA_MFCTR_CHAR2(ID) (char)(((ID>>16) & 0x1F) | '@')  /* Bits 16-20 */
#define EISA_PRODUCT_ID(ID)  (short)((ID>>4)  & 0xFFF)        /* Bits  4-15 */
#define EISA_REVISION_ID(ID) (uint8_t)(ID & 0x0F)             /* Bits  0-3  */

static int aic7770_eisa_dev_probe(struct device *dev);
static int aic7770_eisa_dev_remove(struct device *dev);
static struct eisa_driver aic7770_driver = {
	.driver = {
		.name   = "aic7xxx",
		.probe  = aic7770_eisa_dev_probe,
		.remove = aic7770_eisa_dev_remove,
	}
};

typedef  struct device *aic7770_dev_t;

static int aic7770_linux_config(struct aic7770_identity *entry,
				aic7770_dev_t dev, u_int eisaBase);

int
int
ahc_linux_eisa_init(void)
aic7770_map_registers(struct ahc_softc *ahc, u_int port)
{
{
	struct eisa_device_id *eid;
	struct aic7770_identity *id;
	int i;

	if (aic7xxx_probe_eisa_vl == 0)
		return -ENODEV;

	/*
	/*
	 * Linux requires the EISA IDs to be specified in
	 * Lock out other contenders for our i/o space.
	 * the EISA ID string format.  Perform the conversion
	 * and setup a table with a NUL terminal entry.
	 */
	 */
	aic7770_driver.id_table = malloc(sizeof(struct eisa_device_id) *
	if (request_region(port, AHC_EISA_IOSIZE, "aic7xxx") == 0)
					 (ahc_num_aic7770_devs + 1),
		return (ENOMEM);
					 M_DEVBUF, M_NOWAIT);
	ahc->tag = BUS_SPACE_PIO;
	if (aic7770_driver.id_table == NULL)
	ahc->bsh.ioport = port;
		return -ENOMEM;
	return (0);

	for (eid = (struct eisa_device_id *)aic7770_driver.id_table,
	     id = aic7770_ident_table, i = 0;
	     i < ahc_num_aic7770_devs; eid++, id++, i++) {

		sprintf(eid->sig, "%c%c%c%03X%01X",
			EISA_MFCTR_CHAR0(id->full_id),
			EISA_MFCTR_CHAR1(id->full_id),
			EISA_MFCTR_CHAR2(id->full_id),
			EISA_PRODUCT_ID(id->full_id),
			EISA_REVISION_ID(id->full_id));
		eid->driver_data = i;
	}
	eid->sig[0] = 0;

	return eisa_driver_register(&aic7770_driver);
}
}


void
int
ahc_linux_eisa_exit(void)
aic7770_map_int(struct ahc_softc *ahc, u_int irq)
{
{
	if(aic7xxx_probe_eisa_vl != 0 && aic7770_driver.id_table != NULL) {
	int error;
		eisa_driver_unregister(&aic7770_driver);
	int shared;
		free(aic7770_driver.id_table, M_DEVBUF);

	}
	shared = 0;
	if ((ahc->flags & AHC_EDGE_INTERRUPT) == 0)
		shared = SA_SHIRQ;

	error = request_irq(irq, ahc_linux_isr, shared, "aic7xxx", ahc);
	if (error == 0)
		ahc->platform_data->irq = irq;
	
	return (-error);
}
}


static int
static int
aic7770_linux_config(struct aic7770_identity *entry, aic7770_dev_t dev,
aic7770_probe(struct device *dev)
		     u_int eisaBase)
{
{
	struct eisa_device *edev = to_eisa_device(dev);
	u_int eisaBase = edev->base_addr+AHC_EISA_SLOT_OFFSET;
	struct	ahc_softc *ahc;
	struct	ahc_softc *ahc;
	char	buf[80];
	char	buf[80];
	char   *name;
	char   *name;
	int	error;
	int	error;


	/*
	 * Allocate a softc for this card and
	 * set it up for attachment by our
	 * common detect routine.
	 */
	sprintf(buf, "ahc_eisa:%d", eisaBase >> 12);
	sprintf(buf, "ahc_eisa:%d", eisaBase >> 12);
	name = malloc(strlen(buf) + 1, M_DEVBUF, M_NOWAIT);
	name = malloc(strlen(buf) + 1, M_DEVBUF, M_NOWAIT);
	if (name == NULL)
	if (name == NULL)
@@ -134,69 +92,62 @@ aic7770_linux_config(struct aic7770_identity *entry, aic7770_dev_t dev,
	ahc = ahc_alloc(&aic7xxx_driver_template, name);
	ahc = ahc_alloc(&aic7xxx_driver_template, name);
	if (ahc == NULL)
	if (ahc == NULL)
		return (ENOMEM);
		return (ENOMEM);
	error = aic7770_config(ahc, entry, eisaBase);
	error = aic7770_config(ahc, aic7770_ident_table + edev->id.driver_data,
			       eisaBase);
	if (error != 0) {
	if (error != 0) {
		ahc->bsh.ioport = 0;
		ahc->bsh.ioport = 0;
		ahc_free(ahc);
		ahc_free(ahc);
		return (error);
		return (error);
	}
	}


	dev->driver_data = (void *)ahc;
 	dev_set_drvdata(dev, ahc);

	if (aic7xxx_detect_complete)
	if (aic7xxx_detect_complete)
		error = ahc_linux_register_host(ahc, &aic7xxx_driver_template);
		error = ahc_linux_register_host(ahc, &aic7xxx_driver_template);
	return (error);
	return (error);
}
}


int
static int
aic7770_map_registers(struct ahc_softc *ahc, u_int port)
aic7770_remove(struct device *dev)
{
{
	/*
	struct ahc_softc *ahc = dev_get_drvdata(dev);
	 * Lock out other contenders for our i/o space.
	u_long s;
	 */
	if (request_region(port, AHC_EISA_IOSIZE, "aic7xxx") == 0)
		return (ENOMEM);
	ahc->tag = BUS_SPACE_PIO;
	ahc->bsh.ioport = port;
	return (0);
}


int
	ahc_lock(ahc, &s);
aic7770_map_int(struct ahc_softc *ahc, u_int irq)
	ahc_intr_enable(ahc, FALSE);
{
	ahc_unlock(ahc, &s);
	int error;
	int shared;


	shared = 0;
	ahc_free(ahc);
	if ((ahc->flags & AHC_EDGE_INTERRUPT) == 0)
	return 0;
		shared = SA_SHIRQ;
}
 
 
	error = request_irq(irq, ahc_linux_isr, shared, "aic7xxx", ahc);
static struct eisa_device_id aic7770_ids[] = {
	if (error == 0)
	{ "ADP7771", 0 }, /* AHA 274x */
		ahc->platform_data->irq = irq;
	{ "ADP7756", 1 }, /* AHA 284x BIOS enabled */
	{ "ADP7757", 2 }, /* AHA 284x BIOS disabled */
	{ "ADP7782", 3 }, /* AHA 274x Olivetti OEM */
	{ "ADP7783", 4 }, /* AHA 274x Olivetti OEM (Differential) */
	{ "ADP7770", 5 }, /* AIC7770 generic */
	{ "" }
};
  
  
	return (-error);
static struct eisa_driver aic7770_driver = {
	.id_table	= aic7770_ids,
	.driver = {
		.name   = "aic7xxx",
		.probe  = aic7770_probe,
		.remove = aic7770_remove,
	}
	}
};
  
  
static int
int
aic7770_eisa_dev_probe(struct device *dev)
ahc_linux_eisa_init(void)
{
{
	struct eisa_device *edev;
	return eisa_driver_register(&aic7770_driver);

	edev = to_eisa_device(dev);
	return (aic7770_linux_config(aic7770_ident_table + edev->id.driver_data,
				    dev, edev->base_addr+AHC_EISA_SLOT_OFFSET));
}
}
  
  
static int
void
aic7770_eisa_dev_remove(struct device *dev)
ahc_linux_eisa_exit(void)
{
{
	struct ahc_softc *ahc = dev_get_drvata(dev);
	eisa_driver_unregister(&aic7770_driver);
	u_long s;

	ahc_lock(ahc, &s);
	ahc_intr_enable(ahc, FALSE);
	ahc_unlock(ahc, &s);
	ahc_free(ahc);

	return (0);
}
}
+0 −18
Original line number Original line Diff line number Diff line
@@ -329,22 +329,6 @@ static uint32_t aic7xxx_extended;
 */
 */
static uint32_t aic7xxx_pci_parity = ~0;
static uint32_t aic7xxx_pci_parity = ~0;


/*
 * Certain newer motherboards have put new PCI based devices into the
 * IO spaces that used to typically be occupied by VLB or EISA cards.
 * This overlap can cause these newer motherboards to lock up when scanned
 * for older EISA and VLB devices.  Setting this option to non-0 will
 * cause the driver to skip scanning for any VLB or EISA controllers and
 * only support the PCI controllers.  NOTE: this means that if the kernel
 * os compiled with PCI support disabled, then setting this to non-0
 * would result in never finding any devices :)
 */
#ifndef CONFIG_AIC7XXX_PROBE_EISA_VL
uint32_t aic7xxx_probe_eisa_vl;
#else
uint32_t aic7xxx_probe_eisa_vl = ~0;
#endif

/*
/*
 * There are lots of broken chipsets in the world.  Some of them will
 * There are lots of broken chipsets in the world.  Some of them will
 * violate the PCI spec when we issue byte sized memory writes to our
 * violate the PCI spec when we issue byte sized memory writes to our
@@ -1101,8 +1085,6 @@ aic7xxx_setup(char *s)
		{ "debug", &ahc_debug },
		{ "debug", &ahc_debug },
#endif
#endif
		{ "reverse_scan", &aic7xxx_reverse_scan },
		{ "reverse_scan", &aic7xxx_reverse_scan },
		{ "no_probe", &aic7xxx_probe_eisa_vl },
		{ "probe_eisa_vl", &aic7xxx_probe_eisa_vl },
		{ "periodic_otag", &aic7xxx_periodic_otag },
		{ "periodic_otag", &aic7xxx_periodic_otag },
		{ "pci_parity", &aic7xxx_pci_parity },
		{ "pci_parity", &aic7xxx_pci_parity },
		{ "seltime", &aic7xxx_seltime },
		{ "seltime", &aic7xxx_seltime },
+0 −1
Original line number Original line Diff line number Diff line
@@ -605,7 +605,6 @@ typedef enum


/**************************** VL/EISA Routines ********************************/
/**************************** VL/EISA Routines ********************************/
#ifdef CONFIG_EISA
#ifdef CONFIG_EISA
extern uint32_t aic7xxx_probe_eisa_vl;
int			 ahc_linux_eisa_init(void);
int			 ahc_linux_eisa_init(void);
void			 ahc_linux_eisa_exit(void);
void			 ahc_linux_eisa_exit(void);
int			 aic7770_map_registers(struct ahc_softc *ahc,
int			 aic7770_map_registers(struct ahc_softc *ahc,