Commit 1394f032 authored by Bryan Wu's avatar Bryan Wu Committed by Linus Torvalds
Browse files

blackfin architecture

This adds support for the Analog Devices Blackfin processor architecture, and
currently supports the BF533, BF532, BF531, BF537, BF536, BF534, and BF561
(Dual Core) devices, with a variety of development platforms including those
avaliable from Analog Devices (BF533-EZKit, BF533-STAMP, BF537-STAMP,
BF561-EZKIT), and Bluetechnix!  Tinyboards.

The Blackfin architecture was jointly developed by Intel and Analog Devices
Inc.  (ADI) as the Micro Signal Architecture (MSA) core and introduced it in
December of 2000.  Since then ADI has put this core into its Blackfin
processor family of devices.  The Blackfin core has the advantages of a clean,
orthogonal,RISC-like microprocessor instruction set.  It combines a dual-MAC
(Multiply/Accumulate), state-of-the-art signal processing engine and
single-instruction, multiple-data (SIMD) multimedia capabilities into a single
instruction-set architecture.

The Blackfin architecture, including the instruction set, is described by the
ADSP-BF53x/BF56x Blackfin Processor Programming Reference

The Blackfin processor is already supported by major releases of gcc, and
there are binary and source rpms/tarballs for many architectures at: There is complete
documentation, including "getting started" guides available at: which provides links to the sources and
patches you will need in order to set up a cross-compiling environment for

This patch, as well as the other patches (toolchain, distribution,
uClibc) are actively supported by Analog Devices Inc, at:

We have tested this on LTP, and our test plan (including pass/fails) can
be found at:

