Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/hpcarm pcmcia support of SA1110



details:   https://anonhg.NetBSD.org/src/rev/17e9d7cbf620
branches:  trunk
changeset: 512188:17e9d7cbf620
user:      ichiro <ichiro%NetBSD.org@localhost>
date:      Sat Jul 07 15:53:24 2001 +0000

description:
pcmcia support of SA1110

diffstat:

 sys/arch/hpcarm/conf/IPAQ               |   39 +++-
 sys/arch/hpcarm/sa11x0/sa11x0_pcic.c    |  281 ++++++++++++++++++++++++++++++++
 sys/arch/hpcarm/sa11x0/sa11x0_pcicreg.h |   43 ++++
 3 files changed, 357 insertions(+), 6 deletions(-)

diffs (truncated from 396 to 300 lines):

diff -r 3a7cb2c71a35 -r 17e9d7cbf620 sys/arch/hpcarm/conf/IPAQ
--- a/sys/arch/hpcarm/conf/IPAQ Sat Jul 07 15:53:13 2001 +0000
+++ b/sys/arch/hpcarm/conf/IPAQ Sat Jul 07 15:53:24 2001 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: IPAQ,v 1.6 2001/07/07 07:04:56 ichiro Exp $
+#      $NetBSD: IPAQ,v 1.7 2001/07/07 15:53:25 ichiro Exp $
 #
 #      iPAQ H3600 -- Windows-CE based PDA
 #
@@ -130,15 +130,39 @@
 options        CONSPEED=19200
 sacom*  at saip? addr 0xd000d000 size 0x24     intr 17
 
-#OS Timer
+# OS Timer
 saost*  at saip? addr 0x90000000 size 0x20
 
+# Internal LCD controller
 #salcd* at saip?
 #hpcfb* at salcd?
-    
-# Workstation Console attachments
-#wsdisplay*     at      hpcfb? console?
-    
+
+# PCMCIA bus support
+sagpcic*       at saip?
+pcmcia*                at sagpcic?
+
+# PCMCIA serial interfaces
+com*   at pcmcia? function ?           # Modems and serial cards
+
+# PCMCIA IDE controllers and disks
+wdc*   at pcmcia? function ?
+wd*    at wdc?
+
+# PCMCIA network interfaces
+an*    at pcmcia? function ?           # Aironet PC4500/PC4800 (802.11)
+awi*   at pcmcia? function ?           # BayStack 650/660 (802.11FH/DS)
+cnw*   at pcmcia? function ?           # Xircom/Netwave AirSurfer
+ep*    at pcmcia? function ?           # 3Com 3c589 and 3c562 Ethernet
+mbe*   at pcmcia? function ?           # MB8696x based Ethernet
+ne*    at pcmcia? function ?           # NE2000-compatible Ethernet
+ray*   at pcmcia? function ?           # Raytheon Raylink (802.11)
+#sm*   at pcmcia? function ?           # Megahertz Ethernet
+wi*    at pcmcia? function ?           # Lucent WaveLan IEEE (802.11)
+#xi*   at pcmcia? function ?           # Xircom CreditCard Ethernet
+#mhzc* at pcmcia? function ?           # Megahertz Ethernet/Modem combo cards
+#com*  at mhzc?
+#sm*   at mhzc?
+
 # Serial ports
 #com*    at pioc? offset 0x03f8 irq 10
 #com*    at pioc? offset 0x02f8 irq -1
@@ -150,6 +174,9 @@
 #lpt*    at pioc? offset 0x0378 irq -1
 #lpt*    at pioc? offset 0x03bc irq -1
 
+# Workstation Console attachments
+#wsdisplay*     at      hpcfb? console?
+
 pseudo-device  loop    1               # network loopback
 pseudo-device  bpfilter 8              # packet filter
 pseudo-device  sl      2               # CSLIP
