ARM: bcm283x: merge BCM2835/BCM2836 directories into mach-bcm283x
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Thu, 19 Mar 2015 10:42:56 +0000 (19:42 +0900)
committerTom Rini <trini@konsulko.com>
Sat, 28 Mar 2015 13:03:09 +0000 (09:03 -0400)
BCM2835 (used on Raspberry Pi) and BCM2836 (used on Raspberry Pi 2)
are similar enough.  One of the biggest differences is the ARM
processor.  It is reasonable to collect the source files into a
single place, arch/arm/mach-bcm283x/.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Stephen Warren <swarren@wwwdotorg.org>
23 files changed:
arch/arm/Kconfig
arch/arm/Makefile
arch/arm/cpu/arm1176/Makefile
arch/arm/cpu/arm1176/bcm2835/Kconfig [deleted file]
arch/arm/cpu/arm1176/bcm2835/Makefile [deleted file]
arch/arm/cpu/arm1176/bcm2835/init.c [deleted file]
arch/arm/cpu/arm1176/bcm2835/lowlevel_init.S [deleted file]
arch/arm/cpu/arm1176/bcm2835/mbox.c [deleted file]
arch/arm/cpu/arm1176/bcm2835/reset.c [deleted file]
arch/arm/cpu/arm1176/bcm2835/timer.c [deleted file]
arch/arm/cpu/armv7/Makefile
arch/arm/cpu/armv7/bcm2835/Makefile [deleted file]
arch/arm/mach-bcm283x/Kconfig [new file with mode: 0644]
arch/arm/mach-bcm283x/Makefile [new file with mode: 0644]
arch/arm/mach-bcm283x/init.c [new file with mode: 0644]
arch/arm/mach-bcm283x/lowlevel_init.S [new file with mode: 0644]
arch/arm/mach-bcm283x/mbox.c [new file with mode: 0644]
arch/arm/mach-bcm283x/reset.c [new file with mode: 0644]
arch/arm/mach-bcm283x/timer.c [new file with mode: 0644]
board/raspberrypi/rpi/Kconfig [deleted file]
board/raspberrypi/rpi_2/Kconfig [deleted file]
configs/rpi_2_defconfig
configs/rpi_defconfig

index b9ebee1046288e817034f0d30fbdc7e2ff1853ce..9292e9878df39111aaddfc309e5b0485de4ebc1e 100644 (file)
@@ -286,13 +286,8 @@ config TARGET_MX35PDK
        bool "Support mx35pdk"
        select CPU_ARM1136
 
-config TARGET_RPI
-       bool "Support rpi"
-       select CPU_ARM1176
-
-config TARGET_RPI_2
-       bool "Support rpi_2"
-       select CPU_V7
+config ARCH_BCM283X
+       bool "Broadcom BCM283X family"
 
 config TARGET_INTEGRATORAP_CM946ES
        bool "Support integratorap_cm946es"
@@ -723,9 +718,9 @@ endchoice
 
 source "arch/arm/mach-at91/Kconfig"
 
-source "arch/arm/mach-davinci/Kconfig"
+source "arch/arm/mach-bcm283x/Kconfig"
 
-source "arch/arm/cpu/arm1176/bcm2835/Kconfig"
+source "arch/arm/mach-davinci/Kconfig"
 
 source "arch/arm/cpu/armv7/exynos/Kconfig"
 
@@ -834,8 +829,6 @@ source "board/palmtreo680/Kconfig"
 source "board/phytec/pcm051/Kconfig"
 source "board/ppcag/bg0900/Kconfig"
 source "board/pxa255_idp/Kconfig"
-source "board/raspberrypi/rpi/Kconfig"
-source "board/raspberrypi/rpi_2/Kconfig"
 source "board/samsung/smdk2410/Kconfig"
 source "board/sandisk/sansa_fuze_plus/Kconfig"
 source "board/scb9328/Kconfig"
