aboutsummaryrefslogtreecommitdiffstats
path: root/arch/c6x/include
diff options
context:
space:
mode:
Diffstat (limited to 'arch/c6x/include')
-rw-r--r--arch/c6x/include/asm/Kbuild54
-rw-r--r--arch/c6x/include/asm/asm-offsets.h1
-rw-r--r--arch/c6x/include/asm/bitops.h105
-rw-r--r--arch/c6x/include/asm/byteorder.h12
-rw-r--r--arch/c6x/include/asm/cache.h90
-rw-r--r--arch/c6x/include/asm/cacheflush.h65
-rw-r--r--arch/c6x/include/asm/checksum.h34
-rw-r--r--arch/c6x/include/asm/clkdev.h22
-rw-r--r--arch/c6x/include/asm/clock.h148
-rw-r--r--arch/c6x/include/asm/delay.h67
-rw-r--r--arch/c6x/include/asm/dma-mapping.h91
-rw-r--r--arch/c6x/include/asm/dscr.h34
-rw-r--r--arch/c6x/include/asm/elf.h113
-rw-r--r--arch/c6x/include/asm/ftrace.h6
-rw-r--r--arch/c6x/include/asm/hardirq.h20
-rw-r--r--arch/c6x/include/asm/irq.h302
-rw-r--r--arch/c6x/include/asm/irqflags.h72
-rw-r--r--arch/c6x/include/asm/linkage.h30
-rw-r--r--arch/c6x/include/asm/megamod-pic.h9
-rw-r--r--arch/c6x/include/asm/mmu.h18
-rw-r--r--arch/c6x/include/asm/module.h33
-rw-r--r--arch/c6x/include/asm/mutex.h6
-rw-r--r--arch/c6x/include/asm/page.h11
-rw-r--r--arch/c6x/include/asm/pgtable.h81
-rw-r--r--arch/c6x/include/asm/processor.h132
-rw-r--r--arch/c6x/include/asm/procinfo.h28
-rw-r--r--arch/c6x/include/asm/prom.h1
-rw-r--r--arch/c6x/include/asm/ptrace.h174
-rw-r--r--arch/c6x/include/asm/sections.h12
-rw-r--r--arch/c6x/include/asm/setup.h32
-rw-r--r--arch/c6x/include/asm/sigcontext.h80
-rw-r--r--arch/c6x/include/asm/signal.h17
-rw-r--r--arch/c6x/include/asm/soc.h35
-rw-r--r--arch/c6x/include/asm/string.h21
-rw-r--r--arch/c6x/include/asm/swab.h54
-rw-r--r--arch/c6x/include/asm/syscall.h123
-rw-r--r--arch/c6x/include/asm/syscalls.h55
-rw-r--r--arch/c6x/include/asm/system.h168
-rw-r--r--arch/c6x/include/asm/thread_info.h121
-rw-r--r--arch/c6x/include/asm/timer64.h6
-rw-r--r--arch/c6x/include/asm/timex.h33
-rw-r--r--arch/c6x/include/asm/tlb.h8
-rw-r--r--arch/c6x/include/asm/traps.h36
-rw-r--r--arch/c6x/include/asm/uaccess.h107
-rw-r--r--arch/c6x/include/asm/unaligned.h170
-rw-r--r--arch/c6x/include/asm/unistd.h26
46 files changed, 2863 insertions, 0 deletions
diff --git a/arch/c6x/include/asm/Kbuild b/arch/c6x/include/asm/Kbuild
new file mode 100644
index 00000000000..13dcf78adf9
--- /dev/null
+++ b/arch/c6x/include/asm/Kbuild
@@ -0,0 +1,54 @@
1include include/asm-generic/Kbuild.asm
2
3generic-y += atomic.h
4generic-y += auxvec.h
5generic-y += bitsperlong.h
6generic-y += bug.h
7generic-y += bugs.h
8generic-y += cputime.h
9generic-y += current.h
10generic-y += device.h
11generic-y += div64.h
12generic-y += dma.h
13generic-y += emergency-restart.h
14generic-y += errno.h
15generic-y += fb.h
16generic-y += fcntl.h
17generic-y += futex.h
18generic-y += hw_irq.h
19generic-y += io.h
20generic-y += ioctl.h
21generic-y += ioctls.h
22generic-y += ipcbuf.h
23generic-y += irq_regs.h
24generic-y += kdebug.h
25generic-y += kmap_types.h
26generic-y += local.h
27generic-y += mman.h
28generic-y += mmu_context.h
29generic-y += msgbuf.h
30generic-y += param.h
31generic-y += pci.h
32generic-y += percpu.h
33generic-y += pgalloc.h
34generic-y += poll.h
35generic-y += posix_types.h
36generic-y += resource.h
37generic-y += scatterlist.h
38generic-y += segment.h
39generic-y += sembuf.h
40generic-y += shmbuf.h
41generic-y += shmparam.h
42generic-y += siginfo.h
43generic-y += socket.h
44generic-y += sockios.h
45generic-y += stat.h
46generic-y += statfs.h
47generic-y += termbits.h
48generic-y += termios.h
49generic-y += tlbflush.h
50generic-y += topology.h
51generic-y += types.h
52generic-y += ucontext.h
53generic-y += user.h
54generic-y += vga.h
diff --git a/arch/c6x/include/asm/asm-offsets.h b/arch/c6x/include/asm/asm-offsets.h
new file mode 100644
index 00000000000..d370ee36a18
--- /dev/null
+++ b/arch/c6x/include/asm/asm-offsets.h
@@ -0,0 +1 @@
#include <generated/asm-offsets.h>
diff --git a/arch/c6x/include/asm/bitops.h b/arch/c6x/include/asm/bitops.h
new file mode 100644
index 00000000000..39ab7e874d9
--- /dev/null
+++ b/arch/c6x/include/asm/bitops.h
@@ -0,0 +1,105 @@
1/*
2 * Port on Texas Instruments TMS320C6x architecture
3 *
4 * Copyright (C) 2004, 2009, 2010 Texas Instruments Incorporated
5 * Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com)
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11#ifndef _ASM_C6X_BITOPS_H
12#define _ASM_C6X_BITOPS_H
13
14#ifdef __KERNEL__
15
16#include <linux/bitops.h>
17
18#include <asm/system.h>
19#include <asm/byteorder.h>
20
21/*
22 * clear_bit() doesn't provide any barrier for the compiler.
23 */
24#define smp_mb__before_clear_bit() barrier()
25#define smp_mb__after_clear_bit() barrier()
26
27/*
28 * We are lucky, DSP is perfect for bitops: do it in 3 cycles
29 */
30
31/**
32 * __ffs - find first bit in word.
33 * @word: The word to search
34 *
35 * Undefined if no bit exists, so code should check against 0 first.
36 * Note __ffs(0) = undef, __ffs(1) = 0, __ffs(0x80000000) = 31.
37 *
38 */
39static inline unsigned long __ffs(unsigned long x)
40{
41 asm (" bitr .M1 %0,%0\n"
42 " nop\n"
43 " lmbd .L1 1,%0,%0\n"
44 : "+a"(x));
45
46 return x;
47}
48
49/*
50 * ffz - find first zero in word.
51 * @word: The word to search
52 *
53 * Undefined if no zero exists, so code should check against ~0UL first.
54 */
55#define ffz(x) __ffs(~(x))
56
57/**
58 * fls - find last (most-significant) bit set
59 * @x: the word to search
60 *
61 * This is defined the same way as ffs.
62 * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
63 */
64static inline int fls(int x)
65{
66 if (!x)
67 return 0;
68
69 asm (" lmbd .L1 1,%0,%0\n" : "+a"(x));
70
71 return 32 - x;
72}
73
74/**
75 * ffs - find first bit set
76 * @x: the word to search
77 *
78 * This is defined the same way as
79 * the libc and compiler builtin ffs routines, therefore
80 * differs in spirit from the above ffz (man ffs).
81 * Note ffs(0) = 0, ffs(1) = 1, ffs(0x80000000) = 32.
82 */
83static inline int ffs(int x)
84{
85 if (!x)
86 return 0;
87
88 return __ffs(x) + 1;
89}
90
91#include <asm-generic/bitops/__fls.h>
92#include <asm-generic/bitops/fls64.h>
93#include <asm-generic/bitops/find.h>
94
95#include <asm-generic/bitops/sched.h>
96#include <asm-generic/bitops/hweight.h>
97#include <asm-generic/bitops/lock.h>
98
99#include <asm-generic/bitops/atomic.h>
100#include <asm-generic/bitops/non-atomic.h>
101#include <asm-generic/bitops/le.h>
102#include <asm-generic/bitops/ext2-atomic.h>
103
104#endif /* __KERNEL__ */
105#endif /* _ASM_C6X_BITOPS_H */
diff --git a/arch/c6x/include/asm/byteorder.h b/arch/c6x/include/asm/byteorder.h
new file mode 100644
index 00000000000..166038db342
--- /dev/null
+++ b/arch/c6x/include/asm/byteorder.h
@@ -0,0 +1,12 @@
1#ifndef _ASM_C6X_BYTEORDER_H
2#define _ASM_C6X_BYTEORDER_H
3
4#include <asm/types.h>
5
6#ifdef _BIG_ENDIAN
7#include <linux/byteorder/big_endian.h>
8#else /* _BIG_ENDIAN */
9#include <linux/byteorder/little_endian.h>
10#endif /* _BIG_ENDIAN */
11
12#endif /* _ASM_BYTEORDER_H */
diff --git a/arch/c6x/include/asm/cache.h b/arch/c6x/include/asm/cache.h
new file mode 100644
index 00000000000..6d521d96d94
--- /dev/null
+++ b/arch/c6x/include/asm/cache.h
@@ -0,0 +1,90 @@
1/*
2 * Port on Texas Instruments TMS320C6x architecture
3 *
4 * Copyright (C) 2005, 2006, 2009, 2010 Texas Instruments Incorporated
5 * Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com)
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11#ifndef _ASM_C6X_CACHE_H
12#define _ASM_C6X_CACHE_H
13
14#include <linux/irqflags.h>
15
16/*
17 * Cache line size
18 */
19#define L1D_CACHE_BYTES 64
20#define L1P_CACHE_BYTES 32
21#define L2_CACHE_BYTES 128
22
23/*
24 * L2 used as cache
25 */
26#define L2MODE_SIZE L2MODE_256K_CACHE
27
28/*
29 * For practical reasons the L1_CACHE_BYTES defines should not be smaller than
30 * the L2 line size
31 */
32#define L1_CACHE_BYTES L2_CACHE_BYTES
33
34#define L2_CACHE_ALIGN_LOW(x) \
35 (((x) & ~(L2_CACHE_BYTES - 1)))
36#define L2_CACHE_ALIGN_UP(x) \
37 (((x) + (L2_CACHE_BYTES - 1)) & ~(L2_CACHE_BYTES - 1))
38#define L2_CACHE_ALIGN_CNT(x) \
39 (((x) + (sizeof(int) - 1)) & ~(sizeof(int) - 1))
40
41#define ARCH_DMA_MINALIGN L1_CACHE_BYTES
42#define ARCH_SLAB_MINALIGN L1_CACHE_BYTES
43
44/*
45 * This is the granularity of hardware cacheability control.
46 */
47#define CACHEABILITY_ALIGN 0x01000000
48
49/*
50 * Align a physical address to MAR regions
51 */
52#define CACHE_REGION_START(v) \
53 (((u32) (v)) & ~(CACHEABILITY_ALIGN - 1))
54#define CACHE_REGION_END(v) \
55 (((u32) (v) + (CACHEABILITY_ALIGN - 1)) & ~(CACHEABILITY_ALIGN - 1))
56
57extern void __init c6x_cache_init(void);
58
59extern void enable_caching(unsigned long start, unsigned long end);
60extern void disable_caching(unsigned long start, unsigned long end);
61
62extern void L1_cache_off(void);
63extern void L1_cache_on(void);
64
65extern void L1P_cache_global_invalidate(void);
66extern void L1D_cache_global_invalidate(void);
67extern void L1D_cache_global_writeback(void);
68extern void L1D_cache_global_writeback_invalidate(void);
69extern void L2_cache_set_mode(unsigned int mode);
70extern void L2_cache_global_writeback_invalidate(void);
71extern void L2_cache_global_writeback(void);
72
73extern void L1P_cache_block_invalidate(unsigned int start, unsigned int end);
74extern void L1D_cache_block_invalidate(unsigned int start, unsigned int end);
75extern void L1D_cache_block_writeback_invalidate(unsigned int start,
76 unsigned int end);
77extern void L1D_cache_block_writeback(unsigned int start, unsigned int end);
78extern void L2_cache_block_invalidate(unsigned int start, unsigned int end);
79extern void L2_cache_block_writeback(unsigned int start, unsigned int end);
80extern void L2_cache_block_writeback_invalidate(unsigned int start,
81 unsigned int end);
82extern void L2_cache_block_invalidate_nowait(unsigned int start,
83 unsigned int end);
84extern void L2_cache_block_writeback_nowait(unsigned int start,
85 unsigned int end);
86
87extern void L2_cache_block_writeback_invalidate_nowait(unsigned int start,
88 unsigned int end);
89
90#endif /* _ASM_C6X_CACHE_H */
diff --git a/arch/c6x/include/asm/cacheflush.h b/arch/c6x/include/asm/cacheflush.h
new file mode 100644
index 00000000000..df5db90dbe5
--- /dev/null
+++ b/arch/c6x/include/asm/cacheflush.h
@@ -0,0 +1,65 @@
1/*
2 * Port on Texas Instruments TMS320C6x architecture
3 *
4 * Copyright (C) 2004, 2009, 2010 Texas Instruments Incorporated
5 * Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com)
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11#ifndef _ASM_C6X_CACHEFLUSH_H
12#define _ASM_C6X_CACHEFLUSH_H
13
14#include <linux/spinlock.h>
15
16#include <asm/setup.h>
17#include <asm/cache.h>
18#include <asm/mman.h>
19#include <asm/page.h>
20#include <asm/string.h>
21
22/*
23 * virtually-indexed cache management (our cache is physically indexed)
24 */
25#define flush_cache_all() do {} while (0)
26#define flush_cache_mm(mm) do {} while (0)
27#define flush_cache_dup_mm(mm) do {} while (0)
28#define flush_cache_range(mm, start, end) do {} while (0)
29#define flush_cache_page(vma, vmaddr, pfn) do {} while (0)
30#define flush_cache_vmap(start, end) do {} while (0)
31#define flush_cache_vunmap(start, end) do {} while (0)
32#define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE 0
33#define flush_dcache_page(page) do {} while (0)
34#define flush_dcache_mmap_lock(mapping) do {} while (0)
35#define flush_dcache_mmap_unlock(mapping) do {} while (0)
36
37/*
38 * physically-indexed cache management
39 */
40#define flush_icache_range(s, e) \
41do { \
42 L1D_cache_block_writeback((s), (e)); \
43 L1P_cache_block_invalidate((s), (e)); \
44} while (0)
45
46#define flush_icache_page(vma, page) \
47do { \
48 if ((vma)->vm_flags & PROT_EXEC) \
49 L1D_cache_block_writeback_invalidate(page_address(page), \
50 (unsigned long) page_address(page) + PAGE_SIZE)); \
51 L1P_cache_block_invalidate(page_address(page), \
52 (unsigned long) page_address(page) + PAGE_SIZE)); \
53} while (0)
54
55
56#define copy_to_user_page(vma, page, vaddr, dst, src, len) \
57do { \
58 memcpy(dst, src, len); \
59 flush_icache_range((unsigned) (dst), (unsigned) (dst) + (len)); \
60} while (0)
61
62#define copy_from_user_page(vma, page, vaddr, dst, src, len) \
63 memcpy(dst, src, len)
64
65#endif /* _ASM_C6X_CACHEFLUSH_H */
diff --git a/arch/c6x/include/asm/checksum.h b/arch/c6x/include/asm/checksum.h
new file mode 100644
index 00000000000..7246816d6e4
--- /dev/null
+++ b/arch/c6x/include/asm/checksum.h
@@ -0,0 +1,34 @@
1/*
2 * Copyright (C) 2011 Texas Instruments Incorporated
3 * Author: Mark Salter <msalter@redhat.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */
9#ifndef _ASM_C6X_CHECKSUM_H
10#define _ASM_C6X_CHECKSUM_H
11
12static inline __wsum
13csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len,
14 unsigned short proto, __wsum sum)
15{
16 unsigned long long tmp;
17
18 asm ("add .d1 %1,%5,%1\n"
19 "|| addu .l1 %3,%4,%0\n"
20 "addu .l1 %2,%0,%0\n"
21#ifndef CONFIG_CPU_BIG_ENDIAN
22 "|| shl .s1 %1,8,%1\n"
23#endif
24 "addu .l1 %1,%0,%0\n"
25 "add .l1 %P0,%p0,%2\n"
26 : "=&a"(tmp), "+a"(len), "+a"(sum)
27 : "a" (saddr), "a" (daddr), "a" (proto));
28 return sum;
29}
30#define csum_tcpudp_nofold csum_tcpudp_nofold
31
32#include <asm-generic/checksum.h>
33
34#endif /* _ASM_C6X_CHECKSUM_H */
diff --git a/arch/c6x/include/asm/clkdev.h b/arch/c6x/include/asm/clkdev.h
new file mode 100644
index 00000000000..76a070b1c2e
--- /dev/null
+++ b/arch/c6x/include/asm/clkdev.h
@@ -0,0 +1,22 @@
1#ifndef _ASM_CLKDEV_H
2#define _ASM_CLKDEV_H
3
4#include <linux/slab.h>
5
6struct clk;
7
8static inline int __clk_get(struct clk *clk)
9{
10 return 1;
11}
12
13static inline void __clk_put(struct clk *clk)
14{
15}
16
17static inline struct clk_lookup_alloc *__clkdev_alloc(size_t size)
18{
19 return kzalloc(size, GFP_KERNEL);
20}
21
22#endif /* _ASM_CLKDEV_H */
diff --git a/arch/c6x/include/asm/clock.h b/arch/c6x/include/asm/clock.h
new file mode 100644
index 00000000000..bcf42b2b4b1
--- /dev/null
+++ b/arch/c6x/include/asm/clock.h
@@ -0,0 +1,148 @@
1/*
2 * TI C64X clock definitions
3 *
4 * Copyright (C) 2010, 2011 Texas Instruments.
5 * Contributed by: Mark Salter <msalter@redhat.com>
6 *
7 * Copied heavily from arm/mach-davinci/clock.h, so:
8 *
9 * Copyright (C) 2006-2007 Texas Instruments.
10 * Copyright (C) 2008-2009 Deep Root Systems, LLC
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2 as
14 * published by the Free Software Foundation.
15 */
16
17#ifndef _ASM_C6X_CLOCK_H
18#define _ASM_C6X_CLOCK_H
19
20#ifndef __ASSEMBLER__
21
22#include <linux/list.h>
23
24/* PLL/Reset register offsets */
25#define PLLCTL 0x100
26#define PLLM 0x110
27#define PLLPRE 0x114
28#define PLLDIV1 0x118
29#define PLLDIV2 0x11c
30#define PLLDIV3 0x120
31#define PLLPOST 0x128
32#define PLLCMD 0x138
33#define PLLSTAT 0x13c
34#define PLLALNCTL 0x140
35#define PLLDCHANGE 0x144
36#define PLLCKEN 0x148
37#define PLLCKSTAT 0x14c
38#define PLLSYSTAT 0x150
39#define PLLDIV4 0x160
40#define PLLDIV5 0x164
41#define PLLDIV6 0x168
42#define PLLDIV7 0x16c
43#define PLLDIV8 0x170
44#define PLLDIV9 0x174
45#define PLLDIV10 0x178
46#define PLLDIV11 0x17c
47#define PLLDIV12 0x180
48#define PLLDIV13 0x184
49#define PLLDIV14 0x188
50#define PLLDIV15 0x18c
51#define PLLDIV16 0x190
52
53/* PLLM register bits */
54#define PLLM_PLLM_MASK 0xff
55#define PLLM_VAL(x) ((x) - 1)
56
57/* PREDIV register bits */
58#define PLLPREDIV_EN BIT(15)
59#define PLLPREDIV_VAL(x) ((x) - 1)
60
61/* PLLCTL register bits */
62#define PLLCTL_PLLEN BIT(0)
63#define PLLCTL_PLLPWRDN BIT(1)
64#define PLLCTL_PLLRST BIT(3)
65#define PLLCTL_PLLDIS BIT(4)
66#define PLLCTL_PLLENSRC BIT(5)
67#define PLLCTL_CLKMODE BIT(8)
68
69/* PLLCMD register bits */
70#define PLLCMD_GOSTAT BIT(0)
71
72/* PLLSTAT register bits */
73#define PLLSTAT_GOSTAT BIT(0)
74
75/* PLLDIV register bits */
76#define PLLDIV_EN BIT(15)
77#define PLLDIV_RATIO_MASK 0x1f
78#define PLLDIV_RATIO(x) ((x) - 1)
79
80struct pll_data;
81
82struct clk {
83 struct list_head node;
84 struct module *owner;
85 const char *name;
86 unsigned long rate;
87 int usecount;
88 u32 flags;
89 struct clk *parent;
90 struct list_head children; /* list of children */
91 struct list_head childnode; /* parent's child list node */
92 struct pll_data *pll_data;
93 u32 div;
94 unsigned long (*recalc) (struct clk *);
95 int (*set_rate) (struct clk *clk, unsigned long rate);
96 int (*round_rate) (struct clk *clk, unsigned long rate);
97};
98
99/* Clock flags: SoC-specific flags start at BIT(16) */
100#define ALWAYS_ENABLED BIT(1)
101#define CLK_PLL BIT(2) /* PLL-derived clock */
102#define PRE_PLL BIT(3) /* source is before PLL mult/div */
103#define FIXED_DIV_PLL BIT(4) /* fixed divisor from PLL */
104#define FIXED_RATE_PLL BIT(5) /* fixed ouput rate PLL */
105
106#define MAX_PLL_SYSCLKS 16
107
108struct pll_data {
109 void __iomem *base;
110 u32 num;
111 u32 flags;
112 u32 input_rate;
113 u32 bypass_delay; /* in loops */
114 u32 reset_delay; /* in loops */
115 u32 lock_delay; /* in loops */
116 struct clk sysclks[MAX_PLL_SYSCLKS + 1];
117};
118
119/* pll_data flag bit */
120#define PLL_HAS_PRE BIT(0)
121#define PLL_HAS_MUL BIT(1)
122#define PLL_HAS_POST BIT(2)
123
124#define CLK(dev, con, ck) \
125 { \
126 .dev_id = dev, \
127 .con_id = con, \
128 .clk = ck, \
129 } \
130
131extern void c6x_clks_init(struct clk_lookup *clocks);
132extern int clk_register(struct clk *clk);
133extern void clk_unregister(struct clk *clk);
134extern void c64x_setup_clocks(void);
135
136extern struct pll_data c6x_soc_pll1;
137
138extern struct clk clkin1;
139extern struct clk c6x_core_clk;
140extern struct clk c6x_i2c_clk;
141extern struct clk c6x_watchdog_clk;
142extern struct clk c6x_mcbsp1_clk;
143extern struct clk c6x_mcbsp2_clk;
144extern struct clk c6x_mdio_clk;
145
146#endif
147
148#endif /* _ASM_C6X_CLOCK_H */
diff --git a/arch/c6x/include/asm/delay.h b/arch/c6x/include/asm/delay.h
new file mode 100644
index 00000000000..f314c2e9eb5
--- /dev/null
+++ b/arch/c6x/include/asm/delay.h
@@ -0,0 +1,67 @@
1/*
2 * Port on Texas Instruments TMS320C6x architecture
3 *
4 * Copyright (C) 2004, 2009, 2010, 2011 Texas Instruments Incorporated
5 * Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com)
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11#ifndef _ASM_C6X_DELAY_H
12#define _ASM_C6X_DELAY_H
13
14#include <linux/kernel.h>
15
16extern unsigned int ticks_per_ns_scaled;
17
18static inline void __delay(unsigned long loops)
19{
20 uint32_t tmp;
21
22 /* 6 cycles per loop */
23 asm volatile (" mv .s1 %0,%1\n"
24 "0: [%1] b .s1 0b\n"
25 " add .l1 -6,%0,%0\n"
26 " cmplt .l1 1,%0,%1\n"
27 " nop 3\n"
28 : "+a"(loops), "=A"(tmp));
29}
30
31static inline void _c6x_tickdelay(unsigned int x)
32{
33 uint32_t cnt, endcnt;
34
35 asm volatile (" mvc .s2 TSCL,%0\n"
36 " add .s2x %0,%1,%2\n"
37 " || mvk .l2 1,B0\n"
38 "0: [B0] b .s2 0b\n"
39 " mvc .s2 TSCL,%0\n"
40 " sub .s2 %0,%2,%0\n"
41 " cmpgt .l2 0,%0,B0\n"
42 " nop 2\n"
43 : "=b"(cnt), "+a"(x), "=b"(endcnt) : : "B0");
44}
45
46/* use scaled math to avoid slow division */
47#define C6X_NDELAY_SCALE 10
48
49static inline void _ndelay(unsigned int n)
50{
51 _c6x_tickdelay((ticks_per_ns_scaled * n) >> C6X_NDELAY_SCALE);
52}
53
54static inline void _udelay(unsigned int n)
55{
56 while (n >= 10) {
57 _ndelay(10000);
58 n -= 10;
59 }
60 while (n-- > 0)
61 _ndelay(1000);
62}
63
64#define udelay(x) _udelay((unsigned int)(x))
65#define ndelay(x) _ndelay((unsigned int)(x))
66
67#endif /* _ASM_C6X_DELAY_H */
diff --git a/arch/c6x/include/asm/dma-mapping.h b/arch/c6x/include/asm/dma-mapping.h
new file mode 100644
index 00000000000..03579fd99db
--- /dev/null
+++ b/arch/c6x/include/asm/dma-mapping.h
@@ -0,0 +1,91 @@
1/*
2 * Port on Texas Instruments TMS320C6x architecture
3 *
4 * Copyright (C) 2004, 2009, 2010, 2011 Texas Instruments Incorporated
5 * Author: Aurelien Jacquiot <aurelien.jacquiot@ti.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 */
12#ifndef _ASM_C6X_DMA_MAPPING_H
13#define _ASM_C6X_DMA_MAPPING_H
14
15#include <linux/dma-debug.h>
16#include <asm-generic/dma-coherent.h>
17
18#define dma_supported(d, m) 1
19
20static inline int dma_set_mask(struct device *dev, u64 dma_mask)
21{
22 if (!dev->dma_mask || !dma_supported(dev, dma_mask))
23 return -EIO;
24
25 *dev->dma_mask = dma_mask;
26
27 return 0;
28}
29
30/*
31 * DMA errors are defined by all-bits-set in the DMA address.
32 */
33static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
34{
35 return dma_addr == ~0;
36}
37
38extern dma_addr_t dma_map_single(struct device *dev, void *cpu_addr,
39 size_t size, enum dma_data_direction dir);
40
41extern void dma_unmap_single(struct device *dev, dma_addr_t handle,
42 size_t size, enum dma_data_direction dir);
43
44extern int dma_map_sg(struct device *dev, struct scatterlist *sglist,
45 int nents, enum dma_data_direction direction);
46
47extern void dma_unmap_sg(struct device *dev, struct scatterlist *sglist,
48 int nents, enum dma_data_direction direction);
49
50static inline dma_addr_t dma_map_page(struct device *dev, struct page *page,
51 unsigned long offset, size_t size,
52 enum dma_data_direction dir)
53{
54 dma_addr_t handle;
55
56 handle = dma_map_single(dev, page_address(page) + offset, size, dir);
57
58 debug_dma_map_page(dev, page, offset, size, dir, handle, false);
59
60 return handle;
61}
62
63static inline void dma_unmap_page(struct device *dev, dma_addr_t handle,
64 size_t size, enum dma_data_direction dir)
65{
66 dma_unmap_single(dev, handle, size, dir);
67
68 debug_dma_unmap_page(dev, handle, size, dir, false);
69}
70
71extern void dma_sync_single_for_cpu(struct device *dev, dma_addr_t handle,
72 size_t size, enum dma_data_direction dir);
73
74extern void dma_sync_single_for_device(struct device *dev, dma_addr_t handle,
75 size_t size,
76 enum dma_data_direction dir);
77
78extern void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg,
79 int nents, enum dma_data_direction dir);
80
81extern void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
82 int nents, enum dma_data_direction dir);
83
84extern void coherent_mem_init(u32 start, u32 size);
85extern void *dma_alloc_coherent(struct device *, size_t, dma_addr_t *, gfp_t);
86extern void dma_free_coherent(struct device *, size_t, void *, dma_addr_t);
87
88#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent((d), (s), (h), (f))
89#define dma_free_noncoherent(d, s, v, h) dma_free_coherent((d), (s), (v), (h))
90
91#endif /* _ASM_C6X_DMA_MAPPING_H */
diff --git a/arch/c6x/include/asm/dscr.h b/arch/c6x/include/asm/dscr.h
new file mode 100644
index 00000000000..561ba833204
--- /dev/null
+++ b/arch/c6x/include/asm/dscr.h
@@ -0,0 +1,34 @@
1/*
2 * Copyright (C) 2011 Texas Instruments Incorporated
3 * Author: Mark Salter <msalter@redhat.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 *
9 */
10#ifndef _ASM_C6X_DSCR_H
11#define _ASM_C6X_DSCR_H
12
13enum dscr_devstate_t {
14 DSCR_DEVSTATE_ENABLED,
15 DSCR_DEVSTATE_DISABLED,
16};
17
18/*
19 * Set the device state of the device with the given ID.
20 *
21 * Individual drivers should use this to enable or disable the
22 * hardware device. The devid used to identify the device being
23 * controlled should be a property in the device's tree node.
24 */
25extern void dscr_set_devstate(int devid, enum dscr_devstate_t state);
26
27/*
28 * Assert or de-assert an RMII reset.
29 */
30extern void dscr_rmii_reset(int id, int assert);
31
32extern void dscr_probe(void);
33
34#endif /* _ASM_C6X_DSCR_H */
diff --git a/arch/c6x/include/asm/elf.h b/arch/c6x/include/asm/elf.h
new file mode 100644
index 00000000000..d57865ba2c4
--- /dev/null
+++ b/arch/c6x/include/asm/elf.h
@@ -0,0 +1,113 @@
1/*
2 * Port on Texas Instruments TMS320C6x architecture
3 *
4 * Copyright (C) 2004, 2009, 2010 Texas Instruments Incorporated
5 * Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com)
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11#ifndef _ASM_C6X_ELF_H
12#define _ASM_C6X_ELF_H
13
14/*
15 * ELF register definitions..
16 */
17#include <asm/ptrace.h>
18
19typedef unsigned long elf_greg_t;
20typedef unsigned long elf_fpreg_t;
21
22#define ELF_NGREG 58
23#define ELF_NFPREG 1
24
25typedef elf_greg_t elf_gregset_t[ELF_NGREG];
26typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
27
28/*
29 * This is used to ensure we don't load something for the wrong architecture.
30 */
31#define elf_check_arch(x) ((x)->e_machine == EM_TI_C6000)
32
33#define elf_check_const_displacement(x) (1)
34
35/*
36 * These are used to set parameters in the core dumps.
37 */
38#ifdef __LITTLE_ENDIAN__
39#define ELF_DATA ELFDATA2LSB
40#else
41#define ELF_DATA ELFDATA2MSB
42#endif
43
44#define ELF_CLASS ELFCLASS32
45#define ELF_ARCH EM_TI_C6000
46
47/* Nothing for now. Need to setup DP... */
48#define ELF_PLAT_INIT(_r)
49
50#define USE_ELF_CORE_DUMP
51#define ELF_EXEC_PAGESIZE 4096
52
53#define ELF_CORE_COPY_REGS(_dest, _regs) \
54 memcpy((char *) &_dest, (char *) _regs, \
55 sizeof(struct pt_regs));
56
57/* This yields a mask that user programs can use to figure out what
58 instruction set this cpu supports. */
59
60#define ELF_HWCAP (0)
61
62/* This yields a string that ld.so will use to load implementation
63 specific libraries for optimization. This is more specific in
64 intent than poking at uname or /proc/cpuinfo. */
65
66#define ELF_PLATFORM (NULL)
67
68#define SET_PERSONALITY(ex) set_personality(PER_LINUX)
69
70/* C6X specific section types */
71#define SHT_C6000_UNWIND 0x70000001
72#define SHT_C6000_PREEMPTMAP 0x70000002
73#define SHT_C6000_ATTRIBUTES 0x70000003
74
75/* C6X specific DT_ tags */
76#define DT_C6000_DSBT_BASE 0x70000000
77#define DT_C6000_DSBT_SIZE 0x70000001
78#define DT_C6000_PREEMPTMAP 0x70000002
79#define DT_C6000_DSBT_INDEX 0x70000003
80
81/* C6X specific relocs */
82#define R_C6000_NONE 0
83#define R_C6000_ABS32 1
84#define R_C6000_ABS16 2
85#define R_C6000_ABS8 3
86#define R_C6000_PCR_S21 4
87#define R_C6000_PCR_S12 5
88#define R_C6000_PCR_S10 6
89#define R_C6000_PCR_S7 7
90#define R_C6000_ABS_S16 8
91#define R_C6000_ABS_L16 9
92#define R_C6000_ABS_H16 10
93#define R_C6000_SBR_U15_B 11
94#define R_C6000_SBR_U15_H 12
95#define R_C6000_SBR_U15_W 13
96#define R_C6000_SBR_S16 14
97#define R_C6000_SBR_L16_B 15
98#define R_C6000_SBR_L16_H 16
99#define R_C6000_SBR_L16_W 17
100#define R_C6000_SBR_H16_B 18
101#define R_C6000_SBR_H16_H 19
102#define R_C6000_SBR_H16_W 20
103#define R_C6000_SBR_GOT_U15_W 21
104#define R_C6000_SBR_GOT_L16_W 22
105#define R_C6000_SBR_GOT_H16_W 23
106#define R_C6000_DSBT_INDEX 24
107#define R_C6000_PREL31 25
108#define R_C6000_COPY 26
109#define R_C6000_ALIGN 253
110#define R_C6000_FPHEAD 254
111#define R_C6000_NOCMP 255
112
113#endif /*_ASM_C6X_ELF_H */
diff --git a/arch/c6x/include/asm/ftrace.h b/arch/c6x/include/asm/ftrace.h
new file mode 100644
index 00000000000..3701958d3d1
--- /dev/null
+++ b/arch/c6x/include/asm/ftrace.h
@@ -0,0 +1,6 @@
1#ifndef _ASM_C6X_FTRACE_H
2#define _ASM_C6X_FTRACE_H
3
4/* empty */
5
6#endif /* _ASM_C6X_FTRACE_H */
diff --git a/arch/c6x/include/asm/hardirq.h b/arch/c6x/include/asm/hardirq.h
new file mode 100644
index 00000000000..9621954f98f
--- /dev/null
+++ b/arch/c6x/include/asm/hardirq.h
@@ -0,0 +1,20 @@
1/*
2 * Port on Texas Instruments TMS320C6x architecture
3 *
4 * Copyright (C) 2004, 2009, 2010 Texas Instruments Incorporated
5 * Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com)
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11
12#ifndef _ASM_C6X_HARDIRQ_H
13#define _ASM_C6X_HARDIRQ_H
14
15extern void ack_bad_irq(int irq);
16#define ack_bad_irq ack_bad_irq
17
18#include <asm-generic/hardirq.h>
19
20#endif /* _ASM_C6X_HARDIRQ_H */
diff --git a/arch/c6x/include/asm/irq.h b/arch/c6x/include/asm/irq.h
new file mode 100644
index 00000000000..a6ae3c9d9c4
--- /dev/null
+++ b/arch/c6x/include/asm/irq.h
@@ -0,0 +1,302 @@
1/*
2 * Port on Texas Instruments TMS320C6x architecture
3 *
4 * Copyright (C) 2004, 2006, 2009, 2010, 2011 Texas Instruments Incorporated
5 * Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com)
6 *
7 * Large parts taken directly from powerpc.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13#ifndef _ASM_C6X_IRQ_H
14#define _ASM_C6X_IRQ_H
15
16#include <linux/threads.h>
17#include <linux/list.h>
18#include <linux/radix-tree.h>
19#include <asm/percpu.h>
20
21#define irq_canonicalize(irq) (irq)
22
23/*
24 * The C64X+ core has 16 IRQ vectors. One each is used by Reset and NMI. Two
25 * are reserved. The remaining 12 vectors are used to route SoC interrupts.
26 * These interrupt vectors are prioritized with IRQ 4 having the highest
27 * priority and IRQ 15 having the lowest.
28 *
29 * The C64x+ megamodule provides a PIC which combines SoC IRQ sources into a
30 * single core IRQ vector. There are four combined sources, each of which
31 * feed into one of the 12 general interrupt vectors. The remaining 8 vectors
32 * can each route a single SoC interrupt directly.
33 */
34#define NR_PRIORITY_IRQS 16
35
36#define NR_IRQS_LEGACY NR_PRIORITY_IRQS
37
38/* Total number of virq in the platform */
39#define NR_IRQS 256
40
41/* This number is used when no interrupt has been assigned */
42#define NO_IRQ 0
43
44/* This type is the placeholder for a hardware interrupt number. It has to
45 * be big enough to enclose whatever representation is used by a given
46 * platform.
47 */
48typedef unsigned long irq_hw_number_t;
49
50/* Interrupt controller "host" data structure. This could be defined as a
51 * irq domain controller. That is, it handles the mapping between hardware
52 * and virtual interrupt numbers for a given interrupt domain. The host
53 * structure is generally created by the PIC code for a given PIC instance
54 * (though a host can cover more than one PIC if they have a flat number
55 * model). It's the host callbacks that are responsible for setting the
56 * irq_chip on a given irq_desc after it's been mapped.
57 *
58 * The host code and data structures are fairly agnostic to the fact that
59 * we use an open firmware device-tree. We do have references to struct
60 * device_node in two places: in irq_find_host() to find the host matching
61 * a given interrupt controller node, and of course as an argument to its
62 * counterpart host->ops->match() callback. However, those are treated as
63 * generic pointers by the core and the fact that it's actually a device-node
64 * pointer is purely a convention between callers and implementation. This
65 * code could thus be used on other architectures by replacing those two
66 * by some sort of arch-specific void * "token" used to identify interrupt
67 * controllers.
68 */
69struct irq_host;
70struct radix_tree_root;
71struct device_node;
72
73/* Functions below are provided by the host and called whenever a new mapping
74 * is created or an old mapping is disposed. The host can then proceed to
75 * whatever internal data structures management is required. It also needs
76 * to setup the irq_desc when returning from map().
77 */
78struct irq_host_ops {
79 /* Match an interrupt controller device node to a host, returns
80 * 1 on a match
81 */
82 int (*match)(struct irq_host *h, struct device_node *node);
83
84 /* Create or update a mapping between a virtual irq number and a hw
85 * irq number. This is called only once for a given mapping.
86 */
87 int (*map)(struct irq_host *h, unsigned int virq, irq_hw_number_t hw);
88
89 /* Dispose of such a mapping */
90 void (*unmap)(struct irq_host *h, unsigned int virq);
91
92 /* Translate device-tree interrupt specifier from raw format coming
93 * from the firmware to a irq_hw_number_t (interrupt line number) and
94 * type (sense) that can be passed to set_irq_type(). In the absence
95 * of this callback, irq_create_of_mapping() and irq_of_parse_and_map()
96 * will return the hw number in the first cell and IRQ_TYPE_NONE for
97 * the type (which amount to keeping whatever default value the
98 * interrupt controller has for that line)
99 */
100 int (*xlate)(struct irq_host *h, struct device_node *ctrler,
101 const u32 *intspec, unsigned int intsize,
102 irq_hw_number_t *out_hwirq, unsigned int *out_type);
103};
104
105struct irq_host {
106 struct list_head link;
107
108 /* type of reverse mapping technique */
109 unsigned int revmap_type;
110#define IRQ_HOST_MAP_PRIORITY 0 /* core priority irqs, get irqs 1..15 */
111#define IRQ_HOST_MAP_NOMAP 1 /* no fast reverse mapping */
112#define IRQ_HOST_MAP_LINEAR 2 /* linear map of interrupts */
113#define IRQ_HOST_MAP_TREE 3 /* radix tree */
114 union {
115 struct {
116 unsigned int size;
117 unsigned int *revmap;
118 } linear;
119 struct radix_tree_root tree;
120 } revmap_data;
121 struct irq_host_ops *ops;
122 void *host_data;
123 irq_hw_number_t inval_irq;
124
125 /* Optional device node pointer */
126 struct device_node *of_node;
127};
128
129struct irq_data;
130extern irq_hw_number_t irqd_to_hwirq(struct irq_data *d);
131extern irq_hw_number_t virq_to_hw(unsigned int virq);
132extern bool virq_is_host(unsigned int virq, struct irq_host *host);
133
134/**
135 * irq_alloc_host - Allocate a new irq_host data structure
136 * @of_node: optional device-tree node of the interrupt controller
137 * @revmap_type: type of reverse mapping to use
138 * @revmap_arg: for IRQ_HOST_MAP_LINEAR linear only: size of the map
139 * @ops: map/unmap host callbacks
140 * @inval_irq: provide a hw number in that host space that is always invalid
141 *
142 * Allocates and initialize and irq_host structure. Note that in the case of
143 * IRQ_HOST_MAP_LEGACY, the map() callback will be called before this returns
144 * for all legacy interrupts except 0 (which is always the invalid irq for
145 * a legacy controller). For a IRQ_HOST_MAP_LINEAR, the map is allocated by
146 * this call as well. For a IRQ_HOST_MAP_TREE, the radix tree will be allocated
147 * later during boot automatically (the reverse mapping will use the slow path
148 * until that happens).
149 */
150extern struct irq_host *irq_alloc_host(struct device_node *of_node,
151 unsigned int revmap_type,
152 unsigned int revmap_arg,
153 struct irq_host_ops *ops,
154 irq_hw_number_t inval_irq);
155
156
157/**
158 * irq_find_host - Locates a host for a given device node
159 * @node: device-tree node of the interrupt controller
160 */
161extern struct irq_host *irq_find_host(struct device_node *node);
162
163
164/**
165 * irq_set_default_host - Set a "default" host
166 * @host: default host pointer
167 *
168 * For convenience, it's possible to set a "default" host that will be used
169 * whenever NULL is passed to irq_create_mapping(). It makes life easier for
170 * platforms that want to manipulate a few hard coded interrupt numbers that
171 * aren't properly represented in the device-tree.
172 */
173extern void irq_set_default_host(struct irq_host *host);
174
175
176/**
177 * irq_set_virq_count - Set the maximum number of virt irqs
178 * @count: number of linux virtual irqs, capped with NR_IRQS
179 *
180 * This is mainly for use by platforms like iSeries who want to program
181 * the virtual irq number in the controller to avoid the reverse mapping
182 */
183extern void irq_set_virq_count(unsigned int count);
184
185
186/**
187 * irq_create_mapping - Map a hardware interrupt into linux virq space
188 * @host: host owning this hardware interrupt or NULL for default host
189 * @hwirq: hardware irq number in that host space
190 *
191 * Only one mapping per hardware interrupt is permitted. Returns a linux
192 * virq number.
193 * If the sense/trigger is to be specified, set_irq_type() should be called
194 * on the number returned from that call.
195 */
196extern unsigned int irq_create_mapping(struct irq_host *host,
197 irq_hw_number_t hwirq);
198
199
200/**
201 * irq_dispose_mapping - Unmap an interrupt
202 * @virq: linux virq number of the interrupt to unmap
203 */
204extern void irq_dispose_mapping(unsigned int virq);
205
206/**
207 * irq_find_mapping - Find a linux virq from an hw irq number.
208 * @host: host owning this hardware interrupt
209 * @hwirq: hardware irq number in that host space
210 *
211 * This is a slow path, for use by generic code. It's expected that an
212 * irq controller implementation directly calls the appropriate low level
213 * mapping function.
214 */
215extern unsigned int irq_find_mapping(struct irq_host *host,
216 irq_hw_number_t hwirq);
217
218/**
219 * irq_create_direct_mapping - Allocate a virq for direct mapping
220 * @host: host to allocate the virq for or NULL for default host
221 *
222 * This routine is used for irq controllers which can choose the hardware
223 * interrupt numbers they generate. In such a case it's simplest to use
224 * the linux virq as the hardware interrupt number.
225 */
226extern unsigned int irq_create_direct_mapping(struct irq_host *host);
227
228/**
229 * irq_radix_revmap_insert - Insert a hw irq to linux virq number mapping.
230 * @host: host owning this hardware interrupt
231 * @virq: linux irq number
232 * @hwirq: hardware irq number in that host space
233 *
234 * This is for use by irq controllers that use a radix tree reverse
235 * mapping for fast lookup.
236 */
237extern void irq_radix_revmap_insert(struct irq_host *host, unsigned int virq,
238 irq_hw_number_t hwirq);
239
240/**
241 * irq_radix_revmap_lookup - Find a linux virq from a hw irq number.
242 * @host: host owning this hardware interrupt
243 * @hwirq: hardware irq number in that host space
244 *
245 * This is a fast path, for use by irq controller code that uses radix tree
246 * revmaps
247 */
248extern unsigned int irq_radix_revmap_lookup(struct irq_host *host,
249 irq_hw_number_t hwirq);
250
251/**
252 * irq_linear_revmap - Find a linux virq from a hw irq number.
253 * @host: host owning this hardware interrupt
254 * @hwirq: hardware irq number in that host space
255 *
256 * This is a fast path, for use by irq controller code that uses linear
257 * revmaps. It does fallback to the slow path if the revmap doesn't exist
258 * yet and will create the revmap entry with appropriate locking
259 */
260
261extern unsigned int irq_linear_revmap(struct irq_host *host,
262 irq_hw_number_t hwirq);
263
264
265
266/**
267 * irq_alloc_virt - Allocate virtual irq numbers
268 * @host: host owning these new virtual irqs
269 * @count: number of consecutive numbers to allocate
270 * @hint: pass a hint number, the allocator will try to use a 1:1 mapping
271 *
272 * This is a low level function that is used internally by irq_create_mapping()
273 * and that can be used by some irq controllers implementations for things
274 * like allocating ranges of numbers for MSIs. The revmaps are left untouched.
275 */
276extern unsigned int irq_alloc_virt(struct irq_host *host,
277 unsigned int count,
278 unsigned int hint);
279
280/**
281 * irq_free_virt - Free virtual irq numbers
282 * @virq: virtual irq number of the first interrupt to free
283 * @count: number of interrupts to free
284 *
285 * This function is the opposite of irq_alloc_virt. It will not clear reverse
286 * maps, this should be done previously by unmap'ing the interrupt. In fact,
287 * all interrupts covered by the range being freed should have been unmapped
288 * prior to calling this.
289 */
290extern void irq_free_virt(unsigned int virq, unsigned int count);
291
292extern void __init init_pic_c64xplus(void);
293
294extern void init_IRQ(void);
295
296struct pt_regs;
297
298extern asmlinkage void c6x_do_IRQ(unsigned int prio, struct pt_regs *regs);
299
300extern unsigned long irq_err_count;
301
302#endif /* _ASM_C6X_IRQ_H */
diff --git a/arch/c6x/include/asm/irqflags.h b/arch/c6x/include/asm/irqflags.h
new file mode 100644
index 00000000000..cf78e09e18c
--- /dev/null
+++ b/arch/c6x/include/asm/irqflags.h
@@ -0,0 +1,72 @@
1/*
2 * C6X IRQ flag handling
3 *
4 * Copyright (C) 2010 Texas Instruments Incorporated
5 * Written by Mark Salter (msalter@redhat.com)
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public Licence
9 * as published by the Free Software Foundation; either version
10 * 2 of the Licence, or (at your option) any later version.
11 */
12
13#ifndef _ASM_IRQFLAGS_H
14#define _ASM_IRQFLAGS_H
15
16#ifndef __ASSEMBLY__
17
18/* read interrupt enabled status */
19static inline unsigned long arch_local_save_flags(void)
20{
21 unsigned long flags;
22
23 asm volatile (" mvc .s2 CSR,%0\n" : "=b"(flags));
24 return flags;
25}
26
27/* set interrupt enabled status */
28static inline void arch_local_irq_restore(unsigned long flags)
29{
30 asm volatile (" mvc .s2 %0,CSR\n" : : "b"(flags));
31}
32
33/* unconditionally enable interrupts */
34static inline void arch_local_irq_enable(void)
35{
36 unsigned long flags = arch_local_save_flags();
37 flags |= 1;
38 arch_local_irq_restore(flags);
39}
40
41/* unconditionally disable interrupts */
42static inline void arch_local_irq_disable(void)
43{
44 unsigned long flags = arch_local_save_flags();
45 flags &= ~1;
46 arch_local_irq_restore(flags);
47}
48
49/* get status and disable interrupts */
50static inline unsigned long arch_local_irq_save(void)
51{
52 unsigned long flags;
53
54 flags = arch_local_save_flags();
55 arch_local_irq_restore(flags & ~1);
56 return flags;
57}
58
59/* test flags */
60static inline int arch_irqs_disabled_flags(unsigned long flags)
61{
62 return (flags & 1) == 0;
63}
64
65/* test hardware interrupt enable bit */
66static inline int arch_irqs_disabled(void)
67{
68 return arch_irqs_disabled_flags(arch_local_save_flags());
69}
70
71#endif /* __ASSEMBLY__ */
72#endif /* __ASM_IRQFLAGS_H */
diff --git a/arch/c6x/include/asm/linkage.h b/arch/c6x/include/asm/linkage.h
new file mode 100644
index 00000000000..376925c47d5
--- /dev/null
+++ b/arch/c6x/include/asm/linkage.h
@@ -0,0 +1,30 @@
1#ifndef _ASM_C6X_LINKAGE_H
2#define _ASM_C6X_LINKAGE_H
3
4#ifdef __ASSEMBLER__
5
6#define __ALIGN .align 2
7#define __ALIGN_STR ".align 2"
8
9#ifndef __DSBT__
10#define ENTRY(name) \
11 .global name @ \
12 __ALIGN @ \
13name:
14#else
15#define ENTRY(name) \
16 .global name @ \
17 .hidden name @ \
18 __ALIGN @ \
19name:
20#endif
21
22#define ENDPROC(name) \
23 .type name, @function @ \
24 .size name, . - name
25
26#endif
27
28#include <asm-generic/linkage.h>
29
30#endif /* _ASM_C6X_LINKAGE_H */
diff --git a/arch/c6x/include/asm/megamod-pic.h b/arch/c6x/include/asm/megamod-pic.h
new file mode 100644
index 00000000000..eca0a867803
--- /dev/null
+++ b/arch/c6x/include/asm/megamod-pic.h
@@ -0,0 +1,9 @@
1#ifndef _C6X_MEGAMOD_PIC_H
2#define _C6X_MEGAMOD_PIC_H
3
4#ifdef __KERNEL__
5
6extern void __init megamod_pic_init(void);
7
8#endif /* __KERNEL__ */
9#endif /* _C6X_MEGAMOD_PIC_H */
diff --git a/arch/c6x/include/asm/mmu.h b/arch/c6x/include/asm/mmu.h
new file mode 100644
index 00000000000..41592bf1606
--- /dev/null
+++ b/arch/c6x/include/asm/mmu.h
@@ -0,0 +1,18 @@
1/*
2 * Port on Texas Instruments TMS320C6x architecture
3 *
4 * Copyright (C) 2004, 2009, 2010 Texas Instruments Incorporated
5 * Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com)
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11#ifndef _ASM_C6X_MMU_H
12#define _ASM_C6X_MMU_H
13
14typedef struct {
15 unsigned long end_brk;
16} mm_context_t;
17
18#endif /* _ASM_C6X_MMU_H */
diff --git a/arch/c6x/include/asm/module.h b/arch/c6x/include/asm/module.h
new file mode 100644
index 00000000000..a453f9744f4
--- /dev/null
+++ b/arch/c6x/include/asm/module.h
@@ -0,0 +1,33 @@
1/*
2 * Port on Texas Instruments TMS320C6x architecture
3 *
4 * Copyright (C) 2004, 2009, 2010 Texas Instruments Incorporated
5 * Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com)
6 *
7 * Updated for 2.6.34 by: Mark Salter (msalter@redhat.com)
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13#ifndef _ASM_C6X_MODULE_H
14#define _ASM_C6X_MODULE_H
15
16#define Elf_Shdr Elf32_Shdr
17#define Elf_Sym Elf32_Sym
18#define Elf_Ehdr Elf32_Ehdr
19#define Elf_Addr Elf32_Addr
20#define Elf_Word Elf32_Word
21
22/*
23 * This file contains the C6x architecture specific module code.
24 */
25struct mod_arch_specific {
26};
27
28struct loaded_sections {
29 unsigned int new_vaddr;
30 unsigned int loaded;
31};
32
33#endif /* _ASM_C6X_MODULE_H */
diff --git a/arch/c6x/include/asm/mutex.h b/arch/c6x/include/asm/mutex.h
new file mode 100644
index 00000000000..7a7248e0462
--- /dev/null
+++ b/arch/c6x/include/asm/mutex.h
@@ -0,0 +1,6 @@
1#ifndef _ASM_C6X_MUTEX_H
2#define _ASM_C6X_MUTEX_H
3
4#include <asm-generic/mutex-null.h>
5
6#endif /* _ASM_C6X_MUTEX_H */
diff --git a/arch/c6x/include/asm/page.h b/arch/c6x/include/asm/page.h
new file mode 100644
index 00000000000..d18e2b0c7ae
--- /dev/null
+++ b/arch/c6x/include/asm/page.h
@@ -0,0 +1,11 @@
1#ifndef _ASM_C6X_PAGE_H
2#define _ASM_C6X_PAGE_H
3
4#define VM_DATA_DEFAULT_FLAGS \
5 (VM_READ | VM_WRITE | \
6 ((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
7 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
8
9#include <asm-generic/page.h>
10
11#endif /* _ASM_C6X_PAGE_H */
diff --git a/arch/c6x/include/asm/pgtable.h b/arch/c6x/include/asm/pgtable.h
new file mode 100644
index 00000000000..68c8af4f1f9
--- /dev/null
+++ b/arch/c6x/include/asm/pgtable.h
@@ -0,0 +1,81 @@
1/*
2 * Port on Texas Instruments TMS320C6x architecture
3 *
4 * Copyright (C) 2004, 2009, 2010 Texas Instruments Incorporated
5 * Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com)
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11#ifndef _ASM_C6X_PGTABLE_H
12#define _ASM_C6X_PGTABLE_H
13
14#include <asm-generic/4level-fixup.h>
15
16#include <asm/setup.h>
17#include <asm/page.h>
18
19/*
20 * All 32bit addresses are effectively valid for vmalloc...
21 * Sort of meaningless for non-VM targets.
22 */
23#define VMALLOC_START 0
24#define VMALLOC_END 0xffffffff
25
26#define pgd_present(pgd) (1)
27#define pgd_none(pgd) (0)
28#define pgd_bad(pgd) (0)
29#define pgd_clear(pgdp)
30#define kern_addr_valid(addr) (1)
31
32#define pmd_offset(a, b) ((void *)0)
33#define pmd_none(x) (!pmd_val(x))
34#define pmd_present(x) (pmd_val(x))
35#define pmd_clear(xp) do { set_pmd(xp, __pmd(0)); } while (0)
36#define pmd_bad(x) (pmd_val(x) & ~PAGE_MASK)
37
38#define PAGE_NONE __pgprot(0) /* these mean nothing to NO_MM */
39#define PAGE_SHARED __pgprot(0) /* these mean nothing to NO_MM */
40#define PAGE_COPY __pgprot(0) /* these mean nothing to NO_MM */
41#define PAGE_READONLY __pgprot(0) /* these mean nothing to NO_MM */
42#define PAGE_KERNEL __pgprot(0) /* these mean nothing to NO_MM */
43#define pgprot_noncached(prot) (prot)
44
45extern void paging_init(void);
46
47#define __swp_type(x) (0)
48#define __swp_offset(x) (0)
49#define __swp_entry(typ, off) ((swp_entry_t) { ((typ) | ((off) << 7)) })
50#define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })
51#define __swp_entry_to_pte(x) ((pte_t) { (x).val })
52
53static inline int pte_file(pte_t pte)
54{
55 return 0;
56}
57
58#define set_pte(pteptr, pteval) (*(pteptr) = pteval)
59#define set_pte_at(mm, addr, ptep, pteval) set_pte(ptep, pteval)
60
61/*
62 * ZERO_PAGE is a global shared page that is always zero: used
63 * for zero-mapped memory areas etc..
64 */
65#define ZERO_PAGE(vaddr) virt_to_page(empty_zero_page)
66extern unsigned long empty_zero_page;
67
68#define swapper_pg_dir ((pgd_t *) 0)
69
70/*
71 * No page table caches to initialise
72 */
73#define pgtable_cache_init() do { } while (0)
74#define io_remap_pfn_range remap_pfn_range
75
76#define io_remap_page_range(vma, vaddr, paddr, size, prot) \
77 remap_pfn_range(vma, vaddr, (paddr) >> PAGE_SHIFT, size, prot)
78
79#include <asm-generic/pgtable.h>
80
81#endif /* _ASM_C6X_PGTABLE_H */
diff --git a/arch/c6x/include/asm/processor.h b/arch/c6x/include/asm/processor.h
new file mode 100644
index 00000000000..8154c4ee8c9
--- /dev/null
+++ b/arch/c6x/include/asm/processor.h
@@ -0,0 +1,132 @@
1/*
2 * Port on Texas Instruments TMS320C6x architecture
3 *
4 * Copyright (C) 2004, 2009, 2010, 2011 Texas Instruments Incorporated
5 * Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com)
6 *
7 * Updated for 2.6.34: Mark Salter <msalter@redhat.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13#ifndef _ASM_C6X_PROCESSOR_H
14#define _ASM_C6X_PROCESSOR_H
15
16#include <asm/ptrace.h>
17#include <asm/page.h>
18#include <asm/current.h>
19
20/*
21 * Default implementation of macro that returns current
22 * instruction pointer ("program counter").
23 */
24#define current_text_addr() \
25({ \
26 void *__pc; \
27 asm("mvc .S2 pce1,%0\n" : "=b"(__pc)); \
28 __pc; \
29})
30
31/*
32 * User space process size. This is mostly meaningless for NOMMU
33 * but some C6X processors may have RAM addresses up to 0xFFFFFFFF.
34 * Since calls like mmap() can return an address or an error, we
35 * have to allow room for error returns when code does something
36 * like:
37 *
38 * addr = do_mmap(...)
39 * if ((unsigned long)addr >= TASK_SIZE)
40 * ... its an error code, not an address ...
41 *
42 * Here, we allow for 4096 error codes which means we really can't
43 * use the last 4K page on systems with RAM extending all the way
44 * to the end of the 32-bit address space.
45 */
46#define TASK_SIZE 0xFFFFF000
47
48/*
49 * This decides where the kernel will search for a free chunk of vm
50 * space during mmap's. We won't be using it
51 */
52#define TASK_UNMAPPED_BASE 0
53
54struct thread_struct {
55 unsigned long long b15_14;
56 unsigned long long a15_14;
57 unsigned long long b13_12;
58 unsigned long long a13_12;
59 unsigned long long b11_10;
60 unsigned long long a11_10;
61 unsigned long long ricl_icl;
62 unsigned long usp; /* user stack pointer */
63 unsigned long pc; /* kernel pc */
64 unsigned long wchan;
65};
66
67#define INIT_THREAD \
68{ \
69 .usp = 0, \
70 .wchan = 0, \
71}
72
73#define INIT_MMAP { \
74 &init_mm, 0, 0, NULL, PAGE_SHARED, VM_READ | VM_WRITE | VM_EXEC, 1, \
75 NULL, NULL }
76
77#define task_pt_regs(task) \
78 ((struct pt_regs *)(THREAD_START_SP + task_stack_page(task)) - 1)
79
80#define alloc_kernel_stack() __get_free_page(GFP_KERNEL)
81#define free_kernel_stack(page) free_page((page))
82
83
84/* Forward declaration, a strange C thing */
85struct task_struct;
86
87extern void start_thread(struct pt_regs *regs, unsigned int pc,
88 unsigned long usp);
89
90/* Free all resources held by a thread. */
91static inline void release_thread(struct task_struct *dead_task)
92{
93}
94
95/* Prepare to copy thread state - unlazy all lazy status */
96#define prepare_to_copy(tsk) do { } while (0)
97
98extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
99
100#define copy_segments(tsk, mm) do { } while (0)
101#define release_segments(mm) do { } while (0)
102
103/*
104 * saved PC of a blocked thread.
105 */
106#define thread_saved_pc(tsk) (task_pt_regs(tsk)->pc)
107
108/*
109 * saved kernel SP and DP of a blocked thread.
110 */
111#ifdef _BIG_ENDIAN
112#define thread_saved_ksp(tsk) \
113 (*(unsigned long *)&(tsk)->thread.b15_14)
114#define thread_saved_dp(tsk) \
115 (*(((unsigned long *)&(tsk)->thread.b15_14) + 1))
116#else
117#define thread_saved_ksp(tsk) \
118 (*(((unsigned long *)&(tsk)->thread.b15_14) + 1))
119#define thread_saved_dp(tsk) \
120 (*(unsigned long *)&(tsk)->thread.b15_14)
121#endif
122
123extern unsigned long get_wchan(struct task_struct *p);
124
125#define KSTK_EIP(tsk) (task_pt_regs(task)->pc)
126#define KSTK_ESP(tsk) (task_pt_regs(task)->sp)
127
128#define cpu_relax() do { } while (0)
129
130extern const struct seq_operations cpuinfo_op;
131
132#endif /* ASM_C6X_PROCESSOR_H */
diff --git a/arch/c6x/include/asm/procinfo.h b/arch/c6x/include/asm/procinfo.h
new file mode 100644
index 00000000000..c139d1e71f8
--- /dev/null
+++ b/arch/c6x/include/asm/procinfo.h
@@ -0,0 +1,28 @@
1/*
2 * Copyright (C) 2010 Texas Instruments Incorporated
3 * Author: Mark Salter (msalter@redhat.com)
4 *
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
9 */
10#ifndef _ASM_C6X_PROCINFO_H
11#define _ASM_C6X_PROCINFO_H
12
13#ifdef __KERNEL__
14
15struct proc_info_list {
16 unsigned int cpu_val;
17 unsigned int cpu_mask;
18 const char *arch_name;
19 const char *elf_name;
20 unsigned int elf_hwcap;
21};
22
23#else /* __KERNEL__ */
24#include <asm/elf.h>
25#warning "Please include asm/elf.h instead"
26#endif /* __KERNEL__ */
27
28#endif /* _ASM_C6X_PROCINFO_H */
diff --git a/arch/c6x/include/asm/prom.h b/arch/c6x/include/asm/prom.h
new file mode 100644
index 00000000000..b4ec95f0751
--- /dev/null
+++ b/arch/c6x/include/asm/prom.h
@@ -0,0 +1 @@
/* dummy prom.h; here to make linux/of.h's #includes happy */
diff --git a/arch/c6x/include/asm/ptrace.h b/arch/c6x/include/asm/ptrace.h
new file mode 100644
index 00000000000..21e8d7931fe
--- /dev/null
+++ b/arch/c6x/include/asm/ptrace.h
@@ -0,0 +1,174 @@
1/*
2 * Copyright (C) 2004, 2006, 2009, 2010 Texas Instruments Incorporated
3 * Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com)
4 *
5 * Updated for 2.6.34: Mark Salter <msalter@redhat.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11#ifndef _ASM_C6X_PTRACE_H
12#define _ASM_C6X_PTRACE_H
13
14#define BKPT_OPCODE 0x56454314 /* illegal opcode */
15
16#ifdef _BIG_ENDIAN
17#define PT_LO(odd, even) odd
18#define PT_HI(odd, even) even
19#else
20#define PT_LO(odd, even) even
21#define PT_HI(odd, even) odd
22#endif
23
24#define PT_A4_ORG PT_LO(1, 0)
25#define PT_TSR PT_HI(1, 0)
26#define PT_ILC PT_LO(3, 2)
27#define PT_RILC PT_HI(3, 2)
28#define PT_CSR PT_LO(5, 4)
29#define PT_PC PT_HI(5, 4)
30#define PT_B16 PT_LO(7, 6)
31#define PT_B17 PT_HI(7, 6)
32#define PT_B18 PT_LO(9, 8)
33#define PT_B19 PT_HI(9, 8)
34#define PT_B20 PT_LO(11, 10)
35#define PT_B21 PT_HI(11, 10)
36#define PT_B22 PT_LO(13, 12)
37#define PT_B23 PT_HI(13, 12)
38#define PT_B24 PT_LO(15, 14)
39#define PT_B25 PT_HI(15, 14)
40#define PT_B26 PT_LO(17, 16)
41#define PT_B27 PT_HI(17, 16)
42#define PT_B28 PT_LO(19, 18)
43#define PT_B29 PT_HI(19, 18)
44#define PT_B30 PT_LO(21, 20)
45#define PT_B31 PT_HI(21, 20)
46#define PT_B0 PT_LO(23, 22)
47#define PT_B1 PT_HI(23, 22)
48#define PT_B2 PT_LO(25, 24)
49#define PT_B3 PT_HI(25, 24)
50#define PT_B4 PT_LO(27, 26)
51#define PT_B5 PT_HI(27, 26)
52#define PT_B6 PT_LO(29, 28)
53#define PT_B7 PT_HI(29, 28)
54#define PT_B8 PT_LO(31, 30)
55#define PT_B9 PT_HI(31, 30)
56#define PT_B10 PT_LO(33, 32)
57#define PT_B11 PT_HI(33, 32)
58#define PT_B12 PT_LO(35, 34)
59#define PT_B13 PT_HI(35, 34)
60#define PT_A16 PT_LO(37, 36)
61#define PT_A17 PT_HI(37, 36)
62#define PT_A18 PT_LO(39, 38)
63#define PT_A19 PT_HI(39, 38)
64#define PT_A20 PT_LO(41, 40)
65#define PT_A21 PT_HI(41, 40)
66#define PT_A22 PT_LO(43, 42)
67#define PT_A23 PT_HI(43, 42)
68#define PT_A24 PT_LO(45, 44)
69#define PT_A25 PT_HI(45, 44)
70#define PT_A26 PT_LO(47, 46)
71#define PT_A27 PT_HI(47, 46)
72#define PT_A28 PT_LO(49, 48)
73#define PT_A29 PT_HI(49, 48)
74#define PT_A30 PT_LO(51, 50)
75#define PT_A31 PT_HI(51, 50)
76#define PT_A0 PT_LO(53, 52)
77#define PT_A1 PT_HI(53, 52)
78#define PT_A2 PT_LO(55, 54)
79#define PT_A3 PT_HI(55, 54)
80#define PT_A4 PT_LO(57, 56)
81#define PT_A5 PT_HI(57, 56)
82#define PT_A6 PT_LO(59, 58)
83#define PT_A7 PT_HI(59, 58)
84#define PT_A8 PT_LO(61, 60)
85#define PT_A9 PT_HI(61, 60)
86#define PT_A10 PT_LO(63, 62)
87#define PT_A11 PT_HI(63, 62)
88#define PT_A12 PT_LO(65, 64)
89#define PT_A13 PT_HI(65, 64)
90#define PT_A14 PT_LO(67, 66)
91#define PT_A15 PT_HI(67, 66)
92#define PT_B14 PT_LO(69, 68)
93#define PT_B15 PT_HI(69, 68)
94
95#define NR_PTREGS 70
96
97#define PT_DP PT_B14 /* Data Segment Pointer (B14) */
98#define PT_SP PT_B15 /* Stack Pointer (B15) */
99
100#ifndef __ASSEMBLY__
101
102#ifdef _BIG_ENDIAN
103#define REG_PAIR(odd, even) unsigned long odd; unsigned long even
104#else
105#define REG_PAIR(odd, even) unsigned long even; unsigned long odd
106#endif
107
108/*
109 * this struct defines the way the registers are stored on the
110 * stack during a system call. fields defined with REG_PAIR
111 * are saved and restored using double-word memory operations
112 * which means the word ordering of the pair depends on endianess.
113 */
114struct pt_regs {
115 REG_PAIR(tsr, orig_a4);
116 REG_PAIR(rilc, ilc);
117 REG_PAIR(pc, csr);
118
119 REG_PAIR(b17, b16);
120 REG_PAIR(b19, b18);
121 REG_PAIR(b21, b20);
122 REG_PAIR(b23, b22);
123 REG_PAIR(b25, b24);
124 REG_PAIR(b27, b26);
125 REG_PAIR(b29, b28);
126 REG_PAIR(b31, b30);
127
128 REG_PAIR(b1, b0);
129 REG_PAIR(b3, b2);
130 REG_PAIR(b5, b4);
131 REG_PAIR(b7, b6);
132 REG_PAIR(b9, b8);
133 REG_PAIR(b11, b10);
134 REG_PAIR(b13, b12);
135
136 REG_PAIR(a17, a16);
137 REG_PAIR(a19, a18);
138 REG_PAIR(a21, a20);
139 REG_PAIR(a23, a22);
140 REG_PAIR(a25, a24);
141 REG_PAIR(a27, a26);
142 REG_PAIR(a29, a28);
143 REG_PAIR(a31, a30);
144
145 REG_PAIR(a1, a0);
146 REG_PAIR(a3, a2);
147 REG_PAIR(a5, a4);
148 REG_PAIR(a7, a6);
149 REG_PAIR(a9, a8);
150 REG_PAIR(a11, a10);
151 REG_PAIR(a13, a12);
152
153 REG_PAIR(a15, a14);
154 REG_PAIR(sp, dp);
155};
156
157#ifdef __KERNEL__
158
159#include <linux/linkage.h>
160
161#define user_mode(regs) ((((regs)->tsr) & 0x40) != 0)
162
163#define instruction_pointer(regs) ((regs)->pc)
164#define profile_pc(regs) instruction_pointer(regs)
165#define user_stack_pointer(regs) ((regs)->sp)
166
167extern void show_regs(struct pt_regs *);
168
169extern asmlinkage unsigned long syscall_trace_entry(struct pt_regs *regs);
170extern asmlinkage void syscall_trace_exit(struct pt_regs *regs);
171
172#endif /* __KERNEL__ */
173#endif /* __ASSEMBLY__ */
174#endif /* _ASM_C6X_PTRACE_H */
diff --git a/arch/c6x/include/asm/sections.h b/arch/c6x/include/asm/sections.h
new file mode 100644
index 00000000000..f703989d837
--- /dev/null
+++ b/arch/c6x/include/asm/sections.h
@@ -0,0 +1,12 @@
1#ifndef _ASM_C6X_SECTIONS_H
2#define _ASM_C6X_SECTIONS_H
3
4#include <asm-generic/sections.h>
5
6extern char _vectors_start[];
7extern char _vectors_end[];
8
9extern char _data_lma[];
10extern char _fdt_start[], _fdt_end[];
11
12#endif /* _ASM_C6X_SECTIONS_H */
diff --git a/arch/c6x/include/asm/setup.h b/arch/c6x/include/asm/setup.h
new file mode 100644
index 00000000000..1808f279f82
--- /dev/null
+++ b/arch/c6x/include/asm/setup.h
@@ -0,0 +1,32 @@
1/*
2 * Port on Texas Instruments TMS320C6x architecture
3 *
4 * Copyright (C) 2004, 2009, 2010 2011 Texas Instruments Incorporated
5 * Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com)
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11#ifndef _ASM_C6X_SETUP_H
12#define _ASM_C6X_SETUP_H
13
14#define COMMAND_LINE_SIZE 1024
15
16#ifndef __ASSEMBLY__
17extern char c6x_command_line[COMMAND_LINE_SIZE];
18
19extern int c6x_add_memory(phys_addr_t start, unsigned long size);
20
21extern unsigned long ram_start;
22extern unsigned long ram_end;
23
24extern int c6x_num_cores;
25extern unsigned int c6x_silicon_rev;
26extern unsigned int c6x_devstat;
27extern unsigned char c6x_fuse_mac[6];
28
29extern void machine_init(unsigned long dt_ptr);
30
31#endif /* !__ASSEMBLY__ */
32#endif /* _ASM_C6X_SETUP_H */
diff --git a/arch/c6x/include/asm/sigcontext.h b/arch/c6x/include/asm/sigcontext.h
new file mode 100644
index 00000000000..eb702f39cde
--- /dev/null
+++ b/arch/c6x/include/asm/sigcontext.h
@@ -0,0 +1,80 @@
1/*
2 * Port on Texas Instruments TMS320C6x architecture
3 *
4 * Copyright (C) 2004, 2009 Texas Instruments Incorporated
5 * Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com)
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11#ifndef _ASM_C6X_SIGCONTEXT_H
12#define _ASM_C6X_SIGCONTEXT_H
13
14
15struct sigcontext {
16 unsigned long sc_mask; /* old sigmask */
17 unsigned long sc_sp; /* old user stack pointer */
18
19 unsigned long sc_a4;
20 unsigned long sc_b4;
21 unsigned long sc_a6;
22 unsigned long sc_b6;
23 unsigned long sc_a8;
24 unsigned long sc_b8;
25
26 unsigned long sc_a0;
27 unsigned long sc_a1;
28 unsigned long sc_a2;
29 unsigned long sc_a3;
30 unsigned long sc_a5;
31 unsigned long sc_a7;
32 unsigned long sc_a9;
33
34 unsigned long sc_b0;
35 unsigned long sc_b1;
36 unsigned long sc_b2;
37 unsigned long sc_b3;
38 unsigned long sc_b5;
39 unsigned long sc_b7;
40 unsigned long sc_b9;
41
42 unsigned long sc_a16;
43 unsigned long sc_a17;
44 unsigned long sc_a18;
45 unsigned long sc_a19;
46 unsigned long sc_a20;
47 unsigned long sc_a21;
48 unsigned long sc_a22;
49 unsigned long sc_a23;
50 unsigned long sc_a24;
51 unsigned long sc_a25;
52 unsigned long sc_a26;
53 unsigned long sc_a27;
54 unsigned long sc_a28;
55 unsigned long sc_a29;
56 unsigned long sc_a30;
57 unsigned long sc_a31;
58
59 unsigned long sc_b16;
60 unsigned long sc_b17;
61 unsigned long sc_b18;
62 unsigned long sc_b19;
63 unsigned long sc_b20;
64 unsigned long sc_b21;
65 unsigned long sc_b22;
66 unsigned long sc_b23;
67 unsigned long sc_b24;
68 unsigned long sc_b25;
69 unsigned long sc_b26;
70 unsigned long sc_b27;
71 unsigned long sc_b28;
72 unsigned long sc_b29;
73 unsigned long sc_b30;
74 unsigned long sc_b31;
75
76 unsigned long sc_csr;
77 unsigned long sc_pc;
78};
79
80#endif /* _ASM_C6X_SIGCONTEXT_H */
diff --git a/arch/c6x/include/asm/signal.h b/arch/c6x/include/asm/signal.h
new file mode 100644
index 00000000000..f1cd870596a
--- /dev/null
+++ b/arch/c6x/include/asm/signal.h
@@ -0,0 +1,17 @@
1#ifndef _ASM_C6X_SIGNAL_H
2#define _ASM_C6X_SIGNAL_H
3
4#include <asm-generic/signal.h>
5
6#ifndef __ASSEMBLY__
7#include <linux/linkage.h>
8
9struct pt_regs;
10
11extern asmlinkage int do_rt_sigreturn(struct pt_regs *regs);
12extern asmlinkage void do_notify_resume(struct pt_regs *regs,
13 u32 thread_info_flags,
14 int syscall);
15#endif
16
17#endif /* _ASM_C6X_SIGNAL_H */
diff --git a/arch/c6x/include/asm/soc.h b/arch/c6x/include/asm/soc.h
new file mode 100644
index 00000000000..43f50159e59
--- /dev/null
+++ b/arch/c6x/include/asm/soc.h
@@ -0,0 +1,35 @@
1/*
2 * Miscellaneous SoC-specific hooks.
3 *
4 * Copyright (C) 2011 Texas Instruments Incorporated
5 *
6 * Author: Mark Salter <msalter@redhat.com>
7 *
8 * This file is licensed under the terms of the GNU General Public License
9 * version 2. This program is licensed "as is" without any warranty of any
10 * kind, whether express or implied.
11 */
12#ifndef _ASM_C6X_SOC_H
13#define _ASM_C6X_SOC_H
14
15struct soc_ops {
16 /* Return active exception event or -1 if none */
17 int (*get_exception)(void);
18
19 /* Assert an event */
20 void (*assert_event)(unsigned int evt);
21};
22
23extern struct soc_ops soc_ops;
24
25extern int soc_get_exception(void);
26extern void soc_assert_event(unsigned int event);
27extern int soc_mac_addr(unsigned int index, u8 *addr);
28
29/*
30 * for mmio on SoC devices. regs are always same byte order as cpu.
31 */
32#define soc_readl(addr) __raw_readl(addr)
33#define soc_writel(b, addr) __raw_writel((b), (addr))
34
35#endif /* _ASM_C6X_SOC_H */
diff --git a/arch/c6x/include/asm/string.h b/arch/c6x/include/asm/string.h
new file mode 100644
index 00000000000..b21517c80a1
--- /dev/null
+++ b/arch/c6x/include/asm/string.h
@@ -0,0 +1,21 @@
1/*
2 * Port on Texas Instruments TMS320C6x architecture
3 *
4 * Copyright (C) 2004, 2009, 2011 Texas Instruments Incorporated
5 * Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com)
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11#ifndef _ASM_C6X_STRING_H
12#define _ASM_C6X_STRING_H
13
14#include <asm/page.h>
15#include <linux/linkage.h>
16
17asmlinkage extern void *memcpy(void *to, const void *from, size_t n);
18
19#define __HAVE_ARCH_MEMCPY
20
21#endif /* _ASM_C6X_STRING_H */
diff --git a/arch/c6x/include/asm/swab.h b/arch/c6x/include/asm/swab.h
new file mode 100644
index 00000000000..fd4bb0520e5
--- /dev/null
+++ b/arch/c6x/include/asm/swab.h
@@ -0,0 +1,54 @@
1/*
2 * Copyright (C) 2011 Texas Instruments Incorporated
3 * Author: Mark Salter <msalter@redhat.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */
9#ifndef _ASM_C6X_SWAB_H
10#define _ASM_C6X_SWAB_H
11
12static inline __attribute_const__ __u16 __c6x_swab16(__u16 val)
13{
14 asm("swap4 .l1 %0,%0\n" : "+a"(val));
15 return val;
16}
17
18static inline __attribute_const__ __u32 __c6x_swab32(__u32 val)
19{
20 asm("swap4 .l1 %0,%0\n"
21 "swap2 .l1 %0,%0\n"
22 : "+a"(val));
23 return val;
24}
25
26static inline __attribute_const__ __u64 __c6x_swab64(__u64 val)
27{
28 asm(" swap2 .s1 %p0,%P0\n"
29 "|| swap2 .l1 %P0,%p0\n"
30 " swap4 .l1 %p0,%p0\n"
31 " swap4 .l1 %P0,%P0\n"
32 : "+a"(val));
33 return val;
34}
35
36static inline __attribute_const__ __u32 __c6x_swahw32(__u32 val)
37{
38 asm("swap2 .l1 %0,%0\n" : "+a"(val));
39 return val;
40}
41
42static inline __attribute_const__ __u32 __c6x_swahb32(__u32 val)
43{
44 asm("swap4 .l1 %0,%0\n" : "+a"(val));
45 return val;
46}
47
48#define __arch_swab16 __c6x_swab16
49#define __arch_swab32 __c6x_swab32
50#define __arch_swab64 __c6x_swab64
51#define __arch_swahw32 __c6x_swahw32
52#define __arch_swahb32 __c6x_swahb32
53
54#endif /* _ASM_C6X_SWAB_H */
diff --git a/arch/c6x/include/asm/syscall.h b/arch/c6x/include/asm/syscall.h
new file mode 100644
index 00000000000..ae2be315ee9
--- /dev/null
+++ b/arch/c6x/include/asm/syscall.h
@@ -0,0 +1,123 @@
1/*
2 * Copyright (C) 2011 Texas Instruments Incorporated
3 * Author: Mark Salter <msalter@redhat.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 */
10
11#ifndef __ASM_C6X_SYSCALL_H
12#define __ASM_C6X_SYSCALL_H
13
14#include <linux/err.h>
15#include <linux/sched.h>
16
17static inline int syscall_get_nr(struct task_struct *task,
18 struct pt_regs *regs)
19{
20 return regs->b0;
21}
22
23static inline void syscall_rollback(struct task_struct *task,
24 struct pt_regs *regs)
25{
26 /* do nothing */
27}
28
29static inline long syscall_get_error(struct task_struct *task,
30 struct pt_regs *regs)
31{
32 return IS_ERR_VALUE(regs->a4) ? regs->a4 : 0;
33}
34
35static inline long syscall_get_return_value(struct task_struct *task,
36 struct pt_regs *regs)
37{
38 return regs->a4;
39}
40
41static inline void syscall_set_return_value(struct task_struct *task,
42 struct pt_regs *regs,
43 int error, long val)
44{
45 regs->a4 = error ?: val;
46}
47
48static inline void syscall_get_arguments(struct task_struct *task,
49 struct pt_regs *regs, unsigned int i,
50 unsigned int n, unsigned long *args)
51{
52 switch (i) {
53 case 0:
54 if (!n--)
55 break;
56 *args++ = regs->a4;
57 case 1:
58 if (!n--)
59 break;
60 *args++ = regs->b4;
61 case 2:
62 if (!n--)
63 break;
64 *args++ = regs->a6;
65 case 3:
66 if (!n--)
67 break;
68 *args++ = regs->b6;
69 case 4:
70 if (!n--)
71 break;
72 *args++ = regs->a8;
73 case 5:
74 if (!n--)
75 break;
76 *args++ = regs->b8;
77 case 6:
78 if (!n--)
79 break;
80 default:
81 BUG();
82 }
83}
84
85static inline void syscall_set_arguments(struct task_struct *task,
86 struct pt_regs *regs,
87 unsigned int i, unsigned int n,
88 const unsigned long *args)
89{
90 switch (i) {
91 case 0:
92 if (!n--)
93 break;
94 regs->a4 = *args++;
95 case 1:
96 if (!n--)
97 break;
98 regs->b4 = *args++;
99 case 2:
100 if (!n--)
101 break;
102 regs->a6 = *args++;
103 case 3:
104 if (!n--)
105 break;
106 regs->b6 = *args++;
107 case 4:
108 if (!n--)
109 break;
110 regs->a8 = *args++;
111 case 5:
112 if (!n--)
113 break;
114 regs->a9 = *args++;
115 case 6:
116 if (!n)
117 break;
118 default:
119 BUG();
120 }
121}
122
123#endif /* __ASM_C6X_SYSCALLS_H */
diff --git a/arch/c6x/include/asm/syscalls.h b/arch/c6x/include/asm/syscalls.h
new file mode 100644
index 00000000000..aed53da703c
--- /dev/null
+++ b/arch/c6x/include/asm/syscalls.h
@@ -0,0 +1,55 @@
1/*
2 * Copyright (C) 2011 Texas Instruments Incorporated
3 * Author: Mark Salter <msalter@redhat.com>
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation, version 2.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
12 * NON INFRINGEMENT. See the GNU General Public License for
13 * more details.
14 */
15
16#ifndef __ASM_C6X_SYSCALLS_H
17#define __ASM_C6X_SYSCALLS_H
18
19#include <linux/compiler.h>
20#include <linux/linkage.h>
21#include <linux/types.h>
22
23/* The array of function pointers for syscalls. */
24extern void *sys_call_table[];
25
26/* The following are trampolines in entry.S to handle 64-bit arguments */
27extern long sys_pread_c6x(unsigned int fd, char __user *buf,
28 size_t count, off_t pos_low, off_t pos_high);
29extern long sys_pwrite_c6x(unsigned int fd, const char __user *buf,
30 size_t count, off_t pos_low, off_t pos_high);
31extern long sys_truncate64_c6x(const char __user *path,
32 off_t length_low, off_t length_high);
33extern long sys_ftruncate64_c6x(unsigned int fd,
34 off_t length_low, off_t length_high);
35extern long sys_fadvise64_c6x(int fd, u32 offset_lo, u32 offset_hi,
36 u32 len, int advice);
37extern long sys_fadvise64_64_c6x(int fd, u32 offset_lo, u32 offset_hi,
38 u32 len_lo, u32 len_hi, int advice);
39extern long sys_fallocate_c6x(int fd, int mode,
40 u32 offset_lo, u32 offset_hi,
41 u32 len_lo, u32 len_hi);
42extern int sys_cache_sync(unsigned long s, unsigned long e);
43
44struct pt_regs;
45
46extern asmlinkage long sys_c6x_clone(struct pt_regs *regs);
47extern asmlinkage long sys_c6x_execve(const char __user *name,
48 const char __user *const __user *argv,
49 const char __user *const __user *envp,
50 struct pt_regs *regs);
51
52
53#include <asm-generic/syscalls.h>
54
55#endif /* __ASM_C6X_SYSCALLS_H */
diff --git a/arch/c6x/include/asm/system.h b/arch/c6x/include/asm/system.h
new file mode 100644
index 00000000000..e076dc0eacc
--- /dev/null
+++ b/arch/c6x/include/asm/system.h
@@ -0,0 +1,168 @@
1/*
2 * Port on Texas Instruments TMS320C6x architecture
3 *
4 * Copyright (C) 2004, 2009, 2010, 2011 Texas Instruments Incorporated
5 * Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com)
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11#ifndef _ASM_C6X_SYSTEM_H
12#define _ASM_C6X_SYSTEM_H
13
14#include <linux/linkage.h>
15#include <linux/irqflags.h>
16
17#define prepare_to_switch() do { } while (0)
18
19struct task_struct;
20struct thread_struct;
21asmlinkage void *__switch_to(struct thread_struct *prev,
22 struct thread_struct *next,
23 struct task_struct *tsk);
24
25#define switch_to(prev, next, last) \
26 do { \
27 current->thread.wchan = (u_long) __builtin_return_address(0); \
28 (last) = __switch_to(&(prev)->thread, \
29 &(next)->thread, (prev)); \
30 mb(); \
31 current->thread.wchan = 0; \
32 } while (0)
33
34/* Reset the board */
35#define HARD_RESET_NOW()
36
37#define get_creg(reg) \
38 ({ unsigned int __x; \
39 asm volatile ("mvc .s2 " #reg ",%0\n" : "=b"(__x)); __x; })
40
41#define set_creg(reg, v) \
42 do { unsigned int __x = (unsigned int)(v); \
43 asm volatile ("mvc .s2 %0," #reg "\n" : : "b"(__x)); \
44 } while (0)
45
46#define or_creg(reg, n) \
47 do { unsigned __x, __n = (unsigned)(n); \
48 asm volatile ("mvc .s2 " #reg ",%0\n" \
49 "or .l2 %1,%0,%0\n" \
50 "mvc .s2 %0," #reg "\n" \
51 "nop\n" \
52 : "=&b"(__x) : "b"(__n)); \
53 } while (0)
54
55#define and_creg(reg, n) \
56 do { unsigned __x, __n = (unsigned)(n); \
57 asm volatile ("mvc .s2 " #reg ",%0\n" \
58 "and .l2 %1,%0,%0\n" \
59 "mvc .s2 %0," #reg "\n" \
60 "nop\n" \
61 : "=&b"(__x) : "b"(__n)); \
62 } while (0)
63
64#define get_coreid() (get_creg(DNUM) & 0xff)
65
66/* Set/get IST */
67#define set_ist(x) set_creg(ISTP, x)
68#define get_ist() get_creg(ISTP)
69
70/*
71 * Exception management
72 */
73asmlinkage void enable_exception(void);
74#define disable_exception()
75#define get_except_type() get_creg(EFR)
76#define ack_exception(type) set_creg(ECR, 1 << (type))
77#define get_iexcept() get_creg(IERR)
78#define set_iexcept(mask) set_creg(IERR, (mask))
79
80/*
81 * Misc. functions
82 */
83#define nop() asm("NOP\n");
84#define mb() barrier()
85#define rmb() barrier()
86#define wmb() barrier()
87#define set_mb(var, value) do { var = value; mb(); } while (0)
88#define set_wmb(var, value) do { var = value; wmb(); } while (0)
89
90#define smp_mb() barrier()
91#define smp_rmb() barrier()
92#define smp_wmb() barrier()
93#define smp_read_barrier_depends() do { } while (0)
94
95#define xchg(ptr, x) \
96 ((__typeof__(*(ptr)))__xchg((unsigned int)(x), (void *) (ptr), \
97 sizeof(*(ptr))))
98#define tas(ptr) xchg((ptr), 1)
99
100unsigned int _lmbd(unsigned int, unsigned int);
101unsigned int _bitr(unsigned int);
102
103struct __xchg_dummy { unsigned int a[100]; };
104#define __xg(x) ((volatile struct __xchg_dummy *)(x))
105
106static inline unsigned int __xchg(unsigned int x, volatile void *ptr, int size)
107{
108 unsigned int tmp;
109 unsigned long flags;
110
111 local_irq_save(flags);
112
113 switch (size) {
114 case 1:
115 tmp = 0;
116 tmp = *((unsigned char *) ptr);
117 *((unsigned char *) ptr) = (unsigned char) x;
118 break;
119 case 2:
120 tmp = 0;
121 tmp = *((unsigned short *) ptr);
122 *((unsigned short *) ptr) = x;
123 break;
124 case 4:
125 tmp = 0;
126 tmp = *((unsigned int *) ptr);
127 *((unsigned int *) ptr) = x;
128 break;
129 }
130 local_irq_restore(flags);
131 return tmp;
132}
133
134#include <asm-generic/cmpxchg-local.h>
135
136/*
137 * cmpxchg_local and cmpxchg64_local are atomic wrt current CPU. Always make
138 * them available.
139 */
140#define cmpxchg_local(ptr, o, n) \
141 ((__typeof__(*(ptr)))__cmpxchg_local_generic((ptr), \
142 (unsigned long)(o), \
143 (unsigned long)(n), \
144 sizeof(*(ptr))))
145#define cmpxchg64_local(ptr, o, n) __cmpxchg64_local_generic((ptr), (o), (n))
146
147#include <asm-generic/cmpxchg.h>
148
149#define _extu(x, s, e) \
150 ({ unsigned int __x; \
151 asm volatile ("extu .S2 %3,%1,%2,%0\n" : \
152 "=b"(__x) : "n"(s), "n"(e), "b"(x)); \
153 __x; })
154
155
156extern unsigned int c6x_core_freq;
157
158struct pt_regs;
159
160extern void die(char *str, struct pt_regs *fp, int nr);
161extern asmlinkage int process_exception(struct pt_regs *regs);
162extern void time_init(void);
163extern void free_initmem(void);
164
165extern void (*c6x_restart)(void);
166extern void (*c6x_halt)(void);
167
168#endif /* _ASM_C6X_SYSTEM_H */
diff --git a/arch/c6x/include/asm/thread_info.h b/arch/c6x/include/asm/thread_info.h
new file mode 100644
index 00000000000..fd99148cda9
--- /dev/null
+++ b/arch/c6x/include/asm/thread_info.h
@@ -0,0 +1,121 @@
1/*
2 * Port on Texas Instruments TMS320C6x architecture
3 *
4 * Copyright (C) 2004, 2009, 2010, 2011 Texas Instruments Incorporated
5 * Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com)
6 *
7 * Updated for 2.6.3x: Mark Salter <msalter@redhat.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13#ifndef _ASM_C6X_THREAD_INFO_H
14#define _ASM_C6X_THREAD_INFO_H
15
16#ifdef __KERNEL__
17
18#include <asm/page.h>
19
20#ifdef CONFIG_4KSTACKS
21#define THREAD_SIZE 4096
22#define THREAD_SHIFT 12
23#define THREAD_ORDER 0
24#else
25#define THREAD_SIZE 8192
26#define THREAD_SHIFT 13
27#define THREAD_ORDER 1
28#endif
29
30#define THREAD_START_SP (THREAD_SIZE - 8)
31
32#ifndef __ASSEMBLY__
33
34typedef struct {
35 unsigned long seg;
36} mm_segment_t;
37
38/*
39 * low level task data.
40 */
41struct thread_info {
42 struct task_struct *task; /* main task structure */
43 struct exec_domain *exec_domain; /* execution domain */
44 unsigned long flags; /* low level flags */
45 int cpu; /* cpu we're on */
46 int preempt_count; /* 0 = preemptable, <0 = BUG */
47 mm_segment_t addr_limit; /* thread address space */
48 struct restart_block restart_block;
49};
50
51/*
52 * macros/functions for gaining access to the thread information structure
53 *
54 * preempt_count needs to be 1 initially, until the scheduler is functional.
55 */
56#define INIT_THREAD_INFO(tsk) \
57{ \
58 .task = &tsk, \
59 .exec_domain = &default_exec_domain, \
60 .flags = 0, \
61 .cpu = 0, \
62 .preempt_count = INIT_PREEMPT_COUNT, \
63 .addr_limit = KERNEL_DS, \
64 .restart_block = { \
65 .fn = do_no_restart_syscall, \
66 }, \
67}
68
69#define init_thread_info (init_thread_union.thread_info)
70#define init_stack (init_thread_union.stack)
71
72/* get the thread information struct of current task */
73static inline __attribute__((const))
74struct thread_info *current_thread_info(void)
75{
76 struct thread_info *ti;
77 asm volatile (" clr .s2 B15,0,%1,%0\n"
78 : "=b" (ti)
79 : "Iu5" (THREAD_SHIFT - 1));
80 return ti;
81}
82
83#define __HAVE_ARCH_THREAD_INFO_ALLOCATOR
84
85/* thread information allocation */
86#ifdef CONFIG_DEBUG_STACK_USAGE
87#define THREAD_FLAGS (GFP_KERNEL | __GFP_NOTRACK | __GFP_ZERO)
88#else
89#define THREAD_FLAGS (GFP_KERNEL | __GFP_NOTRACK)
90#endif
91
92#define alloc_thread_info_node(tsk, node) \
93 ((struct thread_info *)__get_free_pages(THREAD_FLAGS, THREAD_ORDER))
94
95#define free_thread_info(ti) free_pages((unsigned long) (ti), THREAD_ORDER)
96#define get_thread_info(ti) get_task_struct((ti)->task)
97#define put_thread_info(ti) put_task_struct((ti)->task)
98#endif /* __ASSEMBLY__ */
99
100#define PREEMPT_ACTIVE 0x10000000
101
102/*
103 * thread information flag bit numbers
104 * - pending work-to-be-done flags are in LSW
105 * - other flags in MSW
106 */
107#define TIF_SYSCALL_TRACE 0 /* syscall trace active */
108#define TIF_NOTIFY_RESUME 1 /* resumption notification requested */
109#define TIF_SIGPENDING 2 /* signal pending */
110#define TIF_NEED_RESCHED 3 /* rescheduling necessary */
111#define TIF_RESTORE_SIGMASK 4 /* restore signal mask in do_signal() */
112
113#define TIF_POLLING_NRFLAG 16 /* true if polling TIF_NEED_RESCHED */
114#define TIF_MEMDIE 17 /* OOM killer killed process */
115
116#define TIF_WORK_MASK 0x00007FFE /* work on irq/exception return */
117#define TIF_ALLWORK_MASK 0x00007FFF /* work on any return to u-space */
118
119#endif /* __KERNEL__ */
120
121#endif /* _ASM_C6X_THREAD_INFO_H */
diff --git a/arch/c6x/include/asm/timer64.h b/arch/c6x/include/asm/timer64.h
new file mode 100644
index 00000000000..bbe27bb9887
--- /dev/null
+++ b/arch/c6x/include/asm/timer64.h
@@ -0,0 +1,6 @@
1#ifndef _C6X_TIMER64_H
2#define _C6X_TIMER64_H
3
4extern void __init timer64_init(void);
5
6#endif /* _C6X_TIMER64_H */
diff --git a/arch/c6x/include/asm/timex.h b/arch/c6x/include/asm/timex.h
new file mode 100644
index 00000000000..508c3ec971f
--- /dev/null
+++ b/arch/c6x/include/asm/timex.h
@@ -0,0 +1,33 @@
1/*
2 * Port on Texas Instruments TMS320C6x architecture
3 *
4 * Copyright (C) 2004, 2009, 2010, 2011 Texas Instruments Incorporated
5 * Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com)
6 *
7 * Modified for 2.6.34: Mark Salter <msalter@redhat.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
13#ifndef _ASM_C6X_TIMEX_H
14#define _ASM_C6X_TIMEX_H
15
16#define CLOCK_TICK_RATE ((1000 * 1000000UL) / 6)
17
18/* 64-bit timestamp */
19typedef unsigned long long cycles_t;
20
21static inline cycles_t get_cycles(void)
22{
23 unsigned l, h;
24
25 asm volatile (" dint\n"
26 " mvc .s2 TSCL,%0\n"
27 " mvc .s2 TSCH,%1\n"
28 " rint\n"
29 : "=b"(l), "=b"(h));
30 return ((cycles_t)h << 32) | l;
31}
32
33#endif /* _ASM_C6X_TIMEX_H */
diff --git a/arch/c6x/include/asm/tlb.h b/arch/c6x/include/asm/tlb.h
new file mode 100644
index 00000000000..8709e5e29d2
--- /dev/null
+++ b/arch/c6x/include/asm/tlb.h
@@ -0,0 +1,8 @@
1#ifndef _ASM_C6X_TLB_H
2#define _ASM_C6X_TLB_H
3
4#define tlb_flush(tlb) flush_tlb_mm((tlb)->mm)
5
6#include <asm-generic/tlb.h>
7
8#endif /* _ASM_C6X_TLB_H */
diff --git a/arch/c6x/include/asm/traps.h b/arch/c6x/include/asm/traps.h
new file mode 100644
index 00000000000..62124d7b1b5
--- /dev/null
+++ b/arch/c6x/include/asm/traps.h
@@ -0,0 +1,36 @@
1/*
2 * Port on Texas Instruments TMS320C6x architecture
3 *
4 * Copyright (C) 2004, 2009, 2011 Texas Instruments Incorporated
5 * Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com)
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 */
11#ifndef _ASM_C6X_TRAPS_H
12#define _ASM_C6X_TRAPS_H
13
14#define EXCEPT_TYPE_NXF 31 /* NMI */
15#define EXCEPT_TYPE_EXC 30 /* external exception */
16#define EXCEPT_TYPE_IXF 1 /* internal exception */
17#define EXCEPT_TYPE_SXF 0 /* software exception */
18
19#define EXCEPT_CAUSE_LBX (1 << 7) /* loop buffer exception */
20#define EXCEPT_CAUSE_PRX (1 << 6) /* privilege exception */
21#define EXCEPT_CAUSE_RAX (1 << 5) /* resource access exception */
22#define EXCEPT_CAUSE_RCX (1 << 4) /* resource conflict exception */
23#define EXCEPT_CAUSE_OPX (1 << 3) /* opcode exception */
24#define EXCEPT_CAUSE_EPX (1 << 2) /* execute packet exception */
25#define EXCEPT_CAUSE_FPX (1 << 1) /* fetch packet exception */
26#define EXCEPT_CAUSE_IFX (1 << 0) /* instruction fetch exception */
27
28struct exception_info {
29 char *kernel_str;
30 int signo;
31 int code;
32};
33
34extern int (*c6x_nmi_handler)(struct pt_regs *regs);
35
36#endif /* _ASM_C6X_TRAPS_H */
diff --git a/arch/c6x/include/asm/uaccess.h b/arch/c6x/include/asm/uaccess.h
new file mode 100644
index 00000000000..453dd263bee
--- /dev/null
+++ b/arch/c6x/include/asm/uaccess.h
@@ -0,0 +1,107 @@
1/*
2 * Copyright (C) 2011 Texas Instruments Incorporated
3 * Author: Mark Salter <msalter@redhat.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 2 as
7 * published by the Free Software Foundation.
8 */
9#ifndef _ASM_C6X_UACCESS_H
10#define _ASM_C6X_UACCESS_H
11
12#include <linux/types.h>
13#include <linux/compiler.h>
14#include <linux/string.h>
15
16#ifdef CONFIG_ACCESS_CHECK
17#define __access_ok _access_ok
18#endif
19
20/*
21 * __copy_from_user/copy_to_user are based on ones in asm-generic/uaccess.h
22 *
23 * C6X supports unaligned 32 and 64 bit loads and stores.
24 */
25static inline __must_check long __copy_from_user(void *to,
26 const void __user *from, unsigned long n)
27{
28 u32 tmp32;
29 u64 tmp64;
30
31 if (__builtin_constant_p(n)) {
32 switch (n) {
33 case 1:
34 *(u8 *)to = *(u8 __force *)from;
35 return 0;
36 case 4:
37 asm volatile ("ldnw .d1t1 *%2,%0\n"
38 "nop 4\n"
39 "stnw .d1t1 %0,*%1\n"
40 : "=&a"(tmp32)
41 : "A"(to), "a"(from)
42 : "memory");
43 return 0;
44 case 8:
45 asm volatile ("ldndw .d1t1 *%2,%0\n"
46 "nop 4\n"
47 "stndw .d1t1 %0,*%1\n"
48 : "=&a"(tmp64)
49 : "a"(to), "a"(from)
50 : "memory");
51 return 0;
52 default:
53 break;
54 }
55 }
56
57 memcpy(to, (const void __force *)from, n);
58 return 0;
59}
60
61static inline __must_check long __copy_to_user(void __user *to,
62 const void *from, unsigned long n)
63{
64 u32 tmp32;
65 u64 tmp64;
66
67 if (__builtin_constant_p(n)) {
68 switch (n) {
69 case 1:
70 *(u8 __force *)to = *(u8 *)from;
71 return 0;
72 case 4:
73 asm volatile ("ldnw .d1t1 *%2,%0\n"
74 "nop 4\n"
75 "stnw .d1t1 %0,*%1\n"
76 : "=&a"(tmp32)
77 : "a"(to), "a"(from)
78 : "memory");
79 return 0;
80 case 8:
81 asm volatile ("ldndw .d1t1 *%2,%0\n"
82 "nop 4\n"
83 "stndw .d1t1 %0,*%1\n"
84 : "=&a"(tmp64)
85 : "a"(to), "a"(from)
86 : "memory");
87 return 0;
88 default:
89 break;
90 }
91 }
92
93 memcpy((void __force *)to, from, n);
94 return 0;
95}
96
97#define __copy_to_user __copy_to_user
98#define __copy_from_user __copy_from_user
99
100extern int _access_ok(unsigned long addr, unsigned long size);
101#ifdef CONFIG_ACCESS_CHECK
102#define __access_ok _access_ok
103#endif
104
105#include <asm-generic/uaccess.h>
106
107#endif /* _ASM_C6X_UACCESS_H */
diff --git a/arch/c6x/include/asm/unaligned.h b/arch/c6x/include/asm/unaligned.h
new file mode 100644
index 00000000000..b976cb740ea
--- /dev/null
+++ b/arch/c6x/include/asm/unaligned.h
@@ -0,0 +1,170 @@
1/*
2 * Port on Texas Instruments TMS320C6x architecture
3 *
4 * Copyright (C) 2004, 2009, 2010 Texas Instruments Incorporated
5 * Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com)
6 * Rewritten for 2.6.3x: Mark Salter <msalter@redhat.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 */
12#ifndef _ASM_C6X_UNALIGNED_H
13#define _ASM_C6X_UNALIGNED_H
14
15#include <linux/swab.h>
16
17/*
18 * The C64x+ can do unaligned word and dword accesses in hardware
19 * using special load/store instructions.
20 */
21
22static inline u16 get_unaligned_le16(const void *p)
23{
24 const u8 *_p = p;
25 return _p[0] | _p[1] << 8;
26}
27
28static inline u16 get_unaligned_be16(const void *p)
29{
30 const u8 *_p = p;
31 return _p[0] << 8 | _p[1];
32}
33
34static inline void put_unaligned_le16(u16 val, void *p)
35{
36 u8 *_p = p;
37 _p[0] = val;
38 _p[1] = val >> 8;
39}
40
41static inline void put_unaligned_be16(u16 val, void *p)
42{
43 u8 *_p = p;
44 _p[0] = val >> 8;
45 _p[1] = val;
46}
47
48static inline u32 get_unaligned32(const void *p)
49{
50 u32 val = (u32) p;
51 asm (" ldnw .d1t1 *%0,%0\n"
52 " nop 4\n"
53 : "+a"(val));
54 return val;
55}
56
57static inline void put_unaligned32(u32 val, void *p)
58{
59 asm volatile (" stnw .d2t1 %0,*%1\n"
60 : : "a"(val), "b"(p) : "memory");
61}
62
63static inline u64 get_unaligned64(const void *p)
64{
65 u64 val;
66 asm volatile (" ldndw .d1t1 *%1,%0\n"
67 " nop 4\n"
68 : "=a"(val) : "a"(p));
69 return val;
70}
71
72static inline void put_unaligned64(u64 val, const void *p)
73{
74 asm volatile (" stndw .d2t1 %0,*%1\n"
75 : : "a"(val), "b"(p) : "memory");
76}
77
78#ifdef CONFIG_CPU_BIG_ENDIAN
79
80#define get_unaligned_le32(p) __swab32(get_unaligned32(p))
81#define get_unaligned_le64(p) __swab64(get_unaligned64(p))
82#define get_unaligned_be32(p) get_unaligned32(p)
83#define get_unaligned_be64(p) get_unaligned64(p)
84#define put_unaligned_le32(v, p) put_unaligned32(__swab32(v), (p))
85#define put_unaligned_le64(v, p) put_unaligned64(__swab64(v), (p))
86#define put_unaligned_be32(v, p) put_unaligned32((v), (p))
87#define put_unaligned_be64(v, p) put_unaligned64((v), (p))
88#define get_unaligned __get_unaligned_be
89#define put_unaligned __put_unaligned_be
90
91#else
92
93#define get_unaligned_le32(p) get_unaligned32(p)
94#define get_unaligned_le64(p) get_unaligned64(p)
95#define get_unaligned_be32(p) __swab32(get_unaligned32(p))
96#define get_unaligned_be64(p) __swab64(get_unaligned64(p))
97#define put_unaligned_le32(v, p) put_unaligned32((v), (p))
98#define put_unaligned_le64(v, p) put_unaligned64((v), (p))
99#define put_unaligned_be32(v, p) put_unaligned32(__swab32(v), (p))
100#define put_unaligned_be64(v, p) put_unaligned64(__swab64(v), (p))
101#define get_unaligned __get_unaligned_le
102#define put_unaligned __put_unaligned_le
103
104#endif
105
106/*
107 * Cause a link-time error if we try an unaligned access other than
108 * 1,2,4 or 8 bytes long
109 */
110extern int __bad_unaligned_access_size(void);
111
112#define __get_unaligned_le(ptr) (typeof(*(ptr)))({ \
113 sizeof(*(ptr)) == 1 ? *(ptr) : \
114 (sizeof(*(ptr)) == 2 ? get_unaligned_le16((ptr)) : \
115 (sizeof(*(ptr)) == 4 ? get_unaligned_le32((ptr)) : \
116 (sizeof(*(ptr)) == 8 ? get_unaligned_le64((ptr)) : \
117 __bad_unaligned_access_size()))); \
118 })
119
120#define __get_unaligned_be(ptr) (__force typeof(*(ptr)))({ \
121 sizeof(*(ptr)) == 1 ? *(ptr) : \
122 (sizeof(*(ptr)) == 2 ? get_unaligned_be16((ptr)) : \
123 (sizeof(*(ptr)) == 4 ? get_unaligned_be32((ptr)) : \
124 (sizeof(*(ptr)) == 8 ? get_unaligned_be64((ptr)) : \
125 __bad_unaligned_access_size()))); \
126 })
127
128#define __put_unaligned_le(val, ptr) ({ \
129 void *__gu_p = (ptr); \
130 switch (sizeof(*(ptr))) { \
131 case 1: \
132 *(u8 *)__gu_p = (__force u8)(val); \
133 break; \
134 case 2: \
135 put_unaligned_le16((__force u16)(val), __gu_p); \
136 break; \
137 case 4: \
138 put_unaligned_le32((__force u32)(val), __gu_p); \
139 break; \
140 case 8: \
141 put_unaligned_le64((__force u64)(val), __gu_p); \
142 break; \
143 default: \
144 __bad_unaligned_access_size(); \
145 break; \
146 } \
147 (void)0; })
148
149#define __put_unaligned_be(val, ptr) ({ \
150 void *__gu_p = (ptr); \
151 switch (sizeof(*(ptr))) { \
152 case 1: \
153 *(u8 *)__gu_p = (__force u8)(val); \
154 break; \
155 case 2: \
156 put_unaligned_be16((__force u16)(val), __gu_p); \
157 break; \
158 case 4: \
159 put_unaligned_be32((__force u32)(val), __gu_p); \
160 break; \
161 case 8: \
162 put_unaligned_be64((__force u64)(val), __gu_p); \
163 break; \
164 default: \
165 __bad_unaligned_access_size(); \
166 break; \
167 } \
168 (void)0; })
169
170#endif /* _ASM_C6X_UNALIGNED_H */
diff --git a/arch/c6x/include/asm/unistd.h b/arch/c6x/include/asm/unistd.h
new file mode 100644
index 00000000000..6d54ea4262e
--- /dev/null
+++ b/arch/c6x/include/asm/unistd.h
@@ -0,0 +1,26 @@
1/*
2 * Copyright (C) 2011 Texas Instruments Incorporated
3 *
4 * Based on arch/tile version.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation, version 2.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
13 * NON INFRINGEMENT. See the GNU General Public License for
14 * more details.
15 */
16#if !defined(_ASM_C6X_UNISTD_H) || defined(__SYSCALL)
17#define _ASM_C6X_UNISTD_H
18
19/* Use the standard ABI for syscalls. */
20#include <asm-generic/unistd.h>
21
22/* C6X-specific syscalls. */
23#define __NR_cache_sync (__NR_arch_specific_syscall + 0)
24__SYSCALL(__NR_cache_sync, sys_cache_sync)
25
26#endif /* _ASM_C6X_UNISTD_H */