summaryrefslogtreecommitdiffstats
path: root/arch/ppc
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2007-07-05 18:01:28 +0200
committerSascha Hauer <sha@octopus.labnet.pengutronix.de>2007-07-05 18:01:28 +0200
commit0d3d354cf66cccd0d3932dd18c7dffc96c8c23de (patch)
tree89b762ae72b8e21924c8bdaaa71c63c37804347c /arch/ppc
parentceddda143b55019ed6be8a331b5ed218a1c64d3b (diff)
downloadbarebox-0d3d354cf66cccd0d3932dd18c7dffc96c8c23de.tar.gz
barebox-0d3d354cf66cccd0d3932dd18c7dffc96c8c23de.tar.xz
svn_rev_155
on the way to compile powerpc
Diffstat (limited to 'arch/ppc')
-rw-r--r--arch/ppc/Kconfig23
-rw-r--r--arch/ppc/Makefile102
-rw-r--r--arch/ppc/lib/Makefile10
-rw-r--r--arch/ppc/lib/bat_rw.c (renamed from arch/ppc/bat_rw.c)0
-rw-r--r--arch/ppc/lib/board.c (renamed from arch/ppc/board.c)180
-rw-r--r--arch/ppc/lib/cache.c (renamed from arch/ppc/cache.c)0
-rw-r--r--arch/ppc/lib/extable.c (renamed from arch/ppc/extable.c)0
-rw-r--r--arch/ppc/lib/interrupts.c (renamed from arch/ppc/interrupts.c)0
-rw-r--r--arch/ppc/lib/kgdb.c (renamed from arch/ppc/kgdb.c)0
-rw-r--r--arch/ppc/lib/misc.S27
-rw-r--r--arch/ppc/lib/ppcstring.S (renamed from arch/ppc/ppcstring.S)2
-rw-r--r--arch/ppc/lib/ticks.S65
-rw-r--r--arch/ppc/lib/time.c (renamed from arch/ppc/time.c)40
13 files changed, 208 insertions, 241 deletions
diff --git a/arch/ppc/Kconfig b/arch/ppc/Kconfig
new file mode 100644
index 0000000000..8c59244e03
--- /dev/null
+++ b/arch/ppc/Kconfig
@@ -0,0 +1,23 @@
+
+config TEXT_BASE
+ string
+ default "0x0" if MACH_PHYCORE_MPC5200B_TINY
+
+config MPC5200
+ bool
+
+choice
+ prompt "Select your board"
+
+config MACH_PHYCORE_MPC5200B_TINY
+ bool "Phycore mpc5200b tiny"
+ select MPC5200
+ help
+ Say Y here if you are using the Motorola MX1ADS board
+
+endchoice
+
+source common/Kconfig
+source net/Kconfig
+source drivers/Kconfig
+
diff --git a/arch/ppc/Makefile b/arch/ppc/Makefile
index 2ba034f1ee..68d85314a3 100644
--- a/arch/ppc/Makefile
+++ b/arch/ppc/Makefile
@@ -1,46 +1,56 @@
-#
-# (C) Copyright 2000-2006
-# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
-#
-# See file CREDITS for list of people who contributed to this
-# project.
-#
-# 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 $(TOPDIR)/config.mk
-
-LIB = $(obj)lib$(ARCH).a
-
-SOBJS = ppcstring.o ticks.o
-
-COBJS = board.o \
- bat_rw.o cache.o extable.o kgdb.o time.o interrupts.o
-
-SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c)
-OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS))
-
-$(LIB): $(obj).depend $(OBJS)
- $(AR) $(ARFLAGS) $@ $(OBJS)
-
-#########################################################################
-
-# defines $(obj).depend target
-include $(SRCTREE)/rules.mk
-
-sinclude $(obj).depend
-
-#########################################################################
+
+CPPFLAGS += -fno-builtin -ffreestanding -nostdinc -Wall \
+ -isystem $(gccincdir) -ffixed-r14 -meabi -Wstrict-prototypes -fPIC -D __PPC__ -D CONFIG_PPC \
+
+
+machine-$(CONFIG_ARCH_MPC5200) := mpc5200
+board-$(CONFIG_MACH_PHYCORE_MPC5200B_TINY) := phycore_mpc5200b_tiny
+cpu-$(CONFIG_MPC5200) := mpc5xxx
+
+TEXT_BASE = $(CONFIG_TEXT_BASE)
+
+CPPFLAGS += -DTEXT_BASE=$(TEXT_BASE) -P
+CFLAGS := -fno-common -Os
+LDFLAGS_vmlinux :=-L $(shell dirname `$(CC) $(CFLAGS) -print-libgcc-file-name`) -lgcc -Ttext $(TEXT_BASE)
+
+ifeq ($(incdir-y),)
+incdir-y := $(machine-y)
+endif
+INCDIR := arch-$(incdir-y)
+
+# Update machine arch and proc symlinks if something which affects
+# them changed. We use .arch to indicate when they were updated
+# last, otherwise make uses the target directory mtime.
+
+include/asm-ppc/.arch: $(wildcard include/config/arch/*.h) include/config/auto.conf
+ @echo ' SYMLINK include/asm-ppc/arch -> include/asm-ppc/$(INCDIR)'
+ifneq ($(KBUILD_SRC),)
+ $(Q)mkdir -p include/asm-ppc
+ $(Q)ln -fsn $(srctree)/include/asm-ppc/$(INCDIR) include/asm-ppc/arch
+else
+ $(Q)ln -fsn $(INCDIR) include/asm-ppc/arch
+endif
+ @touch $@
+
+archprepare: maketools
+
+PHONY += maketools
+maketools: include/asm-ppc/.arch
+
+
+ifneq ($(board-y),)
+BOARD := board/$(board-y)/
+else
+BOARD :=
+endif
+
+ifneq ($(cpu-y),)
+CPU := cpu/$(cpu-y)/
+else
+CPU :=
+endif
+
+common-y += $(BOARD) $(CPU)
+common-y += arch/ppc/lib/
+
+MRPROPER_FILES += include/asm-ppc/arch
diff --git a/arch/ppc/lib/Makefile b/arch/ppc/lib/Makefile
new file mode 100644
index 0000000000..d147171d8f
--- /dev/null
+++ b/arch/ppc/lib/Makefile
@@ -0,0 +1,10 @@
+obj-y += bat_rw.o
+obj-y += board.o
+obj-y += cache.o
+obj-y += extable.o
+obj-y += interrupts.o
+obj-y += kgdb.o
+obj-y += ppcstring.o
+obj-y += ticks.o
+obj-y += time.o
+obj-y += misc.o
diff --git a/arch/ppc/bat_rw.c b/arch/ppc/lib/bat_rw.c
index 912efa72b4..912efa72b4 100644
--- a/arch/ppc/bat_rw.c
+++ b/arch/ppc/lib/bat_rw.c
diff --git a/arch/ppc/board.c b/arch/ppc/lib/board.c
index 797b925e58..bd8b7ef7fb 100644
--- a/arch/ppc/board.c
+++ b/arch/ppc/lib/board.c
@@ -182,24 +182,6 @@ char *strmhz (char *buf, long hz)
*/
typedef int (init_fnc_t) (void);
-/************************************************************************
- * Init Utilities *
- ************************************************************************
- * Some of this code should be moved into the core functions,
- * but let's get it working (again) first...
- */
-
-static int init_baudrate (void)
-{
- char tmp[64]; /* long enough for environment variables */
- int i = getenv_r ("baudrate", tmp, sizeof (tmp));
-
- gd->baudrate = (i > 0)
- ? (int) simple_strtoul (tmp, NULL, 10)
- : CONFIG_BAUDRATE;
- return (0);
-}
-
/***********************************************************************/
#ifdef CONFIG_ADD_RAM_INFO
@@ -268,10 +250,6 @@ static int init_func_watchdog_reset (void)
init_fnc_t *init_sequence[] = {
-#if defined(CONFIG_BOARD_EARLY_INIT_F)
- board_early_init_f,
-#endif
-
#if !defined(CONFIG_8xx_CPUCLK_DEFAULT)
get_clocks, /* get CPU and bus clocks (etc.) */
#if defined(CONFIG_TQM8xxL) && !defined(CONFIG_TQM866M) \
@@ -280,60 +258,23 @@ init_fnc_t *init_sequence[] = {
#endif
init_timebase,
#endif
-#ifdef CFG_ALLOC_DPRAM
-#if !defined(CONFIG_CPM2)
- dpram_init,
-#endif
-#endif
#if defined(CONFIG_BOARD_POSTCLK_INIT)
board_postclk_init,
#endif
- env_init,
#if defined(CONFIG_8xx_CPUCLK_DEFAULT)
get_clocks_866, /* get CPU and bus clocks according to the environment variable */
sdram_adjust_866, /* adjust sdram refresh rate according to the new clock */
init_timebase,
#endif
- init_baudrate,
serial_init,
- console_init_f,
- display_options,
-#if defined(CONFIG_8260)
- prt_8260_rsr,
- prt_8260_clks,
-#endif /* CONFIG_8260 */
-
-#if defined(CONFIG_MPC83XX)
- print_clock_conf,
-#endif
-
checkcpu,
#if defined(CONFIG_MPC5xxx)
prt_mpc5xxx_clks,
#endif /* CONFIG_MPC5xxx */
-#if defined(CONFIG_MPC8220)
- prt_mpc8220_clks,
-#endif
checkboard,
INIT_FUNC_WATCHDOG_INIT
-#if defined(CONFIG_MISC_INIT_F)
- misc_init_f,
-#endif
INIT_FUNC_WATCHDOG_RESET
-#if defined(CONFIG_HARD_I2C) || defined(CONFIG_SOFT_I2C)
- init_func_i2c,
-#endif
-#if defined(CONFIG_DTT) /* Digital Thermometers and Thermostats */
- dtt_init,
-#endif
-#ifdef CONFIG_POST
- post_init_f,
-#endif
INIT_FUNC_WATCHDOG_RESET
- init_func_ram,
-#if defined(CFG_DRAM_TEST)
- testdram,
-#endif /* CFG_DRAM_TEST */
INIT_FUNC_WATCHDOG_RESET
NULL, /* Terminate this list */
@@ -603,9 +544,6 @@ void board_init_r (gd_t *id, ulong dest_addr)
bd_t *bd;
int i;
extern void malloc_bin_reloc (void);
-#ifndef CFG_ENV_IS_NOWHERE
- extern char * env_name_spec;
-#endif
#ifndef CFG_NO_FLASH
ulong flash_size;
@@ -655,9 +593,6 @@ void board_init_r (gd_t *id, ulong dest_addr)
#endif
}
/* there are some other pointer constants we must deal with */
-#ifndef CFG_ENV_IS_NOWHERE
- env_name_spec += gd->reloc_off;
-#endif
WATCHDOG_RESET ();
@@ -702,56 +637,6 @@ void board_init_r (gd_t *id, ulong dest_addr)
*/
trap_init (dest_addr);
-#if !defined(CFG_NO_FLASH)
- puts ("FLASH: ");
-
- if ((flash_size = flash_init ()) > 0) {
-# ifdef CFG_FLASH_CHECKSUM
- print_size (flash_size, "");
- /*
- * Compute and print flash CRC if flashchecksum is set to 'y'
- *
- * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX
- */
- s = getenv ("flashchecksum");
- if (s && (*s == 'y')) {
- printf (" CRC: %08lX",
- crc32 (0, (const unsigned char *) CFG_FLASH_BASE, flash_size)
- );
- }
- putc ('\n');
-# else /* !CFG_FLASH_CHECKSUM */
- print_size (flash_size, "\n");
-# endif /* CFG_FLASH_CHECKSUM */
- } else {
- puts (failed);
- hang ();
- }
-
- bd->bi_flashstart = CFG_FLASH_BASE; /* update start of FLASH memory */
- bd->bi_flashsize = flash_size; /* size of FLASH memory (final value) */
-
-#if defined(CFG_UPDATE_FLASH_SIZE)
- /* Make a update of the Memctrl. */
- update_flash_size (flash_size);
-#endif
-
-
-# if defined(CONFIG_PCU_E) || defined(CONFIG_OXC) || defined(CONFIG_RMU)
- /* flash mapped at end of memory map */
- bd->bi_flashoffset = TEXT_BASE + flash_size;
-# elif CFG_MONITOR_BASE == CFG_FLASH_BASE
- bd->bi_flashoffset = monitor_flash_len; /* reserved area for startup monitor */
-# else
- bd->bi_flashoffset = 0;
-# endif
-#else /* CFG_NO_FLASH */
-
- bd->bi_flashsize = 0;
- bd->bi_flashstart = 0;
- bd->bi_flashoffset = 0;
-#endif /* !CFG_NO_FLASH */
-
WATCHDOG_RESET ();
/* initialize higher level parts of CPU like time base and timers */
@@ -777,7 +662,7 @@ void board_init_r (gd_t *id, ulong dest_addr)
#endif
/* relocate environment function pointers etc. */
- env_relocate ();
+// env_relocate ();
/*
* Fill in missing fields of bd_info.
@@ -882,14 +767,6 @@ void board_init_r (gd_t *id, ulong dest_addr)
mac_read_from_eeprom();
#endif
-#if defined(CONFIG_TQM8xxL) || defined(CONFIG_TQM8260) || \
- defined(CONFIG_TQM8272) || \
- defined(CONFIG_CCM) || defined(CONFIG_KUP4K) || defined(CONFIG_KUP4X)
- load_sernum_ethaddr ();
-#endif
- /* IP Address */
- bd->bi_ip_addr = getenv_IPaddr ("ipaddr");
-
WATCHDOG_RESET ();
#if defined(CONFIG_PCI) && !defined(CONFIG_BAB7xx) && !defined(CONFIG_CPC45)
@@ -899,30 +776,6 @@ void board_init_r (gd_t *id, ulong dest_addr)
pci_init ();
#endif
-/** leave this here (after malloc(), environment and PCI are working) **/
- /* Initialize devices */
- devices_init ();
-
- /* Initialize the jump table for applications */
- jumptable_init ();
-
- /* Initialize the console (after the relocation and devices init) */
- console_init_r ();
-
-#if defined(CONFIG_CCM) || \
- defined(CONFIG_COGENT) || \
- defined(CONFIG_CPCI405) || \
- defined(CONFIG_EVB64260) || \
- defined(CONFIG_KUP4K) || \
- defined(CONFIG_KUP4X) || \
- defined(CONFIG_LWMON) || \
- defined(CONFIG_PCU_E) || \
- defined(CONFIG_W7O) || \
- defined(CONFIG_MISC_INIT_R)
- /* miscellaneous platform dependent initialisations */
- misc_init_r ();
-#endif
-
#ifdef CONFIG_HERMES
if (bd->bi_ethspeed != 0xFFFF)
hermes_start_lxt980 ((int) bd->bi_ethspeed);
@@ -956,16 +809,6 @@ void board_init_r (gd_t *id, ulong dest_addr)
set_timer (0);
- /* Initialize from environment */
- if ((s = getenv ("loadaddr")) != NULL) {
- load_addr = simple_strtoul (s, NULL, 16);
- }
-#if (CONFIG_COMMANDS & CFG_CMD_NET)
- if ((s = getenv ("bootfile")) != NULL) {
- copy_filename (BootFile, s, sizeof (BootFile));
- }
-#endif /* CFG_CMD_NET */
-
WATCHDOG_RESET ();
#if (CONFIG_COMMANDS & CFG_CMD_SCSI)
@@ -985,28 +828,7 @@ void board_init_r (gd_t *id, ulong dest_addr)
WATCHDOG_RESET ();
puts ("Net: ");
#endif
- eth_initialize (bd);
-#endif
-
-#if (CONFIG_COMMANDS & CFG_CMD_NET) && ( \
- defined(CONFIG_CCM) || \
- defined(CONFIG_ELPT860) || \
- defined(CONFIG_EP8260) || \
- defined(CONFIG_IP860) || \
- defined(CONFIG_IVML24) || \
- defined(CONFIG_IVMS8) || \
- defined(CONFIG_MPC8260ADS) || \
- defined(CONFIG_MPC8266ADS) || \
- defined(CONFIG_MPC8560ADS) || \
- defined(CONFIG_PCU_E) || \
- defined(CONFIG_RPXSUPER) || \
- defined(CONFIG_STXGP3) || \
- defined(CONFIG_SPD823TS) || \
- defined(CONFIG_RESET_PHY_R) )
- WATCHDOG_RESET ();
- debug ("Reset Ethernet PHY\n");
- reset_phy ();
#endif
#ifdef CONFIG_POST
diff --git a/arch/ppc/cache.c b/arch/ppc/lib/cache.c
index a81ab5e363..a81ab5e363 100644
--- a/arch/ppc/cache.c
+++ b/arch/ppc/lib/cache.c
diff --git a/arch/ppc/extable.c b/arch/ppc/lib/extable.c
index d92f14270e..d92f14270e 100644
--- a/arch/ppc/extable.c
+++ b/arch/ppc/lib/extable.c
diff --git a/arch/ppc/interrupts.c b/arch/ppc/lib/interrupts.c
index b803952bad..b803952bad 100644
--- a/arch/ppc/interrupts.c
+++ b/arch/ppc/lib/interrupts.c
diff --git a/arch/ppc/kgdb.c b/arch/ppc/lib/kgdb.c
index d00edcc9bb..d00edcc9bb 100644
--- a/arch/ppc/kgdb.c
+++ b/arch/ppc/lib/kgdb.c
diff --git a/arch/ppc/lib/misc.S b/arch/ppc/lib/misc.S
new file mode 100644
index 0000000000..05c5059eb0
--- /dev/null
+++ b/arch/ppc/lib/misc.S
@@ -0,0 +1,27 @@
+
+#include <ppc_asm.tmpl>
+#include <asm-generic/errno.h>
+
+ .globl __ashldi3
+__ashldi3:
+ subfic r6,r5,32
+ slw r3,r3,r5 # MSW = count > 31 ? 0 : MSW << count
+ addi r7,r5,32 # could be xori, or addi with -32
+ srw r6,r4,r6 # t1 = count > 31 ? 0 : LSW >> (32-count)
+ slw r7,r4,r7 # t2 = count < 32 ? 0 : LSW << (count-32)
+ or r3,r3,r6 # MSW |= t1
+ slw r4,r4,r5 # LSW = LSW << count
+ or r3,r3,r7 # MSW |= t2
+ blr
+
+ .globl __lshrdi3
+__lshrdi3:
+ subfic r6,r5,32
+ srw r4,r4,r5 # LSW = count > 31 ? 0 : LSW >> count
+ addi r7,r5,32 # could be xori, or addi with -32
+ slw r6,r3,r6 # t1 = count > 31 ? 0 : MSW << (32-count)
+ srw r7,r3,r7 # t2 = count < 32 ? 0 : MSW >> (count-32)
+ or r4,r4,r6 # LSW |= t1
+ srw r3,r3,r5 # MSW = MSW >> count
+ or r4,r4,r7 # LSW |= t2
+ blr
diff --git a/arch/ppc/ppcstring.S b/arch/ppc/lib/ppcstring.S
index 97023a0555..d4d6ee9b27 100644
--- a/arch/ppc/ppcstring.S
+++ b/arch/ppc/lib/ppcstring.S
@@ -9,7 +9,7 @@
* 2 of the License, or (at your option) any later version.
*/
#include <ppc_asm.tmpl>
-#include <asm/errno.h>
+#include <asm-generic/errno.h>
.globl strcpy
strcpy:
diff --git a/arch/ppc/lib/ticks.S b/arch/ppc/lib/ticks.S
new file mode 100644
index 0000000000..b8d25b7f46
--- /dev/null
+++ b/arch/ppc/lib/ticks.S
@@ -0,0 +1,65 @@
+/*
+ * (C) Copyright 2000, 2001
+ * Erik Theisen, Wave 7 Optics, etheisen@mindspring.com.
+ * base on code by
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * 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 <ppc_asm.tmpl>
+#include <ppc_defs.h>
+#include <config.h>
+#include <watchdog.h>
+
+/*
+ * unsigned long long get_ticks(void);
+ *
+ * read timebase as "long long"
+ */
+ .globl get_ticks
+get_ticks:
+1: mftbu r3
+ mftb r4
+ mftbu r5
+ cmp 0,r3,r5
+ bne 1b
+ blr
+
+/*
+ * Delay for a number of ticks
+ */
+ .globl wait_ticks
+wait_ticks:
+ mflr r8 /* save link register */
+ mr r7, r3 /* save tick count */
+ bl get_ticks /* Get start time */
+
+ /* Calculate end time */
+ addc r7, r4, r7 /* Compute end time lower */
+ addze r6, r3 /* and end time upper */
+
+ WATCHDOG_RESET /* Trigger watchdog, if needed */
+1: bl get_ticks /* Get current time */
+ subfc r4, r4, r7 /* Subtract current time from end time */
+ subfe. r3, r3, r6
+ bge 1b /* Loop until time expired */
+
+ mtlr r8 /* restore link register */
+ blr
diff --git a/arch/ppc/time.c b/arch/ppc/lib/time.c
index 51e8e8406d..a7697a172a 100644
--- a/arch/ppc/time.c
+++ b/arch/ppc/lib/time.c
@@ -22,7 +22,8 @@
*/
#include <common.h>
-
+#include <clock.h>
+#include <init.h>
/* ------------------------------------------------------------------------- */
@@ -46,20 +47,6 @@ unsigned long usec2ticks(unsigned long usec)
/* ------------------------------------------------------------------------- */
-/*
- * We implement the delay by converting the delay (the number of
- * microseconds to wait) into a number of time base ticks; then we
- * watch the time base until it has incremented by that amount.
- */
-void udelay(unsigned long usec)
-{
- ulong ticks = usec2ticks (usec);
-
- wait_ticks (ticks);
-}
-
-/* ------------------------------------------------------------------------- */
-
unsigned long ticks2usec(unsigned long ticks)
{
ulong tbclk = get_tbclk();
@@ -97,3 +84,26 @@ int init_timebase (void)
return (0);
}
/* ------------------------------------------------------------------------- */
+
+uint64_t ppc_clocksource_read(void)
+{
+ return get_ticks();
+}
+
+static struct clocksource cs = {
+ .read = ppc_clocksource_read,
+ .mask = 0xffffffff,
+ .shift = 15,
+};
+
+static int clocksource_init (void)
+{
+
+ cs.mult = clocksource_hz2mult(get_tbclk(), cs.shift);
+
+ init_clock(&cs);
+
+ return 0;
+}
+
+core_initcall(clocksource_init);