#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: gxmci.c,v 1.4 2012/01/21 19:44:28 nonaka Exp $");
#include <sys/param.h>
#include <sys/device.h>
#include <sys/systm.h>
#include <sys/bus.h>
#include <machine/intr.h>
#include <arm/xscale/pxa2x0cpu.h>
#include <arm/xscale/pxa2x0reg.h>
#include <arm/xscale/pxa2x0var.h>
#include <arm/xscale/pxa2x0_gpio.h>
#include <arm/xscale/pxa2x0_mci.h>
#include <dev/sdmmc/sdmmcreg.h>
#if defined(PXAMCI_DEBUG)
#define DPRINTF(s) printf s
#else
#define DPRINTF(s)
#endif
struct gxmci_softc {
struct pxamci_softc sc;
};
static int pxamci_match(device_t, cfdata_t, void *);
static void pxamci_attach(device_t, device_t, void *);
CFATTACH_DECL_NEW(gxmci, sizeof(struct gxmci_softc),
pxamci_match, pxamci_attach, NULL, NULL);
static uint32_t gxmci_get_ocr(void *);
static int gxmci_set_power(void *, uint32_t);
static int gxmci_card_detect(void *);
static int gxmci_write_protect(void *);
static int
pxamci_match(device_t parent, cfdata_t match, void *aux)
{
struct pxaip_attach_args *pxa = aux;
static struct pxa2x0_gpioconf pxa25x_gxmci_gpioconf[] = {
{ 8, GPIO_ALT_FN_1_OUT },
{ 53, GPIO_ALT_FN_1_OUT },
{ -1 }
};
struct pxa2x0_gpioconf *gpioconf;
u_int reg;
int i;
if (strcmp(pxa->pxa_name, match->cf_name) != 0)
return 0;
gpioconf =
CPU_IS_PXA250 ? pxa25x_gxmci_gpioconf : pxa27x_pxamci_gpioconf;
for (i = 0; gpioconf[i].pin != -1; i++) {
reg = pxa2x0_gpio_get_function(gpioconf[i].pin);
if (GPIO_FN(reg) != GPIO_FN(gpioconf[i].value) ||
GPIO_FN_IS_OUT(reg) != GPIO_FN_IS_OUT(gpioconf[i].value))
return 0;
}
pxa->pxa_size = PXA2X0_MMC_SIZE;
return 1;
}
static void
pxamci_attach(device_t parent, device_t self, void *aux)
{
struct gxmci_softc *sc = device_private(self);
struct pxaip_attach_args *pxa = aux;
sc->sc.sc_tag.cookie = sc;
sc->sc.sc_tag.get_ocr = gxmci_get_ocr;
sc->sc.sc_tag.set_power = gxmci_set_power;
sc->sc.sc_tag.card_detect = gxmci_card_detect;
sc->sc.sc_tag.write_protect = gxmci_write_protect;
sc->sc.sc_caps = 0;
if (pxamci_attach_sub(self, pxa)) {
aprint_error_dev(self, "unable to attach MMC controller\n");
}
if (!pmf_device_register(self, NULL, NULL)) {
aprint_error_dev(self, "couldn't establish power handler\n");
}
}
static uint32_t
gxmci_get_ocr(void *arg)
{
return MMC_OCR_3_2V_3_3V|MMC_OCR_3_3V_3_4V;
}
static int
gxmci_set_power(void *arg, uint32_t ocr)
{
return 0;
}
static int
gxmci_card_detect(void *arg)
{
return 1;
}
static int
gxmci_write_protect(void *arg)
{
return 0;
}