/*
* Copyright (c) 2000-2003 Michael Shalayeff
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* These cards has to be known to work so far:
* - HPA1991AGrayscale rev 0.02 (705/35) (byte-wide)
* - HPA1991AC19 rev 0.02 (715/33) (byte-wide)
* - HPA208LC1280 rev 8.04 (712/80) just works
*/
/*
* Locate STI ROM.
* On some machines it may not be part of the HPA space.
*/
paddr_t
sti_sgc_getrom(struct confargs *ca)
{
paddr_t rom;
int pagezero_cookie;
pagezero_cookie = hppa_pagezero_map();
rom = PAGE0->pd_resv2[1];
hppa_pagezero_unmap(pagezero_cookie);
if (ca->ca_type.iodc_sv_model == HPPA_FIO_GSGC &&
ca->ca_hpa != STI_ONBOARD_HPA0 &&
ca->ca_hpa != STI_ONBOARD_HPA1) {
int i;
for (i = sizeof(sti_sgc_opt); i--; )
if (sti_sgc_opt[i] == ca->ca_type.iodc_revision)
break;
if (i < 0)
rom = 0;
}
if (rom < HPPA_IOBEGIN) {
if (ca->ca_naddrs > 0)
rom = ca->ca_addrs[0].addr;
else
rom = ca->ca_hpa;
}
/* due to the graphic nature of this program do probe only one */
if (cf->cf_unit > sti_cd.cd_ndevs)
return 0;
if (ca->ca_type.iodc_type != HPPA_TYPE_FIO)
return 0;
/* these need further checking for the graphics id */
if (ca->ca_type.iodc_sv_model != HPPA_FIO_GSGC &&
ca->ca_type.iodc_sv_model != HPPA_FIO_SGC)
return 0;
rom = sti_sgc_getrom(ca);
DPRINTF(("%s: hpa=%x, rom=%x\n", __func__, (uint)ca->ca_hpa,
(uint)rom));
/* if it does not map, probably part of the lasi space */
if ((rv = bus_space_map(ca->ca_iot, rom, STI_ROMSIZE, 0, &romh))) {
DPRINTF(("%s: can't map rom space (%d)\n", __func__, rv));
if ((rom & HPPA_IOBEGIN) == HPPA_IOBEGIN) {
romh = rom;
romunmapped++;
} else {
/* in this case nobody has no freaking idea */
return 0;
}
}
/* we stashed rom addr/len into the last slot during probe */
rom = ca->ca_addrs[ca->ca_naddrs - 1].addr;
romlen = ca->ca_addrs[ca->ca_naddrs - 1].size;
if ((rv = bus_space_map(ca->ca_iot, rom, romlen, 0, &romh))) {
if ((rom & HPPA_IOBEGIN) == HPPA_IOBEGIN)
romh = rom;
else {
aprint_error(": can't map rom space (%d)\n", rv);
return;
}
}
sc->bases[0] = romh;
for (i = 1; i < STI_REGION_MAX; i++)
sc->bases[i] = ca->ca_hpa;