=================================================================== RCS file: /cvs/sys/arch/arm/sa11x0/sa1111.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- sys/arch/arm/sa11x0/sa1111.c 2008/03/04 16:05:18 1.1 +++ sys/arch/arm/sa11x0/sa1111.c 2008/03/05 11:11:22 1.2 @@ -1,4 +1,4 @@ -/* $Id: sa1111.c,v 1.1 2008/03/04 16:05:18 nbrk Exp $ */ +/* $Id: sa1111.c,v 1.2 2008/03/05 11:11:22 nbrk Exp $ */ /* * Copyright (c) 2002 Genetec Corporation. All rights reserved. * Written by Hiroyuki Bessho for Genetec Corporation. @@ -100,23 +100,18 @@ #include #include -//#include - #include #include #include -struct sacc_softc { - struct device sc_dev; - bus_space_tag_t sc_bust; - bus_dma_tag_t sc_dmat; -}; +//#include /* 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 *); +void sacc_attach_critical(struct sacc_softc *sc); /* attach structures */ struct cfattach sacc_ca = { @@ -141,17 +136,19 @@ { 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; + sc->sc_intr = saa->sai_intr; /* 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)) { + /* + * Map whole I/O space. + */ + if (bus_space_map(sc->sc_bust, 0, 128 * 12, 0, &sc->sc_ioh)) { printf(": can't map i/o space\n"); return; } @@ -159,17 +156,22 @@ /* * Identify chip. */ - skid = bus_space_read_4(sc->sc_bust, sbih, SACCSBI_SKID); - bus_space_unmap(sc->sc_bust, sbih, 3 /* SACCSBI_SIZE */); + skid = bus_space_read_4(sc->sc_bust, sc->sc_ioh, SACCSBI_SKID); if ((skid & 0xffffff00) != 0x690cc200) { printf(": incorrect SA-1111 chip ID\n"); + bus_space_unmap(sc->sc_bust, sc->sc_ioh, 128 * 12); return; } printf(": SA-1111 companion chip rev. %d/%d\n", skid & 0xf0, skid & 0x0f); /* - * Attach all other devices + * Attach critical devices. */ + sacc_attach_critical(sc); + + /* + * Attach all other devices. + */ config_search(sacc_search, self, sc); } @@ -183,9 +185,7 @@ 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]; + aa.sac_xintr = (cf->cf_loc)[0]; config_found(parent, &aa, sacc_print); @@ -197,14 +197,34 @@ { 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); + if (sa->sac_xintr != -1) + printf(" xintr %d", sa->sac_xintr); - return (UNCONF); + return (UNCONF); +} + +void +sacc_attach_critical(struct sacc_softc *sc) +{ + /* + * Attach Interrupt and GPIO controllers because + * their functionality is needed for the rest of our onboard devices. + */ + struct sacc_attach_args saa; + + saa.sac_iot = sc->sc_bust; + saa.sac_dmat = sc->sc_dmat; + + /* XXX sac_xintr is an internal to us interrupt number, but here we use it + to inform our INTC about which intr line it uses on main INTC. */ + saa.sac_xintr = sc->sc_intr; + saa.sac_typecookie = SACC_TYPE_INTC; + config_found(&sc->sc_dev, &saa, sacc_print); + +#if 0 + saa.sac_xintr = -1; /* is not widely used, spec defines most of them */ + saa.sac_typecookie = SACC_TYPE_GPIO; + config_found(&sc->sc_dev, &saa, sacc_print); +#endif }