예제 #1
0
int
ergo_inithardware(hysdn_card * card)
{
	if (!request_region(card->iobase + PCI9050_INTR_REG, 1, "HYSDN")) 
		return (-1);
	if (!request_region(card->iobase + PCI9050_USER_IO, 1, "HYSDN")) {
		release_region(card->iobase + PCI9050_INTR_REG, 1);
		return (-1);	
	}
	card->memend = card->membase + ERG_DPRAM_PAGE_SIZE - 1;
	if (!(card->dpram = ioremap(card->membase, ERG_DPRAM_PAGE_SIZE))) {
		release_region(card->iobase + PCI9050_INTR_REG, 1);
		release_region(card->iobase + PCI9050_USER_IO, 1);
		return (-1);
	}

	ergo_stopcard(card);	
	if (request_irq(card->irq, ergo_interrupt, IRQF_SHARED, "HYSDN", card)) {
		ergo_releasehardware(card); 
		return (-1);
	}
	
	card->stopcard = ergo_stopcard;
	card->releasehardware = ergo_releasehardware;
	card->testram = ergo_testram;
	card->writebootimg = ergo_writebootimg;
	card->writebootseq = ergo_writebootseq;
	card->waitpofready = ergo_waitpofready;
	card->set_errlog_state = ergo_set_errlog_state;
	INIT_WORK(&card->irq_queue, ergo_irq_bh);
	spin_lock_init(&card->hysdn_lock);

	return (0);
}				
예제 #2
0
int
ergo_inithardware(hysdn_card * card)
{
	if (!request_region(card->iobase + PCI9050_INTR_REG, 1, "HYSDN")) 
		return (-1);
	if (!request_region(card->iobase + PCI9050_USER_IO, 1, "HYSDN")) {
		release_region(card->iobase + PCI9050_INTR_REG, 1);
		return (-1);	/* ports already in use */
	}
	card->memend = card->membase + ERG_DPRAM_PAGE_SIZE - 1;
	if (!(card->dpram = ioremap(card->membase, ERG_DPRAM_PAGE_SIZE))) {
		release_region(card->iobase + PCI9050_INTR_REG, 1);
		release_region(card->iobase + PCI9050_USER_IO, 1);
		return (-1);
	}

	ergo_stopcard(card);	/* disable interrupts */
	if (request_irq(card->irq, ergo_interrupt, IRQF_SHARED, "HYSDN", card)) {
		ergo_releasehardware(card); /* return the acquired hardware */
		return (-1);
	}
	/* success, now setup the function pointers */
	card->stopcard = ergo_stopcard;
	card->releasehardware = ergo_releasehardware;
	card->testram = ergo_testram;
	card->writebootimg = ergo_writebootimg;
	card->writebootseq = ergo_writebootseq;
	card->waitpofready = ergo_waitpofready;
	card->set_errlog_state = ergo_set_errlog_state;
	INIT_WORK(&card->irq_queue, ergo_irq_bh);
	card->hysdn_lock = SPIN_LOCK_UNLOCKED;

	return (0);
}				/* ergo_inithardware */
int
ergo_inithardware(hysdn_card * card)
{
	if (check_region(card->iobase + PCI9050_INTR_REG, 1) ||
	    check_region(card->iobase + PCI9050_USER_IO, 1))
		return (-1);	/* ports already in use */

	card->memend = card->membase + ERG_DPRAM_PAGE_SIZE - 1;
	if (!(card->dpram = ioremap(card->membase, ERG_DPRAM_PAGE_SIZE)))
		return (-1);

	request_region(card->iobase + PCI9050_INTR_REG, 1, "HYSDN");
	request_region(card->iobase + PCI9050_USER_IO, 1, "HYSDN");
	ergo_stopcard(card);	/* disable interrupts */
	if (request_irq(card->irq, ergo_interrupt, SA_SHIRQ, "HYSDN", card)) {
		ergo_releasehardware(card); /* return the acquired hardware */
		return (-1);
	}
	/* success, now setup the function pointers */
	card->stopcard = ergo_stopcard;
	card->releasehardware = ergo_releasehardware;
	card->testram = ergo_testram;
	card->writebootimg = ergo_writebootimg;
	card->writebootseq = ergo_writebootseq;
	card->waitpofready = ergo_waitpofready;
	card->set_errlog_state = ergo_set_errlog_state;
	card->irq_queue.sync = 0;
	card->irq_queue.data = card;	/* init task queue for interrupt */
	card->irq_queue.routine = (void *) (void *) ergo_irq_bh;

	return (0);
}				/* ergo_inithardware */
예제 #4
0
static void
ergo_releasehardware(hysdn_card * card)
{
	ergo_stopcard(card);	/* first stop the card if not already done */
	free_irq(card->irq, card);	/* release interrupt */
	release_region(card->iobase + PCI9050_INTR_REG, 1);	/* release all io ports */
	release_region(card->iobase + PCI9050_USER_IO, 1);
	iounmap(card->dpram);
	card->dpram = NULL;	/* release shared mem */
}				/* ergo_releasehardware */
예제 #5
0
static void
ergo_releasehardware(hysdn_card * card)
{
	ergo_stopcard(card);	
	free_irq(card->irq, card);	
	release_region(card->iobase + PCI9050_INTR_REG, 1);	
	release_region(card->iobase + PCI9050_USER_IO, 1);
	iounmap(card->dpram);
	card->dpram = NULL;	
}				
예제 #6
0
static int
ergo_waitpofready(struct HYSDN_CARD *card)
{
	tErgDpram *dpr = card->dpram;	/* pointer to DPRAM structure */
	int timecnt = 10000 / 50;	/* timeout is 10 secs max. */
	unsigned long flags;
	int msg_size;
	int i;

	if (card->debug_flags & LOG_POF_CARD)
		hysdn_addlog(card, "ERGO: waiting for pof ready");
	while (timecnt--) {
		/* wait until timeout  */

		if (dpr->ToPcFlag) {
			/* data has arrived */

			if ((dpr->ToPcChannel != CHAN_SYSTEM) ||
			    (dpr->ToPcSize < MIN_RDY_MSG_SIZE) ||
			    (dpr->ToPcSize > MAX_RDY_MSG_SIZE) ||
			    ((*(unsigned long *) dpr->ToPcBuf) != RDY_MAGIC))
				break;	/* an error occurred */

			/* Check for additional data delivered during SysReady */
			msg_size = dpr->ToPcSize - RDY_MAGIC_SIZE;
			if (msg_size > 0)
				if (EvalSysrTokData(card, dpr->ToPcBuf + RDY_MAGIC_SIZE, msg_size))
					break;

			if (card->debug_flags & LOG_POF_RECORD)
				hysdn_addlog(card, "ERGO: pof boot success");
			spin_lock_irqsave(&card->hysdn_lock, flags);

			card->state = CARD_STATE_RUN;	/* now card is running */
			/* enable the cards interrupt */
			byteout(card->iobase + PCI9050_INTR_REG,
				bytein(card->iobase + PCI9050_INTR_REG) |
			(PCI9050_INTR_REG_ENPCI | PCI9050_INTR_REG_EN1));
			card->irq_enabled = 1;	/* we are ready to receive interrupts */

			dpr->ToPcFlag = 0;	/* reset data indicator */
			dpr->ToHyInt = 1;
			dpr->ToPcInt = 1;	/* interrupt to E1 for all cards */

			spin_unlock_irqrestore(&card->hysdn_lock, flags);
			if ((hynet_enable & (1 << card->myid)) 
			    && (i = hysdn_net_create(card))) 
			{
				ergo_stopcard(card);
				card->state = CARD_STATE_BOOTERR;
				return (i);
			}
#ifdef CONFIG_HYSDN_CAPI
			if((i = hycapi_capi_create(card))) {
				printk(KERN_WARNING "HYSDN: failed to create capi-interface.\n");
			}
#endif /* CONFIG_HYSDN_CAPI */
			return (0);	/* success */
		}		/* data has arrived */
		sti();
		msleep_interruptible(50);		/* Timeout 50ms */
	}			/* wait until timeout */

	if (card->debug_flags & LOG_POF_CARD)
		hysdn_addlog(card, "ERGO: pof boot ready timeout");
	return (-ERR_POF_TIMEOUT);
}				/* ergo_waitpofready */
예제 #7
0
static int
ergo_waitpofready(struct HYSDN_CARD *card)
{
	tErgDpram *dpr = card->dpram;	
	int timecnt = 10000 / 50;	
	unsigned long flags;
	int msg_size;
	int i;

	if (card->debug_flags & LOG_POF_CARD)
		hysdn_addlog(card, "ERGO: waiting for pof ready");
	while (timecnt--) {
		

		if (dpr->ToPcFlag) {
			

			if ((dpr->ToPcChannel != CHAN_SYSTEM) ||
			    (dpr->ToPcSize < MIN_RDY_MSG_SIZE) ||
			    (dpr->ToPcSize > MAX_RDY_MSG_SIZE) ||
			    ((*(unsigned long *) dpr->ToPcBuf) != RDY_MAGIC))
				break;	

			
			msg_size = dpr->ToPcSize - RDY_MAGIC_SIZE;
			if (msg_size > 0)
				if (EvalSysrTokData(card, dpr->ToPcBuf + RDY_MAGIC_SIZE, msg_size))
					break;

			if (card->debug_flags & LOG_POF_RECORD)
				hysdn_addlog(card, "ERGO: pof boot success");
			spin_lock_irqsave(&card->hysdn_lock, flags);

			card->state = CARD_STATE_RUN;	
			
			byteout(card->iobase + PCI9050_INTR_REG,
				bytein(card->iobase + PCI9050_INTR_REG) |
			(PCI9050_INTR_REG_ENPCI | PCI9050_INTR_REG_EN1));
			card->irq_enabled = 1;	

			dpr->ToPcFlag = 0;	
			dpr->ToHyInt = 1;
			dpr->ToPcInt = 1;	

			spin_unlock_irqrestore(&card->hysdn_lock, flags);
			if ((hynet_enable & (1 << card->myid)) 
			    && (i = hysdn_net_create(card))) 
			{
				ergo_stopcard(card);
				card->state = CARD_STATE_BOOTERR;
				return (i);
			}
#ifdef CONFIG_HYSDN_CAPI
			if((i = hycapi_capi_create(card))) {
				printk(KERN_WARNING "HYSDN: failed to create capi-interface.\n");
			}
#endif 
			return (0);	
		}		
		msleep_interruptible(50);		
	}			

	if (card->debug_flags & LOG_POF_CARD)
		hysdn_addlog(card, "ERGO: pof boot ready timeout");
	return (-ERR_POF_TIMEOUT);
}