version 1.1, 2008/03/04 16:05:18 |
version 1.4, 2008/05/11 10:26:11 |
|
|
#include <machine/cpu.h> |
#include <machine/cpu.h> |
#include <machine/bus.h> |
#include <machine/bus.h> |
|
|
//#include <arm/mainbus/mainbus.h> |
|
|
|
#include <arm/sa11x0/sa1111_reg.h> |
#include <arm/sa11x0/sa1111_reg.h> |
#include <arm/sa11x0/sa11x0_var.h> |
#include <arm/sa11x0/sa11x0_var.h> |
#include <arm/sa11x0/sa11x1_var.h> |
#include <arm/sa11x0/sa11x1_var.h> |
|
|
struct sacc_softc { |
//#include <arm/sa11x0/sa1111_gpiovar.h> |
struct device sc_dev; |
|
bus_space_tag_t sc_bust; |
|
bus_dma_tag_t sc_dmat; |
|
}; |
|
|
|
/* prototypes */ |
/* prototypes */ |
int sacc_match(struct device *, void *, void *); |
int sacc_match(struct device *, void *, void *); |
void sacc_attach(struct device *, struct device *, void *); |
void sacc_attach(struct device *, struct device *, void *); |
int sacc_search(struct device *, void *, void *); |
int sacc_search(struct device *, void *, void *); |
int sacc_print(void *, const char *); |
int sacc_print(void *, const char *); |
|
void sacc_attach_critical(struct sacc_softc *sc); |
|
|
/* attach structures */ |
/* attach structures */ |
struct cfattach sacc_ca = { |
struct cfattach sacc_ca = { |
|
|
{ |
{ |
struct sacc_softc *sc = (struct sacc_softc *)self; |
struct sacc_softc *sc = (struct sacc_softc *)self; |
struct saip_attach_args *saa = aux; |
struct saip_attach_args *saa = aux; |
bus_space_handle_t sbih; |
|
uint32_t skid; |
uint32_t skid; |
|
|
sacc_sc = sc; |
sacc_sc = sc; |
sc->sc_bust = &sa11x1_bs_tag; |
sc->sc_bust = &sa11x1_bs_tag; |
|
sc->sc_intr = saa->sai_intr; |
|
|
/* XXX preserve our base addr for sa11x1_bs_map() */ |
/* XXX preserve our base addr for sa11x1_bs_map() */ |
sa11x1_bs_tag.bs_cookie = &saa->sai_addr; |
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)) { |
|
if (bus_space_map(sc->sc_bust, 0, saa->sai_size, 0, &sc->sc_ioh)) { |
printf(": can't map i/o space\n"); |
printf(": can't map i/o space\n"); |
return; |
return; |
} |
} |
|
|
/* |
/* |
* Identify chip. |
* Identify chip. |
*/ |
*/ |
skid = bus_space_read_4(sc->sc_bust, sbih, SACCSBI_SKID); |
skid = bus_space_read_4(sc->sc_bust, sc->sc_ioh, SACCSBI_SKID); |
bus_space_unmap(sc->sc_bust, sbih, 3 /* SACCSBI_SIZE */); |
|
if ((skid & 0xffffff00) != 0x690cc200) { |
if ((skid & 0xffffff00) != 0x690cc200) { |
printf(": incorrect SA-1111 chip ID\n"); |
printf(": incorrect SA-1111 chip ID\n"); |
|
bus_space_unmap(sc->sc_bust, sc->sc_ioh, 128 * 12); |
return; |
return; |
} |
} |
printf(": SA-1111 companion chip rev. %d/%d\n", skid & 0xf0, skid & 0x0f); |
printf(": SA-1111 companion chip rev. %d/%d\n", skid & 0xf0, skid & 0x0f); |
|
|
/* |
/* |
* Attach all other devices |
* Attach critical devices (GPIO and Interrupt controllers). |
*/ |
*/ |
|
sacc_attach_critical(sc); |
|
|
|
/* |
|
* Attach all other devices. |
|
*/ |
config_search(sacc_search, self, sc); |
config_search(sacc_search, self, sc); |
} |
} |
|
|
|
|
|
|
aa.sac_iot = sc->sc_bust; |
aa.sac_iot = sc->sc_bust; |
aa.sac_dmat = sc->sc_dmat; |
aa.sac_dmat = sc->sc_dmat; |
|
aa.sac_bush = sc->sc_ioh; |
|
|
aa.sac_addr = (cf->cf_loc)[0]; |
aa.sac_xintr = (cf->cf_loc)[0]; |
aa.sac_size = (cf->cf_loc)[1]; |
|
aa.sac_intr = (cf->cf_loc)[2]; |
|
|
|
config_found(parent, &aa, sacc_print); |
config_found(parent, &aa, sacc_print); |
|
|
|
|
{ |
{ |
struct sacc_attach_args *sa = (struct sacc_attach_args*)aux; |
struct sacc_attach_args *sa = (struct sacc_attach_args*)aux; |
|
|
if (sa->sac_addr != -1) { |
if (sa->sac_xintr != -1) |
printf(" addr 0x%lx", sa->sac_addr); |
printf(" xintr %d", sa->sac_xintr); |
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); |
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; |
|
saa.sac_bush = sc->sc_ioh; |
|
|
|
/* 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); |
|
|
|
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); |
} |
} |
|
|