summaryrefslogtreecommitdiffstats
path: root/arch/arm
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm')
-rw-r--r--arch/arm/Kconfig23
-rw-r--r--arch/arm/Makefile2
-rw-r--r--arch/arm/boards/Makefile2
-rw-r--r--arch/arm/boards/at91sam9x5ek/hw_version.c2
-rw-r--r--arch/arm/boards/highbank/init.c4
-rw-r--r--arch/arm/boards/karo-tx6x/board.c2
-rw-r--r--arch/arm/boards/raspberry-pi/Makefile2
-rw-r--r--arch/arm/boards/raspberry-pi/rpi-common.c294
-rw-r--r--arch/arm/boards/raspberry-pi/rpi.c277
-rw-r--r--arch/arm/boards/raspberry-pi/rpi.h28
-rw-r--r--arch/arm/boards/raspberry-pi/rpi2.c21
-rw-r--r--arch/arm/configs/rpi2_defconfig72
-rw-r--r--arch/arm/configs/rpi_defconfig70
-rw-r--r--arch/arm/configs/socfpga_defconfig1
-rw-r--r--arch/arm/cpu/Makefile5
-rw-r--r--arch/arm/cpu/mmu.c10
-rw-r--r--arch/arm/cpu/no-mmu.c61
-rw-r--r--arch/arm/cpu/start-pbl.c14
-rw-r--r--arch/arm/cpu/start.c71
-rw-r--r--arch/arm/cpu/uncompress.c31
-rw-r--r--arch/arm/dts/am33xx-strip.dtsi1
-rw-r--r--arch/arm/dts/imx6q-embedsky-e9.dts8
-rw-r--r--arch/arm/dts/socfpga.dtsi8
-rw-r--r--arch/arm/include/asm/barebox-arm.h67
-rw-r--r--arch/arm/include/asm/system.h20
-rw-r--r--arch/arm/mach-at91/bootstrap.c8
-rw-r--r--arch/arm/mach-bcm2835/Kconfig15
-rw-r--r--arch/arm/mach-bcm283x/Kconfig25
-rw-r--r--arch/arm/mach-bcm283x/Makefile (renamed from arch/arm/mach-bcm2835/Makefile)0
-rw-r--r--arch/arm/mach-bcm283x/core.c (renamed from arch/arm/mach-bcm2835/core.c)0
-rw-r--r--arch/arm/mach-bcm283x/include/mach/core.h (renamed from arch/arm/mach-bcm2835/include/mach/core.h)2
-rw-r--r--arch/arm/mach-bcm283x/include/mach/debug_ll.h (renamed from arch/arm/mach-bcm2835/include/mach/debug_ll.h)0
-rw-r--r--arch/arm/mach-bcm283x/include/mach/mbox.h (renamed from arch/arm/mach-bcm2835/include/mach/mbox.h)9
-rw-r--r--arch/arm/mach-bcm283x/include/mach/platform.h (renamed from arch/arm/mach-bcm2835/include/mach/platform.h)9
-rw-r--r--arch/arm/mach-bcm283x/include/mach/wd.h (renamed from arch/arm/mach-bcm2835/include/mach/wd.h)0
-rw-r--r--arch/arm/mach-bcm283x/mbox.c (renamed from arch/arm/mach-bcm2835/mbox.c)0
-rw-r--r--arch/arm/mach-imx/ocotp.c1
-rw-r--r--arch/arm/mach-omap/include/mach/sys_info.h2
-rw-r--r--arch/arm/mach-omap/omap3_generic.c2
-rw-r--r--arch/arm/mach-socfpga/generic.c38
40 files changed, 758 insertions, 449 deletions
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 9f4d8e9587..71d4336d2a 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -22,6 +22,15 @@ config ARM_USE_COMPRESSED_DTB
select UNCOMPRESS
select LZO_DECOMPRESS
+config ARCH_BCM283X
+ bool
+ select GPIOLIB
+ select CLKDEV_LOOKUP
+ select COMMON_CLK
+ select CLOCKSOURCE_BCM283X
+ select ARM_AMBA
+ select HAS_DEBUG_LL
+
menu "System Type"
config BUILTIN_DTB
@@ -52,13 +61,13 @@ config ARCH_AT91
config ARCH_BCM2835
bool "Broadcom BCM2835 boards"
- select GPIOLIB
+ select ARCH_BCM283X
select CPU_ARM1176
- select CLKDEV_LOOKUP
- select COMMON_CLK
- select CLOCKSOURCE_BCM2835
- select ARM_AMBA
- select HAS_DEBUG_LL
+
+config ARCH_BCM2836
+ bool "Broadcom BCM2836 boards"
+ select ARCH_BCM283X
+ select CPU_V7
config ARCH_CLPS711X
bool "Cirrus Logic EP711x/EP721x/EP731x"
@@ -251,7 +260,7 @@ endchoice
source arch/arm/cpu/Kconfig
source arch/arm/mach-at91/Kconfig
-source arch/arm/mach-bcm2835/Kconfig
+source arch/arm/mach-bcm283x/Kconfig
source arch/arm/mach-clps711x/Kconfig
source arch/arm/mach-davinci/Kconfig
source arch/arm/mach-digic/Kconfig
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index cae05ff52b..9ce16b9006 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -57,7 +57,7 @@ AFLAGS += -include asm/unified.h -msoft-float $(AFLAGS_THUMB2)
# Machine directory name. This list is sorted alphanumerically
# by CONFIG_* macro name.
machine-$(CONFIG_ARCH_AT91) := at91
-machine-$(CONFIG_ARCH_BCM2835) := bcm2835
+machine-$(CONFIG_ARCH_BCM283X) := bcm283x
machine-$(CONFIG_ARCH_CLPS711X) := clps711x
machine-$(CONFIG_ARCH_DAVINCI) := davinci
machine-$(CONFIG_ARCH_DIGIC) := digic
diff --git a/arch/arm/boards/Makefile b/arch/arm/boards/Makefile
index 2e58f15f35..1029e8f46f 100644
--- a/arch/arm/boards/Makefile
+++ b/arch/arm/boards/Makefile
@@ -95,7 +95,7 @@ obj-$(CONFIG_MACH_QIL_A9260) += qil-a926x/
obj-$(CONFIG_MACH_QIL_A9G20) += qil-a926x/
obj-$(CONFIG_MACH_RADXA_ROCK) += radxa-rock/
obj-$(CONFIG_MACH_REALQ7) += datamodul-edm-qmx6/
-obj-$(CONFIG_MACH_RPI) += raspberry-pi/
+obj-$(CONFIG_MACH_RPI_COMMON) += raspberry-pi/
obj-$(CONFIG_MACH_SABRELITE) += freescale-mx6-sabrelite/
obj-$(CONFIG_MACH_SABRESD) += freescale-mx6-sabresd/
obj-$(CONFIG_MACH_FREESCALE_IMX6SX_SABRESDB) += freescale-mx6sx-sabresdb/
diff --git a/arch/arm/boards/at91sam9x5ek/hw_version.c b/arch/arm/boards/at91sam9x5ek/hw_version.c
index 37eb1f80c5..2f84d82d5d 100644
--- a/arch/arm/boards/at91sam9x5ek/hw_version.c
+++ b/arch/arm/boards/at91sam9x5ek/hw_version.c
@@ -235,7 +235,7 @@ static int cm_cogent_fixup(struct device_node *root, void *unused)
int ret;
struct device_node *node;
- for_each_compatible_node(node, NULL, "atmel,hsmci") {
+ for_each_compatible_node_from(node, root, NULL, "atmel,hsmci") {
struct device_node *slotnode =
of_get_child_by_name(node, "slot");
if (!slotnode)
diff --git a/arch/arm/boards/highbank/init.c b/arch/arm/boards/highbank/init.c
index a0d4b30b48..1cb02e6e48 100644
--- a/arch/arm/boards/highbank/init.c
+++ b/arch/arm/boards/highbank/init.c
@@ -35,13 +35,13 @@ static int hb_fixup(struct device_node *root, void *unused)
__be32 latency;
if (!(reg & HB_PWRDOM_STAT_SATA)) {
- for_each_compatible_node(node, NULL, "calxeda,hb-ahci")
+ for_each_compatible_node_from(node, root, NULL, "calxeda,hb-ahci")
of_set_property(node, "status", "disabled",
sizeof("disabled"), 1);
}
if (!(reg & HB_PWRDOM_STAT_EMMC)) {
- for_each_compatible_node(node, NULL, "calxeda,hb-sdhci")
+ for_each_compatible_node_from(node, root, NULL, "calxeda,hb-sdhci")
of_set_property(node, "status", "disabled",
sizeof("disabled"), 1);
}
diff --git a/arch/arm/boards/karo-tx6x/board.c b/arch/arm/boards/karo-tx6x/board.c
index 6d9dd9a505..a921541bfc 100644
--- a/arch/arm/boards/karo-tx6x/board.c
+++ b/arch/arm/boards/karo-tx6x/board.c
@@ -21,6 +21,7 @@
#include <init.h>
#include <i2c/i2c.h>
#include <linux/clk.h>
+#include <linux/kernel.h>
#include <environment.h>
#include <mach/bbu.h>
#include <mach/imx6.h>
@@ -29,7 +30,6 @@
#define ETH_PHY_RST IMX_GPIO_NR(7, 6)
#define ETH_PHY_PWR IMX_GPIO_NR(3, 20)
#define ETH_PHY_INT IMX_GPIO_NR(7, 1)
-#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
#define DIV_ROUND(n,d) (((n) + ((d)/2)) / (d))
#define LTC3676_BUCK1 0x01
diff --git a/arch/arm/boards/raspberry-pi/Makefile b/arch/arm/boards/raspberry-pi/Makefile
index 978383aeaa..7a3d7de241 100644
--- a/arch/arm/boards/raspberry-pi/Makefile
+++ b/arch/arm/boards/raspberry-pi/Makefile
@@ -1,2 +1,4 @@
+obj-$(CONFIG_MACH_RPI_COMMON) += rpi-common.o
obj-$(CONFIG_MACH_RPI) += rpi.o
+obj-$(CONFIG_MACH_RPI2) += rpi2.o
lwl-y += lowlevel.o
diff --git a/arch/arm/boards/raspberry-pi/rpi-common.c b/arch/arm/boards/raspberry-pi/rpi-common.c
new file mode 100644
index 0000000000..0e17587a74
--- /dev/null
+++ b/arch/arm/boards/raspberry-pi/rpi-common.c
@@ -0,0 +1,294 @@
+/*
+ * Copyright (C) 2009 Carlo Caione <carlo@carlocaione.org>
+ *
+ * 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.
+ *
+ */
+
+#include <common.h>
+#include <init.h>
+#include <fs.h>
+#include <linux/stat.h>
+#include <linux/clk.h>
+#include <linux/clkdev.h>
+#include <envfs.h>
+#include <malloc.h>
+#include <gpio.h>
+#include <net.h>
+#include <led.h>
+#include <asm/armlinux.h>
+#include <generated/mach-types.h>
+
+#include <mach/core.h>
+#include <mach/mbox.h>
+
+#include "rpi.h"
+
+struct msg_get_arm_mem {
+ struct bcm2835_mbox_hdr hdr;
+ struct bcm2835_mbox_tag_get_arm_mem get_arm_mem;
+ u32 end_tag;
+};
+
+struct msg_get_clock_rate {
+ struct bcm2835_mbox_hdr hdr;
+ struct bcm2835_mbox_tag_get_clock_rate get_clock_rate;
+ u32 end_tag;
+};
+
+struct msg_get_board_rev {
+ struct bcm2835_mbox_hdr hdr;
+ struct bcm2835_mbox_tag_get_board_rev get_board_rev;
+ u32 end_tag;
+};
+
+struct msg_get_mac_address {
+ struct bcm2835_mbox_hdr hdr;
+ struct bcm2835_mbox_tag_get_mac_address get_mac_address;
+ u32 end_tag;
+};
+
+static int rpi_get_arm_mem(u32 *size)
+{
+ BCM2835_MBOX_STACK_ALIGN(struct msg_get_arm_mem, msg);
+ int ret;
+
+ BCM2835_MBOX_INIT_HDR(msg);
+ BCM2835_MBOX_INIT_TAG(&msg->get_arm_mem, GET_ARM_MEMORY);
+
+ ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr);
+ if (ret)
+ return ret;
+
+ *size = msg->get_arm_mem.body.resp.mem_size;
+
+ return 0;
+}
+
+static int rpi_register_clkdev(u32 clock_id, const char *name)
+{
+ BCM2835_MBOX_STACK_ALIGN(struct msg_get_clock_rate, msg);
+ struct clk *clk;
+ int ret;
+
+ BCM2835_MBOX_INIT_HDR(msg);
+ BCM2835_MBOX_INIT_TAG(&msg->get_clock_rate, GET_CLOCK_RATE);
+ msg->get_clock_rate.body.req.clock_id = clock_id;
+
+ ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr);
+ if (ret)
+ return ret;
+
+ clk = clk_fixed(name, msg->get_clock_rate.body.resp.rate_hz);
+ if (IS_ERR(clk))
+ return PTR_ERR(clk);
+
+ if (!clk_register_clkdev(clk, NULL, name))
+ return -ENODEV;
+
+ return 0;
+}
+
+void rpi_set_usbethaddr(void)
+{
+ BCM2835_MBOX_STACK_ALIGN(struct msg_get_mac_address, msg);
+ int ret;
+
+ BCM2835_MBOX_INIT_HDR(msg);
+ BCM2835_MBOX_INIT_TAG(&msg->get_mac_address, GET_MAC_ADDRESS);
+
+ ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr);
+ if (ret) {
+ printf("bcm2835: Could not query MAC address\n");
+ /* Ignore error; not critical */
+ return;
+ }
+
+ eth_register_ethaddr(0, msg->get_mac_address.body.resp.mac);
+}
+
+struct gpio_led rpi_leds[] = {
+ {
+ .gpio = -EINVAL,
+ .led = {
+ .name = "ACT",
+ },
+ }, {
+ .gpio = -EINVAL,
+ .led = {
+ .name = "PWR",
+ },
+ },
+};
+
+void rpi_add_led(void)
+{
+ int i;
+ struct gpio_led *l;
+
+ for (i = 0; i < ARRAY_SIZE(rpi_leds); i++) {
+ l = &rpi_leds[i];
+
+ if (gpio_is_valid(l->gpio))
+ led_gpio_register(l);
+ }
+
+ l = &rpi_leds[0];
+ if (gpio_is_valid(l->gpio))
+ led_set_trigger(LED_TRIGGER_HEARTBEAT, &l->led);
+}
+
+void rpi_b_plus_init(void)
+{
+ rpi_leds[0].gpio = 47;
+ rpi_leds[1].gpio = 35;
+ rpi_set_usbethaddr();
+}
+
+static int rpi_board_rev = 0;
+
+static void rpi_get_board_rev(void)
+{
+ int ret;
+ char *name;
+
+ BCM2835_MBOX_STACK_ALIGN(struct msg_get_board_rev, msg);
+ BCM2835_MBOX_INIT_HDR(msg);
+ BCM2835_MBOX_INIT_TAG(&msg->get_board_rev, GET_BOARD_REV);
+
+ ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr);
+ if (ret) {
+ printf("bcm2835: Could not query board revision\n");
+ /* Ignore error; not critical */
+ return;
+ }
+
+ /* Comments from u-boot:
+ * For details of old-vs-new scheme, see:
+ * https://github.com/pimoroni/RPi.version/blob/master/RPi/version.py
+ * http://www.raspberrypi.org/forums/viewtopic.php?f=63&t=99293&p=690282
+ * (a few posts down)
+ *
+ * For the RPi 1, bit 24 is the "warranty bit", so we mask off just the
+ * lower byte to use as the board rev:
+ * http://www.raspberrypi.org/forums/viewtopic.php?f=63&t=98367&start=250
+ * http://www.raspberrypi.org/forums/viewtopic.php?f=31&t=20594
+ */
+ rpi_board_rev = msg->get_board_rev.body.resp.rev;
+ if (rpi_board_rev & 0x800000)
+ rpi_board_rev = (rpi_board_rev >> 4) & 0xff;
+ else
+ rpi_board_rev &= 0xff;
+ if (rpi_board_rev >= rpi_models_size) {
+ printf("RPI: Board rev %u outside known range\n",
+ rpi_board_rev);
+ goto unknown_rev;
+ }
+
+ if (!rpi_models[rpi_board_rev].name) {
+ printf("RPI: Board rev %u unknown\n", rpi_board_rev);
+ goto unknown_rev;
+ }
+
+ if (!rpi_board_rev)
+ goto unknown_rev;
+
+ name = asprintf("RaspberryPi %s %s", rpi_models[rpi_board_rev].name,
+ rpi_model_string);
+ barebox_set_model(name);
+ free(name);
+
+ return;
+
+unknown_rev:
+ rpi_board_rev = 0;
+ name = asprintf("RaspberryPi %s", rpi_model_string);
+ barebox_set_model(name);
+ free(name);
+}
+
+static void rpi_model_init(void)
+{
+ if (!rpi_models[rpi_board_rev].init)
+ return;
+
+ rpi_models[rpi_board_rev].init();
+ rpi_add_led();
+}
+
+static int rpi_mem_init(void)
+{
+ u32 size = 0;
+ int ret;
+
+ ret = rpi_get_arm_mem(&size);
+ if (ret)
+ printf("could not query ARM memory size\n");
+
+ bcm2835_add_device_sdram(size);
+
+ return ret;
+}
+mem_initcall(rpi_mem_init);
+
+static int rpi_console_init(void)
+{
+ rpi_get_board_rev();
+ barebox_set_hostname("rpi");
+
+ bcm2835_register_uart();
+ return 0;
+}
+console_initcall(rpi_console_init);
+
+static int rpi_clock_init(void)
+{
+ rpi_register_clkdev(BCM2835_MBOX_CLOCK_ID_EMMC, "bcm2835_mci0");
+ return 0;
+}
+postconsole_initcall(rpi_clock_init);
+
+static int rpi_env_init(void)
+{
+ struct stat s;
+ const char *diskdev = "/dev/disk0.0";
+ int ret;
+
+ device_detect_by_name("mci0");
+
+ ret = stat(diskdev, &s);
+ if (ret) {
+ printf("no %s. using default env\n", diskdev);
+ return 0;
+ }
+
+ mkdir("/boot", 0666);
+ ret = mount(diskdev, "fat", "/boot", NULL);
+ if (ret) {
+ printf("failed to mount %s\n", diskdev);
+ return 0;
+ }
+
+ default_environment_path_set("/boot/barebox.env");
+
+ return 0;
+}
+
+static int rpi_devices_init(void)
+{
+ rpi_model_init();
+ bcm2835_register_mci();
+ bcm2835_register_fb();
+ armlinux_set_architecture(MACH_TYPE_BCM2708);
+ rpi_env_init();
+ return 0;
+}
+late_initcall(rpi_devices_init);
diff --git a/arch/arm/boards/raspberry-pi/rpi.c b/arch/arm/boards/raspberry-pi/rpi.c
index f9406d4623..dd2ad7f5a5 100644
--- a/arch/arm/boards/raspberry-pi/rpi.c
+++ b/arch/arm/boards/raspberry-pi/rpi.c
@@ -13,161 +13,17 @@
*
*/
-#include <common.h>
-#include <init.h>
-#include <fs.h>
-#include <linux/stat.h>
-#include <linux/clk.h>
-#include <linux/clkdev.h>
-#include <envfs.h>
-#include <malloc.h>
-#include <gpio.h>
-#include <net.h>
-#include <led.h>
-#include <asm/armlinux.h>
-#include <generated/mach-types.h>
-
-#include <mach/core.h>
-#include <mach/mbox.h>
-
-struct msg_get_arm_mem {
- struct bcm2835_mbox_hdr hdr;
- struct bcm2835_mbox_tag_get_arm_mem get_arm_mem;
- u32 end_tag;
-};
-
-struct msg_get_clock_rate {
- struct bcm2835_mbox_hdr hdr;
- struct bcm2835_mbox_tag_get_clock_rate get_clock_rate;
- u32 end_tag;
-};
-
-struct msg_get_board_rev {
- struct bcm2835_mbox_hdr hdr;
- struct bcm2835_mbox_tag_get_board_rev get_board_rev;
- u32 end_tag;
-};
-
-struct msg_get_mac_address {
- struct bcm2835_mbox_hdr hdr;
- struct bcm2835_mbox_tag_get_mac_address get_mac_address;
- u32 end_tag;
-};
-
-static int rpi_get_arm_mem(u32 *size)
-{
- BCM2835_MBOX_STACK_ALIGN(struct msg_get_arm_mem, msg);
- int ret;
-
- BCM2835_MBOX_INIT_HDR(msg);
- BCM2835_MBOX_INIT_TAG(&msg->get_arm_mem, GET_ARM_MEMORY);
-
- ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr);
- if (ret)
- return ret;
-
- *size = msg->get_arm_mem.body.resp.mem_size;
-
- return 0;
-}
-
-static int rpi_register_clkdev(u32 clock_id, const char *name)
-{
- BCM2835_MBOX_STACK_ALIGN(struct msg_get_clock_rate, msg);
- struct clk *clk;
- int ret;
-
- BCM2835_MBOX_INIT_HDR(msg);
- BCM2835_MBOX_INIT_TAG(&msg->get_clock_rate, GET_CLOCK_RATE);
- msg->get_clock_rate.body.req.clock_id = clock_id;
-
- ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr);
- if (ret)
- return ret;
-
- clk = clk_fixed(name, msg->get_clock_rate.body.resp.rate_hz);
- if (IS_ERR(clk))
- return PTR_ERR(clk);
-
- if (!clk_register_clkdev(clk, NULL, name))
- return -ENODEV;
-
- return 0;
-}
-
-static void rpi_set_usbethaddr(void)
-{
- BCM2835_MBOX_STACK_ALIGN(struct msg_get_mac_address, msg);
- int ret;
-
- BCM2835_MBOX_INIT_HDR(msg);
- BCM2835_MBOX_INIT_TAG(&msg->get_mac_address, GET_MAC_ADDRESS);
-
- ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr);
- if (ret) {
- printf("bcm2835: Could not query MAC address\n");
- /* Ignore error; not critical */
- return;
- }
-
- eth_register_ethaddr(0, msg->get_mac_address.body.resp.mac);
-}
-
-static struct gpio_led leds[] = {
- {
- .gpio = -EINVAL,
- .led = {
- .name = "ACT",
- },
- }, {
- .gpio = -EINVAL,
- .led = {
- .name = "PWR",
- },
- },
-};
-
-static void rpi_add_led(void)
-{
- int i;
- struct gpio_led *l;
-
- for (i = 0; i < ARRAY_SIZE(leds); i++) {
- l = &leds[i];
-
- if (gpio_is_valid(l->gpio))
- led_gpio_register(l);
- }
-
- l = &leds[0];
- if (gpio_is_valid(l->gpio))
- led_set_trigger(LED_TRIGGER_HEARTBEAT, &l->led);
-}
-
-static void rpi_b_plus_init(void)
-{
- leds[0].gpio = 47;
- leds[1].gpio = 35;
- rpi_set_usbethaddr();
-}
+#include "rpi.h"
static void rpi_b_init(void)
{
- leds[0].gpio = 16;
- leds[0].active_low = 1;
+ rpi_leds[0].gpio = 16;
+ rpi_leds[0].active_low = 1;
rpi_set_usbethaddr();
}
-#define RPI_MODEL(_id, _name, _init) \
- [_id] = { \
- .name = _name,\
- .init = _init,\
- }
/* See comments in mbox.h for data source */
-static const struct {
- const char *name;
- void (*init)(void);
-} models[] = {
+const struct rpi_model rpi_models[] = {
RPI_MODEL(0, "Unknown model", NULL),
RPI_MODEL(BCM2835_BOARD_REV_B_I2C0_2, "Model B (no P5)", rpi_b_init),
RPI_MODEL(BCM2835_BOARD_REV_B_I2C0_3, "Model B (no P5)", rpi_b_init),
@@ -184,126 +40,5 @@ static const struct {
RPI_MODEL(BCM2835_BOARD_REV_CM, "Compute Module", NULL),
RPI_MODEL(BCM2835_BOARD_REV_A_PLUS, "Model A+", NULL),
};
-
-static int rpi_board_rev = 0;
-
-static void rpi_get_board_rev(void)
-{
- int ret;
- char *name;
-
- BCM2835_MBOX_STACK_ALIGN(struct msg_get_board_rev, msg);
- BCM2835_MBOX_INIT_HDR(msg);
- BCM2835_MBOX_INIT_TAG(&msg->get_board_rev, GET_BOARD_REV);
-
- ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN, &msg->hdr);
- if (ret) {
- printf("bcm2835: Could not query board revision\n");
- /* Ignore error; not critical */
- return;
- }
-
- rpi_board_rev = msg->get_board_rev.body.resp.rev;
- if (rpi_board_rev >= ARRAY_SIZE(models)) {
- printf("RPI: Board rev %u outside known range\n",
- rpi_board_rev);
- goto unknown_rev;
- }
-
- if (!models[rpi_board_rev].name) {
- printf("RPI: Board rev %u unknown\n", rpi_board_rev);
- goto unknown_rev;
- }
-
- if (!rpi_board_rev)
- goto unknown_rev;
-
- name = asprintf("RaspberryPi %s (BCM2835/ARM1176JZF-S)",
- models[rpi_board_rev].name);
- barebox_set_model(name);
- free(name);
-
- return;
-
-unknown_rev:
- rpi_board_rev = 0;
- barebox_set_model("RaspberryPi (BCM2835/ARM1176JZF-S)");
-}
-
-static void rpi_model_init(void)
-{
- if (!models[rpi_board_rev].init)
- return;
-
- models[rpi_board_rev].init();
- rpi_add_led();
-}
-
-static int rpi_mem_init(void)
-{
- u32 size = 0;
- int ret;
-
- ret = rpi_get_arm_mem(&size);
- if (ret)
- printf("could not query ARM memory size\n");
-
- bcm2835_add_device_sdram(size);
-
- return ret;
-}
-mem_initcall(rpi_mem_init);
-
-static int rpi_console_init(void)
-{
- rpi_get_board_rev();
- barebox_set_hostname("rpi");
-
- bcm2835_register_uart();
- return 0;
-}
-console_initcall(rpi_console_init);
-
-static int rpi_clock_init(void)
-{
- rpi_register_clkdev(BCM2835_MBOX_CLOCK_ID_EMMC, "bcm2835_mci0");
- return 0;
-}
-postconsole_initcall(rpi_clock_init);
-
-static int rpi_env_init(void)
-{
- struct stat s;
- const char *diskdev = "/dev/disk0.0";
- int ret;
-
- device_detect_by_name("mci0");
-
- ret = stat(diskdev, &s);
- if (ret) {
- printf("no %s. using default env\n", diskdev);
- return 0;
- }
-
- mkdir("/boot", 0666);
- ret = mount(diskdev, "fat", "/boot", NULL);
- if (ret) {
- printf("failed to mount %s\n", diskdev);
- return 0;
- }
-
- default_environment_path_set("/boot/barebox.env");
-
- return 0;
-}
-
-static int rpi_devices_init(void)
-{
- rpi_model_init();
- bcm2835_register_mci();
- bcm2835_register_fb();
- armlinux_set_architecture(MACH_TYPE_BCM2708);
- rpi_env_init();
- return 0;
-}
-late_initcall(rpi_devices_init);
+const size_t rpi_models_size = ARRAY_SIZE(rpi_models);
+const char *rpi_model_string = "(BCM2835/ARM1176JZF-S)";
diff --git a/arch/arm/boards/raspberry-pi/rpi.h b/arch/arm/boards/raspberry-pi/rpi.h
new file mode 100644
index 0000000000..739cdee1b3
--- /dev/null
+++ b/arch/arm/boards/raspberry-pi/rpi.h
@@ -0,0 +1,28 @@
+#ifndef __ARCH_ARM_BOARDS_RPI_H__
+#define __ARCH_ARM_BOARDS_RPI_H__
+
+#include <types.h>
+#include <led.h>
+
+#include <mach/mbox.h>
+
+#define RPI_MODEL(_id, _name, _init) \
+ [_id] = { \
+ .name = _name,\
+ .init = _init,\
+ }
+
+struct rpi_model {
+ const char *name;
+ void (*init)(void);
+};
+
+extern const struct rpi_model rpi_models[];
+extern const size_t rpi_models_size;
+extern const char *rpi_model_string;
+extern struct gpio_led rpi_leds[];
+
+void rpi_b_plus_init(void);
+void rpi_set_usbethaddr(void);
+
+#endif /* __ARCH_ARM_BOARDS_RPI_H__ */
diff --git a/arch/arm/boards/raspberry-pi/rpi2.c b/arch/arm/boards/raspberry-pi/rpi2.c
new file mode 100644
index 0000000000..2cfc06f8a6
--- /dev/null
+++ b/arch/arm/boards/raspberry-pi/rpi2.c
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ *
+ */
+
+#include "rpi.h"
+
+const struct rpi_model rpi_models[] = {
+ RPI_MODEL(0, "Unknown model", NULL),
+ RPI_MODEL(BCM2836_BOARD_REV_2_B, "2 Model B", rpi_b_plus_init),
+};
+const size_t rpi_models_size = ARRAY_SIZE(rpi_models);
+const char *rpi_model_string = "(BCM2836/CORTEX-A7)";
diff --git a/arch/arm/configs/rpi2_defconfig b/arch/arm/configs/rpi2_defconfig
new file mode 100644
index 0000000000..81f821a719
--- /dev/null
+++ b/arch/arm/configs/rpi2_defconfig
@@ -0,0 +1,72 @@
+CONFIG_ARCH_BCM2836=y
+CONFIG_AEABI=y
+CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y
+CONFIG_ARM_UNWIND=y
+CONFIG_MMU=y
+CONFIG_MALLOC_TLSF=y
+CONFIG_KALLSYMS=y
+CONFIG_PROMPT="R-Pi> "
+CONFIG_HUSH_FANCY_PROMPT=y
+CONFIG_CMDLINE_EDITING=y
+CONFIG_AUTO_COMPLETE=y
+CONFIG_MENU=y
+CONFIG_BLSPEC=y
+CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y
+CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/arm/boards/raspberry-pi/env"
+CONFIG_LONGHELP=y
+CONFIG_CMD_IOMEM=y
+CONFIG_CMD_MEMINFO=y
+CONFIG_CMD_BOOTM_SHOW_TYPE=y
+CONFIG_CMD_BOOTM_VERBOSE=y
+CONFIG_CMD_BOOTM_INITRD=y
+CONFIG_CMD_BOOTM_OFTREE=y
+CONFIG_CMD_GO=y
+CONFIG_CMD_LOADB=y
+CONFIG_CMD_LOADY=y
+CONFIG_CMD_RESET=y
+CONFIG_CMD_UIMAGE=y
+CONFIG_CMD_PARTITION=y
+CONFIG_CMD_EXPORT=y
+CONFIG_CMD_PRINTENV=y
+CONFIG_CMD_MAGICVAR=y
+CONFIG_CMD_MAGICVAR_HELP=y
+CONFIG_CMD_SAVEENV=y
+CONFIG_CMD_FILETYPE=y
+CONFIG_CMD_LN=y
+CONFIG_CMD_MD5SUM=y
+CONFIG_CMD_UNCOMPRESS=y
+CONFIG_CMD_LET=y
+CONFIG_CMD_MSLEEP=y
+CONFIG_CMD_SLEEP=y
+CONFIG_CMD_ECHO_E=y
+CONFIG_CMD_EDIT=y
+CONFIG_CMD_LOGIN=y
+CONFIG_CMD_MENU=y
+CONFIG_CMD_MENU_MANAGEMENT=y
+CONFIG_CMD_PASSWD=y
+CONFIG_CMD_READLINE=y
+CONFIG_CMD_TIMEOUT=y
+CONFIG_CMD_CRC=y
+CONFIG_CMD_CRC_CMP=y
+CONFIG_CMD_MM=y
+CONFIG_CMD_CLK=y
+CONFIG_CMD_DETECT=y
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_OF_NODE=y
+CONFIG_CMD_OF_PROPERTY=y
+CONFIG_CMD_OFTREE=y
+CONFIG_CMD_TIME=y
+CONFIG_SERIAL_AMBA_PL011=y
+CONFIG_MCI=y
+CONFIG_MCI_BCM283X=y
+CONFIG_LED=y
+CONFIG_LED_GPIO=y
+CONFIG_LED_TRIGGERS=y
+CONFIG_GPIO_BCM283X=y
+CONFIG_REGULATOR=y
+CONFIG_FS_EXT4=y
+CONFIG_FS_FAT=y
+CONFIG_FS_FAT_WRITE=y
+CONFIG_FS_FAT_LFN=y
+CONFIG_DIGEST_SHA1_GENERIC=y
+CONFIG_DIGEST_SHA256_GENERIC=y
diff --git a/arch/arm/configs/rpi_defconfig b/arch/arm/configs/rpi_defconfig
index 25770a007f..f7b591066a 100644
--- a/arch/arm/configs/rpi_defconfig
+++ b/arch/arm/configs/rpi_defconfig
@@ -6,7 +6,6 @@ CONFIG_MMU=y
CONFIG_MALLOC_TLSF=y
CONFIG_KALLSYMS=y
CONFIG_PROMPT="R-Pi> "
-CONFIG_LONGHELP=y
CONFIG_HUSH_FANCY_PROMPT=y
CONFIG_CMDLINE_EDITING=y
CONFIG_AUTO_COMPLETE=y
@@ -14,52 +13,57 @@ CONFIG_MENU=y
CONFIG_BLSPEC=y
CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y
CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/arm/boards/raspberry-pi/env"
-CONFIG_CMD_EDIT=y
-CONFIG_CMD_SLEEP=y
-CONFIG_CMD_MSLEEP=y
-CONFIG_CMD_SAVEENV=y
-CONFIG_CMD_EXPORT=y
-CONFIG_CMD_PRINTENV=y
-CONFIG_CMD_READLINE=y
-CONFIG_CMD_LET=y
-CONFIG_CMD_MENU=y
-CONFIG_CMD_MENU_MANAGEMENT=y
-CONFIG_CMD_LOGIN=y
-CONFIG_CMD_PASSWD=y
-CONFIG_CMD_TIME=y
-CONFIG_CMD_LN=y
-CONFIG_CMD_FILETYPE=y
-CONFIG_CMD_ECHO_E=y
-CONFIG_CMD_LOADB=y
-CONFIG_CMD_LOADY=y
-CONFIG_CMD_MEMINFO=y
+CONFIG_LONGHELP=y
CONFIG_CMD_IOMEM=y
-CONFIG_CMD_MM=y
-CONFIG_CMD_CRC=y
-CONFIG_CMD_CRC_CMP=y
-CONFIG_CMD_MD5SUM=y
+CONFIG_CMD_MEMINFO=y
CONFIG_CMD_BOOTM_SHOW_TYPE=y
CONFIG_CMD_BOOTM_VERBOSE=y
CONFIG_CMD_BOOTM_INITRD=y
CONFIG_CMD_BOOTM_OFTREE=y
-CONFIG_CMD_UIMAGE=y
-CONFIG_CMD_RESET=y
CONFIG_CMD_GO=y
-CONFIG_CMD_OFTREE=y
-CONFIG_CMD_OF_PROPERTY=y
-CONFIG_CMD_OF_NODE=y
-CONFIG_CMD_TIMEOUT=y
+CONFIG_CMD_LOADB=y
+CONFIG_CMD_LOADY=y
+CONFIG_CMD_RESET=y
+CONFIG_CMD_UIMAGE=y
CONFIG_CMD_PARTITION=y
+CONFIG_CMD_EXPORT=y
+CONFIG_CMD_PRINTENV=y
CONFIG_CMD_MAGICVAR=y
CONFIG_CMD_MAGICVAR_HELP=y
-CONFIG_CMD_GPIO=y
+CONFIG_CMD_SAVEENV=y
+CONFIG_CMD_FILETYPE=y
+CONFIG_CMD_LN=y
+CONFIG_CMD_MD5SUM=y
CONFIG_CMD_UNCOMPRESS=y
+CONFIG_CMD_LET=y
+CONFIG_CMD_MSLEEP=y
+CONFIG_CMD_SLEEP=y
+CONFIG_CMD_ECHO_E=y
+CONFIG_CMD_EDIT=y
+CONFIG_CMD_LOGIN=y
+CONFIG_CMD_MENU=y
+CONFIG_CMD_MENU_MANAGEMENT=y
+CONFIG_CMD_PASSWD=y
+CONFIG_CMD_READLINE=y
+CONFIG_CMD_TIMEOUT=y
+CONFIG_CMD_CRC=y
+CONFIG_CMD_CRC_CMP=y
+CONFIG_CMD_MM=y
CONFIG_CMD_CLK=y
CONFIG_CMD_DETECT=y
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_OF_NODE=y
+CONFIG_CMD_OF_PROPERTY=y
+CONFIG_CMD_OFTREE=y
+CONFIG_CMD_TIME=y
CONFIG_SERIAL_AMBA_PL011=y
CONFIG_MCI=y
-CONFIG_MCI_BCM2835=y
-CONFIG_GPIO_BCM2835=y
+CONFIG_MCI_BCM283X=y
+CONFIG_LED=y
+CONFIG_LED_GPIO=y
+CONFIG_LED_TRIGGERS=y
+CONFIG_GPIO_BCM283X=y
+CONFIG_REGULATOR=y
CONFIG_FS_EXT4=y
CONFIG_FS_FAT=y
CONFIG_FS_FAT_WRITE=y
diff --git a/arch/arm/configs/socfpga_defconfig b/arch/arm/configs/socfpga_defconfig
index 0a31de518d..7fbe045e27 100644
--- a/arch/arm/configs/socfpga_defconfig
+++ b/arch/arm/configs/socfpga_defconfig
@@ -67,6 +67,7 @@ CONFIG_NET=y
CONFIG_NET_NETCONSOLE=y
CONFIG_NET_RESOLV=y
CONFIG_OF_BAREBOX_DRIVERS=y
+CONFIG_OF_BAREBOX_ENV_IN_FS=y
CONFIG_DRIVER_SERIAL_NS16550=y
CONFIG_DRIVER_NET_DESIGNWARE=y
CONFIG_MCI=y
diff --git a/arch/arm/cpu/Makefile b/arch/arm/cpu/Makefile
index 418bcab759..854df60ebb 100644
--- a/arch/arm/cpu/Makefile
+++ b/arch/arm/cpu/Makefile
@@ -11,6 +11,11 @@ obj-$(CONFIG_CMD_ARM_MMUINFO) += mmuinfo.o
obj-$(CONFIG_OFDEVICE) += dtb.o
obj-$(CONFIG_MMU) += mmu.o cache.o mmu-early.o
pbl-$(CONFIG_MMU) += mmu-early.o
+
+ifeq ($(CONFIG_MMU),)
+obj-y += no-mmu.o
+endif
+
obj-$(CONFIG_CPU_32v4T) += cache-armv4.o
pbl-$(CONFIG_CPU_32v4T) += cache-armv4.o
obj-$(CONFIG_CPU_32v5) += cache-armv5.o
diff --git a/arch/arm/cpu/mmu.c b/arch/arm/cpu/mmu.c
index 784221ce13..bc5325faba 100644
--- a/arch/arm/cpu/mmu.c
+++ b/arch/arm/cpu/mmu.c
@@ -302,6 +302,16 @@ static void vectors_init(void)
* live without being able to catch NULL pointer dereferences
*/
exc = arm_create_pte(0x0);
+
+ if (cpu_architecture() >= CPU_ARCH_ARMv7) {
+ /*
+ * ARMv7 CPUs allow to remap low vectors from
+ * 0x0 to an arbitrary address using VBAR
+ * register, so let's make sure we have it
+ * pointing to the correct address
+ */
+ set_vbar(0x0);
+ }
}
arm_fixup_vectors();
diff --git a/arch/arm/cpu/no-mmu.c b/arch/arm/cpu/no-mmu.c
new file mode 100644
index 0000000000..e227b457a1
--- /dev/null
+++ b/arch/arm/cpu/no-mmu.c
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2015 Zodiac Inflight Innovation
+ * Author: Andrey Smirnov <andrew.smirnov@gmail.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.
+ *
+ * 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.
+ *
+ */
+
+#define pr_fmt(fmt) "nommu: " fmt
+
+#include <common.h>
+#include <dma-dir.h>
+#include <init.h>
+#include <mmu.h>
+#include <errno.h>
+#include <linux/sizes.h>
+#include <asm/memory.h>
+#include <asm/barebox-arm.h>
+#include <asm/system.h>
+#include <asm/cache.h>
+#include <memory.h>
+#include <asm/system_info.h>
+#include <debug_ll.h>
+
+
+#define __exceptions_size (__exceptions_stop - __exceptions_start)
+
+static int nommu_v7_vectors_init(void)
+{
+ void *vectors;
+ u32 cr;
+
+ if (cpu_architecture() < CPU_ARCH_ARMv7)
+ return 0;
+
+ /*
+ * High vectors cannot be re-mapped, so we have to use normal
+ * vectors
+ */
+ cr = get_cr();
+ cr &= ~CR_V;
+ set_cr(cr);
+
+ arm_fixup_vectors();
+
+ vectors = xmemalign(PAGE_SIZE, PAGE_SIZE);
+ memset(vectors, 0, PAGE_SIZE);
+ memcpy(vectors, __exceptions_start, __exceptions_size);
+
+ set_vbar((unsigned int)vectors);
+
+ return 0;
+}
+mmu_initcall(nommu_v7_vectors_init);
diff --git a/arch/arm/cpu/start-pbl.c b/arch/arm/cpu/start-pbl.c
index 2075ffeee7..f723edc613 100644
--- a/arch/arm/cpu/start-pbl.c
+++ b/arch/arm/cpu/start-pbl.c
@@ -54,8 +54,6 @@ __noreturn void barebox_single_pbl_start(unsigned long membase,
uint32_t endmem = membase + memsize;
unsigned long barebox_base;
- endmem -= STACK_SIZE; /* stack */
-
if (IS_ENABLED(CONFIG_PBL_RELOCATABLE))
relocate_to_current_adr();
@@ -67,7 +65,7 @@ __noreturn void barebox_single_pbl_start(unsigned long membase,
pg_len = pg_end - pg_start;
if (IS_ENABLED(CONFIG_RELOCATABLE))
- barebox_base = arm_barebox_image_place(membase + memsize);
+ barebox_base = arm_mem_barebox_image(membase, endmem, pg_len);
else
barebox_base = TEXT_BASE;
@@ -83,14 +81,12 @@ __noreturn void barebox_single_pbl_start(unsigned long membase,
setup_c();
if (IS_ENABLED(CONFIG_MMU_EARLY)) {
- endmem &= ~0x3fff;
- endmem -= SZ_16K; /* ttb */
- mmu_early_enable(membase, memsize, endmem);
+ unsigned long ttb = arm_mem_ttb(membase, endmem);
+ mmu_early_enable(membase, memsize, ttb);
}
- endmem -= SZ_128K; /* early malloc */
- free_mem_ptr = endmem;
- free_mem_end_ptr = free_mem_ptr + SZ_128K;
+ free_mem_ptr = arm_mem_early_malloc(membase, endmem);
+ free_mem_end_ptr = arm_mem_early_malloc_end(membase, endmem);
pbl_barebox_uncompress((void*)barebox_base, (void *)pg_start, pg_len);
diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c
index c054f3c440..d03d1edfaf 100644
--- a/arch/arm/cpu/start.c
+++ b/arch/arm/cpu/start.c
@@ -34,6 +34,8 @@
#include "mmu-early.h"
unsigned long arm_stack_top;
+static unsigned long arm_head_bottom;
+static unsigned long arm_barebox_size;
static void *barebox_boarddata;
static bool blob_is_fdt(const void *blob)
@@ -104,14 +106,48 @@ void *barebox_arm_boot_dtb(void)
return barebox_boarddata;
}
+static inline unsigned long arm_mem_boarddata(unsigned long membase,
+ unsigned long endmem,
+ unsigned long size)
+{
+ unsigned long mem;
+
+ mem = arm_mem_barebox_image(membase, endmem, barebox_image_size);
+ mem -= ALIGN(size, 64);
+
+ return mem;
+}
+
+unsigned long arm_mem_ramoops_get(void)
+{
+ return arm_mem_ramoops(0, arm_stack_top);
+}
+EXPORT_SYMBOL_GPL(arm_mem_ramoops_get);
+
+static int barebox_memory_areas_init(void)
+{
+ unsigned long start = arm_head_bottom;
+ unsigned long size = arm_mem_barebox_image(0, arm_stack_top,
+ arm_barebox_size) -
+ arm_head_bottom;
+ request_sdram_region("board data", start, size);
+
+ return 0;
+}
+device_initcall(barebox_memory_areas_init);
+
__noreturn void barebox_non_pbl_start(unsigned long membase,
unsigned long memsize, void *boarddata)
{
unsigned long endmem = membase + memsize;
unsigned long malloc_start, malloc_end;
+ unsigned long barebox_size = barebox_image_size +
+ ((unsigned long)&__bss_stop - (unsigned long)&__bss_start);
if (IS_ENABLED(CONFIG_RELOCATABLE)) {
- unsigned long barebox_base = arm_barebox_image_place(endmem);
+ unsigned long barebox_base = arm_mem_barebox_image(membase,
+ endmem,
+ barebox_size);
relocate_to_adr(barebox_base);
}
@@ -122,19 +158,19 @@ __noreturn void barebox_non_pbl_start(unsigned long membase,
pr_debug("memory at 0x%08lx, size 0x%08lx\n", membase, memsize);
arm_stack_top = endmem;
- endmem -= STACK_SIZE; /* Stack */
+ arm_barebox_size = barebox_size;
+ arm_head_bottom = arm_mem_barebox_image(membase, endmem,
+ arm_barebox_size);
if (IS_ENABLED(CONFIG_MMU_EARLY)) {
-
- endmem &= ~0x3fff;
- endmem -= SZ_16K; /* ttb */
+ unsigned long ttb = arm_mem_ttb(membase, endmem);
if (IS_ENABLED(CONFIG_PBL_IMAGE)) {
arm_set_cache_functions();
} else {
- pr_debug("enabling MMU, ttb @ 0x%08lx\n", endmem);
+ pr_debug("enabling MMU, ttb @ 0x%08lx\n", ttb);
arm_early_mmu_cache_invalidate();
- mmu_early_enable(membase, memsize, endmem);
+ mmu_early_enable(membase, memsize, ttb);
}
}
@@ -155,24 +191,17 @@ __noreturn void barebox_non_pbl_start(unsigned long membase,
}
if (totalsize) {
- endmem -= ALIGN(totalsize, 64);
+ unsigned long mem = arm_mem_boarddata(membase, endmem,
+ totalsize);
pr_debug("found %s in boarddata, copying to 0x%lu\n",
- name, endmem);
- barebox_boarddata = memcpy((void *)endmem,
- boarddata, totalsize);
+ name, mem);
+ barebox_boarddata = memcpy((void *)mem, boarddata,
+ totalsize);
+ arm_head_bottom = mem;
}
}
- if ((unsigned long)_text > membase + memsize ||
- (unsigned long)_text < membase)
- /*
- * barebox is either outside SDRAM or in another
- * memory bank, so we can use the whole bank for
- * malloc.
- */
- malloc_end = endmem;
- else
- malloc_end = (unsigned long)_text;
+ malloc_end = arm_head_bottom;
/*
* Maximum malloc space is the Kconfig value if given
diff --git a/arch/arm/cpu/uncompress.c b/arch/arm/cpu/uncompress.c
index dbf6b1e3f8..5bcce6b9e3 100644
--- a/arch/arm/cpu/uncompress.c
+++ b/arch/arm/cpu/uncompress.c
@@ -52,8 +52,6 @@ void __noreturn barebox_multi_pbl_start(unsigned long membase,
void *pg_start;
unsigned long pc = get_pc();
- endmem -= STACK_SIZE; /* stack */
-
image_end = (void *)ld_var(__image_end) - get_runtime_offset();
if (IS_ENABLED(CONFIG_PBL_RELOCATABLE)) {
@@ -68,8 +66,16 @@ void __noreturn barebox_multi_pbl_start(unsigned long membase,
relocate_to_adr(membase);
}
+ /*
+ * image_end is the first location after the executable. It contains
+ * the size of the appended compressed binary followed by the binary.
+ */
+ pg_start = image_end + 1;
+ pg_len = *(image_end);
+
if (IS_ENABLED(CONFIG_RELOCATABLE))
- barebox_base = arm_barebox_image_place(membase + memsize);
+ barebox_base = arm_mem_barebox_image(membase, endmem,
+ pg_len);
else
barebox_base = TEXT_BASE;
@@ -78,22 +84,13 @@ void __noreturn barebox_multi_pbl_start(unsigned long membase,
pr_debug("memory at 0x%08lx, size 0x%08lx\n", membase, memsize);
if (IS_ENABLED(CONFIG_MMU_EARLY)) {
- endmem &= ~0x3fff;
- endmem -= SZ_16K; /* ttb */
- pr_debug("enabling MMU, ttb @ 0x%08x\n", endmem);
- mmu_early_enable(membase, memsize, endmem);
+ unsigned long ttb = arm_mem_ttb(membase, endmem);
+ pr_debug("enabling MMU, ttb @ 0x%08lx\n", ttb);
+ mmu_early_enable(membase, memsize, ttb);
}
- endmem -= SZ_128K; /* early malloc */
- free_mem_ptr = endmem;
- free_mem_end_ptr = free_mem_ptr + SZ_128K;
-
- /*
- * image_end is the first location after the executable. It contains
- * the size of the appended compressed binary followed by the binary.
- */
- pg_start = image_end + 1;
- pg_len = *(image_end);
+ free_mem_ptr = arm_mem_early_malloc(membase, endmem);
+ free_mem_end_ptr = arm_mem_early_malloc_end(membase, endmem);
pr_debug("uncompressing barebox binary at 0x%p (size 0x%08x) to 0x%08lx\n",
pg_start, pg_len, barebox_base);
diff --git a/arch/arm/dts/am33xx-strip.dtsi b/arch/arm/dts/am33xx-strip.dtsi
index 04cf3151ea..2943fd1cc3 100644
--- a/arch/arm/dts/am33xx-strip.dtsi
+++ b/arch/arm/dts/am33xx-strip.dtsi
@@ -45,3 +45,4 @@
/delete-node/ &rng;
/delete-node/ &rtc;
/delete-node/ &wkup_m3;
+/delete-node/ &wkup_m3_ipc;
diff --git a/arch/arm/dts/imx6q-embedsky-e9.dts b/arch/arm/dts/imx6q-embedsky-e9.dts
index 4514d4e433..726d620681 100644
--- a/arch/arm/dts/imx6q-embedsky-e9.dts
+++ b/arch/arm/dts/imx6q-embedsky-e9.dts
@@ -22,13 +22,13 @@
environment-mmc1 {
compatible = "barebox,environment";
- device-path = &usdhc2, "partname:barebox-environment";
+ device-path = &environment_mmc1;
status = "disabled";
};
environment-mmc3 {
compatible = "barebox,environment";
- device-path = &usdhc4, "partname:barebox-environment";
+ device-path = &environment_mmc3;
status = "disabled";
};
@@ -43,7 +43,7 @@
label = "barebox";
reg = <0x0 0x80000>;
};
- partition@1 {
+ environment_mmc1: partition@1 {
label = "barebox-environment";
reg = <0x80000 0x80000>;
};
@@ -57,7 +57,7 @@
label = "barebox";
reg = <0x0 0x80000>;
};
- partition@1 {
+ environment_mmc3: partition@1 {
label = "barebox-environment";
reg = <0x80000 0x80000>;
};
diff --git a/arch/arm/dts/socfpga.dtsi b/arch/arm/dts/socfpga.dtsi
index d4d498be13..d16758fdab 100644
--- a/arch/arm/dts/socfpga.dtsi
+++ b/arch/arm/dts/socfpga.dtsi
@@ -1,4 +1,12 @@
/ {
+ chosen {
+ environment@0 {
+ compatible = "barebox,environment";
+ device-path = &mmc, "partname:1";
+ file-path = "barebox.env";
+ };
+ };
+
aliases {
mmc0 = &mmc;
};
diff --git a/arch/arm/include/asm/barebox-arm.h b/arch/arm/include/asm/barebox-arm.h
index 76e356413a..67133265d1 100644
--- a/arch/arm/include/asm/barebox-arm.h
+++ b/arch/arm/include/asm/barebox-arm.h
@@ -94,25 +94,56 @@ static inline void arm_fixup_vectors(void)
void *barebox_arm_boot_dtb(void);
-/*
- * For relocatable binaries find a suitable start address for the
- * relocated binary. Beginning at the memory end substract the reserved
- * space and round down a bit at the end. This is used by the pbl to
- * extract the image to a suitable place so that the uncompressed image
- * does not have to copy itself to another place. Also it's used by
- * the uncompressed image to relocate itself to the same place.
- */
-static inline unsigned long arm_barebox_image_place(unsigned long endmem)
+static inline unsigned long arm_mem_stack(unsigned long membase,
+ unsigned long endmem)
+{
+ return endmem - STACK_SIZE;
+}
+
+static inline unsigned long arm_mem_ttb(unsigned long membase,
+ unsigned long endmem)
+{
+ endmem = arm_mem_stack(membase, endmem);
+ endmem &= ~(SZ_16K - 1);
+ endmem -= SZ_16K;
+
+ return endmem;
+}
+
+static inline unsigned long arm_mem_early_malloc(unsigned long membase,
+ unsigned long endmem)
{
- endmem -= STACK_SIZE;
- endmem -= SZ_32K; /* ttb */
- endmem -= SZ_128K; /* early malloc */
- endmem -= SZ_1M; /* place for barebox image */
-
- /*
- * round down to make translating the objdump easier
- */
- endmem &= ~(SZ_1M - 1);
+ return arm_mem_ttb(membase, endmem) - SZ_128K;
+}
+
+static inline unsigned long arm_mem_early_malloc_end(unsigned long membase,
+ unsigned long endmem)
+{
+ return arm_mem_ttb(membase, endmem);
+}
+
+static inline unsigned long arm_mem_ramoops(unsigned long membase,
+ unsigned long endmem)
+{
+ endmem = arm_mem_ttb(membase, endmem);
+#ifdef CONFIG_FS_PSTORE_RAMOOPS
+ endmem -= CONFIG_FS_PSTORE_RAMOOPS_SIZE;
+ endmem &= ~(SZ_4K - 1); /* Align to 4K */
+#endif
+
+ return endmem;
+}
+
+static inline unsigned long arm_mem_barebox_image(unsigned long membase,
+ unsigned long endmem,
+ unsigned long size)
+{
+ endmem = arm_mem_ramoops(membase, endmem);
+
+ if (IS_ENABLED(CONFIG_RELOCATABLE)) {
+ endmem -= size;
+ endmem &= ~(SZ_1M - 1);
+ }
return endmem;
}
diff --git a/arch/arm/include/asm/system.h b/arch/arm/include/asm/system.h
index 26fb18c79a..b118a42609 100644
--- a/arch/arm/include/asm/system.h
+++ b/arch/arm/include/asm/system.h
@@ -71,6 +71,26 @@ static inline void set_cr(unsigned int val)
isb();
}
+#ifdef CONFIG_CPU_32v7
+static inline unsigned int get_vbar(void)
+{
+ unsigned int vbar;
+ asm volatile("mrc p15, 0, %0, c12, c0, 0 @ get VBAR"
+ : "=r" (vbar) : : "cc");
+ return vbar;
+}
+
+static inline void set_vbar(unsigned int vbar)
+{
+ asm volatile("mcr p15, 0, %0, c12, c0, 0 @ set VBAR"
+ : : "r" (vbar) : "cc");
+ isb();
+}
+#else
+static inline unsigned int get_vbar(void) { return 0; }
+static inline void set_vbar(unsigned int vbar) {}
+#endif
+
#endif
#endif /* __ASM_ARM_SYSTEM_H */
diff --git a/arch/arm/mach-at91/bootstrap.c b/arch/arm/mach-at91/bootstrap.c
index 1baf7323fe..47e78965d9 100644
--- a/arch/arm/mach-at91/bootstrap.c
+++ b/arch/arm/mach-at91/bootstrap.c
@@ -51,7 +51,7 @@ static char* is_barebox_to_str(bool is_barebox)
static void at91bootstrap_boot_m25p80(bool is_barebox)
{
char *name = is_barebox_to_str(is_barebox);
- int (*func)(void) = NULL;
+ kernel_entry_func func = NULL;
func = bootstrap_board_read_m25p80();
printf("Boot %s from m25p80\n", name);
@@ -63,7 +63,7 @@ static void at91bootstrap_boot_m25p80(bool is_barebox)
static void at91bootstrap_boot_dataflash(bool is_barebox)
{
char *name = is_barebox_to_str(is_barebox);
- int (*func)(void) = NULL;
+ kernel_entry_func func = NULL;
printf("Boot %s from dataflash\n", name);
func = bootstrap_board_read_dataflash();
@@ -75,7 +75,7 @@ static void at91bootstrap_boot_dataflash(bool is_barebox)
static void at91bootstrap_boot_nand(bool is_barebox)
{
char *name = is_barebox_to_str(is_barebox);
- int (*func)(void) = NULL;
+ kernel_entry_func func = NULL;
printf("Boot %s from nand\n", name);
func = bootstrap_read_devfs("nand0", true, SZ_128K, SZ_256K, SZ_1M);
@@ -86,7 +86,7 @@ static void at91bootstrap_boot_nand(bool is_barebox)
static void at91bootstrap_boot_mmc(void)
{
- int (*func)(void) = NULL;
+ kernel_entry_func func = NULL;
printf("Boot from mmc\n");
func = bootstrap_read_disk("disk0.0", NULL);
diff --git a/arch/arm/mach-bcm2835/Kconfig b/arch/arm/mach-bcm2835/Kconfig
deleted file mode 100644
index 134ad9bb23..0000000000
--- a/arch/arm/mach-bcm2835/Kconfig
+++ /dev/null
@@ -1,15 +0,0 @@
-if ARCH_BCM2835
-
-config ARCH_TEXT_BASE
- hex
- default 0x04000000 if MACH_RPI
-
-choice
- prompt "Broadcom Board type"
-
-config MACH_RPI
- bool "RaspberryPi (BCM2835/ARM1176JZF-S)"
-
-endchoice
-
-endif
diff --git a/arch/arm/mach-bcm283x/Kconfig b/arch/arm/mach-bcm283x/Kconfig
new file mode 100644
index 0000000000..e861268627
--- /dev/null
+++ b/arch/arm/mach-bcm283x/Kconfig
@@ -0,0 +1,25 @@
+if ARCH_BCM283X
+
+config ARCH_TEXT_BASE
+ hex
+ default 0x04000000
+
+config MACH_RPI_COMMON
+ bool
+
+choice
+ prompt "Broadcom Board type"
+
+config MACH_RPI
+ bool "RaspberryPi (BCM2835/ARM1176JZF-S)"
+ depends on ARCH_BCM2835
+ select MACH_RPI_COMMON
+
+config MACH_RPI2
+ bool "RaspberryPi 2 (BCM2836/CORTEX-A7)"
+ depends on ARCH_BCM2836
+ select MACH_RPI_COMMON
+
+endchoice
+
+endif
diff --git a/arch/arm/mach-bcm2835/Makefile b/arch/arm/mach-bcm283x/Makefile
index 940f98cbce..940f98cbce 100644
--- a/arch/arm/mach-bcm2835/Makefile
+++ b/arch/arm/mach-bcm283x/Makefile
diff --git a/arch/arm/mach-bcm2835/core.c b/arch/arm/mach-bcm283x/core.c
index 64f3781388..64f3781388 100644
--- a/arch/arm/mach-bcm2835/core.c
+++ b/arch/arm/mach-bcm283x/core.c
diff --git a/arch/arm/mach-bcm2835/include/mach/core.h b/arch/arm/mach-bcm283x/include/mach/core.h
index 477ecb977c..b0bed80ea0 100644
--- a/arch/arm/mach-bcm2835/include/mach/core.h
+++ b/arch/arm/mach-bcm283x/include/mach/core.h
@@ -24,7 +24,7 @@ void bcm2835_add_device_sdram(u32 size);
static void inline bcm2835_register_mci(void)
{
add_generic_device("bcm2835_mci", 0, NULL, BCM2835_EMMC_BASE, 0xFC,
- IORESOURCE_MEM, NULL);
+ IORESOURCE_MEM, NULL);
}
static void inline bcm2835_register_fb(void)
diff --git a/arch/arm/mach-bcm2835/include/mach/debug_ll.h b/arch/arm/mach-bcm283x/include/mach/debug_ll.h
index be93cd95ad..be93cd95ad 100644
--- a/arch/arm/mach-bcm2835/include/mach/debug_ll.h
+++ b/arch/arm/mach-bcm283x/include/mach/debug_ll.h
diff --git a/arch/arm/mach-bcm2835/include/mach/mbox.h b/arch/arm/mach-bcm283x/include/mach/mbox.h
index 4c3fd775dd..cd9ee1f434 100644
--- a/arch/arm/mach-bcm2835/include/mach/mbox.h
+++ b/arch/arm/mach-bcm283x/include/mach/mbox.h
@@ -11,6 +11,8 @@
#include <common.h>
+#include <mach/platform.h>
+
/*
* The BCM2835 SoC contains (at least) two CPUs; the VideoCore (a/k/a "GPU")
* and the ARM CPU. The ARM CPU is often thought of as the main CPU.
@@ -40,7 +42,7 @@
/* Raw mailbox HW */
-#define BCM2835_MBOX_PHYSADDR 0x2000b880
+#define BCM2835_MBOX_PHYSADDR (BCM2835_ARM_BASE + 0x880)
struct bcm2835_mbox_regs {
u32 read;
@@ -74,7 +76,7 @@ struct bcm2835_mbox_hdr {
#define BCM2835_MBOX_RESP_CODE_SUCCESS 0x80000000
#define BCM2835_MBOX_STACK_ALIGN(type, name) \
- STACK_ALIGN_ARRAY(type, name, 1, BCM2835_CHAN_MASK + 1)
+ STACK_ALIGN_ARRAY(type, name, 1, BCM2835_CACHELINE_SIZE)
#define BCM2835_MBOX_INIT_HDR(_m_) { \
memset((_m_), 0, sizeof(*(_m_))); \
@@ -126,6 +128,9 @@ struct bcm2835_mbox_tag_hdr {
#define BCM2835_MBOX_TAG_GET_BOARD_REV 0x00010002
+/* RPi 2 */
+#define BCM2836_BOARD_REV_2_B 0x4
+
/*
* 0x2..0xf from:
* http://raspberryalphaomega.org.uk/2013/02/06/automatic-raspberry-pi-board-revision-detection-model-a-b1-and-b2/
diff --git a/arch/arm/mach-bcm2835/include/mach/platform.h b/arch/arm/mach-bcm283x/include/mach/platform.h
index e55085a75b..3b73831aa5 100644
--- a/arch/arm/mach-bcm2835/include/mach/platform.h
+++ b/arch/arm/mach-bcm283x/include/mach/platform.h
@@ -28,7 +28,16 @@
* This file is manually generated.
*/
+#ifdef CONFIG_ARCH_BCM2835
#define BCM2835_PERI_BASE 0x20000000
+#define BCM2835_CACHELINE_SIZE 32
+#elif defined CONFIG_ARCH_BCM2836
+#define BCM2835_PERI_BASE 0x3f000000
+#define BCM2835_CACHELINE_SIZE 64
+#else
+#error "no CONFIG_ARCH_BCM283X defined"
+#endif
+
#define BCM2835_ST_BASE (BCM2835_PERI_BASE + 0x3000) /* System Timer */
#define BCM2835_DMA_BASE (BCM2835_PERI_BASE + 0x7000) /* DMA controller */
#define BCM2835_ARM_BASE (BCM2835_PERI_BASE + 0xB000) /* BCM2708 ARM control block */
diff --git a/arch/arm/mach-bcm2835/include/mach/wd.h b/arch/arm/mach-bcm283x/include/mach/wd.h
index ad8b762d96..ad8b762d96 100644
--- a/arch/arm/mach-bcm2835/include/mach/wd.h
+++ b/arch/arm/mach-bcm283x/include/mach/wd.h
diff --git a/arch/arm/mach-bcm2835/mbox.c b/arch/arm/mach-bcm283x/mbox.c
index 9d69bc8ea7..9d69bc8ea7 100644
--- a/arch/arm/mach-bcm2835/mbox.c
+++ b/arch/arm/mach-bcm283x/mbox.c
diff --git a/arch/arm/mach-imx/ocotp.c b/arch/arm/mach-imx/ocotp.c
index 6ff5ee4efc..c99a003bb0 100644
--- a/arch/arm/mach-imx/ocotp.c
+++ b/arch/arm/mach-imx/ocotp.c
@@ -426,7 +426,6 @@ static int imx_ocotp_probe(struct device_d *dev)
cdev->priv = priv;
cdev->size = 192;
cdev->name = "imx-ocotp";
- cdev->device_node = dev->device_node;
ret = devfs_create(cdev);
diff --git a/arch/arm/mach-omap/include/mach/sys_info.h b/arch/arm/mach-omap/include/mach/sys_info.h
index fbac9b571f..e36f49df8a 100644
--- a/arch/arm/mach-omap/include/mach/sys_info.h
+++ b/arch/arm/mach-omap/include/mach/sys_info.h
@@ -90,7 +90,7 @@ u32 get_cpu_type(void);
u32 get_cpu_rev(void);
u32 get_sdr_cs_size(u32 offset);
u32 get_sdr_cs1_base(void);
-inline u32 get_sysboot_value(void);
+u32 get_sysboot_value(void);
u32 get_boot_type(void);
u32 get_device_type(void);
diff --git a/arch/arm/mach-omap/omap3_generic.c b/arch/arm/mach-omap/omap3_generic.c
index 5c29feaeb4..5327bad1aa 100644
--- a/arch/arm/mach-omap/omap3_generic.c
+++ b/arch/arm/mach-omap/omap3_generic.c
@@ -200,7 +200,7 @@ EXPORT_SYMBOL(get_sdr_cs1_base);
*
* @return - Return the value of SYSBOOT.
*/
-inline u32 get_sysboot_value(void)
+u32 get_sysboot_value(void)
{
return (0x0000003F & readl(OMAP3_CONTROL_REG(STATUS)));
}
diff --git a/arch/arm/mach-socfpga/generic.c b/arch/arm/mach-socfpga/generic.c
index 2d4afd0a7a..906bc63330 100644
--- a/arch/arm/mach-socfpga/generic.c
+++ b/arch/arm/mach-socfpga/generic.c
@@ -103,41 +103,3 @@ static int socfpga_init(void)
return 0;
}
core_initcall(socfpga_init);
-
-#if defined(CONFIG_ENV_HANDLING)
-#define ENV_PATH "/boot/barebox.env"
-static int socfpga_env_init(void)
-{
- struct stat s;
- char *diskdev, *partname;
- int ret;
-
- diskdev = "mmc0";
-
- device_detect_by_name(diskdev);
-
- partname = asprintf("/dev/%s.1", diskdev);
-
- ret = stat(partname, &s);
-
- if (ret) {
- pr_err("Failed to load environment: no device '%s'\n", diskdev);
- goto out_free;
- }
-
- mkdir("/boot", 0666);
- ret = mount(partname, "fat", "/boot", NULL);
- if (ret) {
- pr_err("Failed to load environment: mount %s failed (%d)\n", partname, ret);
- goto out_free;
- }
-
- pr_debug("Loading default env from %s on device %s\n", ENV_PATH, diskdev);
- default_environment_path_set(ENV_PATH);
-
-out_free:
- free(partname);
- return 0;
-}
-late_initcall(socfpga_env_init);
-#endif