si_isa.c (56505) | si_isa.c (100744) |
---|---|
1/* 2 * Device driver for Specialix range (SI/XIO) of serial line multiplexors. 3 * 4 * Copyright (C) 2000, Peter Wemm <peter@netplex.com.au> 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notices, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notices, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY EXPRESS OR IMPLIED 16 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 17 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN 18 * NO EVENT SHALL THE AUTHORS BE LIABLE. 19 * | 1/* 2 * Device driver for Specialix range (SI/XIO) of serial line multiplexors. 3 * 4 * Copyright (C) 2000, Peter Wemm <peter@netplex.com.au> 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notices, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notices, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY EXPRESS OR IMPLIED 16 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 17 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN 18 * NO EVENT SHALL THE AUTHORS BE LIABLE. 19 * |
20 * $FreeBSD: head/sys/dev/si/si_isa.c 56505 2000-01-24 07:24:02Z peter $ | 20 * $FreeBSD: head/sys/dev/si/si_isa.c 100744 2002-07-27 08:46:28Z peter $ |
21 */ 22 23#include "opt_debug_si.h" 24 25#include <sys/param.h> 26#include <sys/systm.h> 27#include <sys/kernel.h> 28#include <sys/bus.h> --- 13 unchanged lines hidden (view full) --- 42 struct si_softc *sc; 43 int type; 44 u_int i, ramsize; 45 volatile unsigned char was, *ux; 46 volatile unsigned char *maddr; 47 unsigned char *paddr; 48 int unit; 49 | 21 */ 22 23#include "opt_debug_si.h" 24 25#include <sys/param.h> 26#include <sys/systm.h> 27#include <sys/kernel.h> 28#include <sys/bus.h> --- 13 unchanged lines hidden (view full) --- 42 struct si_softc *sc; 43 int type; 44 u_int i, ramsize; 45 volatile unsigned char was, *ux; 46 volatile unsigned char *maddr; 47 unsigned char *paddr; 48 int unit; 49 |
50 /* No pnp support */ 51 if (isa_get_vendorid(dev)) 52 return (ENXIO); 53 |
|
50 sc = device_get_softc(dev); 51 unit = device_get_unit(dev); 52 53 sc->sc_mem_rid = 0; 54 sc->sc_mem_res = bus_alloc_resource(dev, SYS_RES_MEMORY, 55 &sc->sc_mem_rid, 56 0, ~0, SIPROBEALLOC, RF_ACTIVE); | 54 sc = device_get_softc(dev); 55 unit = device_get_unit(dev); 56 57 sc->sc_mem_rid = 0; 58 sc->sc_mem_res = bus_alloc_resource(dev, SYS_RES_MEMORY, 59 &sc->sc_mem_rid, 60 0, ~0, SIPROBEALLOC, RF_ACTIVE); |
57 if (!sc->sc_mem_res) | 61 if (!sc->sc_mem_res) { 62 device_printf(dev, "cannot allocate memory resource\n"); |
58 return ENXIO; | 63 return ENXIO; |
64 } |
|
59 paddr = (caddr_t)rman_get_start(sc->sc_mem_res);/* physical */ 60 maddr = rman_get_virtual(sc->sc_mem_res); /* in kvm */ 61 62 DPRINT((0, DBG_AUTOBOOT, "si%d: probe at virtual=0x%x physical=0x%x\n", 63 unit, maddr, paddr)); 64 65 /* 66 * this is a lie, but it's easier than trying to handle caching 67 * and ram conflicts in the >1M and <16M region. 68 */ 69 if ((caddr_t)paddr < (caddr_t)0xA0000 || 70 (caddr_t)paddr >= (caddr_t)0x100000) { | 65 paddr = (caddr_t)rman_get_start(sc->sc_mem_res);/* physical */ 66 maddr = rman_get_virtual(sc->sc_mem_res); /* in kvm */ 67 68 DPRINT((0, DBG_AUTOBOOT, "si%d: probe at virtual=0x%x physical=0x%x\n", 69 unit, maddr, paddr)); 70 71 /* 72 * this is a lie, but it's easier than trying to handle caching 73 * and ram conflicts in the >1M and <16M region. 74 */ 75 if ((caddr_t)paddr < (caddr_t)0xA0000 || 76 (caddr_t)paddr >= (caddr_t)0x100000) { |
71 printf("si%d: iomem (%p) out of range\n", 72 unit, (void *)paddr); | 77 device_printf(dev, "maddr (%p) out of range\n", paddr); |
73 goto fail; 74 } 75 76 if (((u_int)paddr & 0x7fff) != 0) { | 78 goto fail; 79 } 80 81 if (((u_int)paddr & 0x7fff) != 0) { |
77 DPRINT((0, DBG_AUTOBOOT|DBG_FAIL, 78 "si%d: iomem (%x) not on 32k boundary\n", unit, paddr)); | 82 device_printf(dev, "maddr (%p) not on 32k boundary\n", paddr); |
79 goto fail; 80 } 81 82 /* Is there anything out there? (0x17 is just an arbitrary number) */ 83 *maddr = 0x17; 84 if (*maddr != 0x17) { | 83 goto fail; 84 } 85 86 /* Is there anything out there? (0x17 is just an arbitrary number) */ 87 *maddr = 0x17; 88 if (*maddr != 0x17) { |
85 DPRINT((0, DBG_AUTOBOOT|DBG_FAIL, 86 "si%d: 0x17 check fail at phys 0x%x\n", unit, paddr)); | 89 device_printf(dev, "0x17 check fail at phys %p\n", paddr); |
87 goto fail; 88 } 89 /* 90 * Let's look first for a JET ISA card, since that's pretty easy 91 * 92 * All jet hosts are supposed to have this string in the IDROM, 93 * but it's not worth checking on self-IDing busses like PCI. 94 */ --- 46 unchanged lines hidden (view full) --- 141 */ 142 *(maddr+SIRESET) = 0x0; /* reset the card */ 143 *(maddr+SIINTCL) = 0x0; /* clear int */ 144 *(maddr+SIRAM) = 0x17; 145 if (*(maddr+SIRAM) != (unsigned char)0x17) 146 goto fail; 147 *(maddr+0x7ff8) = 0x17; 148 if (*(maddr+0x7ff8) != (unsigned char)0x17) { | 90 goto fail; 91 } 92 /* 93 * Let's look first for a JET ISA card, since that's pretty easy 94 * 95 * All jet hosts are supposed to have this string in the IDROM, 96 * but it's not worth checking on self-IDing busses like PCI. 97 */ --- 46 unchanged lines hidden (view full) --- 144 */ 145 *(maddr+SIRESET) = 0x0; /* reset the card */ 146 *(maddr+SIINTCL) = 0x0; /* clear int */ 147 *(maddr+SIRAM) = 0x17; 148 if (*(maddr+SIRAM) != (unsigned char)0x17) 149 goto fail; 150 *(maddr+0x7ff8) = 0x17; 151 if (*(maddr+0x7ff8) != (unsigned char)0x17) { |
149 DPRINT((0, DBG_AUTOBOOT|DBG_FAIL, 150 "si%d: 0x17 check fail at phys 0x%x = 0x%x\n", 151 unit, paddr+0x77f8, *(maddr+0x77f8))); | 152 device_printf(dev, "0x17 check fail at phys %p = 0x%x\n", 153 paddr+0x77f8, *(maddr+0x77f8)); |
152 goto fail; 153 } 154 155 /* It must be an SIHOST (maybe?) - there must be a better way XXX */ 156 type = SIHOST; 157 ramsize = SIHOST_RAMSIZE; 158 159got_card: 160 DPRINT((0, DBG_AUTOBOOT, "si%d: found type %d card, try memory test\n", 161 unit, type)); 162 /* Try the acid test */ 163 ux = maddr + SIRAM; 164 for (i = 0; i < ramsize; i++, ux++) 165 *ux = (unsigned char)(i&0xff); 166 ux = maddr + SIRAM; 167 for (i = 0; i < ramsize; i++, ux++) { 168 if ((was = *ux) != (unsigned char)(i&0xff)) { | 154 goto fail; 155 } 156 157 /* It must be an SIHOST (maybe?) - there must be a better way XXX */ 158 type = SIHOST; 159 ramsize = SIHOST_RAMSIZE; 160 161got_card: 162 DPRINT((0, DBG_AUTOBOOT, "si%d: found type %d card, try memory test\n", 163 unit, type)); 164 /* Try the acid test */ 165 ux = maddr + SIRAM; 166 for (i = 0; i < ramsize; i++, ux++) 167 *ux = (unsigned char)(i&0xff); 168 ux = maddr + SIRAM; 169 for (i = 0; i < ramsize; i++, ux++) { 170 if ((was = *ux) != (unsigned char)(i&0xff)) { |
169 DPRINT((0, DBG_AUTOBOOT|DBG_FAIL, 170 "si%d: match fail at phys 0x%x, was %x should be %x\n", 171 unit, paddr + i, was, i&0xff)); | 171 device_printf(dev, 172 "memtest fail at phys %p, was %x should be %x\n", 173 paddr + i, was, i & 0xff); |
172 goto fail; 173 } 174 } 175 176 /* clear out the RAM */ 177 ux = maddr + SIRAM; 178 for (i = 0; i < ramsize; i++) 179 *ux++ = 0; 180 ux = maddr + SIRAM; 181 for (i = 0; i < ramsize; i++) { 182 if ((was = *ux++) != 0) { | 174 goto fail; 175 } 176 } 177 178 /* clear out the RAM */ 179 ux = maddr + SIRAM; 180 for (i = 0; i < ramsize; i++) 181 *ux++ = 0; 182 ux = maddr + SIRAM; 183 for (i = 0; i < ramsize; i++) { 184 if ((was = *ux++) != 0) { |
183 DPRINT((0, DBG_AUTOBOOT|DBG_FAIL, 184 "si%d: clear fail at phys 0x%x, was %x\n", 185 unit, paddr + i, was)); | 185 device_printf(dev, "clear fail at phys %p, was %x\n", 186 paddr + i, was); |
186 goto fail; 187 } 188 } 189 190 /* 191 * Success, we've found a valid board, now fill in 192 * the adapter structure. 193 */ 194 switch (type) { 195 case SIHOST2: 196 switch (isa_get_irq(dev)) { 197 case 11: 198 case 12: 199 case 15: 200 break; 201 default: | 187 goto fail; 188 } 189 } 190 191 /* 192 * Success, we've found a valid board, now fill in 193 * the adapter structure. 194 */ 195 switch (type) { 196 case SIHOST2: 197 switch (isa_get_irq(dev)) { 198 case 11: 199 case 12: 200 case 15: 201 break; 202 default: |
202bad_irq: 203 DPRINT((0, DBG_AUTOBOOT|DBG_FAIL, 204 "si%d: bad IRQ value - %d\n", 205 unit, isa_get_irq(dev))); | 203 device_printf(dev, 204 "bad IRQ value - %d (11, 12, 15 allowed)\n", 205 isa_get_irq(dev)); |
206 goto fail; 207 } 208 sc->sc_memsize = SIHOST2_MEMSIZE; 209 break; 210 case SIHOST: 211 switch (isa_get_irq(dev)) { 212 case 11: 213 case 12: 214 case 15: 215 break; 216 default: | 206 goto fail; 207 } 208 sc->sc_memsize = SIHOST2_MEMSIZE; 209 break; 210 case SIHOST: 211 switch (isa_get_irq(dev)) { 212 case 11: 213 case 12: 214 case 15: 215 break; 216 default: |
217 goto bad_irq; | 217 device_printf(dev, 218 "bad IRQ value - %d (11, 12, 15 allowed)\n", 219 isa_get_irq(dev)); 220 goto fail; |
218 } 219 sc->sc_memsize = SIHOST_MEMSIZE; 220 break; 221 case SIJETISA: 222 switch (isa_get_irq(dev)) { 223 case 9: 224 case 10: 225 case 11: 226 case 12: 227 case 15: 228 break; 229 default: | 221 } 222 sc->sc_memsize = SIHOST_MEMSIZE; 223 break; 224 case SIJETISA: 225 switch (isa_get_irq(dev)) { 226 case 9: 227 case 10: 228 case 11: 229 case 12: 230 case 15: 231 break; 232 default: |
230 goto bad_irq; | 233 device_printf(dev, 234 "bad IRQ value - %d (9, 10, 11, 12, 15 allowed)\n", 235 isa_get_irq(dev)); 236 goto fail; |
231 } 232 sc->sc_memsize = SIJETISA_MEMSIZE; 233 break; 234 case SIMCA: /* MCA */ 235 default: | 237 } 238 sc->sc_memsize = SIJETISA_MEMSIZE; 239 break; 240 case SIMCA: /* MCA */ 241 default: |
236 printf("si%d: card type %d not supported\n", unit, type); | 242 device_printf(dev, "card type %d not supported\n", type); |
237 goto fail; 238 } 239 sc->sc_type = type; 240 bus_release_resource(dev, SYS_RES_MEMORY, 241 sc->sc_mem_rid, sc->sc_mem_res); 242 sc->sc_mem_res = 0; 243 return (0); /* success! */ 244 --- 84 unchanged lines hidden --- | 243 goto fail; 244 } 245 sc->sc_type = type; 246 bus_release_resource(dev, SYS_RES_MEMORY, 247 sc->sc_mem_rid, sc->sc_mem_res); 248 sc->sc_mem_res = 0; 249 return (0); /* success! */ 250 --- 84 unchanged lines hidden --- |