This is a boat-load of changes designed to finish parameterizing the

stuff necessary to separate out AR5312 from AR5315.  This includes:

	1) rework of arbus IRQs, so that IRQs are now seperately specified
	   as either MISC or CPU irqs
	2) move board/chip-specific addresses into chip-dependent file
	3) unencumber argpio from ar5312 specifics, using properties to pass
	   details such as reset-pin and sysled-pin.
	4) an option to select which WiSoC is to be configured is provided.

AR5315 support should be forthcoming shortly now.
This commit is contained in:
gdamore 2006-09-04 05:17:26 +00:00
parent 9de94f8e2e
commit 1f585717a8
16 changed files with 359 additions and 271 deletions

View File

@ -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 <sys/cdefs.h>
__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 <sys/param.h>
#include <sys/systm.h>
#include <sys/conf.h>
#include <sys/socket.h> /* these three just to get ETHER_ADDR_LEN(!) */
#include <net/if.h>
#include <net/if_ether.h>
#include <machine/bus.h>
#include <mips/atheros/include/ar5312reg.h>
#include <mips/atheros/include/ar531xvar.h>
#include <mips/atheros/include/arbusvar.h>
@ -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);
}

View File

@ -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 <sys/cdefs.h>
__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 <sys/param.h>
#include <sys/systm.h>
@ -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;

View File

@ -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

View File

@ -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"

View File

@ -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 <mips/locore.h>
#include <mips/cpuregs.h>
#include <sys/socket.h> /* these three just to get ETHER_ADDR_LEN(!) */
#include <net/if.h>
#include <net/if_ether.h>
#include <mips/atheros/include/ar5312reg.h>
#include <mips/atheros/include/ar531xvar.h>
#include <mips/atheros/include/arbusvar.h>
@ -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;
}

View File

@ -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 <sys/cdefs.h>
__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 <sys/param.h>
#include <sys/queue.h>
@ -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;

View File

@ -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 <sys/cdefs.h>
__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 <sys/param.h>
@ -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);
}

View File

@ -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 */

View File

@ -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 <sys/cdefs.h>
__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 <sys/param.h>
#include <sys/conf.h>
@ -44,12 +44,8 @@ __KERNEL_RCSID(0, "$NetBSD: argpio.c,v 1.2 2006/08/28 07:21:15 gdamore Exp $");
#include <machine/bus.h>
#include <machine/intr.h>
#include <mips/atheros/include/ar5312reg.h>
#include <mips/atheros/include/ar531xvar.h>
#include <mips/atheros/include/arbusvar.h>
#include <contrib/dev/ath/ah_soc.h> /* this should really move */
#include <dev/gpio/gpiovar.h>
#include <dev/sysmon/sysmonvar.h>
#include <dev/sysmon/sysmon_taskq.h>
@ -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);

View File

@ -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 <sys/cdefs.h>
__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 <sys/param.h>
#include <sys/systm.h>
#include <sys/device.h>
#include <sys/kernel.h>
#include <sys/termios.h>
#include <sys/ttydefaults.h>
#include <sys/types.h>
@ -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)
&regs.cr_ioh))
return;
comcnattach1(&regs, com_arbus_baud, ar531x_sys_freq(),
COM_TYPE_NORMAL, CONMODE);
comcnattach1(&regs, com_arbus_baud, freq, COM_TYPE_NORMAL, CONMODE);
}

View File

@ -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 <sys/cdefs.h>
__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);

View File

@ -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 <jmcneill@invisible.ca>
@ -34,7 +34,7 @@
*/
#include <sys/cdefs.h>
__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 <sys/param.h>
#include <sys/systm.h>
@ -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);

View File

@ -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.

View File

@ -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 <sys/param.h>
#include <machine/bus.h>
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.

View File

@ -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

View File

@ -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] }