diff options
author | Marek Vasut <marex@cvs.openbsd.org> | 2009-09-05 01:22:12 +0000 |
---|---|---|
committer | Marek Vasut <marex@cvs.openbsd.org> | 2009-09-05 01:22:12 +0000 |
commit | d1cc7e6467991909c848131c2418e5879c85412d (patch) | |
tree | c389ccf0ca21fc4df81f23ef6137508c8421667f /sys/arch/palm/dev | |
parent | fce0339e25d60b70523c3fd6ca778dff89e93720 (diff) |
Palm: initial commit of sys/arch/palm
OK deraadt@
Diffstat (limited to 'sys/arch/palm/dev')
-rw-r--r-- | sys/arch/palm/dev/palm_hdd.c | 86 | ||||
-rw-r--r-- | sys/arch/palm/dev/palm_kpc.c | 91 | ||||
-rw-r--r-- | sys/arch/palm/dev/palm_mmc.c | 90 | ||||
-rw-r--r-- | sys/arch/palm/dev/palm_udc.c | 91 |
4 files changed, 358 insertions, 0 deletions
diff --git a/sys/arch/palm/dev/palm_hdd.c b/sys/arch/palm/dev/palm_hdd.c new file mode 100644 index 00000000000..7ed37302362 --- /dev/null +++ b/sys/arch/palm/dev/palm_hdd.c @@ -0,0 +1,86 @@ +/* + * Marek Vasut '09 + * + * Public domain + * + * */ + +#include <sys/param.h> +#include <sys/device.h> +#include <sys/systm.h> +#include <sys/malloc.h> + +#include <machine/bus.h> +#include <machine/palm_var.h> + +#include <dev/ata/atavar.h> +#include <dev/ic/wdcvar.h> + +#include <arch/arm/xscale/pxa2x0_gpio.h> +#include <arch/arm/xscale/pxa2x0var.h> + +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); +} diff --git a/sys/arch/palm/dev/palm_kpc.c b/sys/arch/palm/dev/palm_kpc.c new file mode 100644 index 00000000000..632cacab55b --- /dev/null +++ b/sys/arch/palm/dev/palm_kpc.c @@ -0,0 +1,91 @@ +#include <sys/param.h> +#include <sys/device.h> +#include <sys/systm.h> + +#include <machine/machine_reg.h> +#include <machine/palm_var.h> +#include <arch/arm/xscale/pxa2x0_gpio.h> + +#include <arch/arm/xscale/pxa27x_kpc.h> + +int palm_kpc_match(struct device *, void *, void *); +void palm_kpc_attach(struct device *, struct device *, void *); + +struct cfattach pxakpc_palm_ca = { + sizeof(struct pxa27x_kpc_softc), + palm_kpc_match, + palm_kpc_attach +}; + +const keysym_t palmkpc_keycodes[] = { + KS_KEYCODE(0), KS_s, + KS_KEYCODE(1), KS_a, + KS_KEYCODE(2), KS_b, + KS_KEYCODE(3), KS_c, + KS_KEYCODE(4), KS_d, + KS_KEYCODE(5), KS_Return, + KS_KEYCODE(6), KS_KP_Up, + KS_KEYCODE(7), KS_KP_Down, + KS_KEYCODE(8), KS_KP_Left, + KS_KEYCODE(9), KS_KP_Right, +}; + +#ifdef WSDISPLAY_COMPAT_RAWKBD +const keysym_t palmkpc_xt_keycodes[] = { + RAWKEY_s, + RAWKEY_a, + RAWKEY_b, + RAWKEY_c, + RAWKEY_d, + RAWKEY_Return, + RAWKEY_KP_Up, + RAWKEY_KP_Down, + RAWKEY_KP_Left, + RAWKEY_KP_Right, +}; +#endif + +const struct pxa27x_kpc_keymap palmkpc_keymap[] = { + {0, 0, 0}, + {0, 1, 1}, + {1, 0, 2}, + {1, 1, 3}, + {1, 2, 4}, + {0, 2, 5}, + {2, 0, 6}, + {2, 2, 7}, + {3, 2, 8}, + {3, 0, 9}, +}; + +int +palm_kpc_match(struct device *parent, void *match, void *aux) +{ + return pxa27x_kpc_match(); +} + +void +palm_kpc_attach(struct device *parent, struct device *self, void *aux) +{ + struct pxa27x_kpc_softc *sc = (struct pxa27x_kpc_softc *)self; + + pxa2x0_gpio_set_function(100, GPIO_ALT_FN_1_IN); + pxa2x0_gpio_set_function(101, GPIO_ALT_FN_1_IN); + pxa2x0_gpio_set_function(102, GPIO_ALT_FN_1_IN); + pxa2x0_gpio_set_function(97, GPIO_ALT_FN_3_IN); + + pxa2x0_gpio_set_function(103, GPIO_ALT_FN_2_OUT); + pxa2x0_gpio_set_function(104, GPIO_ALT_FN_2_OUT); + pxa2x0_gpio_set_function(105, GPIO_ALT_FN_2_OUT); + + sc->sc_rows = 4; + sc->sc_cols = 3; + sc->sc_kmap = palmkpc_keymap; + sc->sc_kcodes = palmkpc_keycodes; +#ifdef WSDISPLAY_COMPAT_RAWKBD + sc->sc_xt_kcodes = palmkpc_xt_keycodes; +#endif + sc->sc_ksize = sizeof(palmkpc_keycodes)/sizeof(keysym_t); + + pxa27x_kpc_attach(sc, aux); +} diff --git a/sys/arch/palm/dev/palm_mmc.c b/sys/arch/palm/dev/palm_mmc.c new file mode 100644 index 00000000000..e9a15d497bb --- /dev/null +++ b/sys/arch/palm/dev/palm_mmc.c @@ -0,0 +1,90 @@ +/* $OpenBSD: palm_mmc.c,v 1.1 2009/09/05 01:22:11 marex Exp $ */ + +/* + * Copyright (c) 2009 Marek Vasut <marex@openbsd.org> + * Copyright (c) 2007 Uwe Stuehler <uwe@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* Attachment driver for pxammc(4) on Palm */ + +#include <sys/param.h> +#include <sys/device.h> +#include <sys/systm.h> + +#include <dev/sdmmc/sdmmcreg.h> +#include <machine/machine_reg.h> +#include <machine/palm_var.h> +#include <arch/arm/xscale/pxa2x0_gpio.h> + +#include <arch/arm/xscale/pxammcvar.h> + +int palm_mmc_match(struct device *, void *, void *); +void palm_mmc_attach(struct device *, struct device *, void *); + +struct cfattach pxammc_palm_ca = { + sizeof(struct pxammc_softc), + palm_mmc_match, + palm_mmc_attach +}; + +u_int32_t palm_mmc_get_ocr(void *); +int palm_mmc_set_power(void *, u_int32_t); + +int +palm_mmc_match(struct device *parent, void *match, void *aux) +{ + return pxammc_match(); +} + +void +palm_mmc_attach(struct device *parent, struct device *self, void *aux) +{ + struct pxammc_softc *sc = (struct pxammc_softc *)self; + + sc->tag.cookie = (void *)sc; + sc->tag.get_ocr = palm_mmc_get_ocr; + sc->tag.set_power = palm_mmc_set_power; + + sc->sc_gpio_detect = GPIO14_MMC_DETECT; + + pxammc_attach(sc, aux); +} + +u_int32_t +palm_mmc_get_ocr(void *cookie) +{ + return MMC_OCR_3_2V_3_3V | MMC_OCR_3_3V_3_4V; +} + +int +palm_mmc_set_power(void *cookie, u_int32_t ocr) +{ + if (ISSET(ocr, MMC_OCR_3_2V_3_3V | MMC_OCR_3_3V_3_4V)) { + if (mach_is_palmz72) + pxa2x0_gpio_clear_bit(GPIO98_PALMZ72_MMC_POWER); + else + pxa2x0_gpio_set_bit(GPIO114_MMC_POWER); + return 0; + } else if (ocr != 0) { + printf("palm_mmc_set_power: unsupported OCR (%#x)\n", ocr); + return EINVAL; + } else { + if (mach_is_palmz72) + pxa2x0_gpio_set_bit(GPIO98_PALMZ72_MMC_POWER); + else + pxa2x0_gpio_clear_bit(GPIO114_MMC_POWER); + return 0; + } +} diff --git a/sys/arch/palm/dev/palm_udc.c b/sys/arch/palm/dev/palm_udc.c new file mode 100644 index 00000000000..fd59dba9aee --- /dev/null +++ b/sys/arch/palm/dev/palm_udc.c @@ -0,0 +1,91 @@ +/* $OpenBSD: palm_udc.c,v 1.1 2009/09/05 01:22:11 marex Exp $ */ + +/* + * Copyright (c) 2009 Marek Vasut <marex@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include <sys/param.h> +#include <sys/device.h> +#include <sys/systm.h> +#include <sys/timeout.h> + +#include <dev/sdmmc/sdmmcreg.h> +#include <machine/machine_reg.h> +#include <machine/palm_var.h> + +#include <dev/usb/usb.h> +#include <dev/usb/usbdi.h> +#include <dev/usb/usbdivar.h> +#include <dev/usb/usbf.h> +#include <dev/usb/usbfvar.h> + +#include <arch/arm/xscale/pxa2x0_gpio.h> +#include <arch/arm/xscale/pxa27x_udc.h> + +int palm_udc_match(struct device *, void *, void *); +void palm_udc_attach(struct device *, struct device *, void *); +int palm_udc_detach(struct device *, int); +int palm_udc_is_host(void); + +struct cfattach pxaudc_palm_ca = { + sizeof(struct pxaudc_softc), + palm_udc_match, + palm_udc_attach, + palm_udc_detach, +}; + +int +palm_udc_match(struct device *parent, void *match, void *aux) +{ + if (mach_is_palmld) + return 0; + return pxaudc_match(); +} + +int +palm_udc_is_host(void) +{ + return 1; +} + +void +palm_udc_attach(struct device *parent, struct device *self, void *aux) +{ + struct pxaudc_softc *sc = (struct pxaudc_softc *)self; + + if (mach_is_palmtx) + sc->sc_gpio_detect = GPIO13_PALMTX_USB_DETECT; + else if (mach_is_palmt5 || mach_is_palmz72) + sc->sc_gpio_detect = GPIO15_USB_DETECT; + else { + printf(": No suitable GPIO setup found\n"); + return; + } + + sc->sc_gpio_detect_inv = 1; + sc->sc_gpio_pullup = GPIO95_USB_PULLUP; + sc->sc_gpio_pullup_inv = 0; + sc->sc_is_host = palm_udc_is_host; + + pxaudc_attach(sc, aux); +} + +int +palm_udc_detach(struct device *self, int flags) +{ + struct pxaudc_softc *sc = (struct pxaudc_softc *)self; + + return pxaudc_detach(sc, flags); +} |