Skip to contentSkip to conversation

C6X: New architecture patch set

PATCH Superseded Mark Salter 7 participants 49 messages Aug 31, 2011 – Sep 13, 2011

Subsystems (7)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover C6X: New architecture patch set

Here is v2 of the C6X architecture patch series.

Changes from the previous patchset are:

* Replaced 64-by-64 divides (two places) with do_div

* Parse device tree for base address of some miscellaneous SoC registers. The clkdev code still has a hard-coded address but that will go away when device tree clock bindings are settled.

* Tweaked the DTS files to more closely match the actual hardware.

* Removed all board-specific files by making better use of device tree.

* Removed CONFIG_NR_IRQS and replaced with hard-coded number which is large enough for all supported SoCs with room to spare.

* Removed GENERIC_FIND_* references.

* Cleaned up Makefiles and Kconfig files.

* Removed VMLINUX_SYMBOL usage in linker script (not needed for C6X).

* Cleaned up show_cpuinfo.

* Added __HEAD to head.S

* Use generic asm/dma.h

* Added cpu_relax() to busy wait loops in cache code.

* Dropped unneeded module support routines (handled in generic code)

* Cleaned up DMA support.

* Removed deprecated syscalls.

* Removed PTRACE_PEEKUSR and PTRACE_POKEUSR.

* Cleaned up sparse warnings.

This latest patchset is available in the 'upstream-v2' branch of the git repo at:

git at linux-c6x.org:/git/projects/linux-c6x-upstreaming

Mark Salter (24):
fix default __strnlen_user macro
fixed generic page.h for non-zero PAGE_OFFSET
add ELF machine define for TI C6X DSPs
C6X: build infrastructure
C6X: early boot code
C6X: devicetree
C6X: memory management and DMA support
C6X: process management
C6X: signal management
C6X: time management
C6X: interrupt handling
C6X: syscalls
C6X: traps
C6X: clocks
C6X: cache control
C6X: loadable module support
C6X: ptrace support
C6X: headers
C6X: library code
C6X: general SoC support
C6X: specific SoC support
C6X: EMIF - External Memory Interface
C6X: Power and Sleep Controller
C6X: MAINTAINERS

 MAINTAINERS                         |    8 +
 arch/c6x/Kconfig                    |  179 ++++++++
 arch/c6x/Makefile                   |   56 +++
 arch/c6x/boot/Makefile              |   22 +
 arch/c6x/boot/dts/dsk6455.dts       |  128 ++++++
 arch/c6x/boot/dts/evmc6457.dts      |  106 +++++
 arch/c6x/boot/dts/evmc6472.dts      |  176 ++++++++
 arch/c6x/boot/dts/evmc6474.dts      |  133 ++++++
 arch/c6x/boot/install-dtb.c         |  333 +++++++++++++++
 arch/c6x/configs/dsk6455_defconfig  |   43 ++
 arch/c6x/configs/evmc6457_defconfig |   40 ++
 arch/c6x/configs/evmc6472_defconfig |   41 ++
 arch/c6x/configs/evmc6474_defconfig |   41 ++
 arch/c6x/include/asm/Kbuild         |   55 +++
 arch/c6x/include/asm/asm-offsets.h  |    1 +
 arch/c6x/include/asm/bitops.h       |  105 +++++
 arch/c6x/include/asm/byteorder.h    |   12 +
 arch/c6x/include/asm/cache.h        |   90 ++++
 arch/c6x/include/asm/cacheflush.h   |   65 +++
 arch/c6x/include/asm/checksum.h     |  115 +++++
 arch/c6x/include/asm/clkdev.h       |   22 +
 arch/c6x/include/asm/clock.h        |  148 +++++++
 arch/c6x/include/asm/delay.h        |   67 +++
 arch/c6x/include/asm/dma-mapping.h  |   91 ++++
 arch/c6x/include/asm/elf.h          |  113 +++++
 arch/c6x/include/asm/ftrace.h       |    6 +
 arch/c6x/include/asm/hardirq.h      |   20 +
 arch/c6x/include/asm/irq.h          |  302 +++++++++++++
 arch/c6x/include/asm/irqflags.h     |   72 ++++
 arch/c6x/include/asm/linkage.h      |   30 ++
 arch/c6x/include/asm/memblock.h     |    4 +
 arch/c6x/include/asm/mmu.h          |   18 +
 arch/c6x/include/asm/module.h       |   33 ++
 arch/c6x/include/asm/mutex.h        |    6 +
 arch/c6x/include/asm/page.h         |   11 +
 arch/c6x/include/asm/pgtable.h      |   81 ++++
 arch/c6x/include/asm/processor.h    |  132 ++++++
 arch/c6x/include/asm/procinfo.h     |   28 ++
 arch/c6x/include/asm/prom.h         |    1 +
 arch/c6x/include/asm/ptrace.h       |  181 ++++++++
 arch/c6x/include/asm/sections.h     |   12 +
 arch/c6x/include/asm/setup.h        |   29 ++
 arch/c6x/include/asm/sigcontext.h   |   80 ++++
 arch/c6x/include/asm/signal.h       |   17 +
 arch/c6x/include/asm/soc.h          |  126 ++++++
 arch/c6x/include/asm/string.h       |   21 +
 arch/c6x/include/asm/syscalls.h     |   55 +++
 arch/c6x/include/asm/system.h       |  197 +++++++++
 arch/c6x/include/asm/thread_info.h  |  121 ++++++
 arch/c6x/include/asm/timex.h        |   41 ++
 arch/c6x/include/asm/tlb.h          |    8 +
 arch/c6x/include/asm/traps.h        |   39 ++
 arch/c6x/include/asm/uaccess.h      |  107 +++++
 arch/c6x/include/asm/unaligned.h    |  288 +++++++++++++
 arch/c6x/include/asm/unistd.h       |   26 ++
 arch/c6x/kernel/Makefile            |   12 +
 arch/c6x/kernel/asm-offsets.c       |  123 ++++++
 arch/c6x/kernel/c6x_ksyms.c         |   68 +++
 arch/c6x/kernel/devicetree.c        |   53 +++
 arch/c6x/kernel/dma.c               |  168 ++++++++
 arch/c6x/kernel/entry.S             |  803 +++++++++++++++++++++++++++++++++++
 arch/c6x/kernel/head.S              |   84 ++++
 arch/c6x/kernel/irq.c               |  732 +++++++++++++++++++++++++++++++
 arch/c6x/kernel/module.c            |  196 +++++++++
 arch/c6x/kernel/process.c           |  260 +++++++++++
 arch/c6x/kernel/ptrace.c            |  207 +++++++++
 arch/c6x/kernel/setup.c             |  488 +++++++++++++++++++++
 arch/c6x/kernel/signal.c            |  377 ++++++++++++++++
 arch/c6x/kernel/soc.c               |  168 ++++++++
 arch/c6x/kernel/switch_to.S         |   74 ++++
 arch/c6x/kernel/sys_c6x.c           |   82 ++++
 arch/c6x/kernel/time.c              |   64 +++
 arch/c6x/kernel/traps.c             |  423 ++++++++++++++++++
 arch/c6x/kernel/vectors.S           |   81 ++++
 arch/c6x/kernel/vmlinux.lds.S       |  170 ++++++++
 arch/c6x/lib/Makefile               |    8 +
 arch/c6x/lib/csum_64plus.S          |  404 ++++++++++++++++++
 arch/c6x/lib/divi.S                 |   53 +++
 arch/c6x/lib/divremi.S              |   46 ++
 arch/c6x/lib/divremu.S              |   87 ++++
 arch/c6x/lib/divu.S                 |   98 +++++
 arch/c6x/lib/llshl.S                |   37 ++
 arch/c6x/lib/llshr.S                |   38 ++
 arch/c6x/lib/llshru.S               |   38 ++
 arch/c6x/lib/memcpy_64plus.S        |   46 ++
 arch/c6x/lib/mpyll.S                |   49 +++
 arch/c6x/lib/negll.S                |   31 ++
 arch/c6x/lib/pop_rts.S              |   32 ++
 arch/c6x/lib/push_rts.S             |   31 ++
 arch/c6x/lib/remi.S                 |   64 +++
 arch/c6x/lib/remu.S                 |   82 ++++
 arch/c6x/lib/strasgi.S              |   89 ++++
 arch/c6x/lib/strasgi_64plus.S       |   39 ++
 arch/c6x/mm/Makefile                |    5 +
 arch/c6x/mm/dma-coherent.c          |  142 ++++++
 arch/c6x/mm/init.c                  |  112 +++++
 arch/c6x/platforms/Kconfig          |   45 ++
 arch/c6x/platforms/Makefile         |   13 +
 arch/c6x/platforms/cache.c          |  445 +++++++++++++++++++
 arch/c6x/platforms/emif.c           |   77 ++++
 arch/c6x/platforms/megamod-pic.c    |  336 +++++++++++++++
 arch/c6x/platforms/megamod-pic.h    |    9 +
 arch/c6x/platforms/platform.c       |   23 +
 arch/c6x/platforms/pll.c            |  471 ++++++++++++++++++++
 arch/c6x/platforms/plldata.c        |  151 +++++++
 arch/c6x/platforms/psc.c            |  181 ++++++++
 arch/c6x/platforms/psc.h            |   25 ++
 arch/c6x/platforms/soc-6455.c       |  389 +++++++++++++++++
 arch/c6x/platforms/soc-6457.c       |  187 ++++++++
 arch/c6x/platforms/soc-6472.c       |  428 +++++++++++++++++++
 arch/c6x/platforms/soc-6474.c       |  244 +++++++++++
 arch/c6x/platforms/timer64.c        |  191 +++++++++
 arch/c6x/platforms/timer64.h        |    6 +
 include/asm-generic/page.h          |   10 +-
 include/asm-generic/uaccess.h       |    2 +-
 include/linux/elf-em.h              |    1 +
 116 files changed, 13676 insertions(+), 4 deletions(-)
 create mode 100644 arch/c6x/Kconfig
 create mode 100644 arch/c6x/Makefile
 create mode 100644 arch/c6x/boot/Makefile
 create mode 100644 arch/c6x/boot/dts/dsk6455.dts
 create mode 100644 arch/c6x/boot/dts/evmc6457.dts
 create mode 100644 arch/c6x/boot/dts/evmc6472.dts
 create mode 100644 arch/c6x/boot/dts/evmc6474.dts
 create mode 100644 arch/c6x/boot/install-dtb.c
 create mode 100644 arch/c6x/configs/dsk6455_defconfig
 create mode 100644 arch/c6x/configs/evmc6457_defconfig
 create mode 100644 arch/c6x/configs/evmc6472_defconfig
 create mode 100644 arch/c6x/configs/evmc6474_defconfig
 create mode 100644 arch/c6x/include/asm/Kbuild
 create mode 100644 arch/c6x/include/asm/asm-offsets.h
 create mode 100644 arch/c6x/include/asm/bitops.h
 create mode 100644 arch/c6x/include/asm/byteorder.h
 create mode 100644 arch/c6x/include/asm/cache.h
 create mode 100644 arch/c6x/include/asm/cacheflush.h
 create mode 100644 arch/c6x/include/asm/checksum.h
 create mode 100644 arch/c6x/include/asm/clkdev.h
 create mode 100644 arch/c6x/include/asm/clock.h
 create mode 100644 arch/c6x/include/asm/delay.h
 create mode 100644 arch/c6x/include/asm/dma-mapping.h
 create mode 100644 arch/c6x/include/asm/elf.h
 create mode 100644 arch/c6x/include/asm/ftrace.h
 create mode 100644 arch/c6x/include/asm/hardirq.h
 create mode 100644 arch/c6x/include/asm/irq.h
 create mode 100644 arch/c6x/include/asm/irqflags.h
 create mode 100644 arch/c6x/include/asm/linkage.h
 create mode 100644 arch/c6x/include/asm/memblock.h
 create mode 100644 arch/c6x/include/asm/mmu.h
 create mode 100644 arch/c6x/include/asm/module.h
 create mode 100644 arch/c6x/include/asm/mutex.h
 create mode 100644 arch/c6x/include/asm/page.h
 create mode 100644 arch/c6x/include/asm/pgtable.h
 create mode 100644 arch/c6x/include/asm/processor.h
 create mode 100644 arch/c6x/include/asm/procinfo.h
 create mode 100644 arch/c6x/include/asm/prom.h
 create mode 100644 arch/c6x/include/asm/ptrace.h
 create mode 100644 arch/c6x/include/asm/sections.h
 create mode 100644 arch/c6x/include/asm/setup.h
 create mode 100644 arch/c6x/include/asm/sigcontext.h
 create mode 100644 arch/c6x/include/asm/signal.h
 create mode 100644 arch/c6x/include/asm/soc.h
 create mode 100644 arch/c6x/include/asm/string.h
 create mode 100644 arch/c6x/include/asm/syscalls.h
 create mode 100644 arch/c6x/include/asm/system.h
 create mode 100644 arch/c6x/include/asm/thread_info.h
 create mode 100644 arch/c6x/include/asm/timex.h
 create mode 100644 arch/c6x/include/asm/tlb.h
 create mode 100644 arch/c6x/include/asm/traps.h
 create mode 100644 arch/c6x/include/asm/uaccess.h
 create mode 100644 arch/c6x/include/asm/unaligned.h
 create mode 100644 arch/c6x/include/asm/unistd.h
 create mode 100644 arch/c6x/kernel/Makefile
 create mode 100644 arch/c6x/kernel/asm-offsets.c
 create mode 100644 arch/c6x/kernel/c6x_ksyms.c
 create mode 100644 arch/c6x/kernel/devicetree.c
 create mode 100644 arch/c6x/kernel/dma.c
 create mode 100644 arch/c6x/kernel/entry.S
 create mode 100644 arch/c6x/kernel/head.S
 create mode 100644 arch/c6x/kernel/irq.c
 create mode 100644 arch/c6x/kernel/module.c
 create mode 100644 arch/c6x/kernel/process.c
 create mode 100644 arch/c6x/kernel/ptrace.c
 create mode 100644 arch/c6x/kernel/setup.c
 create mode 100644 arch/c6x/kernel/signal.c
 create mode 100644 arch/c6x/kernel/soc.c
 create mode 100644 arch/c6x/kernel/switch_to.S
 create mode 100644 arch/c6x/kernel/sys_c6x.c
 create mode 100644 arch/c6x/kernel/time.c
 create mode 100644 arch/c6x/kernel/traps.c
 create mode 100644 arch/c6x/kernel/vectors.S
 create mode 100644 arch/c6x/kernel/vmlinux.lds.S
 create mode 100644 arch/c6x/lib/Makefile
 create mode 100644 arch/c6x/lib/csum_64plus.S
 create mode 100644 arch/c6x/lib/divi.S
 create mode 100644 arch/c6x/lib/divremi.S
 create mode 100644 arch/c6x/lib/divremu.S
 create mode 100644 arch/c6x/lib/divu.S
 create mode 100644 arch/c6x/lib/llshl.S
 create mode 100644 arch/c6x/lib/llshr.S
 create mode 100644 arch/c6x/lib/llshru.S
 create mode 100644 arch/c6x/lib/memcpy_64plus.S
 create mode 100644 arch/c6x/lib/mpyll.S
 create mode 100644 arch/c6x/lib/negll.S
 create mode 100644 arch/c6x/lib/pop_rts.S
 create mode 100644 arch/c6x/lib/push_rts.S
 create mode 100644 arch/c6x/lib/remi.S
 create mode 100644 arch/c6x/lib/remu.S
 create mode 100644 arch/c6x/lib/strasgi.S
 create mode 100644 arch/c6x/lib/strasgi_64plus.S
 create mode 100644 arch/c6x/mm/Makefile
 create mode 100644 arch/c6x/mm/dma-coherent.c
 create mode 100644 arch/c6x/mm/init.c
 create mode 100644 arch/c6x/platforms/Kconfig
 create mode 100644 arch/c6x/platforms/Makefile
 create mode 100644 arch/c6x/platforms/cache.c
 create mode 100644 arch/c6x/platforms/emif.c
 create mode 100644 arch/c6x/platforms/megamod-pic.c
 create mode 100644 arch/c6x/platforms/megamod-pic.h
 create mode 100644 arch/c6x/platforms/platform.c
 create mode 100644 arch/c6x/platforms/pll.c
 create mode 100644 arch/c6x/platforms/plldata.c
 create mode 100644 arch/c6x/platforms/psc.c
 create mode 100644 arch/c6x/platforms/psc.h
 create mode 100644 arch/c6x/platforms/soc-6455.c
 create mode 100644 arch/c6x/platforms/soc-6457.c
 create mode 100644 arch/c6x/platforms/soc-6472.c
 create mode 100644 arch/c6x/platforms/soc-6474.c
 create mode 100644 arch/c6x/platforms/timer64.c
 create mode 100644 arch/c6x/platforms/timer64.h
Signature · 1 line
1.7.6
#1 lore raw

PATCH v2 1/24 fix default __strnlen_user macro

The existing __strnlen_user macro simply resolved to strnlen. However, the count returned by strnlen_user should include the NULL byte. This patch fixes the __strnlen_user macro to include the NULL byte in the count.

---
 include/asm-generic/uaccess.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
include/asm-generic/uaccess.h +1 -1
index ac68c99..1d0fdf8 100644
@@ -289,7 +289,7 @@ strncpy_from_user(char *dst, const char __user *src, long count)
  * Return 0 on exception, a value greater than N if too long
  */
 #ifndef __strnlen_user
-#define __strnlen_user strnlen
+#define __strnlen_user(s, n) (strnlen((s), (n)) + 1)
 #endif
 
 static inline long strnlen_user(const char __user *src, long n)
Signature · 1 line
1.7.6
#2 lore raw

Re: [PATCH 01/24] fix default __strnlen_user macro

Quoted 14 lines · Mark Salter

The existing __strnlen_user macro simply resolved to strnlen. However, the count returned by strnlen_user should include the NULL byte. This patch fixes the __strnlen_user macro to include the NULL byte in the count.

---
  include/asm-generic/uaccess.h |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
include/asm-generic/uaccess.h +0 -0
index ac68c99..1d0fdf8 100644

include/asm-generic/uaccess.h strncpy_from_user(char *dst, const char __user *src, long count) · line 293

Quoted 6 lines
include/asm-generic/uaccess.h +1 -1
@@ -289,7 +289,7 @@ strncpy_from_user(char *dst, const char __user *src, long count)
   * Return 0 on exception, a value greater than N if too long
   */
  #ifndef __strnlen_user
-#define __strnlen_user strnlen
+#define __strnlen_user(s, n) (strnlen((s), (n)) + 1)
  #endif

I don't think this is correct because if you hit maxlen you will add one to it. e.g. __strnlen_user("abcd\0", 3) would return 4 instead of 3.

It should probably be something like this:

#define __strnlen_user(s, n) ({		\
	size_t k = strnlen(s, n);	\
	k<  n ? k + 1 : n; })

I wonder if this change will break anything since it has been incorrect (according to the comment in uaccess.h@least) for a while. Why does __strnlen_user have different semantics to strnlen anway?

~Ryan

#3 lore raw

Re: [PATCH 01/24] fix default __strnlen_user macro

Quoted 10 lines · Ryan Mallon
Quoted 9 lines · Mark Salter

The existing __strnlen_user macro simply resolved to strnlen. However, the count returned by strnlen_user should include the NULL byte. This patch fixes the __strnlen_user macro to include the NULL byte in the count.

---
  include/asm-generic/uaccess.h |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
Quoted 14 lines

include/asm-generic/uaccess.h strncpy_from_user(char *dst, const char __user *src, long count) · line 293

Quoted 11 lines
include/asm-generic/uaccess.h +1 -1
index ac68c99..1d0fdf8 100644
@@ -289,7 +289,7 @@ strncpy_from_user(char *dst, const char __user *src, long count)
   * Return 0 on exception, a value greater than N if too long
   */
  #ifndef __strnlen_user
-#define __strnlen_user strnlen
+#define __strnlen_user(s, n) (strnlen((s), (n)) + 1)
  #endif

I don't think this is correct because if you hit maxlen you will add one to it. e.g. __strnlen_user("abcd\0", 3) would return 4 instead of 3.

Yes, one would think so, but that doesn't seem to be the case. Looking at various places that call strnlen_user, you'll find checks for that. For one example, mm/util.c:

    char *strndup_user(const char __user *s, long n)
    {
	char *p;
	long length;

	length = strnlen_user(s, n);

	if (!length)
		return ERR_PTR(-EFAULT);

	if (length > n)
		return ERR_PTR(-EINVAL);
Quoted 11 lines

It should probably be something like this:

#define __strnlen_user(s, n) ({		\
	size_t k = strnlen(s, n);	\
	k<  n ? k + 1 : n; })

I wonder if this change will break anything since it has been incorrect (according to the comment in uaccess.h at least) for a while. Why does __strnlen_user have different semantics to strnlen anway?

I think the C6X port I'm in the process of pushing upstream is the only port to actually use the definition in asm-generic/uaccess.h and I can assure you that the existing definition causes a failure to boot as it stands. No idea why the semantics are different, but you're not the first to note that fact. I thought briefly about changing the kernel to make the strnlen_user have the same semantics as strnlen, but that means touching every arch, every one of which defines their own. Kinda makes me feel inadequate for wanting to use the generic one. :)

--Mark

#4 lore raw

Re: [PATCH 01/24] fix default __strnlen_user macro

Quoted 28 lines · Mark Salter
Quoted 10 lines · Ryan Mallon
Quoted 9 lines · Mark Salter

The existing __strnlen_user macro simply resolved to strnlen. However, the count returned by strnlen_user should include the NULL byte. This patch fixes the __strnlen_user macro to include the NULL byte in the count.

---
   include/asm-generic/uaccess.h |    2 +-
   1 files changed, 1 insertions(+), 1 deletions(-)
Quoted 13 lines

include/asm-generic/uaccess.h strncpy_from_user(char *dst, const char __user *src, long count) · line 293

Quoted 11 lines
include/asm-generic/uaccess.h +1 -1
index ac68c99..1d0fdf8 100644
@@ -289,7 +289,7 @@ strncpy_from_user(char *dst, const char __user *src, long count)
    * Return 0 on exception, a value greater than N if too long
    */
   #ifndef __strnlen_user
-#define __strnlen_user strnlen
+#define __strnlen_user(s, n) (strnlen((s), (n)) + 1)
   #endif

I don't think this is correct because if you hit maxlen you will add one to it. e.g. __strnlen_user("abcd\0", 3) would return 4 instead of 3.

Yes, one would think so, but that doesn't seem to be the case. Looking at various places that call strnlen_user, you'll find checks for that. For one example, mm/util.c:

