-put gpio stuff inside #if NGPIO > 0

-kill gba_name in attach arg, specify interface attribute
This commit is contained in:
drochner 2005-10-11 15:58:37 +00:00
parent 0cf2f76f79
commit 69f432c06d
2 changed files with 33 additions and 10 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: elan520.c,v 1.9 2005/10/07 15:59:50 riz Exp $ */
/* $NetBSD: elan520.c,v 1.10 2005/10/11 15:58:37 drochner Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -47,7 +47,7 @@
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: elan520.c,v 1.9 2005/10/07 15:59:50 riz Exp $");
__KERNEL_RCSID(0, "$NetBSD: elan520.c,v 1.10 2005/10/11 15:58:37 drochner Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -63,7 +63,10 @@ __KERNEL_RCSID(0, "$NetBSD: elan520.c,v 1.9 2005/10/07 15:59:50 riz Exp $");
#include <dev/pci/pcidevs.h>
#include "gpio.h"
#if NGPIO > 0
#include <dev/gpio/gpiovar.h>
#endif
#include <arch/i386/pci/elan520reg.h>
@ -81,9 +84,11 @@ struct elansc_softc {
gpio_pin_t sc_gpio_pins[ELANSC_PIO_NPINS];
};
#if NGPIO > 0
static int elansc_gpio_pin_read(void *, int);
static void elansc_gpio_pin_write(void *, int, int);
static void elansc_gpio_pin_ctl(void *, int, int);
#endif
static void
elansc_wdogctl_write(struct elansc_softc *sc, uint16_t val)
@ -226,12 +231,14 @@ elansc_attach(struct device *parent, struct device *self, void *aux)
{
struct elansc_softc *sc = (void *) self;
struct pci_attach_args *pa = aux;
struct gpiobus_attach_args gba;
uint16_t rev;
uint8_t ressta, cpuctl;
#if NGPIO > 0
struct gpiobus_attach_args gba;
int pin;
int reg, shift;
uint16_t data;
#endif
printf(": AMD Elan SC520 System Controller\n");
@ -297,6 +304,7 @@ elansc_attach(struct device *parent, struct device *self, void *aux)
/* ...and clear it. */
elansc_wdogctl_reset(sc);
#if NGPIO > 0
/* Initialize GPIO pins array */
for (pin = 0; pin < ELANSC_PIO_NPINS; pin++) {
sc->sc_gpio_pins[pin].pin_num = pin;
@ -323,18 +331,19 @@ elansc_attach(struct device *parent, struct device *self, void *aux)
sc->sc_gpio_gc.gp_pin_write = elansc_gpio_pin_write;
sc->sc_gpio_gc.gp_pin_ctl = elansc_gpio_pin_ctl;
gba.gba_name = "gpio";
gba.gba_gc = &sc->sc_gpio_gc;
gba.gba_pins = sc->sc_gpio_pins;
gba.gba_npins = ELANSC_PIO_NPINS;
/* Attach GPIO framework */
config_found(&sc->sc_dev, &gba, gpiobus_print);
config_found_ia(&sc->sc_dev, "gpiobus", &gba, gpiobus_print);
#endif /* NGPIO */
}
CFATTACH_DECL(elansc, sizeof(struct elansc_softc),
elansc_match, elansc_attach, NULL, NULL);
#if NGPIO > 0
static int
elansc_gpio_pin_read(void *arg, int pin)
{
@ -384,3 +393,4 @@ elansc_gpio_pin_ctl(void *arg, int pin, int flags)
bus_space_write_2(sc->sc_memt, sc->sc_memh, reg, data);
}
#endif /* NGPIO */

View File

@ -1,4 +1,4 @@
/* $NetBSD: nsclpcsio_isa.c,v 1.11 2005/09/27 02:56:27 jmcneill Exp $ */
/* $NetBSD: nsclpcsio_isa.c,v 1.12 2005/10/11 15:58:38 drochner Exp $ */
/*
* Copyright (c) 2002
@ -27,7 +27,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: nsclpcsio_isa.c,v 1.11 2005/09/27 02:56:27 jmcneill Exp $");
__KERNEL_RCSID(0, "$NetBSD: nsclpcsio_isa.c,v 1.12 2005/10/11 15:58:38 drochner Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -38,7 +38,10 @@ __KERNEL_RCSID(0, "$NetBSD: nsclpcsio_isa.c,v 1.11 2005/09/27 02:56:27 jmcneill
#include <dev/isa/isareg.h>
#include <dev/isa/isavar.h>
#include "gpio.h"
#if NGPIO > 0
#include <dev/gpio/gpiovar.h>
#endif
#include <dev/sysmon/sysmonvar.h>
static int nsclpcsio_isa_match(struct device *, struct cfdata *, void *);
@ -59,9 +62,11 @@ struct nsclpcsio_softc {
struct sysmon_envsys sc_sysmon;
struct simplelock sc_lock;
#if NGPIO > 0
/* GPIO */
struct gpio_chipset_tag sc_gpio_gc;
struct gpio_pin sc_gpio_pins[GPIO_NPINS];
#endif
};
#define GPIO_READ(sc, reg) \
@ -86,11 +91,13 @@ static void tms_update(struct nsclpcsio_softc *, int);
static int tms_gtredata(struct sysmon_envsys *, struct envsys_tre_data *);
static int tms_streinfo(struct sysmon_envsys *, struct envsys_basic_info *);
#if NGPIO > 0
static void nsclpcsio_gpio_init(struct nsclpcsio_softc *);
static void nsclpcsio_gpio_pin_select(struct nsclpcsio_softc *, int);
static void nsclpcsio_gpio_pin_write(void *, int, int);
static int nsclpcsio_gpio_pin_read(void *, int);
static void nsclpcsio_gpio_pin_ctl(void *, int, int);
#endif
static u_int8_t
nsread(iot, ioh, idx)
@ -183,7 +190,9 @@ nsclpcsio_isa_attach(parent, self, aux)
{
struct nsclpcsio_softc *sc = (void *)self;
struct isa_attach_args *ia = aux;
#if NGPIO > 0
struct gpiobus_attach_args gba;
#endif
bus_space_tag_t iot;
bus_space_handle_t ioh;
u_int8_t val;
@ -217,7 +226,9 @@ nsclpcsio_isa_attach(parent, self, aux)
}
printf("%s: GPIO at 0x%x\n", sc->sc_dev.dv_xname, gpio_iobase);
#if NGPIO > 0
nsclpcsio_gpio_init(sc);
#endif
}
nswrite(iot, ioh, 0x07, 0x0e); /* select tms */
@ -287,15 +298,15 @@ nsclpcsio_isa_attach(parent, self, aux)
printf("%s: unable to register with sysmon\n",
sc->sc_dev.dv_xname);
#if NGPIO > 0
/* attach GPIO framework */
if (gpio_iobase != 0) {
gba.gba_name = "gpio";
gba.gba_gc = &sc->sc_gpio_gc;
gba.gba_pins = sc->sc_gpio_pins;
gba.gba_npins = GPIO_NPINS;
config_found(&sc->sc_dev, &gba, NULL);
config_found_ia(&sc->sc_dev, "gpiobus", &gba, NULL);
}
#endif
return;
}
@ -415,6 +426,7 @@ tms_streinfo(sme, info)
return (0);
}
#if NGPIO > 0
static void
nsclpcsio_gpio_pin_select(struct nsclpcsio_softc *sc, int pin)
{
@ -533,3 +545,4 @@ nsclpcsio_gpio_pin_ctl(void *aux, int pin, int flags)
return;
}
#endif /* NGPIO */