diff -r 3a7cb2c71a35 -r 17e9d7cbf620 sys/arch/hpcarm/sa11x0/sa11x0_pcic.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/arch/hpcarm/sa11x0/sa11x0_pcic.c      Sat Jul 07 15:53:24 2001 +0000
@@ -0,0 +1,281 @@
+/*      $NetBSD: sa11x0_pcic.c,v 1.1 2001/07/07 15:53:24 ichiro Exp $        */
+
+/*-
+ * Copyright (c) 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Ichiro FUKUHARA (ichiro%ichiro.org@localhost).
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *        This product includes software developed by the NetBSD
+ *        Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/types.h>
+#include <sys/conf.h>
+#include <sys/file.h>
+#include <sys/device.h>
+#include <sys/kernel.h>
+#include <sys/kthread.h>
+#include <sys/malloc.h>
+
+#include <machine/bus.h>
+#include <dev/pcmcia/pcmciachip.h>
+#include <dev/pcmcia/pcmciavar.h>
+#include <hpcarm/sa11x0/sa11x0_gpioreg.h>
+#include <hpcarm/sa11x0/sa11x0_reg.h>
+#include <hpcarm/sa11x0/sa11x0_var.h>
+#include <hpcarm/sa11x0/sa11x0_pcicreg.h>
+#include <hpcarm/sa11x0/sa11xx_pcicvar.h>
+
+#include "sagpcic.h"
+
+static int     sagpcic_match(struct device *, struct cfdata *, void *);
+static void    sagpcic_attach(struct device *, struct device *, void *);
+static int     sagpcic_print(void *, const char *);
+static int     sagpcic_submatch(struct device *, struct cfdata *, void *);
+
+static int     sagpcic_read(struct sapcic_socket *, int);
+static void    sagpcic_write(struct sapcic_socket *, int, int);
+static void    sagpcic_set_power(struct sapcic_socket *, int);
+static void    sagpcic_clear_intr(int);
+static void    *sagpcic_intr_establish(struct sapcic_socket *, int,
+                                      int (*)(void *), void *);
+static void    sagpcic_intr_disestablish(struct sapcic_socket *, void *);
+
+struct sagpcic_softc {
+       struct sapcic_softc sc_pc;
+       bus_space_handle_t sc_ioh;
+       bus_space_handle_t sc_gpioh;
+       bus_space_handle_t sc_egpioh;
+       
+       struct sapcic_socket sc_socket[2];
+};
+
+static struct sapcic_tag sagpcic_functions = {
+       sagpcic_read,
+       sagpcic_write,
+       sagpcic_set_power,
+       sagpcic_clear_intr,
+       sagpcic_intr_establish,
+       sagpcic_intr_disestablish
+};
+
+struct cfattach sagpcic_ca = {
+       sizeof(struct sagpcic_softc), sagpcic_match, sagpcic_attach
+};
+
+static int
+sagpcic_match(parent, cf, aux)
+       struct device *parent;
+       struct cfdata *cf;
+       void *aux;
+{
+       return (1);
+}
+
+static void
+sagpcic_attach(parent, self, aux)
+       struct device *parent;
+       struct device *self;
+       void *aux;
+{
+       int i;
+       struct pcmciabus_attach_args paa;
+       struct sagpcic_softc *sc = (struct sagpcic_softc *)self;
+       struct sa11x0_softc *psc = (struct sa11x0_softc *)parent;
+
+       printf("\n");
+
+       sc->sc_pc.sc_iot = psc->sc_iot;
+       sc->sc_ioh = psc->sc_ioh;
+
+       sc->sc_gpioh = psc->sc_gpioh;
+       sc->sc_egpioh = psc->sc_egpioh;
+
+       for(i = 0; i < 2; i++) {
+               sc->sc_socket[i].sc = (struct sapcic_softc *)sc;
+               sc->sc_socket[i].socket = i;
+               sc->sc_socket[i].saip_sc = psc;
+               sc->sc_socket[i].sacc_sc = NULL;
+               sc->sc_socket[i].pcictag = &sagpcic_functions;
+               sc->sc_socket[i].pddata = NULL;         /* XXX */
+               sc->sc_socket[i].event_thread = NULL;
+               sc->sc_socket[i].event = 0;
+               sc->sc_socket[i].laststatus = SAPCIC_CARD_INVALID;
+               sc->sc_socket[i].shutdown = 0;
+
+               paa.paa_busname = "pcmcia";
+               paa.pct = (pcmcia_chipset_tag_t)&sa11x0_pcmcia_functions;
+               paa.pch = (pcmcia_chipset_handle_t)&sc->sc_socket[i];
+               paa.iobase = 0;
+               paa.iosize = 0x4000000;
+
+               sc->sc_socket[i].pcmcia =
+                   (struct device *)config_found_sm(&sc->sc_pc.sc_dev,
+                   &paa, sagpcic_print, sagpcic_submatch);
+
+               sa11x0_intr_establish((sa11x0_chipset_tag_t)psc,
+                           i ? IRQ_CD1 : IRQ_CD0,
+                           1, IPL_BIO, sapcic_intr,
+                           &sc->sc_socket[i]);
+
+               /* schedule kthread creation */
+               kthread_create(sapcic_kthread_create, &sc->sc_socket[i]);
+
+#if 0 /* XXX */
+               /* establish_intr should be after creating the kthread */
+               config_interrupt(&sc->sc_socket[i], sacpcic_config_intr);
+#endif
+       }
+}
+
+static int
+sagpcic_print(aux, name)
+       void *aux;
+       const char *name;
+{
+       return (UNCONF);
+}
+
+static int
+sagpcic_submatch(parent, cf, aux)
+       struct device *parent;
+       struct cfdata *cf;
+       void *aux;
+{
+       return (*cf->cf_attach->ca_match)(parent, cf, aux);
+}
+
+
+static int
+sagpcic_read(so, reg)
+       struct sapcic_socket *so;
+       int reg;
+{
+       int cr, bit;
+       struct sagpcic_softc *sc = (struct sagpcic_softc *)so->sc;
+
+       cr = bus_space_read_4(sc->sc_pc.sc_iot, sc->sc_gpioh, SAGPIO_PLR);
+
+       switch (reg) {
+       case SAPCIC_STATUS_CARD:
+       case SAPCIC_STATUS_READY:
+               bit = (so->socket ? GPIO_H3600_PCMCIA_CD1 :
+                               GPIO_H3600_PCMCIA_CD0) & cr;
+               if (bit)
+                       return SAPCIC_CARD_INVALID;
+               else
+                       return SAPCIC_CARD_VALID;
+       case SAPCIC_STATUS_VS1:
+        case SAPCIC_STATUS_VS2:
+       default:
+               panic("sagpcic_read: bogus register\n");
+       }
+}
+
+static void
+sagpcic_write(so, reg, arg)
+       struct sapcic_socket *so;
+       int reg;
+       int arg;
+{
+       int s, value;
+       struct sagpcic_softc *sc = (struct sagpcic_softc *)so->sc;
+
+       s = splhigh();
+       switch (reg) {
+       case SAPCIC_CONTROL_RESET:
+               value = EGPIO_H3600_CARD_RESET;
+               break;
+       case SAPCIC_CONTROL_LINEENABLE:
+       case SAPCIC_CONTROL_WAITENABLE:
+       case SAPCIC_CONTROL_POWERSELECT:
+               break;
+
+       default:
+               splx(s);
+               panic("sagpcic_write: bogus register");
+       }
+       bus_space_write_4(sc->sc_pc.sc_iot, sc->sc_egpioh, 0, value);
+       splx(s);
+}
+               
+static void
+sagpcic_set_power(so, arg)



Home | Main Index | Thread Index | Old Index