Quoted 12 lines
     char *strndup_user(const char __user *s, long n)
     {
	char *p;
	long length;

	length = strnlen_user(s, n);

	if (!length)
		return ERR_PTR(-EFAULT);

	if (length>  n)
		return ERR_PTR(-EINVAL);

Sure, but that isn't a good reason to not write it correctly according to the API description. There are also places where that check doesn't happen like fs/exec.c and the rather dodgy looking usage in kernel/auditsc.c which appears to rely on it returning n + 1 in the maxlen case.

It should either be changed as I suggested, or the comment in uaccess.h should be updated to reflect the actual behaviour of the function (stating that it returns n + 1 in the case where n is reached). Either way, its probably worth doing a quick check through the arch specific versions to see what their behaviour really is. It looks like there are potentially some subtle bugs at the callsites.

~Ryan

#5 lore raw

Re: [PATCH 01/24] fix default __strnlen_user macro

Quoted 6 lines · Ryan Mallon

It should either be changed as I suggested, or the comment in uaccess.h should be updated to reflect the actual behaviour of the function (stating that it returns n + 1 in the case where n is reached). Either way, its probably worth doing a quick check through the arch specific versions to see what their behaviour really is. It looks like there are potentially some subtle bugs at the callsites.

I think commenting it in uaccess.h is the only sane way to go. Changing the semantics means changing all the arch-specific versions, most of which are asm code and changing most, if not all callsites. All of the arch-specific versions I looked at include the NULL count.

--Mark

#6 lore raw

Re: [PATCH 01/24] fix default __strnlen_user macro

Quoted 7 lines · Mark Salter
Quoted 6 lines · Ryan Mallon

It should either be changed as I suggested, or the comment in uaccess.h should be updated to reflect the actual behaviour of the function (stating that it returns n + 1 in the case where n is reached). Either way, its probably worth doing a quick check through the arch specific versions to see what their behaviour really is. It looks like there are potentially some subtle bugs at the callsites.

Quoted 5 lines

I think commenting it in uaccess.h is the only sane way to go. Changing the semantics means changing all the arch-specific versions, most of which are asm code and changing most, if not all callsites. All of the arch-specific versions I looked at include the NULL count.

Agreed. Add a note to the comment that callers should check for a return value > n.

~Ryan

#7 lore raw

PATCH v2 2/24 fixed generic page.h for non-zero PAGE_OFFSET

In reply to Mark Salter

asm-generic/page.h had several problems when used with a non-zero PAGE_OFFSET. This patch adds a default ARCH_PFN_OFFSET and fixes the __va, __pa, and pfn_valid macros to work with non-zero PAGE_OFFSETs.

---
 include/asm-generic/page.h |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
include/asm-generic/page.h +7 -3
index 75fec18..f376db2 100644
@@ -71,10 +71,14 @@ extern unsigned long memory_end;
 #define PAGE_OFFSET		(0)
 #endif
 
+#ifndef ARCH_PFN_OFFSET
+#define ARCH_PFN_OFFSET		(PAGE_OFFSET >> PAGE_SHIFT)
+#endif
+
 #ifndef __ASSEMBLY__
 
-#define __va(x) ((void *)((unsigned long)(x) + PAGE_OFFSET))
-#define __pa(x) ((unsigned long) (x) - PAGE_OFFSET)
+#define __va(x) ((void *)((unsigned long) (x)))
+#define __pa(x) ((unsigned long) (x))
 
 #define virt_to_pfn(kaddr)	(__pa(kaddr) >> PAGE_SHIFT)
 #define pfn_to_virt(pfn)	__va((pfn) << PAGE_SHIFT)
@@ -86,7 +90,7 @@ extern unsigned long memory_end;
 #define page_to_phys(page)      ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT)
 #endif
 
-#define pfn_valid(pfn)		((pfn) < max_mapnr)
+#define pfn_valid(pfn)		((pfn) >= ARCH_PFN_OFFSET && ((pfn) - ARCH_PFN_OFFSET) < max_mapnr)
 
 #define	virt_addr_valid(kaddr)	(((void *)(kaddr) >= (void *)PAGE_OFFSET) && \
 				((void *)(kaddr) < (void *)memory_end))
Signature · 1 line
1.7.6
#8 lore raw

PATCH v2 3/24 add ELF machine define for TI C6X DSPs

In reply to Mark Salter
---
 include/linux/elf-em.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
include/linux/elf-em.h +1 -0
index 18bea78..8e2b7ba 100644
@@ -33,6 +33,7 @@
 #define EM_H8_300	46	/* Renesas H8/300,300H,H8S */
 #define EM_MN10300	89	/* Panasonic/MEI MN10300, AM33 */
 #define EM_BLACKFIN     106     /* ADI Blackfin Processor */
+#define EM_TI_C6000	140	/* TI C6X DSPs */
 #define EM_FRV		0x5441	/* Fujitsu FR-V */
 #define EM_AVR32	0x18ad	/* Atmel AVR32 */
 
Signature · 1 line
1.7.6
#9 lore raw

PATCH v2 4/24 C6X: build infrastructure

In reply to Mark Salter
---
 arch/c6x/Kconfig                    |  179 +++++++++++++++++++++++++++++++++++
 arch/c6x/Makefile                   |   56 +++++++++++
 arch/c6x/boot/Makefile              |   22 +++++
 arch/c6x/configs/dsk6455_defconfig  |   43 +++++++++
 arch/c6x/configs/evmc6457_defconfig |   40 ++++++++
 arch/c6x/configs/evmc6472_defconfig |   41 ++++++++
 arch/c6x/configs/evmc6474_defconfig |   41 ++++++++
 arch/c6x/include/asm/Kbuild         |   55 +++++++++++
 arch/c6x/kernel/Makefile            |   12 +++
 arch/c6x/kernel/vmlinux.lds.S       |  170 +++++++++++++++++++++++++++++++++
 arch/c6x/lib/Makefile               |    8 ++
 arch/c6x/mm/Makefile                |    5 +
 arch/c6x/platforms/Kconfig          |   45 +++++++++
 arch/c6x/platforms/Makefile         |   13 +++
 14 files changed, 730 insertions(+), 0 deletions(-)
 create mode 100644 arch/c6x/Kconfig
 create mode 100644 arch/c6x/Makefile
 create mode 100644 arch/c6x/boot/Makefile
 create mode 100644 arch/c6x/configs/dsk6455_defconfig
 create mode 100644 arch/c6x/configs/evmc6457_defconfig
 create mode 100644 arch/c6x/configs/evmc6472_defconfig
 create mode 100644 arch/c6x/configs/evmc6474_defconfig
 create mode 100644 arch/c6x/include/asm/Kbuild
 create mode 100644 arch/c6x/kernel/Makefile
 create mode 100644 arch/c6x/kernel/vmlinux.lds.S
 create mode 100644 arch/c6x/lib/Makefile
 create mode 100644 arch/c6x/mm/Makefile
 create mode 100644 arch/c6x/platforms/Kconfig
 create mode 100644 arch/c6x/platforms/Makefile
arch/c6x/Kconfig new file +179 -0
new file mode 100644
index 0000000..f147a446
@@ -0,0 +1,179 @@
+#
+# For a description of the syntax of this configuration file,
+# see Documentation/kbuild/kconfig-language.txt.
+#
+
+config TMS320C6X
+	def_bool y
+	select CLKDEV_LOOKUP
+	select GENERIC_HARDIRQS_NO__DO_IRQ
+	select GENERIC_HARDIRQS_NO__DO_IRQ
+	select GENERIC_HARDIRQS_NO_DEPRECATED
+	select GENERIC_IRQ_SHOW
+	select HAVE_DMA_API_DEBUG
+	select HAVE_GENERIC_HARDIRQS
+	select HAVE_MEMBLOCK
+	select HAVE_SPARSE_IRQ
+	select OF
+	select OF_EARLY_FLATTREE
+
+config MMU
+	def_bool n
+
+config ZONE_DMA
+	def_bool y
+
+config FPU
+	def_bool n
+
+config HIGHMEM
+	def_bool n
+
+config NUMA
+	def_bool n
+
+config RWSEM_GENERIC_SPINLOCK
+	def_bool y
+
+config RWSEM_XCHGADD_ALGORITHM
+	def_bool n
+
+config GENERIC_CALIBRATE_DELAY
+	def_bool y
+
+config GENERIC_HWEIGHT
+	def_bool y
+
+config GENERIC_CLOCKEVENTS
+	def_bool y
+
+config GENERIC_CLOCKEVENTS_BROADCAST
+	bool
+
+config GENERIC_BUG
+	def_bool y
+
+config COMMON_CLKDEV
+	def_bool y
+
+config C6X_BIG_KERNEL
+	bool "Build a big kernel"
+	help
+	  The C6X function call instruction has a limited range of +/- 2MiB.
+	  This is sufficient for most kernels, but some kernel configurations
+	  with lots of compiled-in functionality may require a larger range
+	  for function calls. Use this option to have the compiler generate
+	  function calls with 32-bit range. This will make the kernel both
+	  larger and slower.
+
+	  If unsure, say N.
+
+source "init/Kconfig"
+
+# Use the generic interrupt handling code in kernel/irq/
+
+source "kernel/Kconfig.freezer"
+
+config CMDLINE_BOOL
+	bool "Default bootloader kernel arguments"
+
+config CMDLINE
+	string "Kernel command line"
+	depends on CMDLINE_BOOL
+	default "console=ttyS0,57600"
+	help
+	  On some architectures there is currently no way for the boot loader
+	  to pass arguments to the kernel. For these architectures, you should
+	  supply some command-line options at build time by entering them
+	  here.
+
+config CMDLINE_FORCE
+	bool "Force default kernel command string"
+	depends on CMDLINE_BOOL
+	default n
+	help
+	  Set this to have arguments from the default kernel command string
+	  override those passed by the boot loader.
+
+config CPU_BIG_ENDIAN
+	bool "Build big-endian kernel"
+	default n
+	help
+	  Say Y if you plan on running a kernel in big-endian mode.
+	  Note that your board must be properly built and your board
+	  port must properly enable any big-endian related features
+	  of your chipset/board/processor.
+
+config FORCE_MAX_ZONEORDER
+	int "Maximum zone order"
+	default "13"
+	help
+	  The kernel memory allocator divides physically contiguous memory
+	  blocks into "zones", where each zone is a power of two number of
+	  pages.  This option selects the largest power of two that the kernel
+	  keeps in the memory allocator.  If you need to allocate very large
+	  blocks of physically contiguous memory, then you may need to
+	  increase this value.
+
+	  This config option is actually maximum order plus one. For example,
+	  a value of 11 means that the largest free memory block is 2^10 pages.
+
+menu "Processor type and features"
+
+config TMS320C64XPLUS
+	bool "TMS320C64X+"
+
+source "arch/c6x/platforms/Kconfig"
+
+config TMS320C6X_CACHES_ON
+	bool "L2 cache support"
+	default y
+
+config KERNEL_RAM_BASE_ADDRESS
+	hex "Virtual address of memory base"
+	default 0xe0000000 if SOC_TMS320C6455
+	default 0xe0000000 if SOC_TMS320C6457
+	default 0xe0000000 if SOC_TMS320C6472
+	default 0x80000000
+
+source "mm/Kconfig"
+
+source "kernel/Kconfig.preempt"
+
+source "kernel/Kconfig.hz"
+source "kernel/time/Kconfig"
+
+endmenu
+
+menu "Executable file formats"
+
+source "fs/Kconfig.binfmt"
+
+endmenu
+
+source "net/Kconfig"
+
+source "drivers/Kconfig"
+
+source "fs/Kconfig"
+
+source "security/Kconfig"
+
+source "crypto/Kconfig"
+
+source "lib/Kconfig"
+
+menu "Kernel hacking"
+
+source "lib/Kconfig.debug"
+
+config ACCESS_CHECK
+	bool "Check the user pointer address"
+	default y
+	help
+	  Usually the pointer transfer from user space is checked to see if its
+	  address is in the kernel space.
+
+	  Say N here to disable that check to improve the performance.
+
+endmenu
arch/c6x/Makefile new file +56 -0

56 lines not on this page · raw message

arch/c6x/boot/Makefile new file +22 -0
new file mode 100644
index 0000000..75ed02f
@@ -0,0 +1,22 @@
+#
+# Makefile for bootable kernel images
+#
+
+hostprogs-y := install-dtb
+
+OBJCOPYFLAGS_vmlinux.bin := -O binary
+$(obj)/vmlinux.bin: vmlinux FORCE
+	$(call if_changed,objcopy)
+
+quiet_cmd_install_dtb = INSTALL_DTB $@
+cmd_install_dtb = $(obj)/install-dtb $(obj)/$*.dtb vmlinux $@
+
+$(obj)/dtbImage.%: vmlinux $(obj)/install-dtb $(obj)/%.dtb
+	$(call cmd,install_dtb)
+
+clean-files := $(obj)/*.dtb
+
+DTC_FLAGS ?= -p 1024
+
+$(obj)/%.dtb: $(src)/dts/%.dts FORCE
+	$(call cmd,dtc)
arch/c6x/configs/dsk6455_defconfig new file +43 -0

43 lines not on this page · raw message

arch/c6x/configs/evmc6457_defconfig new file +40 -0
new file mode 100644
index 0000000..d2eff63
@@ -0,0 +1,40 @@
+CONFIG_EXPERIMENTAL=y
+# CONFIG_LOCALVERSION_AUTO is not set
+CONFIG_SYSVIPC=y
+CONFIG_SPARSE_IRQ=y
+CONFIG_LOG_BUF_SHIFT=14
+CONFIG_NAMESPACES=y
+# CONFIG_UTS_NS is not set
+# CONFIG_USER_NS is not set
+# CONFIG_PID_NS is not set
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_CC_OPTIMIZE_FOR_SIZE=y
+CONFIG_EXPERT=y
+# CONFIG_FUTEX is not set
+# CONFIG_SLUB_DEBUG is not set
+CONFIG_MODULES=y
+CONFIG_MODULE_FORCE_LOAD=y
+CONFIG_MODULE_UNLOAD=y
+CONFIG_MODULE_FORCE_UNLOAD=y
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE=""
+CONFIG_BOARD_EVM6457=y
+CONFIG_NO_HZ=y
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_BLK_DEV_LOOP=y
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_COUNT=2
+CONFIG_BLK_DEV_RAM_SIZE=17000
+CONFIG_MISC_DEVICES=y
+# CONFIG_INPUT is not set
+# CONFIG_SERIO is not set
+# CONFIG_VT is not set
+# CONFIG_HW_RANDOM is not set
+# CONFIG_HWMON is not set
+# CONFIG_USB_SUPPORT is not set
+# CONFIG_IOMMU_SUPPORT is not set
+# CONFIG_MISC_FILESYSTEMS is not set
+CONFIG_CRC16=y
+# CONFIG_ENABLE_MUST_CHECK is not set
+# CONFIG_SCHED_DEBUG is not set
+# CONFIG_DEBUG_BUGVERBOSE is not set
arch/c6x/configs/evmc6472_defconfig new file +41 -0

41 lines not on this page · raw message

arch/c6x/configs/evmc6474_defconfig new file +41 -0

41 lines not on this page · raw message

arch/c6x/include/asm/Kbuild new file +55 -0

55 lines not on this page · raw message

arch/c6x/kernel/Makefile new file +12 -0
new file mode 100644
index 0000000..580a515
@@ -0,0 +1,12 @@
+#
+# Makefile for arch/c6x/kernel/
+#
+
+extra-y := head.o vmlinux.lds
+
+obj-y := process.o traps.o irq.o signal.o ptrace.o
+obj-y += setup.o sys_c6x.o time.o devicetree.o
+obj-y += switch_to.o entry.o vectors.o c6x_ksyms.o
+obj-y += soc.o dma.o
+
+obj-$(CONFIG_MODULES)           += module.o
arch/c6x/kernel/vmlinux.lds.S new file +170 -0

170 lines not on this page · raw message

arch/c6x/lib/Makefile new file +8 -0
new file mode 100644
index 0000000..b473f02
@@ -0,0 +1,8 @@
+#
+# Makefile for arch/c6x/lib/
+#
+
+lib-y := divu.o divi.o pop_rts.o push_rts.o remi.o remu.o strasgi.o llshru.o
+lib-y += llshr.o llshl.o negll.o mpyll.o divremi.o divremu.o
+
+lib-$(CONFIG_TMS320C64XPLUS) += csum_64plus.o memcpy_64plus.o strasgi_64plus.o
arch/c6x/mm/Makefile new file +5 -0
new file mode 100644
index 0000000..136a975
@@ -0,0 +1,5 @@
+#
+# Makefile for the linux c6x-specific parts of the memory manager.
+#
+
+obj-y := init.o dma-coherent.o
arch/c6x/platforms/Kconfig new file +45 -0

45 lines not on this page · raw message

arch/c6x/platforms/Makefile new file +13 -0
new file mode 100644
index 0000000..ca5cadc
@@ -0,0 +1,13 @@
+#
+# Makefile for arch/c6x/platforms
+#
+# Copyright 2010, 2011 Texas Instruments Incorporated
+#
+
+obj-y = platform.o cache.o megamod-pic.o pll.o plldata.o timer64.o
+
+# SoC objects
+obj-$(CONFIG_SOC_TMS320C6455)   += soc-6455.o emif.o
+obj-$(CONFIG_SOC_TMS320C6457)   += soc-6457.o emif.o psc.o
+obj-$(CONFIG_SOC_TMS320C6472)   += soc-6472.o psc.o
+obj-$(CONFIG_SOC_TMS320C6474)   += soc-6474.o psc.o
Signature · 1 line
1.7.6
#10 lore raw

PATCH v2 5/24 C6X: early boot code

In reply to Mark Salter

This patch provides the early boot code for C6X architecture. There is a 16 entry vector table which is used to direct reset and interrupt events. The vector table entries contain a small amount of code (maximum of 8 opcodes) which simply branches to the actual event handling code.

The head.S code simply clears BSS, setups up a few control registers, and calls machine_init followed by start_kernel. The machine_init code in setup.c does the early flat tree parsing (memory, commandline, etc). At setup_arch time, the code does the usual memory setup and scans the devicetree to find out which SoC is being used.

---
 arch/c6x/kernel/head.S    |   84 ++++++++
 arch/c6x/kernel/setup.c   |  488 +++++++++++++++++++++++++++++++++++++++++++++
 arch/c6x/kernel/vectors.S |   81 ++++++++
 3 files changed, 653 insertions(+), 0 deletions(-)
 create mode 100644 arch/c6x/kernel/head.S
 create mode 100644 arch/c6x/kernel/setup.c
 create mode 100644 arch/c6x/kernel/vectors.S
arch/c6x/kernel/head.S new file +84 -0
new file mode 100644
index 0000000..133eab6
@@ -0,0 +1,84 @@
+;
+;  Port on Texas Instruments TMS320C6x architecture
+;
+;  Copyright (C) 2004, 2009, 2010, 2011 Texas Instruments Incorporated
+;  Author: Aurelien Jacquiot (aurelien.jacquiot at jaluna.com)
+;
+;  This program is free software; you can redistribute it and/or modify
+;  it under the terms of the GNU General Public License version 2 as
+;  published by the Free Software Foundation.
+;
+#include <linux/linkage.h>
+#include <linux/of_fdt.h>
+#include <asm/asm-offsets.h>
+
+	__HEAD
+ENTRY(_c_int00)
+	;; Save magic and pointer
+	MV	.S1	A4,A10
+	MV	.S2	B4,B10
+	MVKL	.S2	__bss_start,B5
+	MVKH	.S2	__bss_start,B5
+	MVKL	.S2	__bss_stop,B6
+	MVKH	.S2	__bss_stop,B6
+	SUB	.L2	B6,B5,B6 ; bss size
+
+	;; Set the stack pointer
+	MVKL	.S2	current_ksp,B0
+	MVKH	.S2	current_ksp,B0
+	LDW	.D2T2	*B0,B15
+
+	;; clear bss
+	SHR	.S2	B6,3,B0	  ; number of dwords to clear
+	ZERO	.L2	B13
+	ZERO	.L2	B12
+bss_loop:
+	BDEC	.S2	bss_loop,B0
+	NOP	3
+	CMPLT	.L2	B0,0,B1
+ [!B1]	STDW	.D2T2	B13:B12,*B5++[1]
+
+	NOP	4
+	AND	.D2	~7,B15,B15
+
+	;; Clear GIE and PGIE
+	MVC	.S2	CSR,B2
+	CLR	.S2	B2,0,1,B2
+	MVC	.S2	B2,CSR
+	MVC	.S2	TSR,B2
+	CLR	.S2	B2,0,1,B2
+	MVC	.S2	B2,TSR
+	MVC	.S2	ITSR,B2
+	CLR	.S2	B2,0,1,B2
+	MVC	.S2	B2,ITSR
+	MVC	.S2	NTSR,B2
+	CLR	.S2	B2,0,1,B2
+	MVC	.S2	B2,NTSR
+
+	;; pass DTB pointer to machine_init (or zero if none)
+	MVKL	.S1	OF_DT_HEADER,A0
+	MVKH	.S1	OF_DT_HEADER,A0
+	CMPEQ	.L1	A10,A0,A0
+  [A0]	MV	.S1X	B10,A4
+  [!A0] MVK	.S1	0,A4
+
+#ifdef CONFIG_C6X_BIG_KERNEL
+	MVKL	.S1	machine_init,A0
+	MVKH	.S1	machine_init,A0
+	B	.S2X	A0
+	ADDKPC  .S2     0f,B3,4
+0:
+#else
+	CALLP	.S2	machine_init,B3
+#endif
+
+	;; Jump to Linux init
+#ifdef CONFIG_C6X_BIG_KERNEL
+	MVKL	.S1	start_kernel,A0
+	MVKH	.S1	start_kernel,A0
+	B	.S2X	A0
+#else
+	B	.S2	start_kernel
+#endif
+	NOP	5
+L1:	BNOP	.S2	L1,5
arch/c6x/kernel/setup.c new file +488 -0

488 lines not on this page · raw message

arch/c6x/kernel/vectors.S new file +81 -0

81 lines not on this page · raw message

Signature · 1 line
1.7.6
#11 lore raw

PATCH v2 6/24 C6X: devicetree

In reply to Mark Salter

This is the basic devicetree support for C6X. Currently, four boards are supported. Each one uses a different SoC part. Two of the four supported SoCs are multicore. One with 3 cores and the other with 6 cores. There is no coherency between the core-level caches, so SMP is not an option. It is possible to run separate kernel instances on the various cores. There is currently no C6X bootloader support for device trees so we build in the DTB for now.

There are some interesting twists to the hardware which are of note for device tree support. Each core has its own interrupt controller which is controlled by special purpose core registers. This core controller provides 12 general purpose prioritized interrupt sources. Each core is contained within a hardware "module" which provides L1 and L2 caches, power control, and another interrupt controller which cascades into the core interrupt controller. These core module functions are controlled by memory mapped registers. The addresses for these registers are the same for each core. That is, when coreN accesses a module-level MMIO register at a given address, it accesses the register for coreN even though other cores would use the same address to access the register in the module containing those cores. Other hardware modules (timers, enet, etc) which are memory mapped can be accessed by all cores.

The timers need some further explanation for multicore SoCs. Even though all timer control registers are visible to all cores, interrupt routing or other considerations may make a given timer more suitable for use by a core than some other timer. Because of this and the desire to have the same image run on more than one core, the timer nodes have a "ti,core-mask" property which is used by the driver to scan for a suitable timer to use.

Cc devicetree-discuss at lists.ozlabs.org
---
 arch/c6x/boot/dts/dsk6455.dts  |  128 +++++++++++++++
 arch/c6x/boot/dts/evmc6457.dts |  106 +++++++++++++
 arch/c6x/boot/dts/evmc6472.dts |  176 +++++++++++++++++++++
 arch/c6x/boot/dts/evmc6474.dts |  133 ++++++++++++++++
 arch/c6x/boot/install-dtb.c    |  333 ++++++++++++++++++++++++++++++++++++++++
 arch/c6x/kernel/devicetree.c   |   53 +++++++
 arch/c6x/platforms/platform.c  |   23 +++
 7 files changed, 952 insertions(+), 0 deletions(-)
 create mode 100644 arch/c6x/boot/dts/dsk6455.dts
 create mode 100644 arch/c6x/boot/dts/evmc6457.dts
 create mode 100644 arch/c6x/boot/dts/evmc6472.dts
 create mode 100644 arch/c6x/boot/dts/evmc6474.dts
 create mode 100644 arch/c6x/boot/install-dtb.c
 create mode 100644 arch/c6x/kernel/devicetree.c
 create mode 100644 arch/c6x/platforms/platform.c
arch/c6x/boot/dts/dsk6455.dts new file +128 -0
new file mode 100644
index 0000000..ef703aa
@@ -0,0 +1,128 @@
+/*
+ * arch/c6x/boot/dts/dsk6455.dts
+ *
+ * DSK6455 Evaluation Platform For TMS320C6455
+ * Copyright (C) 2011 Texas Instruments Incorporated
+ *
+ * Author: Mark Salter <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ */
+
+/dts-v1/;
+
+/ {
+	model = "Spectrum Digital DSK6455";
+	compatible = "spectrum-digital,dsk6455";
+
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	chosen {
+		bootargs = "root=/dev/nfs ip=dhcp rw";
+	};
+
+	memory {
+		device_type = "memory";
+		reg = <0xE0000000 0x08000000>;
+	};
+
+	cpus {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		cpu at 0 {
+			device_type = "cpu";
+			model = "ti,c64x+";
+			reg = <0>;
+		};
+	};
+
+	/*
+	 * Core priority interrupt controller
+	 */
+	core_pic: interrupt-controller at 0 {
+		interrupt-controller;
+		#interrupt-cells = <1>;
+		compatible = "ti,c64x+core-pic";
+	};
+
+	soc at 00000000 {
+		compatible = "ti,tms320c6455";
+		device_type = "soc";
+		#address-cells = <1>;
+		#size-cells = <1>;
+		#interrupt-cells = <1>;
+		ranges;
+		reg = <0x02a80000 0xc>;
+
+		clock-frequency = <50000000>;
+
+		/*
+		 * Megamodule interrupt controller
+		 */
+		megamod_pic: interrupt-controller at 1800000 {
+		       interrupt-controller;
+		       #interrupt-cells = <1>;
+		       reg = <0x1800000 0x1000>;
+		       interrupt-parent = <&core_pic>;
+		       interrupts = < 12 13 14 15 >;
+		       ti,priority-map = < 0xffff 0xffff 0xffff 0xffff
+					   0xffff 0xffff 0xffff 0xffff
+					   0xffff 0xffff 0xffff 0xffff
+					   0 1 2 3 >;
+		       compatible = "ti,c64x+megamod-pic";
+		};
+
+		cache-controller at 1840000 {
+			compatible = "ti,c64x+cache";
+			reg = <0x01840000 0x8400>;
+		};
+
+		emifa at 70000000 {
+			compatible = "ti,c64x+emifa", "simple-bus";
+			#address-cells = <2>;
+			#size-cells = <1>;
+			reg = <0x70000000 0x100>;
+			ranges = <0x2 0x0 0xa0000000 0x00000008
+			          0x3 0x0 0xb0000000 0x00400000
+				  0x4 0x0 0xc0000000 0x10000000
+				  0x5 0x0 0xD0000000 0x10000000>;
+
+			ti,emifa-burst-priority = <255>;
+			ti,emifa-ce-config = <0x00240120
+					      0x00240120
+					      0x00240122
+					      0x00240122>;
+
+			flash at 3,0 {
+				#address-cells = <1>;
+				#size-cells = <1>;
+				compatible = "cfi-flash";
+				reg = <0x3 0x0 0x400000>;
+				bank-width = <1>;
+				device-width = <1>;
+				partition at 0 {
+					reg = <0x0 0x400000>;
+					label = "NOR";
+				};
+			};
+		};
+
+		timer1: timer at 2980000 {
+			compatible = "ti,c64x+timer64";
+			reg = <0x2980000 0x40>;
+			interrupt-parent = <&megamod_pic>;
+			interrupts = < 69 >;
+		};
+
+		device-state-controller at 2ac0000 {
+			compatible = "ti,tms320c6455-dscr";
+			reg = <0x02ac0000 0x80>;
+		};
+	};
+};
arch/c6x/boot/dts/evmc6457.dts new file +106 -0