[ balance parenthesis in blackfin header files]
Signed-off-by: default avatarBryan Wu <>
Signed-off-by: default avatarMariusz Kozlowski <>
Signed-off-by: default avatarAubrey Li <>
Signed-off-by: default avatarJie Zhang <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 73243284
- This file
- HOWTO for blackfin cache locking.
- Supported cache features.
- Requirements for mounting the root file system.
* File: Documentation/blackfin/Filesystems
* Based on:
* Author:
* Created:
* Description: This file contains the simple DMA Implementation for Blackfin
* Rev: $Id: Filesystems 2384 2006-11-01 04:12:43Z magicyang $
* Modified:
* Copyright 2004-2006 Analog Devices Inc.
* Bugs: Enter bugs at
How to mount the root file system in uClinux/Blackfin
1 Mounting EXT3 File system.
Creating an EXT3 File system for uClinux/Blackfin:
Please follow the steps to form the EXT3 File system and mount the same as root
file system.
a Make an ext3 file system as large as you want the final root file
mkfs.ext3 /dev/ram0 <your-rootfs-size-in-1k-blocks>
b Mount this Empty file system on a free directory as:
mount -t ext3 /dev/ram0 ./test
where ./test is the empty directory.
c Copy your root fs directory that you have so carefully made over.
cp -af /tmp/my_final_rootfs_files/* ./test
(For ex: cp -af uClinux-dist/romfs/* ./test)
d If you have done everything right till now you should be able to see
the required "root" dir's (that's etc, root, bin, lib, sbin...)
e Now unmount the file system
umount ./test
f Create the root file system image.
dd if=/dev/ram0 bs=1k count=<your-rootfs-size-in-1k-blocks> \
> ext3fs.img
Now you have to tell the kernel that will be mounting this file system as
So do a make menuconfig under kernel and select the Ext3 journaling file system
support under File system --> submenu.
2. Mounting EXT2 File system.
By default the ext2 file system image will be created if you invoke make from
the top uClinux-dist directory.
3. Mounting CRAMFS File System
To create a CRAMFS file system image execute the command
mkfs.cramfs ./test cramfs.img
where ./test is the target directory.
4. Mounting ROMFS File System
To create a ROMFS file system image execute the command
genromfs -v -V "ROMdisk" -f romfs.img -d ./test
where ./test is the target directory
5. Mounting the JFFS2 Filesystem
To create a compressed JFFS filesystem (JFFS2), please execute the command
mkfs.jffs2 -d ./test -o jffs2.img
where ./test is the target directory.
However, please make sure the following is in your kernel config.
* RAM/ROM/Flash chip drivers
#define CONFIG_MTD_CFI 1
#define CONFIG_MTD_ROM 1
* Mapping drivers for chip access
#define CONFIG_MTD_BF533 1
Through the u-boot boot loader, use the jffs2.img in the corresponding
partition made in linux-2.6.x/drivers/mtd/maps/bf533_flash.c.
NOTE - Currently the Flash driver is available only for EZKIT. Watch out for a
STAMP driver soon.
6. Mounting the NFS File system
For mounting the NFS please do the following in the kernel config.
In Networking Support --> Networking options --> TCP/IP networking -->
IP: kernel level autoconfiguration
Enable BOOTP Support.
In Kernel hacking --> Compiled-in kernel boot parameter add the following
root=/dev/nfs rw ip=bootp
In File system --> Network File system, Enable
NFS file system support --> NFSv3 client support
Root File system on NFS
in uClibc menuconfig, do the following
In Networking Support
enable Remote Procedure Call (RPC) support
Full RPC Support
On the Host side, ensure that /etc/dhcpd.conf looks something like this
ddns-update-style ad-hoc;
allow bootp;
subnet netmask {
default-lease-time 122209600;
max-lease-time 31557600;
group {
host bf533 {
hardware ethernet 00:CF:52:49:C3:01;
option root-path "/home/nfsmount";
ensure that /etc/exports looks something like this
/home/nfsmount *(rw,no_root_squash,no_all_squash)
run the following commands as root (may differ depending on your
distribution) :
- service nfs start
- service portmap start
- service dhcpd start
- /usr/sbin/exportfs
* File: Documentation/blackfin/cache-lock.txt
* Based on:
* Author:
* Created:
* Description: This file contains the simple DMA Implementation for Blackfin
* Rev: $Id: cache-lock.txt 2384 2006-11-01 04:12:43Z magicyang $
* Modified:
* Copyright 2004-2006 Analog Devices Inc.
* Bugs: Enter bugs at
How to lock your code in cache in uClinux/blackfin
There are only a few steps required to lock your code into the cache.
Currently you can lock the code by Way.
Below are the interface provided for locking the cache.
1. cache_grab_lock(int Ways);
This function grab the lock for locking your code into the cache specified
by Ways.
2. cache_lock(int Ways);
This function should be called after your critical code has been executed.
Once the critical code exits, the code is now loaded into the cache. This
function locks the code into the cache.
So, the example sequence will be:
cache_grab_lock(WAY0_L); /* Grab the lock */
critical_code(); /* Execute the code of interest */
cache_lock(WAY0_L); /* Lock the cache */
Where WAY0_L signifies WAY0 locking.
* File: Documentation/blackfin/cachefeatures.txt
* Based on:
* Author:
* Created:
* Description: This file contains the simple DMA Implementation for Blackfin
* Rev: $Id: cachefeatures.txt 2384 2006-11-01 04:12:43Z magicyang $
* Modified:
* Copyright 2004-2006 Analog Devices Inc.
* Bugs: Enter bugs at
- Instruction and Data cache initialization.
- Instruction and Data cache Invalidation Routines, when flushing the
same is not required.
Also, for invalidating the entire instruction and data cache, the below
routines are provided (another method for invalidation, refer page no 267 and 287 of
ADSP-BF533 Hardware Reference manual)
-External Flushing of Instruction and data cache routines.
- Internal Flushing of Instruction and Data Cache.
- Locking the cache.
Please refer linux-2.6.x/Documentation/blackfin/cache-lock.txt for how to
lock the cache.
Locking the cache is optional feature.
- Miscellaneous cache functions.
......@@ -700,6 +700,44 @@ P: Richard Purdie
S: Maintained
P: Aubrey Li
P: Bernd Schmidt
P: Bryan Wu
P: Grace Pan
P: Michael Hennerich
P: Mike Frysinger
P: Jane Lv
P: Jerry Zeng
P: Jie Zhang
P: Robin Getz
P: Roy Huang
P: Sonic Zhang
P: Yi Li
S: Supported
P: Aubrey Li
S: Supported
P: Thomas Sailer
This diff is collapsed.
# arch/blackfin/Makefile
# This file is subject to the terms and conditions of the GNU General Public
# License. See the file "COPYING" in the main directory of this archive
# for more details.
CROSS_COMPILE ?= bfin-uclinux-
LDFLAGS_vmlinux := -X
OBJCOPYFLAGS := -O binary -R .note -R .comment -S
CFLAGS_MODULE += -mlong-calls
KALLSYMS += --symbol-prefix=_
# setup the machine name and the machine dependent settings
machine-$(CONFIG_BF531) := bf533
machine-$(CONFIG_BF532) := bf533
machine-$(CONFIG_BF533) := bf533
machine-$(CONFIG_BF534) := bf537
machine-$(CONFIG_BF536) := bf537
machine-$(CONFIG_BF537) := bf537
machine-$(CONFIG_BF561) := bf561
MACHINE := $(machine-y)
export MACHINE
head-y := arch/$(ARCH)/mach-$(MACHINE)/head.o arch/$(ARCH)/kernel/init_task.o
core-y += arch/$(ARCH)/kernel/ arch/$(ARCH)/mm/ arch/$(ARCH)/mach-common/
# If we have a machine-specific directory, then include it in the build.
ifneq ($(machine-y),)
core-y += arch/$(ARCH)/mach-$(MACHINE)/
core-y += arch/$(ARCH)/mach-$(MACHINE)/boards/
libs-y += arch/$(ARCH)/lib/
drivers-$(CONFIG_OPROFILE) += arch/$(ARCH)/oprofile/
# Update machine arch symlinks if something which affects
# them changed. We use .mach to indicate when they were updated
# last, otherwise make uses the target directory mtime.
include/asm-blackfin/.mach: $(wildcard include/config/arch/*.h) include/config/auto.conf
@echo ' SYMLINK include/asm-$(ARCH)/mach-$(MACHINE) -> include/asm-$(ARCH)/mach'
ifneq ($(KBUILD_SRC),)
$(Q)mkdir -p include/asm-$(ARCH)
$(Q)ln -fsn $(srctree)/include/asm-$(ARCH)/mach-$(MACHINE) include/asm-$(ARCH)/mach
$(Q)ln -fsn mach-$(MACHINE) include/asm-$(ARCH)/mach
@touch $@
include/asm-$(ARCH)/asm-offsets.h \
arch/$(ARCH)/kernel/asm-offsets.s \
include/asm-$(ARCH)/mach \
archprepare: include/asm-blackfin/.mach
$(Q)$(MAKE) $(clean)=$(boot)
all: vmImage
boot := arch/$(ARCH)/boot
$(BOOT_TARGETS): vmlinux
$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
define archhelp
echo '* vmImage - Kernel-only image for U-Boot (arch/$(ARCH)/boot/vmImage)'
# arch/blackfin/boot/Makefile
# This file is subject to the terms and conditions of the GNU General Public
# License. See the file "COPYING" in the main directory of this archive
# for more details.
MKIMAGE := $(srctree)/scripts/
targets := vmImage
extra-y += vmlinux.bin vmlinux.gz
quiet_cmd_uimage = UIMAGE $@
cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A $(ARCH) -O linux -T kernel \
-d $< $@
$(obj)/vmlinux.bin: vmlinux FORCE
$(call if_changed,objcopy)
$(obj)/vmlinux.gz: $(obj)/vmlinux.bin FORCE
$(call if_changed,gzip)
$(obj)/vmImage: $(obj)/vmlinux.gz
$(call if_changed,uimage)
@echo 'Kernel: $@ is ready'
This diff is collapsed.
# arch/blackfin/kernel/Makefile
extra-y := init_task.o
obj-y := \
entry.o process.o bfin_ksyms.o ptrace.o setup.o signal.o \
sys_bfin.o time.o traps.o irqchip.o dma-mapping.o bfin_gpio.o \
obj-$(CONFIG_MODULES) += module.o
obj-$(CONFIG_BFIN_DMA_5XX) += bfin_dma_5xx.o
obj-$(CONFIG_DUAL_CORE_TEST_MODULE) += dualcore_test.o
* File: arch/blackfin/kernel/asm-offsets.c
* Based on:
* Author:
* Created:
* Description: generate definitions needed by assembly language modules.
* Modified:
* Copyright 2004-2006 Analog Devices Inc.
* Bugs: Enter bugs at
* 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
* 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, see the file COPYING, or write
* to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include <linux/stddef.h>
#include <linux/sched.h>
#include <linux/kernel_stat.h>
#include <linux/ptrace.h>
#include <linux/hardirq.h>
#include <asm/irq.h>
#include <asm/thread_info.h>
#define DEFINE(sym, val) \
asm volatile("\n->" #sym " %0 " #val : : "i" (val))
int main(void)
/* offsets into the task struct */
DEFINE(TASK_STATE, offsetof(struct task_struct, state));
DEFINE(TASK_FLAGS, offsetof(struct task_struct, flags));
DEFINE(TASK_PTRACE, offsetof(struct task_struct, ptrace));
DEFINE(TASK_BLOCKED, offsetof(struct task_struct, blocked));
DEFINE(TASK_THREAD, offsetof(struct task_struct, thread));
DEFINE(TASK_THREAD_INFO, offsetof(struct task_struct, thread_info));
DEFINE(TASK_MM, offsetof(struct task_struct, mm));
DEFINE(TASK_ACTIVE_MM, offsetof(struct task_struct, active_mm));
DEFINE(TASK_SIGPENDING, offsetof(struct task_struct, pending));
/* offsets into the irq_cpustat_t struct */
offsetof(irq_cpustat_t, __softirq_pending));
/* offsets into the thread struct */
DEFINE(THREAD_KSP, offsetof(struct thread_struct, ksp));
DEFINE(THREAD_USP, offsetof(struct thread_struct, usp));
DEFINE(THREAD_SR, offsetof(struct thread_struct, seqstat));
DEFINE(PT_SR, offsetof(struct thread_struct, seqstat));
DEFINE(THREAD_ESP0, offsetof(struct thread_struct, esp0));
DEFINE(THREAD_PC, offsetof(struct thread_struct, pc));
/* offsets into the pt_regs */
DEFINE(PT_ORIG_P0, offsetof(struct pt_regs, orig_p0));
DEFINE(PT_ORIG_PC, offsetof(struct pt_regs, orig_pc));
DEFINE(PT_R0, offsetof(struct pt_regs, r0));
DEFINE(PT_R1, offsetof(struct pt_regs, r1));
DEFINE(PT_R2, offsetof(struct pt_regs, r2));
DEFINE(PT_R3, offsetof(struct pt_regs, r3));
DEFINE(PT_R4, offsetof(struct pt_regs, r4));
DEFINE(PT_R5, offsetof(struct pt_regs, r5));
DEFINE(PT_R6, offsetof(struct pt_regs, r6));
DEFINE(PT_R7, offsetof(struct pt_regs, r7));
DEFINE(PT_P0, offsetof(struct pt_regs, p0));
DEFINE(PT_P1, offsetof(struct pt_regs, p1));
DEFINE(PT_P2, offsetof(struct pt_regs, p2));
DEFINE(PT_P3, offsetof(struct pt_regs, p3));
DEFINE(PT_P4, offsetof(struct pt_regs, p4));
DEFINE(PT_P5, offsetof(struct pt_regs, p5));
DEFINE(PT_FP, offsetof(struct pt_regs, fp));
DEFINE(PT_USP, offsetof(struct pt_regs, usp));
DEFINE(PT_I0, offsetof(struct pt_regs, i0));
DEFINE(PT_I1, offsetof(struct pt_regs, i1));
DEFINE(PT_I2, offsetof(struct pt_regs, i2));
DEFINE(PT_I3, offsetof(struct pt_regs, i3));
DEFINE(PT_M0, offsetof(struct pt_regs, m0));
DEFINE(PT_M1, offsetof(struct pt_regs, m1));
DEFINE(PT_M2, offsetof(struct pt_regs, m2));
DEFINE(PT_M3, offsetof(struct pt_regs, m3));
DEFINE(PT_L0, offsetof(struct pt_regs, l0));
DEFINE(PT_L1, offsetof(struct pt_regs, l1));
DEFINE(PT_L2, offsetof(struct pt_regs, l2));
DEFINE(PT_L3, offsetof(struct pt_regs, l3));
DEFINE(PT_B0, offsetof(struct pt_regs, b0));
DEFINE(PT_B1, offsetof(struct pt_regs, b1));
DEFINE(PT_B2, offsetof(struct pt_regs, b2));
DEFINE(PT_B3, offsetof(struct pt_regs, b3));
DEFINE(PT_A0X, offsetof(struct pt_regs, a0x));
DEFINE(PT_A0W, offsetof(struct pt_regs, a0w));
DEFINE(PT_A1X, offsetof(struct pt_regs, a1x));
DEFINE(PT_A1W, offsetof(struct pt_regs, a1w));
DEFINE(PT_LC0, offsetof(struct pt_regs, lc0));
DEFINE(PT_LC1, offsetof(struct pt_regs, lc1));
DEFINE(PT_LT0, offsetof(struct pt_regs, lt0));
DEFINE(PT_LT1, offsetof(struct pt_regs, lt1));
DEFINE(PT_LB0, offsetof(struct pt_regs, lb0));
DEFINE(PT_LB1, offsetof(struct pt_regs, lb1));
DEFINE(PT_ASTAT, offsetof(struct pt_regs, astat));
DEFINE(PT_RESERVED, offsetof(struct pt_regs, reserved));
DEFINE(PT_RETS, offsetof(struct pt_regs, rets));
DEFINE(PT_PC, offsetof(struct pt_regs, pc));
DEFINE(PT_RETX, offsetof(struct pt_regs, retx));
DEFINE(PT_RETN, offsetof(struct pt_regs, retn));
DEFINE(PT_RETE, offsetof(struct pt_regs, rete));
DEFINE(PT_SEQSTAT, offsetof(struct pt_regs, seqstat));
DEFINE(PT_SYSCFG, offsetof(struct pt_regs, syscfg));
DEFINE(PT_IPEND, offsetof(struct pt_regs, ipend));
DEFINE(SIZEOF_PTREGS, sizeof(struct pt_regs));
DEFINE(PT_TEXT_ADDR, sizeof(struct pt_regs)); /* Needed by gdb */
DEFINE(PT_TEXT_END_ADDR, 4 + sizeof(struct pt_regs));/* Needed by gdb */
DEFINE(PT_DATA_ADDR, 8 + sizeof(struct pt_regs)); /* Needed by gdb */
DEFINE(PT_FDPIC_EXEC, 12 + sizeof(struct pt_regs)); /* Needed by gdb */
DEFINE(PT_FDPIC_INTERP, 16 + sizeof(struct pt_regs));/* Needed by gdb */
/* signal defines */
return 0;
This diff is collapsed.
* File: arch/blackfin/kernel/bfin_gpio.c
* Based on:
* Author: Michael Hennerich (
* Created: