Esempio n. 1
0
static void __init _apbuart_init_bases(void)
{
	int i;
	amba_apb_device dev[8];
	if (!_apbuart_init_bases_done) {
		unsigned long clk =
		    ((unsigned
		      long)(((LEON3_BYPASS_LOAD_PA
			      (&LEON3_GpTimer_Regs->scalar_reload)) + 1)));
		printk("Attaching grlib apbuart serial drivers (clk:%ihz):\n",
		       (int)clk);
		leon_ports_nr =
		    amba_get_free_apbslv_devices(VENDOR_GAISLER,
						 GAISLER_APBUART, dev, 8);

		for (i = 0; i < leon_ports_nr; i++) {
			leon_ports[i].port.membase = (void *)dev[i].start;
			leon_ports[i].port.mapbase = dev[i].start;
			leon_ports[i].port.irq = dev[i].irq;
			leon_ports[i].port.iotype = SERIAL_IO_MEM;
			leon_ports[i].port.uartclk = clk * 1000 * 1000;
			leon_ports[i].port.fifosize = 1;
			leon_ports[i].port.ops = &leon_pops;
			leon_ports[i].port.flags = ASYNC_BOOT_AUTOCONF;
			leon_ports[i].port.line = i;
		}
		_apbuart_init_bases_done = 1;
	}
}
Esempio n. 2
0
static void leon_enable_irq(unsigned int irq_nr)
{
	unsigned long mask, flags;
	mask = get_irqmask(irq_nr);
	local_irq_save(flags);
	LEON3_BYPASS_STORE_PA(LEON_IMASK,
			      (LEON3_BYPASS_LOAD_PA(LEON_IMASK) | (mask)));
	local_irq_restore(flags);
}
Esempio n. 3
0
void leon_enable_irq_cpu(unsigned int irq_nr, unsigned int cpu)
{
	unsigned long mask, flags, *addr;
	mask = get_irqmask(irq_nr);
	local_irq_save(flags);
	addr = (unsigned long *)&(leon3_irqctrl_regs->mask[cpu]);
	LEON3_BYPASS_STORE_PA(addr, (LEON3_BYPASS_LOAD_PA(addr) | (mask)));
	local_irq_restore(flags);
}
Esempio n. 4
0
void leon3_rs_put_char_base(LEON3_APBUART_Regs_Map * uart_regs, char ch)
{
	int flags, loops;

	local_irq_save(flags);
	loops = 0;
	while (!
	       (LEON3_BYPASS_LOAD_PA(&(uart_regs->status)) &
		LEON_REG_UART_STATUS_THE) && (loops < 100000))
		loops++;

	LEON3_BYPASS_STORE_PA(&(uart_regs->data), ch);

	loops = 0;
	while (!
	       (LEON3_BYPASS_LOAD_PA(&(uart_regs->status)) &
		LEON_REG_UART_STATUS_TSE) && (loops < 100000))
		loops++;
	local_irq_restore(flags);
}
Esempio n. 5
0
static int __devinit apbuart_probe(struct of_device *op, const struct of_device_id *match)
{
	struct console co;
	int node;
	int freq_khz;
	int baud_rates[UART_NR];
	unsigned long clk;
	struct device_node *dp = op->node; int v = 0, d = 0; unsigned int addr;
	struct uart_leon_port *port; struct amba_prom_registers *regs; int irq, line, *irqs;
	int *vendor = of_get_property(dp, "vendor", NULL);
	int *device = of_get_property(dp, "device", NULL);
	regs = of_get_property(dp, "reg", NULL);
	irqs = of_get_property(dp, "interrupts", NULL);
	if (vendor)
		v = *vendor;
	if (device)
		d = *device;
	
	if (LEON3_GpTimer_Regs == 0 || irqs == 0 || regs == 0 || !(v == VENDOR_GAISLER && d == GAISLER_APBUART)) {
		return -ENODEV;
	}
	addr = regs->phys_addr ;
	irq = *irqs;
	
	port = kzalloc(sizeof(struct uart_leon_port), GFP_KERNEL);
	if (unlikely(!port))
		return -ENOMEM;

	node = prom_getchild(prom_root_node);
	freq_khz = prom_getint(node, "clock-frequency");
	clk = ((unsigned long)(((LEON3_BYPASS_LOAD_PA(&LEON3_GpTimer_Regs->scalar_reload)) + 1)));
	
	port->port.membase = (void *)addr;
	port->port.mapbase = addr;
	port->port.irq = irq;
	port->port.iotype = SERIAL_IO_MEM;
	port->port.uartclk = clk * 1000 * 1000;
	port->port.fifosize = 1;
	port->port.ops = &leon_pops;
	port->port.flags = ASYNC_BOOT_AUTOCONF;
	port->port.line = line = leon_line_nr++;

	port->port.uartclk = freq_khz * 1000;
	uart_add_one_port(&leon_reg, port);
	uart_set_options(port, &co, line >= UART_NR ? 9600 : baud_rates[line], 'n', 8, 'n');
	port->port.fifosize = apbuart_scan_fifo_size(port, line);
	apbuart_flush_fifo(port);
	
	printk("---------------- Match %d: 0x%x@%d : %s ----------------\n",line,addr, irq,dp->path_component_name);
	return 0;
}
Esempio n. 6
0
/* Return the IRQ of the pending IRQ on the extended IRQ controller */
int sparc_leon_eirq_get(int eirq, int cpu)
{
	return LEON3_BYPASS_LOAD_PA(&leon3_irqctrl_regs->intid[cpu]) & 0x1f;
}
Esempio n. 7
0
void __init leon_init_timers(irq_handler_t counter_fn)
{
	int irq;

	leondebug_irq_disable = 0;
	leon_debug_irqout = 0;
	master_l10_counter = (unsigned int *)&dummy_master_l10_counter;
	dummy_master_l10_counter = 0;

	if (leon3_gptimer_regs && leon3_irqctrl_regs) {
		LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[0].val, 0);
		LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[0].rld,
				      (((1000000 / HZ) - 1)));
		LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[0].ctrl, 0);

