=================================================================== RCS file: /cvs/sys/arch/arm/sa11x0/sa11xx_pcic.c,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- sys/arch/arm/sa11x0/sa11xx_pcic.c 2008/03/04 16:05:17 1.1 +++ sys/arch/arm/sa11x0/sa11xx_pcic.c 2008/05/11 10:26:11 1.2 @@ -1,4 +1,4 @@ -/* $Id: sa11xx_pcic.c,v 1.1 2008/03/04 16:05:17 nbrk Exp $ */ +/* $Id: sa11xx_pcic.c,v 1.2 2008/05/11 09:26:11 nbrk Exp $ */ /* * Copyright (c) 2001 IWAMOTO Toshihiro. All rights reserved. * Copyright (c) 1997 Marc Horowitz. All rights reserved. @@ -39,13 +39,15 @@ #include #include #include -#include +//#include #include #include #include -#include -#include +#include +#include +#include + #include #include @@ -76,18 +78,21 @@ static void sapcic_io_unmap(pcmcia_chipset_handle_t, int); static void *sapcic_intr_establish(pcmcia_chipset_handle_t, struct pcmcia_function *, int, - int (*)(void *), void *); + int (*)(void *), void *, char *); static void sapcic_intr_disestablish(pcmcia_chipset_handle_t, void *); static void sapcic_socket_enable(pcmcia_chipset_handle_t); static void sapcic_socket_disable(pcmcia_chipset_handle_t); -static void sapcic_socket_settype(pcmcia_chipset_handle_t, int); +//static void sapcic_socket_settype(pcmcia_chipset_handle_t, int); +//int sapcic_socket_detect(pcmcia_chipset_handle_t); +const char *sapcic_intr_string(pcmcia_chipset_handle_t pch, void *ih); + static void sapcic_event_thread(void *); static void sapcic_delay(int, const char *); -#ifdef DEBUG +#if (defined DEBUG) || (defined PCMCIADEBUG) #define DPRINTF(arg) printf arg #else #define DPRINTF(arg) @@ -106,10 +111,10 @@ sapcic_intr_establish, sapcic_intr_disestablish, + sapcic_intr_string, sapcic_socket_enable, - sapcic_socket_disable, - sapcic_socket_settype, + sapcic_socket_disable }; @@ -120,7 +125,7 @@ /* XXX attach card if already present */ - mutex_init(&so->sc->sc_lock, MUTEX_DEFAULT, IPL_NONE); + mtx_init(&so->sc->sc_lock, IPL_NONE); so->laststatus = (so->pcictag->read)(so, SAPCIC_STATUS_CARD); if (so->laststatus == SAPCIC_CARD_VALID) { @@ -130,12 +135,17 @@ pcmcia_card_attach(so->pcmcia); } +#if 0 if (kthread_create(PRI_NONE, 0, NULL, sapcic_event_thread, so, &so->event_thread, "%s,%d", so->sc->sc_dev.dv_xname, so->socket)) { printf("%s: unable to create event thread for socket %d\n", so->sc->sc_dev.dv_xname, so->socket); panic("sapcic_kthread_create"); } +#endif + + kthread_create_deferred(sapcic_event_thread, so); + } static void @@ -149,7 +159,7 @@ * Serialize event processing on the PCIC. We may * sleep while we hold this lock. */ - mutex_enter(&so->sc->sc_lock); + mtx_enter(&so->sc->sc_lock); /* sleep .25s to be enqueued chatterling interrupts */ (void) tsleep(sapcic_event_thread, PWAIT, "pcicss", hz / 4); @@ -165,7 +175,7 @@ /* * No events to process; release the PCIC lock. */ - mutex_exit(&so->sc->sc_lock); + mtx_leave(&so->sc->sc_lock); (void) tsleep(&so->event, PWAIT, "pcicev", hz); continue; } @@ -191,10 +201,10 @@ newstatus); } - mutex_exit(&so->sc->sc_lock); + mtx_leave(&so->sc->sc_lock); } - so->event_thread = NULL; + //so->event_thread = NULL; /* In case parent is waiting for us to exit. */ wakeup(so->sc); @@ -205,12 +215,8 @@ static void sapcic_delay(int timo, const char *wmesg) { -#ifdef DIAGNOSTIC - if (curlwp == NULL) - panic("sapcic_delay: called in interrupt context"); -#endif - - tsleep(sapcic_delay, PWAIT, wmesg, roundup(timo * hz, 1000) / 1000); +// tsleep(sapcic_delay, PWAIT, wmesg, roundup(timo * hz, 1000) / 1000); + delay(timo * 10); } int @@ -331,7 +337,7 @@ static void * sapcic_intr_establish(pcmcia_chipset_handle_t pch, struct pcmcia_function *pf, - int ipl, int (*fct)(void *), void *arg) + int ipl, int (*fct)(void *), void *arg, char *str) { struct sapcic_socket *so = pch; @@ -369,6 +375,7 @@ * we are changing Vcc (Toff). */ sapcic_delay(300 + 100, "pccen0"); + printf("sapcic_socket_enable: sapcic_delay\n"); /* power up the socket */ /* XXX voltage selection should be done in PCMCIA code */ @@ -438,9 +445,29 @@ (so->pcictag->write)(so, SAPCIC_CONTROL_LINEENABLE, 0); } +#if 0 static void sapcic_socket_settype(pcmcia_chipset_handle_t pch, int type) { /* XXX nothing to do */ } +#endif + +#if 0 +int +sapcic_socket_detect(pcmcia_chipset_handle_t pch) +{ + /* TODO */ + return (0); +} +#endif + +const char * +sapcic_intr_string(pcmcia_chipset_handle_t pch, void *ih) +{ +// return (sa11x0_gpio_intr_string(ih)); + return ("(sapcic_intr_string)"); +} + +