/* $Id: sa1111.c,v 1.1 2008/03/04 16:05:18 nbrk Exp $ */
/*
* Copyright (c) 2002 Genetec Corporation. All rights reserved.
* Written by Hiroyuki Bessho for Genetec Corporation.
*
* 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.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed for the NetBSD Project by
* Genetec Corporation.
* 4. The name of Genetec Corporation may not be used to endorse or
* promote products derived from this software without specific prior
* written permission.
*
* THIS SOFTWARE IS PROVIDED BY GENETEC CORPORATION ``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 GENETEC CORPORATION
* 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 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.
*
*/
/*-
* Copyright (c) 2001, The NetBSD Foundation, Inc. All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by IWAMOTO Toshihiro and Ichiro FUKUHARA.
*
* 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.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*/
/*-
* Copyright (c) 1999
* Shin Takemura and PocketBSD Project. 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.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the PocketBSD project
* and its contributors.
* 4. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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 REGENTS OR CONTRIBUTORS 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 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.
*
*/
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/kernel.h>
#include <sys/reboot.h>
#include <machine/cpu.h>
#include <machine/bus.h>
//#include <arm/mainbus/mainbus.h>
#include <arm/sa11x0/sa1111_reg.h>
#include <arm/sa11x0/sa11x0_var.h>
#include <arm/sa11x0/sa11x1_var.h>
struct sacc_softc {
struct device sc_dev;
bus_space_tag_t sc_bust;
bus_dma_tag_t sc_dmat;
};
/* prototypes */
int sacc_match(struct device *, void *, void *);
void sacc_attach(struct device *, struct device *, void *);
int sacc_search(struct device *, void *, void *);
int sacc_print(void *, const char *);
/* attach structures */
struct cfattach sacc_ca = {
sizeof(struct sacc_softc), sacc_match, sacc_attach
};
struct cfdriver sacc_cd = {
NULL, "sacc", DV_DULL
};
struct sacc_softc *sacc_sc;
int
sacc_match(struct device *parent, void *match, void *aux)
{
return 1;
}
void
sacc_attach(struct device *parent, struct device *self, void *aux)
{
struct sacc_softc *sc = (struct sacc_softc *)self;
struct saip_attach_args *saa = aux;
bus_space_handle_t sbih;
uint32_t skid;
sacc_sc = sc;
sc->sc_bust = &sa11x1_bs_tag;
/* XXX preserve our base addr for sa11x1_bs_map() */
sa11x1_bs_tag.bs_cookie = &saa->sai_addr;
/* map SBI module */
if (bus_space_map(sc->sc_bust, 0 /* SACCSBI_BASE */, 3 /* SACCSBI_SIZE */, 0, &sbih)) {
printf(": can't map i/o space\n");
return;
}
/*
* Identify chip.
*/
skid = bus_space_read_4(sc->sc_bust, sbih, SACCSBI_SKID);
bus_space_unmap(sc->sc_bust, sbih, 3 /* SACCSBI_SIZE */);
if ((skid & 0xffffff00) != 0x690cc200) {
printf(": incorrect SA-1111 chip ID\n");
return;
}
printf(": SA-1111 companion chip rev. %d/%d\n", skid & 0xf0, skid & 0x0f);
/*
* Attach all other devices
*/
config_search(sacc_search, self, sc);
}
int
sacc_search(struct device *parent, void *c, void *aux)
{
struct sacc_softc *sc = aux;
struct sacc_attach_args aa;
struct cfdata *cf = c;
aa.sac_iot = sc->sc_bust;
aa.sac_dmat = sc->sc_dmat;
aa.sac_addr = (cf->cf_loc)[0];
aa.sac_size = (cf->cf_loc)[1];
aa.sac_intr = (cf->cf_loc)[2];
config_found(parent, &aa, sacc_print);
return 0;
}
int
sacc_print(void *aux, const char *name)
{
struct sacc_attach_args *sa = (struct sacc_attach_args*)aux;
if (sa->sac_addr != -1) {
printf(" addr 0x%lx", sa->sac_addr);
if (sa->sac_size > -1)
printf("-0x%lx", sa->sac_addr + sa->sac_size-1);
}
if (sa->sac_intr != -1)
printf(" xintr %d", sa->sac_intr);
return (UNCONF);
}