index 08946de244d56b6e625a46aa63c8beeef5950567..bac3cb27e251bc3a0804a73dc223110649cfb68e 100644 (file)
@@ -5,6 +5,7 @@
 # Machine directory name.  This list is sorted alphanumerically
 # by CONFIG_* macro name.
 machine-$(CONFIG_ARCH_AT91)            += at91
+machine-$(CONFIG_ARCH_BCM283X)         += bcm283x
 machine-$(CONFIG_ARCH_DAVINCI)         += davinci
 machine-$(CONFIG_ARCH_HIGHBANK)                += highbank
 machine-$(CONFIG_ARCH_KEYSTONE)                += keystone
index 480e1304891dc69606e358610d553b64edd5309d..deec4274477551b17b13b8e1b601892246d2641c 100644 (file)
@@ -10,5 +10,3 @@
 
 extra-y        = start.o
 obj-y  = cpu.o
-
-obj-$(CONFIG_BCM2835) += bcm2835/
diff --git a/arch/arm/cpu/arm1176/bcm2835/Kconfig b/arch/arm/cpu/arm1176/bcm2835/Kconfig
deleted file mode 100644 (file)
index 73cc72b..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-if TARGET_RPI || TARGET_RPI_2
-
-config DM
-       default y
-
-config DM_SERIAL
-       default y
-
-config DM_GPIO
-       default y
-
-endif
diff --git a/arch/arm/cpu/arm1176/bcm2835/Makefile b/arch/arm/cpu/arm1176/bcm2835/Makefile
deleted file mode 100644 (file)
index 7e5dbe1..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#
-# (C) Copyright 2012 Stephen Warren
-#
-# SPDX-License-Identifier:     GPL-2.0
-#
-
-obj-y  := lowlevel_init.o
-obj-y  += init.o reset.o timer.o mbox.o
diff --git a/arch/arm/cpu/arm1176/bcm2835/init.c b/arch/arm/cpu/arm1176/bcm2835/init.c
deleted file mode 100644 (file)
index e90d3bb..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * (C) Copyright 2012 Stephen Warren
- *
- * 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
- * version 2 as published by the Free Software Foundation.
- *
- * 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.
- */
-
-#include <common.h>
-
-int arch_cpu_init(void)
-{
-       icache_enable();
-
-       return 0;
-}
diff --git a/arch/arm/cpu/arm1176/bcm2835/lowlevel_init.S b/arch/arm/cpu/arm1176/bcm2835/lowlevel_init.S
deleted file mode 100644 (file)
index c7b0843..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * (C) Copyright 2012 Stephen Warren
- *
- * 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
- * version 2 as published by the Free Software Foundation.
- *
- * 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.
- */
-
-.globl lowlevel_init
-lowlevel_init:
-       mov     pc, lr
diff --git a/arch/arm/cpu/arm1176/bcm2835/mbox.c b/arch/arm/cpu/arm1176/bcm2835/mbox.c
deleted file mode 100644 (file)
index 3b17a31..0000000
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * (C) Copyright 2012 Stephen Warren
- *
- * SPDX-License-Identifier:    GPL-2.0+
- */
-
-#include <common.h>
-#include <asm/io.h>
-#include <asm/arch/mbox.h>
-
-#define TIMEOUT 1000 /* ms */
-
-int bcm2835_mbox_call_raw(u32 chan, u32 send, u32 *recv)
-{
-       struct bcm2835_mbox_regs *regs =
-               (struct bcm2835_mbox_regs *)BCM2835_MBOX_PHYSADDR;
-       ulong endtime = get_timer(0) + TIMEOUT;
-       u32 val;
-
-       debug("time: %lu timeout: %lu\n", get_timer(0), endtime);
-
-       if (send & BCM2835_CHAN_MASK) {
-               printf("mbox: Illegal mbox data 0x%08x\n", send);
-               return -1;
-       }
-
-       /* Drain any stale responses */
-
-       for (;;) {
-               val = readl(&regs->status);
-               if (val & BCM2835_MBOX_STATUS_RD_EMPTY)
-                       break;
-               if (get_timer(0) >= endtime) {
-                       printf("mbox: Timeout draining stale responses\n");
-                       return -1;
-               }
-               val = readl(&regs->read);
-       }
-
-       /* Wait for space to send */
-
-       for (;;) {
-               val = readl(&regs->status);
-               if (!(val & BCM2835_MBOX_STATUS_WR_FULL))
-                       break;
-               if (get_timer(0) >= endtime) {
-                       printf("mbox: Timeout waiting for send space\n");
-                       return -1;
-               }
-       }
-
-       /* Send the request */
-
-       val = BCM2835_MBOX_PACK(chan, send);
-       debug("mbox: TX raw: 0x%08x\n", val);
-       writel(val, &regs->write);
-
-       /* Wait for the response */
-
-       for (;;) {
-               val = readl(&regs->status);
-               if (!(val & BCM2835_MBOX_STATUS_RD_EMPTY))
-                       break;
-               if (get_timer(0) >= endtime) {
-                       printf("mbox: Timeout waiting for response\n");
-                       return -1;
-               }
-       }
-
-       /* Read the response */
-
-       val = readl(&regs->read);
-       debug("mbox: RX raw: 0x%08x\n", val);
-
-       /* Validate the response */
-
-       if (BCM2835_MBOX_UNPACK_CHAN(val) != chan) {
-               printf("mbox: Response channel mismatch\n");
-               return -1;
-       }
-
-       *recv = BCM2835_MBOX_UNPACK_DATA(val);
-
-       return 0;
-}
-
-#ifdef DEBUG
-void dump_buf(struct bcm2835_mbox_hdr *buffer)
-{
-       u32 *p;
-       u32 words;
-       int i;
-
-       p = (u32 *)buffer;
-       words = buffer->buf_size / 4;
-       for (i = 0; i < words; i++)
-               printf("    0x%04x: 0x%08x\n", i * 4, p[i]);
-}
-#endif
-
-int bcm2835_mbox_call_prop(u32 chan, struct bcm2835_mbox_hdr *buffer)
-{
-       int ret;
-       u32 rbuffer;
-       struct bcm2835_mbox_tag_hdr *tag;
-       int tag_index;
-
-#ifdef DEBUG
-       printf("mbox: TX buffer\n");
-       dump_buf(buffer);
-#endif
-
-       ret = bcm2835_mbox_call_raw(chan, (u32)buffer, &rbuffer);
-       if (ret)
-               return ret;
-       if (rbuffer != (u32)buffer) {
-               printf("mbox: Response buffer mismatch\n");
-               return -1;
-       }
-
-#ifdef DEBUG
-       printf("mbox: RX buffer\n");
-       dump_buf(buffer);
-#endif
-
-       /* Validate overall response status */
-
-       if (buffer->code != BCM2835_MBOX_RESP_CODE_SUCCESS) {
-               printf("mbox: Header response code invalid\n");
-               return -1;
-       }
-
-       /* Validate each tag's response status */
-
-       tag = (void *)(buffer + 1);
-       tag_index = 0;
-       while (tag->tag) {
-               if (!(tag->val_len & BCM2835_MBOX_TAG_VAL_LEN_RESPONSE)) {
-                       printf("mbox: Tag %d missing val_len response bit\n",
-                               tag_index);
-                       return -1;
-               }
-               /*
-                * Clear the reponse bit so clients can just look right at the
-                * length field without extra processing
-                */
-               tag->val_len &= ~BCM2835_MBOX_TAG_VAL_LEN_RESPONSE;
-               tag = (void *)(((u8 *)tag) + sizeof(*tag) + tag->val_buf_size);
-               tag_index++;
-       }
-
-       return 0;
-}
diff --git a/arch/arm/cpu/arm1176/bcm2835/reset.c b/arch/arm/cpu/arm1176/bcm2835/reset.c
deleted file mode 100644 (file)
index 8c37ad9..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * (C) Copyright 2012 Stephen Warren
- *
- * 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
- * version 2 as published by the Free Software Foundation.
- *
- * 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.
- */
-
-#include <common.h>
-#include <asm/io.h>
-#include <asm/arch/wdog.h>
-
-#define RESET_TIMEOUT 10
-
-void reset_cpu(ulong addr)
-{
-       struct bcm2835_wdog_regs *regs =
-               (struct bcm2835_wdog_regs *)BCM2835_WDOG_PHYSADDR;
-       uint32_t rstc;
-
-       rstc = readl(&regs->rstc);
-       rstc &= ~BCM2835_WDOG_RSTC_WRCFG_MASK;
-       rstc |= BCM2835_WDOG_RSTC_WRCFG_FULL_RESET;
-
-       writel(BCM2835_WDOG_PASSWORD | RESET_TIMEOUT, &regs->wdog);
-       writel(BCM2835_WDOG_PASSWORD | rstc, &regs->rstc);
-}
diff --git a/arch/arm/cpu/arm1176/bcm2835/timer.c b/arch/arm/cpu/arm1176/bcm2835/timer.c
deleted file mode 100644 (file)
index 017907c..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * (C) Copyright 2012 Stephen Warren
- *
- * 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
- * version 2 as published by the Free Software Foundation.
- *
- * 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.
- */
-
-#include <common.h>
-#include <asm/io.h>
-#include <asm/arch/timer.h>
-
-ulong get_timer_us(ulong base)
-{
-       struct bcm2835_timer_regs *regs =
-               (struct bcm2835_timer_regs *)BCM2835_TIMER_PHYSADDR;
-
-       return readl(&regs->clo) - base;
-}
-
-ulong get_timer(ulong base)
-{
-       ulong us = get_timer_us(0);
-       us /= (1000000 / CONFIG_SYS_HZ);
-       us -= base;
-       return us;
-}
-
-unsigned long long get_ticks(void)
-{
-       return get_timer(0);
-}
-
-ulong get_tbclk(void)
-{
-       return CONFIG_SYS_HZ;
-}
-
-void __udelay(unsigned long usec)
-{
-       ulong endtime;
-       signed long diff;
-
-       endtime = get_timer_us(0) + usec;
-
-       do {
-               ulong now = get_timer_us(0);
-               diff = endtime - now;
-       } while (diff >= 0);
-}
index 1312a9db9e84c28b3b5d2b4c1bcffa60de5aa13c..21fc03b97eef431438f773757eb8e2bbcfc1df3a 100644 (file)
@@ -39,7 +39,6 @@ endif
 
 obj-$(if $(filter am33xx,$(SOC)),y) += am33xx/
 obj-$(if $(filter armada-xp,$(SOC)),y) += armada-xp/
