#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: armadillo9_pcic.c,v 1.2 2012/10/27 17:17:46 chs Exp $");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/device.h>
#include <arm/ep93xx/epsocvar.h>
#include <arm/ep93xx/epgpiovar.h>
#include <arm/ep93xx/eppcicvar.h>
#ifdef A9PCIC_DEBUG
int armadillo9pcic_debug = A9PCIC_DEBUG;
#define DPRINTFN(n,x) if (armadillo9pcic_debug>(n)) printf x;
#else
#define DPRINTFN(n,x)
#endif
static int armadillo9pcic_match(device_t, cfdata_t, void *);
static void armadillo9pcic_attach(device_t, device_t, void *);
CFATTACH_DECL_NEW(armadillo9pcic, 0,
armadillo9pcic_match, armadillo9pcic_attach, NULL, NULL);
static int armadillo9pcic_card_mode(void *, int);
static int armadillo9pcic_power_capability(void *, int);
static int armadillo9pcic_power_ctl(void *, int, int);
struct eppcic_chipset_tag armadillo9pcic_tag = {
armadillo9pcic_card_mode,
armadillo9pcic_power_capability,
armadillo9pcic_power_ctl
};
static int
armadillo9pcic_match(device_t parent, cfdata_t match, void *aux)
{
return 1;
}
static void
armadillo9pcic_attach(device_t parent, device_t self, void *aux)
{
struct epsoc_attach_args *sa = aux;
epgpio_out(sa->sa_gpio, PORT_A, 3);
eppcic_attach_common(parent, self, aux, &armadillo9pcic_tag);
}
static int
armadillo9pcic_card_mode(void *self, int socket)
{
if (socket == 0)
return CF_MODE;
else
return SLOT_DISABLE;
}
static int
armadillo9pcic_power_capability(void *self, int socket)
{
int vcc = 0;
if (socket == 0)
vcc |= VCC_3V;
return vcc;
}
static int
armadillo9pcic_power_ctl(void *self, int socket, int onoff)
{
struct eppcic_softc *sc = device_private(self);
DPRINTFN(1, ("armadillo9pcic_power_ctl: %s\n",onoff?"on":"off"));
if (onoff)
epgpio_clear(sc->sc_gpio, PORT_A, 3);
else
epgpio_set(sc->sc_gpio, PORT_A, 3);
return (300 * 1000);
}