From 11555b5da2c46259634ee74c66d36afcaf3c0052 Mon Sep 17 00:00:00 2001 From: Marek Vasut Date: Sat, 15 Aug 2009 00:44:17 +0200 Subject: [PATCH 05/10] PalmLD HDD driver --- sys/arch/palm/conf/RAMDISK | 4 +- sys/arch/palm/conf/files.palm | 10 +++++ sys/arch/palm/dev/palm_hdd.c | 86 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 99 insertions(+), 1 deletions(-) create mode 100644 sys/arch/palm/dev/palm_hdd.c diff --git a/sys/arch/palm/conf/RAMDISK b/sys/arch/palm/conf/RAMDISK index 86d39fb..974b955 100644 --- a/sys/arch/palm/conf/RAMDISK +++ b/sys/arch/palm/conf/RAMDISK @@ -117,8 +117,10 @@ com2 at pxaip? addr 0x40700000 intr 20 # Standard UART (for IrDA) #ne* at pcmcia? #wdc* at pcmcia? +wdc0 at pxaip? + # IDE hard drives -#wd* at wdc? flags 0x0000 +wd* at wdc? flags 0x0000 # PHY #exphy* at mii? # 3Com internal PHYs diff --git a/sys/arch/palm/conf/files.palm b/sys/arch/palm/conf/files.palm index fbdf8ab..96efcf9 100644 --- a/sys/arch/palm/conf/files.palm +++ b/sys/arch/palm/conf/files.palm @@ -37,6 +37,16 @@ file arch/palm/dev/palm_mmc.c pxammc_palm # include "dev/ata/files.ata" +# Drive +#define palmvlio { [port = -1], [size = 0], [iomem = -1], [iosiz = 0], [irq = -1] } +#device palmvlio: palmvlio +#attach palmvlio at pxaip +#file arch/palm/dev/palmvlio.c palmvlio + +#attach wdc at palmvlio with palmhdd +attach wdc at pxaip with palm_hdd +file arch/palm/dev/palm_hdd.c palm_hdd + # Generic MD files file arch/palm/palm/autoconf.c diff --git a/sys/arch/palm/dev/palm_hdd.c b/sys/arch/palm/dev/palm_hdd.c new file mode 100644 index 0000000..7ed3730 --- /dev/null +++ b/sys/arch/palm/dev/palm_hdd.c @@ -0,0 +1,86 @@ +/* + * Marek Vasut '09 + * + * Public domain + * + * */ + +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include +#include + +struct palm_hdd_softc { + struct wdc_softc sc_wdcdev; + struct channel_softc sc_channel; + void *sc_ih; +}; + +int palm_hdd_match(struct device *, void *, void *); +void palm_hdd_attach(struct device *, struct device *, void *); + +struct cfattach palm_hdd_ca = { + sizeof(struct palm_hdd_softc), + palm_hdd_match, + palm_hdd_attach, +}; + +int palm_hdd_match(struct device *parent, void *match, void *aux) +{ + return mach_is_palmld; +} + +void palm_hdd_attach(struct device *parent, struct device *self, void *aux) +{ + struct palm_hdd_softc *sc = (void *)self; + struct channel_softc *chp = &sc->sc_channel; + struct pxaip_attach_args *pxa = aux; + int ret; + + chp->cmd_iot = pxa->pxa_iot; + chp->ctl_iot = pxa->pxa_iot; + + ret = bus_space_map(chp->cmd_iot, 0x20000010, WDC_NREG, + 0, &chp->cmd_ioh); + if (ret) { + printf(": Failed mapping CMD register\n"); + return; + } + + ret = bus_space_map(chp->ctl_iot, 0x2000000e, 2, 0, &chp->ctl_ioh); + if (ret) { + printf(": Failed mapping CTL register\n"); + return; + } + + sc->sc_ih = pxa2x0_gpio_intr_establish(95, IST_EDGE_BOTH, IPL_BIO, wdcintr, chp, self->dv_xname); + + pxa2x0_gpio_set_bit(115); /* PWEN */ + pxa2x0_gpio_clear_bit(98); /* RESET */ + delay(50); + pxa2x0_gpio_set_bit(98); /* RESET */ + delay(50); + + sc->sc_wdcdev.cap |= WDC_CAPABILITY_DATA16 | WDC_CAPABILITY_DMA | WDC_CAPABILITY_SINGLE_DRIVE/* | WDC_CAPABILITY_IRQACK*/; + sc->sc_wdcdev.PIO_cap = 4; + sc->sc_wdcdev.channels = &chp; + sc->sc_wdcdev.nchannels = 1; + + chp->channel = 0; + chp->wdc = &sc->sc_wdcdev; + chp->ch_queue = malloc(sizeof(struct channel_queue), M_DEVBUF, M_NOWAIT); + + printf("\n"); + + wdcattach(chp); + wdc_print_current_modes(chp); +} -- 1.6.3.4