Home | History | Annotate | Line # | Download | only in sa11x0
sa11xx_pcic.c revision 1.6.6.1
      1  1.6.6.1   simonb /*	$NetBSD: sa11xx_pcic.c,v 1.6.6.1 2006/04/22 11:37:17 simonb Exp $	*/
      2      1.1      rjs 
      3      1.1      rjs /*
      4      1.1      rjs  * Copyright (c) 2001 IWAMOTO Toshihiro.  All rights reserved.
      5      1.1      rjs  * Copyright (c) 1997 Marc Horowitz.  All rights reserved.
      6      1.1      rjs  *
      7      1.1      rjs  * Redistribution and use in source and binary forms, with or without
      8      1.1      rjs  * modification, are permitted provided that the following conditions
      9      1.1      rjs  * are met:
     10      1.1      rjs  * 1. Redistributions of source code must retain the above copyright
     11      1.1      rjs  *    notice, this list of conditions and the following disclaimer.
     12      1.1      rjs  * 2. Redistributions in binary form must reproduce the above copyright
     13      1.1      rjs  *    notice, this list of conditions and the following disclaimer in the
     14      1.1      rjs  *    documentation and/or other materials provided with the distribution.
     15      1.1      rjs  * 3. All advertising materials mentioning features or use of this software
     16      1.1      rjs  *    must display the following acknowledgement:
     17      1.1      rjs  *	This product includes software developed by Marc Horowitz.
     18      1.1      rjs  * 4. The name of the author may not be used to endorse or promote products
     19      1.1      rjs  *    derived from this software without specific prior written permission.
     20      1.1      rjs  *
     21      1.1      rjs  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     22      1.1      rjs  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     23      1.1      rjs  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     24      1.1      rjs  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     25      1.1      rjs  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     26      1.1      rjs  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     27      1.1      rjs  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     28      1.1      rjs  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     29      1.1      rjs  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     30      1.1      rjs  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     31      1.1      rjs  */
     32      1.1      rjs 
     33      1.1      rjs /*
     34      1.1      rjs  * Common code for SA11x0 based PCMCIA modules
     35      1.1      rjs  */
     36      1.4    lukem 
     37      1.4    lukem #include <sys/cdefs.h>
     38  1.6.6.1   simonb __KERNEL_RCSID(0, "$NetBSD: sa11xx_pcic.c,v 1.6.6.1 2006/04/22 11:37:17 simonb Exp $");
     39      1.1      rjs 
     40      1.1      rjs #include <sys/types.h>
     41      1.1      rjs #include <sys/param.h>
     42      1.1      rjs #include <sys/systm.h>
     43      1.1      rjs #include <sys/device.h>
     44      1.1      rjs #include <sys/callout.h>
     45      1.1      rjs #include <sys/kernel.h>
     46      1.1      rjs #include <sys/kthread.h>
     47      1.1      rjs #include <sys/malloc.h>
     48      1.1      rjs #include <uvm/uvm.h>
     49      1.1      rjs 
     50      1.1      rjs #include <machine/bus.h>
     51      1.1      rjs #include <machine/intr.h>
     52      1.1      rjs 
     53      1.1      rjs #include <dev/pcmcia/pcmciareg.h>
     54      1.1      rjs #include <dev/pcmcia/pcmciavar.h>
     55      1.1      rjs #include <dev/pcmcia/pcmciachip.h>
     56      1.1      rjs 
     57      1.1      rjs #include <arm/sa11x0/sa11x0_reg.h>
     58      1.1      rjs #include <arm/sa11x0/sa11x0_var.h>
     59      1.1      rjs #include <arm/sa11x0/sa11xx_pcicreg.h>
     60      1.1      rjs #include <arm/sa11x0/sa11xx_pcicvar.h>
     61      1.1      rjs 
     62      1.1      rjs static	int	sapcic_mem_alloc(pcmcia_chipset_handle_t, bus_size_t,
     63      1.1      rjs 					struct pcmcia_mem_handle *);
     64      1.1      rjs static	void	sapcic_mem_free(pcmcia_chipset_handle_t,
     65      1.1      rjs 				       struct pcmcia_mem_handle *);
     66      1.1      rjs static	int	sapcic_mem_map(pcmcia_chipset_handle_t, int, bus_addr_t,
     67      1.1      rjs 				      bus_size_t, struct pcmcia_mem_handle *,
     68      1.1      rjs 				      bus_addr_t *, int *);
     69      1.1      rjs static	void	sapcic_mem_unmap(pcmcia_chipset_handle_t, int);
     70      1.1      rjs static	int	sapcic_io_alloc(pcmcia_chipset_handle_t, bus_addr_t,
     71      1.1      rjs 				       bus_size_t, bus_size_t,
     72      1.1      rjs 				       struct pcmcia_io_handle *);
     73      1.1      rjs static	void	sapcic_io_free(pcmcia_chipset_handle_t,
     74      1.1      rjs 				      struct pcmcia_io_handle *);
     75      1.1      rjs static	int	sapcic_io_map(pcmcia_chipset_handle_t, int,
     76      1.1      rjs 				     bus_addr_t, bus_size_t,
     77      1.1      rjs 				     struct pcmcia_io_handle *, int *);
     78      1.1      rjs static	void	sapcic_io_unmap(pcmcia_chipset_handle_t, int);
     79      1.1      rjs static	void	*sapcic_intr_establish(pcmcia_chipset_handle_t,
     80      1.1      rjs 					      struct pcmcia_function *, int,
     81      1.1      rjs 					      int (*)(void *), void *);
     82      1.1      rjs static	void	sapcic_intr_disestablish(pcmcia_chipset_handle_t,
     83      1.1      rjs 						void *);
     84      1.1      rjs static	void	sapcic_socket_enable(pcmcia_chipset_handle_t);
     85      1.1      rjs static	void	sapcic_socket_disable(pcmcia_chipset_handle_t);
     86      1.5   toshii static	void	sapcic_socket_settype(pcmcia_chipset_handle_t, int);
     87      1.1      rjs 
     88      1.1      rjs static	void	sapcic_event_thread(void *);
     89      1.1      rjs 
     90      1.1      rjs static	void	sapcic_delay(int, const char *);
     91      1.1      rjs 
     92      1.1      rjs #ifdef DEBUG
     93      1.1      rjs #define DPRINTF(arg)	printf arg
     94      1.1      rjs #else
     95      1.1      rjs #define DPRINTF(arg)
     96      1.1      rjs #endif
     97      1.1      rjs 
     98      1.1      rjs struct pcmcia_chip_functions sa11x0_pcmcia_functions = {
     99      1.1      rjs 	sapcic_mem_alloc,
    100      1.1      rjs 	sapcic_mem_free,
    101      1.1      rjs 	sapcic_mem_map,
    102      1.1      rjs 	sapcic_mem_unmap,
    103      1.1      rjs 
    104      1.1      rjs 	sapcic_io_alloc,
    105      1.1      rjs 	sapcic_io_free,
    106      1.1      rjs 	sapcic_io_map,
    107      1.1      rjs 	sapcic_io_unmap,
    108      1.1      rjs 
    109      1.1      rjs 	sapcic_intr_establish,
    110      1.1      rjs 	sapcic_intr_disestablish,
    111      1.1      rjs 
    112      1.1      rjs 	sapcic_socket_enable,
    113      1.1      rjs 	sapcic_socket_disable,
    114      1.5   toshii 	sapcic_socket_settype,
    115      1.1      rjs };
    116      1.1      rjs 
    117      1.1      rjs 
    118      1.1      rjs void
    119  1.6.6.1   simonb sapcic_kthread_create(void *arg)
    120      1.1      rjs {
    121      1.1      rjs 	struct sapcic_socket *so = arg;
    122      1.1      rjs 
    123      1.1      rjs 	/* XXX attach card if already present */
    124      1.1      rjs 
    125      1.1      rjs 	so->laststatus =(so->pcictag->read)(so, SAPCIC_STATUS_CARD);
    126      1.1      rjs 	if (so->laststatus == SAPCIC_CARD_VALID) {
    127      1.1      rjs 		printf("%s: card present\n",
    128      1.1      rjs 		       so->sc->sc_dev.dv_xname);
    129      1.1      rjs 
    130      1.1      rjs 		pcmcia_card_attach(so->pcmcia);
    131      1.1      rjs 	}
    132      1.1      rjs 
    133      1.1      rjs 	if (kthread_create1(sapcic_event_thread, so, &so->event_thread,
    134      1.1      rjs 			    "%s,%d", so->sc->sc_dev.dv_xname, so->socket)) {
    135      1.1      rjs 		printf("%s: unable to create event thread for socket %d\n",
    136      1.1      rjs 		       so->sc->sc_dev.dv_xname, so->socket);
    137      1.1      rjs 		panic("sapcic_kthread_create");
    138      1.1      rjs 	}
    139      1.1      rjs }
    140      1.1      rjs 
    141      1.1      rjs static void
    142  1.6.6.1   simonb sapcic_event_thread(void *arg)
    143      1.1      rjs {
    144      1.1      rjs 	struct sapcic_socket *so = arg;
    145      1.1      rjs 	int newstatus, s;
    146      1.1      rjs 
    147      1.1      rjs 	while (so->shutdown == 0) {
    148      1.1      rjs 		/*
    149      1.1      rjs 		 * Serialize event processing on the PCIC.  We may
    150      1.1      rjs 		 * sleep while we hold this lock.
    151      1.1      rjs 		 */
    152      1.1      rjs 		(void) lockmgr(&so->sc->sc_lock, LK_EXCLUSIVE, NULL);
    153      1.1      rjs 
    154      1.1      rjs 		/* sleep .25s to be enqueued chatterling interrupts */
    155      1.1      rjs 		(void) tsleep((caddr_t)sapcic_event_thread, PWAIT,
    156      1.1      rjs 			      "pcicss", hz/4);
    157      1.1      rjs 
    158      1.1      rjs 		s = splhigh();
    159      1.1      rjs 		so->event = 0;
    160      1.1      rjs 
    161      1.1      rjs 		/* we don't rely on interrupt type */
    162      1.1      rjs 		newstatus = (so->pcictag->read)(so, SAPCIC_STATUS_CARD);
    163      1.1      rjs 		splx(s);
    164      1.1      rjs 
    165      1.1      rjs 		if (so->laststatus == newstatus) {
    166      1.1      rjs 			/*
    167      1.1      rjs 			 * No events to process; release the PCIC lock.
    168      1.1      rjs 			 */
    169      1.1      rjs 			(void) lockmgr(&so->sc->sc_lock, LK_RELEASE, NULL);
    170      1.1      rjs 			(void) tsleep(&so->event, PWAIT, "pcicev", hz);
    171      1.1      rjs 			continue;
    172      1.1      rjs 		}
    173      1.1      rjs 
    174      1.1      rjs 		so->laststatus = newstatus;
    175      1.1      rjs 		switch (newstatus) {
    176      1.1      rjs 		case SAPCIC_CARD_VALID:
    177      1.1      rjs 			printf("%s: insertion event\n",
    178      1.1      rjs 			       so->sc->sc_dev.dv_xname);
    179      1.1      rjs 
    180      1.1      rjs 			pcmcia_card_attach(so->pcmcia);
    181      1.1      rjs 			break;
    182      1.1      rjs 
    183      1.1      rjs 		case SAPCIC_CARD_INVALID:
    184      1.1      rjs 			printf("%s: removal event\n",
    185      1.1      rjs 			       so->sc->sc_dev.dv_xname);
    186      1.1      rjs 
    187      1.1      rjs 			pcmcia_card_detach(so->pcmcia, DETACH_FORCE);
    188      1.1      rjs 			break;
    189      1.1      rjs 
    190      1.1      rjs 		default:
    191      1.1      rjs 			panic("sapcic_event_thread: unknown status %d",
    192      1.1      rjs 			    newstatus);
    193      1.1      rjs 		}
    194      1.1      rjs 
    195      1.1      rjs 		(void) lockmgr(&so->sc->sc_lock, LK_RELEASE, NULL);
    196      1.1      rjs 	}
    197      1.1      rjs 
    198      1.1      rjs 	so->event_thread = NULL;
    199      1.1      rjs 
    200      1.1      rjs 	/* In case parent is waiting for us to exit. */
    201      1.1      rjs 	wakeup(so->sc);
    202      1.1      rjs 
    203      1.1      rjs 	kthread_exit(0);
    204      1.1      rjs }
    205      1.1      rjs 
    206      1.1      rjs static void
    207  1.6.6.1   simonb sapcic_delay(int timo, const char *wmesg)
    208      1.1      rjs {
    209      1.1      rjs #ifdef DIAGNOSTIC
    210      1.3  thorpej 	if (curlwp == NULL)
    211      1.2   provos 		panic("sapcic_delay: called in interrupt context");
    212      1.1      rjs #endif
    213      1.1      rjs 
    214      1.1      rjs 	tsleep(sapcic_delay, PWAIT, wmesg, roundup(timo * hz, 1000) / 1000);
    215      1.1      rjs }
    216      1.1      rjs 
    217      1.1      rjs int
    218  1.6.6.1   simonb sapcic_intr(void *arg)
    219      1.1      rjs {
    220      1.1      rjs 	struct sapcic_socket *so = arg;
    221      1.1      rjs 
    222      1.1      rjs 	so->event++;
    223      1.1      rjs 	(so->pcictag->clear_intr)(so->socket);
    224      1.1      rjs 	wakeup(&so->event);
    225      1.1      rjs 	return 1;
    226      1.1      rjs }
    227      1.1      rjs 
    228      1.1      rjs static int
    229  1.6.6.1   simonb sapcic_mem_alloc(pcmcia_chipset_handle_t pch, bus_size_t size,
    230  1.6.6.1   simonb     struct pcmcia_mem_handle *pmh)
    231      1.1      rjs {
    232      1.1      rjs 	struct sapcic_socket *so = pch;
    233      1.1      rjs 
    234      1.1      rjs 	/* All we need is bus space tag */
    235      1.1      rjs 	memset(pmh, 0, sizeof(*pmh));
    236      1.1      rjs 	pmh->memt = so->sc->sc_iot;
    237      1.1      rjs 	return (0);
    238      1.1      rjs }
    239      1.1      rjs 
    240      1.1      rjs 
    241      1.1      rjs static void
    242  1.6.6.1   simonb sapcic_mem_free(pcmcia_chipset_handle_t pch, struct pcmcia_mem_handle *pmh)
    243      1.1      rjs {
    244      1.1      rjs }
    245      1.1      rjs 
    246      1.1      rjs static int
    247  1.6.6.1   simonb sapcic_mem_map(pcmcia_chipset_handle_t pch, int kind, bus_addr_t card_addr,
    248  1.6.6.1   simonb     bus_size_t size, struct pcmcia_mem_handle *pmh, bus_addr_t *offsetp,
    249  1.6.6.1   simonb     int *windowp)
    250      1.1      rjs {
    251      1.1      rjs 	struct sapcic_socket *so = pch;
    252      1.1      rjs 	int error;
    253      1.1      rjs 	bus_addr_t pa;
    254      1.1      rjs 
    255      1.1      rjs 	pa = trunc_page(card_addr);
    256      1.1      rjs 	*offsetp = card_addr - pa;
    257      1.1      rjs 	size = round_page(card_addr + size) - pa;
    258      1.1      rjs 	pmh->realsize = size;
    259      1.1      rjs 
    260      1.1      rjs 	pa += SAPCIC_BASE_OFFSET;
    261      1.1      rjs 	pa += SAPCIC_SOCKET_OFFSET * so->socket;
    262      1.1      rjs 
    263      1.1      rjs 	switch (kind & ~PCMCIA_WIDTH_MEM_MASK) {
    264      1.1      rjs 	case PCMCIA_MEM_ATTR:
    265      1.1      rjs 		pa += SAPCIC_ATTR_OFFSET;
    266      1.1      rjs 		break;
    267      1.1      rjs 	case PCMCIA_MEM_COMMON:
    268      1.1      rjs 		pa += SAPCIC_COMMON_OFFSET;
    269      1.1      rjs 		break;
    270      1.1      rjs 	default:
    271      1.2   provos 		panic("sapcic_mem_map: bogus kind");
    272      1.1      rjs 	}
    273      1.1      rjs 
    274      1.1      rjs 	error = bus_space_map(so->sc->sc_iot, pa, size, 0, &pmh->memh);
    275      1.1      rjs 	if (! error)
    276      1.1      rjs 		*windowp = (int)pmh->memh;
    277      1.1      rjs 	return (error);
    278      1.1      rjs }
    279      1.1      rjs 
    280      1.1      rjs static void
    281  1.6.6.1   simonb sapcic_mem_unmap(pcmcia_chipset_handle_t pch, int window)
    282      1.1      rjs {
    283      1.1      rjs 	struct sapcic_socket *so = pch;
    284      1.1      rjs 
    285      1.1      rjs 	bus_space_unmap(so->sc->sc_iot, (bus_addr_t)window, 4096); /* XXX */
    286      1.1      rjs }
    287      1.1      rjs 
    288      1.1      rjs static int
    289  1.6.6.1   simonb sapcic_io_alloc(pcmcia_chipset_handle_t pch, bus_addr_t start,
    290  1.6.6.1   simonb     bus_size_t size, bus_size_t align, struct pcmcia_io_handle *pih)
    291      1.1      rjs {
    292      1.1      rjs 	struct sapcic_socket *so = pch;
    293      1.1      rjs 	int error;
    294      1.1      rjs 	bus_addr_t pa;
    295      1.1      rjs 
    296      1.1      rjs 	memset(pih, 0, sizeof(*pih));
    297      1.1      rjs 	pih->iot = so->sc->sc_iot;
    298      1.1      rjs 	pih->addr = start;
    299      1.1      rjs 	pih->size = size;
    300      1.1      rjs 
    301      1.1      rjs 	pa = pih->addr;
    302      1.1      rjs 	pa += SAPCIC_BASE_OFFSET;
    303      1.1      rjs 	pa += SAPCIC_SOCKET_OFFSET * so->socket;
    304      1.1      rjs 
    305      1.1      rjs 	DPRINTF(("sapcic_io_alloc: %x %x\n", (unsigned int)pa,
    306      1.1      rjs 		 (unsigned int)size));
    307      1.1      rjs 	/* XXX Are we ignoring alignment constraints? */
    308      1.1      rjs 	error = bus_space_map(so->sc->sc_iot, pa, size, 0, &pih->ioh);
    309      1.1      rjs 
    310      1.1      rjs 	return (error);
    311      1.1      rjs }
    312      1.1      rjs 
    313      1.1      rjs static void
    314  1.6.6.1   simonb sapcic_io_free(pcmcia_chipset_handle_t pch, struct pcmcia_io_handle *pih)
    315      1.1      rjs {
    316      1.1      rjs 	struct sapcic_socket *so = pch;
    317      1.1      rjs 
    318      1.1      rjs 	bus_space_unmap(so->sc->sc_iot, pih->ioh, pih->size);
    319      1.1      rjs }
    320      1.1      rjs 
    321      1.1      rjs static int
    322  1.6.6.1   simonb sapcic_io_map(pcmcia_chipset_handle_t pch, int width, bus_addr_t offset,
    323  1.6.6.1   simonb     bus_size_t size, struct pcmcia_io_handle *pih, int *windowp)
    324      1.1      rjs {
    325      1.1      rjs 	return (0);
    326      1.1      rjs }
    327      1.1      rjs 
    328  1.6.6.1   simonb static void sapcic_io_unmap(pcmcia_chipset_handle_t pch, int window)
    329      1.1      rjs {
    330      1.1      rjs }
    331      1.1      rjs 
    332      1.1      rjs static void *
    333  1.6.6.1   simonb sapcic_intr_establish(pcmcia_chipset_handle_t pch, struct pcmcia_function *pf,
    334  1.6.6.1   simonb     int ipl, int (*fct)(void *), void *arg)
    335      1.1      rjs {
    336      1.1      rjs 	struct sapcic_socket *so = pch;
    337      1.1      rjs 
    338      1.1      rjs 	/* XXX need to check if something should be done here */
    339      1.1      rjs 
    340      1.1      rjs 	return ((so->pcictag->intr_establish)(so, ipl, fct, arg));
    341      1.1      rjs }
    342      1.1      rjs 
    343      1.1      rjs static void
    344  1.6.6.1   simonb sapcic_intr_disestablish(pcmcia_chipset_handle_t pch, void *ih)
    345      1.1      rjs {
    346      1.1      rjs 	struct sapcic_socket *so = pch;
    347      1.1      rjs 
    348      1.1      rjs 	((so->pcictag->intr_disestablish)(so, ih));
    349      1.1      rjs }
    350      1.1      rjs 
    351      1.1      rjs static void
    352  1.6.6.1   simonb sapcic_socket_enable(pcmcia_chipset_handle_t pch)
    353      1.1      rjs {
    354      1.1      rjs 	struct sapcic_socket *so = pch;
    355      1.1      rjs 	int i;
    356      1.1      rjs 
    357      1.1      rjs #if defined(DIAGNOSTIC) && defined(notyet)
    358      1.1      rjs 	if (so->flags & PCIC_FLAG_ENABLED)
    359      1.1      rjs 		printf("sapcic_socket_enable: enabling twice\n");
    360      1.1      rjs #endif
    361      1.1      rjs 
    362      1.1      rjs 	/* disable interrupts */
    363      1.1      rjs 
    364      1.1      rjs 	/* power down the socket to reset it, clear the card reset pin */
    365      1.1      rjs 	(so->pcictag->set_power)(so, SAPCIC_POWER_OFF);
    366      1.1      rjs 
    367      1.1      rjs 	/*
    368      1.1      rjs 	 * wait 300ms until power fails (Tpf).  Then, wait 100ms since
    369      1.1      rjs 	 * we are changing Vcc (Toff).
    370      1.1      rjs 	 */
    371      1.1      rjs 	sapcic_delay(300 + 100, "pccen0");
    372      1.1      rjs 
    373      1.1      rjs 	/* power up the socket */
    374      1.1      rjs 	/* XXX voltage selection should be done in PCMCIA code */
    375      1.1      rjs 	if (so->power_capability & SAPCIC_POWER_5V) {
    376      1.1      rjs 		(so->pcictag->set_power)(so, SAPCIC_POWER_5V);
    377      1.1      rjs 		(so->pcictag->write)(so, SAPCIC_CONTROL_POWERSELECT,
    378      1.1      rjs 				     SAPCIC_POWER_5V);
    379      1.1      rjs 	} else {
    380      1.1      rjs 		(so->pcictag->set_power)(so, SAPCIC_POWER_3V);
    381      1.1      rjs 		(so->pcictag->write)(so, SAPCIC_CONTROL_POWERSELECT,
    382      1.1      rjs 				     SAPCIC_POWER_3V);
    383      1.1      rjs 	}
    384      1.1      rjs 
    385      1.1      rjs 	/* enable PCMCIA control lines */
    386      1.1      rjs 	(so->pcictag->write)(so, SAPCIC_CONTROL_LINEENABLE, 1);
    387      1.1      rjs 
    388      1.1      rjs 	/*
    389      1.1      rjs 	 * wait 100ms until power raise (Tpr) and 20ms to become
    390      1.1      rjs 	 * stable (Tsu(Vcc)).
    391      1.1      rjs 	 *
    392      1.1      rjs 	 * some machines require some more time to be settled
    393      1.1      rjs 	 * (300ms is added here).
    394      1.1      rjs 	 */
    395      1.1      rjs 	sapcic_delay(100 + 20 + 300, "pccen1");
    396      1.1      rjs 
    397      1.1      rjs 	/* honor nWAIT signal */
    398      1.1      rjs 	(so->pcictag->write)(so, SAPCIC_CONTROL_WAITENABLE, 1);
    399      1.1      rjs 	/* now make sure we have reset# active */
    400      1.1      rjs 	(so->pcictag->write)(so, SAPCIC_CONTROL_RESET, 1);
    401      1.1      rjs 
    402      1.1      rjs 	/*
    403      1.1      rjs 	 * hold RESET at least 10us, this is a min allow for slop in
    404      1.1      rjs 	 * delay routine.
    405      1.1      rjs 	 */
    406      1.1      rjs 	delay(20);
    407      1.1      rjs 
    408      1.1      rjs 	/* clear the reset flag */
    409      1.1      rjs 	(so->pcictag->write)(so, SAPCIC_CONTROL_RESET, 0);
    410      1.1      rjs 
    411      1.1      rjs 	/* wait 20ms as per pc card standard (r2.01) section 4.3.6 */
    412      1.1      rjs 	sapcic_delay(20, "pccen2");
    413      1.1      rjs 
    414      1.1      rjs 	/* wait for the chip to finish initializing */
    415      1.1      rjs 	sapcic_delay(10, "pccen3");
    416      1.1      rjs 	for(i = 100; i; i--) {
    417      1.1      rjs 		if ((so->pcictag->read)(so, SAPCIC_STATUS_READY))
    418      1.1      rjs 			break;
    419      1.1      rjs 		sapcic_delay(100, "pccen4");
    420      1.1      rjs 	}
    421      1.1      rjs 	DPRINTF(("sapcic_socket_enable: wait ready %d\n", 100 - i));
    422      1.1      rjs 
    423      1.1      rjs 	/* finally enable the interrupt */
    424      1.1      rjs 
    425      1.1      rjs }
    426      1.1      rjs 
    427      1.1      rjs static void
    428  1.6.6.1   simonb sapcic_socket_disable(pcmcia_chipset_handle_t pch)
    429      1.1      rjs {
    430      1.1      rjs 	struct sapcic_socket *so = pch;
    431      1.1      rjs 
    432      1.1      rjs 	/* XXX mask card interrupts */
    433      1.1      rjs 
    434      1.1      rjs 	/* power down the card */
    435      1.1      rjs 	(so->pcictag->set_power)(so, SAPCIC_POWER_OFF);
    436      1.1      rjs 
    437      1.1      rjs 	/* float controller lines */
    438      1.1      rjs 	(so->pcictag->write)(so, SAPCIC_CONTROL_LINEENABLE, 0);
    439      1.1      rjs }
    440      1.5   toshii 
    441      1.5   toshii static void
    442  1.6.6.1   simonb sapcic_socket_settype(pcmcia_chipset_handle_t pch, int type)
    443      1.5   toshii {
    444      1.5   toshii 
    445      1.5   toshii 	/* XXX nothing to do */
    446      1.5   toshii }
    447