From 7b28ff979e4770232c1caa8e1a3258f26295aa85 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Fri, 7 Jun 2002 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 2002-06-07 --- bitsy/devpcmcia.c | 47 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/bitsy/devpcmcia.c b/bitsy/devpcmcia.c index 8ff095c623610171bef225ad5ba9ce188499469e..68bdb08af7519a160bd5324747bd57c520abccf5 100644 --- a/bitsy/devpcmcia.c +++ b/bitsy/devpcmcia.c @@ -105,6 +105,31 @@ bitno(ulong x) return i; } +/* + * power up/down pcmcia + */ +static void +pcmciapower(int up) +{ + /* if there's no pcmcia sleave, no interrupts */ + if(gpioregs->level & GPIO_OPT_IND_i) + return; + if (up){ + /* set timing to the default, 300 */ + slottiming(0, 300, 300, 300, 0); + slottiming(1, 300, 300, 300, 0); + + /* if there's no pcmcia sleave, no interrupts */ + if(gpioregs->level & GPIO_OPT_IND_i) + return; + + /* sleave there, interrupt on card removal */ + intrenable(GPIOrising, bitno(GPIO_CARD_IND1_i), slotinfo, nil, "pcmcia slot1 status"); + intrenable(GPIOrising, bitno(GPIO_CARD_IND0_i), slotinfo, nil, "pcmcia slot0 status"); + }else{ + } +} + /* * set up the cards, default timing is 300 ns */ @@ -115,17 +140,7 @@ pcmciareset(void) slotmap(0, PHYSPCM0REGS, PYHSPCM0ATTR, PYHSPCM0MEM); slotmap(1, PHYSPCM1REGS, PYHSPCM1ATTR, PYHSPCM1MEM); - /* set timing to the default, 300 */ - slottiming(0, 300, 300, 300, 0); - slottiming(1, 300, 300, 300, 0); - - /* if there's no pcmcia sleave, no interrupts */ - if(gpioregs->level & GPIO_OPT_IND_i) - return; - - /* sleave there, interrupt on card removal */ - intrenable(GPIOrising, bitno(GPIO_CARD_IND1_i), slotinfo, nil, "pcmcia slot1 status"); - intrenable(GPIOrising, bitno(GPIO_CARD_IND0_i), slotinfo, nil, "pcmcia slot0 status"); + pcmciapower(1); } static Chan* @@ -348,6 +363,16 @@ pcmctlwrite(char *p, long n, ulong, PCMslot *sp) /* don't let the power turn off */ increfp(sp); + }else if(strcmp(cmd->f[0], "remove") == 0){ + wlock(sp); + if(waserror()){ + wunlock(sp); + nexterror(); + } + + + wunlock(sp); + poperror(); } free(cmd);