Annotation of sys/arch/jornada/dev/sacpcic_jornada.c, Revision 1.1
1.1 ! nbrk 1: /* $NetBSD: j720pcic.c,v 1.4 2006/03/04 13:57:11 peter Exp $ */
! 2:
! 3: /*-
! 4: * Copyright (c) 2001 The NetBSD Foundation, Inc.
! 5: * All rights reserved.
! 6: *
! 7: * This code is derived from software contributed to The NetBSD Foundation
! 8: * by IWAMOTO Toshihiro.
! 9: *
! 10: * Redistribution and use in source and binary forms, with or without
! 11: * modification, are permitted provided that the following conditions
! 12: * are met:
! 13: * 1. Redistributions of source code must retain the above copyright
! 14: * notice, this list of conditions and the following disclaimer.
! 15: * 2. Redistributions in binary form must reproduce the above copyright
! 16: * notice, this list of conditions and the following disclaimer in the
! 17: * documentation and/or other materials provided with the distribution.
! 18: * 3. All advertising materials mentioning features or use of this software
! 19: * must display the following acknowledgement:
! 20: * This product includes software developed by the NetBSD
! 21: * Foundation, Inc. and its contributors.
! 22: * 4. Neither the name of The NetBSD Foundation nor the names of its
! 23: * contributors may be used to endorse or promote products derived
! 24: * from this software without specific prior written permission.
! 25: *
! 26: * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
! 27: * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
! 28: * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
! 29: * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
! 30: * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
! 31: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
! 32: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
! 33: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
! 34: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
! 35: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
! 36: * POSSIBILITY OF SUCH DAMAGE.
! 37: */
! 38:
! 39: /* Jornada 720 PCMCIA support. */
! 40:
! 41: #include <sys/cdefs.h>
! 42:
! 43: #include <sys/param.h>
! 44: #include <sys/systm.h>
! 45: #include <sys/types.h>
! 46: #include <sys/conf.h>
! 47: #include <sys/file.h>
! 48: #include <sys/device.h>
! 49: #include <sys/kernel.h>
! 50: #include <sys/kthread.h>
! 51: #include <sys/malloc.h>
! 52: #include <sys/mutex.h>
! 53:
! 54: #include <dev/pcmcia/pcmciachip.h>
! 55: #include <dev/pcmcia/pcmciavar.h>
! 56:
! 57: #include <arm/sa11x0/sa11x0_reg.h>
! 58: #include <arm/sa11x0/sa11x0_var.h>
! 59: #include <arm/sa11x0/sa1111_reg.h>
! 60: #include <arm/sa11x0/sa11x1_var.h>
! 61: #include <arm/sa11x0/sa11x1_pcicreg.h>
! 62: #include <arm/sa11x0/sa11xx_pcicvar.h>
! 63: #include <arm/sa11x0/sa11x1_pcicvar.h>
! 64:
! 65: //#include "jpcic.h"
! 66:
! 67: static int sacpcic_jornada_match(struct device *, void *, void *);
! 68: static void sacpcic_jornada_attach(struct device *, struct device *, void *);
! 69:
! 70: static void j720_socket_setup(struct sapcic_socket *);
! 71: static void j720_set_power(struct sapcic_socket *, int);
! 72:
! 73: static struct sapcic_tag j720_sacpcic_functions = {
! 74: sacpcic_read,
! 75: sacpcic_write,
! 76: j720_set_power,
! 77: sacpcic_clear_intr,
! 78: sacpcic_intr_establish,
! 79: sacpcic_intr_disestablish
! 80: };
! 81:
! 82: #if 0
! 83: static int j720_power_capability[] = {
! 84: SAPCIC_POWER_5V | SAPCIC_POWER_3V, SAPCIC_POWER_3V
! 85: };
! 86: #endif
! 87:
! 88: /*
! 89: * Autoconf glue.
! 90: */
! 91: struct cfattach sacpcic_jornada_ca = {
! 92: sizeof(struct sacpcic_softc),
! 93: sacpcic_jornada_match,
! 94: sacpcic_jornada_attach,
! 95: NULL,
! 96: NULL
! 97: };
! 98:
! 99:
! 100: static int
! 101: sacpcic_jornada_match(struct device *parent, void *cdata, void *aux)
! 102: {
! 103:
! 104: return 1;
! 105: }
! 106:
! 107: static void
! 108: sacpcic_jornada_attach(struct device *parent, struct device *self, void *aux)
! 109: {
! 110:
! 111: sacpcic_attach_common((struct sacc_softc *)parent,
! 112: (struct sacpcic_softc *)self, aux, j720_socket_setup);
! 113: }
! 114:
! 115: static void
! 116: j720_socket_setup(struct sapcic_socket *sp)
! 117: {
! 118: /* XXX */
! 119:
! 120: sp->power_capability = SAPCIC_POWER_5V;
! 121:
! 122: sp->pcictag = &j720_sacpcic_functions;
! 123: }
! 124:
! 125: static void
! 126: j720_set_power(struct sapcic_socket *so, int arg)
! 127: {
! 128: int newval, oldval, s;
! 129: struct sacc_softc *sc = so->pcictag_cookie;
! 130:
! 131: /* XXX this isn't well confirmed. DANGER DANGER */
! 132: switch (arg) {
! 133: case SAPCIC_POWER_OFF:
! 134: newval = 0;
! 135: break;
! 136: case SAPCIC_POWER_3V:
! 137: newval = 2;
! 138: break;
! 139: case SAPCIC_POWER_5V:
! 140: newval = 1;
! 141: break;
! 142: default:
! 143: panic("j720_set_power: bogus arg (%d)", arg);
! 144: }
! 145:
! 146: s = splbio();
! 147: oldval = bus_space_read_4(sc->sc_bust, sc->sc_ioh, SACCGPIOA_DVR);
! 148: printf("j720_set_power: bus_space_read_4\n");
! 149:
! 150: switch (so->socket) {
! 151: case 0:
! 152: newval = newval | (oldval & 0xc);
! 153: break;
! 154: case 1:
! 155: newval = (newval << 2) | (oldval & 3);
! 156: break;
! 157: default:
! 158: splx(s);
! 159: panic("j720_set_power: bogus socket (%d)", so->socket);
! 160: }
! 161: bus_space_write_4(sc->sc_bust, sc->sc_ioh, SACCGPIOA_DVR, newval);
! 162: printf("j720_set_power: bus_space_write_4\n");
! 163:
! 164: splx(s);
! 165: }
CVSweb