106 lines not on this page · raw message

arch/c6x/boot/dts/evmc6472.dts new file +176 -0

176 lines not on this page · raw message

arch/c6x/boot/dts/evmc6474.dts new file +133 -0

133 lines not on this page · raw message

arch/c6x/boot/install-dtb.c new file +333 -0

333 lines not on this page · raw message

arch/c6x/kernel/devicetree.c new file +53 -0

53 lines not on this page · raw message

arch/c6x/platforms/platform.c new file +23 -0
new file mode 100644
index 0000000..83fbedd
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2011 Texas Instruments Incorporated
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2. This program is licensed "as is" without any warranty of any
+ * kind, whether express or implied.
+ */
+
+#include <linux/init.h>
+#include <linux/of_platform.h>
+
+static struct of_device_id c6x_bus_ids[] __initdata = {
+	{ .type = "soc", },
+	{ .compatible = "simple-bus", },
+	{}
+};
+
+static int __init c6x_device_probe(void)
+{
+	of_platform_bus_probe(NULL, c6x_bus_ids, NULL);
+	return 0;
+}
+device_initcall(c6x_device_probe);
Signature · 1 line
1.7.6
#12 lore raw

Re: [PATCH 06/24] C6X: devicetree

Quoted 60 lines · Mark Salter

This is the basic devicetree support for C6X. Currently, four boards are supported. Each one uses a different SoC part. Two of the four supported SoCs are multicore. One with 3 cores and the other with 6 cores. There is no coherency between the core-level caches, so SMP is not an option. It is possible to run separate kernel instances on the various cores. There is currently no C6X bootloader support for device trees so we build in the DTB for now.

There are some interesting twists to the hardware which are of note for device tree support. Each core has its own interrupt controller which is controlled by special purpose core registers. This core controller provides 12 general purpose prioritized interrupt sources. Each core is contained within a hardware "module" which provides L1 and L2 caches, power control, and another interrupt controller which cascades into the core interrupt controller. These core module functions are controlled by memory mapped registers. The addresses for these registers are the same for each core. That is, when coreN accesses a module-level MMIO register at a given address, it accesses the register for coreN even though other cores would use the same address to access the register in the module containing those cores. Other hardware modules (timers, enet, etc) which are memory mapped can be accessed by all cores.

The timers need some further explanation for multicore SoCs. Even though all timer control registers are visible to all cores, interrupt routing or other considerations may make a given timer more suitable for use by a core than some other timer. Because of this and the desire to have the same image run on more than one core, the timer nodes have a "ti,core-mask" property which is used by the driver to scan for a suitable timer to use.

Cc devicetree-discuss at lists.ozlabs.org
---
 arch/c6x/boot/dts/dsk6455.dts  |  128 +++++++++++++++
 arch/c6x/boot/dts/evmc6457.dts |  106 +++++++++++++
 arch/c6x/boot/dts/evmc6472.dts |  176 +++++++++++++++++++++
 arch/c6x/boot/dts/evmc6474.dts |  133 ++++++++++++++++
 arch/c6x/boot/install-dtb.c    |  333 ++++++++++++++++++++++++++++++++++++++++
 arch/c6x/kernel/devicetree.c   |   53 +++++++
 arch/c6x/platforms/platform.c  |   23 +++
 7 files changed, 952 insertions(+), 0 deletions(-)
 create mode 100644 arch/c6x/boot/dts/dsk6455.dts
 create mode 100644 arch/c6x/boot/dts/evmc6457.dts
 create mode 100644 arch/c6x/boot/dts/evmc6472.dts
 create mode 100644 arch/c6x/boot/dts/evmc6474.dts
 create mode 100644 arch/c6x/boot/install-dtb.c
 create mode 100644 arch/c6x/kernel/devicetree.c
 create mode 100644 arch/c6x/platforms/platform.c
arch/c6x/boot/dts/dsk6455.dts new file +7 -0
new file mode 100644
index 0000000..ef703aa
@@ -0,0 +1,128 @@
+/*
+ * arch/c6x/boot/dts/dsk6455.dts
+ *
+ * DSK6455 Evaluation Platform For TMS320C6455
+ * Copyright (C) 2011 Texas Instruments Incorporated
+ *
+ * Author: Mark Salter <[email protected]>

arch/c6x/boot/dts/dsk6455.dts line 17

Quoted 10 lines
arch/c6x/boot/dts/dsk6455.dts new file +10 -0
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ */
+
+/dts-v1/;
+

I expect you'll want to use the /include/ functionality here to avoid duplicating all the SoC details in each and every board file.

