summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/Kconfig12
-rw-r--r--arch/arm/Makefile1
-rw-r--r--arch/arm/boards/Makefile1
-rw-r--r--arch/arm/boards/module-mb7707/Makefile2
-rw-r--r--arch/arm/boards/module-mb7707/board.c43
-rw-r--r--arch/arm/boards/module-mb7707/lowlevel.c34
-rw-r--r--arch/arm/boards/module-mb7707/module-mb7707.dox29
-rw-r--r--arch/arm/configs/module-mb7707_defconfig49
-rw-r--r--arch/arm/dts/k1879hb1ya.dtsi37
-rw-r--r--arch/arm/dts/module-mb7707.dts24
-rw-r--r--arch/arm/mach-uemd/Kconfig16
-rw-r--r--arch/arm/mach-uemd/Makefile1
-rw-r--r--arch/arm/mach-uemd/include/mach/debug_ll.h42
-rw-r--r--arch/arm/mach-uemd/include/mach/hardware.h7
-rw-r--r--arch/arm/mach-uemd/reset.c24
-rw-r--r--drivers/clocksource/Kconfig4
-rw-r--r--drivers/clocksource/Makefile1
-rw-r--r--drivers/clocksource/uemd.c130
18 files changed, 457 insertions, 0 deletions
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 6e54c8f55a..8674a2d17c 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -194,6 +194,17 @@ config ARCH_TEGRA
select RELOCATABLE
select RESET_CONTROLLER
+config ARCH_UEMD
+ bool "RC Module UEMD Platform"
+ select CPU_ARM1176
+ select COMMON_CLK
+ select COMMON_CLK_OF_PROVIDER
+ select CLKDEV_LOOKUP
+ select OFDEVICE
+ select OFTREE
+ select CLOCKSOURCE_UEMD
+ select HAS_DEBUG_LL
+
config ARCH_ZYNQ
bool "Xilinx Zynq-based boards"
select HAS_DEBUG_LL
@@ -220,6 +231,7 @@ source arch/arm/mach-socfpga/Kconfig
source arch/arm/mach-versatile/Kconfig
source arch/arm/mach-vexpress/Kconfig
source arch/arm/mach-tegra/Kconfig
+source arch/arm/mach-uemd/Kconfig
source arch/arm/mach-zynq/Kconfig
config ARM_ASM_UNIFIED
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index c5769991fd..64db73c62e 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -70,6 +70,7 @@ machine-$(CONFIG_ARCH_SOCFPGA) := socfpga
machine-$(CONFIG_ARCH_VERSATILE) := versatile
machine-$(CONFIG_ARCH_VEXPRESS) := vexpress
machine-$(CONFIG_ARCH_TEGRA) := tegra
+machine-$(CONFIG_ARCH_UEMD) := uemd
machine-$(CONFIG_ARCH_ZYNQ) := zynq
diff --git a/arch/arm/boards/Makefile b/arch/arm/boards/Makefile
index 15d20bee3d..be03e9b32e 100644
--- a/arch/arm/boards/Makefile
+++ b/arch/arm/boards/Makefile
@@ -48,6 +48,7 @@ obj-$(CONFIG_MACH_HIGHBANK) += highbank/
obj-$(CONFIG_MACH_IMX21ADS) += freescale-mx21-ads/
obj-$(CONFIG_MACH_IMX233_OLINUXINO) += imx233-olinuxino/
obj-$(CONFIG_MACH_IMX27ADS) += freescale-mx27-ads/
+obj-$(CONFIG_MACH_MB7707) += module-mb7707/
obj-$(CONFIG_MACH_MIOA701) += mioa701/
obj-$(CONFIG_MACH_MMCCPU) += mmccpu/
obj-$(CONFIG_MACH_MX23EVK) += freescale-mx23-evk/
diff --git a/arch/arm/boards/module-mb7707/Makefile b/arch/arm/boards/module-mb7707/Makefile
new file mode 100644
index 0000000000..01c7a259e9
--- /dev/null
+++ b/arch/arm/boards/module-mb7707/Makefile
@@ -0,0 +1,2 @@
+obj-y += board.o
+lwl-y += lowlevel.o
diff --git a/arch/arm/boards/module-mb7707/board.c b/arch/arm/boards/module-mb7707/board.c
new file mode 100644
index 0000000000..7ffad6e62a
--- /dev/null
+++ b/arch/arm/boards/module-mb7707/board.c
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2014 Antony Pavlov <antonynpavlov@gmail.com>
+ *
+ * This file is part of barebox.
+ * 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 <init.h>
+#include <driver.h>
+#include <usb/ehci.h>
+#include <mach/hardware.h>
+
+static int hostname_init(void)
+{
+ barebox_set_hostname("mb7707");
+
+ return 0;
+}
+core_initcall(hostname_init);
+
+static struct ehci_platform_data ehci_pdata = {
+ .flags = 0,
+};
+
+static int mb7707_devices_init(void)
+{
+ add_usb_ehci_device(DEVICE_ID_DYNAMIC, UEMD_EHCI_BASE,
+ UEMD_EHCI_BASE + 0x10, &ehci_pdata);
+
+ return 0;
+}
+device_initcall(mb7707_devices_init);
diff --git a/arch/arm/boards/module-mb7707/lowlevel.c b/arch/arm/boards/module-mb7707/lowlevel.c
new file mode 100644
index 0000000000..5f5e1d7af1
--- /dev/null
+++ b/arch/arm/boards/module-mb7707/lowlevel.c
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2014 Antony Pavlov <antonynpavlov@gmail.com>
+ *
+ * This file is part of barebox.
+ * 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.
+ *
+ */
+
+#define __LOWLEVEL_INIT__
+
+#include <common.h>
+#include <asm/barebox-arm.h>
+#include <asm/barebox-arm-head.h>
+#include <init.h>
+#include <sizes.h>
+
+#define MB7707_SRAM_BASE 0x40000000
+#define MB7707_SRAM_SIZE SZ_128M
+
+void __naked __bare_init barebox_arm_reset_vector(void)
+{
+ arm_cpu_lowlevel_init();
+
+ barebox_arm_entry(MB7707_SRAM_BASE, MB7707_SRAM_SIZE, 0);
+}
diff --git a/arch/arm/boards/module-mb7707/module-mb7707.dox b/arch/arm/boards/module-mb7707/module-mb7707.dox
new file mode 100644
index 0000000000..c0dbc8a602
--- /dev/null
+++ b/arch/arm/boards/module-mb7707/module-mb7707.dox
@@ -0,0 +1,29 @@
+/** @page module-mb7707 MB 77.07 board
+
+The board uses MBOOT as bootloader.
+
+Barebox mini-howto:
+
+1. Connect to the boards's UART (38400 8N1);
+
+2. Turn board's power on;
+
+3. Wait 'Hit any key (in 2 sec) to skip autoload...' prompt and press the space key;
+
+4. Compile zbarebox.bin image and upload it to the board via tftp
+@verbatim
+ MBOOT # tftpboot zbarebox.bin
+ greth: greth_halt
+ TFTP Using GRETH_10/100 device
+ TFTP params: server 192.168.0.1 our_ip 192.168.0.7
+ TFTP params: filename 'zbarebox.bin' load_address 0x40100000
+ TFTP Loading: ################
+ TFTP done
+@endverbatim
+
+5. Run barebox
+@verbatim
+ MBOOT # go 0x40100000
+@endverbatim
+
+*/
diff --git a/arch/arm/configs/module-mb7707_defconfig b/arch/arm/configs/module-mb7707_defconfig
new file mode 100644
index 0000000000..9a4f1d1cb6
--- /dev/null
+++ b/arch/arm/configs/module-mb7707_defconfig
@@ -0,0 +1,49 @@
+CONFIG_BUILTIN_DTB=y
+CONFIG_BUILTIN_DTB_NAME="module-mb7707"
+CONFIG_ARCH_UEMD=y
+CONFIG_AEABI=y
+CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y
+CONFIG_PBL_IMAGE=y
+CONFIG_PBL_RELOCATABLE=y
+CONFIG_MALLOC_TLSF=y
+CONFIG_PROMPT="MB 77.07: "
+CONFIG_BAUDRATE=38400
+CONFIG_GLOB=y
+CONFIG_HUSH_FANCY_PROMPT=y
+CONFIG_CMDLINE_EDITING=y
+CONFIG_AUTO_COMPLETE=y
+CONFIG_MENU=y
+CONFIG_PASSWORD=y
+CONFIG_LONGHELP=y
+CONFIG_CMD_IOMEM=y
+CONFIG_CMD_MEMINFO=y
+# CONFIG_CMD_BOOTM is not set
+# CONFIG_CMD_BOOTU is not set
+CONFIG_CMD_GO=y
+CONFIG_CMD_LOADB=y
+CONFIG_CMD_LOADY=y
+CONFIG_CMD_RESET=y
+# CONFIG_CMD_MOUNT is not set
+# CONFIG_CMD_UMOUNT is not set
+CONFIG_CMD_EXPORT=y
+CONFIG_CMD_PRINTENV=y
+CONFIG_CMD_UNCOMPRESS=y
+CONFIG_CMD_SLEEP=y
+CONFIG_CMD_ECHO_E=y
+CONFIG_CMD_EDIT=y
+CONFIG_CMD_READLINE=y
+CONFIG_CMD_MM=y
+CONFIG_CMD_CLK=y
+CONFIG_CMD_OF_NODE=y
+CONFIG_CMD_OF_PROPERTY=y
+CONFIG_CMD_OFTREE=y
+CONFIG_CMD_TIME=y
+CONFIG_OF_BAREBOX_DRIVERS=y
+CONFIG_DRIVER_SERIAL_NS16550=y
+# CONFIG_SPI is not set
+CONFIG_USB=y
+CONFIG_USB_EHCI=y
+CONFIG_USB_STORAGE=y
+CONFIG_CLOCKSOURCE_DUMMY=y
+CONFIG_SHA1=y
+CONFIG_SHA256=y
diff --git a/arch/arm/dts/k1879hb1ya.dtsi b/arch/arm/dts/k1879hb1ya.dtsi
new file mode 100644
index 0000000000..83ba7fb399
--- /dev/null
+++ b/arch/arm/dts/k1879hb1ya.dtsi
@@ -0,0 +1,37 @@
+#include "skeleton.dtsi"
+
+/ {
+ soc {
+ compatible = "simple-bus";
+ model = "RC Module K1879HB1YA";
+ #address-cells = <1>;
+ #size-cells = <1>;
+ ranges;
+
+ /*
+ * Actually clk_apb is not a fixed-clock at all.
+ * clk_apb is a derivated clock, but for the moment
+ * there is no public documentation on k1879hb1ya
+ * so we can't describe it correctly.
+ */
+ clk_apb: clock@0 {
+ compatible = "fixed-clock";
+ #clock-cells = <0>;
+ };
+
+ serial0: serial@2002b000 {
+ compatible = "ns16550a";
+ reg = <0x2002b000 0x1000>;
+ reg-shift = <2>;
+ clocks = <&clk_apb 0>;
+ status = "disabled";
+ };
+
+ timer0: timer@20024000 {
+ compatible = "module,uemd-timer";
+ reg = <0x20024000 0x20>;
+ clocks = <&clk_apb 0>;
+ status = "disabled";
+ };
+ };
+};
diff --git a/arch/arm/dts/module-mb7707.dts b/arch/arm/dts/module-mb7707.dts
new file mode 100644
index 0000000000..94a3373fc1
--- /dev/null
+++ b/arch/arm/dts/module-mb7707.dts
@@ -0,0 +1,24 @@
+/dts-v1/;
+
+#include "k1879hb1ya.dtsi"
+
+/ {
+ model = "Module MB 77.07";
+ compatible = "module,mb7707";
+
+ memory {
+ reg = <0x40000000 0x8000000>;
+ };
+};
+
+&clk_apb {
+ clock-frequency = <54000000>;
+};
+
+&serial0 {
+ status = "okay";
+};
+
+&timer0 {
+ status = "okay";
+};
diff --git a/arch/arm/mach-uemd/Kconfig b/arch/arm/mach-uemd/Kconfig
new file mode 100644
index 0000000000..aedd7574ac
--- /dev/null
+++ b/arch/arm/mach-uemd/Kconfig
@@ -0,0 +1,16 @@
+if ARCH_UEMD
+
+config ARCH_TEXT_BASE
+ hex
+ default 0x40800000
+
+choice
+ prompt "UEMD Board type"
+
+config MACH_MB7707
+ bool "MB7707"
+ select HAVE_DEFAULT_ENVIRONMENT_NEW
+
+endchoice
+
+endif
diff --git a/arch/arm/mach-uemd/Makefile b/arch/arm/mach-uemd/Makefile
new file mode 100644
index 0000000000..f3cc6684b8
--- /dev/null
+++ b/arch/arm/mach-uemd/Makefile
@@ -0,0 +1 @@
+obj-y += reset.o
diff --git a/arch/arm/mach-uemd/include/mach/debug_ll.h b/arch/arm/mach-uemd/include/mach/debug_ll.h
new file mode 100644
index 0000000000..ce182446b0
--- /dev/null
+++ b/arch/arm/mach-uemd/include/mach/debug_ll.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2014 Antony Pavlov <antonynpavlov@gmail.com>
+ *
+ * This file is part of barebox.
+ * 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.
+ *
+ */
+
+/** @file
+ * This File contains declaration for early output support
+ */
+#ifndef __INCLUDE_ARCH_DEBUG_LL_H__
+#define __INCLUDE_ARCH_DEBUG_LL_H__
+
+#include <asm/io.h>
+#include <mach/hardware.h>
+
+#define DEBUG_LL_UART_ADDR UEMD_UART0_BASE
+#define DEBUG_LL_UART_RSHFT 2
+
+#define rbr (0 << DEBUG_LL_UART_RSHFT)
+#define lsr (5 << DEBUG_LL_UART_RSHFT)
+#define LSR_THRE 0x20 /* Xmit holding register empty */
+
+static inline void PUTC_LL(char ch)
+{
+ while (!(__raw_readb(DEBUG_LL_UART_ADDR + lsr) & LSR_THRE))
+ ;
+
+ __raw_writeb(ch, DEBUG_LL_UART_ADDR + rbr);
+}
+
+#endif /* __INCLUDE_ARCH_DEBUG_LL_H__ */
diff --git a/arch/arm/mach-uemd/include/mach/hardware.h b/arch/arm/mach-uemd/include/mach/hardware.h
new file mode 100644
index 0000000000..2311ebf1cd
--- /dev/null
+++ b/arch/arm/mach-uemd/include/mach/hardware.h
@@ -0,0 +1,7 @@
+#ifndef __ASM_ARCH_HARDWARE_H
+#define __ASM_ARCH_HARDWARE_H
+
+#define UEMD_EHCI_BASE 0x10040000
+#define UEMD_UART0_BASE 0x2002b000
+
+#endif /* __ASM_ARCH_HARDWARE_H */
diff --git a/arch/arm/mach-uemd/reset.c b/arch/arm/mach-uemd/reset.c
new file mode 100644
index 0000000000..00ae0be0b3
--- /dev/null
+++ b/arch/arm/mach-uemd/reset.c
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2014 Antony Pavlov <antonynpavlov@gmail.com>
+ *
+ * This file is part of barebox.
+ * 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>
+
+void __noreturn reset_cpu(ulong addr)
+{
+ hang();
+}
+EXPORT_SYMBOL(reset_cpu);
diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig
index 43974f03c2..c1480ceaaf 100644
--- a/drivers/clocksource/Kconfig
+++ b/drivers/clocksource/Kconfig
@@ -48,3 +48,7 @@ config CLOCKSOURCE_NOMADIK
config CLOCKSOURCE_ORION
bool
depends on ARCH_MVEBU
+
+config CLOCKSOURCE_UEMD
+ bool
+ depends on ARCH_UEMD
diff --git a/drivers/clocksource/Makefile b/drivers/clocksource/Makefile
index 834a15d1e9..97c0288aaa 100644
--- a/drivers/clocksource/Makefile
+++ b/drivers/clocksource/Makefile
@@ -6,3 +6,4 @@ obj-$(CONFIG_CLOCKSOURCE_DUMMY) += dummy.o
obj-$(CONFIG_CLOCKSOURCE_MVEBU) += mvebu.o
obj-$(CONFIG_CLOCKSOURCE_NOMADIK) += nomadik.o
obj-$(CONFIG_CLOCKSOURCE_ORION) += orion.o
+obj-$(CONFIG_CLOCKSOURCE_UEMD) += uemd.o
diff --git a/drivers/clocksource/uemd.c b/drivers/clocksource/uemd.c
new file mode 100644
index 0000000000..2ea455edfa
--- /dev/null
+++ b/drivers/clocksource/uemd.c
@@ -0,0 +1,130 @@
+/*
+ * Copyright (C) 2014 Antony Pavlov <antonynpavlov@gmail.com>
+ *
+ * Based on
+ * https://github.com/RC-MODULE/linux-3.10.x/tree/k1879-3.10.28/arch/arm/mach-uemd/clocksource.c
+ * (C) 2011 RC Module, Sergey Mironov <ierton@gmail.com>
+ *
+ * This file is part of barebox.
+ * 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 <io.h>
+#include <init.h>
+#include <linux/bitops.h>
+#include <linux/clk.h>
+#include <clock.h>
+
+#define TIMER_LOAD 0x00
+#define TIMER_VALUE 0x04
+#define TIMER_CONTROL 0x08
+
+#define TIMER_CTRL_ENABLE BIT(7)
+
+/*
+ * TIMER_CONTROL_PERIODIC:
+ * The counter generates an interrupt at a constant interval,
+ * reloading the original value after wrapping past zero.
+ */
+#define TIMER_CTRL_PERIODIC BIT(6)
+
+/* interrupt enable */
+#define TIMER_CTRL_IE BIT(5)
+
+/* Prescalers */
+#define TIMER_CTRL_P1 (0 << 2)
+#define TIMER_CTRL_P16 (1 << 2)
+#define TIMER_CTRL_P256 (2 << 2)
+
+/* Counter register size is 32 Bit long */
+#define TIMER_CTRL_32BIT BIT(1)
+
+static void __iomem *timer_base;
+
+static uint64_t uemd_timer_cs_read(void)
+{
+ /* Down counter! */
+ return ~__raw_readl(timer_base + TIMER_VALUE);
+}
+
+static struct clocksource uemd_cs = {
+ .read = uemd_timer_cs_read,
+ .mask = CLOCKSOURCE_MASK(32),
+};
+
+static int uemd_timer_probe(struct device_d *dev)
+{
+ int mode;
+ struct clk *timer_clk;
+
+ /* use only one timer */
+ if (timer_base)
+ return -EBUSY;
+
+ timer_base = dev_request_mem_region(dev, 0);
+ if (!timer_base) {
+ dev_err(dev, "could not get memory region\n");
+ return -ENODEV;
+ }
+
+ timer_clk = clk_get(dev, NULL);
+ if (IS_ERR(timer_clk)) {
+ int ret = PTR_ERR(timer_clk);
+ dev_err(dev, "clock not found: %d\n", ret);
+ return ret;
+ }
+
+ /* Stop timer */
+ __raw_writel(0, timer_base + TIMER_CONTROL);
+
+ /* Setup */
+ __raw_writel(0xffffffff, timer_base + TIMER_LOAD);
+ __raw_writel(0xffffffff, timer_base + TIMER_VALUE);
+
+ mode = TIMER_CTRL_32BIT |
+ TIMER_CTRL_PERIODIC |
+ TIMER_CTRL_P1;
+ __raw_writel(mode, timer_base + TIMER_CONTROL);
+
+ /* Fire it up! */
+ mode |= TIMER_CTRL_ENABLE;
+ __raw_writel(mode, timer_base + TIMER_CONTROL);
+
+ clocks_calc_mult_shift(&uemd_cs.mult, &uemd_cs.shift,
+ clk_get_rate(timer_clk), NSEC_PER_SEC, 10);
+
+ init_clock(&uemd_cs);
+
+ return 0;
+}
+
+static __maybe_unused struct of_device_id uemd_timer_dt_ids[] = {
+ {
+ .compatible = "module,uemd-timer",
+ }, {
+ /* sentinel */
+ }
+};
+
+static struct driver_d uemd_timer_driver = {
+ .probe = uemd_timer_probe,
+ .name = "uemd-timer",
+ .of_compatible = DRV_OF_COMPAT(uemd_timer_dt_ids),
+};
+
+static int uemd_timer_init(void)
+{
+ return platform_driver_register(&uemd_timer_driver);
+}
+coredevice_initcall(uemd_timer_init);