2007-02-16 14:36:55 +00:00
|
|
|
/*
|
|
|
|
* arch/arm/mach-ns9xxx/board-a9m9750dev.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006,2007 by Digi International Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 as published by
|
|
|
|
* the Free Software Foundation.
|
|
|
|
*/
|
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/serial_8250.h>
|
|
|
|
#include <linux/irq.h>
|
|
|
|
|
|
|
|
#include <asm/mach/map.h>
|
2007-09-30 19:36:14 +00:00
|
|
|
#include <asm/gpio.h>
|
2007-02-16 14:36:55 +00:00
|
|
|
|
|
|
|
#include <asm/arch-ns9xxx/board.h>
|
|
|
|
#include <asm/arch-ns9xxx/regs-sys.h>
|
|
|
|
#include <asm/arch-ns9xxx/regs-mem.h>
|
|
|
|
#include <asm/arch-ns9xxx/regs-bbu.h>
|
|
|
|
#include <asm/arch-ns9xxx/regs-board-a9m9750dev.h>
|
|
|
|
|
|
|
|
#include "board-a9m9750dev.h"
|
|
|
|
|
|
|
|
static struct map_desc board_a9m9750dev_io_desc[] __initdata = {
|
|
|
|
{ /* FPGA on CS0 */
|
|
|
|
.virtual = io_p2v(NS9XXX_CSxSTAT_PHYS(0)),
|
|
|
|
.pfn = __phys_to_pfn(NS9XXX_CSxSTAT_PHYS(0)),
|
|
|
|
.length = NS9XXX_CS0STAT_LENGTH,
|
|
|
|
.type = MT_DEVICE,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
void __init board_a9m9750dev_map_io(void)
|
|
|
|
{
|
|
|
|
iotable_init(board_a9m9750dev_io_desc,
|
|
|
|
ARRAY_SIZE(board_a9m9750dev_io_desc));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void a9m9750dev_fpga_ack_irq(unsigned int irq)
|
|
|
|
{
|
|
|
|
/* nothing */
|
|
|
|
}
|
|
|
|
|
|
|
|
static void a9m9750dev_fpga_mask_irq(unsigned int irq)
|
|
|
|
{
|
2007-09-30 19:36:33 +00:00
|
|
|
u8 ier;
|
|
|
|
|
|
|
|
ier = __raw_readb(FPGA_IER);
|
|
|
|
|
|
|
|
ier &= ~(1 << (irq - FPGA_IRQ(0)));
|
|
|
|
|
|
|
|
__raw_writeb(ier, FPGA_IER);
|
2007-02-16 14:36:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void a9m9750dev_fpga_maskack_irq(unsigned int irq)
|
|
|
|
{
|
|
|
|
a9m9750dev_fpga_mask_irq(irq);
|
|
|
|
a9m9750dev_fpga_ack_irq(irq);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void a9m9750dev_fpga_unmask_irq(unsigned int irq)
|
|
|
|
{
|
2007-09-30 19:36:33 +00:00
|
|
|
u8 ier;
|
|
|
|
|
|
|
|
ier = __raw_readb(FPGA_IER);
|
|
|
|
|
|
|
|
ier |= 1 << (irq - FPGA_IRQ(0));
|
|
|
|
|
|
|
|
__raw_writeb(ier, FPGA_IER);
|
2007-02-16 14:36:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static struct irq_chip a9m9750dev_fpga_chip = {
|
|
|
|
.ack = a9m9750dev_fpga_ack_irq,
|
|
|
|
.mask = a9m9750dev_fpga_mask_irq,
|
|
|
|
.mask_ack = a9m9750dev_fpga_maskack_irq,
|
|
|
|
.unmask = a9m9750dev_fpga_unmask_irq,
|
|
|
|
};
|
|
|
|
|
|
|
|
static void a9m9750dev_fpga_demux_handler(unsigned int irq,
|
|
|
|
struct irq_desc *desc)
|
|
|
|
{
|
2007-09-30 19:36:33 +00:00
|
|
|
u8 stat = __raw_readb(FPGA_ISR);
|
2007-02-16 14:36:55 +00:00
|
|
|
|
2007-09-30 19:34:41 +00:00
|
|
|
desc->chip->mask_ack(irq);
|
|
|
|
|
2007-02-16 14:36:55 +00:00
|
|
|
while (stat != 0) {
|
|
|
|
int irqno = fls(stat) - 1;
|
2007-09-30 19:34:41 +00:00
|
|
|
struct irq_desc *fpgadesc;
|
2007-02-16 14:36:55 +00:00
|
|
|
|
|
|
|
stat &= ~(1 << irqno);
|
|
|
|
|
2007-09-30 19:34:41 +00:00
|
|
|
fpgadesc = irq_desc + FPGA_IRQ(irqno);
|
2007-02-16 14:36:55 +00:00
|
|
|
|
2007-09-30 19:34:41 +00:00
|
|
|
desc_handle_irq(FPGA_IRQ(irqno), fpgadesc);
|
2007-02-16 14:36:55 +00:00
|
|
|
}
|
2007-09-30 19:34:41 +00:00
|
|
|
|
|
|
|
desc->chip->unmask(irq);
|
2007-02-16 14:36:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void __init board_a9m9750dev_init_irq(void)
|
|
|
|
{
|
2007-09-30 19:36:33 +00:00
|
|
|
u32 eic;
|
2007-02-16 14:36:55 +00:00
|
|
|
int i;
|
|
|
|
|
2007-09-30 19:36:14 +00:00
|
|
|
if (gpio_request(11, "board a9m9750dev extirq2") == 0)
|
|
|
|
ns9xxx_gpio_configure(11, 0, 1);
|
|
|
|
else
|
|
|
|
printk(KERN_ERR "%s: cannot get gpio 11 for IRQ_EXT2\n",
|
|
|
|
__func__);
|
2007-02-16 14:36:55 +00:00
|
|
|
|
|
|
|
for (i = FPGA_IRQ(0); i <= FPGA_IRQ(7); ++i) {
|
|
|
|
set_irq_chip(i, &a9m9750dev_fpga_chip);
|
|
|
|
set_irq_handler(i, handle_level_irq);
|
|
|
|
set_irq_flags(i, IRQF_VALID);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* IRQ_EXT2: level sensitive + active low */
|
2007-09-30 19:36:33 +00:00
|
|
|
eic = __raw_readl(SYS_EIC(2));
|
|
|
|
REGSET(eic, SYS_EIC, PLTY, AL);
|
|
|
|
REGSET(eic, SYS_EIC, LVEDG, LEVEL);
|
|
|
|
__raw_writel(eic, SYS_EIC(2));
|
2007-02-16 14:36:55 +00:00
|
|
|
|
|
|
|
set_irq_chained_handler(IRQ_EXT2,
|
|
|
|
a9m9750dev_fpga_demux_handler);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct plat_serial8250_port board_a9m9750dev_serial8250_port[] = {
|
|
|
|
{
|
|
|
|
.iobase = FPGA_UARTA_BASE,
|
|
|
|
.membase = (unsigned char*)FPGA_UARTA_BASE,
|
|
|
|
.mapbase = FPGA_UARTA_BASE,
|
|
|
|
.irq = IRQ_FPGA_UARTA,
|
|
|
|
.iotype = UPIO_MEM,
|
|
|
|
.uartclk = 18432000,
|
|
|
|
.regshift = 0,
|
|
|
|
.flags = UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ,
|
|
|
|
}, {
|
|
|
|
.iobase = FPGA_UARTB_BASE,
|
|
|
|
.membase = (unsigned char*)FPGA_UARTB_BASE,
|
|
|
|
.mapbase = FPGA_UARTB_BASE,
|
|
|
|
.irq = IRQ_FPGA_UARTB,
|
|
|
|
.iotype = UPIO_MEM,
|
|
|
|
.uartclk = 18432000,
|
|
|
|
.regshift = 0,
|
|
|
|
.flags = UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ,
|
|
|
|
}, {
|
|
|
|
.iobase = FPGA_UARTC_BASE,
|
|
|
|
.membase = (unsigned char*)FPGA_UARTC_BASE,
|
|
|
|
.mapbase = FPGA_UARTC_BASE,
|
|
|
|
.irq = IRQ_FPGA_UARTC,
|
|
|
|
.iotype = UPIO_MEM,
|
|
|
|
.uartclk = 18432000,
|
|
|
|
.regshift = 0,
|
|
|
|
.flags = UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ,
|
|
|
|
}, {
|
|
|
|
.iobase = FPGA_UARTD_BASE,
|
|
|
|
.membase = (unsigned char*)FPGA_UARTD_BASE,
|
|
|
|
.mapbase = FPGA_UARTD_BASE,
|
|
|
|
.irq = IRQ_FPGA_UARTD,
|
|
|
|
.iotype = UPIO_MEM,
|
|
|
|
.uartclk = 18432000,
|
|
|
|
.regshift = 0,
|
|
|
|
.flags = UPF_BOOT_AUTOCONF | UPF_SHARE_IRQ,
|
|
|
|
}, {
|
|
|
|
/* end marker */
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct platform_device board_a9m9750dev_serial_device = {
|
|
|
|
.name = "serial8250",
|
|
|
|
.dev = {
|
|
|
|
.platform_data = board_a9m9750dev_serial8250_port,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct platform_device *board_a9m9750dev_devices[] __initdata = {
|
|
|
|
&board_a9m9750dev_serial_device,
|
|
|
|
};
|
|
|
|
|
|
|
|
void __init board_a9m9750dev_init_machine(void)
|
|
|
|
{
|
|
|
|
u32 reg;
|
|
|
|
|
|
|
|
/* setup static CS0: memory base ... */
|
2007-09-30 19:36:33 +00:00
|
|
|
reg = __raw_readl(SYS_SMCSSMB(0));
|
|
|
|
REGSETIM(reg, SYS_SMCSSMB, CSxB, NS9XXX_CSxSTAT_PHYS(0) >> 12);
|
|
|
|
__raw_writel(reg, SYS_SMCSSMB(0));
|
2007-02-16 14:36:55 +00:00
|
|
|
|
|
|
|
/* ... and mask */
|
2007-09-30 19:36:33 +00:00
|
|
|
reg = __raw_readl(SYS_SMCSSMM(0));
|
2007-02-16 14:36:55 +00:00
|
|
|
REGSETIM(reg, SYS_SMCSSMM, CSxM, 0xfffff);
|
|
|
|
REGSET(reg, SYS_SMCSSMM, CSEx, EN);
|
2007-09-30 19:36:33 +00:00
|
|
|
__raw_writel(reg, SYS_SMCSSMM(0));
|
2007-02-16 14:36:55 +00:00
|
|
|
|
|
|
|
/* setup static CS0: memory configuration */
|
2007-09-30 19:36:33 +00:00
|
|
|
reg = __raw_readl(MEM_SMC(0));
|
2007-07-17 21:35:52 +00:00
|
|
|
REGSET(reg, MEM_SMC, PSMC, OFF);
|
2007-02-16 14:36:55 +00:00
|
|
|
REGSET(reg, MEM_SMC, BSMC, OFF);
|
|
|
|
REGSET(reg, MEM_SMC, EW, OFF);
|
|
|
|
REGSET(reg, MEM_SMC, PB, 1);
|
|
|
|
REGSET(reg, MEM_SMC, PC, AL);
|
|
|
|
REGSET(reg, MEM_SMC, PM, DIS);
|
|
|
|
REGSET(reg, MEM_SMC, MW, 8);
|
2007-09-30 19:36:33 +00:00
|
|
|
__raw_writel(reg, MEM_SMC(0));
|
2007-02-16 14:36:55 +00:00
|
|
|
|
|
|
|
/* setup static CS0: timing */
|
2007-09-30 19:36:33 +00:00
|
|
|
__raw_writel(0x2, MEM_SMWED(0));
|
|
|
|
__raw_writel(0x2, MEM_SMOED(0));
|
|
|
|
__raw_writel(0x6, MEM_SMRD(0));
|
|
|
|
__raw_writel(0x6, MEM_SMWD(0));
|
2007-02-16 14:36:55 +00:00
|
|
|
|
|
|
|
platform_add_devices(board_a9m9750dev_devices,
|
|
|
|
ARRAY_SIZE(board_a9m9750dev_devices));
|
|
|
|
}
|