#ifdef CONFIG_SMP
		leon_percpu_timer_dev[0].start = (int)leon3_gptimer_regs;
		leon_percpu_timer_dev[0].irq = leon3_gptimer_irq+1;

		if (!(LEON3_BYPASS_LOAD_PA(&leon3_gptimer_regs->config) &
		      (1<<LEON3_GPTIMER_SEPIRQ))) {
			prom_printf("irq timer not configured with separate irqs\n");
			BUG();
		}

		LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[1].val, 0);
		LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[1].rld, (((1000000/HZ) - 1)));
		LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[1].ctrl, 0);
# endif

	} else {
		printk(KERN_ERR "No Timer/irqctrl found\n");
		BUG();
	}

	irq = request_irq(leon3_gptimer_irq,
			  counter_fn,
			  (IRQF_DISABLED | SA_STATIC_ALLOC), "timer", NULL);

	if (irq) {
		printk(KERN_ERR "leon_time_init: unable to attach IRQ%d\n",
		       LEON_INTERRUPT_TIMER1);
		prom_halt();
	}

# ifdef CONFIG_SMP
	{
		unsigned long flags;
		struct tt_entry *trap_table = &sparc_ttable[SP_TRAP_IRQ1 + (leon_percpu_timer_dev[0].irq - 1)];

		/* For SMP we use the level 14 ticker, however the bootup code
		 * has copied the firmwares level 14 vector into boot cpu's
		 * trap table, we must fix this now or we get squashed.
		 */
		local_irq_save(flags);

		patchme_maybe_smp_msg[0] = 0x01000000; /* NOP out the branch */

		/* Adjust so that we jump directly to smpleon_ticker */
		trap_table->inst_three += smpleon_ticker - real_irq_entry;

		local_flush_cache_all();
		local_irq_restore(flags);
	}
# endif

	if (leon3_gptimer_regs) {
		LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[0].ctrl,
				      LEON3_GPTIMER_EN |
				      LEON3_GPTIMER_RL |
				      LEON3_GPTIMER_LD | LEON3_GPTIMER_IRQEN);

#ifdef CONFIG_SMP
		LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[1].ctrl,
				      LEON3_GPTIMER_EN |
				      LEON3_GPTIMER_RL |
				      LEON3_GPTIMER_LD |
				      LEON3_GPTIMER_IRQEN);
#endif

	}
}