Quoted 21 lines
arch/c6x/boot/dts/dsk6455.dts new file +21 -0
+/ {
+	model = "Spectrum Digital DSK6455";
+	compatible = "spectrum-digital,dsk6455";
+
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	chosen {
+		bootargs = "root=/dev/nfs ip=dhcp rw";
+	};
+
+	memory {
+		device_type = "memory";
+		reg = <0xE0000000 0x08000000>;
+	};
+
+	cpus {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		cpu at 0 {

arch/c6x/boot/dts/dsk6455.dts line 48

Quoted 10 lines
arch/c6x/boot/dts/dsk6455.dts new file +10 -0
+			device_type = "cpu";
+			model = "ti,c64x+";
+			reg = <0>;
+		};
+	};
+
+	/*
+	 * Core priority interrupt controller
+	 */
+	core_pic: interrupt-controller at 0 {

@0 doesn't make sense without a 'reg' property.

arch/c6x/boot/dts/dsk6455.dts line 51

Quoted 3 lines
arch/c6x/boot/dts/dsk6455.dts new file +3 -0
+		interrupt-controller;
+		#interrupt-cells = <1>;
+		compatible = "ti,c64x+core-pic";

The interrupt controller isn't addressable? Is it integrated into the CPU?

arch/c6x/boot/dts/dsk6455.dts line 54

Quoted 3 lines
arch/c6x/boot/dts/dsk6455.dts new file +3 -0
+	};
+
+	soc at 00000000 {

"soc at 2a80000" to match the 'reg' property of this node.

arch/c6x/boot/dts/dsk6455.dts line 55

Quoted 1 line
arch/c6x/boot/dts/dsk6455.dts new file +1 -0
+		compatible = "ti,tms320c6455";

Make sure you add documentation for all new compatible properties to Documentation/devicetree/bindings

arch/c6x/boot/dts/dsk6455.dts line 56

Quoted 1 line
arch/c6x/boot/dts/dsk6455.dts new file +1 -0
+		device_type = "soc";

Drop device_type from everything except the memory node.

arch/c6x/boot/dts/dsk6455.dts line 50

Quoted 3 lines
arch/c6x/boot/dts/dsk6455.dts new file +3 -0
+		#address-cells = <1>;
+		#size-cells = <1>;
+		#interrupt-cells = <1>;

#interrupt-cells doesn't make any sense for nodes that aren't an interrupt controller.

Quoted 13 lines
arch/c6x/boot/install-dtb.c new file +7 -0
new file mode 100644
index 0000000..fa979ce
@@ -0,0 +1,333 @@
+/*
+ * Program to hack in a DTB to an ELF file having a placeholder
+ * section named __fst_blob.
+ *
+ * This allows for building multiple images with builtin DTBs
+ * using a single vmlinux image. This is only necessary until
+ * bootloader support exists.

arch/c6x/boot/install-dtb.c line 17

Quoted 10 lines
arch/c6x/boot/install-dtb.c new file +10 -0
+ *
+ * Copyright 2011 Texas Instruments Incorporated
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ * Usage: install-dtb <image.dtb> <kernel.elf>
+ */

Surely this can be done with objcopy or with the linker.

Quoted 68 lines
arch/c6x/kernel/devicetree.c new file +53 -0
new file mode 100644
index 0000000..bdb56f0
@@ -0,0 +1,53 @@
+/*
+ *  Architecture specific OF callbacks.
+ *
+ *  Copyright (C) 2011 Texas Instruments Incorporated
+ *  Author: Mark Salter <[email protected]>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ */
+#include <linux/init.h>
+#include <linux/of.h>
+#include <linux/of_fdt.h>
+#include <linux/initrd.h>
+#include <linux/memblock.h>
+
+void __init early_init_devtree(void *params)
+{
+	/* Setup flat device-tree pointer */
+	initial_boot_params = params;
+
+	/* Retrieve various informations from the /chosen node of the
+	 * device-tree, including the platform type, initrd location and
+	 * size and more ...
+	 */
+	of_scan_flat_dt(early_init_dt_scan_chosen, c6x_command_line);
+
+	/* Scan memory nodes and rebuild MEMBLOCKs */
+	of_scan_flat_dt(early_init_dt_scan_root, NULL);
+	of_scan_flat_dt(early_init_dt_scan_memory, NULL);
+}
+
+
+#ifdef CONFIG_BLK_DEV_INITRD
+void __init early_init_dt_setup_initrd_arch(unsigned long start,
+		unsigned long end)
+{
+	initrd_start = (unsigned long)__va(start);
+	initrd_end = (unsigned long)__va(end);
+	initrd_below_start_ok = 1;
+}
+#endif
+
+void __init early_init_dt_add_memory_arch(u64 base, u64 size)
+{
+	c6x_add_memory(base, size);
+}
+
+void * __init early_init_dt_alloc_memory_arch(u64 size, u64 align)
+{
+	return __va(memblock_alloc(size, align));
+}
arch/c6x/platforms/platform.c new file +3 -0
new file mode 100644
index 0000000..83fbedd
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2011 Texas Instruments Incorporated
+ *

arch/c6x/platforms/platform.c line 13

Quoted 10 lines
arch/c6x/platforms/platform.c new file +10 -0
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2. This program is licensed "as is" without any warranty of any
+ * kind, whether express or implied.
+ */
+
+#include <linux/init.h>
+#include <linux/of_platform.h>
+
+static struct of_device_id c6x_bus_ids[] __initdata = {
+	{ .type = "soc", },

Drop .type matching. Only ever use .compatible, unless supporting legacy platforms.

arch/c6x/platforms/platform.c line 20

Quoted 7 lines
arch/c6x/platforms/platform.c new file +7 -0
+	{ .compatible = "simple-bus", },
+	{}
+};
+
+static int __init c6x_device_probe(void)
+{
+	of_platform_bus_probe(NULL, c6x_bus_ids, NULL);

You can probably just use the stock of_default_bus_match_table

g.

#13 lore raw

Re: [PATCH 06/24] C6X: devicetree

Quoted 7 lines · Grant Likely

arch/c6x/boot/dts/dsk6455.dts line 51

Quoted 3 lines · Mark Salter
arch/c6x/boot/dts/dsk6455.dts new file +3 -0
+		interrupt-controller;
+		#interrupt-cells = <1>;
+		compatible = "ti,c64x+core-pic";

The interrupt controller isn't addressable? Is it integrated into the CPU?

Yes, that core controller is controlled through registers accessed with special-purpose instructions, not MMIO. Other controllers, like megamodule and some as-yet unimplemented use MMIO.

Quoted 6 lines

arch/c6x/boot/dts/dsk6455.dts

Quoted 4 lines
arch/c6x/boot/dts/dsk6455.dts new file +3 -0
+	};
+
+	soc@00000000 {

"soc@2a80000" to match the 'reg' property of this node.

Okay, I think I need a separate node for that reg property. The SoC address space does actually start at 0. The registers in that reg property are "SoC-level" registers holding silicon revision, pin strap status, etc. All of the SoCs have a "device state config" node which have registers like that. Instead of having them in the device state block, this SoC has them in a separate area. I just got lazy and put them the reg property in the soc node, but I think it really calls for a separate node.

--Mark

maintainer
#14 lore raw

Re: [PATCH 06/24] C6X: devicetree

Quoted 6 lines · On Monday 12 September 2011 19:20:35 Mark Salter wrote:
Quoted 5 lines · Grant Likely
Quoted 3 lines · Mark Salter
arch/c6x/boot/dts/dsk6455.dts new file +3 -0
+           interrupt-controller;
+           #interrupt-cells = <1>;
+           compatible = "ti,c64x+core-pic";
Quoted 6 lines
Quoted 2 lines

The interrupt controller isn't addressable? Is it integrated into the CPU?

Yes, that core controller is controlled through registers accessed with special-purpose instructions, not MMIO. Other controllers, like megamodule and some as-yet unimplemented use MMIO.

Are these instructions specific to the interrupt controller or do they access a register space that can contain arbitrary devices?

If there is a separate address space for special devices, it might be good to describe that in the device tree, like we do for PCI I/O space.

Arnd

#15 lore raw

Re: [PATCH 06/24] C6X: devicetree

Quoted 14 lines · Arnd Bergmann
Quoted 6 lines · On Monday 12 September 2011 19:20:35 Mark Salter wrote:
Quoted 5 lines · Grant Likely
Quoted 3 lines · Mark Salter
arch/c6x/boot/dts/dsk6455.dts new file +3 -0
+           interrupt-controller;
+           #interrupt-cells = <1>;
+           compatible = "ti,c64x+core-pic";
Quoted 6 lines
Quoted 2 lines

The interrupt controller isn't addressable? Is it integrated into the CPU?

Yes, that core controller is controlled through registers accessed with special-purpose instructions, not MMIO. Other controllers, like megamodule and some as-yet unimplemented use MMIO.

Quoted 8 lines

Are these instructions specific to the interrupt controller or do they access a register space that can contain arbitrary devices?

If there is a separate address space for special devices, it might be good to describe that in the device tree, like we do for PCI I/O space.

It is a core register area. Similar to ARM or MIPS coprocessor registers.

--Mark

maintainer
#16 lore raw

Re: [PATCH 06/24] C6X: devicetree

Quoted 5 lines · Mark Salter
Quoted 4 lines · Arnd Bergmann

Are these instructions specific to the interrupt controller or do they access a register space that can contain arbitrary devices?

Quoted 7 lines
Quoted 4 lines

If there is a separate address space for special devices, it might be good to describe that in the device tree, like we do for PCI I/O space.

It is a core register area. Similar to ARM or MIPS coprocessor registers.

I guess it still depends, it's probably a grey area. If the register layout is the same on all c6x cores and it's only for core stuff, there is no need to put it in the device tree. If you have multiple soc (off-core) devices being controlled through the registers, or the numbers vary a lot between different chips, I would put all of them into the device tree.

Arnd

#17 lore raw

Re: [PATCH 06/24] C6X: devicetree

Quoted 11 lines · Arnd Bergmann
Quoted 10 lines · Mark Salter
Quoted 8 lines · Arnd Bergmann

Are these instructions specific to the interrupt controller or do they access a register space that can contain arbitrary devices?

If there is a separate address space for special devices, it might be good to describe that in the device tree, like we do for PCI I/O space.

Quoted 8 lines
Quoted 2 lines

It is a core register area. Similar to ARM or MIPS coprocessor registers.

I guess it still depends, it's probably a grey area. If the register layout is the same on all c6x cores and it's only for core stuff, there is no need to put it in the device tree. If you have multiple soc (off-core) devices being controlled through the registers, or the numbers vary a lot between different chips, I would put all of them into the device tree.

It's an interrupt controller. There still needs to be a node to act as the interrupt-parent and specify #interrupt-cells.

g.

maintainer
#18 lore raw

Re: [PATCH 06/24] C6X: devicetree

Quoted 9 lines · On Tuesday 13 September 2011 11:54:36 Grant Likely wrote:
Quoted 6 lines

I guess it still depends, it's probably a grey area. If the register layout is the same on all c6x cores and it's only for core stuff, there is no need to put it in the device tree. If you have multiple soc (off-core) devices being controlled through the registers, or the numbers vary a lot between different chips, I would put all of them into the device tree.

It's an interrupt controller. There still needs to be a node to act as the interrupt-parent and specify #interrupt-cells.

I was talking about whether the interrupt controller node needs to have a "regs" property or not. If the register space is similar to generic MMIO registers, it should have one, like all other users of these registers. If it's more like ARM's coprocessor extension, it probably should not.

Arnd

#19 lore raw

Re: [PATCH 06/24] C6X: devicetree

In reply to Grant Likely
Quoted 15 lines · Grant Likely
Quoted 14 lines · Arnd Bergmann
Quoted 12 lines · Mark Salter
Quoted 8 lines · Arnd Bergmann

Are these instructions specific to the interrupt controller or do they access a register space that can contain arbitrary devices?

If there is a separate address space for special devices, it might be good to describe that in the device tree, like we do for PCI I/O space.

It is a core register area. Similar to ARM or MIPS coprocessor registers.

Quoted 8 lines
Quoted 5 lines

I guess it still depends, it's probably a grey area. If the register layout is the same on all c6x cores and it's only for core stuff, there is no need to put it in the device tree. If you have multiple soc (off-core) devices being controlled through the registers, or the numbers vary a lot between different chips, I would put all of them into the device tree.

It's an interrupt controller. There still needs to be a node to act as the interrupt-parent and specify #interrupt-cells.

It already has that. But maybe that node should be moved into the cpu node.

--Mark

#20 lore raw

PATCH v2 7/24 C6X: memory management and DMA support

In reply to Mark Salter

The C6X architecture currently lacks an MMU so memory management is relatively simple. There is no bus snooping between L2 and main memory but coherent DMA memory is supported by making regions of main memory uncached. If such a region is desired, it can be specified on the commandline with a "memdma=" argument.

---
 arch/c6x/include/asm/dma-mapping.h |   91 +++++++++++++++++++
 arch/c6x/kernel/dma.c              |  168 ++++++++++++++++++++++++++++++++++++
 arch/c6x/mm/dma-coherent.c         |  142 ++++++++++++++++++++++++++++++
 arch/c6x/mm/init.c                 |  112 ++++++++++++++++++++++++
 4 files changed, 513 insertions(+), 0 deletions(-)
 create mode 100644 arch/c6x/include/asm/dma-mapping.h
 create mode 100644 arch/c6x/kernel/dma.c
 create mode 100644 arch/c6x/mm/dma-coherent.c
 create mode 100644 arch/c6x/mm/init.c
arch/c6x/include/asm/dma-mapping.h new file +91 -0
new file mode 100644
index 0000000..03579fd
@@ -0,0 +1,91 @@
+/*
+ *  Port on Texas Instruments TMS320C6x architecture
+ *
+ *  Copyright (C) 2004, 2009, 2010, 2011 Texas Instruments Incorporated
+ *  Author: Aurelien Jacquiot <[email protected]>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ *
+ */
+#ifndef _ASM_C6X_DMA_MAPPING_H
+#define _ASM_C6X_DMA_MAPPING_H
+
+#include <linux/dma-debug.h>
+#include <asm-generic/dma-coherent.h>
+
+#define dma_supported(d, m)	1
+
+static inline int dma_set_mask(struct device *dev, u64 dma_mask)
+{
+	if (!dev->dma_mask || !dma_supported(dev, dma_mask))
+		return -EIO;
+
+	*dev->dma_mask = dma_mask;
+
+	return 0;
+}
+
+/*
+ * DMA errors are defined by all-bits-set in the DMA address.
+ */
+static inline int dma_mapping_error(struct device *dev, dma_addr_t dma_addr)
+{
+	return dma_addr == ~0;
+}
+
+extern dma_addr_t dma_map_single(struct device *dev, void *cpu_addr,
+				 size_t size, enum dma_data_direction dir);
+
+extern void dma_unmap_single(struct device *dev, dma_addr_t handle,
+			     size_t size, enum dma_data_direction dir);
+
+extern int dma_map_sg(struct device *dev, struct scatterlist *sglist,
+		      int nents, enum dma_data_direction direction);
+
+extern void dma_unmap_sg(struct device *dev, struct scatterlist *sglist,
+			 int nents, enum dma_data_direction direction);
+
+static inline dma_addr_t dma_map_page(struct device *dev, struct page *page,
+				      unsigned long offset, size_t size,
+				      enum dma_data_direction dir)
+{
+	dma_addr_t handle;
+
+	handle = dma_map_single(dev, page_address(page) + offset, size, dir);
+
+	debug_dma_map_page(dev, page, offset, size, dir, handle, false);
+
+	return handle;
+}
+
+static inline void dma_unmap_page(struct device *dev, dma_addr_t handle,
+		size_t size, enum dma_data_direction dir)
+{
+	dma_unmap_single(dev, handle, size, dir);
+
+	debug_dma_unmap_page(dev, handle, size, dir, false);
+}
+
+extern void dma_sync_single_for_cpu(struct device *dev, dma_addr_t handle,
+				    size_t size, enum dma_data_direction dir);
+
+extern void dma_sync_single_for_device(struct device *dev, dma_addr_t handle,
+				       size_t size,
+				       enum dma_data_direction dir);
+
+extern void dma_sync_sg_for_cpu(struct device *dev, struct scatterlist *sg,
+				int nents, enum dma_data_direction dir);
+
+extern void dma_sync_sg_for_device(struct device *dev, struct scatterlist *sg,
+				   int nents, enum dma_data_direction dir);
+
+extern void coherent_mem_init(u32 start, u32 size);
+extern void *dma_alloc_coherent(struct device *, size_t, dma_addr_t *, gfp_t);
+extern void dma_free_coherent(struct device *, size_t, void *, dma_addr_t);
+
+#define dma_alloc_noncoherent(d, s, h, f) dma_alloc_coherent((d), (s), (h), (f))
+#define dma_free_noncoherent(d, s, v, h)  dma_free_coherent((d), (s), (v), (h))
+
+#endif	/* _ASM_C6X_DMA_MAPPING_H */
arch/c6x/kernel/dma.c new file +168 -0

168 lines not on this page · raw message

arch/c6x/mm/dma-coherent.c new file +142 -0

142 lines not on this page · raw message

arch/c6x/mm/init.c new file +112 -0

112 lines not on this page · raw message

Signature · 1 line
1.7.6
#21 lore raw

PATCH v2 8/24 C6X: process management

In reply to Mark Salter
---
 arch/c6x/include/asm/processor.h   |  132 ++++++++++++++++++
 arch/c6x/include/asm/thread_info.h |  121 +++++++++++++++++
 arch/c6x/kernel/process.c          |  260 ++++++++++++++++++++++++++++++++++++
 arch/c6x/kernel/switch_to.S        |   74 ++++++++++
 4 files changed, 587 insertions(+), 0 deletions(-)
 create mode 100644 arch/c6x/include/asm/processor.h
 create mode 100644 arch/c6x/include/asm/thread_info.h
 create mode 100644 arch/c6x/kernel/process.c
 create mode 100644 arch/c6x/kernel/switch_to.S
arch/c6x/include/asm/processor.h new file +132 -0
new file mode 100644
index 0000000..8154c4e
@@ -0,0 +1,132 @@
+/*
+ *  Port on Texas Instruments TMS320C6x architecture
+ *
+ *  Copyright (C) 2004, 2009, 2010, 2011 Texas Instruments Incorporated
+ *  Author: Aurelien Jacquiot (aurelien.jacquiot at jaluna.com)
+ *
+ *  Updated for 2.6.34: Mark Salter <[email protected]>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ */
+#ifndef _ASM_C6X_PROCESSOR_H
+#define _ASM_C6X_PROCESSOR_H
+
+#include <asm/ptrace.h>
+#include <asm/page.h>
+#include <asm/current.h>
+
+/*
+ * Default implementation of macro that returns current
+ * instruction pointer ("program counter").
+ */
+#define current_text_addr()			\
+({						\
+	void *__pc;				\
+	asm("mvc .S2 pce1,%0\n" : "=b"(__pc));	\
+	__pc;					\
+})
+
+/*
+ * User space process size. This is mostly meaningless for NOMMU
+ * but some C6X processors may have RAM addresses up to 0xFFFFFFFF.
+ * Since calls like mmap() can return an address or an error, we
+ * have to allow room for error returns when code does something
+ * like:
+ *
+ *       addr = do_mmap(...)
+ *       if ((unsigned long)addr >= TASK_SIZE)
+ *            ... its an error code, not an address ...
+ *
+ * Here, we allow for 4096 error codes which means we really can't
+ * use the last 4K page on systems with RAM extending all the way
+ * to the end of the 32-bit address space.
+ */
+#define TASK_SIZE	0xFFFFF000
+
+/*
+ * This decides where the kernel will search for a free chunk of vm
+ * space during mmap's. We won't be using it
+ */
+#define TASK_UNMAPPED_BASE	0
+
+struct thread_struct {
+	unsigned long long b15_14;
+	unsigned long long a15_14;
+	unsigned long long b13_12;
+	unsigned long long a13_12;
+	unsigned long long b11_10;
+	unsigned long long a11_10;
+	unsigned long long ricl_icl;
+	unsigned long  usp;		/* user stack pointer */
+	unsigned long  pc;		/* kernel pc */
+	unsigned long  wchan;
+};
+
+#define INIT_THREAD					\
+{							\
+	.usp = 0,					\
+	.wchan = 0,					\
+}
+
+#define INIT_MMAP { \
+	&init_mm, 0, 0, NULL, PAGE_SHARED, VM_READ | VM_WRITE | VM_EXEC, 1, \
+	NULL, NULL }
+
+#define task_pt_regs(task) \
+	((struct pt_regs *)(THREAD_START_SP + task_stack_page(task)) - 1)
+
+#define alloc_kernel_stack()	__get_free_page(GFP_KERNEL)
+#define free_kernel_stack(page) free_page((page))
+
+
+/* Forward declaration, a strange C thing */
+struct task_struct;
+
+extern void start_thread(struct pt_regs *regs, unsigned int pc,
+			 unsigned long usp);
+
+/* Free all resources held by a thread. */
+static inline void release_thread(struct task_struct *dead_task)
+{
+}
+
+/* Prepare to copy thread state - unlazy all lazy status */
+#define prepare_to_copy(tsk)	do { } while (0)
+
+extern int kernel_thread(int (*fn)(void *), void * arg, unsigned long flags);
+
+#define copy_segments(tsk, mm)		do { } while (0)
+#define release_segments(mm)		do { } while (0)
+
+/*
+ * saved PC of a blocked thread.
+ */
+#define thread_saved_pc(tsk) (task_pt_regs(tsk)->pc)
+
+/*
+ * saved kernel SP and DP of a blocked thread.
+ */
+#ifdef _BIG_ENDIAN
+#define thread_saved_ksp(tsk) \
+	(*(unsigned long *)&(tsk)->thread.b15_14)
+#define thread_saved_dp(tsk) \
+	(*(((unsigned long *)&(tsk)->thread.b15_14) + 1))
+#else
+#define thread_saved_ksp(tsk) \
+	(*(((unsigned long *)&(tsk)->thread.b15_14) + 1))
+#define thread_saved_dp(tsk) \
+	(*(unsigned long *)&(tsk)->thread.b15_14)
+#endif
+
+extern unsigned long get_wchan(struct task_struct *p);
+
+#define KSTK_EIP(tsk)	(task_pt_regs(task)->pc)
+#define	KSTK_ESP(tsk)	(task_pt_regs(task)->sp)
+
+#define cpu_relax()		do { } while (0)
+
+extern const struct seq_operations cpuinfo_op;
+
+#endif /* ASM_C6X_PROCESSOR_H */
arch/c6x/include/asm/thread_info.h new file +121 -0

121 lines not on this page · raw message

arch/c6x/kernel/process.c new file +260 -0

260 lines not on this page · raw message

arch/c6x/kernel/switch_to.S new file +74 -0

74 lines not on this page · raw message

Signature · 1 line
1.7.6
#22 lore raw

PATCH v2 9/24 C6X: signal management

In reply to Mark Salter
---
 arch/c6x/include/asm/sigcontext.h |   80 ++++++++
 arch/c6x/include/asm/signal.h     |   17 ++
 arch/c6x/kernel/signal.c          |  377 +++++++++++++++++++++++++++++++++++++
 3 files changed, 474 insertions(+), 0 deletions(-)
 create mode 100644 arch/c6x/include/asm/sigcontext.h
 create mode 100644 arch/c6x/include/asm/signal.h
 create mode 100644 arch/c6x/kernel/signal.c
arch/c6x/include/asm/sigcontext.h new file +80 -0
new file mode 100644
index 0000000..eb702f3
@@ -0,0 +1,80 @@
+/*
+ *  Port on Texas Instruments TMS320C6x architecture
+ *
+ *  Copyright (C) 2004, 2009 Texas Instruments Incorporated
+ *  Author: Aurelien Jacquiot (aurelien.jacquiot at jaluna.com)
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ */
+#ifndef _ASM_C6X_SIGCONTEXT_H
+#define _ASM_C6X_SIGCONTEXT_H
+
+
+struct sigcontext {
+	unsigned long  sc_mask;		/* old sigmask */
+	unsigned long  sc_sp;		/* old user stack pointer */
+
+	unsigned long  sc_a4;
+	unsigned long  sc_b4;
+	unsigned long  sc_a6;
+	unsigned long  sc_b6;
+	unsigned long  sc_a8;
+	unsigned long  sc_b8;
+
+	unsigned long  sc_a0;
+	unsigned long  sc_a1;
+	unsigned long  sc_a2;
+	unsigned long  sc_a3;
+	unsigned long  sc_a5;
+	unsigned long  sc_a7;
+	unsigned long  sc_a9;
+
+	unsigned long  sc_b0;
+	unsigned long  sc_b1;
+	unsigned long  sc_b2;
+	unsigned long  sc_b3;
+	unsigned long  sc_b5;
+	unsigned long  sc_b7;
+	unsigned long  sc_b9;
+
+	unsigned long  sc_a16;
+	unsigned long  sc_a17;
+	unsigned long  sc_a18;
+	unsigned long  sc_a19;
+	unsigned long  sc_a20;
+	unsigned long  sc_a21;
+	unsigned long  sc_a22;
+	unsigned long  sc_a23;
+	unsigned long  sc_a24;
+	unsigned long  sc_a25;
+	unsigned long  sc_a26;
+	unsigned long  sc_a27;
+	unsigned long  sc_a28;
+	unsigned long  sc_a29;
+	unsigned long  sc_a30;
+	unsigned long  sc_a31;
+
+	unsigned long  sc_b16;
+	unsigned long  sc_b17;
+	unsigned long  sc_b18;
+	unsigned long  sc_b19;
+	unsigned long  sc_b20;
+	unsigned long  sc_b21;
+	unsigned long  sc_b22;
+	unsigned long  sc_b23;
+	unsigned long  sc_b24;
+	unsigned long  sc_b25;
+	unsigned long  sc_b26;
+	unsigned long  sc_b27;
+	unsigned long  sc_b28;
+	unsigned long  sc_b29;
+	unsigned long  sc_b30;
+	unsigned long  sc_b31;
+
+	unsigned long  sc_csr;
+	unsigned long  sc_pc;
+};
+
+#endif /* _ASM_C6X_SIGCONTEXT_H */
arch/c6x/include/asm/signal.h new file +17 -0
new file mode 100644
index 0000000..f1cd870
@@ -0,0 +1,17 @@
+#ifndef _ASM_C6X_SIGNAL_H
+#define _ASM_C6X_SIGNAL_H
+
+#include <asm-generic/signal.h>
+
+#ifndef __ASSEMBLY__
+#include <linux/linkage.h>
+
+struct pt_regs;
+
+extern asmlinkage int do_rt_sigreturn(struct pt_regs *regs);
+extern asmlinkage void do_notify_resume(struct pt_regs *regs,
+					u32 thread_info_flags,
+					int syscall);
+#endif
+
+#endif /* _ASM_C6X_SIGNAL_H */
arch/c6x/kernel/signal.c new file +377 -0

377 lines not on this page · raw message

Signature · 1 line
1.7.6
#23 lore raw

Re: [PATCH 09/24] C6X: signal management

Quoted 11 lines · Mark Salter
arch/c6x/kernel/signal.c new file +11 -0
+static int setup_rt_frame(int signr, struct k_sigaction *ka, siginfo_t *info,
+			   sigset_t *set, struct pt_regs *regs)
+{
+	struct rt_sigframe __user *frame;
+	unsigned long __user *retcode;
+	int err = 0;
+
+	frame = get_sigframe(ka, regs, sizeof(*frame));
+
+	if (!access_ok(VERIFY_WRITE, frame, sizeof(*frame)))
+		goto segv_and_exit;

[...]

arch/c6x/kernel/signal.c line 222

Quoted 4 lines
arch/c6x/kernel/signal.c new file +4 -0
+segv_and_exit:
+	force_sig(SIGSEGV, current);
+	return -EFAULT;
+}

Shouldn't that really be a call to force_sigsegv(signr, current) ?

#24 lore raw

Re: [PATCH 09/24] C6X: signal management

Quoted 6 lines · Matt Fleming

arch/c6x/kernel/signal.c line 222

Quoted 4 lines
arch/c6x/kernel/signal.c new file +4 -0
+segv_and_exit:
+     force_sig(SIGSEGV, current);
+     return -EFAULT;
+}

Shouldn't that really be a call to force_sigsegv(signr, current) ?

Yes, I think so. Thanks.

--Mark

#25 lore raw

PATCH v2 10/24 C6X: time management

In reply to Mark Salter

The C6X architecture includes a 64-bit free running core clock counter which is used as the clocksource. The SoCs have a number of 64-bit programmable timers. One of these is used as the clockevent timer.

---
 arch/c6x/include/asm/timex.h |   41 +++++++++
 arch/c6x/kernel/time.c       |   64 ++++++++++++++
 arch/c6x/platforms/timer64.c |  191 ++++++++++++++++++++++++++++++++++++++++++
 arch/c6x/platforms/timer64.h |    6 ++
 4 files changed, 302 insertions(+), 0 deletions(-)
 create mode 100644 arch/c6x/include/asm/timex.h
 create mode 100644 arch/c6x/kernel/time.c
 create mode 100644 arch/c6x/platforms/timer64.c
 create mode 100644 arch/c6x/platforms/timer64.h
arch/c6x/include/asm/timex.h new file +41 -0
new file mode 100644
index 0000000..0741648
@@ -0,0 +1,41 @@
+/*
+ *  Port on Texas Instruments TMS320C6x architecture
+ *
+ *  Copyright (C) 2004, 2009, 2010, 2011 Texas Instruments Incorporated
+ *  Author: Aurelien Jacquiot (aurelien.jacquiot at jaluna.com)
+ *
+ *  Modified for 2.6.34: Mark Salter <[email protected]>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ */
+#ifndef _ASM_C6X_TIMEX_H
+#define _ASM_C6X_TIMEX_H
+
+/*
+ * This should be close enough...
+ */
+#define CLOCK_TICK_RATE ((1000 * 1000000UL) / 6)
+
+/* 64-bit timestamp */
+typedef unsigned long long cycles_t;
+
+extern cycles_t cacheflush_time;
+
+static inline cycles_t get_cycles(void)
+{
+	unsigned l, h;
+
+	asm volatile (" dint\n"
+		      " mvc .s2 TSCL,%0\n"
+		      " mvc .s2 TSCH,%1\n"
+		      " rint\n"
+		      : "=b"(l), "=b"(h));
+	return ((cycles_t)h << 32) | l;
+}
+
+extern int init_tsc_clocksource(void);
+extern int init_timer64_clocksource(void);
+
+#endif /* _ASM_C6X_TIMEX_H */
arch/c6x/kernel/time.c new file +64 -0

64 lines not on this page · raw message

arch/c6x/platforms/timer64.c new file +191 -0

191 lines not on this page · raw message

arch/c6x/platforms/timer64.h new file +6 -0
new file mode 100644
index 0000000..11f53d6
@@ -0,0 +1,6 @@
+#ifndef _C6X_TIMER64_PIC_H
+#define _C6X_TIMER64_PIC_H
+
+extern void __init timer64_init(void);
+
+#endif /* _C6X_TIMER64_PIC_H */
Signature · 1 line
1.7.6
#26 lore raw

Re: [PATCH 10/24] C6X: time management

Quoted 9 lines · Mark Salter
arch/c6x/platforms/timer64.c new file +9 -0
+static int next_event(unsigned long delta,
+		      struct clock_event_device *evt)
+{
+	soc_writel(soc_readl(&timer->tcr) & ~TCR_ENAMODELO_MASK, &timer->tcr);
+	soc_writel(delta - 1, &timer->prdlo);
+	soc_writel(0, &timer->cntlo);
+	soc_writel(soc_readl(&timer->tcr) | TCR_ENAMODELO_ONCE, &timer->tcr);
+
+	return 0;

arch/c6x/platforms/timer64.c line 93

Quoted 10 lines
arch/c6x/platforms/timer64.c new file +10 -0
+}
+
+static void set_clock_mode(enum clock_event_mode mode,
+			   struct clock_event_device *evt)
+{
+}
+
+static void event_handler(struct clock_event_device *dev)
+{
+}

You don't need a handler function. The core code sets one for you.

Quoted 13 lines
arch/c6x/platforms/timer64.c new file +13 -0
+static irqreturn_t timer_interrupt(int irq, void *dev_id)
+{
+	struct clock_event_device *cd = &t64_clockevent_device;
+
+	cd->event_handler(cd);
+
+	return IRQ_HANDLED;
+}
+
+
+void __init timer64_init(void)
+{
+	struct clock_event_device *cd = &t64_clockevent_device;

...

arch/c6x/platforms/timer64.c line 158

Quoted 2 lines
arch/c6x/platforms/timer64.c new file +2 -0
+	cd->name	= "TIMER64_EVT32_TIMER";
+	cd->features	= CLOCK_EVT_FEAT_ONESHOT;

Please move those into a static initializer of t64_clockevent_device.

arch/c6x/platforms/timer64.c line 171

Quoted 12 lines
arch/c6x/platforms/timer64.c new file +12 -0
+	/* Calculate the min / max delta */
+	/* Find a shift value */
+	for (shift = 32; shift > 0; shift--) {
+		temp = (u64)(c6x_core_freq / TIMER_DIVISOR);
+		temp <<=  shift;
+
+		do_div(temp, NSEC_PER_SEC);
+		if ((temp >> 32) == 0)
+			break;
+	}
+	cd->shift = shift;
+	cd->mult = (u32) temp;

clockevents_calc_mult_shift() please

arch/c6x/platforms/timer64.c line 177

Quoted 2 lines
arch/c6x/platforms/timer64.c new file +2 -0
+	cd->rating		= 200;
+	cd->set_mode		= set_clock_mode;

static initializer

arch/c6x/platforms/timer64.c line 178

Quoted 1 line
arch/c6x/platforms/timer64.c new file +1 -0
+	cd->event_handler	= event_handler;

Please drop

arch/c6x/platforms/timer64.c line 179

Quoted 1 line
arch/c6x/platforms/timer64.c new file +1 -0
+	cd->set_next_event	= next_event;

static initializer

arch/c6x/platforms/timer64.c line 185

Quoted 6 lines
arch/c6x/platforms/timer64.c new file +6 -0
+	cd->cpumask		= cpumask_of(smp_processor_id());
+
+	clockevents_register_device(cd);
+
+	/* Set handler */
+	if (cd->irq != NO_IRQ)

How does a timer device work w/o interrupt ?

arch/c6x/platforms/timer64.c line 187

Quoted 2 lines
arch/c6x/platforms/timer64.c new file +2 -0
+		request_irq(cd->irq, timer_interrupt,
+			    IRQF_DISABLED | IRQF_TIMER, "timer", NULL);

Please drop IRQF_DISABLED it's about to vanish.

Thanks,

tglx

#27 lore raw

Re: [PATCH 10/24] C6X: time management

Quoted 9 lines · Thomas Gleixner

arch/c6x/platforms/timer64.c line 185

Quoted 6 lines · Mark Salter
arch/c6x/platforms/timer64.c new file +6 -0
+	cd->cpumask		= cpumask_of(smp_processor_id());
+
+	clockevents_register_device(cd);
+
+	/* Set handler */
+	if (cd->irq != NO_IRQ)

How does a timer device work w/o interrupt ?

Heh, not very well. That check needs to happen earlier so we don't register the device if we can't find the irq number.

--Mark

#28 lore raw

Re: [PATCH 10/24] C6X: time management

In reply to Mark Salter
Quoted 5 lines · Mark Salter

The C6X architecture includes a 64-bit free running core clock counter which is used as the clocksource. The SoCs have a number of 64-bit programmable timers. One of these is used as the clockevent timer.

Sort of a tangent to this specific patch, but since it came up recently in the x32 discussion, I wanted to check if you were using a 64bit definition of time_t?

thanks
-john

#29 lore raw

Re: [PATCH 10/24] C6X: time management

Quoted 10 lines · john stultz
Quoted 5 lines · Mark Salter

The C6X architecture includes a 64-bit free running core clock counter which is used as the clocksource. The SoCs have a number of 64-bit programmable timers. One of these is used as the clockevent timer.

Sort of a tangent to this specific patch, but since it came up recently in the x32 discussion, I wanted to check if you were using a 64bit definition of time_t?

C6X uses the asm-generic definition which is a long, so 32-bits.

--Mark

#30 lore raw

Re: [PATCH 10/24] C6X: time management

Quoted 6 lines · Mark Salter
Quoted 5 lines · john stultz
Quoted 4 lines · Mark Salter

The C6X architecture includes a 64-bit free running core clock counter which is used as the clocksource. The SoCs have a number of 64-bit programmable timers. One of these is used as the clockevent timer.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Sort of a tangent to this specific patch, but since it came up recently in the x32 discussion, I wanted to check if you were using a 64bit definition of time_t?

C6X uses the asm-generic definition which is a long, so 32-bits.

You might want to seriously consider following the x32 folks and use 64 bits, as 2038 isn't very far away.

thanks
-john

#31 lore raw

PATCH v2 11/24 C6X: interrupt handling

In reply to Mark Salter

The C6X core includes an interrupt controller with 12 inputs of fixed priority. Each core is contained within a core "megamodule" which includes another interrupt controller which cascades into the prioritized core controller. The megamodule PIC has four interrupt combiners; each with up to 32 inputs which are combined into one interrupt. The megamodule contains a set of MUX registers which are used map megamodule interrupt sources to one of 12 core interrupts. Any one of these 12 MUX outputs feeding into the core interrupt controller may be the output from one of the four interrupt combiners or an individual megamodule interrupt source. An individual megamodule interrupt source will bypass the combiners if the MUX registers are set up such that the individual interrupt feeds directly to one of the 12 core interrupts. This priority mapping of interrupts is supported in the devicetree by means of a "ti,priority-map" property in the megamodule interrupt controller node.

Most of the code in arch/c6x/kernel/irq.c which supports mapping of hardware interrupts to virtual kernel interrupts was taken as-is from powerpc. Very few changes were necessary for C6X, so separating that out into the generic kernel interrupt code may be worthwhile for cases where other architectures may want to use it.

---
 arch/c6x/include/asm/hardirq.h   |   20 +
 arch/c6x/include/asm/irq.h       |  302 ++++++++++++++++
 arch/c6x/include/asm/irqflags.h  |   72 ++++
 arch/c6x/kernel/irq.c            |  732 ++++++++++++++++++++++++++++++++++++++
 arch/c6x/platforms/megamod-pic.c |  336 +++++++++++++++++
 arch/c6x/platforms/megamod-pic.h |    9 +
 6 files changed, 1471 insertions(+), 0 deletions(-)
 create mode 100644 arch/c6x/include/asm/hardirq.h
 create mode 100644 arch/c6x/include/asm/irq.h
 create mode 100644 arch/c6x/include/asm/irqflags.h
 create mode 100644 arch/c6x/kernel/irq.c
 create mode 100644 arch/c6x/platforms/megamod-pic.c
 create mode 100644 arch/c6x/platforms/megamod-pic.h
arch/c6x/include/asm/hardirq.h new file +20 -0
new file mode 100644
index 0000000..9621954
@@ -0,0 +1,20 @@
+/*
+ *  Port on Texas Instruments TMS320C6x architecture
+ *
+ *  Copyright (C) 2004, 2009, 2010 Texas Instruments Incorporated
+ *  Author: Aurelien Jacquiot (aurelien.jacquiot at jaluna.com)
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ */
+
+#ifndef _ASM_C6X_HARDIRQ_H
+#define _ASM_C6X_HARDIRQ_H
+
+extern void ack_bad_irq(int irq);
+#define ack_bad_irq ack_bad_irq
+
+#include <asm-generic/hardirq.h>
+
+#endif /* _ASM_C6X_HARDIRQ_H */
arch/c6x/include/asm/irq.h new file +302 -0

302 lines not on this page · raw message

arch/c6x/include/asm/irqflags.h new file +72 -0

72 lines not on this page · raw message

arch/c6x/kernel/irq.c new file +732 -0

732 lines not on this page · raw message

arch/c6x/platforms/megamod-pic.c new file +336 -0

336 lines not on this page · raw message

arch/c6x/platforms/megamod-pic.h new file +9 -0
new file mode 100644
index 0000000..eca0a86
@@ -0,0 +1,9 @@
+#ifndef _C6X_MEGAMOD_PIC_H
+#define _C6X_MEGAMOD_PIC_H
+
+#ifdef __KERNEL__
+
+extern void __init megamod_pic_init(void);
+
+#endif /* __KERNEL__ */
+#endif /* _C6X_MEGAMOD_PIC_H */
Signature · 1 line
1.7.6
#32 lore raw

Re: [PATCH 11/24] C6X: interrupt handling

Quoted 2 lines · Mark Salter

+ *
+ * Large parts taken directly from powerpc.

Is it really necessary to copy that stuff instead of generalizing it ? I guess that's mostly about the reverse map & Co.

arch/c6x/kernel/irq.c line 33

Quoted 2 lines
arch/c6x/kernel/irq.c new file +2 -0
+
+static spinlock_t core_irq_lock;

raw_spinlock_t please

arch/c6x/kernel/irq.c line 42

Quoted 8 lines
arch/c6x/kernel/irq.c new file +8 -0
+static void mask_core_irq(struct irq_data *data)
+{
+	unsigned int prio = data->irq;
+	unsigned long flags;
+
+	BUG_ON(prio < 4 || prio >= NR_PRIORITY_IRQS);
+
+	spin_lock_irqsave(&core_irq_lock, flags);

The chip functions are called with interrupts disabled, so raw_spin_lock() is sufficient

Quoted 3 lines

+/*
+ * IRQ controller and virtual interrupts
+ */

How different is this from PPC ? Looks fairly familiar to me :)

arch/c6x/platforms/megamod-pic.c line 52

Quoted 4 lines
arch/c6x/platforms/megamod-pic.c new file +4 -0
+struct megamod_pic {
+	struct irq_host	*irqhost;
+	struct megamod_regs __iomem *regs;
+	spinlock_t lock;

raw_spinlock_t please

Quoted 12 lines
arch/c6x/platforms/megamod-pic.c new file +12 -0
+
+	/* hw mux mapping */
+	unsigned int output_to_irq[NR_MUX_OUTPUTS];
+};
+
+static struct megamod_pic *mm_pic;
+
+struct megamod_cascade_data {
+	struct megamod_pic *pic;
+	int index;
+};
+

arch/c6x/platforms/megamod-pic.c line 74

Quoted 10 lines
arch/c6x/platforms/megamod-pic.c new file +10 -0
+static struct megamod_cascade_data cascade_data[NR_COMBINERS];
+
+static void mask_megamod(struct irq_data *data)
+{
+	struct megamod_pic *pic = irq_data_get_irq_chip_data(data);
+	irq_hw_number_t src = irqd_to_hwirq(data);
+	unsigned long flags;
+	u32 __iomem *evtmask = &pic->regs->evtmask[src / 32];
+
+	spin_lock_irqsave(&pic->lock, flags);

raw_spin_lock() is sufficient

Quoted 11 lines
arch/c6x/platforms/megamod-pic.c new file +10 -0
+	soc_writel(soc_readl(evtmask) | (1 << (src & 31)), evtmask);
+	spin_unlock_irqrestore(&pic->lock, flags);
+}
+
 
+static void megamod_irq_cascade(unsigned int irq, struct irq_desc *desc)
+{
+	struct irq_chip *chip = irq_desc_get_chip(desc);
+	struct irq_data *idata = irq_desc_get_irq_data(desc);
+	struct megamod_cascade_data *cascade;
+	struct megamod_pic *pic;

arch/c6x/platforms/megamod-pic.c line 112

Quoted 10 lines
arch/c6x/platforms/megamod-pic.c new file +10 -0
+	u32 events;
+	int n, idx;
+
+	cascade = irq_desc_get_handler_data(desc);
+
+	pic = cascade->pic;
+
+	raw_spin_lock(&desc->lock);
+
+	chip->irq_mask(idata);

This runs with interrupts disabled, so why the lock, mask and the inprogress fiddling? That interrupt cannot be reentered and it is not controlled by disable_irq/enable_irq and better not subject to free_irq, so why do you need this?

Thanks,

tglx

#33 lore raw

Re: [PATCH 11/24] C6X: interrupt handling

Quoted 7 lines · Thomas Gleixner
Quoted 2 lines · Mark Salter

+ *
+ * Large parts taken directly from powerpc.

Is it really necessary to copy that stuff instead of generalizing it ? I guess that's mostly about the reverse map & Co.

I have a patch that takes the code out of powerpc and puts in kernel/irq where both powerpc and c6x can use it. That leaves us with two files in kernel/irq trying to manage hw <--> virt mappings. So, some merging of irqdomain.c and the former powerpc code is needed. I'm not sure how that should go. At the moment, irqdomain doesn't support dynamic allocation of irq_descs, so its not currently suitable for powerpc or c6x.

Quoted 5 lines
Quoted 3 lines

+/*
+ * IRQ controller and virtual interrupts
+ */

How different is this from PPC ? Looks fairly familiar to me :)

I had changed it in a few minor ways, but looking again, I probably didn't need to change it at all. In the patch to generalize it, I simply did s/NUM_ISA_INTERRUPTS/NR_IRQS_LEGACY/.

Quoted 13 lines
Quoted 13 lines
arch/c6x/platforms/megamod-pic.c new file +13 -0
+static void megamod_irq_cascade(unsigned int irq, struct irq_desc *desc)
+{
+	struct irq_chip *chip = irq_desc_get_chip(desc);
+	struct irq_data *idata = irq_desc_get_irq_data(desc);
+	struct megamod_cascade_data *cascade;
+	struct megamod_pic *pic;
+	u32 events;
+	int n, idx;
+
+	cascade = irq_desc_get_handler_data(desc);
+
+	pic = cascade->pic;
+
Quoted 8 lines

arch/c6x/platforms/megamod-pic.c line 112

Quoted 3 lines
arch/c6x/platforms/megamod-pic.c new file +3 -0
+	raw_spin_lock(&desc->lock);
+
+	chip->irq_mask(idata);

This runs with interrupts disabled, so why the lock, mask and the inprogress fiddling? That interrupt cannot be reentered and it is not controlled by disable_irq/enable_irq and better not subject to free_irq, so why do you need this?

It was leftover cruft from a previous incarnation. Not needed, so I took it out.

--Mark

#34 lore raw

Re: [PATCH 11/24] C6X: interrupt handling

Quoted 9 lines · Mark Salter
Quoted 7 lines · Thomas Gleixner
Quoted 2 lines · Mark Salter

+ *
+ * Large parts taken directly from powerpc.

Is it really necessary to copy that stuff instead of generalizing it ? I guess that's mostly about the reverse map & Co.

Quoted 6 lines

I have a patch that takes the code out of powerpc and puts in kernel/irq where both powerpc and c6x can use it. That leaves us with two files in kernel/irq trying to manage hw <--> virt mappings. So, some merging of irqdomain.c and the former powerpc code is needed. I'm not sure how that should go. At the moment, irqdomain doesn't support dynamic allocation of irq_descs, so its not currently suitable for powerpc or c6x.

Grant was working on that as well. You should talk to him.

Quoted 10 lines
Quoted 6 lines
Quoted 4 lines

+/*
+ * IRQ controller and virtual interrupts
+ */

How different is this from PPC ? Looks fairly familiar to me :)

I had changed it in a few minor ways, but looking again, I probably didn't need to change it at all. In the patch to generalize it, I simply did s/NUM_ISA_INTERRUPTS/NR_IRQS_LEGACY/.

Thanks,

tglx

#35 lore raw

Re: [PATCH 11/24] C6X: interrupt handling

Quoted 11 lines · Thomas Gleixner
Quoted 9 lines · Mark Salter
Quoted 7 lines · Thomas Gleixner
Quoted 2 lines · Mark Salter

+ *
+ * Large parts taken directly from powerpc.

Is it really necessary to copy that stuff instead of generalizing it ? I guess that's mostly about the reverse map & Co.

Quoted 8 lines
Quoted 6 lines

I have a patch that takes the code out of powerpc and puts in kernel/irq where both powerpc and c6x can use it. That leaves us with two files in kernel/irq trying to manage hw <--> virt mappings. So, some merging of irqdomain.c and the former powerpc code is needed. I'm not sure how that should go. At the moment, irqdomain doesn't support dynamic allocation of irq_descs, so its not currently suitable for powerpc or c6x.

Grant was working on that as well. You should talk to him.

Yes, I've been working on it, but it isn't complete. Summer hit and all my hacking time went to travel and being a father to my home-from-school children. :-)

I believe Deepak is getting an engineer assigned from Linaro to help me finish the work of migrating PowerPC to use irqdomain.c. We talked about it last week at Linux Plumbers conference.

g.

#36 lore raw

PATCH v2 12/24 C6X: syscalls

In reply to Mark Salter
---
 arch/c6x/include/asm/syscalls.h |   55 ++++++++++++++++++++++++++
 arch/c6x/include/asm/unistd.h   |   26 ++++++++++++
 arch/c6x/kernel/sys_c6x.c       |   82 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 163 insertions(+), 0 deletions(-)
 create mode 100644 arch/c6x/include/asm/syscalls.h
 create mode 100644 arch/c6x/include/asm/unistd.h
 create mode 100644 arch/c6x/kernel/sys_c6x.c
arch/c6x/include/asm/syscalls.h new file +55 -0
new file mode 100644
index 0000000..aed53da
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2011 Texas Instruments Incorporated
+ * Author: Mark Salter <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ * NON INFRINGEMENT.  See the GNU General Public License for
+ * more details.
+ */
+
+#ifndef __ASM_C6X_SYSCALLS_H
+#define __ASM_C6X_SYSCALLS_H
+
+#include <linux/compiler.h>
+#include <linux/linkage.h>
+#include <linux/types.h>
+
+/* The array of function pointers for syscalls. */
+extern void *sys_call_table[];
+
+/* The following are trampolines in entry.S to handle 64-bit arguments */
+extern long sys_pread_c6x(unsigned int fd, char __user *buf,
+			  size_t count, off_t pos_low, off_t pos_high);
+extern long sys_pwrite_c6x(unsigned int fd, const char __user *buf,
+			   size_t count, off_t pos_low, off_t pos_high);
+extern long sys_truncate64_c6x(const char __user *path,
+			       off_t length_low, off_t length_high);
+extern long sys_ftruncate64_c6x(unsigned int fd,
+			       off_t length_low, off_t length_high);
+extern long sys_fadvise64_c6x(int fd, u32 offset_lo, u32 offset_hi,
+			      u32 len, int advice);
+extern long sys_fadvise64_64_c6x(int fd, u32 offset_lo, u32 offset_hi,
+				u32 len_lo, u32 len_hi, int advice);
+extern long sys_fallocate_c6x(int fd, int mode,
+			      u32 offset_lo, u32 offset_hi,
+			      u32 len_lo, u32 len_hi);
+extern int sys_cache_sync(unsigned long s, unsigned long e);
+
+struct pt_regs;
+
+extern asmlinkage long sys_c6x_clone(struct pt_regs *regs);
+extern asmlinkage long sys_c6x_execve(const char __user *name,
+				      const char __user *const __user *argv,
+				      const char __user *const __user *envp,
+				      struct pt_regs *regs);
+
+
+#include <asm-generic/syscalls.h>
+
+#endif /* __ASM_C6X_SYSCALLS_H */
arch/c6x/include/asm/unistd.h new file +26 -0
new file mode 100644
index 0000000..6d54ea4
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2011 Texas Instruments Incorporated
+ *
+ * Based on arch/tile version.
+ *
+ *   This program is free software; you can redistribute it and/or
+ *   modify it under the terms of the GNU General Public License
+ *   as published by the Free Software Foundation, version 2.
+ *
+ *   This program is distributed in the hope that it will be useful, but
+ *   WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, GOOD TITLE or
+ *   NON INFRINGEMENT.	See the GNU General Public License for
+ *   more details.
+ */
+#if !defined(_ASM_C6X_UNISTD_H) || defined(__SYSCALL)
+#define _ASM_C6X_UNISTD_H
+
+/* Use the standard ABI for syscalls. */
+#include <asm-generic/unistd.h>
+
+/* C6X-specific syscalls. */
+#define __NR_cache_sync	(__NR_arch_specific_syscall + 0)
+__SYSCALL(__NR_cache_sync, sys_cache_sync)
+
+#endif /* _ASM_C6X_UNISTD_H */
arch/c6x/kernel/sys_c6x.c new file +82 -0

82 lines not on this page · raw message

Signature · 1 line
1.7.6
#37 lore raw

PATCH v2 13/24 C6X: traps

In reply to Mark Salter

This patch provides the kernel entry points for traps, syscalls and interrupts.

---
 arch/c6x/include/asm/traps.h  |   39 ++
 arch/c6x/kernel/asm-offsets.c |  123 +++++++
 arch/c6x/kernel/entry.S       |  803 +++++++++++++++++++++++++++++++++++++++++
 arch/c6x/kernel/traps.c       |  423 ++++++++++++++++++++++
 4 files changed, 1388 insertions(+), 0 deletions(-)
 create mode 100644 arch/c6x/include/asm/traps.h
 create mode 100644 arch/c6x/kernel/asm-offsets.c
 create mode 100644 arch/c6x/kernel/entry.S
 create mode 100644 arch/c6x/kernel/traps.c
arch/c6x/include/asm/traps.h new file +39 -0
new file mode 100644
index 0000000..d7ff65d
@@ -0,0 +1,39 @@
+/*
+ *  Port on Texas Instruments TMS320C6x architecture
+ *
+ *  Copyright (C) 2004, 2009, 2011 Texas Instruments Incorporated
+ *  Author: Aurelien Jacquiot (aurelien.jacquiot at jaluna.com)
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ */
+#ifndef _ASM_C6X_TRAPS_H
+#define _ASM_C6X_TRAPS_H
+
+#ifdef CONFIG_TMS320C64XPLUS
+
+#define EXCEPT_TYPE_NXF   31	   /* NMI */
+#define EXCEPT_TYPE_EXC   30	   /* external exception */
+#define EXCEPT_TYPE_IXF   1	   /* internal exception */
+#define EXCEPT_TYPE_SXF   0	   /* software exception */
+
+#define EXCEPT_CAUSE_LBX  (1 << 7) /* loop buffer exception */
+#define EXCEPT_CAUSE_PRX  (1 << 6) /* privilege exception */
+#define EXCEPT_CAUSE_RAX  (1 << 5) /* resource access exception */
+#define EXCEPT_CAUSE_RCX  (1 << 4) /* resource conflict exception */
+#define EXCEPT_CAUSE_OPX  (1 << 3) /* opcode exception */
+#define EXCEPT_CAUSE_EPX  (1 << 2) /* execute packet exception */
+#define EXCEPT_CAUSE_FPX  (1 << 1) /* fetch packet exception */
+#define EXCEPT_CAUSE_IFX  (1 << 0) /* instruction fetch exception */
+
+struct exception_info {
+	char *kernel_str;
+	int  signo;
+	int  code;
+};
+
+extern int (*c6x_nmi_handler)(struct pt_regs *regs);
+
+#endif /* CONFIG_TMS320C64XPLUS */
+#endif /* _ASM_C6X_TRAPS_H */
arch/c6x/kernel/asm-offsets.c new file +123 -0

123 lines not on this page · raw message

arch/c6x/kernel/entry.S new file +803 -0

803 lines not on this page · raw message

arch/c6x/kernel/traps.c new file +423 -0

423 lines not on this page · raw message

Signature · 1 line
1.7.6
#38 lore raw

PATCH v2 14/24 C6X: clocks

In reply to Mark Salter

The C6X SoCs contain several PLL controllers each with up to 16 clock outputs feeding into the cores or peripheral clock domains. The hardware is very similar to arm/mach-davinci clocks. This is still a work in progress which needs to be updated once device tree clock binding changes shake out.

---
 arch/c6x/include/asm/clkdev.h |   22 ++
 arch/c6x/include/asm/clock.h  |  148 +++++++++++++
 arch/c6x/platforms/pll.c      |  471 +++++++++++++++++++++++++++++++++++++++++
 arch/c6x/platforms/plldata.c  |  151 +++++++++++++
 4 files changed, 792 insertions(+), 0 deletions(-)
 create mode 100644 arch/c6x/include/asm/clkdev.h
 create mode 100644 arch/c6x/include/asm/clock.h
 create mode 100644 arch/c6x/platforms/pll.c
 create mode 100644 arch/c6x/platforms/plldata.c
arch/c6x/include/asm/clkdev.h new file +22 -0
new file mode 100644
index 0000000..76a070b
@@ -0,0 +1,22 @@
+#ifndef _ASM_CLKDEV_H
+#define _ASM_CLKDEV_H
+
+#include <linux/slab.h>
+
+struct clk;
+
+static inline int __clk_get(struct clk *clk)
+{
+	return 1;
+}
+
+static inline void __clk_put(struct clk *clk)
+{
+}
+
+static inline struct clk_lookup_alloc *__clkdev_alloc(size_t size)
+{
+	return kzalloc(size, GFP_KERNEL);
+}
+
+#endif /* _ASM_CLKDEV_H */
arch/c6x/include/asm/clock.h new file +148 -0

148 lines not on this page · raw message

arch/c6x/platforms/pll.c new file +471 -0

471 lines not on this page · raw message

arch/c6x/platforms/plldata.c new file +151 -0

151 lines not on this page · raw message

Signature · 1 line
1.7.6
#39 lore raw

PATCH v2 15/24 C6X: cache control

In reply to Mark Salter
---
 arch/c6x/include/asm/cache.h      |   90 ++++++++
 arch/c6x/include/asm/cacheflush.h |   65 ++++++
 arch/c6x/platforms/cache.c        |  445 +++++++++++++++++++++++++++++++++++++
 3 files changed, 600 insertions(+), 0 deletions(-)
 create mode 100644 arch/c6x/include/asm/cache.h
 create mode 100644 arch/c6x/include/asm/cacheflush.h
 create mode 100644 arch/c6x/platforms/cache.c
arch/c6x/include/asm/cache.h new file +90 -0
new file mode 100644
index 0000000..6d521d9
@@ -0,0 +1,90 @@
+/*
+ *  Port on Texas Instruments TMS320C6x architecture
+ *
+ *  Copyright (C) 2005, 2006, 2009, 2010 Texas Instruments Incorporated
+ *  Author: Aurelien Jacquiot (aurelien.jacquiot at jaluna.com)
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ */
+#ifndef _ASM_C6X_CACHE_H
+#define _ASM_C6X_CACHE_H
+
+#include <linux/irqflags.h>
+
+/*
+ * Cache line size
+ */
+#define L1D_CACHE_BYTES   64
+#define L1P_CACHE_BYTES   32
+#define L2_CACHE_BYTES	  128
+
+/*
+ * L2 used as cache
+ */
+#define L2MODE_SIZE	  L2MODE_256K_CACHE
+
+/*
+ * For practical reasons the L1_CACHE_BYTES defines should not be smaller than
+ * the L2 line size
+ */
+#define L1_CACHE_BYTES        L2_CACHE_BYTES
+
+#define L2_CACHE_ALIGN_LOW(x) \
+	(((x) & ~(L2_CACHE_BYTES - 1)))
+#define L2_CACHE_ALIGN_UP(x) \
+	(((x) + (L2_CACHE_BYTES - 1)) & ~(L2_CACHE_BYTES - 1))
+#define L2_CACHE_ALIGN_CNT(x) \
+	(((x) + (sizeof(int) - 1)) & ~(sizeof(int) - 1))
+
+#define ARCH_DMA_MINALIGN	L1_CACHE_BYTES
+#define ARCH_SLAB_MINALIGN	L1_CACHE_BYTES
+
+/*
+ * This is the granularity of hardware cacheability control.
+ */
+#define CACHEABILITY_ALIGN	0x01000000
+
+/*
+ * Align a physical address to MAR regions
+ */
+#define CACHE_REGION_START(v) \
+	(((u32) (v)) & ~(CACHEABILITY_ALIGN - 1))
+#define CACHE_REGION_END(v) \
+	(((u32) (v) + (CACHEABILITY_ALIGN - 1)) & ~(CACHEABILITY_ALIGN - 1))
+
+extern void __init c6x_cache_init(void);
+
+extern void enable_caching(unsigned long start, unsigned long end);
+extern void disable_caching(unsigned long start, unsigned long end);
+
+extern void L1_cache_off(void);
+extern void L1_cache_on(void);
+
+extern void L1P_cache_global_invalidate(void);
+extern void L1D_cache_global_invalidate(void);
+extern void L1D_cache_global_writeback(void);
+extern void L1D_cache_global_writeback_invalidate(void);
+extern void L2_cache_set_mode(unsigned int mode);
+extern void L2_cache_global_writeback_invalidate(void);
+extern void L2_cache_global_writeback(void);
+
+extern void L1P_cache_block_invalidate(unsigned int start, unsigned int end);
+extern void L1D_cache_block_invalidate(unsigned int start, unsigned int end);
+extern void L1D_cache_block_writeback_invalidate(unsigned int start,
+						 unsigned int end);
+extern void L1D_cache_block_writeback(unsigned int start, unsigned int end);
+extern void L2_cache_block_invalidate(unsigned int start, unsigned int end);
+extern void L2_cache_block_writeback(unsigned int start, unsigned int end);
+extern void L2_cache_block_writeback_invalidate(unsigned int start,
+						unsigned int end);
+extern void L2_cache_block_invalidate_nowait(unsigned int start,
+					     unsigned int end);
+extern void L2_cache_block_writeback_nowait(unsigned int start,
+					    unsigned int end);
+
+extern void L2_cache_block_writeback_invalidate_nowait(unsigned int start,
+						       unsigned int end);
+
+#endif /* _ASM_C6X_CACHE_H */
arch/c6x/include/asm/cacheflush.h new file +65 -0

65 lines not on this page · raw message

arch/c6x/platforms/cache.c new file +445 -0

445 lines not on this page · raw message

Signature · 1 line
1.7.6
#40 lore raw

PATCH v2 16/24 C6X: loadable module support

In reply to Mark Salter
---
 arch/c6x/include/asm/module.h |   33 +++++++
 arch/c6x/kernel/c6x_ksyms.c   |   68 ++++++++++++++
 arch/c6x/kernel/module.c      |  196 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 297 insertions(+), 0 deletions(-)
 create mode 100644 arch/c6x/include/asm/module.h
 create mode 100644 arch/c6x/kernel/c6x_ksyms.c
 create mode 100644 arch/c6x/kernel/module.c
arch/c6x/include/asm/module.h new file +33 -0
new file mode 100644
index 0000000..a453f97
@@ -0,0 +1,33 @@
+/*
+ *  Port on Texas Instruments TMS320C6x architecture
+ *
+ *  Copyright (C) 2004, 2009, 2010 Texas Instruments Incorporated
+ *  Author: Aurelien Jacquiot (aurelien.jacquiot at jaluna.com)
+ *
+ *  Updated for 2.6.34 by: Mark Salter (msalter at redhat.com)
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ */
+#ifndef _ASM_C6X_MODULE_H
+#define _ASM_C6X_MODULE_H
+
+#define Elf_Shdr	Elf32_Shdr
+#define Elf_Sym		Elf32_Sym
+#define Elf_Ehdr	Elf32_Ehdr
+#define Elf_Addr	Elf32_Addr
+#define Elf_Word	Elf32_Word
+
+/*
+ * This file contains the C6x architecture specific module code.
+ */
+struct mod_arch_specific {
+};
+
+struct loaded_sections {
+	unsigned int new_vaddr;
+	unsigned int loaded;
+};
+
+#endif /* _ASM_C6X_MODULE_H */
arch/c6x/kernel/c6x_ksyms.c new file +68 -0

68 lines not on this page · raw message

arch/c6x/kernel/module.c new file +196 -0

196 lines not on this page · raw message

Signature · 1 line
1.7.6
#41 lore raw

PATCH v2 17/24 C6X: ptrace support

In reply to Mark Salter
---
 arch/c6x/include/asm/ptrace.h |  181 +++++++++++++++++++++++++++++++++++
 arch/c6x/kernel/ptrace.c      |  207 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 388 insertions(+), 0 deletions(-)
 create mode 100644 arch/c6x/include/asm/ptrace.h
 create mode 100644 arch/c6x/kernel/ptrace.c
arch/c6x/include/asm/ptrace.h new file +181 -0
new file mode 100644
index 0000000..347f2ed
@@ -0,0 +1,181 @@
+/*
+ *  Copyright (C) 2004, 2006, 2009, 2010 Texas Instruments Incorporated
+ *  Author: Aurelien Jacquiot (aurelien.jacquiot at jaluna.com)
+ *
+ *  Updated for 2.6.34: Mark Salter <[email protected]>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ */
+#ifndef _ASM_C6X_PTRACE_H
+#define _ASM_C6X_PTRACE_H
+
+#if defined(__TMS320C6XPLUS__) || defined(_TMS320C6400_PLUS)
+#define BKPT_OPCODE	   0x56454314	    /* illegal opcode */
+#else
+#define BKPT_OPCODE	   0x0000a122	    /* BNOP .S2 0,5 */
+#endif
+
+#ifdef _BIG_ENDIAN
+#define PT_LO(odd, even)  odd
+#define PT_HI(odd, even)  even
+#else
+#define PT_LO(odd, even)  even
+#define PT_HI(odd, even)  odd
+#endif
+
+#define PT_A4_ORG  PT_LO(1, 0)
+#define PT_TSR	   PT_HI(1, 0)
+#define PT_ILC	   PT_LO(3, 2)
+#define PT_RILC    PT_HI(3, 2)
+#define PT_CSR	   PT_LO(5, 4)
+#define PT_PC	   PT_HI(5, 4)
+#define PT_B16	   PT_LO(7, 6)
+#define PT_B17	   PT_HI(7, 6)
+#define PT_B18	   PT_LO(9, 8)
+#define PT_B19	   PT_HI(9, 8)
+#define PT_B20	   PT_LO(11, 10)
+#define PT_B21	   PT_HI(11, 10)
+#define PT_B22	   PT_LO(13, 12)
+#define PT_B23	   PT_HI(13, 12)
+#define PT_B24	   PT_LO(15, 14)
+#define PT_B25	   PT_HI(15, 14)
+#define PT_B26	   PT_LO(17, 16)
+#define PT_B27	   PT_HI(17, 16)
+#define PT_B28	   PT_LO(19, 18)
+#define PT_B29	   PT_HI(19, 18)
+#define PT_B30	   PT_LO(21, 20)
+#define PT_B31	   PT_HI(21, 20)
+#define PT_B0	   PT_LO(23, 22)
+#define PT_B1	   PT_HI(23, 22)
+#define PT_B2	   PT_LO(25, 24)
+#define PT_B3	   PT_HI(25, 24)
+#define PT_B4	   PT_LO(27, 26)
+#define PT_B5	   PT_HI(27, 26)
+#define PT_B6	   PT_LO(29, 28)
+#define PT_B7	   PT_HI(29, 28)
+#define PT_B8	   PT_LO(31, 30)
+#define PT_B9	   PT_HI(31, 30)
+#define PT_B10	   PT_LO(33, 32)
+#define PT_B11	   PT_HI(33, 32)
+#define PT_B12	   PT_LO(35, 34)
+#define PT_B13	   PT_HI(35, 34)
+#define PT_A16	   PT_LO(37, 36)
+#define PT_A17	   PT_HI(37, 36)
+#define PT_A18	   PT_LO(39, 38)
+#define PT_A19	   PT_HI(39, 38)
+#define PT_A20	   PT_LO(41, 40)
+#define PT_A21	   PT_HI(41, 40)
+#define PT_A22	   PT_LO(43, 42)
+#define PT_A23	   PT_HI(43, 42)
+#define PT_A24	   PT_LO(45, 44)
+#define PT_A25	   PT_HI(45, 44)
+#define PT_A26	   PT_LO(47, 46)
+#define PT_A27	   PT_HI(47, 46)
+#define PT_A28	   PT_LO(49, 48)
+#define PT_A29	   PT_HI(49, 48)
+#define PT_A30	   PT_LO(51, 50)
+#define PT_A31	   PT_HI(51, 50)
+#define PT_A0	   PT_LO(53, 52)
+#define PT_A1	   PT_HI(53, 52)
+#define PT_A2	   PT_LO(55, 54)
+#define PT_A3	   PT_HI(55, 54)
+#define PT_A4	   PT_LO(57, 56)
+#define PT_A5	   PT_HI(57, 56)
+#define PT_A6	   PT_LO(59, 58)
+#define PT_A7	   PT_HI(59, 58)
+#define PT_A8	   PT_LO(61, 60)
+#define PT_A9	   PT_HI(61, 60)
+#define PT_A10	   PT_LO(63, 62)
+#define PT_A11	   PT_HI(63, 62)
+#define PT_A12	   PT_LO(65, 64)
+#define PT_A13	   PT_HI(65, 64)
+#define PT_A14	   PT_LO(67, 66)
+#define PT_A15	   PT_HI(67, 66)
+#define PT_B14	   PT_LO(69, 68)
+#define PT_B15	   PT_HI(69, 68)
+
+#define NR_PTREGS  70
+
+#define PT_DP	   PT_B14  /* Data Segment Pointer (B14) */
+#define PT_SP	   PT_B15  /* Stack Pointer (B15)  */
+
+#ifndef __ASSEMBLY__
+
+#ifdef _BIG_ENDIAN
+#define REG_PAIR(odd, even) unsigned long odd; unsigned long even
+#else
+#define REG_PAIR(odd, even) unsigned long even; unsigned long odd
+#endif
+
+/*
+ * this struct defines the way the registers are stored on the
+ * stack during a system call. fields defined with REG_PAIR
+ * are saved and restored using double-word memory operations
+ * which means the word ordering of the pair depends on endianess.
+ */
+struct pt_regs {
+	REG_PAIR(tsr, orig_a4);
+	REG_PAIR(rilc, ilc);
+	REG_PAIR(pc, csr);
+
+	REG_PAIR(b17, b16);
+	REG_PAIR(b19, b18);
+	REG_PAIR(b21, b20);
+	REG_PAIR(b23, b22);
+	REG_PAIR(b25, b24);
+	REG_PAIR(b27, b26);
+	REG_PAIR(b29, b28);
+	REG_PAIR(b31, b30);
+
+	REG_PAIR(b1, b0);
+	REG_PAIR(b3, b2);
+	REG_PAIR(b5, b4);
+	REG_PAIR(b7, b6);
+	REG_PAIR(b9, b8);
+	REG_PAIR(b11, b10);
+	REG_PAIR(b13, b12);
+
+	REG_PAIR(a17, a16);
+	REG_PAIR(a19, a18);
+	REG_PAIR(a21, a20);
+	REG_PAIR(a23, a22);
+	REG_PAIR(a25, a24);
+	REG_PAIR(a27, a26);
+	REG_PAIR(a29, a28);
+	REG_PAIR(a31, a30);
+
+	REG_PAIR(a1, a0);
+	REG_PAIR(a3, a2);
+	REG_PAIR(a5, a4);
+	REG_PAIR(a7, a6);
+	REG_PAIR(a9, a8);
+	REG_PAIR(a11, a10);
+	REG_PAIR(a13, a12);
+
+	REG_PAIR(a15, a14);
+	REG_PAIR(sp, dp);
+};
+
+#define PTRACE_GETREGS		  12
+#define PTRACE_SETREGS		  13
+#define PTRACE_GETFPREGS	  14
+#define PTRACE_SETFPREGS	  15
+
+#ifdef __KERNEL__
+
+#include <linux/linkage.h>
+
+#define user_mode(regs)	((((regs)->tsr) & 0x40) != 0)
+
+#define instruction_pointer(regs) ((regs)->pc)
+#define profile_pc(regs) instruction_pointer(regs)
+extern void show_regs(struct pt_regs *);
+
+extern asmlinkage unsigned long syscall_trace_entry(struct pt_regs *regs);
+extern asmlinkage void syscall_trace_exit(struct pt_regs *regs);
+
+#endif /* __KERNEL__ */
+#endif /* __ASSEMBLY__ */
+#endif /* _ASM_C6X_PTRACE_H */
arch/c6x/kernel/ptrace.c new file +207 -0

207 lines not on this page · raw message

Signature · 1 line
1.7.6
#42 lore raw

PATCH v2 18/24 C6X: headers

In reply to Mark Salter
---
 arch/c6x/include/asm/asm-offsets.h |    1 +
 arch/c6x/include/asm/bitops.h      |  105 +++++++++++++
 arch/c6x/include/asm/byteorder.h   |   12 ++
 arch/c6x/include/asm/delay.h       |   67 +++++++++
 arch/c6x/include/asm/elf.h         |  113 ++++++++++++++
 arch/c6x/include/asm/ftrace.h      |    6 +
 arch/c6x/include/asm/linkage.h     |   30 ++++
 arch/c6x/include/asm/memblock.h    |    4 +
 arch/c6x/include/asm/mmu.h         |   18 +++
 arch/c6x/include/asm/mutex.h       |    6 +
 arch/c6x/include/asm/page.h        |   11 ++
 arch/c6x/include/asm/pgtable.h     |   81 ++++++++++
 arch/c6x/include/asm/procinfo.h    |   28 ++++
 arch/c6x/include/asm/prom.h        |    1 +
 arch/c6x/include/asm/sections.h    |   12 ++
 arch/c6x/include/asm/setup.h       |   29 ++++
 arch/c6x/include/asm/string.h      |   21 +++
 arch/c6x/include/asm/system.h      |  197 ++++++++++++++++++++++++
 arch/c6x/include/asm/tlb.h         |    8 +
 arch/c6x/include/asm/uaccess.h     |  107 +++++++++++++
 arch/c6x/include/asm/unaligned.h   |  288 ++++++++++++++++++++++++++++++++++++
 21 files changed, 1145 insertions(+), 0 deletions(-)
 create mode 100644 arch/c6x/include/asm/asm-offsets.h
 create mode 100644 arch/c6x/include/asm/bitops.h
 create mode 100644 arch/c6x/include/asm/byteorder.h
 create mode 100644 arch/c6x/include/asm/delay.h
 create mode 100644 arch/c6x/include/asm/elf.h
 create mode 100644 arch/c6x/include/asm/ftrace.h
 create mode 100644 arch/c6x/include/asm/linkage.h
 create mode 100644 arch/c6x/include/asm/memblock.h
 create mode 100644 arch/c6x/include/asm/mmu.h
 create mode 100644 arch/c6x/include/asm/mutex.h
 create mode 100644 arch/c6x/include/asm/page.h
 create mode 100644 arch/c6x/include/asm/pgtable.h
 create mode 100644 arch/c6x/include/asm/procinfo.h
 create mode 100644 arch/c6x/include/asm/prom.h
 create mode 100644 arch/c6x/include/asm/sections.h
 create mode 100644 arch/c6x/include/asm/setup.h
 create mode 100644 arch/c6x/include/asm/string.h
 create mode 100644 arch/c6x/include/asm/system.h
 create mode 100644 arch/c6x/include/asm/tlb.h
 create mode 100644 arch/c6x/include/asm/uaccess.h
 create mode 100644 arch/c6x/include/asm/unaligned.h
arch/c6x/include/asm/asm-offsets.h new file +1 -0
new file mode 100644
index 0000000..d370ee3
@@ -0,0 +1 @@
+#include <generated/asm-offsets.h>
arch/c6x/include/asm/bitops.h new file +105 -0

105 lines not on this page · raw message

arch/c6x/include/asm/byteorder.h new file +12 -0
new file mode 100644
index 0000000..166038d
@@ -0,0 +1,12 @@
+#ifndef _ASM_C6X_BYTEORDER_H
+#define _ASM_C6X_BYTEORDER_H
+
+#include <asm/types.h>
+
+#ifdef _BIG_ENDIAN
+#include <linux/byteorder/big_endian.h>
+#else /* _BIG_ENDIAN */
+#include <linux/byteorder/little_endian.h>
+#endif /* _BIG_ENDIAN */
+
+#endif /* _ASM_BYTEORDER_H */
arch/c6x/include/asm/delay.h new file +67 -0

67 lines not on this page · raw message

arch/c6x/include/asm/elf.h new file +113 -0

113 lines not on this page · raw message

arch/c6x/include/asm/ftrace.h new file +6 -0
new file mode 100644
index 0000000..3701958
@@ -0,0 +1,6 @@
+#ifndef _ASM_C6X_FTRACE_H
+#define _ASM_C6X_FTRACE_H
+
+/* empty */
+
+#endif /* _ASM_C6X_FTRACE_H */
arch/c6x/include/asm/linkage.h new file +30 -0
new file mode 100644
index 0000000..376925c
@@ -0,0 +1,30 @@
+#ifndef _ASM_C6X_LINKAGE_H
+#define _ASM_C6X_LINKAGE_H
+
+#ifdef __ASSEMBLER__
+
+#define __ALIGN		.align 2
+#define __ALIGN_STR	".align 2"
+
+#ifndef __DSBT__
+#define ENTRY(name)		\
+	.global name @		\
+	__ALIGN @		\
+name:
+#else
+#define ENTRY(name)		\
+	.global name @		\
+	.hidden name @		\
+	__ALIGN @		\
+name:
+#endif
+
+#define ENDPROC(name)		\
+	.type name, @function @	\
+	.size name, . - name
+
+#endif
+
+#include <asm-generic/linkage.h>
+
+#endif /* _ASM_C6X_LINKAGE_H */
arch/c6x/include/asm/memblock.h new file +4 -0
new file mode 100644
index 0000000..1181a97
@@ -0,0 +1,4 @@
+#ifndef _ASM_C6X_MEMBLOCK_H
+#define _ASM_C6X_MEMBLOCK_H
+
+#endif /* _ASM_C6X_MEMBLOCK_H */
arch/c6x/include/asm/mmu.h new file +18 -0
new file mode 100644
index 0000000..41592bf
@@ -0,0 +1,18 @@
+/*
+ *  Port on Texas Instruments TMS320C6x architecture
+ *
+ *  Copyright (C) 2004, 2009, 2010 Texas Instruments Incorporated
+ *  Author: Aurelien Jacquiot (aurelien.jacquiot at jaluna.com)
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ */
+#ifndef _ASM_C6X_MMU_H
+#define _ASM_C6X_MMU_H
+
+typedef struct {
+	unsigned long		end_brk;
+} mm_context_t;
+
+#endif /* _ASM_C6X_MMU_H */
arch/c6x/include/asm/mutex.h new file +6 -0
new file mode 100644
index 0000000..7a7248e
@@ -0,0 +1,6 @@
+#ifndef _ASM_C6X_MUTEX_H
+#define _ASM_C6X_MUTEX_H
+
+#include <asm-generic/mutex-null.h>
+
+#endif /* _ASM_C6X_MUTEX_H */
arch/c6x/include/asm/page.h new file +11 -0
new file mode 100644
index 0000000..d18e2b0
@@ -0,0 +1,11 @@
+#ifndef _ASM_C6X_PAGE_H
+#define _ASM_C6X_PAGE_H
+
+#define VM_DATA_DEFAULT_FLAGS \
+	(VM_READ | VM_WRITE | \
+	((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
+		 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
+
+#include <asm-generic/page.h>
+
+#endif /* _ASM_C6X_PAGE_H */
arch/c6x/include/asm/pgtable.h new file +81 -0

81 lines not on this page · raw message

arch/c6x/include/asm/procinfo.h new file +28 -0
new file mode 100644
index 0000000..c139d1e
@@ -0,0 +1,28 @@
+/*
+ *  Copyright (C) 2010 Texas Instruments Incorporated
+ *  Author: Mark Salter (msalter at redhat.com)
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#ifndef _ASM_C6X_PROCINFO_H
+#define _ASM_C6X_PROCINFO_H
+
+#ifdef __KERNEL__
+
+struct proc_info_list {
+	unsigned int		cpu_val;
+	unsigned int		cpu_mask;
+	const char		*arch_name;
+	const char		*elf_name;
+	unsigned int		elf_hwcap;
+};
+
+#else	/* __KERNEL__ */
+#include <asm/elf.h>
+#warning "Please include asm/elf.h instead"
+#endif	/* __KERNEL__ */
+
+#endif	/* _ASM_C6X_PROCINFO_H */
arch/c6x/include/asm/prom.h new file +1 -0
new file mode 100644
index 0000000..b4ec95f
@@ -0,0 +1 @@
+/* dummy prom.h; here to make linux/of.h's #includes happy */
arch/c6x/include/asm/sections.h new file +12 -0
new file mode 100644
index 0000000..f703989
@@ -0,0 +1,12 @@
+#ifndef _ASM_C6X_SECTIONS_H
+#define _ASM_C6X_SECTIONS_H
+
+#include <asm-generic/sections.h>
+
+extern char _vectors_start[];
+extern char _vectors_end[];
+
+extern char _data_lma[];
+extern char _fdt_start[], _fdt_end[];
+
+#endif /* _ASM_C6X_SECTIONS_H */
arch/c6x/include/asm/setup.h new file +29 -0
new file mode 100644
index 0000000..ee3188d
@@ -0,0 +1,29 @@
+/*
+ *  Port on Texas Instruments TMS320C6x architecture
+ *
+ *  Copyright (C) 2004, 2009, 2010 2011 Texas Instruments Incorporated
+ *  Author: Aurelien Jacquiot (aurelien.jacquiot at jaluna.com)
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ */
+#ifndef _ASM_C6X_SETUP_H
+#define _ASM_C6X_SETUP_H
+
+#define COMMAND_LINE_SIZE   1024
+
+#ifndef __ASSEMBLY__
+extern char c6x_command_line[COMMAND_LINE_SIZE];
+
+extern int c6x_add_memory(phys_addr_t start, unsigned long size);
+
+extern unsigned long ram_start;
+extern unsigned long ram_end;
+
+extern int c6x_num_cores;
+
+extern void machine_init(unsigned long dt_ptr);
+
+#endif /* !__ASSEMBLY__ */
+#endif /* _ASM_C6X_SETUP_H */
arch/c6x/include/asm/string.h new file +21 -0
new file mode 100644
index 0000000..b21517c
@@ -0,0 +1,21 @@
+/*
+ *  Port on Texas Instruments TMS320C6x architecture
+ *
+ *  Copyright (C) 2004, 2009, 2011 Texas Instruments Incorporated
+ *  Author: Aurelien Jacquiot (aurelien.jacquiot at jaluna.com)
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ */
+#ifndef _ASM_C6X_STRING_H
+#define _ASM_C6X_STRING_H
+
+#include <asm/page.h>
+#include <linux/linkage.h>
+
+asmlinkage extern void *memcpy(void *to, const void *from, size_t n);
+
+#define __HAVE_ARCH_MEMCPY
+
+#endif /* _ASM_C6X_STRING_H */
arch/c6x/include/asm/system.h new file +197 -0

197 lines not on this page · raw message

arch/c6x/include/asm/tlb.h new file +8 -0
new file mode 100644
index 0000000..8709e5e
@@ -0,0 +1,8 @@
+#ifndef _ASM_C6X_TLB_H
+#define _ASM_C6X_TLB_H
+
+#define tlb_flush(tlb) flush_tlb_mm((tlb)->mm)
+
+#include <asm-generic/tlb.h>
+
+#endif /* _ASM_C6X_TLB_H */
arch/c6x/include/asm/uaccess.h new file +107 -0

107 lines not on this page · raw message

arch/c6x/include/asm/unaligned.h new file +288 -0

288 lines not on this page · raw message

Signature · 1 line
1.7.6
#43 lore raw

PATCH v2 19/24 C6X: library code

In reply to Mark Salter

The C6X library code contains an optimized memcpy, optimized csum, and various libgcc support routines.

---
 arch/c6x/include/asm/checksum.h |  115 +++++++++++
 arch/c6x/lib/csum_64plus.S      |  404 +++++++++++++++++++++++++++++++++++++++
 arch/c6x/lib/divi.S             |   53 +++++
 arch/c6x/lib/divremi.S          |   46 +++++
 arch/c6x/lib/divremu.S          |   87 +++++++++
 arch/c6x/lib/divu.S             |   98 ++++++++++
 arch/c6x/lib/llshl.S            |   37 ++++
 arch/c6x/lib/llshr.S            |   38 ++++
 arch/c6x/lib/llshru.S           |   38 ++++
 arch/c6x/lib/memcpy_64plus.S    |   46 +++++
 arch/c6x/lib/mpyll.S            |   49 +++++
 arch/c6x/lib/negll.S            |   31 +++
 arch/c6x/lib/pop_rts.S          |   32 +++
 arch/c6x/lib/push_rts.S         |   31 +++
 arch/c6x/lib/remi.S             |   64 ++++++
 arch/c6x/lib/remu.S             |   82 ++++++++
 arch/c6x/lib/strasgi.S          |   89 +++++++++
 arch/c6x/lib/strasgi_64plus.S   |   39 ++++
 18 files changed, 1379 insertions(+), 0 deletions(-)
 create mode 100644 arch/c6x/include/asm/checksum.h
 create mode 100644 arch/c6x/lib/csum_64plus.S
 create mode 100644 arch/c6x/lib/divi.S
 create mode 100644 arch/c6x/lib/divremi.S
 create mode 100644 arch/c6x/lib/divremu.S
 create mode 100644 arch/c6x/lib/divu.S
 create mode 100644 arch/c6x/lib/llshl.S
 create mode 100644 arch/c6x/lib/llshr.S
 create mode 100644 arch/c6x/lib/llshru.S
 create mode 100644 arch/c6x/lib/memcpy_64plus.S
 create mode 100644 arch/c6x/lib/mpyll.S
 create mode 100644 arch/c6x/lib/negll.S
 create mode 100644 arch/c6x/lib/pop_rts.S
 create mode 100644 arch/c6x/lib/push_rts.S
 create mode 100644 arch/c6x/lib/remi.S
 create mode 100644 arch/c6x/lib/remu.S
 create mode 100644 arch/c6x/lib/strasgi.S
 create mode 100644 arch/c6x/lib/strasgi_64plus.S
arch/c6x/include/asm/checksum.h new file +115 -0
new file mode 100644
index 0000000..9bb2845
@@ -0,0 +1,115 @@
+/*
+ *  Port on Texas Instruments TMS320C6x architecture
+ *
+ *  Copyright (C) 2004, 2009, 2010 Texas Instruments Incorporated
+ *  Author: Aurelien Jacquiot (aurelien.jacquiot at jaluna.com)
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ */
+#ifndef _ASM_C6X_CHECKSUM_H
+#define _ASM_C6X_CHECKSUM_H
+
+#include <asm/byteorder.h>
+
+/*
+ * Computes the checksum of a memory block at buff, length len,
+ * and adds in "sum" (32-bit)
+ *
+ * returns a 32-bit number suitable for feeding into itself
+ * or csum_tcpudp_magic
+ *
+ * this function must be called with even lengths, except
+ * for the last fragment, which may be odd
+ *
+ * it's best to have buff aligned on a 32-bit boundary
+ */
+extern __wsum csum_partial(const void *buff, int len, __wsum sum);
+
+/*
+ * The same as csum_partial, but copies from src while it checksums
+ *
+ * here even more important to align src and dst on a 32-bit (or even
+ * better 64-bit) boundary
+ */
+extern __wsum csum_partial_copy(const void *src, void *dst,
+				int len, __wsum sum);
+
+/*
+ * This is a new version of the above that records errors it finds in *errp,
+ * but continues and zeros the rest of the buffer.
+ */
+#define csum_partial_copy_nocheck csum_partial_copy
+
+/*
+ * The same as csum_partial_copy, but copies from user space.
+ *
+ * here even more important to align src and dst on a 32-bit (or even
+ * better 64-bit) boundary
+ */
+#define csum_partial_copy_from_user(src, dst, len, sum, err_ptr) \
+	csum_partial_copy(src, dst, len, sum)
+
+/*
+ * This is a version of ip_compute_csum() optimized for IP headers,
+ * which always checksum on 4 octet boundaries.
+ *
+ */
+extern __sum16 ip_fast_csum(const void *iph, unsigned int ihl);
+
+/*
+ * Fold a partial checksum
+ */
+static inline __sum16 csum_fold(__wsum csum)
+{
+	u32 sum = (u32)csum;
+	sum = (sum & 0xffff) + (sum >> 16);
+	sum = (sum & 0xffff) + (sum >> 16);
+	return (__sum16)~sum;
+}
+
+/*
+ * Computes the checksum of the TCP/UDP pseudo-header
+ */
+static inline __wsum
+csum_tcpudp_nofold(__be32 saddr, __be32 daddr, unsigned short len,
+		  unsigned short proto, __wsum sum)
+{
+	unsigned long long s = (__force u32)sum;
+
+	s += (__force u32)saddr;
+	s += (__force u32)daddr;
+#ifdef _BIG_ENDIAN
+	s += proto + len;
+#else
+	s += (proto + len) << 8;
+#endif
+	s += (s >> 32);
+
+	return (__force __wsum)s;
+}
+
+/*
+ * Computes the checksum of the TCP/UDP pseudo-header
+ * returns a 16-bit checksum, already complemented
+ */
+static inline __sum16
+csum_tcpudp_magic(__be32 saddr, __be32 daddr, unsigned short len,
+		  unsigned short proto, __wsum sum)
+{
+	return csum_fold(csum_tcpudp_nofold(saddr, daddr, len, proto, sum));
+}
+
+/*
+ * This routine is used for miscellaneous IP-like checksums, mainly
+ * in icmp.c
+ */
+static inline __sum16
+ip_compute_csum(const void *buff, int len)
+{
+	extern unsigned int do_csum(const unsigned char *, size_t);
+	return (__force __sum16)~do_csum(buff, len);
+}
+
+#endif /* _ASM_C6X_CHECKSUM_H */
arch/c6x/lib/csum_64plus.S new file +404 -0

404 lines not on this page · raw message

arch/c6x/lib/divi.S new file +53 -0

53 lines not on this page · raw message

arch/c6x/lib/divremi.S new file +46 -0

46 lines not on this page · raw message

arch/c6x/lib/divremu.S new file +87 -0

87 lines not on this page · raw message

arch/c6x/lib/divu.S new file +98 -0

98 lines not on this page · raw message

arch/c6x/lib/llshl.S new file +37 -0
new file mode 100644
index 0000000..7b105e2
@@ -0,0 +1,37 @@
+;;  Copyright (C) 2010 Texas Instruments Incorporated
+;;  Contributed by Mark Salter <[email protected]>.
+;;
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2 of the License, or
+;; (at your option) any later version.
+;;
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with this program; if not, write to the Free Software
+;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+;;  uint64_t __c6xabi_llshl(uint64_t val, uint shift)
+
+#include <linux/linkage.h>
+
+	.text
+ENTRY(__c6xabi_llshl)
+	 mv	.l1x	B4,A1
+   [!A1] b	.s2	B3		; just return if zero shift
+	 mvk	.s1	32,A0
+	 sub	.d1	A0,A1,A0
+	 cmplt	.l1	0,A0,A2
+   [A2]	 shru	.s1	A4,A0,A0
+   [!A2] neg	.l1	A0,A5
+|| [A2]  shl	.s1	A5,A1,A5
+   [!A2] shl	.s1	A4,A5,A5
+|| [A2]  or	.d1	A5,A0,A5
+|| [!A2] mvk	.l1	0,A4
+   [A2]	 shl	.s1	A4,A1,A4
+	 bnop	.s2	B3,5
+ENDPROC(__c6xabi_llshl)
arch/c6x/lib/llshr.S new file +38 -0
new file mode 100644
index 0000000..fde1bec
@@ -0,0 +1,38 @@
+;;  Copyright (C) 2010 Texas Instruments Incorporated
+;;  Contributed by Mark Salter <[email protected]>.
+;;
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2 of the License, or
+;; (at your option) any later version.
+;;
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with this program; if not, write to the Free Software
+;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+;;  uint64_t __c6xabi_llshr(uint64_t val, uint shift)
+
+#include <linux/linkage.h>
+
+	.text
+ENTRY(__c6xabi_llshr)
+	 mv	.l1x	B4,A1
+   [!A1] b	.s2	B3		; return if zero shift count
+	 mvk	.s1	32,A0
+	 sub	.d1	A0,A1,A0
+	 cmplt	.l1	0,A0,A2
+   [A2]  shl	.s1	A5,A0,A0
+	 nop
+   [!A2] neg	.l1	A0,A4
+|| [A2]  shru	.s1	A4,A1,A4
+   [!A2] shr	.s1	A5,A4,A4
+|| [A2]  or	.d1	A4,A0,A4
+   [!A2] shr	.s1	A5,0x1f,A5
+   [A2]  shr	.s1	A5,A1,A5
+	 bnop	.s2	B3,5
+ENDPROC(__c6xabi_llshr)
arch/c6x/lib/llshru.S new file +38 -0
new file mode 100644
index 0000000..596ae3f
@@ -0,0 +1,38 @@
+;;  Copyright (C) 2010 Texas Instruments Incorporated
+;;  Contributed by Mark Salter <[email protected]>.
+;;
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2 of the License, or
+;; (at your option) any later version.
+;;
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with this program; if not, write to the Free Software
+;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+;;  uint64_t __c6xabi_llshru(uint64_t val, uint shift)
+
+#include <linux/linkage.h>
+
+	.text
+ENTRY(__c6xabi_llshru)
+	 mv	.l1x	B4,A1
+   [!A1] b	.s2	B3		; return if zero shift count
+	 mvk	.s1	32,A0
+	 sub	.d1	A0,A1,A0
+	 cmplt	.l1	0,A0,A2
+   [A2]  shl	.s1	A5,A0,A0
+	 nop
+   [!A2] neg	.l1	A0,A4
+|| [A2]  shru	.s1	A4,A1,A4
+   [!A2] shru	.s1	A5,A4,A4
+|| [A2]  or	.d1	A4,A0,A4
+|| [!A2] mvk	.l1	0,A5
+   [A2]  shru	.s1	A5,A1,A5
+	 bnop	.s2	B3,5
+ENDPROC(__c6xabi_llshru)
arch/c6x/lib/memcpy_64plus.S new file +46 -0

46 lines not on this page · raw message

arch/c6x/lib/mpyll.S new file +49 -0

49 lines not on this page · raw message

arch/c6x/lib/negll.S new file +31 -0
new file mode 100644
index 0000000..82f4bce
@@ -0,0 +1,31 @@
+;;  Copyright (C) 2010 Texas Instruments Incorporated
+;;  Contributed by Mark Salter <[email protected]>.
+;;
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2 of the License, or
+;; (at your option) any later version.
+;;
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with this program; if not, write to the Free Software
+;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+;;  int64_t __c6xabi_negll(int64_t val)
+
+#include <linux/linkage.h>
+
+	.text
+ENTRY(__c6xabi_negll)
+	b	.s2	B3
+	mvk	.l1	0,A0
+	subu	.l1	A0,A4,A3:A2
+	sub	.l1	A0,A5,A0
+||	ext	.s1	A3,24,24,A5
+	add	.l1	A5,A0,A5
+	mv	.s1	A2,A4
+ENDPROC(__c6xabi_negll)
arch/c6x/lib/pop_rts.S new file +32 -0
new file mode 100644
index 0000000..d7d96c7
@@ -0,0 +1,32 @@
+;;  Copyright 2010  Free Software Foundation, Inc.
+;;  Contributed by Bernd Schmidt <[email protected]>.
+;;
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2 of the License, or
+;; (at your option) any later version.
+;;
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with this program; if not, write to the Free Software
+;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#include <linux/linkage.h>
+
+	.text
+
+ENTRY(__c6xabi_pop_rts)
+	lddw	.d2t2	*++B15, B3:B2
+	lddw	.d2t1	*++B15, A11:A10
+	lddw	.d2t2	*++B15, B11:B10
+	lddw	.d2t1	*++B15, A13:A12
+	lddw	.d2t2	*++B15, B13:B12
+	lddw	.d2t1	*++B15, A15:A14
+||	b	.s2	B3
+	ldw	.d2t2	*++B15[2], B14
+	nop	4
+ENDPROC(__c6xabi_pop_rts)
arch/c6x/lib/push_rts.S new file +31 -0
new file mode 100644
index 0000000..f6e3db3
@@ -0,0 +1,31 @@
+;;  Copyright 2010  Free Software Foundation, Inc.
+;;  Contributed by Bernd Schmidt <[email protected]>.
+;;
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2 of the License, or
+;; (at your option) any later version.
+;;
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with this program; if not, write to the Free Software
+;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#include <linux/linkage.h>
+
+	.text
+
+ENTRY(__c6xabi_push_rts)
+	stw	.d2t2	B14, *B15--[2]
+	stdw	.d2t1	A15:A14, *B15--
+||	b	.s2x	A3
+	stdw	.d2t2	B13:B12, *B15--
+	stdw	.d2t1	A13:A12, *B15--
+	stdw	.d2t2	B11:B10, *B15--
+	stdw	.d2t1	A11:A10, *B15--
+	stdw	.d2t2	B3:B2, *B15--
+ENDPROC(__c6xabi_push_rts)
arch/c6x/lib/remi.S new file +64 -0

64 lines not on this page · raw message

arch/c6x/lib/remu.S new file +82 -0

82 lines not on this page · raw message

arch/c6x/lib/strasgi.S new file +89 -0

89 lines not on this page · raw message

arch/c6x/lib/strasgi_64plus.S new file +39 -0
new file mode 100644
index 0000000..c9fd159
@@ -0,0 +1,39 @@
+;;  Copyright 2010  Free Software Foundation, Inc.
+;;  Contributed by Bernd Schmidt <[email protected]>.
+;;
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 2 of the License, or
+;; (at your option) any later version.
+;;
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+;;
+;; You should have received a copy of the GNU General Public License
+;; along with this program; if not, write to the Free Software
+;; Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+#include <linux/linkage.h>
+
+	.text
+
+ENTRY(__c6xabi_strasgi_64plus)
+	shru	.s2x	a6, 2, b31
+||	mv	.s1	a4, a30
+||	mv	.d2	b4, b30
+
+	add	.s2	-4, b31, b31
+
+	sploopd		1
+||	mvc	.s2	b31, ilc
+	ldw	.d2t2	*b30++, b31
+	nop	4
+	mv	.s1x	b31,a31
+	spkernel	6, 0
+||	stw	.d1t1	a31, *a30++
+
+	ret	.s2	b3
+	nop 5
+ENDPROC(__c6xabi_strasgi_64plus)
Signature · 1 line
1.7.6
#44 lore raw

PATCH v2 20/24 C6X: general SoC support

In reply to Mark Salter

This patch provides a soc_ops struct which provides hooks for SoC functionality which doesn't fit well into other places. For instance, all SoCs have a silicon revision but each requires different ways to get at that revision.

---
 arch/c6x/include/asm/soc.h |  126 +++++++++++++++++++++++++++++++++
 arch/c6x/kernel/soc.c      |  168 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 294 insertions(+), 0 deletions(-)
 create mode 100644 arch/c6x/include/asm/soc.h
 create mode 100644 arch/c6x/kernel/soc.c
arch/c6x/include/asm/soc.h new file +126 -0
new file mode 100644
index 0000000..72719aa
@@ -0,0 +1,126 @@
+/*
+ * Miscellaneous SoC-specific hooks.
+ *
+ * Copyright (C) 2011 Texas Instruments Incorporated
+ *
+ * Author: Mark Salter <[email protected]>
+ *
+ * This file is licensed under the terms of the GNU General Public License
+ * version 2. This program is licensed "as is" without any warranty of any
+ * kind, whether express or implied.
+ */
+#ifndef _ASM_C6X_SOC_H
+#define _ASM_C6X_SOC_H
+
+/*
+ * IDs of devices that may be enabled/disabled through SoC-specific registers.
+ * Any given SoC will only support a subset of these.
+ */
+enum soc_device_id {
+	SOC_DEV_TCP = 0,
+	SOC_DEV_VCP,
+	SOC_DEV_EMAC,
+	SOC_DEV_TIMER,
+	SOC_DEV_GPIO,
+	SOC_DEV_I2C,
+	SOC_DEV_MCBSP,
+	SOC_DEV_HPI,
+	SOC_DEV_PCI,
+	SOC_DEV_UTOPIA,
+	SOC_DEV_SRIO,
+	SOC_DEV_EMIF,
+	SOC_DEV_DDR2,
+	SOC_DEV_TSIP,
+
+	SOC_DEV_MAX
+};
+
+/* MACSEL values */
+#define MACSEL_UNKNOWN	0
+#define MACSEL_DISABLED	1  /* SoCs may have EMAC disabled with input pin */
+#define MACSEL_MII	2
+#define MACSEL_RMII	3
+#define MACSEL_GMII	4
+#define MACSEL_RGMII	5
+#define MACSEL_S3MII	6
+#define MACSEL_SGMII	7
+
+struct soc_ops {
+	const char *compat;
+	const char *name;
+
+	/* Setup function called by setup_arch() */
+	void		(*setup_arch)(void);
+
+	/* Return silicon rev and optionally, a string representation */
+	unsigned int	(*silicon_rev)(char **rev_str);
+
+	/* IRQ initialization */
+	void		(*init_IRQ)(void);
+
+	/* timer initialization */
+	void		(*time_init)(void);
+
+	/* Return active exception event or -1 if none */
+	int		(*get_exception)(void);
+
+	/* Assert an event */
+	void		(*assert_event)(unsigned int evt);
+
+	/* Get MAC config for given EMAC */
+	int		(*macsel)(unsigned int mac_index);
+
+	/* Get MAC address for given EMAC */
+	int		(*mac_addr)(unsigned int mac_index, u8 *addr);
+
+	/* Boot/reset cores */
+	void		(*boot_core)(int corenum);
+	void		(*reset_core)(int corenum);
+
+	/* Enable/disable power/clocks/buffers for SoC devices */
+	void		(*dev_enable)(enum soc_device_id id, int index);
+	void		(*dev_disable)(enum soc_device_id id, int index);
+
+	/* Chip-level RMII reset for EMAC modules */
+	void		(*rmii_reset_ctl)(int index, int assert);
+};
+
+extern struct soc_ops soc_ops;
+
+#define __soc_ops __attribute__((__section__(".soc.ops")))
+
+#define define_soc(name)					\
+	extern struct soc_ops soc_ops_##name;			\
+	struct soc_ops soc_ops_##name __soc_ops =
+
+extern struct soc_ops __soc_ops_start;
+extern struct soc_ops __soc_ops_end;
+
+/*
+ * This is used to translate soc_devive_ id into SoC-specific id.
+ */
+extern int soc_dev_table[SOC_DEV_MAX];
+#define SOC_DEVCONFIG_SUPPORT(a, b) soc_dev_table[SOC_DEV_##a] = (b)
+
+
+extern unsigned int soc_silicon_rev(char **rev_str);
+extern void soc_init_IRQ(void);
+extern void soc_time_init(void);
+extern int soc_get_exception(void);
+extern void soc_assert_event(unsigned int event);
+extern int soc_macsel(unsigned int index);
+extern int soc_mac_addr(unsigned int index, u8 *addr);
+extern void soc_boot_core(int corenum);
+extern void soc_reset_core(int corenum);
+extern void soc_dev_enable(enum soc_device_id id, unsigned int index);
+extern void soc_dev_disable(enum soc_device_id id, unsigned int index);
+extern void soc_rmii_reset_ctl(int index, int assert);
+extern void soc_arch_init(void);
+
+/*
+ * for mmio on SoC devices. regs are always same byte order as cpu.
+ */
+#define soc_readl(addr)    __raw_readl(addr)
+#define soc_writel(b, addr) __raw_writel((b), (addr))
+
+#endif /* _ASM_C6X_SOC_H */
arch/c6x/kernel/soc.c new file +168 -0

168 lines not on this page · raw message

Signature · 1 line
1.7.6
#45 lore raw

PATCH v2 21/24 C6X: specific SoC support

In reply to Mark Salter

This patch provides the code for the four currently supported SoCs. Each SoC provides a struct soc_ops which contains hooks for miscellaneous functionality which does not fit well in any drivers. At setup_arch time, the device tree is probed to find the correct soc_ops struct to use.

Most SoCs provide one or more sets of MMIO registers for various SoC-specific low-level device setup and control. the device tree is parsed at setup_arch time to find the base address of these registers.

---
 arch/c6x/platforms/soc-6455.c |  389 +++++++++++++++++++++++++++++++++++++
 arch/c6x/platforms/soc-6457.c |  187 ++++++++++++++++++
 arch/c6x/platforms/soc-6472.c |  428 +++++++++++++++++++++++++++++++++++++++++
 arch/c6x/platforms/soc-6474.c |  244 +++++++++++++++++++++++
 4 files changed, 1248 insertions(+), 0 deletions(-)
 create mode 100644 arch/c6x/platforms/soc-6455.c
 create mode 100644 arch/c6x/platforms/soc-6457.c
 create mode 100644 arch/c6x/platforms/soc-6472.c
 create mode 100644 arch/c6x/platforms/soc-6474.c
arch/c6x/platforms/soc-6455.c new file +389 -0
new file mode 100644
index 0000000..03fb618
@@ -0,0 +1,389 @@
+/*
+ *  Miscellaneous SoC specific code
+ *
+ *  Port on Texas Instruments TMS320C6x architecture
+ *
+ *  Copyright (C) 2011 Texas Instruments Incorporated
+ *  Author: Mark Salter <[email protected]>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ */
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/clkdev.h>
+#include <linux/delay.h>
+#include <linux/io.h>
+#include <linux/irq.h>
+#include <asm/clock.h>
+#include <asm/soc.h>
+#include "megamod-pic.h"
+#include "timer64.h"
+
+static struct clk_lookup c6455_clks[] = {
+	CLK(NULL, "pll1", &c6x_soc_pll1.sysclks[0]),
+	CLK(NULL, "pll1_sysclk2", &c6x_soc_pll1.sysclks[2]),
+	CLK(NULL, "pll1_sysclk3", &c6x_soc_pll1.sysclks[3]),
+	CLK(NULL, "pll1_sysclk4", &c6x_soc_pll1.sysclks[4]),
+	CLK(NULL, "pll1_sysclk5", &c6x_soc_pll1.sysclks[5]),
+	CLK(NULL, "core", &c6x_core_clk),
+	CLK("i2c_davinci.1", NULL, &c6x_i2c_clk),
+	CLK("watchdog", NULL, &c6x_watchdog_clk),
+	CLK("2c81800.mdio", NULL, &c6x_mdio_clk),
+	CLK("", NULL, NULL)
+};
+
+
+/* assumptions used for delay loop calculations */
+#define MIN_CLKIN1_KHz 10000
+#define MAX_CORE_KHz   1200000
+#define MIN_PLLOUT_KHz (MIN_CLKIN1_KHz/3)
+
+static void __init __setup_clocks(void)
+{
+	struct pll_data *pll = &c6x_soc_pll1;
+	struct clk *sysclks = pll->sysclks;
+
+	pll->flags = PLL_HAS_PRE | PLL_HAS_MUL;
+
+	pll->bypass_delay = 4 * (MAX_CORE_KHz/MIN_PLLOUT_KHz);
+	pll->reset_delay = 128 * (MAX_CORE_KHz/MIN_CLKIN1_KHz);
+	pll->lock_delay = 2000 * (MAX_CORE_KHz/MIN_CLKIN1_KHz);
+
+	sysclks[2].flags |= FIXED_DIV_PLL;
+	sysclks[2].div = 3;
+	sysclks[3].flags |= FIXED_DIV_PLL;
+	sysclks[3].div = 6;
+	sysclks[4].div = PLLDIV4;
+	sysclks[5].div = PLLDIV5;
+
+	c6x_core_clk.parent = &sysclks[0];
+	c6x_i2c_clk.parent = &sysclks[3];
+	c6x_watchdog_clk.parent = &sysclks[3];
+	c6x_mdio_clk.parent = &sysclks[3];
+
+	c6x_clks_init(c6455_clks);
+}
+
+/*
+ * Chip Level (SoC) Registers
+ */
+#define CHIP_DEVSTAT	0x00
+#define CHIP_PRI_ALLOC	0x04
+#define CHIP_JTAGID	0x08
+
+/*
+ * Device State Controller Registers
+ */
+#define DSCR_PERLOCK	0x04
+#define DSCR_PERCFG0	0x08
+#define DSCR_PERSTAT0	0x14
+#define DSCR_PERSTAT1	0x18
+#define DSCR_EMACCFG	0x20
+#define DSCR_PERCFG1	0x2C
+#define DSCR_EMUBUFPD	0x54
+
+#define DSCR_LOCKVAL	0x0f0a0b00
+
+/* device IDs passed to dscr_enable() and dscr_disable() */
+#define DSCR_TCP	0
+#define DSCR_VCP	1
+#define DSCR_EMAC	2
+#define DSCR_TIMER0	3
+#define DSCR_TIMER1	4
+#define DSCR_GPIO	5
+#define DSCR_I2C	6
+#define DSCR_BSP0	7
+#define DSCR_BSP1	8
+#define DSCR_HPI	9
+#define DSCR_PCI	10
+#define DSCR_UTOPIA	11
+#define DSCR_SRIO	15
+#define DSCR_EMIFA	16
+#define DSCR_DDR2	17
+
+#define PERSTAT_DISABLED	0
+#define PERSTAT_ENABLED		1
+#define PERSTAT_PWRDOWN		3
+#define PERSTAT_INPROGRESS	5
+
+static void __iomem *chip_base;
+static void __iomem *dscr_base;
+
+static inline void dscr_write(int offset, unsigned int val)
+{
+	soc_writel(val, dscr_base + offset);
+}
+
+static inline unsigned int dscr_read(int offset)
+{
+	return soc_readl(dscr_base + offset);
+}
+
+static inline void chip_write(int offset, unsigned int val)
+{
+	soc_writel(val, chip_base + offset);
+}
+
+static inline unsigned int chip_read(int offset)
+{
+	return soc_readl(chip_base + offset);
+}
+
+static inline void __write_percfg0(unsigned int val)
+{
+	void __iomem *_base = dscr_base;
+	int _key = DSCR_LOCKVAL;
+
+	/*
+	 * We need to ensure write to lock register and write to PERCFG0 are
+	 * in same fetch packet and that an interrupt doesn't occur between
+	 * them. The .align makes sure they're in the same packet and putting
+	 * them in the delay slots of the second branch ensures they are not
+	 * interrupted.
+	 */
+	asm volatile ("b	.s2	0f\n"
+		      "nop	5\n"
+		      "    .align 5\n"
+		      "0:\n"
+		      "b	.s2	0f\n"
+		      "stw	.D1T1	%2,*+%1(%4)\n"
+		      "stw	.D1T1	%0,*+%1(%3)\n"
+		      "nop\n"
+		      "nop\n"
+		      "nop\n"
+		      "0:\n"
+		      :
+		      : "a"(val), "a"(_base), "a"(_key),
+		      "Iu5"(DSCR_PERCFG0), "Iu5"(DSCR_PERLOCK)
+		);
+}
+
+/*
+ * Enable a peripheral through PERCFG registers.
+ */
+static void dscr_enable(int id)
+{
+	unsigned int val;
+	int shift;
+
+	if (id < 16) {
+		int status_reg;
+
+		shift = id * 2;
+
+		val = dscr_read(DSCR_PERCFG0);
+		val &= ~(3 << shift);
+		if (id == DSCR_SRIO) {
+			/* SRIO is handled differently than the others */
+			val |= (3 << shift);
+			__write_percfg0(val);
+			return;
+		}
+		val |= (1 << shift);
+		__write_percfg0(val);
+		/* wait for completion */
+		if (id < 10) {
+			status_reg = DSCR_PERSTAT0;
+			shift = id * 3;
+		} else {
+			status_reg = DSCR_PERSTAT1;
+			shift = (id - 10) * 3;
+		}
+		do {
+			val = dscr_read(status_reg);
+			val >>= shift;
+			val &= 7;
+		} while (val != PERSTAT_ENABLED);
+	} else {
+		shift = id - 16;
+		val = dscr_read(DSCR_PERCFG1);
+		dscr_write(DSCR_PERCFG1, val | (1 << shift));
+		__delay(100);
+	}
+}
+
+/*
+ * Disable a peripheral through PERCFG registers.
+ */
+static void dscr_disable(int id)
+{
+	unsigned int val;
+	int shift;
+
+	if (id < 16) {
+		shift = id * 2;
+
+		val = dscr_read(DSCR_PERCFG0);
+		val &= ~(3 << shift);
+		__write_percfg0(val);
+	}
+}
+
+static void __dev_enable(int id, unsigned int index, int enable)
+{
+	switch (id) {
+	case DSCR_TIMER0:
+		if (index == 1)
+			id = DSCR_TIMER1;
+		else if (index)
+			return;
+		break;
+	case DSCR_BSP0:
+		if (index == 1)
+			id = DSCR_BSP1;
+		else if (index)
+			return;
+		break;
+	default:
+		if (index)
+			return;
+		break;
+	}
+	if (enable)
+		dscr_enable(id);
+	else
+		dscr_disable(id);
+}
+
+static void c6455_dev_enable(enum soc_device_id id, int index)
+{
+	__dev_enable(id, index, 1);
+}
+
+static void c6455_dev_disable(enum soc_device_id id, int index)
+{
+	__dev_enable(id, index, 0);
+}
+
+static void __init __setup_dscr(void)
+{
+	struct device_node *node;
+
+	node = of_find_compatible_node(NULL, NULL, "ti,tms320c6455-dscr");
+	if (!node)
+		return;
+
+	dscr_base = of_iomap(node, 0);
+	of_node_put(node);
+	if (!dscr_base)
+		return;
+
+	node = of_find_node_by_type(NULL, "soc");
+	if (node) {
+		chip_base = of_iomap(node, 0);
+		of_node_put(node);
+
+		pr_info("DEVSTAT=%08x  PERCFG0=%08x PERCFG1=%08x\n",
+			 chip_read(CHIP_DEVSTAT), dscr_read(DSCR_PERCFG0),
+			 dscr_read(DSCR_PERCFG1));
+	}
+
+	SOC_DEVCONFIG_SUPPORT(TCP, DSCR_TCP);
+	SOC_DEVCONFIG_SUPPORT(VCP, DSCR_VCP);
+	SOC_DEVCONFIG_SUPPORT(EMAC, DSCR_EMAC);
+	SOC_DEVCONFIG_SUPPORT(TIMER, DSCR_TIMER0);
+	SOC_DEVCONFIG_SUPPORT(GPIO, DSCR_GPIO);
+	SOC_DEVCONFIG_SUPPORT(I2C, DSCR_I2C);
+	SOC_DEVCONFIG_SUPPORT(MCBSP, DSCR_BSP0);
+	SOC_DEVCONFIG_SUPPORT(HPI, DSCR_HPI);
+	SOC_DEVCONFIG_SUPPORT(PCI, DSCR_PCI);
+	SOC_DEVCONFIG_SUPPORT(UTOPIA, DSCR_UTOPIA);
+	SOC_DEVCONFIG_SUPPORT(SRIO, DSCR_SRIO);
+	SOC_DEVCONFIG_SUPPORT(EMIF, DSCR_EMIFA);
+	SOC_DEVCONFIG_SUPPORT(DDR2, DSCR_DDR2);
+
+	c6455_dev_enable(SOC_DEV_TIMER, 0);
+	c6455_dev_enable(SOC_DEV_TIMER, 1);
+
+#ifdef CONFIG_I2C
+	c6455_dev_enable(SOC_DEV_I2C, 0);
+#endif
+#ifdef CONFIG_GENERIC_GPIO
+	c6455_dev_enable(SOC_DEV_GPIO, 0);
+#endif
+#ifdef CONFIG_TMS320C64X_GEMAC
+	c6455_dev_enable(SOC_DEV_EMAC, 0);
+#endif
+}
+
+static unsigned int c6455_silicon_rev(char **strp)
+{
+	u32 jtagid = chip_read(CHIP_JTAGID);
+	u32 silicon_rev = (jtagid >> 28) & 0xf;
+
+	if (strp) {
+		switch (silicon_rev) {
+		case 0:
+			*strp = "1.1";
+			break;
+		case 1:
+			*strp = "2.0";
+			break;
+		case 2:
+			*strp = "2.1";
+			break;
+		case 4:
+			*strp = "3.1";
+			break;
+		default:
+			*strp = "unknown";
+			break;
+		}
+	}
+	return silicon_rev;
+}
+
+static int macsel_ids[] = {
+	[0] = MACSEL_MII,
+	[1] = MACSEL_RMII,
+	[2] = MACSEL_GMII,
+	[3] = MACSEL_RGMII,
+};
+
+static int c6455_macsel(unsigned int index)
+{
+	u32 devstat = chip_read(CHIP_DEVSTAT);
+	if (index > 0)
+		return MACSEL_UNKNOWN;
+
+	return macsel_ids[(devstat >> 9) & 3];
+}
+
+static void c6455_rmii_reset_ctl(int index, int assert)
+{
+	u32 val;
+
+	if (index)
+		return;
+
+	val = dscr_read(DSCR_EMACCFG);
+	if (assert)
+		dscr_write(DSCR_EMACCFG, val | (1 << 18));
+	else
+		dscr_write(DSCR_EMACCFG, val & ~(1 << 18));
+}
+
+static void __init c6455_setup_arch(void)
+{
+	/* so we won't get called twice */
+	soc_ops.setup_arch = NULL;
+
+	c6x_num_cores = 1;
+	__setup_dscr();
+	__setup_clocks();
+}
+
+define_soc(tms320c6455) {
+	.compat		= "ti,tms320c6455",
+	.name		= "TMS320C6455",
+	.setup_arch	= c6455_setup_arch,
+	.silicon_rev	= c6455_silicon_rev,
+	.init_IRQ	= megamod_pic_init,
+	.time_init	= timer64_init,
+	.macsel		= c6455_macsel,
+	.dev_enable	= c6455_dev_enable,
+	.dev_disable	= c6455_dev_disable,
+	.rmii_reset_ctl	= c6455_rmii_reset_ctl,
+};
arch/c6x/platforms/soc-6457.c new file +187 -0

187 lines not on this page · raw message

arch/c6x/platforms/soc-6472.c new file +428 -0

428 lines not on this page · raw message

arch/c6x/platforms/soc-6474.c new file +244 -0

244 lines not on this page · raw message

Signature · 1 line
1.7.6
#46 lore raw

PATCH v2 22/24 C6X: EMIF - External Memory Interface

In reply to Mark Salter

Several SoC parts provide a simple bridge to support external memory mapped devices. This code probes the device tree for an EMIF node and sets up the bridge registers if such a node is found. Beyond initial set up, there is no further need to access the bridge control registers. External devices on the bus are accessed through their MMIO registers using suitable drivers. The bridge hardware does provide for timeout and other error interrupts, but these are not yet supported.

---
 arch/c6x/platforms/emif.c |   77 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 77 insertions(+), 0 deletions(-)
 create mode 100644 arch/c6x/platforms/emif.c
arch/c6x/platforms/emif.c new file +77 -0
new file mode 100644
index 0000000..2d9a35d
@@ -0,0 +1,77 @@
+/*
+ *  External Memory Interface
+ *
+ *  Copyright (C) 2011 Texas Instruments Incorporated
+ *  Author: Mark Salter <[email protected]>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ */
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/io.h>
+#include <asm/soc.h>
+
+#define NUM_EMIFA_CHIP_ENABLES 4
+
+struct emifa_regs {
+	u32	midr;
+	u32	stat;
+	u32	reserved1[6];
+	u32	bprio;
+	u32	reserved2[23];
+	u32	ce_config;
+	u32	cecfg[NUM_EMIFA_CHIP_ENABLES];
+	u32	reserved3[4];
+	u32	awcc;
+	u32	reserved4[7];
+	u32	intraw;
+	u32	intmsk;
+	u32	intmskset;
+	u32	intmskclr;
+};
+
+/*
+ * Parse device tree for existence of an EMIF (External Memory Interface)
+ * and initialize it if found.
+ */
+static int __init c6x_emifa_init(void)
+{
+	struct emifa_regs __iomem *regs;
+	struct device_node *node;
+	const __be32 *p;
+	int i, len;
+
+	node = of_find_compatible_node(NULL, NULL, "ti,c64x+emifa");
+	if (!node)
+		return 0;
+
+	regs = of_iomap(node, 0);
+	if (!regs)
+		return 0;
+
+	/* emif power/clocks */
+	soc_dev_enable(SOC_DEV_EMIF, 0);
+
+	p = of_get_property(node, "ti,emifa-ce-config", &len);
+	if (p) {
+		len /= sizeof(u32);
+		if (len > NUM_EMIFA_CHIP_ENABLES)
+			len = NUM_EMIFA_CHIP_ENABLES;
+		for (i = 0; i <= len; i++)
+			soc_writel(be32_to_cpup(&p[i]), &regs->cecfg[i]);
+	}
+
+	p = of_get_property(node, "ti,emifa-burst-priority", &len);
+	if (p && len == sizeof(u32))
+		soc_writel(be32_to_cpup(p), &regs->bprio);
+
+	p = of_get_property(node, "ti,emifa-async-wait-control", &len);
+	if (p && len == sizeof(u32))
+		soc_writel(be32_to_cpup(p), &regs->awcc);
+
+	of_node_put(node);
+	return 0;
+}
+pure_initcall(c6x_emifa_init);
Signature · 1 line
1.7.6
#47 lore raw

PATCH v2 23/24 C6X: Power and Sleep Controller

In reply to Mark Salter

This patch provides support for the Power/Sleep controller found on some SoCs. The PSC controls two basic things: power domains and peripheral clock gating and resets. The device tree is parsed at setup_arch tree to find any PSC node. The number and controllability of the power domains and peripheral reset/gating varies quite a bit from SoC to SoC. This driver tries to encapsulate the common bits and provide an API for the SoC specific code to use.

---
 arch/c6x/platforms/psc.c |  181 ++++++++++++++++++++++++++++++++++++++++++++++
 arch/c6x/platforms/psc.h |   25 +++++++
 2 files changed, 206 insertions(+), 0 deletions(-)
 create mode 100644 arch/c6x/platforms/psc.c
 create mode 100644 arch/c6x/platforms/psc.h
arch/c6x/platforms/psc.c new file +181 -0
new file mode 100644
index 0000000..c3fd52c
@@ -0,0 +1,181 @@
+/*
+ *  Power/Sleep Controller
+ *
+ *  Copyright (C) 2011 Texas Instruments Incorporated
+ *  Author: Mark Salter <[email protected]>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ */
+#include <linux/of.h>
+#include <linux/of_address.h>
+#include <linux/io.h>
+#include <linux/delay.h>
+#include <asm/soc.h>
+#include "psc.h"
+
+#define PSC_PTCMD	0x0120
+#define PSC_PTSTAT	0x0128
+
+#define PSC_PDSTAT0	0x0200
+#define PSC_PDCTL0	0x0300
+
+#define PSC_MDSTAT0	0x0800
+#define PSC_MDCTL0	0x0a00
+
+#define PD_NEXT_DISABLE       2
+#define PD_NEXT_ENABLE        3
+
+#define MD_NEXT_SWRST_DISABLE	0
+#define MD_NEXT_SYNCRST		1
+#define MD_NEXT_DISABLE		2
+#define MD_NEXT_ENABLE		3
+#define MD_NEXT_MASK		0x1f
+
+#define LRSTZ	0x100
+
+struct psc_data {
+	u32		phys_base;
+	void __iomem	*base;
+	int		num_domains;
+	int		num_modules;
+	u8		module_domains[MAX_PSC_MODULES];
+};
+
+static struct psc_data psc;
+
+static inline void psc_write(int offset, unsigned int val)
+{
+	if (psc.base)
+		soc_writel(val, psc.base + offset);
+}
+
+static inline unsigned int psc_read(int offset)
+{
+	if (!psc.base)
+		return 0;
+	return soc_readl(psc.base + offset);
+}
+
+static void __wait_for_gostat(int domain_mask)
+{
+	while (psc_read(PSC_PTSTAT) & domain_mask)
+		;
+}
+
+void psc_domain_on(int domain)
+{
+	int reg = PSC_PDCTL0 + (domain * 4);
+
+	if (domain < 0 || domain >= psc.num_domains)
+		return;
+
+	__wait_for_gostat(1 << domain);
+	psc_write(reg, psc_read(reg) | 1);
+}
+
+void psc_domain_off(int domain)
+{
+	int reg = PSC_PDCTL0 + (domain * 4);
+
+	if (domain < 0 || domain >= psc.num_domains)
+		return;
+
+	__wait_for_gostat(1 << domain);
+	psc_write(reg, psc_read(reg) & ~1);
+}
+
+void psc_transition_domains(int domain_mask)
+{
+	domain_mask &= (1 << psc.num_domains) - 1;
+	if (domain_mask == 0)
+		return;
+
+	__wait_for_gostat(domain_mask);
+	psc_write(PSC_PTCMD, domain_mask);
+}
+
+void psc_module_on(int module)
+{
+	u32 reg, val;
+
+	if (module < 0 || module >= psc.num_modules)
+		return;
+
+	__wait_for_gostat(1 << psc.module_domains[module]);
+
+	reg = PSC_MDCTL0 + (module * 4);
+	val = psc_read(reg) & ~MD_NEXT_MASK;
+	psc_write(reg, val | MD_NEXT_ENABLE);
+}
+
+void psc_module_off(int module)
+{
+	u32 reg, val;
+
+	if (module < 0 || module >= psc.num_modules)
+		return;
+
+	__wait_for_gostat(1 << psc.module_domains[module]);
+
+	reg = PSC_MDCTL0 + (module * 4);
+	val = psc_read(reg) & ~MD_NEXT_MASK;
+	psc_write(reg, val | MD_NEXT_DISABLE);
+}
+
+void psc_module_reset(int module)
+{
+	int reg = PSC_MDCTL0 + module * 4;
+
+	if (module < 0 || module >= psc.num_modules)
+		return;
+
+	psc_write(reg, psc_read(reg) & ~LRSTZ);
+}
+
+void psc_module_reset_release(int module)
+{
+	int reg = PSC_MDCTL0 + module * 4;
+
+	if (module < 0 || module >= psc.num_modules)
+		return;
+
+	psc_write(reg, psc_read(reg) | LRSTZ);
+}
+
+void __init psc_init(void)
+{
+	struct device_node *node;
+	const __be32 *p;
+	int i, len;
+
+	node = of_find_compatible_node(NULL, NULL, "ti,c64x+psc");
+	if (!node)
+		return;
+
+	psc.base = of_iomap(node, 0);
+	if (!psc.base) {
+		of_node_put(node);
+		return;
+	}
+
+	p = of_get_property(node, "ti,number-psc-domains", &len);
+	if (p && len == sizeof(u32))
+		psc.num_domains = be32_to_cpup(p);
+
+	p = of_get_property(node, "ti,number-psc-modules", &len);
+	if (p && len == sizeof(u32))
+		psc.num_modules = be32_to_cpup(p);
+
+	p = of_get_property(node, "ti,module-domain-map", &len);
+	if (p) {
+		len /= sizeof(u32);
+		if (len > MAX_PSC_MODULES)
+			len = MAX_PSC_MODULES;
+		for (i = 0; i <= len; i++)
+			psc.module_domains[i] = be32_to_cpup(&p[i]);
+	}
+
+	of_node_put(node);
+}
arch/c6x/platforms/psc.h new file +25 -0
new file mode 100644
index 0000000..7f4bd1d
@@ -0,0 +1,25 @@
+/*
+ *  C6X Power/Sleep Controller
+ *
+ *  Copyright (C) 2011 Texas Instruments Incorporated
+ *  Author: Mark Salter <[email protected]>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2 as
+ *  published by the Free Software Foundation.
+ */
+#ifndef _C6X_PSC_H
+#define _C6X_PSC_H
+
+#define MAX_PSC_MODULES 16
+
+extern void psc_init(void);
+extern void psc_domain_on(int domain);
+extern void psc_domain_off(int domain);
+extern void psc_transition_domains(int domain_mask);
+extern void psc_module_on(int module);
+extern void psc_module_off(int module);
+extern void psc_module_reset(int module);
+extern void psc_module_reset_release(int module);
+
+#endif /* _C6X_PSC_H */
Signature · 1 line
1.7.6
#48 lore raw
In reply to Mark Salter
Quoted 1 line · Mark Salter

Here is v2 of the C6X architecture patch series.

Please ignore this. It a mistaken resend of a previous mail sent to linux-arch. Sorry for the noise.

--Mark