diff --git a/sys/arch/evbmips/atheros/autoconf.c b/sys/arch/evbmips/atheros/autoconf.c index 18754f9f2074..8d41be984412 100644 --- a/sys/arch/evbmips/atheros/autoconf.c +++ b/sys/arch/evbmips/atheros/autoconf.c @@ -1,4 +1,4 @@ -/* $NetBSD: autoconf.c,v 1.5 2006/08/28 07:21:15 gdamore Exp $ */ +/* $NetBSD: autoconf.c,v 1.6 2006/09/04 05:17:26 gdamore Exp $ */ /*- * Copyright (c) 2001 The NetBSD Foundation, Inc. @@ -37,19 +37,14 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.5 2006/08/28 07:21:15 gdamore Exp $"); +__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.6 2006/09/04 05:17:26 gdamore Exp $"); #include #include #include -#include /* these three just to get ETHER_ADDR_LEN(!) */ -#include -#include - #include -#include #include #include @@ -79,60 +74,5 @@ cpu_rootconf(void) void device_register(struct device *dev, void *aux) { - struct arbus_attach_args *aa = aux; - const struct ar531x_boarddata *info; - - info = ar531x_board_info(); - if (info == NULL) { - /* nothing known about this board! */ - return; - } - - /* - * We don't ever know the boot device. But that's because the - * firmware only loads from the network. - */ - - /* Fetch the MAC addresses from YAMON. */ - if (device_is_a(dev, "ae")) { - prop_data_t pd; - const uint8_t *enet; - - if (aa->aa_addr == AR5312_ENET0_BASE) - enet = info->enet0Mac; - else if (aa->aa_addr == AR5312_ENET1_BASE) - enet = info->enet1Mac; - else - return; - - pd = prop_data_create_data(enet, ETHER_ADDR_LEN); - KASSERT(pd != NULL); - if (prop_dictionary_set(device_properties(dev), - "mac-addr", pd) == FALSE) { - printf("WARNING: unable to set mac-addr " - "property for %s\n", device_xname(dev)); - } - prop_object_release(pd); - } - - if (device_is_a(dev, "ath")) { - prop_data_t pd; - const uint8_t *enet; - - if (aa->aa_addr == AR5312_WLAN0_BASE) - enet = info->wlan0Mac; - else if (aa->aa_addr == AR5312_WLAN1_BASE) - enet = info->wlan1Mac; - else - return; - - pd = prop_data_create_data(enet, ETHER_ADDR_LEN); - KASSERT(pd != NULL); - if (prop_dictionary_set(device_properties(dev), - "mac-addr", pd) == FALSE) { - printf("WARNING: unable to set mac-addr " - "property for %s\n", device_xname(dev)); - } - prop_object_release(pd); - } + ar531x_device_register(dev, aux); } diff --git a/sys/arch/evbmips/atheros/wdog.c b/sys/arch/evbmips/atheros/wdog.c index b356a4f048f8..3ffc8f08ebdd 100644 --- a/sys/arch/evbmips/atheros/wdog.c +++ b/sys/arch/evbmips/atheros/wdog.c @@ -1,4 +1,4 @@ -/* $NetBSD: wdog.c,v 1.3 2006/08/29 02:35:44 gdamore Exp $ */ +/* $NetBSD: wdog.c,v 1.4 2006/09/04 05:17:26 gdamore Exp $ */ /*- * Copyright (c) 2006 Urbana-Champaign Independent Media Center. * Copyright (c) 2006 Garrett D'Amore. @@ -79,7 +79,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: wdog.c,v 1.3 2006/08/29 02:35:44 gdamore Exp $"); +__KERNEL_RCSID(0, "$NetBSD: wdog.c,v 1.4 2006/09/04 05:17:26 gdamore Exp $"); #include #include @@ -125,7 +125,7 @@ wdog_attach(struct device *parent, struct device *self, void *aux) { struct wdog_softc *sc = (void *)self; - sc->sc_mult = ar531x_sys_freq(); + sc->sc_mult = ar531x_bus_freq(); sc->sc_wdog_period = WDOG_DEFAULT_PERIOD; sc->sc_wdog_max = 0xffffffffU / sc->sc_mult; sc->sc_wdog_reload = sc->sc_wdog_period * sc->sc_mult; diff --git a/sys/arch/evbmips/conf/AP30 b/sys/arch/evbmips/conf/AP30 index 56d0ef7d37e5..5215688ce7b9 100644 --- a/sys/arch/evbmips/conf/AP30 +++ b/sys/arch/evbmips/conf/AP30 @@ -1,10 +1,10 @@ -# $NetBSD: AP30,v 1.4 2006/08/26 20:26:44 christos Exp $ +# $NetBSD: AP30,v 1.5 2006/09/04 05:17:26 gdamore Exp $ include "arch/evbmips/conf/std.atheros" #options INCLUDE_CONFIG_FILE # embed config file in kernel binary -#ident "AP30-$Revision: 1.4 $" +#ident "AP30-$Revision: 1.5 $" maxusers 32 @@ -14,6 +14,7 @@ makeoptions ATH_MACHINE_HAL=ap30 options MIPS32 options NOFPU # No FPU options SOFTFLOAT # emulate FPU insn +options WISOC_AR5312 # WiSoC select # Options for necessary to use MD #options MEMORY_DISK_HOOKS diff --git a/sys/arch/evbmips/conf/std.atheros b/sys/arch/evbmips/conf/std.atheros index 6820fffba3c4..17f2f40f970d 100644 --- a/sys/arch/evbmips/conf/std.atheros +++ b/sys/arch/evbmips/conf/std.atheros @@ -1,4 +1,4 @@ -# $NetBSD: std.atheros,v 1.1 2006/03/21 08:15:19 gdamore Exp $ +# $NetBSD: std.atheros,v 1.2 2006/09/04 05:17:26 gdamore Exp $ machine evbmips mips include "conf/std" # MI standard options @@ -9,6 +9,7 @@ options EXEC_ELF32 # exec ELF32 binaries options EXEC_SCRIPT # exec #! scripts makeoptions DEFTEXTADDR="0x80020000" +#makeoptions DEFTEXTADDR="0x80041000" makeoptions BOARDTYPE="atheros" include "arch/evbmips/conf/files.atheros" diff --git a/sys/arch/mips/atheros/ar5312.c b/sys/arch/mips/atheros/ar5312.c index a05eb7dd63fa..2d4946834b91 100644 --- a/sys/arch/mips/atheros/ar5312.c +++ b/sys/arch/mips/atheros/ar5312.c @@ -1,4 +1,4 @@ -/* $NetBSD: ar5312.c,v 1.1 2006/08/28 07:21:15 gdamore Exp $ */ +/* $NetBSD: ar5312.c,v 1.2 2006/09/04 05:17:26 gdamore Exp $ */ /* * Copyright (c) 2006 Urbana-Champaign Independent Media Center. @@ -59,6 +59,10 @@ #include #include +#include /* these three just to get ETHER_ADDR_LEN(!) */ +#include +#include + #include #include #include @@ -71,8 +75,8 @@ ar531x_memsize(void) uint32_t memcfg, bank0, bank1; /* - * Determine the memory size. Use the `memsize' PMON - * variable. If that's not available, panic. + * Determine the memory size as established by system + * firmware. * * NB: we allow compile time override */ @@ -136,7 +140,7 @@ ar531x_consinit(void) #if NCOM > 0 /* Setup polled serial for early console I/O */ /* XXX: pass in CONSPEED? */ - com_arbus_cnattach(AR5312_UART0_BASE); + com_arbus_cnattach(AR5312_UART0_BASE, ar531x_bus_freq()); #else panic("Not configured to use serial console!\n"); /* not going to see that message now, are we? */ @@ -215,7 +219,203 @@ ar531x_cpu_freq(void) } uint32_t -ar531x_sys_freq(void) +ar531x_bus_freq(void) { return (ar531x_cpu_freq() / 4); } + +static void +addprop_data(struct device *dev, const char *name, const uint8_t *data, + int len) +{ + prop_data_t pd; + pd = prop_data_create_data(data, len); + KASSERT(pd != NULL); + if (prop_dictionary_set(device_properties(dev), name, pd) == FALSE) { + printf("WARNING: unable to set %s property for %s\n", + name, device_xname(dev)); + } + prop_object_release(pd); +} + +static void +addprop_integer(struct device *dev, const char *name, uint32_t val) +{ + prop_number_t pn; + pn = prop_number_create_integer(val); + KASSERT(pn != NULL); + if (prop_dictionary_set(device_properties(dev), name, pn) == FALSE) { + printf("WARNING: unable to set %s property for %s", + name, device_xname(dev)); + } + prop_object_release(pn); +} + +void +ar531x_device_register(struct device *dev, void *aux) +{ + struct arbus_attach_args *aa = aux; + const struct ar531x_boarddata *info; + + info = ar531x_board_info(); + if (info == NULL) { + /* nothing known about this board! */ + return; + } + + /* + * We don't ever know the boot device. But that's because the + * firmware only loads from the network. + */ + + /* Fetch the MAC addresses. */ + if (device_is_a(dev, "ae")) { + const uint8_t *enet; + + if (aa->aa_addr == AR5312_ENET0_BASE) + enet = info->enet0Mac; + else if (aa->aa_addr == AR5312_ENET1_BASE) + enet = info->enet1Mac; + else + return; + + addprop_data(dev, "mac-addr", enet, ETHER_ADDR_LEN); + } + + if (device_is_a(dev, "ath")) { + const uint8_t *enet; + + if (aa->aa_addr == AR5312_WLAN0_BASE) + enet = info->wlan0Mac; + else if (aa->aa_addr == AR5312_WLAN1_BASE) + enet = info->wlan1Mac; + else + return; + + addprop_data(dev, "mac-addr", enet, ETHER_ADDR_LEN); + } + + if (device_is_a(dev, "com")) { + addprop_integer(dev, "frequency", ar531x_cpu_freq() / 4); + } + + if (device_is_a(dev, "argpio")) { + if (info->config & BD_RSTFACTORY) { + addprop_integer(dev, "reset-pin", + info->resetConfigGpio); + } + if (info->config & BD_SYSLED) { + addprop_integer(dev, "sysled-pin", + info->sysLedGpio); + } + } +} + +int +ar531x_enable_device(const struct ar531x_device *dev) +{ + const struct ar531x_boarddata *info; + + info = ar531x_board_info(); + if (dev->mask && ((dev->mask & info->config) == 0)) { + return -1; + } + if (dev->reset) { + /* put device into reset */ + PUTSYSREG(AR5312_SYSREG_RESETCTL, + GETSYSREG(AR5312_SYSREG_RESETCTL) | dev->reset); + + delay(15000); /* XXX: tsleep? */ + + /* take it out of reset */ + PUTSYSREG(AR5312_SYSREG_RESETCTL, + GETSYSREG(AR5312_SYSREG_RESETCTL) & ~dev->reset); + + delay(25); + } + if (dev->enable) { + PUTSYSREG(AR5312_SYSREG_ENABLE, + GETSYSREG(AR5312_SYSREG_ENABLE) | dev->enable); + } + return 0; +} + +const struct ar531x_device * +ar531x_get_devices(void) +{ + static const struct ar531x_device devices[] = { + { + "ae", + AR5312_ENET0_BASE, 0x100000, + AR5312_IRQ_ENET0, -1, + AR5312_BOARD_CONFIG_ENET0, + AR5312_RESET_ENET0 | AR5312_RESET_PHY0, + AR5312_ENABLE_ENET0 + }, + { + "ae", + AR5312_ENET1_BASE, 0x100000, + AR5312_IRQ_ENET1, -1, + AR5312_BOARD_CONFIG_ENET1, + AR5312_RESET_ENET1 | AR5312_RESET_PHY1, + AR5312_ENABLE_ENET1 + }, + { + "com", + AR5312_UART0_BASE, 0x1000, + AR5312_IRQ_MISC, AR5312_MISC_IRQ_UART0, + AR5312_BOARD_CONFIG_UART0, + 0, + 0, + }, + { + "com", + AR5312_UART1_BASE, 0x1000, + -1, -1, + AR5312_BOARD_CONFIG_UART1, + 0, + 0, + }, + { + "ath", + AR5312_WLAN0_BASE, 0x100000, + AR5312_IRQ_WLAN0, -1, + AR5312_BOARD_CONFIG_WLAN0, + AR5312_RESET_WLAN0 | + AR5312_RESET_WARM_WLAN0_MAC | + AR5312_RESET_WARM_WLAN0_BB, + AR5312_ENABLE_WLAN0 + }, + { + "ath", + AR5312_WLAN1_BASE, 0x100000, + AR5312_IRQ_WLAN1, -1, + AR5312_BOARD_CONFIG_WLAN1, + AR5312_RESET_WLAN1 | + AR5312_RESET_WARM_WLAN1_MAC | + AR5312_RESET_WARM_WLAN1_BB, + AR5312_ENABLE_WLAN1 + }, + { + "athflash", + AR5312_FLASH_BASE, 0, + -1, -1, + 0, + 0, + 0, + }, + { + "argpio", 0x1000, + AR5312_GPIO_BASE, + AR5312_IRQ_MISC, AR5312_MISC_IRQ_GPIO, + 0, + 0, + 0 + }, + { NULL } + }; + + return devices; +} + + diff --git a/sys/arch/mips/atheros/ar5312_intr.c b/sys/arch/mips/atheros/ar5312_intr.c index 5e7b400ef40d..db74f6a7fa96 100644 --- a/sys/arch/mips/atheros/ar5312_intr.c +++ b/sys/arch/mips/atheros/ar5312_intr.c @@ -1,4 +1,4 @@ -/* $Id: ar5312_intr.c,v 1.1 2006/08/28 07:21:15 gdamore Exp $ */ +/* $Id: ar5312_intr.c,v 1.2 2006/09/04 05:17:26 gdamore Exp $ */ /* * Copyright (c) 2006 Urbana-Champaign Independent Media Center. * Copyright (c) 2006 Garrett D'Amore. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ar5312_intr.c,v 1.1 2006/08/28 07:21:15 gdamore Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ar5312_intr.c,v 1.2 2006/09/04 05:17:26 gdamore Exp $"); #include #include @@ -178,12 +178,12 @@ ar531x_intr_init(void) PUTREG(AR5312_SYSREG_MISC_INTMASK, 0); /* make sure we register the MISC interrupt handler */ - ar531x_intr_establish(NINTRS - 1, ar531x_miscintr, NULL); + ar531x_cpu_intr_establish(NINTRS - 1, ar531x_miscintr, NULL); } void * -ar531x_intr_establish(int intr, int (*func)(void *), void *arg) +ar531x_cpu_intr_establish(int intr, int (*func)(void *), void *arg) { struct ar531x_intrhand *ih; int s; @@ -212,7 +212,7 @@ ar531x_intr_establish(int intr, int (*func)(void *), void *arg) } void -ar531x_intr_disestablish(void *arg) +ar531x_cpu_intr_disestablish(void *arg) { struct ar531x_intrhand *ih = arg; int s; diff --git a/sys/arch/mips/atheros/arbus.c b/sys/arch/mips/atheros/arbus.c index d86e71e16cd6..7db96e1144ea 100644 --- a/sys/arch/mips/atheros/arbus.c +++ b/sys/arch/mips/atheros/arbus.c @@ -1,4 +1,4 @@ -/* $Id: arbus.c,v 1.9 2006/08/28 07:21:15 gdamore Exp $ */ +/* $Id: arbus.c,v 1.10 2006/09/04 05:17:26 gdamore Exp $ */ /* * Copyright (c) 2006 Urbana-Champaign Independent Media Center. * Copyright (c) 2006 Garrett D'Amore. @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: arbus.c,v 1.9 2006/08/28 07:21:15 gdamore Exp $"); +__KERNEL_RCSID(0, "$NetBSD: arbus.c,v 1.10 2006/09/04 05:17:26 gdamore Exp $"); #include "locators.h" #include @@ -63,8 +63,8 @@ static void arbus_bus_mem_init(bus_space_tag_t, void *); static void arbus_dma_init(struct device *, bus_dma_tag_t); struct arbus_intrhand { - int ih_irq; - int ih_misc; + int ih_cirq; + int ih_mirq; void *ih_cookie; }; @@ -86,85 +86,6 @@ arbus_init(void) arbus_dma_init(NULL, &arbus_mdt); } -static struct { - const char *name; - bus_addr_t addr; - int irq; - uint32_t mask; - uint32_t reset; - uint32_t enable; -} arbus_devices[] = { - { - "ae", - AR5312_ENET0_BASE, - ARBUS_IRQ_ENET0, - AR5312_BOARD_CONFIG_ENET0, - AR5312_RESET_ENET0 | AR5312_RESET_PHY0, - AR5312_ENABLE_ENET0 - }, - { - "ae", - AR5312_ENET1_BASE, - ARBUS_IRQ_ENET1, - AR5312_BOARD_CONFIG_ENET1, - AR5312_RESET_ENET1 | AR5312_RESET_PHY1, - AR5312_ENABLE_ENET1 - }, - { - "com", - AR5312_UART0_BASE, - ARBUS_IRQ_UART0, - AR5312_BOARD_CONFIG_UART0, - 0, - 0, - }, - { - "com", - AR5312_UART1_BASE, - -1, - AR5312_BOARD_CONFIG_UART1, - 0, - 0, - }, - { - "ath", - AR5312_WLAN0_BASE, - ARBUS_IRQ_WLAN0, - AR5312_BOARD_CONFIG_WLAN0, - AR5312_RESET_WLAN0 | - AR5312_RESET_WARM_WLAN0_MAC | - AR5312_RESET_WARM_WLAN0_BB, - AR5312_ENABLE_WLAN0 - }, - { - "ath", - AR5312_WLAN1_BASE, - ARBUS_IRQ_WLAN1, - AR5312_BOARD_CONFIG_WLAN1, - AR5312_RESET_WLAN1 | - AR5312_RESET_WARM_WLAN1_MAC | - AR5312_RESET_WARM_WLAN1_BB, - AR5312_ENABLE_WLAN1 - }, - { - "athflash", - AR5312_FLASH_BASE, - -1, - 0, - 0, - 0, - }, - { - "argpio", - AR5312_GPIO_BASE, - ARBUS_IRQ_GPIO, - 0, - 0, - 0 - }, - { NULL } -}; - /* this primarily exists so we can get to the console... */ bus_space_tag_t arbus_get_bus_space_tag(void) @@ -191,55 +112,28 @@ void arbus_attach(struct device *parent, struct device *self, void *aux) { struct arbus_attach_args aa; - const struct ar531x_boarddata *info; + const struct ar531x_device *devices; int i; printf("\n"); int locs[ARBUSCF_NLOCS]; - info = ar531x_board_info(); arbus_init(); - for (i = 0; arbus_devices[i].name; i++) { - if (arbus_devices[i].mask && - ((arbus_devices[i].mask & info->config) == 0)) { - continue; - } - aa.aa_name = arbus_devices[i].name; + for (i = 0, devices = ar531x_get_devices(); devices[i].name; i++) { + + aa.aa_name = devices[i].name; + aa.aa_size = devices[i].size; aa.aa_dmat = &arbus_mdt; aa.aa_bst = &arbus_mbst; - aa.aa_irq = arbus_devices[i].irq; - aa.aa_addr = arbus_devices[i].addr; - - if (aa.aa_addr < AR5312_UART0_BASE) - aa.aa_size = 0x00100000; - else if (aa.aa_addr < AR5312_FLASH_BASE) - aa.aa_size = 0x1000; + aa.aa_cirq = devices[i].cirq; + aa.aa_mirq = devices[i].mirq; + aa.aa_addr = devices[i].addr; locs[ARBUSCF_ADDR] = aa.aa_addr; - if (arbus_devices[i].reset) { - /* put device into reset */ - PUTSYSREG(AR5312_SYSREG_RESETCTL, - GETSYSREG(AR5312_SYSREG_RESETCTL) | - arbus_devices[i].reset); - - /* this could probably be a tsleep */ - delay(15000); - - /* take it out of reset */ - PUTSYSREG(AR5312_SYSREG_RESETCTL, - GETSYSREG(AR5312_SYSREG_RESETCTL) & - ~arbus_devices[i].reset); - - delay(25); - } - - if (arbus_devices[i].enable) { - /* enable it */ - PUTSYSREG(AR5312_SYSREG_ENABLE, - GETSYSREG(AR5312_SYSREG_ENABLE) | - arbus_devices[i].enable); + if (ar531x_enable_device(&devices[i]) != 0) { + continue; } (void) config_found_sm_loc(self, "arbus", locs, &aa, @@ -258,18 +152,17 @@ arbus_print(void *aux, const char *pnp) if (aa->aa_addr) aprint_normal(" addr 0x%lx", aa->aa_addr); - if (aa->aa_irq >= 0) { - aprint_normal(" interrupt %d", ARBUS_IRQ_CPU(aa->aa_irq)); + if (aa->aa_cirq >= 0) + aprint_normal(" cpu irq %d", aa->aa_cirq); - if (ARBUS_IRQ_MISC(aa->aa_irq)) - aprint_normal(" irq %d", ARBUS_IRQ_MISC(aa->aa_irq)); - } + if (aa->aa_mirq >= 0) + aprint_normal(" misc irq %d", aa->aa_mirq); return (UNCONF); } void * -arbus_intr_establish(int irq, int (*handler)(void *), void *arg) +arbus_intr_establish(int cirq, int mirq, int (*handler)(void *), void *arg) { struct arbus_intrhand *ih; @@ -277,18 +170,17 @@ arbus_intr_establish(int irq, int (*handler)(void *), void *arg) if (ih == NULL) return NULL; - ih->ih_irq = irq; + ih->ih_cirq = ih->ih_mirq = -1; ih->ih_cookie = NULL; - if (ARBUS_IRQ_MISC(irq)) { - irq = ARBUS_IRQ_MISC(irq); - ih->ih_misc = 1; - ih->ih_cookie = ar531x_misc_intr_establish(irq, handler, arg); - } else { - irq = ARBUS_IRQ_CPU(irq); - ih->ih_misc = 0; - ih->ih_cookie = ar531x_intr_establish(irq, handler, arg); - } + if (mirq >= 0) { + ih->ih_mirq = mirq; + ih->ih_cookie = ar531x_misc_intr_establish(mirq, handler, arg); + } else if (cirq >= 0) { + ih->ih_cirq = cirq; + ih->ih_cookie = ar531x_cpu_intr_establish(cirq, handler, arg); + } else + return ih; if (ih->ih_cookie == NULL) { free(ih, M_DEVBUF); @@ -301,10 +193,10 @@ void arbus_intr_disestablish(void *arg) { struct arbus_intrhand *ih = arg; - if (ih->ih_misc) + if (ih->ih_mirq >= 0) ar531x_misc_intr_disestablish(ih->ih_cookie); - else - ar531x_intr_disestablish(ih->ih_cookie); + else if (ih->ih_cirq >= 0) + ar531x_cpu_intr_disestablish(ih->ih_cookie); free(ih, M_DEVBUF); } diff --git a/sys/arch/mips/atheros/dev/aevar.h b/sys/arch/mips/atheros/dev/aevar.h index 31ca9f53e275..41afe38f35e6 100644 --- a/sys/arch/mips/atheros/dev/aevar.h +++ b/sys/arch/mips/atheros/dev/aevar.h @@ -1,4 +1,4 @@ -/* $NetBSD: aevar.h,v 1.1 2006/03/21 08:15:19 gdamore Exp $ */ +/* $NetBSD: aevar.h,v 1.2 2006/09/04 05:17:26 gdamore Exp $ */ /*- * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc. @@ -141,7 +141,8 @@ struct ae_softc { bus_size_t sc_size; /* bus space size */ bus_dma_tag_t sc_dmat; /* bus DMA tag */ void *sc_ih; /* interrupt handle */ - int sc_irq; /* interrupt request line */ + int sc_cirq; /* interrupt request line (cpu) */ + int sc_mirq; /* interrupt request line (misc) */ struct ethercom sc_ethercom; /* ethernet common data */ void *sc_sdhook; /* shutdown hook */ void *sc_powerhook; /* power management hook */ diff --git a/sys/arch/mips/atheros/dev/argpio.c b/sys/arch/mips/atheros/dev/argpio.c index 2e45a484ffbd..656d1bea88e7 100644 --- a/sys/arch/mips/atheros/dev/argpio.c +++ b/sys/arch/mips/atheros/dev/argpio.c @@ -1,4 +1,4 @@ -/* $NetBSD: argpio.c,v 1.2 2006/08/28 07:21:15 gdamore Exp $ */ +/* $NetBSD: argpio.c,v 1.3 2006/09/04 05:17:26 gdamore Exp $ */ /*- * Copyright (c) 2006 Garrett D'Amore @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: argpio.c,v 1.2 2006/08/28 07:21:15 gdamore Exp $"); +__KERNEL_RCSID(0, "$NetBSD: argpio.c,v 1.3 2006/09/04 05:17:26 gdamore Exp $"); #include #include @@ -44,12 +44,8 @@ __KERNEL_RCSID(0, "$NetBSD: argpio.c,v 1.2 2006/08/28 07:21:15 gdamore Exp $"); #include #include -#include -#include #include -#include /* this should really move */ - #include #include #include @@ -75,6 +71,7 @@ struct argpio_softc { struct sysmon_pswitch sc_resetbtn; void *sc_ih; int sc_rstpin; + int sc_ledpin; }; static int argpio_match(struct device *, struct cfdata *, void *); @@ -111,13 +108,15 @@ argpio_attach(struct device *parent, struct device *self, void *aux) struct argpio_softc *sc = (struct argpio_softc *)self; struct arbus_attach_args *aa = aux; struct gpiobus_attach_args gba; - const struct ar531x_boarddata *board; - int rstpin = -1, ledpin = -1, i; + prop_number_t pn; + int i; uint32_t reg; sc->sc_st = aa->aa_bst; sc->sc_npins = ARGPIO_NPINS; sc->sc_size = aa->aa_size; + sc->sc_ledpin = -1; + sc->sc_rstpin = -1; if (bus_space_map(sc->sc_st, aa->aa_addr, sc->sc_size, 0, &sc->sc_sh) != 0) { @@ -130,27 +129,29 @@ argpio_attach(struct device *parent, struct device *self, void *aux) sc->sc_gc.gp_pin_write = argpio_write; sc->sc_gc.gp_pin_ctl = argpio_ctl; - board = ar531x_board_info(); - aprint_normal(": Atheros AR531X GPIO"); - if (board->config & BD_RSTFACTORY) { - rstpin = board->resetConfigGpio; - aprint_normal(", reset button pin %d", rstpin); - sc->sc_rstpin = rstpin; + pn = prop_dictionary_get(device_properties(&sc->sc_dev), "reset-pin"); + if (pn != NULL) { + KASSERT(prop_object_type(pn) == PROP_TYPE_NUMBER); + sc->sc_rstpin = (int)prop_number_integer_value(pn); + aprint_normal(", reset button pin %d", sc->sc_rstpin); } - if (board->config & BD_SYSLED) { - ledpin = board->sysLedGpio; - aprint_normal(", system led pin %d", ledpin); + pn = prop_dictionary_get(device_properties(&sc->sc_dev), "sysled-pin"); + if (pn != NULL) { + KASSERT(prop_object_type(pn) == PROP_TYPE_NUMBER); + sc->sc_ledpin = (int)prop_number_integer_value(pn); + aprint_normal(", system led pin %d", sc->sc_ledpin); } + printf("\n"); - if ((board->config & BD_RSTFACTORY) && (aa->aa_irq > -1)) { - sc->sc_ih = arbus_intr_establish(aa->aa_irq, argpio_intr, sc); + if (sc->sc_ledpin) { + sc->sc_ih = arbus_intr_establish(aa->aa_cirq, aa->aa_mirq, + argpio_intr, sc); if (sc->sc_ih == NULL) { aprint_error("%s: couldn't establish interrupt\n", sc->sc_dev.dv_xname); } - } if (sc->sc_ih) { @@ -170,7 +171,7 @@ argpio_attach(struct device *parent, struct device *self, void *aux) pp = &sc->sc_pins[i]; - if (i == rstpin) { + if (i == sc->sc_rstpin) { /* configure as interrupt for reset */ pp->pin_caps = GPIO_PIN_INPUT; reg &= ~SERIAL(i); @@ -179,7 +180,7 @@ argpio_attach(struct device *parent, struct device *self, void *aux) if (sc->sc_ih != NULL) reg |= INTR(i); - } else if (i == ledpin) { + } else if (i == sc->sc_ledpin) { /* configure as output for LED */ pp->pin_caps = GPIO_PIN_OUTPUT; reg &= ~SERIAL(i); diff --git a/sys/arch/mips/atheros/dev/com_arbus.c b/sys/arch/mips/atheros/dev/com_arbus.c index 32427489fe88..2c7f3c9fffed 100644 --- a/sys/arch/mips/atheros/dev/com_arbus.c +++ b/sys/arch/mips/atheros/dev/com_arbus.c @@ -1,4 +1,4 @@ -/* $Id: com_arbus.c,v 1.3 2006/08/28 07:21:15 gdamore Exp $ */ +/* $Id: com_arbus.c,v 1.4 2006/09/04 05:17:26 gdamore Exp $ */ /*- * Copyright (c) 2006 Urbana-Champaign Independent Media Center. * Copyright (c) 2006 Garrett D'Amore. @@ -108,11 +108,12 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: com_arbus.c,v 1.3 2006/08/28 07:21:15 gdamore Exp $"); +__KERNEL_RCSID(0, "$NetBSD: com_arbus.c,v 1.4 2006/09/04 05:17:26 gdamore Exp $"); #include #include #include +#include #include #include #include @@ -191,9 +192,18 @@ com_arbus_attach(struct device *parent, struct device *self, void *aux) struct com_arbus_softc *arsc = (void *)self; struct com_softc *sc = &arsc->sc_com; struct arbus_attach_args *aa = aux; + prop_number_t prop; bus_space_handle_t ioh; - sc->sc_frequency = ar531x_sys_freq(); + prop = prop_dictionary_get(device_properties(&sc->sc_dev), + "frequency"); + if (prop == NULL) { + printf(": unable to get frequency property\n"); + return; + } + KASSERT(prop_object_type(prop) == PROP_TYPE_NUMBER); + + sc->sc_frequency = (int)prop_number_integer_value(prop); if (!com_is_console(aa->aa_bst, aa->aa_addr, &ioh) && bus_space_map(aa->aa_bst, aa->aa_addr, aa->aa_size, 0, @@ -208,9 +218,7 @@ com_arbus_attach(struct device *parent, struct device *self, void *aux) com_attach_subr(sc); - if (aa->aa_irq >= 0) { - arbus_intr_establish(aa->aa_irq, comintr, sc); - } + arbus_intr_establish(aa->aa_cirq, aa->aa_mirq, comintr, sc); } void @@ -226,7 +234,7 @@ com_arbus_initmap(struct com_regs *regsp) } void -com_arbus_cnattach(bus_addr_t addr) +com_arbus_cnattach(bus_addr_t addr, uint32_t freq) { struct com_regs regs; @@ -239,7 +247,6 @@ com_arbus_cnattach(bus_addr_t addr) ®s.cr_ioh)) return; - comcnattach1(®s, com_arbus_baud, ar531x_sys_freq(), - COM_TYPE_NORMAL, CONMODE); + comcnattach1(®s, com_arbus_baud, freq, COM_TYPE_NORMAL, CONMODE); } diff --git a/sys/arch/mips/atheros/dev/if_ae.c b/sys/arch/mips/atheros/dev/if_ae.c index 6badbb012b9d..d1161686d7b6 100644 --- a/sys/arch/mips/atheros/dev/if_ae.c +++ b/sys/arch/mips/atheros/dev/if_ae.c @@ -1,4 +1,4 @@ -/* $Id: if_ae.c,v 1.2 2006/05/05 18:04:41 thorpej Exp $ */ +/* $Id: if_ae.c,v 1.3 2006/09/04 05:17:26 gdamore Exp $ */ /*- * Copyright (c) 2006 Urbana-Champaign Independent Media Center. * Copyright (c) 2006 Garrett D'Amore. @@ -105,7 +105,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_ae.c,v 1.2 2006/05/05 18:04:41 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ae.c,v 1.3 2006/09/04 05:17:26 gdamore Exp $"); #include "bpfilter.h" @@ -261,7 +261,8 @@ ae_attach(struct device *parent, struct device *self, void *aux) printf("%s: Ethernet address %s\n", sc->sc_dev.dv_xname, ether_sprintf(enaddr)); - sc->sc_irq = aa->aa_irq; + sc->sc_cirq = aa->aa_cirq; + sc->sc_mirq = aa->aa_mirq; sc->sc_st = aa->aa_bst; sc->sc_dmat = aa->aa_dmat; @@ -1513,7 +1514,8 @@ ae_enable(struct ae_softc *sc) { if (AE_IS_ENABLED(sc) == 0) { - sc->sc_ih = arbus_intr_establish(sc->sc_irq, ae_intr, sc); + sc->sc_ih = arbus_intr_establish(sc->sc_cirq, sc->sc_mirq, + ae_intr, sc); if (sc->sc_ih == NULL) { printf("%s: unable to establish interrupt\n", sc->sc_dev.dv_xname); diff --git a/sys/arch/mips/atheros/dev/if_ath_arbus.c b/sys/arch/mips/atheros/dev/if_ath_arbus.c index 39d143f39fd3..969d374f066f 100644 --- a/sys/arch/mips/atheros/dev/if_ath_arbus.c +++ b/sys/arch/mips/atheros/dev/if_ath_arbus.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ath_arbus.c,v 1.6 2006/08/28 07:21:15 gdamore Exp $ */ +/* $NetBSD: if_ath_arbus.c,v 1.7 2006/09/04 05:17:26 gdamore Exp $ */ /*- * Copyright (c) 2006 Jared D. McNeill @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_ath_arbus.c,v 1.6 2006/08/28 07:21:15 gdamore Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ath_arbus.c,v 1.7 2006/09/04 05:17:26 gdamore Exp $"); #include #include @@ -144,7 +144,8 @@ ath_arbus_attach(struct device *parent, struct device *self, void *opaque) sc->sc_invalid = 1; - asc->sc_ih = arbus_intr_establish(aa->aa_irq, ath_intr, sc); + asc->sc_ih = arbus_intr_establish(aa->aa_cirq, aa->aa_mirq, ath_intr, + sc); if (asc->sc_ih == NULL) { aprint_error("%s: couldn't establish interrupt\n", sc->sc_dev.dv_xname); diff --git a/sys/arch/mips/atheros/include/ar5312reg.h b/sys/arch/mips/atheros/include/ar5312reg.h index e632d3b60186..27dfbc5f8bc0 100644 --- a/sys/arch/mips/atheros/include/ar5312reg.h +++ b/sys/arch/mips/atheros/include/ar5312reg.h @@ -1,4 +1,4 @@ -/* $Id: ar5312reg.h,v 1.1 2006/08/28 07:21:15 gdamore Exp $ */ +/* $Id: ar5312reg.h,v 1.2 2006/09/04 05:17:26 gdamore Exp $ */ /* * Copyright (c) 2006 Urbana-Champaign Independent Media Center. * Copyright (c) 2006 Garrett D'Amore. @@ -181,6 +181,22 @@ #define GETSDRAMREG(x) REGVAL((x) + AR5312_SDRAMCTL_BASE) #define PUTSDRAMREG(x,v) (REGVAL((x) + AR5312_SDRAMCTL_BASE)) = (v) +/* + * Interrupts. + */ +#define AR5312_IRQ_WLAN0 0 +#define AR5312_IRQ_ENET0 1 +#define AR5312_IRQ_ENET1 2 +#define AR5312_IRQ_WLAN1 3 +#define AR5312_IRQ_MISC 4 + +#define AR5312_MISC_IRQ_TIMER 0 +#define AR5312_MISC_IRQ_AHBPERR 1 +#define AR5312_MISC_IRQ_AHBDMAE 2 +#define AR5312_MISC_IRQ_GPIO 3 +#define AR5312_MISC_IRQ_UART0 4 +#define AR5312_MISC_IRQ_UART0_DMA 5 +#define AR5312_MISC_IRQ_WDOG 6 /* * Board data. This is located in flash somewhere, ar531x_board_info * locates it. diff --git a/sys/arch/mips/atheros/include/ar531xvar.h b/sys/arch/mips/atheros/include/ar531xvar.h index 890d5f7698fc..3dd8eb5db5c0 100644 --- a/sys/arch/mips/atheros/include/ar531xvar.h +++ b/sys/arch/mips/atheros/include/ar531xvar.h @@ -1,4 +1,4 @@ -/* $Id: ar531xvar.h,v 1.3 2006/08/28 07:21:15 gdamore Exp $ */ +/* $Id: ar531xvar.h,v 1.4 2006/09/04 05:17:26 gdamore Exp $ */ /* * Copyright (c) 2006 Urbana-Champaign Independent Media Center. * Copyright (c) 2006 Garrett D'Amore. @@ -43,16 +43,32 @@ #ifndef _MIPS_ATHEROS_AR531XVAR_H_ #define _MIPS_ATHEROS_AR531XVAR_H_ +#include +#include + +struct ar531x_device { + const char *name; + bus_addr_t addr; + bus_size_t size; + int cirq; + int mirq; + uint32_t mask; + uint32_t reset; + uint32_t enable; +}; + + void ar531x_intr_init(void); -void *ar531x_intr_establish(int, int (*)(void *), void *); -void ar531x_intr_disestablish(void *); +void *ar531x_cpu_intr_establish(int, int (*)(void *), void *); +void ar531x_cpu_intr_disestablish(void *); void *ar531x_misc_intr_establish(int, int (*)(void *), void *); void ar531x_misc_intr_disestablish(void *); void ar531x_cpuintr(uint32_t, uint32_t, uint32_t, uint32_t); + /* * CPU specific routines. */ @@ -62,7 +78,10 @@ void ar531x_wdog(uint32_t); void ar531x_businit(void); const char *ar531x_cpuname(void); uint32_t ar531x_cpu_freq(void); -uint32_t ar531x_sys_freq(void); +uint32_t ar531x_bus_freq(void); +void ar531x_device_register(struct device *, void *); +int ar531x_enable_device(const struct ar531x_device *); +const struct ar531x_device *ar531x_get_devices(void); /* * Board specific things. diff --git a/sys/arch/mips/atheros/include/arbusvar.h b/sys/arch/mips/atheros/include/arbusvar.h index 0174ba29ec71..75d2833787a6 100644 --- a/sys/arch/mips/atheros/include/arbusvar.h +++ b/sys/arch/mips/atheros/include/arbusvar.h @@ -1,4 +1,4 @@ -/* $Id: arbusvar.h,v 1.1 2006/03/21 08:15:19 gdamore Exp $ */ +/* $Id: arbusvar.h,v 1.2 2006/09/04 05:17:26 gdamore Exp $ */ /* * Copyright (c) 2006 Urbana-Champaign Independent Media Center. * Copyright (c) 2006 Garrett D'Amore. @@ -52,17 +52,18 @@ struct arbus_attach_args { bus_addr_t aa_addr; bus_size_t aa_size; - int aa_irq; + int aa_cirq; /* cpu irq */ + int aa_mirq; /* misc irq */ }; void arbus_init(void); bus_space_tag_t arbus_get_bus_space_tag(void); bus_dma_tag_t arbus_get_bus_dma_tag(void); -void *arbus_intr_establish(int, int (*)(void *), void *); +void *arbus_intr_establish(int, int, int (*)(void *), void *); void arbus_intr_disestablish(void *); -void com_arbus_cnattach(bus_addr_t); +void com_arbus_cnattach(bus_addr_t, uint32_t); /* * These definitions are "funny". To distinquish between diff --git a/sys/arch/mips/conf/files.atheros b/sys/arch/mips/conf/files.atheros index 120b97cd4e3b..2b1391e9c9dd 100644 --- a/sys/arch/mips/conf/files.atheros +++ b/sys/arch/mips/conf/files.atheros @@ -1,8 +1,14 @@ -# $NetBSD: files.atheros,v 1.5 2006/08/28 07:21:15 gdamore Exp $ +# $NetBSD: files.atheros,v 1.6 2006/09/04 05:17:26 gdamore Exp $ -file arch/mips/atheros/ar5312.c -file arch/mips/atheros/ar5312_intr.c -file arch/mips/atheros/ar531x_board.c +defflag opt_wisoc.h WISOC_AR5312 + WISOC_AR5315 + +file arch/mips/atheros/ar5312.c wisoc_ar5312 +file arch/mips/atheros/ar5312_intr.c wisoc_ar5312 +file arch/mips/atheros/ar531x_board.c wisoc_ar5312 + +file arch/mips/atheros/ar5315.c wisoc_ar5315 +file arch/mips/atheros/ar5315_intr.c wisoc_ar5315 # Atheros system bus device arbus { [addr=-1] }