From 8645071006a0b577ae4660f4a271f42c081ef4ab Mon Sep 17 00:00:00 2001 From: Thomas Chou Date: Mon, 25 Aug 2014 16:50:14 +0800 Subject: nios2: divide nios2-io.h into each specific drivers and remove it The nios2-io.h defines hardware registers and bits of several FPGA IP cores. It could be divided in to the specific drivers, including altera timer, altera sysid, altera uart and altera jtag uart. The altera pio and altera spi drivers use their own hardware definitions. The removal of nios2-io.h will help modularity and maintenance. Signed-off-by: Thomas Chou --- arch/nios2/cpu/cpu.c | 1 - arch/nios2/cpu/interrupts.c | 20 +++++++++++++++++++- arch/nios2/cpu/sysid.c | 8 ++++++-- 3 files changed, 25 insertions(+), 4 deletions(-) (limited to 'arch') diff --git a/arch/nios2/cpu/cpu.c b/arch/nios2/cpu/cpu.c index 86f94b7..36ea90b 100644 --- a/arch/nios2/cpu/cpu.c +++ b/arch/nios2/cpu/cpu.c @@ -7,7 +7,6 @@ #include #include -#include #include DECLARE_GLOBAL_DATA_PTR; diff --git a/arch/nios2/cpu/interrupts.c b/arch/nios2/cpu/interrupts.c index c4bed22..b363a1f 100644 --- a/arch/nios2/cpu/interrupts.c +++ b/arch/nios2/cpu/interrupts.c @@ -10,7 +10,6 @@ #include -#include #include #include #include @@ -21,6 +20,25 @@ #include #endif +typedef volatile struct { + unsigned status; /* Timer status reg */ + unsigned control; /* Timer control reg */ + unsigned periodl; /* Timeout period low */ + unsigned periodh; /* Timeout period high */ + unsigned snapl; /* Snapshot low */ + unsigned snaph; /* Snapshot high */ +} nios_timer_t; + +/* status register */ +#define NIOS_TIMER_TO (1 << 0) /* Timeout */ +#define NIOS_TIMER_RUN (1 << 1) /* Timer running */ + +/* control register */ +#define NIOS_TIMER_ITO (1 << 0) /* Timeout int ena */ +#define NIOS_TIMER_CONT (1 << 1) /* Continuous mode */ +#define NIOS_TIMER_START (1 << 2) /* Start timer */ +#define NIOS_TIMER_STOP (1 << 3) /* Stop timer */ + #if defined(CONFIG_SYS_NIOS_TMRBASE) && !defined(CONFIG_SYS_NIOS_TMRIRQ) #error CONFIG_SYS_NIOS_TMRIRQ not defined (see documentation) #endif diff --git a/arch/nios2/cpu/sysid.c b/arch/nios2/cpu/sysid.c index 943bff8..50819b2 100644 --- a/arch/nios2/cpu/sysid.c +++ b/arch/nios2/cpu/sysid.c @@ -11,12 +11,16 @@ #include #include -#include #include +typedef volatile struct { + unsigned id; /* The system build id */ + unsigned timestamp; /* Timestamp */ +} nios_sysid_t; + void display_sysid (void) { - struct nios_sysid_t *sysid = (struct nios_sysid_t *)CONFIG_SYS_NIOS_SYSID_BASE; + nios_sysid_t *sysid = (nios_sysid_t *)CONFIG_SYS_NIOS_SYSID_BASE; struct tm t; char asc[32]; time_t stamp; -- cgit v1.1 From 57cfeb5140642b1071b01a7cc5c34d4ef3166180 Mon Sep 17 00:00:00 2001 From: Thomas Chou Date: Mon, 25 Aug 2014 17:09:07 +0800 Subject: nios2: move nios2.h to arch asm directory The nios2.h is nios2 cpu specific, and should go arch asm directory. Signed-off-by: Thomas Chou --- arch/nios2/cpu/cpu.c | 2 +- arch/nios2/cpu/interrupts.c | 2 +- arch/nios2/include/asm/nios2.h | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 arch/nios2/include/asm/nios2.h (limited to 'arch') diff --git a/arch/nios2/cpu/cpu.c b/arch/nios2/cpu/cpu.c index 36ea90b..39ae972 100644 --- a/arch/nios2/cpu/cpu.c +++ b/arch/nios2/cpu/cpu.c @@ -6,7 +6,7 @@ */ #include -#include +#include #include DECLARE_GLOBAL_DATA_PTR; diff --git a/arch/nios2/cpu/interrupts.c b/arch/nios2/cpu/interrupts.c index b363a1f..9d7e193 100644 --- a/arch/nios2/cpu/interrupts.c +++ b/arch/nios2/cpu/interrupts.c @@ -9,7 +9,7 @@ */ -#include +#include #include #include #include diff --git a/arch/nios2/include/asm/nios2.h b/arch/nios2/include/asm/nios2.h new file mode 100644 index 0000000..abe4df3 --- /dev/null +++ b/arch/nios2/include/asm/nios2.h @@ -0,0 +1,40 @@ +/* + * (C) Copyright 2004, Psyent Corporation + * Scott McNutt + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#ifndef __ASM_NIOS2_H__ +#define __ASM_NIOS2_H__ + +/*------------------------------------------------------------------------ + * Control registers -- use with wrctl() & rdctl() + *----------------------------------------------------------------------*/ +#define CTL_STATUS 0 /* Processor status reg */ +#define CTL_ESTATUS 1 /* Exception status reg */ +#define CTL_BSTATUS 2 /* Break status reg */ +#define CTL_IENABLE 3 /* Interrut enable reg */ +#define CTL_IPENDING 4 /* Interrut pending reg */ + +/*------------------------------------------------------------------------ + * Access to control regs + *----------------------------------------------------------------------*/ + +#define rdctl(reg) __builtin_rdctl(reg) +#define wrctl(reg, val) __builtin_wrctl(reg, val) + +/*------------------------------------------------------------------------ + * Control reg bit masks + *----------------------------------------------------------------------*/ +#define STATUS_IE (1<<0) /* Interrupt enable */ +#define STATUS_U (1<<1) /* User-mode */ + +/*------------------------------------------------------------------------ + * Bit-31 Cache bypass -- only valid for data access. When data cache + * is not implemented, bit 31 is ignored for compatibility. + *----------------------------------------------------------------------*/ +#define CACHE_BYPASS(a) ((a) | 0x80000000) +#define CACHE_NO_BYPASS(a) ((a) & ~0x80000000) + +#endif /* __ASM_NIOS2_H__ */ -- cgit v1.1 From c69d2e57616f20eb1989cfe235ee036a26c78d5a Mon Sep 17 00:00:00 2001 From: Thomas Chou Date: Thu, 28 Aug 2014 17:29:06 +0800 Subject: nios2: link to CONFIG_SYS_MONITOR_BASE and remove text_base hook This patch changes the link script to base at CONFIG_SYS_MONITOR_BASE. Then we can remove the text_base hook in nios2-generic board. Signed-off-by: Thomas Chou --- arch/nios2/cpu/u-boot.lds | 2 ++ 1 file changed, 2 insertions(+) (limited to 'arch') diff --git a/arch/nios2/cpu/u-boot.lds b/arch/nios2/cpu/u-boot.lds index be92e8e..6e174be 100644 --- a/arch/nios2/cpu/u-boot.lds +++ b/arch/nios2/cpu/u-boot.lds @@ -5,6 +5,7 @@ * SPDX-License-Identifier: GPL-2.0+ */ +#include OUTPUT_FORMAT("elf32-littlenios2") OUTPUT_ARCH(nios2) @@ -12,6 +13,7 @@ ENTRY(_start) SECTIONS { + . = CONFIG_SYS_MONITOR_BASE; .text : { arch/nios2/cpu/start.o (.text) -- cgit v1.1