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)  * eisa_enumerator.c - provide support for EISA adapters in PA-RISC machines
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (c) 2002 Daniel Engstrom <5116@telia.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <linux/ioport.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <asm/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <asm/byteorder.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <asm/eisa_bus.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <asm/eisa_eeprom.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 
^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)  * Todo:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22)  * 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23)  * PORT init with MASK attr and other size than byte
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24)  * MEMORY with other decode than 20 bit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25)  * CRC stuff
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26)  * FREEFORM stuff
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #define EPI 0xc80
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #define NUM_SLOT 16
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #define SLOT2PORT(x) (x<<12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) /* macros to handle unaligned accesses and 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35)  * byte swapping. The data in the EEPROM is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36)  * little-endian on the big-endian PAROSC */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) #define get_8(x) (*(u_int8_t*)(x))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) static inline u_int16_t get_16(const unsigned char *x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) { 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	return (x[1] << 8) | x[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) static inline u_int32_t get_32(const unsigned char *x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	return (x[3] << 24) | (x[2] << 16) | (x[1] << 8) | x[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) static inline u_int32_t get_24(const unsigned char *x)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	return (x[2] << 24) | (x[1] << 16) | (x[0] << 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) static void print_eisa_id(char *s, u_int32_t id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	char vendor[4];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	int rev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	int device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	rev = id & 0xff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	id >>= 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	device = id & 0xff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	id >>= 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	vendor[3] = '\0';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	vendor[2] = '@' + (id & 0x1f);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	id >>= 5;	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	vendor[1] = '@' + (id & 0x1f);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	id >>= 5;	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	vendor[0] = '@' + (id & 0x1f);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	id >>= 5;	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	sprintf(s, "%s%02X%02X", vendor, device, rev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74)        
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) static int configure_memory(const unsigned char *buf, 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 		       struct resource *mem_parent,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 		       char *name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	u_int8_t c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	struct resource *res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	len=0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	for (i=0;i<HPEE_MEMORY_MAX_ENT;i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 		c = get_8(buf+len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 		
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 		if (NULL != (res = kzalloc(sizeof(struct resource), GFP_KERNEL))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 			int result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 			
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 			res->name = name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 			res->start = mem_parent->start + get_24(buf+len+2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 			res->end = res->start + get_16(buf+len+5)*1024;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 			res->flags = IORESOURCE_MEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 			pr_cont("memory %pR ", res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 			result = request_resource(mem_parent, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 			if (result < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 				printk(KERN_ERR "EISA Enumerator: failed to claim EISA Bus address space!\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 				return result;
^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) 		 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 		len+=7;      
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 		if (!(c & HPEE_MEMORY_MORE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 		}
^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) 	return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) static int configure_irq(const unsigned char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	u_int8_t c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	len=0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	for (i=0;i<HPEE_IRQ_MAX_ENT;i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 		c = get_8(buf+len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 		
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 		pr_cont("IRQ %d ", c & HPEE_IRQ_CHANNEL_MASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		if (c & HPEE_IRQ_TRIG_LEVEL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 			eisa_make_irq_level(c & HPEE_IRQ_CHANNEL_MASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 			eisa_make_irq_edge(c & HPEE_IRQ_CHANNEL_MASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 		
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 		len+=2; 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 		/* hpux seems to allow for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 		 * two bytes of irq data but only defines one of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 		 * them, I think */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 		if  (!(c & HPEE_IRQ_MORE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	return len;
^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) static int configure_dma(const unsigned char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 	u_int8_t c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	len=0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	for (i=0;i<HPEE_DMA_MAX_ENT;i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 		c = get_8(buf+len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 		pr_cont("DMA %d ", c&HPEE_DMA_CHANNEL_MASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 		/* fixme: maybe initialize the dma channel withthe timing ? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 		len+=2;      
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 		if (!(c & HPEE_DMA_MORE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) static int configure_port(const unsigned char *buf, struct resource *io_parent,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 		     char *board)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	u_int8_t c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	struct resource *res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 	int result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	len=0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	for (i=0;i<HPEE_PORT_MAX_ENT;i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 		c = get_8(buf+len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 		
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 		if (NULL != (res = kzalloc(sizeof(struct resource), GFP_KERNEL))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 			res->name = board;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 			res->start = get_16(buf+len+1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 			res->end = get_16(buf+len+1)+(c&HPEE_PORT_SIZE_MASK)+1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 			res->flags = IORESOURCE_IO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 			pr_cont("ioports %pR ", res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 			result = request_resource(io_parent, res);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 			if (result < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 				printk(KERN_ERR "EISA Enumerator: failed to claim EISA Bus address space!\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 				return result;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 		len+=3;      
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 		if (!(c & HPEE_PORT_MORE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) /* byte 1 and 2 is the port number to write
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205)  * and at byte 3 the value to write starts.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206)  * I assume that there are and- and or- masks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)  * here when HPEE_PORT_INIT_MASK is set but I have 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)  * not yet encountered this. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) static int configure_port_init(const unsigned char *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	int len=0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	u_int8_t c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	while (len<HPEE_PORT_INIT_MAX_LEN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 		int s=0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 		c = get_8(buf+len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 		
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 		switch (c & HPEE_PORT_INIT_WIDTH_MASK)  {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 		 case HPEE_PORT_INIT_WIDTH_BYTE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 			s=1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 			if (c & HPEE_PORT_INIT_MASK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 				printk(KERN_WARNING "port_init: unverified mask attribute\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 				outb((inb(get_16(buf+len+1) & 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 					  get_8(buf+len+3)) | 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 				      get_8(buf+len+4)), get_16(buf+len+1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 				      
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 			} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 				outb(get_8(buf+len+3), get_16(buf+len+1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 				      
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 		 case HPEE_PORT_INIT_WIDTH_WORD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 			s=2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 			if (c & HPEE_PORT_INIT_MASK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)  				printk(KERN_WARNING "port_init: unverified mask attribute\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 				       outw((inw(get_16(buf+len+1)) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 					     get_16(buf+len+3)) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 					    get_16(buf+len+5), 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 					    get_16(buf+len+1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 			} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 				outw(cpu_to_le16(get_16(buf+len+3)), get_16(buf+len+1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 		 case HPEE_PORT_INIT_WIDTH_DWORD:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 			s=4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 			if (c & HPEE_PORT_INIT_MASK) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247)  				printk(KERN_WARNING "port_init: unverified mask attribute\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 				outl((inl(get_16(buf+len+1) &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 					  get_32(buf+len+3)) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 				      get_32(buf+len+7)), get_16(buf+len+1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 			} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 				outl(cpu_to_le32(get_32(buf+len+3)), get_16(buf+len+1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 		 default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 			printk(KERN_ERR "Invalid port init word %02x\n", c);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 			return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 		
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 		if (c & HPEE_PORT_INIT_MASK) {   
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 			s*=2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 		
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 		len+=s+3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 		if (!(c & HPEE_PORT_INIT_MORE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 	return len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) static int configure_choise(const unsigned char *buf, u_int8_t *info)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 	/* theis record contain the value of the functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	 * configuration choises and an info byte which 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	 * describes which other records to expect in this 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	 * function */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	len = get_8(buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	*info=get_8(buf+len+1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	return len+2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) static int configure_type_string(const unsigned char *buf) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	/* just skip past the type field */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 	len = get_8(buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	if (len > 80) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 		printk(KERN_ERR "eisa_enumerator: type info field too long (%d, max is 80)\n", len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	return 1+len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) static int configure_function(const unsigned char *buf, int *more) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 	/* the init field seems to be a two-byte field
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	 * which is non-zero if there are an other function following
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 	 * I think it is the length of the function def 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	*more = get_16(buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	return 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) static int parse_slot_config(int slot,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 			     const unsigned char *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 			     struct eeprom_eisa_slot_info *es, 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 			     struct resource *io_parent,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 			     struct resource *mem_parent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 	int res=0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	int function_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 	unsigned int pos=0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 	unsigned int maxlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 	int num_func=0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 	u_int8_t flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	int p0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 	char *board;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 	int id_string_used=0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 	if (NULL == (board = kmalloc(8, GFP_KERNEL))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 		return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 	print_eisa_id(board, es->eisa_slot_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 	printk(KERN_INFO "EISA slot %d: %s %s ", 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 	       slot, board, es->flags&HPEE_FLAG_BOARD_IS_ISA ? "ISA" : "EISA");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 	maxlen = es->config_data_length < HPEE_MAX_LENGTH ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 			 es->config_data_length : HPEE_MAX_LENGTH;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 	while ((pos < maxlen) && (num_func <= es->num_functions)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 		pos+=configure_function(buf+pos, &function_len); 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 		
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 		if (!function_len) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 		num_func++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 		p0 = pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 		pos += configure_choise(buf+pos, &flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 		if (flags & HPEE_FUNCTION_INFO_F_DISABLED) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 			/* function disabled, skip silently */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 			pos = p0 + function_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 		if (flags & HPEE_FUNCTION_INFO_CFG_FREE_FORM) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 			/* I have no idea how to handle this */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 			printk("function %d have free-form configuration, skipping ",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 				num_func);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 			pos = p0 + function_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 		/* the ordering of the sections need
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 		 * more investigation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 		 * Currently I think that memory comaed before IRQ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 		 * I assume the order is LSB to MSB in the 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 		 * info flags 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 		 * eg type, memory, irq, dma, port, HPEE_PORT_init 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 		if (flags & HPEE_FUNCTION_INFO_HAVE_TYPE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 			pos += configure_type_string(buf+pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 		
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 		if (flags & HPEE_FUNCTION_INFO_HAVE_MEMORY) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 			id_string_used=1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 			pos += configure_memory(buf+pos, mem_parent, board);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 		} 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 		
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 		if (flags & HPEE_FUNCTION_INFO_HAVE_IRQ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 			pos += configure_irq(buf+pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 		} 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 		
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 		if (flags & HPEE_FUNCTION_INFO_HAVE_DMA) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 			pos += configure_dma(buf+pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 		} 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 		
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 		if (flags & HPEE_FUNCTION_INFO_HAVE_PORT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 			id_string_used=1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 			pos += configure_port(buf+pos, io_parent, board);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 		} 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 		
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 		if (flags &  HPEE_FUNCTION_INFO_HAVE_PORT_INIT) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 			pos += configure_port_init(buf+pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 		
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 		if (p0 + function_len < pos) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 			printk(KERN_ERR "eisa_enumerator: function %d length mis-match "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 			       "got %d, expected %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 			       num_func, pos-p0, function_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 			res=-1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 		pos = p0 + function_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 	pr_cont("\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 	if (!id_string_used) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 		kfree(board);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 	if (pos != es->config_data_length) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 		printk(KERN_ERR "eisa_enumerator: config data length mis-match got %d, expected %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 			pos, es->config_data_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 		res=-1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 	if (num_func != es->num_functions) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 		printk(KERN_ERR "eisa_enumerator: number of functions mis-match got %d, expected %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 			num_func, es->num_functions);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 		res=-2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 	return res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) static int init_slot(int slot, struct eeprom_eisa_slot_info *es)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 	unsigned int id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 	char id_string[8];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 	if (!(es->slot_info&HPEE_SLOT_INFO_NO_READID)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 		/* try to read the id of the board in the slot */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 		id = le32_to_cpu(inl(SLOT2PORT(slot)+EPI));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 		
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 		if (0xffffffff == id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 			/* Maybe we didn't expect a card to be here... */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 			if (es->eisa_slot_id == 0xffffffff)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 				return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 			
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 			/* this board is not here or it does not 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 			 * support readid 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 			printk(KERN_ERR "EISA slot %d a configured board was not detected (", 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 			       slot);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 			
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 			print_eisa_id(id_string, es->eisa_slot_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 			printk(" expected %s)\n", id_string);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 		
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 			return -1;	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 		if (es->eisa_slot_id != id) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 			print_eisa_id(id_string, id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 			printk(KERN_ERR "EISA slot %d id mis-match: got %s", 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 			       slot, id_string);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 			
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 			print_eisa_id(id_string, es->eisa_slot_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 			printk(" expected %s\n", id_string);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 		
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 			return -1;	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 			
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 	/* now: we need to enable the board if 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 	 * it supports enabling and run through
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 	 * the port init sction if present
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 	 * and finally record any interrupt polarity
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 	if (es->slot_features & HPEE_SLOT_FEATURES_ENABLE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 		/* enable board */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 		outb(0x01| inb(SLOT2PORT(slot)+EPI+4),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 		     SLOT2PORT(slot)+EPI+4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) int eisa_enumerator(unsigned long eeprom_addr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) 		    struct resource *io_parent, struct resource *mem_parent) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 	struct eeprom_header *eh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 	static char eeprom_buf[HPEE_MAX_LENGTH];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 	for (i=0; i < HPEE_MAX_LENGTH; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) 		eeprom_buf[i] = gsc_readb(eeprom_addr+i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 	printk(KERN_INFO "Enumerating EISA bus\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 		    	
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 	eh = (struct eeprom_header*)(eeprom_buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 	for (i=0;i<eh->num_slots;i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 		struct eeprom_eisa_slot_info *es;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 		
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) 		es = (struct eeprom_eisa_slot_info*)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 			(&eeprom_buf[HPEE_SLOT_INFO(i)]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) 	        
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 		if (-1==init_slot(i+1, es)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 		
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 		if (es->config_data_offset < HPEE_MAX_LENGTH) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) 			if (parse_slot_config(i+1, &eeprom_buf[es->config_data_offset],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) 					      es, io_parent, mem_parent)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) 				return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 			printk (KERN_WARNING "EISA EEPROM offset 0x%x out of range\n",es->config_data_offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 			return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 	return eh->num_slots;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516)