diff options
author | Damien Bergamini <damien@cvs.openbsd.org> | 2010-12-31 17:50:49 +0000 |
---|---|---|
committer | Damien Bergamini <damien@cvs.openbsd.org> | 2010-12-31 17:50:49 +0000 |
commit | 018e461d91255b544863b18432b9fb3b570f5095 (patch) | |
tree | f92810854e9eef44a73ddd753bb3b91ea9aa3660 /sys/dev | |
parent | 86475832be1dd5c523be9ae6c692d54867b08db6 (diff) |
of course, GPIO handling on AR9271 and AR7010 had to be different
from all other chips... quite nightmarish.
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/ic/ar5008.c | 49 | ||||
-rw-r--r-- | sys/dev/ic/ar5008reg.h | 9 | ||||
-rw-r--r-- | sys/dev/ic/ar9280.c | 4 | ||||
-rw-r--r-- | sys/dev/ic/ar9285.c | 4 | ||||
-rw-r--r-- | sys/dev/ic/ar9287.c | 4 |
5 files changed, 52 insertions, 18 deletions
diff --git a/sys/dev/ic/ar5008.c b/sys/dev/ic/ar5008.c index 7b3cce75aff..c6cbeaa228b 100644 --- a/sys/dev/ic/ar5008.c +++ b/sys/dev/ic/ar5008.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ar5008.c,v 1.16 2010/12/31 17:17:14 damien Exp $ */ +/* $OpenBSD: ar5008.c,v 1.17 2010/12/31 17:50:48 damien Exp $ */ /*- * Copyright (c) 2009 Damien Bergamini <damien.bergamini@free.fr> @@ -356,6 +356,8 @@ int ar5008_gpio_read(struct athn_softc *sc, int pin) { KASSERT(pin < sc->ngpiopins); + if ((sc->flags & ATHN_FLAG_USB) && !AR_SREV_9271(sc)) + return (!(AR_READ(sc, AR7010_GPIO_IN) >> pin) & 1); return ((AR_READ(sc, AR_GPIO_IN_OUT) >> (sc->ngpiopins + pin)) & 1); } @@ -365,12 +367,26 @@ ar5008_gpio_write(struct athn_softc *sc, int pin, int set) uint32_t reg; KASSERT(pin < sc->ngpiopins); - reg = AR_READ(sc, AR_GPIO_IN_OUT); - if (set) - reg |= 1 << pin; - else - reg &= ~(1 << pin); - AR_WRITE(sc, AR_GPIO_IN_OUT, reg); + + if (sc->flags & ATHN_FLAG_USB) + set = !set; /* AR9271/AR7010 is reversed. */ + + if ((sc->flags & ATHN_FLAG_USB) && !AR_SREV_9271(sc)) { + /* Special case for AR7010. */ + reg = AR_READ(sc, AR7010_GPIO_OUT); + if (set) + reg |= 1 << pin; + else + reg &= ~(1 << pin); + AR_WRITE(sc, AR7010_GPIO_OUT, reg); + } else { + reg = AR_READ(sc, AR_GPIO_IN_OUT); + if (set) + reg |= 1 << pin; + else + reg &= ~(1 << pin); + AR_WRITE(sc, AR_GPIO_IN_OUT, reg); + } AR_WRITE_BARRIER(sc); } @@ -379,10 +395,15 @@ ar5008_gpio_config_input(struct athn_softc *sc, int pin) { uint32_t reg; - reg = AR_READ(sc, AR_GPIO_OE_OUT); - reg &= ~(AR_GPIO_OE_OUT_DRV_M << (pin * 2)); - reg |= AR_GPIO_OE_OUT_DRV_NO << (pin * 2); - AR_WRITE(sc, AR_GPIO_OE_OUT, reg); + if ((sc->flags & ATHN_FLAG_USB) && !AR_SREV_9271(sc)) { + /* Special case for AR7010. */ + AR_SETBITS(sc, AR7010_GPIO_OE, 1 << pin); + } else { + reg = AR_READ(sc, AR_GPIO_OE_OUT); + reg &= ~(AR_GPIO_OE_OUT_DRV_M << (pin * 2)); + reg |= AR_GPIO_OE_OUT_DRV_NO << (pin * 2); + AR_WRITE(sc, AR_GPIO_OE_OUT, reg); + } AR_WRITE_BARRIER(sc); } @@ -392,6 +413,12 @@ ar5008_gpio_config_output(struct athn_softc *sc, int pin, int type) uint32_t reg; int mux, off; + if ((sc->flags & ATHN_FLAG_USB) && !AR_SREV_9271(sc)) { + /* Special case for AR7010. */ + AR_CLRBITS(sc, AR7010_GPIO_OE, 1 << pin); + AR_WRITE_BARRIER(sc); + return; + } mux = pin / 6; off = pin % 6; diff --git a/sys/dev/ic/ar5008reg.h b/sys/dev/ic/ar5008reg.h index 62d7c1b53ca..d5845cb0134 100644 --- a/sys/dev/ic/ar5008reg.h +++ b/sys/dev/ic/ar5008reg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ar5008reg.h,v 1.2 2010/10/18 16:18:48 damien Exp $ */ +/* $OpenBSD: ar5008reg.h,v 1.3 2010/12/31 17:50:48 damien Exp $ */ /*- * Copyright (c) 2009 Damien Bergamini <damien.bergamini@free.fr> @@ -182,6 +182,13 @@ #define AR_PHY_TX_PWRCTRL6_1 0xb270 #define AR_PHY_CH1_TX_PWRCTRL11 0xb398 +/* + * AR7010 registers. + */ +#define AR7010_GPIO_OE 0x52000 +#define AR7010_GPIO_IN 0x52004 +#define AR7010_GPIO_OUT 0x52008 + /* Bits for AR_AN_RF2G1_CH0. */ #define AR_AN_RF2G1_CH0_OB_M 0x03800000 diff --git a/sys/dev/ic/ar9280.c b/sys/dev/ic/ar9280.c index 9f08325b810..fa3177dba0e 100644 --- a/sys/dev/ic/ar9280.c +++ b/sys/dev/ic/ar9280.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ar9280.c,v 1.14 2010/12/31 14:06:05 damien Exp $ */ +/* $OpenBSD: ar9280.c,v 1.15 2010/12/31 17:50:48 damien Exp $ */ /*- * Copyright (c) 2009 Damien Bergamini <damien.bergamini@free.fr> @@ -99,7 +99,7 @@ ar9280_attach(struct athn_softc *sc) sc->eep_base = AR5416_EEP_START_LOC; sc->eep_size = sizeof(struct ar5416_eeprom); sc->def_nf = AR9280_PHY_CCA_MAX_GOOD_VALUE; - sc->ngpiopins = 10; + sc->ngpiopins = (sc->flags & ATHN_FLAG_USB) ? 16 : 10; sc->led_pin = 1; sc->workaround = AR9280_WA_DEFAULT; sc->ops.setup = ar9280_setup; diff --git a/sys/dev/ic/ar9285.c b/sys/dev/ic/ar9285.c index 73c13740265..57ff3fd1e52 100644 --- a/sys/dev/ic/ar9285.c +++ b/sys/dev/ic/ar9285.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ar9285.c,v 1.14 2010/12/31 17:17:14 damien Exp $ */ +/* $OpenBSD: ar9285.c,v 1.15 2010/12/31 17:50:48 damien Exp $ */ /*- * Copyright (c) 2009-2010 Damien Bergamini <damien.bergamini@free.fr> @@ -109,7 +109,7 @@ ar9285_attach(struct athn_softc *sc) sc->eep_base = AR9285_EEP_START_LOC; sc->eep_size = sizeof(struct ar9285_eeprom); sc->def_nf = AR9285_PHY_CCA_MAX_GOOD_VALUE; - sc->ngpiopins = 12; + sc->ngpiopins = (sc->flags & ATHN_FLAG_USB) ? 16 : 12; sc->led_pin = 1; sc->workaround = AR9285_WA_DEFAULT; sc->ops.setup = ar9285_setup; diff --git a/sys/dev/ic/ar9287.c b/sys/dev/ic/ar9287.c index 381b0ce9ca6..1f10864ce9b 100644 --- a/sys/dev/ic/ar9287.c +++ b/sys/dev/ic/ar9287.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ar9287.c,v 1.15 2010/12/31 14:06:05 damien Exp $ */ +/* $OpenBSD: ar9287.c,v 1.16 2010/12/31 17:50:48 damien Exp $ */ /*- * Copyright (c) 2009 Damien Bergamini <damien.bergamini@free.fr> @@ -108,7 +108,7 @@ ar9287_attach(struct athn_softc *sc) sc->eep_base = AR9287_EEP_START_LOC; sc->eep_size = sizeof(struct ar9287_eeprom); sc->def_nf = AR9287_PHY_CCA_MAX_GOOD_VALUE; - sc->ngpiopins = 11; + sc->ngpiopins = (sc->flags & ATHN_FLAG_USB) ? 16 : 11; sc->led_pin = 8; sc->workaround = AR9285_WA_DEFAULT; sc->ops.setup = ar9287_setup; |