-obj-$(CONFIG_BCM2835) += bcm2835/
 obj-$(if $(filter bcm281xx,$(SOC)),y) += bcm281xx/
 obj-$(if $(filter bcmcygnus,$(SOC)),y) += bcmcygnus/
 obj-$(if $(filter bcmnsp,$(SOC)),y) += bcmnsp/
diff --git a/arch/arm/cpu/armv7/bcm2835/Makefile b/arch/arm/cpu/armv7/bcm2835/Makefile
deleted file mode 100644 (file)
index ed1ee47..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-#
-# (C) Copyright 2012 Stephen Warren
-#
-# SPDX-License-Identifier:     GPL-2.0+
-#
-
-src_dir := ../../arm1176/bcm2835/
-
-obj-y  :=
-obj-y  += $(src_dir)/init.o
-obj-y  += $(src_dir)/reset.o
-obj-y  += $(src_dir)/timer.o
-obj-y  += $(src_dir)/mbox.o
diff --git a/arch/arm/mach-bcm283x/Kconfig b/arch/arm/mach-bcm283x/Kconfig
new file mode 100644 (file)
index 0000000..d5e09e8
--- /dev/null
@@ -0,0 +1,40 @@
+menu "Broadcom BCM283X family"
+       depends on ARCH_BCM283X
+
+choice
+       prompt "Broadcom BCM283X board select"
+
+config TARGET_RPI
+       bool "Raspberry Pi"
+       select CPU_ARM1176
+
+config TARGET_RPI_2
+       bool "Raspberry Pi 2"
+       select CPU_V7
+
+endchoice
+
+config DM
+       default y
+
+config DM_SERIAL
+       default y
+
+config DM_GPIO
+       default y
+
+config SYS_BOARD
+       default "rpi" if TARGET_RPI
+       default "rpi_2" if TARGET_RPI_2
+
+config SYS_VENDOR
+       default "raspberrypi"
+
+config SYS_SOC
+       default "bcm2835"
+
+config SYS_CONFIG_NAME
+       default "rpi" if TARGET_RPI
+       default "rpi_2" if TARGET_RPI_2
+
+endmenu
diff --git a/arch/arm/mach-bcm283x/Makefile b/arch/arm/mach-bcm283x/Makefile
new file mode 100644 (file)
index 0000000..2505428
--- /dev/null
@@ -0,0 +1,8 @@
+#
+# (C) Copyright 2012 Stephen Warren
+#
+# SPDX-License-Identifier:     GPL-2.0
+#
+
+obj-$(CONFIG_TARGET_RPI) += lowlevel_init.o
+obj-y  += init.o reset.o timer.o mbox.o
diff --git a/arch/arm/mach-bcm283x/init.c b/arch/arm/mach-bcm283x/init.c
new file mode 100644 (file)
index 0000000..e90d3bb
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * (C) Copyright 2012 Stephen Warren
+ *
+ * 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
+ * version 2 as published by the Free Software Foundation.
+ *
+ * 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.
+ */
+
+#include <common.h>
+
+int arch_cpu_init(void)
+{
+       icache_enable();
+
+       return 0;
+}
diff --git a/arch/arm/mach-bcm283x/lowlevel_init.S b/arch/arm/mach-bcm283x/lowlevel_init.S
new file mode 100644 (file)
index 0000000..c7b0843
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * (C) Copyright 2012 Stephen Warren
+ *
+ * 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
+ * version 2 as published by the Free Software Foundation.
+ *
+ * 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.
+ */
+
+.globl lowlevel_init
+lowlevel_init:
+       mov     pc, lr
diff --git a/arch/arm/mach-bcm283x/mbox.c b/arch/arm/mach-bcm283x/mbox.c
new file mode 100644 (file)
index 0000000..3b17a31
--- /dev/null
@@ -0,0 +1,153 @@
+/*
+ * (C) Copyright 2012 Stephen Warren
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/arch/mbox.h>
+
+#define TIMEOUT 1000 /* ms */
+
+int bcm2835_mbox_call_raw(u32 chan, u32 send, u32 *recv)
+{
+       struct bcm2835_mbox_regs *regs =
+               (struct bcm2835_mbox_regs *)BCM2835_MBOX_PHYSADDR;
+       ulong endtime = get_timer(0) + TIMEOUT;
+       u32 val;
+
+       debug("time: %lu timeout: %lu\n", get_timer(0), endtime);
+
+       if (send & BCM2835_CHAN_MASK) {
+               printf("mbox: Illegal mbox data 0x%08x\n", send);
+               return -1;
+       }
+
+       /* Drain any stale responses */
+
+       for (;;) {
+               val = readl(&regs->status);
+               if (val & BCM2835_MBOX_STATUS_RD_EMPTY)
+                       break;
+               if (get_timer(0) >= endtime) {
+                       printf("mbox: Timeout draining stale responses\n");
+                       return -1;
+               }
+               val = readl(&regs->read);
+       }
+
+       /* Wait for space to send */
+
+       for (;;) {
+               val = readl(&regs->status);
+               if (!(val & BCM2835_MBOX_STATUS_WR_FULL))
+                       break;
+               if (get_timer(0) >= endtime) {
+                       printf("mbox: Timeout waiting for send space\n");
+                       return -1;
+               }
+       }
+
+       /* Send the request */
+
+       val = BCM2835_MBOX_PACK(chan, send);
+       debug("mbox: TX raw: 0x%08x\n", val);
+       writel(val, &regs->write);
+
+       /* Wait for the response */
+
+       for (;;) {
+               val = readl(&regs->status);
+               if (!(val & BCM2835_MBOX_STATUS_RD_EMPTY))
+                       break;
+               if (get_timer(0) >= endtime) {
+                       printf("mbox: Timeout waiting for response\n");
+                       return -1;
+               }
+       }
+
+       /* Read the response */
+
+       val = readl(&regs->read);
+       debug("mbox: RX raw: 0x%08x\n", val);
+
+       /* Validate the response */
+
+       if (BCM2835_MBOX_UNPACK_CHAN(val) != chan) {
+               printf("mbox: Response channel mismatch\n");
+               return -1;
+       }
+
+       *recv = BCM2835_MBOX_UNPACK_DATA(val);
+
+       return 0;
+}
+
+#ifdef DEBUG
+void dump_buf(struct bcm2835_mbox_hdr *buffer)
+{
+       u32 *p;
+       u32 words;
+       int i;
+
+       p = (u32 *)buffer;
+       words = buffer->buf_size / 4;
+       for (i = 0; i < words; i++)
+               printf("    0x%04x: 0x%08x\n", i * 4, p[i]);
+}
+#endif
+
+int bcm2835_mbox_call_prop(u32 chan, struct bcm2835_mbox_hdr *buffer)
+{
+       int ret;
+       u32 rbuffer;
+       struct bcm2835_mbox_tag_hdr *tag;
+       int tag_index;
+
+#ifdef DEBUG
+       printf("mbox: TX buffer\n");
+       dump_buf(buffer);
+#endif
+
+       ret = bcm2835_mbox_call_raw(chan, (u32)buffer, &rbuffer);
+       if (ret)
+               return ret;
+       if (rbuffer != (u32)buffer) {
+               printf("mbox: Response buffer mismatch\n");
+               return -1;
+       }
+
+#ifdef DEBUG
+       printf("mbox: RX buffer\n");
+       dump_buf(buffer);
+#endif
+
+       /* Validate overall response status */
+
+       if (buffer->code != BCM2835_MBOX_RESP_CODE_SUCCESS) {
+               printf("mbox: Header response code invalid\n");
+               return -1;
+       }
+
+       /* Validate each tag's response status */
+
+       tag = (void *)(buffer + 1);
+       tag_index = 0;
+       while (tag->tag) {
+               if (!(tag->val_len & BCM2835_MBOX_TAG_VAL_LEN_RESPONSE)) {
+                       printf("mbox: Tag %d missing val_len response bit\n",
+                               tag_index);
+                       return -1;
+               }
+               /*
+                * Clear the reponse bit so clients can just look right at the
+                * length field without extra processing
+                */
+               tag->val_len &= ~BCM2835_MBOX_TAG_VAL_LEN_RESPONSE;
+               tag = (void *)(((u8 *)tag) + sizeof(*tag) + tag->val_buf_size);
+               tag_index++;
+       }
+
+       return 0;
+}
diff --git a/arch/arm/mach-bcm283x/reset.c b/arch/arm/mach-bcm283x/reset.c
new file mode 100644 (file)
index 0000000..8c37ad9
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * (C) Copyright 2012 Stephen Warren
+ *
+ * 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
+ * version 2 as published by the Free Software Foundation.
+ *
+ * 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.
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/arch/wdog.h>
+
+#define RESET_TIMEOUT 10
+
+void reset_cpu(ulong addr)
+{
+       struct bcm2835_wdog_regs *regs =
+               (struct bcm2835_wdog_regs *)BCM2835_WDOG_PHYSADDR;
+       uint32_t rstc;
+
+       rstc = readl(&regs->rstc);
+       rstc &= ~BCM2835_WDOG_RSTC_WRCFG_MASK;
+       rstc |= BCM2835_WDOG_RSTC_WRCFG_FULL_RESET;
+
+       writel(BCM2835_WDOG_PASSWORD | RESET_TIMEOUT, &regs->wdog);
+       writel(BCM2835_WDOG_PASSWORD | rstc, &regs->rstc);
+}
diff --git a/arch/arm/mach-bcm283x/timer.c b/arch/arm/mach-bcm283x/timer.c
new file mode 100644 (file)
index 0000000..017907c
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * (C) Copyright 2012 Stephen Warren
+ *
+ * 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
+ * version 2 as published by the Free Software Foundation.
+ *
+ * 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.
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/arch/timer.h>
+
+ulong get_timer_us(ulong base)
+{
+       struct bcm2835_timer_regs *regs =
+               (struct bcm2835_timer_regs *)BCM2835_TIMER_PHYSADDR;
+
+       return readl(&regs->clo) - base;
+}
+
+ulong get_timer(ulong base)
+{
+       ulong us = get_timer_us(0);
+       us /= (1000000 / CONFIG_SYS_HZ);
+       us -= base;
+       return us;
+}
+
+unsigned long long get_ticks(void)
+{
+       return get_timer(0);
+}
+
+ulong get_tbclk(void)
+{
+       return CONFIG_SYS_HZ;
+}
+
+void __udelay(unsigned long usec)
+{
+       ulong endtime;
+       signed long diff;
+
+       endtime = get_timer_us(0) + usec;
+
+       do {
+               ulong now = get_timer_us(0);
+               diff = endtime - now;
+       } while (diff >= 0);
+}
diff --git a/board/raspberrypi/rpi/Kconfig b/board/raspberrypi/rpi/Kconfig
deleted file mode 100644 (file)
index 6a538cf..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-if TARGET_RPI
-
-config SYS_BOARD
-       default "rpi"
-
-config SYS_VENDOR
-       default "raspberrypi"
-
-config SYS_SOC
-       default "bcm2835"
-
-config SYS_CONFIG_NAME
-       default "rpi"
-
-endif
diff --git a/board/raspberrypi/rpi_2/Kconfig b/board/raspberrypi/rpi_2/Kconfig
deleted file mode 100644 (file)
index 032184d..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-if TARGET_RPI_2
-
-config SYS_BOARD
-       default "rpi_2"
-
-config SYS_VENDOR
-       default "raspberrypi"
-
-config SYS_SOC
-       default "bcm2835"
-
-config SYS_CONFIG_NAME
-       default "rpi_2"
-
-endif
index 3075321551c5d0a4c50b44603476e38f2aa505c5..965fcaeaa7dd69ac3433923e8ac33b9fbbb0eb9f 100644 (file)
@@ -1,2 +1,3 @@
 CONFIG_ARM=y
+CONFIG_ARCH_BCM283X=y
 CONFIG_TARGET_RPI_2=y
index 9379cf00d444cdc3cd00b4d51ee08c8f09e27b96..8de1d9f74edf0deb3e4e903fefd261f455d4d2cf 100644 (file)
@@ -1,2 +1,3 @@
 CONFIG_ARM=y
+CONFIG_ARCH_BCM283X=y
 CONFIG_TARGET_RPI=y