summaryrefslogtreecommitdiff
path: root/arch/nios2/include
diff options
context:
space:
mode:
Diffstat (limited to 'arch/nios2/include')
-rw-r--r--arch/nios2/include/asm/cache.h13
-rw-r--r--arch/nios2/include/asm/config.h2
-rw-r--r--arch/nios2/include/asm/dma-mapping.h27
-rw-r--r--arch/nios2/include/asm/global_data.h9
-rw-r--r--arch/nios2/include/asm/gpio.h80
-rw-r--r--arch/nios2/include/asm/io.h69
-rw-r--r--arch/nios2/include/asm/psr.h12
-rw-r--r--arch/nios2/include/asm/sections.h10
-rw-r--r--arch/nios2/include/asm/system.h2
-rw-r--r--arch/nios2/include/asm/unaligned.h5
10 files changed, 94 insertions, 135 deletions
diff --git a/arch/nios2/include/asm/cache.h b/arch/nios2/include/asm/cache.h
index 9b87c9f755f..dde43cd6fc7 100644
--- a/arch/nios2/include/asm/cache.h
+++ b/arch/nios2/include/asm/cache.h
@@ -8,18 +8,11 @@
#ifndef __ASM_NIOS2_CACHE_H_
#define __ASM_NIOS2_CACHE_H_
-extern void flush_dcache (unsigned long start, unsigned long size);
-extern void flush_icache (unsigned long start, unsigned long size);
-
/*
- * Valid L1 data cache line sizes for the NIOS2 architecture are 4, 16, and 32
- * bytes. If the board configuration has not specified one we default to the
- * largest of these values for alignment of DMA buffers.
+ * Valid L1 data cache line sizes for the NIOS2 architecture are 4,
+ * 16, and 32 bytes. We default to the largest of these values for
+ * alignment of DMA buffers.
*/
-#ifdef CONFIG_SYS_CACHELINE_SIZE
-#define ARCH_DMA_MINALIGN CONFIG_SYS_CACHELINE_SIZE
-#else
#define ARCH_DMA_MINALIGN 32
-#endif
#endif /* __ASM_NIOS2_CACHE_H_ */
diff --git a/arch/nios2/include/asm/config.h b/arch/nios2/include/asm/config.h
index 9c13848ea2b..cd297347894 100644
--- a/arch/nios2/include/asm/config.h
+++ b/arch/nios2/include/asm/config.h
@@ -7,6 +7,4 @@
#ifndef _ASM_CONFIG_H_
#define _ASM_CONFIG_H_
-#define CONFIG_SYS_GENERIC_GLOBAL_DATA
-
#endif
diff --git a/arch/nios2/include/asm/dma-mapping.h b/arch/nios2/include/asm/dma-mapping.h
index 1350e3b96fd..1562d35f0dc 100644
--- a/arch/nios2/include/asm/dma-mapping.h
+++ b/arch/nios2/include/asm/dma-mapping.h
@@ -1,23 +1,24 @@
#ifndef __ASM_NIOS2_DMA_MAPPING_H
#define __ASM_NIOS2_DMA_MAPPING_H
-/* dma_alloc_coherent() return cache-line aligned allocation which is mapped
+#include <memalign.h>
+#include <asm/io.h>
+
+/*
+ * dma_alloc_coherent() return cache-line aligned allocation which is mapped
* to uncached io region.
- *
- * IO_REGION_BASE should be defined in board config header file
- * 0x80000000 for nommu, 0xe0000000 for mmu
*/
-
static inline void *dma_alloc_coherent(size_t len, unsigned long *handle)
{
- void *addr = malloc(len + CONFIG_SYS_DCACHELINE_SIZE);
+ unsigned long addr = (unsigned long)malloc_cache_aligned(len);
+
if (!addr)
- return 0;
- flush_dcache((unsigned long)addr, len + CONFIG_SYS_DCACHELINE_SIZE);
- *handle = ((unsigned long)addr +
- (CONFIG_SYS_DCACHELINE_SIZE - 1)) &
- ~(CONFIG_SYS_DCACHELINE_SIZE - 1) & ~(IO_REGION_BASE);
- return (void *)(*handle | IO_REGION_BASE);
-}
+ return NULL;
+
+ invalidate_dcache_range(addr, addr + len);
+ if (handle)
+ *handle = addr;
+ return ioremap(addr, len);
+}
#endif /* __ASM_NIOS2_DMA_MAPPING_H */
diff --git a/arch/nios2/include/asm/global_data.h b/arch/nios2/include/asm/global_data.h
index 580b0199bb8..d6a2cfab4f9 100644
--- a/arch/nios2/include/asm/global_data.h
+++ b/arch/nios2/include/asm/global_data.h
@@ -9,6 +9,15 @@
/* Architecture-specific global data */
struct arch_global_data {
+ u32 dcache_line_size;
+ u32 icache_line_size;
+ u32 dcache_size;
+ u32 icache_size;
+ u32 reset_addr;
+ u32 exception_addr;
+ int has_initda;
+ int has_mmu;
+ u32 io_region_base;
};
#include <asm-generic/global_data.h>
diff --git a/arch/nios2/include/asm/gpio.h b/arch/nios2/include/asm/gpio.h
index 908381f5f7b..306ab4c9f2a 100644
--- a/arch/nios2/include/asm/gpio.h
+++ b/arch/nios2/include/asm/gpio.h
@@ -1,79 +1 @@
-/*
- * nios2 gpio driver
- *
- * This gpio core is described in http://nioswiki.com/GPIO
- * bit[0] data
- * bit[1] output enable
- *
- * When CONFIG_SYS_GPIO_BASE is not defined, the board may either
- * provide its own driver or the altera_pio driver may be used.
- *
- * Copyright (C) 2010 Thomas Chou <thomas@wytron.com.tw>
- *
- * 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.
- */
-
-#ifndef _ASM_NIOS2_GPIO_H_
-#define _ASM_NIOS2_GPIO_H_
-
-#ifdef CONFIG_SYS_GPIO_BASE
-#include <asm/io.h>
-
-static inline int gpio_request(unsigned gpio, const char *label)
-{
- return 0;
-}
-
-static inline int gpio_free(unsigned gpio)
-{
- return 0;
-}
-
-static inline int gpio_direction_input(unsigned gpio)
-{
- writel(1, CONFIG_SYS_GPIO_BASE + (gpio << 2));
- return 0;
-}
-
-static inline int gpio_direction_output(unsigned gpio, int value)
-{
- writel(value ? 3 : 2, CONFIG_SYS_GPIO_BASE + (gpio << 2));
- return 0;
-}
-
-static inline int gpio_get_value(unsigned gpio)
-{
- return readl(CONFIG_SYS_GPIO_BASE + (gpio << 2));
-}
-
-static inline void gpio_set_value(unsigned gpio, int value)
-{
- writel(value ? 3 : 2, CONFIG_SYS_GPIO_BASE + (gpio << 2));
-}
-
-static inline int gpio_is_valid(int number)
-{
- return ((unsigned)number) < CONFIG_SYS_GPIO_WIDTH;
-}
-#else
-#ifdef CONFIG_ALTERA_PIO
-extern int altera_pio_init(u32 base, u8 width, char iot,
- u32 rstval, u32 negmask,
- const char *label);
-
-extern void altera_pio_info(void);
-#define gpio_status() altera_pio_info()
-#endif
-
-extern int gpio_request(unsigned gpio, const char *label);
-extern int gpio_free(unsigned gpio);
-extern int gpio_direction_input(unsigned gpio);
-extern int gpio_direction_output(unsigned gpio, int value);
-extern int gpio_get_value(unsigned gpio);
-extern void gpio_set_value(unsigned gpio, int value);
-extern int gpio_is_valid(int number);
-#endif /* CONFIG_SYS_GPIO_BASE */
-
-#endif /* _ASM_NIOS2_GPIO_H_ */
+#include <asm-generic/gpio.h>
diff --git a/arch/nios2/include/asm/io.h b/arch/nios2/include/asm/io.h
index 69ab23e5f0a..e7da35b0c9e 100644
--- a/arch/nios2/include/asm/io.h
+++ b/arch/nios2/include/asm/io.h
@@ -39,12 +39,18 @@ static inline void unmap_physmem(void *vaddr, unsigned long flags)
static inline phys_addr_t virt_to_phys(void * vaddr)
{
- return (phys_addr_t)(vaddr);
+ DECLARE_GLOBAL_DATA_PTR;
+ if (gd->arch.has_mmu)
+ return (phys_addr_t)vaddr & 0x1fffffff;
+ else
+ return (phys_addr_t)vaddr & 0x7fffffff;
}
-extern unsigned char inb (unsigned char *port);
-extern unsigned short inw (unsigned short *port);
-extern unsigned inl (unsigned port);
+static inline void *ioremap(unsigned long physaddr, unsigned long size)
+{
+ DECLARE_GLOBAL_DATA_PTR;
+ return (void *)(gd->arch.io_region_base | physaddr);
+}
#define __raw_writeb(v,a) (*(volatile unsigned char *)(a) = (v))
#define __raw_writew(v,a) (*(volatile unsigned short *)(a) = (v))
@@ -111,4 +117,59 @@ static inline void outsl (unsigned long port, const void *src, unsigned long cou
while (count--) outl (*p++, port);
}
+/*
+ * Clear and set bits in one shot. These macros can be used to clear and
+ * set multiple bits in a register using a single call. These macros can
+ * also be used to set a multiple-bit bit pattern using a mask, by
+ * specifying the mask in the 'clear' parameter and the new bit pattern
+ * in the 'set' parameter.
+ */
+
+#define out_arch(type,endian,a,v) __raw_write##type(cpu_to_##endian(v),a)
+#define in_arch(type,endian,a) endian##_to_cpu(__raw_read##type(a))
+
+#define out_le32(a,v) out_arch(l,le32,a,v)
+#define out_le16(a,v) out_arch(w,le16,a,v)
+
+#define in_le32(a) in_arch(l,le32,a)
+#define in_le16(a) in_arch(w,le16,a)
+
+#define out_be32(a,v) out_arch(l,be32,a,v)
+#define out_be16(a,v) out_arch(w,be16,a,v)
+
+#define in_be32(a) in_arch(l,be32,a)
+#define in_be16(a) in_arch(w,be16,a)
+
+#define out_8(a,v) __raw_writeb(v,a)
+#define in_8(a) __raw_readb(a)
+
+#define clrbits(type, addr, clear) \
+ out_##type((addr), in_##type(addr) & ~(clear))
+
+#define setbits(type, addr, set) \
+ out_##type((addr), in_##type(addr) | (set))
+
+#define clrsetbits(type, addr, clear, set) \
+ out_##type((addr), (in_##type(addr) & ~(clear)) | (set))
+
+#define clrbits_be32(addr, clear) clrbits(be32, addr, clear)
+#define setbits_be32(addr, set) setbits(be32, addr, set)
+#define clrsetbits_be32(addr, clear, set) clrsetbits(be32, addr, clear, set)
+
+#define clrbits_le32(addr, clear) clrbits(le32, addr, clear)
+#define setbits_le32(addr, set) setbits(le32, addr, set)
+#define clrsetbits_le32(addr, clear, set) clrsetbits(le32, addr, clear, set)
+
+#define clrbits_be16(addr, clear) clrbits(be16, addr, clear)
+#define setbits_be16(addr, set) setbits(be16, addr, set)
+#define clrsetbits_be16(addr, clear, set) clrsetbits(be16, addr, clear, set)
+
+#define clrbits_le16(addr, clear) clrbits(le16, addr, clear)
+#define setbits_le16(addr, set) setbits(le16, addr, set)
+#define clrsetbits_le16(addr, clear, set) clrsetbits(le16, addr, clear, set)
+
+#define clrbits_8(addr, clear) clrbits(8, addr, clear)
+#define setbits_8(addr, set) setbits(8, addr, set)
+#define clrsetbits_8(addr, clear, set) clrsetbits(8, addr, clear, set)
+
#endif /* __ASM_NIOS2_IO_H_ */
diff --git a/arch/nios2/include/asm/psr.h b/arch/nios2/include/asm/psr.h
deleted file mode 100644
index 3ebb2a011e5..00000000000
--- a/arch/nios2/include/asm/psr.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * (C) Copyright 2004, Psyent Corporation <www.psyent.com>
- * Scott McNutt <smcnutt@psyent.com>
- *
- * SPDX-License-Identifier: GPL-2.0+
- */
-
-#ifndef __ASM_NIOS2_PSR_H_
-#define __ASM_NIOS2_PSR_H_
-
-
-#endif /* __ASM_NIOS2_PSR_H_ */
diff --git a/arch/nios2/include/asm/sections.h b/arch/nios2/include/asm/sections.h
index f0da75dcf3e..2b8c5160388 100644
--- a/arch/nios2/include/asm/sections.h
+++ b/arch/nios2/include/asm/sections.h
@@ -1,11 +1 @@
-/*
- * Copyright (c) 2012 The Chromium OS Authors.
- * SPDX-License-Identifier: GPL-2.0+
- */
-
-#ifndef __ASM_NIOS2_SECTIONS_H
-#define __ASM_NIOS2_SECTIONS_H
-
#include <asm-generic/sections.h>
-
-#endif
diff --git a/arch/nios2/include/asm/system.h b/arch/nios2/include/asm/system.h
index 6213a16eda9..b15853563e2 100644
--- a/arch/nios2/include/asm/system.h
+++ b/arch/nios2/include/asm/system.h
@@ -45,4 +45,6 @@
"callr %0" \
: : "r" (addr))
+void display_sysid(void);
+
#endif /* __ASM_NIOS2_SYSTEM_H */
diff --git a/arch/nios2/include/asm/unaligned.h b/arch/nios2/include/asm/unaligned.h
index 779117c4bce..6cecbbb2111 100644
--- a/arch/nios2/include/asm/unaligned.h
+++ b/arch/nios2/include/asm/unaligned.h
@@ -1,6 +1 @@
-#ifndef _ASM_NIOS2_UNALIGNED_H
-#define _ASM_NIOS2_UNALIGNED_H
-
#include <asm-generic/unaligned.h>
-
-#endif /* _ASM_NIOS2_UNALIGNED_H */