Beispiel #1
0
int h8300_enable_irq_pin(unsigned int irq)
{
	int bitmask;
	if (irq < EXT_IRQ0 || irq > EXT_IRQ5)
		return 0;

	
	bitmask = 1 << (irq - EXT_IRQ0);
	switch(irq) {
	case EXT_IRQ0:
	case EXT_IRQ1:
	case EXT_IRQ2:
	case EXT_IRQ3:
		if (H8300_GPIO_RESERVE(H8300_GPIO_P8, bitmask) == 0)
			return -EBUSY;
		H8300_GPIO_DDR(H8300_GPIO_P8, bitmask, H8300_GPIO_INPUT);
		break;
	case EXT_IRQ4:
	case EXT_IRQ5:
		if (H8300_GPIO_RESERVE(H8300_GPIO_P9, bitmask) == 0)
			return -EBUSY;
		H8300_GPIO_DDR(H8300_GPIO_P9, bitmask, H8300_GPIO_INPUT);
		break;
	}

	return 0;
}
Beispiel #2
0
int request_irq(unsigned int irq, 
		void (*handler)(int, void *, struct pt_regs *),
                unsigned long flags, const char *devname, void *dev_id)
{
	irq_handler_t *irq_handle;
	int bitmask;
	if (irq < 0 || irq >= NR_IRQS) {
		printk("Incorrect IRQ %d from %s\n", irq, devname);
		return -EINVAL;
	}
	if (irq_list[irq])
		return -EBUSY;  /* already used */
	/* initialize IRQ pin */
	bitmask = 1 << (irq - EXT_IRQ0);
	switch(irq) {
	case EXT_IRQ0:
	case EXT_IRQ1:
	case EXT_IRQ2:
	case EXT_IRQ3:
		if (H8300_GPIO_RESERVE(H8300_GPIO_P8, bitmask) == 0)
			return -EBUSY;
		H8300_GPIO_DDR(H8300_GPIO_P8, bitmask, H8300_GPIO_INPUT);
		break;
	case EXT_IRQ4:
	case EXT_IRQ5:
		if (H8300_GPIO_RESERVE(H8300_GPIO_P9, bitmask) == 0)
			return -EBUSY;
		H8300_GPIO_DDR(H8300_GPIO_P9, bitmask, H8300_GPIO_INPUT);
		break;
	}

	if(use_kmalloc)
		irq_handle = (irq_handler_t *)kmalloc(sizeof(irq_handler_t), GFP_ATOMIC);
	else {
		irq_handle = (irq_handler_t *)alloc_bootmem(sizeof(irq_handler_t));
		(unsigned long)irq_handle |= 0x80000000UL;
	}

	if (irq_handle == NULL)
		return -ENOMEM;

	irq_handle->handler = handler;
	irq_handle->flags   = flags;
	irq_handle->count   = 0;
	irq_handle->dev_id  = dev_id;
	irq_handle->devname = devname;
	irq_list[irq] = irq_handle;
	if (irq_handle->flags & SA_SAMPLE_RANDOM)
		rand_initialize_irq(irq);

	/* enable interrupt */
	/* compatible i386  */
	if (irq >= EXT_IRQ0 && irq <= EXT_IRQ5)
		*(volatile unsigned char *)IER |= bitmask;
	return 0;
}
Beispiel #3
0
static void sci_init_pins_sci(struct uart_port* port, unsigned int cflag)
{
	int ch = (port->mapbase - SMR0) >> 3;

	/* set DDR regs */
	H8300_GPIO_DDR(h8300_sci_pins[ch].port,h8300_sci_pins[ch].rx,H8300_GPIO_INPUT);
	H8300_GPIO_DDR(h8300_sci_pins[ch].port,h8300_sci_pins[ch].tx,H8300_GPIO_OUTPUT);
	/* tx mark output*/
	H8300_SCI_DR(ch) |= h8300_sci_pins[ch].tx;
}
Beispiel #4
0
int request_irq(unsigned int irq,
		irqreturn_t (*handler)(int, void *, struct pt_regs *),
                unsigned long flags, const char *devname, void *dev_id)
{
	unsigned short ptn = 1 << (irq - EXT_IRQ0);
	irq_handler_t *irq_handle;
	if (irq < 0 || irq >= NR_IRQS) {
		printk("Incorrect IRQ %d from %s\n", irq, devname);
		return -EINVAL;
	}
	if (irq_list[irq])
		return -EBUSY; /* already used */
	if (irq >= EXT_IRQ0 && irq <= EXT_IRQ15) {
		/* initialize IRQ pin */
		unsigned int port_no,bit_no;
		if (*(volatile unsigned short *)ITSR & ptn) {
			port_no = irq_assign_table1[irq - EXT_IRQ0].port_no;
			bit_no = irq_assign_table1[irq - EXT_IRQ0].bit_no;
		} else {
			port_no = irq_assign_table0[irq - EXT_IRQ0].port_no;
			bit_no = irq_assign_table0[irq - EXT_IRQ0].bit_no;
		}
		if (H8300_GPIO_RESERVE(port_no, bit_no) == 0)
			return -EBUSY;                   /* pin already use */
		H8300_GPIO_DDR(port_no, bit_no, H8300_GPIO_INPUT);
		*(volatile unsigned short *)ISR &= ~ptn; /* ISR clear */
	}		

	if (use_kmalloc)
		irq_handle = (irq_handler_t *)kmalloc(sizeof(irq_handler_t), GFP_ATOMIC);
	else {
		/* use bootmem allocater */
		irq_handle = (irq_handler_t *)alloc_bootmem(sizeof(irq_handler_t));
		irq_handle = (irq_handler_t *)((unsigned long)irq_handle | 0x80000000);
	}

	if (irq_handle == NULL)
		return -ENOMEM;

	irq_handle->handler = handler;
	irq_handle->flags   = flags;
	irq_handle->count   = 0;
	irq_handle->dev_id  = dev_id;
	irq_handle->devname = devname;
	irq_list[irq] = irq_handle;
	if (irq_handle->flags & SA_SAMPLE_RANDOM)
		rand_initialize_irq(irq);
	
	/* enable interrupt */
	/* compatible i386  */
	if (irq >= EXT_IRQ0 && irq <= EXT_IRQ15)
		*(volatile unsigned short *)IER |= ptn;
	return 0;
}
Beispiel #5
0
static void sci_init_pins_h8s(struct sci_port* port, unsigned int cflag)
{
	int ch = ((port->base & 0xff) - 0x78) >> 3;
	switch (ch) {
	case 0:
		H8300_GPIO_RESERVE(H8300_GPIO_P3,H8300_GPIO_B2|H8300_GPIO_B0);
		H8300_GPIO_DDR(H8300_GPIO_P3,H8300_GPIO_B2,H8300_GPIO_INPUT);
		H8300_GPIO_DDR(H8300_GPIO_P3,H8300_GPIO_B0,H8300_GPIO_OUTPUT);
		*(volatile char *)P3DR |= 0x01;
		break;
	case 1:
		H8300_GPIO_RESERVE(H8300_GPIO_P3,H8300_GPIO_B3|H8300_GPIO_B1);
		H8300_GPIO_DDR(H8300_GPIO_P3,H8300_GPIO_B3,H8300_GPIO_INPUT);
		H8300_GPIO_DDR(H8300_GPIO_P3,H8300_GPIO_B1,H8300_GPIO_OUTPUT);
		*(volatile char *)P3DR |= 0x02;
		break;
	case 2:
		H8300_GPIO_RESERVE(H8300_GPIO_P5,H8300_GPIO_B1|H8300_GPIO_B0);
		H8300_GPIO_DDR(H8300_GPIO_P5,H8300_GPIO_B1,H8300_GPIO_INPUT);
		H8300_GPIO_DDR(H8300_GPIO_P5,H8300_GPIO_B0,H8300_GPIO_OUTPUT);
		*(volatile char *)P5DR |= 0x01;
		break;
	}
}
Beispiel #6
0
static void sci_init_pins_h8300h(struct sci_port* port, unsigned int cflag)
{
	int ch = ((port->base & 0xff) - 0xb0) >> 3;
	switch (ch) {
	case 0:
		H8300_GPIO_RESERVE(H8300_GPIO_P9,H8300_GPIO_B2|H8300_GPIO_B0);
		H8300_GPIO_DDR(H8300_GPIO_P9,H8300_GPIO_B2,H8300_GPIO_INPUT);
		H8300_GPIO_DDR(H8300_GPIO_P9,H8300_GPIO_B0,H8300_GPIO_OUTPUT);
		*(volatile char *)P9DR |= 0x01;
		break;
	case 1:
		H8300_GPIO_RESERVE(H8300_GPIO_P9,H8300_GPIO_B3|H8300_GPIO_B1);
		H8300_GPIO_DDR(H8300_GPIO_P9,H8300_GPIO_B3,H8300_GPIO_INPUT);
		H8300_GPIO_DDR(H8300_GPIO_P9,H8300_GPIO_B1,H8300_GPIO_OUTPUT);
		*(volatile char *)P9DR |= 0x02;
		break;
	case 2:
		H8300_GPIO_RESERVE(H8300_GPIO_PB,H8300_GPIO_B7|H8300_GPIO_B6);
		H8300_GPIO_DDR(H8300_GPIO_PB,H8300_GPIO_B7,H8300_GPIO_INPUT);
		H8300_GPIO_DDR(H8300_GPIO_PB,H8300_GPIO_B6,H8300_GPIO_OUTPUT);
		*(volatile char *)PBDR |= 0x40;
		break;
	}
}