[PATCH v2 18/18] ARM: Rockchip: Add documentation

2015-03-04 Thread Andrey Panov
Signed-off-by: Andrey Panov 
---
 Documentation/boards/rockchip.rst | 47 +++
 1 file changed, 47 insertions(+)
 create mode 100644 Documentation/boards/rockchip.rst

diff --git a/Documentation/boards/rockchip.rst 
b/Documentation/boards/rockchip.rst
new file mode 100644
index 000..a5599c6
--- /dev/null
+++ b/Documentation/boards/rockchip.rst
@@ -0,0 +1,47 @@
+Rockchip RK3188
+===
+
+Radxa Rock
+--
+
+Radxa Rock is a small SBC based on Rockchip RK3188 SoC.
+See http://radxa.com/Rock for additional information.
+
+Building
+
+
+.. code-block:: sh
+
+  make ARCH=arm radxa_rock_defconfig
+  make ARCH=arm
+
+Creating bootable SD card
+^
+
+This will require a DRAM setup blob and additional utilities, see above.
+
+Card layout (block == 0x200 bytes).
+
+   ==
+Block Number   Name
+   ==
+0x DOS partition table
+0x0040 RK bootinfo (BootROM check sector)
+0x0044 DRAM setup routine
+0x005C Bootloader (barebox)
+0x0400 Barebox environment
+0x0800 Free space start
+   ==
+
+Instructions.
+
+* Make 2 partitions on SD for boot and root filesystems.
+* Checkout and compile https://github.com/apxii/rkboottools
+* Get some RK3188 bootloader from 
https://github.com/neo-technologies/rockchip-bootloader
+* Run "rk-splitboot RK3188Loader(L)_V2.13.bin" command. (for example).
+  You will get FlashData file with others. It's a DRAM setup blob.
+* Otherwise it can be borrowed from RK U-boot sources from
+  
https://github.com/linux-rockchip/u-boot-rockchip/blob/u-boot-rk3188/tools/rk_tools/3188_LPDDR2_300MHz_DDR3_300MHz_20130830.bin
+* Run "rk-makebootable FlashData barebox-radxa-rock.bin rrboot.bin"
+* Insert SD card and run "dd if=rrboot.bin of= bs=$((0x200)) 
seek=$((0x40))"
+* SD card is ready
-- 
2.1.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Barebox drops into shell immediately, without waiting for key (next branch)

2015-03-04 Thread Панов Андрей
Hello!

I've discovered that on recent next commit 
"acc69bdddc50262b8f91034c248279d8dc734284 defaultenv-2: init: don't call 
timeout again if the user intervened"
caused barebox to enter shell without asking for pressing a key.
On Radxa Rock board. It's just me?

--
 Андрей

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2 09/18] CLK: Add helper defines to barebox-wrapper.h for easier porting of drivers from Linux kernel

2015-03-04 Thread Andrey Panov
Signed-off-by: Andrey Panov 
---
 include/linux/barebox-wrapper.h | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/include/linux/barebox-wrapper.h b/include/linux/barebox-wrapper.h
index d34d1d1..3859185 100644
--- a/include/linux/barebox-wrapper.h
+++ b/include/linux/barebox-wrapper.h
@@ -73,4 +73,10 @@ typedef int irqreturn_t;
 #define IRQ_NONE 0
 #define IRQ_HANDLED 0
 
+/* To ease clk drivers porting from Linux kernel */
+#define __clk_get_name(clk)(clk->name)
+#define __clk_lookup   clk_lookup
+#define __clk_get_rate clk_get_rate
+#define __clk_get_parent   clk_get_parent
+
 #endif /* __INCLUDE_LINUX_BAREBOX_WRAPPER_H */
-- 
2.1.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2 05/18] CLK: clk-divider: Respect CLK_DIVIDER_HIWORD_MASK flag

2015-03-04 Thread Andrey Panov
It is required for Rockchip SoCs where clock settings registers have
write-enable mask in high word.

Signed-off-by: Andrey Panov 
---
 drivers/clk/clk-divider.c | 4 
 include/linux/clk.h   | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c
index 506a966..eb48334 100644
--- a/drivers/clk/clk-divider.c
+++ b/drivers/clk/clk-divider.c
@@ -197,6 +197,10 @@ static int clk_divider_set_rate(struct clk *clk, unsigned 
long rate,
val = readl(divider->reg);
val &= ~(div_mask(divider) << divider->shift);
val |= value << divider->shift;
+
+   if (clk->flags & CLK_DIVIDER_HIWORD_MASK)
+   val |= div_mask(divider) << (divider->shift + 16);
+
writel(val, divider->reg);
 
return 0;
diff --git a/include/linux/clk.h b/include/linux/clk.h
index 89cb44e..258bbe3 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -248,6 +248,8 @@ struct clk_divider {
int table_size;
 };
 
+#define CLK_DIVIDER_HIWORD_MASK(1 << 3)
+
 #define CLK_MUX_HIWORD_MASK(1 << 2)
 
 extern struct clk_ops clk_divider_ops;
-- 
2.1.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2 16/18] ARM: Rockchip: Update Radxa Rock board

2015-03-04 Thread Andrey Panov
Signed-off-by: Andrey Panov 
---
 arch/arm/boards/radxa-rock/board.c | 35 ++
 arch/arm/boards/radxa-rock/env/boot/mshc1  |  9 +++
 arch/arm/boards/radxa-rock/env/boot/mshc1-old  |  8 ++
 arch/arm/boards/radxa-rock/env/init/bootsource |  7 ++
 arch/arm/boards/radxa-rock/env/nv/hostname |  1 +
 5 files changed, 32 insertions(+), 28 deletions(-)
 create mode 100644 arch/arm/boards/radxa-rock/env/boot/mshc1
 create mode 100644 arch/arm/boards/radxa-rock/env/boot/mshc1-old
 create mode 100644 arch/arm/boards/radxa-rock/env/init/bootsource
 create mode 100644 arch/arm/boards/radxa-rock/env/nv/hostname

diff --git a/arch/arm/boards/radxa-rock/board.c 
b/arch/arm/boards/radxa-rock/board.c
index 3d9b5be..ec053f9 100644
--- a/arch/arm/boards/radxa-rock/board.c
+++ b/arch/arm/boards/radxa-rock/board.c
@@ -16,8 +16,9 @@
 #include 
 #include 
 #include 
-#include 
+#include 
 #include 
+#include 
 
 static struct i2c_board_info radxa_rock_i2c_devices[] = {
{
@@ -43,20 +44,6 @@ static void radxa_rock_pmic_init(void)
act8846_set_bits(pmic, ACT8846_LDO9_CTRL, BIT(7), BIT(7));
 }
 
-static int setup_plls(void)
-{
-   if (!of_machine_is_compatible("radxa,rock"))
-   return 0;
-
-   /* Codec PLL frequency: 594 MHz */
-   rk3188_pll_set_parameters(RK3188_CPLL, 2, 198, 4);
-   /* General PLL frequency: 300 MHz */
-   rk3188_pll_set_parameters(RK3188_GPLL, 1, 50, 4);
-
-   return 0;
-}
-coredevice_initcall(setup_plls);
-
 static int devices_init(void)
 {
if (!of_machine_is_compatible("radxa,rock"))
@@ -68,20 +55,12 @@ static int devices_init(void)
 
radxa_rock_pmic_init();
 
-   /* Set mac_pll divisor to 6 (50MHz output) */
-   writel((5 << 8) | (0x1f << 24), 0x2098);
+   armlinux_set_architecture(3066);
 
-   return 0;
-}
-device_initcall(devices_init);
-
-static int hostname_init(void)
-{
-   if (!of_machine_is_compatible("radxa,rock"))
-   return 0;
-
-   barebox_set_hostname("radxa-rock");
+   /* Map SRAM to address 0, kernel relies on this */
+   writel((RK_SOC_CON0_REMAP << 16) | RK_SOC_CON0_REMAP,
+   RK_GRF_BASE + RK_GRF_SOC_CON0);
 
return 0;
 }
-postcore_initcall(hostname_init);
+device_initcall(devices_init);
diff --git a/arch/arm/boards/radxa-rock/env/boot/mshc1 
b/arch/arm/boards/radxa-rock/env/boot/mshc1
new file mode 100644
index 000..964b6cc
--- /dev/null
+++ b/arch/arm/boards/radxa-rock/env/boot/mshc1
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+mount /dev/mshc1.0
+
+oftree -f
+oftree -l /mnt/mshc1.0/rk3188-radxarock.dtb
+
+global.bootm.image=/mnt/mshc1.0/zImage
+global.linux.bootargs.dyn.root="root=/dev/mmcblk0p2 rootwait"
diff --git a/arch/arm/boards/radxa-rock/env/boot/mshc1-old 
b/arch/arm/boards/radxa-rock/env/boot/mshc1-old
new file mode 100644
index 000..1e1b577
--- /dev/null
+++ b/arch/arm/boards/radxa-rock/env/boot/mshc1-old
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+mount /dev/mshc1.0
+
+oftree -f
+
+global.bootm.image=/mnt/mshc1.0/zImage-old
+global.linux.bootargs.dyn.root="root=/dev/mmcblk0p2 rootwait"
diff --git a/arch/arm/boards/radxa-rock/env/init/bootsource 
b/arch/arm/boards/radxa-rock/env/init/bootsource
new file mode 100644
index 000..4e8299b
--- /dev/null
+++ b/arch/arm/boards/radxa-rock/env/init/bootsource
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+if [ -n "$nv.boot.default" ]; then
+   exit
+fi
+
+global.boot.default=mshc1
diff --git a/arch/arm/boards/radxa-rock/env/nv/hostname 
b/arch/arm/boards/radxa-rock/env/nv/hostname
new file mode 100644
index 000..16523ac
--- /dev/null
+++ b/arch/arm/boards/radxa-rock/env/nv/hostname
@@ -0,0 +1 @@
+radxa-rock
-- 
2.1.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2 03/18] CLK: Add fractional divider clock support from Linux kernel

2015-03-04 Thread Andrey Panov
Signed-off-by: Andrey Panov 
---
 drivers/clk/Makefile |   3 +-
 drivers/clk/clk-fractional-divider.c | 152 +++
 include/linux/clk.h  |   9 +++
 3 files changed, 163 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/clk-fractional-divider.c

diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index 9df98c8..47ed7b1 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -1,5 +1,6 @@
 obj-$(CONFIG_COMMON_CLK)   += clk.o clk-fixed.o clk-divider.o 
clk-fixed-factor.o \
-   clk-mux.o clk-gate.o clk-composite.o
+   clk-mux.o clk-gate.o clk-composite.o \
+   clk-fractional-divider.o
 obj-$(CONFIG_CLKDEV_LOOKUP)+= clkdev.o
 
 obj-$(CONFIG_ARCH_MVEBU)   += mvebu/
diff --git a/drivers/clk/clk-fractional-divider.c 
b/drivers/clk/clk-fractional-divider.c
new file mode 100644
index 000..59b98aa
--- /dev/null
+++ b/drivers/clk/clk-fractional-divider.c
@@ -0,0 +1,152 @@
+/*
+ * Copyright (C) 2014 Intel Corporation
+ *
+ * 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.
+ *
+ * Adjustable fractional divider clock implementation.
+ * Output rate = (m / n) * parent_rate.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define to_clk_fd(_hw) container_of(_hw, struct clk_fractional_divider, clk)
+
+struct clk_fractional_divider {
+   struct clk  clk;
+   void __iomem*reg;
+   u8  mshift;
+   u32 mmask;
+   u8  nshift;
+   u32 nmask;
+   u8  flags;
+};
+
+static unsigned long clk_fd_recalc_rate(struct clk *hw,
+   unsigned long parent_rate)
+{
+   struct clk_fractional_divider *fd = to_clk_fd(hw);
+   u32 val, m, n;
+   u64 ret;
+
+   val = readl(fd->reg);
+
+   m = (val & fd->mmask) >> fd->mshift;
+   n = (val & fd->nmask) >> fd->nshift;
+
+   ret = (u64)parent_rate * m;
+   do_div(ret, n);
+
+   return ret;
+}
+
+static long clk_fd_round_rate(struct clk *hw, unsigned long rate,
+ unsigned long *prate)
+{
+   struct clk_fractional_divider *fd = to_clk_fd(hw);
+   unsigned maxn = (fd->nmask >> fd->nshift) + 1;
+   unsigned div;
+
+   if (!rate || rate >= *prate)
+   return *prate;
+
+   div = gcd(*prate, rate);
+
+   while ((*prate / div) > maxn) {
+   div <<= 1;
+   rate <<= 1;
+   }
+
+   return rate;
+}
+
+static int clk_fd_set_rate(struct clk *hw, unsigned long rate,
+  unsigned long parent_rate)
+{
+   struct clk_fractional_divider *fd = to_clk_fd(hw);
+   unsigned long div;
+   unsigned n, m;
+   u32 val;
+
+   div = gcd(parent_rate, rate);
+   m = rate / div;
+   n = parent_rate / div;
+
+   val = readl(fd->reg);
+   val &= ~(fd->mmask | fd->nmask);
+   val |= (m << fd->mshift) | (n << fd->nshift);
+   writel(val, fd->reg);
+
+   return 0;
+}
+
+const struct clk_ops clk_fractional_divider_ops = {
+   .recalc_rate = clk_fd_recalc_rate,
+   .round_rate = clk_fd_round_rate,
+   .set_rate = clk_fd_set_rate,
+};
+EXPORT_SYMBOL_GPL(clk_fractional_divider_ops);
+
+struct clk *clk_fractional_divider_alloc(
+   const char *name, const char *parent_name, unsigned long flags,
+   void __iomem *reg, u8 mshift, u8 mwidth, u8 nshift, u8 nwidth,
+   u8 clk_divider_flags)
+{
+   struct clk_fractional_divider *fd;
+
+   fd = xzalloc(sizeof(*fd));
+
+   fd->reg = reg;
+   fd->mshift = mshift;
+   fd->mmask = (BIT(mwidth) - 1) << mshift;
+   fd->nshift = nshift;
+   fd->nmask = (BIT(nwidth) - 1) << nshift;
+   fd->flags = clk_divider_flags;
+   fd->clk.name = name;
+   fd->clk.ops = &clk_fractional_divider_ops;
+   fd->clk.flags = flags;
+   fd->clk.parent_names = parent_name ? &parent_name : NULL;
+   fd->clk.num_parents = parent_name ? 1 : 0;
+
+   return &fd->clk;
+}
+
+void clk_fractional_divider_free(struct clk *clk_fd)
+{
+   struct clk_fractional_divider *fd = to_clk_fd(clk_fd);
+
+   free(fd);
+}
+
+struct clk *clk_fractional_divider(
+   const char *name, const char *parent_name, unsigned long flags,
+   void __iomem *reg, u8 mshift, u8 mwidth, u8 nshift, u8 nwidth,
+   u8 clk_divider_flags)
+{
+   struct clk *fd;
+   int ret;
+
+   fd = clk_fractional_divider_alloc(name, parent_name, flags,
+   reg, mshift, mwidth, nshift, nwidth,
+   clk_divider_flags);
+
+   if (IS_ERR(fd))
+   return fd;
+
+   ret = clk_register(fd);
+   i

[PATCH v2 14/18] ARM: Rockchip: Update clk driver from Linux kernel for use with newer DTS

2015-03-04 Thread Andrey Panov
Signed-off-by: Andrey Panov 
---
 drivers/clk/rockchip/Makefile   |   2 +-
 drivers/clk/rockchip/clk-cpu.c  | 160 +++
 drivers/clk/rockchip/clk-pll.c  | 368 +++
 drivers/clk/rockchip/clk-rk3188.c   | 872 
 drivers/clk/rockchip/clk-rockchip.c |  86 
 drivers/clk/rockchip/clk.c  | 279 
 drivers/clk/rockchip/clk.h  | 416 +
 include/init.h  |   1 +
 8 files changed, 2097 insertions(+), 87 deletions(-)
 create mode 100644 drivers/clk/rockchip/clk-cpu.c
 create mode 100644 drivers/clk/rockchip/clk-pll.c
 create mode 100644 drivers/clk/rockchip/clk-rk3188.c
 delete mode 100644 drivers/clk/rockchip/clk-rockchip.c
 create mode 100644 drivers/clk/rockchip/clk.c
 create mode 100644 drivers/clk/rockchip/clk.h

diff --git a/drivers/clk/rockchip/Makefile b/drivers/clk/rockchip/Makefile
index 1c5271f..865542a 100644
--- a/drivers/clk/rockchip/Makefile
+++ b/drivers/clk/rockchip/Makefile
@@ -1 +1 @@
-obj-y += clk-rockchip.o
\ No newline at end of file
+obj-y += clk-cpu.o clk-pll.o clk-rk3188.o clk.o
diff --git a/drivers/clk/rockchip/clk-cpu.c b/drivers/clk/rockchip/clk-cpu.c
new file mode 100644
index 000..226b819
--- /dev/null
+++ b/drivers/clk/rockchip/clk-cpu.c
@@ -0,0 +1,160 @@
+/*
+ * Copyright (c) 2014 MundoReader S.L.
+ * Author: Heiko Stuebner 
+ *
+ * based on clk/samsung/clk-cpu.c
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Author: Thomas Abraham 
+ *
+ * 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.
+ *
+ * A CPU clock is defined as a clock supplied to a CPU or a group of CPUs.
+ * The CPU clock is typically derived from a hierarchy of clock
+ * blocks which includes mux and divider blocks. There are a number of other
+ * auxiliary clocks supplied to the CPU domain such as the debug blocks and AXI
+ * clock for CPU domain. The rates of these auxiliary clocks are related to the
+ * CPU clock rate and this relation is usually specified in the hardware manual
+ * of the SoC or supplied after the SoC characterization.
+ *
+ * The below implementation of the CPU clock allows the rate changes of the CPU
+ * clock and the corresponding rate changes of the auxillary clocks of the CPU
+ * domain. The platform clock driver provides a clock register configuration
+ * for each configurable rate which is then used to program the clock hardware
+ * registers to acheive a fast co-oridinated rate change for all the CPU domain
+ * clocks.
+ *
+ * On a rate change request for the CPU clock, the rate change is propagated
+ * upto the PLL supplying the clock to the CPU domain clock blocks. While the
+ * CPU domain PLL is reconfigured, the CPU domain clocks are driven using an
+ * alternate clock source. If required, the alternate clock source is divided
+ * down in order to keep the output clock rate within the previous OPP limits.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "clk.h"
+#include 
+
+/**
+ * struct rockchip_cpuclk: information about clock supplied to a CPU core.
+ * @hw:handle between ccf and cpu clock.
+ * @alt_parent:alternate parent clock to use when switching the speed
+ * of the primary parent clock.
+ * @reg_base:  base register for cpu-clock values.
+ * @rate_count:number of rates in the rate_table
+ * @rate_table:pll-rates and their associated dividers
+ * @reg_data:  cpu-specific register settings
+ */
+struct rockchip_cpuclk {
+   struct clk  hw;
+
+   struct clk  *alt_parent;
+   void __iomem*reg_base;
+   unsigned intrate_count;
+   struct rockchip_cpuclk_rate_table   *rate_table;
+   const struct rockchip_cpuclk_reg_data   *reg_data;
+};
+
+#define to_rockchip_cpuclk_hw(hw) container_of(hw, struct rockchip_cpuclk, hw)
+
+static unsigned long rockchip_cpuclk_recalc_rate(struct clk *hw,
+   unsigned long parent_rate)
+{
+   struct rockchip_cpuclk *cpuclk = to_rockchip_cpuclk_hw(hw);
+   const struct rockchip_cpuclk_reg_data *reg_data = cpuclk->reg_data;
+   u32 clksel0 = readl(cpuclk->reg_base + reg_data->core_reg);
+
+   clksel0 >>= reg_data->div_core_shift;
+   clksel0 &= reg_data->div_core_mask;
+   return parent_rate / (clksel0 + 1);
+}
+
+static const struct clk_ops rockchip_cpuclk_ops = {
+   .recalc_rate = rockchip_cpuclk_recalc_rate,
+};
+
+struct clk *rockchip_clk_register_cpuclk(const char *name,
+   const char **parent_names, u8 num_parents,
+   const struct rockchip_cpuclk_reg_data *reg_data,
+   const struct rockchip_cpuclk_rate_table *rates,
+   int nra

[PATCH v2 02/18] CLK: Add support for composite clock from Linux kernel

2015-03-04 Thread Andrey Panov
Signed-off-by: Andrey Panov 
---
 drivers/clk/Makefile|   2 +-
 drivers/clk/clk-composite.c | 145 
 include/linux/clk.h |   6 ++
 3 files changed, 152 insertions(+), 1 deletion(-)
 create mode 100644 drivers/clk/clk-composite.c

diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
index fa707dd..9df98c8 100644
--- a/drivers/clk/Makefile
+++ b/drivers/clk/Makefile
@@ -1,5 +1,5 @@
 obj-$(CONFIG_COMMON_CLK)   += clk.o clk-fixed.o clk-divider.o 
clk-fixed-factor.o \
-   clk-mux.o clk-gate.o
+   clk-mux.o clk-gate.o clk-composite.o
 obj-$(CONFIG_CLKDEV_LOOKUP)+= clkdev.o
 
 obj-$(CONFIG_ARCH_MVEBU)   += mvebu/
diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
new file mode 100644
index 000..5d21a0e
--- /dev/null
+++ b/drivers/clk/clk-composite.c
@@ -0,0 +1,145 @@
+/*
+ * Taken from linux/drivers/clk/
+ *
+ * Copyright (c) 2013 NVIDIA CORPORATION.  All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope 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, see .
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct clk_composite {
+   struct clk  clk;
+
+   struct clk  *mux_clk;
+   struct clk  *rate_clk;
+   struct clk  *gate_clk;
+};
+
+#define to_clk_composite(_clk) container_of(_clk, struct clk_composite, clk)
+
+static int clk_composite_get_parent(struct clk *clk)
+{
+   struct clk_composite *composite = to_clk_composite(clk);
+   struct clk *mux_clk = composite->mux_clk;
+
+   return mux_clk ? mux_clk->ops->get_parent(mux_clk) : 0;
+}
+
+static int clk_composite_set_parent(struct clk *clk, u8 index)
+{
+   struct clk_composite *composite = to_clk_composite(clk);
+   struct clk *mux_clk = composite->mux_clk;
+
+   return mux_clk ? mux_clk->ops->set_parent(mux_clk, index) : 0;
+}
+
+static unsigned long clk_composite_recalc_rate(struct clk *clk,
+   unsigned long parent_rate)
+{
+   struct clk_composite *composite = to_clk_composite(clk);
+   struct clk *rate_clk = composite->rate_clk;
+
+   return rate_clk ? rate_clk->ops->recalc_rate(rate_clk, parent_rate) : 0;
+}
+
+static long clk_composite_round_rate(struct clk *clk, unsigned long rate,
+ unsigned long *prate)
+{
+   struct clk_composite *composite = to_clk_composite(clk);
+   struct clk *rate_clk = composite->rate_clk;
+
+   return rate_clk ? rate_clk->ops->round_rate(rate_clk, rate, prate) : 0;
+}
+
+static int clk_composite_set_rate(struct clk *clk, unsigned long rate,
+  unsigned long parent_rate)
+{
+   struct clk_composite *composite = to_clk_composite(clk);
+   struct clk *rate_clk = composite->rate_clk;
+
+   return rate_clk ?
+   rate_clk->ops->set_rate(rate_clk, rate, parent_rate) : 0;
+}
+
+static int clk_composite_is_enabled(struct clk *clk)
+{
+   struct clk_composite *composite = to_clk_composite(clk);
+   struct clk *gate_clk = composite->gate_clk;
+
+   return gate_clk ? gate_clk->ops->is_enabled(gate_clk) : 0;
+}
+
+static int clk_composite_enable(struct clk *clk)
+{
+   struct clk_composite *composite = to_clk_composite(clk);
+   struct clk *gate_clk = composite->gate_clk;
+
+   return gate_clk ? gate_clk->ops->enable(gate_clk) : 0;
+}
+
+static void clk_composite_disable(struct clk *clk)
+{
+   struct clk_composite *composite = to_clk_composite(clk);
+   struct clk *gate_clk = composite->gate_clk;
+
+   if (gate_clk)
+   gate_clk->ops->disable(gate_clk);
+}
+
+static struct clk_ops clk_composite_ops = {
+   .get_parent = clk_composite_get_parent,
+   .set_parent = clk_composite_set_parent,
+   .recalc_rate = clk_composite_recalc_rate,
+   .round_rate = clk_composite_round_rate,
+   .set_rate = clk_composite_set_rate,
+   .is_enabled = clk_composite_is_enabled,
+   .enable = clk_composite_enable,
+   .disable = clk_composite_disable,
+};
+
+struct clk *clk_register_composite(const char *name,
+   const char **parent_names, int num_parents,
+   struct clk *mux_clk,
+   struct clk *rate_clk,
+   struct clk *gate_clk,
+   unsigned long flags)
+{
+   struct clk_composite *composite;
+

[PATCH v2 06/18] CLK: clk-divider: Introduce clk_divider_alloc() and *_free() routines

2015-03-04 Thread Andrey Panov
Signed-off-by: Andrey Panov 
---
 drivers/clk/clk-divider.c | 27 ++-
 include/linux/clk.h   |  3 +++
 2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c
index eb48334..cedcdda 100644
--- a/drivers/clk/clk-divider.c
+++ b/drivers/clk/clk-divider.c
@@ -212,11 +212,10 @@ struct clk_ops clk_divider_ops = {
.round_rate = clk_divider_round_rate,
 };
 
-struct clk *clk_divider(const char *name, const char *parent,
+struct clk *clk_divider_alloc(const char *name, const char *parent,
void __iomem *reg, u8 shift, u8 width, unsigned flags)
 {
struct clk_divider *div = xzalloc(sizeof(*div));
-   int ret;
 
div->shift = shift;
div->reg = reg;
@@ -228,13 +227,31 @@ struct clk *clk_divider(const char *name, const char 
*parent,
div->clk.parent_names = &div->parent;
div->clk.num_parents = 1;
 
-   ret = clk_register(&div->clk);
+   return &div->clk;
+}
+
+void clk_divider_free(struct clk *clk)
+{
+   struct clk_divider *d =  container_of(clk, struct clk_divider, clk);
+
+   free(d);
+}
+
+struct clk *clk_divider(const char *name, const char *parent,
+   void __iomem *reg, u8 shift, u8 width, unsigned flags)
+{
+   struct clk *d;
+   int ret;
+
+   d = clk_divider_alloc(name , parent, reg, shift, width, flags);
+
+   ret = clk_register(d);
if (ret) {
-   free(div);
+   clk_divider_free(d);
return ERR_PTR(ret);
}
 
-   return &div->clk;
+   return d;
 }
 
 struct clk *clk_divider_one_based(const char *name, const char *parent,
diff --git a/include/linux/clk.h b/include/linux/clk.h
index 258bbe3..65d3e99 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -254,6 +254,9 @@ struct clk_divider {
 
 extern struct clk_ops clk_divider_ops;
 
+struct clk *clk_divider_alloc(const char *name, const char *parent,
+   void __iomem *reg, u8 shift, u8 width, unsigned flags);
+void clk_divider_free(struct clk *clk_divider);
 struct clk *clk_divider(const char *name, const char *parent,
void __iomem *reg, u8 shift, u8 width, unsigned flags);
 struct clk *clk_divider_one_based(const char *name, const char *parent,
-- 
2.1.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2 17/18] ARM: Rockchip: Add Radxa Rock defconfig

2015-03-04 Thread Andrey Panov
Signed-off-by: Andrey Panov 
---
 arch/arm/configs/radxa_rock_defconfig | 110 ++
 1 file changed, 110 insertions(+)
 create mode 100644 arch/arm/configs/radxa_rock_defconfig

diff --git a/arch/arm/configs/radxa_rock_defconfig 
b/arch/arm/configs/radxa_rock_defconfig
new file mode 100644
index 000..6e7da3e
--- /dev/null
+++ b/arch/arm/configs/radxa_rock_defconfig
@@ -0,0 +1,110 @@
+CONFIG_ARCH_ROCKCHIP=y
+CONFIG_MACH_RADXA_ROCK=y
+CONFIG_AEABI=y
+CONFIG_ARM_BOARD_APPEND_ATAG=y
+CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y
+CONFIG_ARM_UNWIND=y
+CONFIG_MALLOC_SIZE=0x400
+CONFIG_EXPERIMENTAL=y
+CONFIG_MALLOC_TLSF=y
+CONFIG_KALLSYMS=y
+CONFIG_RELOCATABLE=y
+CONFIG_PROMPT="radxa-rock:"
+CONFIG_HUSH_FANCY_PROMPT=y
+CONFIG_CMDLINE_EDITING=y
+CONFIG_AUTO_COMPLETE=y
+CONFIG_CONSOLE_ACTIVATE_ALL=y
+CONFIG_DEFAULT_COMPRESSION_LZO=y
+CONFIG_DEFAULT_ENVIRONMENT_GENERIC_NEW=y
+CONFIG_DEFAULT_ENVIRONMENT_PATH="arch/arm/boards/radxa-rock/env"
+CONFIG_BAREBOXENV_TARGET=y
+CONFIG_BAREBOXCRC32_TARGET=y
+CONFIG_POLLER=y
+CONFIG_CMD_DMESG=y
+CONFIG_LONGHELP=y
+CONFIG_CMD_IOMEM=y
+CONFIG_CMD_MEMINFO=y
+CONFIG_CMD_ARM_MMUINFO=y
+CONFIG_CMD_BOOTM_SHOW_TYPE=y
+CONFIG_CMD_BOOTM_VERBOSE=y
+CONFIG_CMD_BOOTM_INITRD=y
+CONFIG_CMD_BOOTM_OFTREE=y
+CONFIG_CMD_BOOTM_OFTREE_UIMAGE=y
+CONFIG_CMD_BOOTM_AIMAGE=y
+CONFIG_CMD_BOOTZ=y
+CONFIG_CMD_GO=y
+CONFIG_CMD_LOADB=y
+CONFIG_CMD_LOADS=y
+CONFIG_CMD_LOADY=y
+CONFIG_CMD_RESET=y
+CONFIG_CMD_SAVES=y
+CONFIG_CMD_UIMAGE=y
+CONFIG_CMD_PARTITION=y
+CONFIG_CMD_EXPORT=y
+CONFIG_CMD_DEFAULTENV=y
+CONFIG_CMD_LOADENV=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_SHA1SUM=y
+CONFIG_CMD_SHA224SUM=y
+CONFIG_CMD_SHA256SUM=y
+CONFIG_CMD_UNCOMPRESS=y
+CONFIG_CMD_LET=y
+CONFIG_CMD_MSLEEP=y
+CONFIG_CMD_READF=y
+CONFIG_CMD_SLEEP=y
+CONFIG_CMD_DHCP=y
+CONFIG_CMD_HOST=y
+CONFIG_CMD_MIITOOL=y
+CONFIG_CMD_PING=y
+CONFIG_CMD_TFTP=y
+CONFIG_CMD_ECHO_E=y
+CONFIG_CMD_EDIT=y
+CONFIG_CMD_READLINE=y
+CONFIG_CMD_TIMEOUT=y
+CONFIG_CMD_MM=y
+CONFIG_CMD_CLK=y
+CONFIG_CMD_DETECT=y
+CONFIG_CMD_FLASH=y
+CONFIG_CMD_GPIO=y
+CONFIG_CMD_I2C=y
+CONFIG_CMD_LED=y
+CONFIG_CMD_SPI=y
+CONFIG_CMD_OF_NODE=y
+CONFIG_CMD_OF_PROPERTY=y
+CONFIG_CMD_OF_DISPLAY_TIMINGS=y
+CONFIG_CMD_OFTREE=y
+CONFIG_CMD_TIME=y
+CONFIG_NET=y
+CONFIG_NET_NFS=y
+CONFIG_NET_NETCONSOLE=y
+CONFIG_OFDEVICE=y
+CONFIG_OF_BAREBOX_DRIVERS=y
+CONFIG_DRIVER_SERIAL_NS16550=y
+CONFIG_DRIVER_NET_ARC_EMAC=y
+CONFIG_SMSC_PHY=y
+CONFIG_I2C=y
+CONFIG_I2C_GPIO=y
+CONFIG_MCI=y
+CONFIG_MCI_STARTUP=y
+CONFIG_MCI_MMC_BOOT_PARTITIONS=y
+CONFIG_MCI_DW=y
+CONFIG_MCI_DW_PIO=y
+CONFIG_MFD_ACT8846=y
+CONFIG_LED=y
+CONFIG_LED_GPIO=y
+CONFIG_LED_GPIO_OF=y
+CONFIG_GENERIC_PHY=y
+CONFIG_FS_CRAMFS=y
+CONFIG_FS_EXT4=y
+CONFIG_FS_TFTP=y
+CONFIG_FS_NFS=y
+CONFIG_FS_FAT=y
+CONFIG_FS_BPKFS=y
+CONFIG_FS_UIMAGEFS=y
+CONFIG_LZO_DECOMPRESS=y
-- 
2.1.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2 08/18] CLK: Check and do not allow to register clock twice

2015-03-04 Thread Andrey Panov
Signed-off-by: Andrey Panov 
---
 drivers/clk/clk.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
index 584e2f3..b77d022 100644
--- a/drivers/clk/clk.c
+++ b/drivers/clk/clk.c
@@ -212,6 +212,16 @@ struct clk *clk_get_parent(struct clk *clk)
 
 int clk_register(struct clk *clk)
 {
+   struct clk *c;
+
+   list_for_each_entry(c, &clks, list) {
+   if (!strcmp(c->name, clk->name)) {
+   pr_err("%s clk %s is already registered, skipping!\n",
+   __func__, clk->name);
+   return -EBUSY;
+   }
+   }
+
clk->parents = xzalloc(sizeof(struct clk *) * clk->num_parents);
 
list_add_tail(&clk->list, &clks);
-- 
2.1.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2 15/18] ARM: Rockchip: Use newer DTS for Radxa Rock board

2015-03-04 Thread Andrey Panov
Signed-off-by: Andrey Panov 
---
 arch/arm/dts/rk3188-clocks.dtsi   | 289 ---
 arch/arm/dts/rk3188-radxarock.dts |  32 ++--
 arch/arm/dts/rk3188.dtsi  | 306 --
 arch/arm/dts/rk3xxx.dtsi  | 139 -
 4 files changed, 20 insertions(+), 746 deletions(-)
 delete mode 100644 arch/arm/dts/rk3188-clocks.dtsi
 delete mode 100644 arch/arm/dts/rk3188.dtsi
 delete mode 100644 arch/arm/dts/rk3xxx.dtsi

diff --git a/arch/arm/dts/rk3188-clocks.dtsi b/arch/arm/dts/rk3188-clocks.dtsi
deleted file mode 100644
index b1b92dc..000
--- a/arch/arm/dts/rk3188-clocks.dtsi
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- * Copyright (c) 2013 MundoReader S.L.
- * Author: Heiko Stuebner 
- *
- * 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.
- */
-
-/ {
-   clocks {
-   #address-cells = <1>;
-   #size-cells = <1>;
-   ranges;
-
-   /*
-* This is a dummy clock, to be used as placeholder on
-* other mux clocks when a specific parent clock is not
-* yet implemented. It should be dropped when the driver
-* is complete.
-*/
-   dummy: dummy {
-   compatible = "fixed-clock";
-   clock-frequency = <0>;
-   #clock-cells = <0>;
-   };
-
-   xin24m: xin24m {
-   compatible = "fixed-clock";
-   clock-frequency = <2400>;
-   #clock-cells = <0>;
-   };
-
-   dummy48m: dummy48m {
-   compatible = "fixed-clock";
-   clock-frequency = <4800>;
-   #clock-cells = <0>;
-   };
-
-   dummy150m: dummy150m {
-   compatible = "fixed-clock";
-   clock-frequency = <15000>;
-   #clock-cells = <0>;
-   };
-
-   clk_gates0: gate-clk@20d0 {
-   compatible = "rockchip,rk2928-gate-clk";
-   reg = <0x20d0 0x4>;
-   clocks = <&dummy150m>, <&dummy>,
-<&dummy>, <&dummy>,
-<&dummy>, <&dummy>,
-<&dummy>, <&dummy>,
-<&dummy>, <&dummy>,
-<&dummy>, <&dummy>,
-<&dummy>, <&dummy>,
-<&dummy>, <&dummy>;
-
-   clock-output-names =
-   "gate_core_periph", "gate_cpu_gpll",
-   "gate_ddrphy", "gate_aclk_cpu",
-   "gate_hclk_cpu", "gate_pclk_cpu",
-   "gate_atclk_cpu", "gate_aclk_core",
-   "reserved", "gate_i2s0",
-   "gate_i2s0_frac", "reserved",
-   "reserved", "gate_spdif",
-   "gate_spdif_frac", "gate_testclk";
-
-   #clock-cells = <1>;
-   };
-
-   clk_gates1: gate-clk@20d4 {
-   compatible = "rockchip,rk2928-gate-clk";
-   reg = <0x20d4 0x4>;
-   clocks = <&xin24m>, <&xin24m>,
-<&xin24m>, <&dummy>,
-<&dummy>, <&xin24m>,
-<&xin24m>, <&dummy>,
-<&xin24m>, <&dummy>,
-<&xin24m>, <&dummy>,
-<&xin24m>, <&dummy>,
-<&xin24m>, <&dummy>;
-
-   clock-output-names =
-   "gate_timer0", "gate_timer1",
-   "gate_timer3", "gate_jtag",
-   "gate_aclk_lcdc1_src", "gate_otgphy0",
-   "gate_otgphy1", "gate_ddr_gpll",
-   "gate_uart0", "gate_frac_uart0",
-   "gate_uart1", "gate_frac_uart1",
-   "gate_uart2", "gate_frac_uart2",
-   "gate_uart3", "gate_frac_uart3";
-
-   #clock-cells = <1>;
-   };
-
-   clk_gates2: gate-clk@20d8 {
-   

[PATCH v2 11/18] MMC: dw_mmc: Add support for PIO mode and Rockchip variant of this hardware

2015-03-04 Thread Andrey Panov
Signed-off-by: Andrey Panov 
---
 drivers/mci/Kconfig  |   6 ++
 drivers/mci/dw_mmc.c | 174 ---
 2 files changed, 173 insertions(+), 7 deletions(-)

diff --git a/drivers/mci/Kconfig b/drivers/mci/Kconfig
index dbcc38d..17bf0d3 100644
--- a/drivers/mci/Kconfig
+++ b/drivers/mci/Kconfig
@@ -42,6 +42,12 @@ config MCI_DW
  block, this provides host support for SD and MMC interfaces, in both
  PIO and external DMA modes.
 
+config MCI_DW_PIO
+   bool "Use PIO mode on Synopsys DesignWare MCI"
+   depends on MCI_DW
+   help
+ Use PIO mode (instead of IDMAC) in DW MMC driver.
+
 config MCI_MXS
bool "i.MX23/i.MX28"
depends on ARCH_MXS
diff --git a/drivers/mci/dw_mmc.c b/drivers/mci/dw_mmc.c
index 365b60d..1232951 100644
--- a/drivers/mci/dw_mmc.c
+++ b/drivers/mci/dw_mmc.c
@@ -125,6 +125,8 @@
 #define DWMCI_CTYPE_8BIT   (1 << 16)
 
 /* Status Register */
+#define DWMCI_STATUS_FIFO_EMPTY(1 << 2)
+#define DWMCI_STATUS_FIFO_FULL (1 << 3)
 #define DWMCI_STATUS_BUSY  (1 << 9)
 
 /* FIFOTH Register */
@@ -153,6 +155,8 @@ struct dwmci_host {
struct dwmci_idmac *idmac;
unsigned long clkrate;
int ciu_div;
+   u32 fifoth_val;
+   u32 pwren_value;
 };
 
 struct dwmci_idmac {
@@ -201,6 +205,8 @@ static int dwmci_prepare_data(struct dwmci_host *host,
struct mci_data *data)
 {
unsigned long ctrl;
+
+#ifndef CONFIG_MCI_DW_PIO
unsigned int i = 0, flags, cnt, blk_cnt;
unsigned long data_start, start_addr;
struct dwmci_idmac *desc = host->idmac;
@@ -256,7 +262,26 @@ static int dwmci_prepare_data(struct dwmci_host *host,
 
dwmci_writel(host, DWMCI_BLKSIZ, data->blocksize);
dwmci_writel(host, DWMCI_BYTCNT, data->blocksize * data->blocks);
+#else
+   /* PIO MODE */
+   dwmci_wait_reset(host, DWMCI_CTRL_FIFO_RESET);
+   dwmci_writel(host, DWMCI_RINTSTS,
+   DWMCI_INTMSK_TXDR | DWMCI_INTMSK_RXDR);
+
+   ctrl = dwmci_readl(host, DWMCI_INTMASK);
+   ctrl |= DWMCI_INTMSK_TXDR | DWMCI_INTMSK_RXDR;
+   dwmci_writel(host, DWMCI_INTMASK, ctrl);
+
+   ctrl = dwmci_readl(host, DWMCI_CTRL);
+   ctrl &= ~(DWMCI_IDMAC_EN | DWMCI_DMA_EN);
+   dwmci_writel(host, DWMCI_CTRL, ctrl);
 
+   dwmci_writel(host, DWMCI_FIFOTH, host->fifoth_val);
+
+   dwmci_writel(host, DWMCI_TMOUT, 0x);
+   dwmci_writel(host, DWMCI_BLKSIZ, data->blocksize);
+   dwmci_writel(host, DWMCI_BYTCNT, data->blocksize * data->blocks);
+#endif
return 0;
 }
 
@@ -272,12 +297,108 @@ static int dwmci_set_transfer_mode(struct dwmci_host 
*host,
return mode;
 }
 
+#ifdef CONFIG_MCI_DW_PIO
+static int dwmci_read_data_pio(struct dwmci_host *host, struct mci_data *data)
+{
+   u32 *pdata = (u32 *)data->dest;
+   u32 val, status, timeout;
+   u32 fcnt, bcnt, rcnt, rlen = 0;
+
+   timeout = 100;
+   status = dwmci_readl(host, DWMCI_RINTSTS);
+   while (--timeout && !(status & DWMCI_INTMSK_RXDR))
+   status = dwmci_readl(host, DWMCI_RINTSTS);
+
+   if (!timeout) {
+   dev_err(host->dev, "%s: RX ready wait timeout\n", __func__);
+   return 0;
+   }
+
+   fcnt = data->blocksize;
+   bcnt = data->blocks;
+
+   do {
+   for (rcnt = fcnt>>2; rcnt; rcnt--) {
+   timeout = 2;
+   status = dwmci_readl(host, DWMCI_STATUS);
+   while (--timeout
+   && (status & DWMCI_STATUS_FIFO_EMPTY)) {
+   udelay(200);
+   status = dwmci_readl(host, DWMCI_STATUS);
+   }
+   if (!timeout) {
+   dev_err(host->dev, "%s: FIFO underflow 
timeout\n",
+   __func__);
+   break;
+   }
+
+   val = dwmci_readl(host, DWMCI_DATA);
+
+   *pdata++ = val;
+   rlen += 4;
+   }
+   status = dwmci_readl(host, DWMCI_RINTSTS);
+   dwmci_writel(host, DWMCI_RINTSTS, DWMCI_INTMSK_RXDR);
+   } while (--bcnt && (status & DWMCI_INTMSK_RXDR));
+
+   return rlen;
+}
+
+static int dwmci_write_data_pio(struct dwmci_host *host, struct mci_data *data)
+{
+   u32 *pdata = (u32 *)data->src;
+   u32 status, timeout;
+   u32 fcnt, bcnt, wcnt, wlen = 0;
+
+   fcnt = host->fifo_size_bytes;
+
+   bcnt = (data->blocks*data->blocksize)/fcnt;
+
+   timeout = 100;
+   status = dwmci_readl(host, DWMCI_RINTSTS);
+
+   while (--timeout && !(status & DWMCI_INTMSK_TXDR))
+   status = dwmci_readl(host, DWMCI_RINTSTS);
+
+   if (!timeout) {
+   dev_err(host->dev, "%s: TX ready wait timeout\n", __fu

[PATCH v2 10/18] NET: arc_emac: Update for newer DTS, support for Rockchip .compatible

2015-03-04 Thread Andrey Panov
Signed-off-by: Andrey Panov 
---
 drivers/net/arc_emac.c | 24 +---
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/drivers/net/arc_emac.c b/drivers/net/arc_emac.c
index 1770506..06c3376 100644
--- a/drivers/net/arc_emac.c
+++ b/drivers/net/arc_emac.c
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 
 /* ARC EMAC register set combines entries for MAC and MDIO */
 enum {
@@ -99,6 +100,8 @@ struct arc_emac_priv {
u8 *rxbuf;
unsigned int txbd_curr;
unsigned int last_rx_bd;
+   struct clk *clk;
+   struct clk *refclk;
 };
 
 /**
@@ -379,20 +382,18 @@ static int arc_emac_mdio_write(struct mii_bus *bus, int 
phy_addr, int reg_num,
return arc_mdio_complete_wait(priv);
 }
 
+#define DEFAULT_EMAC_CLOCK_FREQUENCY 5000UL;
+
 static int arc_emac_probe(struct device_d *dev)
 {
struct eth_device *edev;
struct arc_emac_priv *priv;
-   unsigned int clock_frequency;
+   unsigned long clock_frequency;
struct mii_bus *miibus;
u32 id;
 
-   /* Get CPU clock frequency from device tree */
-   if (of_property_read_u32(dev->device_node, "clock-frequency",
-&clock_frequency)) {
-   dev_err(dev, "failed to retrieve  from device 
tree\n");
-   return -EINVAL;
-   }
+   /* clock-frequency is dropped from DTS, so hardcode it here */
+   clock_frequency = DEFAULT_EMAC_CLOCK_FREQUENCY;
 
edev = xzalloc(sizeof(struct eth_device) +
   sizeof(struct arc_emac_priv));
@@ -405,6 +406,13 @@ static int arc_emac_probe(struct device_d *dev)
return PTR_ERR(priv->regs);
priv->bus = miibus;
 
+   priv->clk = clk_get(dev, "hclk");
+   clk_enable(priv->clk);
+
+   priv->refclk = clk_get(dev, "macref");
+   clk_set_rate(priv->refclk, clock_frequency);
+   clk_enable(priv->refclk);
+
id = arc_reg_get(priv, R_ID);
/* Check for EMAC revision 5 or 7, magic number */
if (!(id == 0x0005fd02 || id == 0x0007fd02)) {
@@ -450,6 +458,8 @@ static __maybe_unused struct of_device_id arc_emac_dt_ids[] 
= {
{
.compatible = "snps,arc-emac",
}, {
+   .compatible = "rockchip,rk3188-emac",
+   }, {
/* sentinel */
}
 };
-- 
2.1.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2 13/18] ARM: Rockchip: Update Kconfig

2015-03-04 Thread Andrey Panov
Signed-off-by: Andrey Panov 
---
 arch/arm/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 527a913..50f3095 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -160,6 +160,7 @@ config ARCH_ROCKCHIP
select PINCTRL_ROCKCHIP
select HAVE_PBL_MULTI_IMAGES
select HAS_DEBUG_LL
+   select ARCH_HAS_L2X0
 
 config ARCH_SOCFPGA
bool "Altera SOCFPGA cyclone5"
-- 
2.1.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2 12/18] ARM: Rockchip: Remove unused files from mach-rockchip

2015-03-04 Thread Andrey Panov
Signed-off-by: Andrey Panov 
---
 arch/arm/mach-rockchip/Makefile|   1 -
 arch/arm/mach-rockchip/include/mach/rockchip-pll.h |  26 --
 arch/arm/mach-rockchip/pll.c   | 102 -
 3 files changed, 129 deletions(-)
 delete mode 100644 arch/arm/mach-rockchip/include/mach/rockchip-pll.h
 delete mode 100644 arch/arm/mach-rockchip/pll.c

diff --git a/arch/arm/mach-rockchip/Makefile b/arch/arm/mach-rockchip/Makefile
index 6f4ec16..820eb10 100644
--- a/arch/arm/mach-rockchip/Makefile
+++ b/arch/arm/mach-rockchip/Makefile
@@ -1,2 +1 @@
 obj-y += core.o
-obj-y += pll.o
\ No newline at end of file
diff --git a/arch/arm/mach-rockchip/include/mach/rockchip-pll.h 
b/arch/arm/mach-rockchip/include/mach/rockchip-pll.h
deleted file mode 100644
index c2cd888..000
--- a/arch/arm/mach-rockchip/include/mach/rockchip-pll.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2014 Beniamino Galvani 
- *
- * 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.
- */
-
-#ifndef __MACH_ROCKCHIP_PLL_H
-#define __MACH_ROCKCHIP_PLL_H
-
-enum rk3188_plls {
-   RK3188_APLL = 0,/* ARM */
-   RK3188_DPLL,/* DDR */
-   RK3188_CPLL,/* Codec */
-   RK3188_GPLL,/* General */
-};
-
-int rk3188_pll_set_parameters(int pll, int nr, int nf, int no);
-
-#endif /* __MACH_ROCKCHIP_PLL_H */
diff --git a/arch/arm/mach-rockchip/pll.c b/arch/arm/mach-rockchip/pll.c
deleted file mode 100644
index fce192c..000
--- a/arch/arm/mach-rockchip/pll.c
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (C) 2014 Beniamino Galvani 
- *
- * Based on Linux clk driver:
- *  Copyright (c) 2014 MundoReader S.L.
- *
- * 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 
-#include 
-#include 
-
-#define RK3188_CLK_BASE0x2000
-#define RK3188_PLL_LOCK_REG0x200080ac
-
-#define PLL_MODE_MASK  0x3
-#define PLL_MODE_SLOW  0x0
-#define PLL_MODE_NORM  0x1
-#define PLL_MODE_DEEP  0x2
-
-#define PLL_RESET_DELAY(nr)((nr * 500) / 24 + 1)
-
-#define PLLCON0_OD_MASK0xf
-#define PLLCON0_OD_SHIFT   0
-#define PLLCON0_NR_MASK0x3f
-#define PLLCON0_NR_SHIFT   8
-
-#define PLLCON1_NF_MASK0x1fff
-#define PLLCON1_NF_SHIFT   0
-
-#define PLLCON2_BWADJ_MASK 0xfff
-#define PLLCON2_BWADJ_SHIFT0
-
-#define PLLCON3_RESET  (1 << 1)
-#define PLLCON3_BYPASS (1 << 0)
-
-struct rockchip_pll_data {
-   int con_base;
-   int mode_offset;
-   int mode_shift;
-   int lock_shift;
-};
-
-struct rockchip_pll_data rk3188_plls[] = {
-   { 0x00, 0x40, 0x00, 0x06 },
-   { 0x10, 0x40, 0x04, 0x05 },
-   { 0x20, 0x40, 0x08, 0x07 },
-   { 0x30, 0x40, 0x0c, 0x08 },
-};
-
-#define HIWORD_UPDATE(val, mask, shift) \
-   ((val) << (shift) | (mask) << ((shift) + 16))
-
-int rk3188_pll_set_parameters(int pll, int nr, int nf, int no)
-{
-   struct rockchip_pll_data *d = &rk3188_plls[pll];
-   int delay = 0;
-
-   debug("rk3188 pll %d: set param %d %d %d\n", pll, nr, nf, no);
-
-   /* pull pll in slow mode */
-   writel(HIWORD_UPDATE(PLL_MODE_SLOW, PLL_MODE_MASK, d->mode_shift),
-  RK3188_CLK_BASE + d->mode_offset);
-   /* enter reset */
-   writel(HIWORD_UPDATE(PLLCON3_RESET, PLLCON3_RESET, 0),
-  RK3188_CLK_BASE + d->con_base + 12);
-
-   /* update pll values */
-   writel(HIWORD_UPDATE(nr - 1, PLLCON0_NR_MASK, PLLCON0_NR_SHIFT) |
-  HIWORD_UPDATE(no - 1, PLLCON0_OD_MASK, PLLCON0_OD_SHIFT),
-  RK3188_CLK_BASE + d->con_base + 0);
-   writel(HIWORD_UPDATE(nf - 1, PLLCON1_NF_MASK, PLLCON1_NF_SHIFT),
-  RK3188_CLK_BASE + d->con_base + 4);
-   writel(HIWORD_UPDATE(nf >> 1, PLLCON2_BWADJ_MASK, PLLCON2_BWADJ_SHIFT),
-  RK3188_CLK_BASE + d->con_base + 8);
-
-   /* leave reset and wait the reset_delay */
-   writel(HIWORD_UPDATE(0, PLLCON3_RESET, 0),
-  RK3188_CLK_BASE + d->con_base + 12);
-   udelay(PLL_RESET_DELAY(nr));
-
-   /* wait for the pll to lock */
-   while (delay++ < 2400) {
-   if (r

[PATCH v2 04/18] CLK: clk-mux: Respect CLK_MUX_HIWORD_MASK flag

2015-03-04 Thread Andrey Panov
It is required for Rockchip SoCs where clock settings registers have
write-enable mask in high word.

Signed-off-by: Andrey Panov 
---
 drivers/clk/clk-mux.c | 3 +++
 include/linux/clk.h   | 2 ++
 2 files changed, 5 insertions(+)

diff --git a/drivers/clk/clk-mux.c b/drivers/clk/clk-mux.c
index 4ce86f4..22e131f 100644
--- a/drivers/clk/clk-mux.c
+++ b/drivers/clk/clk-mux.c
@@ -45,6 +45,9 @@ static int clk_mux_set_parent(struct clk *clk, u8 idx)
val = readl(m->reg);
val &= ~(((1 << m->width) - 1) << m->shift);
val |= idx << m->shift;
+
+   if (clk->flags & CLK_MUX_HIWORD_MASK)
+   val |= ((1 << m->width) - 1) << (m->shift + 16);
writel(val, m->reg);
 
return 0;
diff --git a/include/linux/clk.h b/include/linux/clk.h
index de2d4a5..89cb44e 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -248,6 +248,8 @@ struct clk_divider {
int table_size;
 };
 
+#define CLK_MUX_HIWORD_MASK(1 << 2)
+
 extern struct clk_ops clk_divider_ops;
 
 struct clk *clk_divider(const char *name, const char *parent,
-- 
2.1.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2 07/18] CLK: clk-divider: Respect CLK_DIVIDER_POWER_OF_TWO flag

2015-03-04 Thread Andrey Panov
Signed-off-by: Andrey Panov 
---
 drivers/clk/clk-divider.c | 9 +
 include/linux/clk.h   | 1 +
 2 files changed, 10 insertions(+)

diff --git a/drivers/clk/clk-divider.c b/drivers/clk/clk-divider.c
index cedcdda..646e5b0 100644
--- a/drivers/clk/clk-divider.c
+++ b/drivers/clk/clk-divider.c
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define div_mask(d)((1 << ((d)->width)) - 1)
 
@@ -26,6 +27,8 @@ static unsigned int _get_maxdiv(struct clk_divider *divider)
 {
if (divider->flags & CLK_DIVIDER_ONE_BASED)
return div_mask(divider);
+   if (divider->flags & CLK_DIVIDER_POWER_OF_TWO)
+   return 1 << div_mask(divider);
return div_mask(divider) + 1;
 }
 
@@ -44,6 +47,8 @@ static unsigned int _get_div(struct clk_divider *divider, 
unsigned int val)
 {
if (divider->flags & CLK_DIVIDER_ONE_BASED)
return val;
+   if (divider->flags & CLK_DIVIDER_POWER_OF_TWO)
+   return 1 << val;
if (divider->table)
return _get_table_div(divider->table, val);
return val + 1;
@@ -64,6 +69,8 @@ static unsigned int _get_val(struct clk_divider *divider, 
unsigned int div)
 {
if (divider->flags & CLK_DIVIDER_ONE_BASED)
return div;
+   if (divider->flags & CLK_DIVIDER_POWER_OF_TWO)
+   return __ffs(div);
if (divider->table)
return  _get_table_val(divider->table, div);
return div - 1;
@@ -102,6 +109,8 @@ static bool _is_valid_table_div(const struct clk_div_table 
*table,
 
 static bool _is_valid_div(struct clk_divider *divider, unsigned int div)
 {
+   if (divider->flags & CLK_DIVIDER_POWER_OF_TWO)
+   return is_power_of_2(div);
if (divider->table)
return _is_valid_table_div(divider->table, div);
return true;
diff --git a/include/linux/clk.h b/include/linux/clk.h
index 65d3e99..56890a0 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -248,6 +248,7 @@ struct clk_divider {
int table_size;
 };
 
+#define CLK_DIVIDER_POWER_OF_TWO   (1 << 1)
 #define CLK_DIVIDER_HIWORD_MASK(1 << 3)
 
 #define CLK_MUX_HIWORD_MASK(1 << 2)
-- 
2.1.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2 01/18] lib: Add gcd() function

2015-03-04 Thread Andrey Panov
It calculates greatest common divisor.

Signed-off-by: Andrey Panov 
---
 include/linux/gcd.h|  8 
 include/linux/kernel.h |  5 +
 lib/Makefile   |  1 +
 lib/gcd.c  | 18 ++
 4 files changed, 32 insertions(+)
 create mode 100644 include/linux/gcd.h
 create mode 100644 lib/gcd.c

diff --git a/include/linux/gcd.h b/include/linux/gcd.h
new file mode 100644
index 000..0ac2621
--- /dev/null
+++ b/include/linux/gcd.h
@@ -0,0 +1,8 @@
+#ifndef _GCD_H
+#define _GCD_H
+
+#include 
+
+unsigned long gcd(unsigned long a, unsigned long b) __attribute_const__;
+
+#endif /* _GCD_H */
diff --git a/include/linux/kernel.h b/include/linux/kernel.h
index 3f2644c..5b6b448 100644
--- a/include/linux/kernel.h
+++ b/include/linux/kernel.h
@@ -257,5 +257,10 @@ static inline char *hex_byte_pack_upper(char *buf, u8 byte)
const typeof( ((type *)0)->member ) *__mptr = (ptr);\
(type *)( (char *)__mptr - offsetof(type,member) );})
 
+/*
+ * swap - swap value of @a and @b
+ */
+#define swap(a, b) \
+   do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0)
 
 #endif /* _LINUX_KERNEL_H */
diff --git a/lib/Makefile b/lib/Makefile
index b97e52d..f08ac59 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -52,3 +52,4 @@ obj-$(CONFIG_STMP_DEVICE) += stmp-device.o
 obj-y  += wchar.o
 obj-y  += libfile.o
 obj-y  += bitmap.o
+obj-y  += gcd.o
diff --git a/lib/gcd.c b/lib/gcd.c
new file mode 100644
index 000..86bdba9
--- /dev/null
+++ b/lib/gcd.c
@@ -0,0 +1,18 @@
+#include 
+
+/* Greatest common divisor */
+unsigned long gcd(unsigned long a, unsigned long b)
+{
+   unsigned long r;
+
+   if (a < b)
+   swap(a, b);
+
+   if (!b)
+   return a;
+   while ((r = a % b) != 0) {
+   a = b;
+   b = r;
+   }
+   return b;
+}
-- 
2.1.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2 00/18] Update support for RK3188, Radxa Rock board

2015-03-04 Thread Andrey Panov
This series will update support for Radxa Rock board, allowing it
to boot from SD card with Barebox as first-stage loader.

Based on next branch.

v2: Rebased on more recent sources, fixed patches.



___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: Rockchip RK3188

2015-03-04 Thread Панов Андрей
Hello!

04.03.2015, 13:26, "Erwin Rol" :
> Hey all,
>
> I saw some mails and patches passing by for the Rockchip RK3188. Since I
> am just starting a project with a RK3188 I was wondering if there are
> ppl that have more info than the pathetic databook from Rochchip.

All known documents are on http://rockchip.fr/
3188 TRM: http://rockchip.fr/Rockchip%20RK3188%20TRM%20V1.3.pdf
PX2 TRM: http://rockchip.fr/Rockchip%20PX2%20TRM%20V1.0.pdf
PX2 document is more complete and has description of parts missing in 3188 doc.
Chips are similar in many parts and PX2 doc can be used as reference.

> Also it seems large parts (even essential things like the NAND
> controller) are closed source kernel blobs ?
>
> How is this dealt with in barebox? Is NAND even usable ?

NAND works with Radxa supplied images with 3.0.36+ kernel and 
does not with mainline.

Barebox (with patches) supports SD and network controllers.

--
 Андрей

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 2/2] remove unnecessary device pointer argument

2015-03-04 Thread Jean-Christophe PLAGNIOL-VILLARD

> On Mar 4, 2015, at 6:45 PM, Sascha Hauer  wrote:
> 
> On Wed, Mar 04, 2015 at 04:43:13PM +0800, Jean-Christophe PLAGNIOL-VILLARD 
> wrote:
>> 
>>> On Mar 4, 2015, at 3:49 PM, Sascha Hauer  wrote:
>>> 
>>> The struct device_d * argument is not necessary, it can be retrieved from
>>> the FILE *. This adds a convenience function for doing this and removes
>>> the struct device_d * argument from the the filesystem drivers functions.
>> 
>> if you do so you should introduce fs_warn/info & co too
>> 
>> so we de not use dev_xxx version in fs
> 
> We can do that, but it's independent of these patches, right?
I’d said no as we drop the device_d we need drop dev_xxx too
to be logic

Best Regards,
J.
> 
> Sascha
> 
> -- 
> Pengutronix e.K.   | |
> Industrial Linux Solutions | http://www.pengutronix.de/  |
> Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
> Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 2/2] remove unnecessary device pointer argument

2015-03-04 Thread Sascha Hauer
On Wed, Mar 04, 2015 at 04:43:13PM +0800, Jean-Christophe PLAGNIOL-VILLARD 
wrote:
> 
> > On Mar 4, 2015, at 3:49 PM, Sascha Hauer  wrote:
> > 
> > The struct device_d * argument is not necessary, it can be retrieved from
> > the FILE *. This adds a convenience function for doing this and removes
> > the struct device_d * argument from the the filesystem drivers functions.
> 
> if you do so you should introduce fs_warn/info & co too
> 
> so we de not use dev_xxx version in fs

We can do that, but it's independent of these patches, right?

Sascha

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH v2] led: gpio: add support for default-state dt-property

2015-03-04 Thread Sascha Hauer
On Wed, Mar 04, 2015 at 10:52:04AM +0100, Hubert Feurstein wrote:
> This patch adds support for the default-state device tree property.
> 
> Signed-off-by: Hubert Feurstein 
> ---
>  drivers/led/led-gpio.c | 8 
>  1 file changed, 8 insertions(+)

Nice, as it happens I can just make use of this patch to turn off an
annoying LED on my beaglebone board.

Applied, thanks.

Sascha

-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH v3 00/13] sandbox OF integration

2015-03-04 Thread Sascha Hauer
On Tue, Mar 03, 2015 at 01:14:46PM +0100, Marc Kleine-Budde wrote:
> Hello Sascha,
> 
> these are the remaining patches that bring OF support to the sandbox so that
> enables testing of framworks which need the device tree.
> 
> changes since v2:
> - build sandbox with oftree support always, select CONFIG_OFTREE
> - the hostfile nodes in the device tree are now generated on the fly,
>   no need for stubs.
> - hostfile: switch to oftree only, remove platform data
> - hostfile: add possibility to specify name of device via:
>   --image =

Applied, thanks

Sascha


-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 01/11] of: make of_alias_get work on all types of DT paths

2015-03-04 Thread Sascha Hauer
On Tue, Mar 03, 2015 at 08:46:13PM +0100, Lucas Stach wrote:
> of_alias_get assumed that a DT path is always the full node path,
> whic is not necessarily the case, as there are other valid path
> descriptions. All of them are handled by of_find_node_by_path.
> 
> As there is already a preparsed list with all DT aliases that handles
> this case properly we can simply reuse that one.
> 
> Signed-off-by: Lucas Stach 
> ---
>  drivers/of/base.c | 8 
>  1 file changed, 4 insertions(+), 4 deletions(-)

Applied all, thanks

Sascha


-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Rockchip RK3188

2015-03-04 Thread Erwin Rol
Hey all,

I saw some mails and patches passing by for the Rockchip RK3188. Since I
am just starting a project with a RK3188 I was wondering if there are
ppl that have more info than the pathetic databook from Rochchip.

Also it seems large parts (even essential things like the NAND
controller) are closed source kernel blobs ?

How is this dealt with in barebox? Is NAND even usable ?

- Erwin

___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH v2] led: gpio: add support for default-state dt-property

2015-03-04 Thread Hubert Feurstein
This patch adds support for the default-state device tree property.

Signed-off-by: Hubert Feurstein 
---
 drivers/led/led-gpio.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/led/led-gpio.c b/drivers/led/led-gpio.c
index a1a6617..ae3f13f 100644
--- a/drivers/led/led-gpio.c
+++ b/drivers/led/led-gpio.c
@@ -204,6 +204,7 @@ static int led_gpio_of_probe(struct device_d *dev)
 
for_each_child_of_node(dev->device_node, child) {
struct gpio_led *gled;
+   const char *default_state;
enum of_gpio_flags flags;
int gpio;
const char *label;
@@ -225,6 +226,13 @@ static int led_gpio_of_probe(struct device_d *dev)
 
led_gpio_register(gled);
led_of_parse_trigger(&gled->led, child);
+
+   if (!of_property_read_string(child, "default-state", 
&default_state)) {
+   if (!strcmp(default_state, "on"))
+   led_gpio_set(&gled->led, 1);
+   else if (!strcmp(default_state, "off"))
+   led_gpio_set(&gled->led, 0);
+   }
}
 
return 0;
-- 
2.3.0


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


Re: [PATCH 0/4] Device Tree Overlay Support

2015-03-04 Thread Jan Lübbe
On Mi, 2015-03-04 at 10:29 +0100, Jan Luebbe wrote:
> This adds support for device tree overlays as supported by Linux 4.0-rc1.
> Patches 2-4 update the included DTC with overlay support.

Sorry, I forgot to mention that this depends on Marc's sandbox-of
series.

Regards,
Jan
-- 
Pengutronix e.K.   | |
Industrial Linux Solutions | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0|
Amtsgericht Hildesheim, HRA 2686   | Fax:   +49-5121-206917- |


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 2/4] scripts/dtc: import update-dtc-source.sh from kernel v4.0-rc1

2015-03-04 Thread Jan Luebbe
The original script was written by Grant Likely .
The version for barebox also imports some libfdt sources, so that we are
able to compile the fdtget host tool. Also remove the unused non-kconfig
makefiles.

Signed-off-by: Jan Luebbe 
---
 scripts/dtc/Makefile.dtc   | 18 ---
 scripts/dtc/libfdt/Makefile.libfdt | 10 ---
 scripts/dtc/update-dtc-source.sh   | 61 ++
 3 files changed, 61 insertions(+), 28 deletions(-)
 delete mode 100644 scripts/dtc/Makefile.dtc
 delete mode 100644 scripts/dtc/libfdt/Makefile.libfdt
 create mode 100755 scripts/dtc/update-dtc-source.sh

diff --git a/scripts/dtc/Makefile.dtc b/scripts/dtc/Makefile.dtc
deleted file mode 100644
index bece49b35535..
--- a/scripts/dtc/Makefile.dtc
+++ /dev/null
@@ -1,18 +0,0 @@
-# Makefile.dtc
-#
-# This is not a complete Makefile of itself.  Instead, it is designed to
-# be easily embeddable into other systems of Makefiles.
-#
-DTC_SRCS = \
-   checks.c \
-   data.c \
-   dtc.c \
-   flattree.c \
-   fstree.c \
-   livetree.c \
-   srcpos.c \
-   treesource.c \
-   util.c
-
-DTC_GEN_SRCS = dtc-lexer.lex.c dtc-parser.tab.c
-DTC_OBJS = $(DTC_SRCS:%.c=%.o) $(DTC_GEN_SRCS:%.c=%.o)
diff --git a/scripts/dtc/libfdt/Makefile.libfdt 
b/scripts/dtc/libfdt/Makefile.libfdt
deleted file mode 100644
index 91126c000a1e..
--- a/scripts/dtc/libfdt/Makefile.libfdt
+++ /dev/null
@@ -1,10 +0,0 @@
-# Makefile.libfdt
-#
-# This is not a complete Makefile of itself.  Instead, it is designed to
-# be easily embeddable into other systems of Makefiles.
-#
-LIBFDT_soname = libfdt.$(SHAREDLIB_EXT).1
-LIBFDT_INCLUDES = fdt.h libfdt.h libfdt_env.h
-LIBFDT_VERSION = version.lds
-LIBFDT_SRCS = fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c 
fdt_empty_tree.c
-LIBFDT_OBJS = $(LIBFDT_SRCS:%.c=%.o)
diff --git a/scripts/dtc/update-dtc-source.sh b/scripts/dtc/update-dtc-source.sh
new file mode 100755
index ..075d1d7af01d
--- /dev/null
+++ b/scripts/dtc/update-dtc-source.sh
@@ -0,0 +1,61 @@
+#!/bin/sh
+# Simple script to update the version of DTC carried by the Linux kernel
+#
+# This script assumes that the dtc and the linux git trees are in the
+# same directory. After building dtc in the dtc directory, it copies the
+# source files and generated source files into the scripts/dtc directory
+# in the kernel and creates a git commit updating them to the new
+# version.
+#
+# Usage: from the top level Linux source tree, run:
+# $ ./scripts/dtc/update-dtc-source.sh
+#
+# The script will change into the dtc tree, build and test dtc, copy the
+# relevant files into the kernel tree and create a git commit. The commit
+# message will need to be modified to reflect the version of DTC being
+# imported
+#
+# TODO:
+# This script is pretty basic, but it is seldom used so a few manual tasks
+# aren't a big deal. If anyone is interested in making it more robust, the
+# the following would be nice:
+# * Actually fail to complete if any testcase fails.
+#   - The dtc "make check" target needs to return a failure
+# * Extract the version number from the dtc repo for the commit message
+# * Build dtc in the kernel tree
+# * run 'make check" on dtc built from the kernel tree
+
+set -ev
+
+DTC_UPSTREAM_PATH=`pwd`/../dtc
+DTC_LINUX_PATH=`pwd`/scripts/dtc
+
+DTC_SOURCE="checks.c data.c dtc.c dtc.h flattree.c fstree.c livetree.c 
srcpos.c \
+   srcpos.h treesource.c util.c util.h version_gen.h Makefile.dtc \
+   dtc-lexer.l dtc-parser.y fdtdump.c fdtput.c fdtget.c"
+DTC_LIB="fdt.c fdt.h fdt_addresses.c fdt_empty_tree.c fdt_ro.c fdt_rw.c \
+   fdt_strerror.c fdt_sw.c fdt_wip.c libfdt.h libfdt_env.h \
+   libfdt_internal.h"
+DTC_GENERATED="dtc-lexer.lex.c dtc-parser.tab.c dtc-parser.tab.h"
+
+# Build DTC
+cd $DTC_UPSTREAM_PATH
+make clean
+make check
+
+# Copy the files into the Linux tree
+cd $DTC_LINUX_PATH
+for f in $DTC_SOURCE; do
+   cp ${DTC_UPSTREAM_PATH}/${f} ${f}
+   git add ${f}
+done
+for f in $DTC_LIB; do
+   cp ${DTC_UPSTREAM_PATH}/libfdt/${f} ${f}
+   git add ${f}
+done
+for f in $DTC_GENERATED; do
+   cp ${DTC_UPSTREAM_PATH}/$f ${f}_shipped
+   git add ${f}_shipped
+done
+
+git commit -e -v -m "scripts/dtc: Update to upstream version [CHANGEME]"
-- 
2.1.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 1/4] drivers: of: implement overlay support

2015-03-04 Thread Jan Luebbe
This is based on Pantelis Antoniou's overlay support for the kernel. It
has been simplified by leaving out transaction support, locking and
other details required by the Linux DT support.

It should support all features of the overlay file format as implemented
in linux 4.0-rc1.

Signed-off-by: Jan Luebbe 
---
 Documentation/user/devicetree.rst | 101 +-
 arch/sandbox/dts/Makefile |   5 +-
 arch/sandbox/dts/sandbox-overlay.dtso |  26 +++
 arch/sandbox/dts/sandbox.dts  |   6 +
 commands/oftree.c |  65 ++-
 drivers/of/Kconfig|   6 +
 drivers/of/Makefile   |   1 +
 drivers/of/overlay.c  | 234 +++
 drivers/of/resolver.c | 346 ++
 include/of.h  |  71 +++
 scripts/Makefile.lib  |   5 +-
 11 files changed, 857 insertions(+), 9 deletions(-)
 create mode 100644 arch/sandbox/dts/sandbox-overlay.dtso
 create mode 100644 drivers/of/overlay.c
 create mode 100644 drivers/of/resolver.c

diff --git a/Documentation/user/devicetree.rst 
b/Documentation/user/devicetree.rst
index 17934d86e3bf..b2220997d822 100644
--- a/Documentation/user/devicetree.rst
+++ b/Documentation/user/devicetree.rst
@@ -21,7 +21,7 @@ The internal devicetree
 ---
 
 The devicetree consulted by barebox plays a special role. It is referred to
-as the "internal devicetree." The barebox devicetree commands work on this
+as the "internal devicetree". The barebox devicetree commands work on this
 devicetree. The devicetree source (DTS) files are kept in sync with the kernel 
DTS
 files. As the FDT files are meant to be backward compatible, it should always 
be possible
 to start a kernel with the barebox internal devicetree. However, since the 
barebox
@@ -83,3 +83,102 @@ you can exchange the internal devicetree during runtime 
using the
 
oftree -f
oftree -l /new/dtb
+
+Devicetree overlays
+---
+
+Since version 3.19, the Linux kernel supports applying "devicetree overlays" to
+its loaded device tree. This can be used to inform the kernel about additional
+non-discoverable devices after the system has booted, which is useful for 
modular
+boards and FPGAs. The details of the overlay format are specified in the Linux
+`kernel documentation 
`_
+and an updated DTC is required to compile the overlays.
+
+The use cases for overlays in barebox are a bit different:
+
+* some of the modular devices are needed to boot Linux to userspace, but 
barebox
+  can detect which module variant is connected
+* one of several parallel or LVDS displays (which use timing data from 
devicetree)
+  can be connected to the SoC and should be used for boot messages
+* a generic Linux (distribution) kernel should be booted on a modular
+  system and support additional hardware on modules
+
+barebox supports applying overlays in the internal devicetree was well using 
the
+:ref:`command_oftree` command with option ``-o``:
+
+.. code-block:: sh
+
+   $ ./barebox -d arch/sandbox/dts/sandbox.dtb -i 
arch/sandbox/dts/sandbox-overlay.dtbo
+   add fd0 backed by file arch/sandbox/dts/sandbox-overlay.dtbo
+
+   barebox 2015.02.0 #26 Wed Mar 4 09:41:19 CET 2015
+   ...
+   barebox@barebox sandbox:/ of_dump
+   ...
+ dummy@0 {
+   status = "disabled";
+   linux,phandle = <0x1>;
+   phandle = <0x1>;
+ };
+ dummy@1 {
+   status = "disabled";
+   linux,phandle = <0x2>;
+   phandle = <0x2>;
+ };
+ __symbols__ {
+   dummy0 = "/dummy@0";
+   dummy1 = "/dummy@1";
+ };
+   ...
+   barebox@barebox sandbox:/ of_dump -f /dev/fd0
+{
+ fragment@0 {
+   target = <0xdeadbeef>;
+   __overlay__ {
+ status = "okay";
+ child {
+   compatible = "barebox,dummy";
+ };
+   };
+ };
+ fragment@1 {
+   target = <0xdeadbeef>;
+   __overlay__ {
+ status = "okay";
+ child {
+   compatible = "barebox,dummy";
+ };
+   };
+ };
+ __fixups__ {
+   dummy0 = "/fragment@0:target:0";
+   dummy1 = "/fragment@1:target:0";
+ };
+   };
+   barebox@barebox sandbox:/ oftree -o /dev/fd0
+   barebox@barebox sandbox:/ of_dump
+   ...
+ dummy@0 {
+   linux,phandle = <0x1>;
+   phandle = <0x1>;
+   status = "okay";
+   child {
+ compatible = "barebox,dummy";
+   };
+ };
+ dummy@1 {
+   linux,phandle = <0x2>;
+   phandle = <0x2>;
+   status = "okay";
+   child {
+ compatible = "barebox,dummy";
+   };
+ };
+ __symbols__ {
+   dummy0 = "/dummy@0";
+   dummy1 = "/dummy@1";
+ };
+   ...
+
+If you need to use a different base devicetree instead of the one compiled into
+barebox, it needs to be replaced as described in the previous section.
diff --git a/arch/

[PATCH 0/4] Device Tree Overlay Support

2015-03-04 Thread Jan Luebbe
This adds support for device tree overlays as supported by Linux 4.0-rc1.
Patches 2-4 update the included DTC with overlay support.

Jan Luebbe (4):
  drivers: of: implement overlay support
  scripts/dtc: import update-dtc-source.sh from kernel v4.0-rc1
  scripts/dtc: Update to upstream version 1.4.1
  scripts/dtc: Update to upstream version 1.4.1 with overlay support

 Documentation/user/devicetree.rst |  101 +-
 arch/sandbox/dts/Makefile |5 +-
 arch/sandbox/dts/sandbox-overlay.dtso |   26 +
 arch/sandbox/dts/sandbox.dts  |6 +
 commands/oftree.c |   65 +-
 drivers/of/Kconfig|6 +
 drivers/of/Makefile   |1 +
 drivers/of/overlay.c  |  234 
 drivers/of/resolver.c |  346 +
 include/of.h  |   71 +
 scripts/Makefile.lib  |5 +-
 scripts/dtc/checks.c  |  137 +-
 scripts/dtc/data.c|   12 +-
 scripts/dtc/dtc-lexer.l   |   72 +-
 scripts/dtc/dtc-lexer.lex.c_shipped   |  701 +-
 scripts/dtc/dtc-parser.tab.c_shipped  | 2411 -
 scripts/dtc/dtc-parser.tab.h_shipped  |  110 +-
 scripts/dtc/dtc-parser.y  |  169 +--
 scripts/dtc/dtc.c |  136 +-
 scripts/dtc/dtc.h |   59 +-
 scripts/dtc/fdt.c |   30 +-
 scripts/dtc/fdt.h |   93 +-
 scripts/dtc/fdt_addresses.c   |   96 ++
 scripts/dtc/fdt_ro.c  |7 +-
 scripts/dtc/fdt_rw.c  |   10 +-
 scripts/dtc/fdt_sw.c  |   36 +-
 scripts/dtc/fdt_wip.c |2 +-
 scripts/dtc/fdtdump.c |  135 +-
 scripts/dtc/fdtget.c  |   60 +-
 scripts/dtc/fdtput.c  |  225 ++-
 scripts/dtc/flattree.c|  206 ++-
 scripts/dtc/fstree.c  |   16 +-
 scripts/dtc/libfdt.h  |  133 +-
 scripts/dtc/libfdt/Makefile.libfdt|   10 -
 scripts/dtc/libfdt_env.h  |  104 +-
 scripts/dtc/libfdt_internal.h |6 +-
 scripts/dtc/livetree.c|4 +-
 scripts/dtc/srcpos.c  |   49 +-
 scripts/dtc/srcpos.h  |   15 +-
 scripts/dtc/treesource.c  |   14 +-
 scripts/dtc/update-dtc-source.sh  |   61 +
 scripts/dtc/util.c|  153 ++-
 scripts/dtc/util.h|  111 +-
 scripts/dtc/version_gen.h |2 +-
 44 files changed, 4104 insertions(+), 2147 deletions(-)
 create mode 100644 arch/sandbox/dts/sandbox-overlay.dtso
 create mode 100644 drivers/of/overlay.c
 create mode 100644 drivers/of/resolver.c
 create mode 100644 scripts/dtc/fdt_addresses.c
 delete mode 100644 scripts/dtc/libfdt/Makefile.libfdt
 create mode 100755 scripts/dtc/update-dtc-source.sh

-- 
2.1.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 4/4] scripts/dtc: Update to upstream version 1.4.1 with overlay support

2015-03-04 Thread Jan Luebbe
This contains Pantelis Antoniou's "dynamic DT support" v4:
* dtc: Symbol and local fixup generation support
* dtc: Plugin (object) device tree support.
* dtc: Document the dynamic plugin internals

Signed-off-by: Jan Luebbe 
---
 scripts/dtc/checks.c | 107 -
 scripts/dtc/dtc-lexer.l  |   5 +
 scripts/dtc/dtc-lexer.lex.c_shipped  | 433 +++--
 scripts/dtc/dtc-parser.tab.c_shipped | 732 ++-
 scripts/dtc/dtc-parser.tab.h_shipped |  46 +--
 scripts/dtc/dtc-parser.y |  34 +-
 scripts/dtc/dtc.c|   9 +-
 scripts/dtc/dtc.h|  40 ++
 scripts/dtc/fdtput.c |  85 +++-
 scripts/dtc/flattree.c   | 202 ++
 scripts/dtc/util.h   |   1 +
 scripts/dtc/version_gen.h|   2 +-
 12 files changed, 1105 insertions(+), 591 deletions(-)

diff --git a/scripts/dtc/checks.c b/scripts/dtc/checks.c
index 3bf0fa4a48d7..4be5233e5234 100644
--- a/scripts/dtc/checks.c
+++ b/scripts/dtc/checks.c
@@ -113,6 +113,7 @@ static inline void check_msg(struct check *c, const char 
*fmt, ...)
vfprintf(stderr, fmt, ap);
fprintf(stderr, "\n");
}
+   va_end(ap);
 }
 
 #define FAIL(c, ...) \
@@ -457,6 +458,8 @@ static void fixup_phandle_references(struct check *c, 
struct node *dt,
 struct node *node, struct property *prop)
 {
struct marker *m = prop->val.markers;
+   struct fixup *f, **fp;
+   struct fixup_entry *fe, **fep;
struct node *refnode;
cell_t phandle;
 
@@ -465,14 +468,73 @@ static void fixup_phandle_references(struct check *c, 
struct node *dt,
 
refnode = get_node_by_ref(dt, m->ref);
if (! refnode) {
-   FAIL(c, "Reference to non-existent node or label 
\"%s\"\n",
-m->ref);
+   if (!dt->is_plugin) {
+   FAIL(c, "Reference to non-existent node or 
label \"%s\"\n",
+   m->ref);
+   continue;
+   }
+
+   /* allocate fixup entry */
+   fe = xmalloc(sizeof(*fe));
+
+   fe->node = node;
+   fe->prop = prop;
+   fe->offset = m->offset;
+   fe->next = NULL;
+
+   /* search for an already existing fixup */
+   for_each_fixup(dt, f)
+   if (strcmp(f->ref, m->ref) == 0)
+   break;
+
+   /* no fixup found, add new */
+   if (f == NULL) {
+   f = xmalloc(sizeof(*f));
+   f->ref = m->ref;
+   f->entries = NULL;
+   f->next = NULL;
+
+   /* add it to the tree */
+   fp = &dt->fixups;
+   while (*fp)
+   fp = &(*fp)->next;
+   *fp = f;
+   }
+
+   /* and now append fixup entry */
+   fep = &f->entries;
+   while (*fep)
+   fep = &(*fep)->next;
+   *fep = fe;
+
+   /* mark the entry as unresolved */
+   *((cell_t *)(prop->val.val + m->offset)) =
+   cpu_to_fdt32(0xdeadbeef);
continue;
}
 
+   /* if it's a local reference, we need to record it */
+   if (symbol_fixup_support) {
+
+   /* allocate a new local fixup entry */
+   fe = xmalloc(sizeof(*fe));
+
+   fe->node = node;
+   fe->prop = prop;
+   fe->offset = m->offset;
+   fe->next = NULL;
+
+   /* append it to the local fixups */
+   fep = &dt->local_fixups;
+   while (*fep)
+   fep = &(*fep)->next;
+   *fep = fe;
+   }
+
phandle = get_node_phandle(dt, refnode);
*((cell_t *)(prop->val.val + m->offset)) = 
cpu_to_fdt32(phandle);
}
+
 }
 ERROR(phandle_references, NULL, NULL, fixup_phandle_references, NULL,
   &duplicate_node_names, &explicit_phandles);
@@ -651,6 +713,45 @@ static void 
check_obsolete_chosen_interrupt_controller(struct check *c,
 }
 TREE_WARNING(obsolete_chosen_interrupt_controller, NULL);
 
+static void check_auto_label_phandles(struct check *c, struct node *dt,
+  struct node *node)
+{
+   struct 

Re: [PATCH 2/2] remove unnecessary device pointer argument

2015-03-04 Thread Jean-Christophe PLAGNIOL-VILLARD

> On Mar 4, 2015, at 3:49 PM, Sascha Hauer  wrote:
> 
> The struct device_d * argument is not necessary, it can be retrieved from
> the FILE *. This adds a convenience function for doing this and removes
> the struct device_d * argument from the the filesystem drivers functions.

if you do so you should introduce fs_warn/info & co too

so we de not use dev_xxx version in fs

Best Regards,
J.
> 
> Signed-off-by: Sascha Hauer 
> ---
> fs/bpkfs.c| 10 +-
> fs/cramfs/cramfs.c| 12 ++--
> fs/devfs.c| 22 +++---
> fs/efi.c  | 12 ++--
> fs/ext4/ext_barebox.c | 12 ++--
> fs/fat/fat.c  | 16 
> fs/fs.c   | 24 
> fs/nfs.c  | 31 +--
> fs/omap4_usbbootfs.c  | 17 +++--
> fs/ramfs.c| 14 +++---
> fs/tftp.c | 21 +++--
> fs/ubifs/ubifs.c  | 10 +-
> fs/uimagefs.c | 14 +++---
> include/fs.h  | 27 ---
> 14 files changed, 124 insertions(+), 118 deletions(-)
> 
> diff --git a/fs/bpkfs.c b/fs/bpkfs.c
> index 1e2619e..94b5379 100644
> --- a/fs/bpkfs.c
> +++ b/fs/bpkfs.c
> @@ -126,9 +126,9 @@ static struct bpkfs_handle_data *bpkfs_get_by_type(
>   return NULL;
> }
> 
> -static int bpkfs_open(struct device_d *dev, FILE *f, const char *filename)
> +static int bpkfs_open(FILE *f, const char *filename)
> {
> - struct bpkfs_handle *priv = dev->priv;
> + struct bpkfs_handle *priv = fs_driver_priv(f);
>   struct bpkfs_handle_data *d;
>   struct bpkfs_handle_hw *h;
>   char *dir, *file;
> @@ -170,7 +170,7 @@ out:
>   return ret;
> }
> 
> -static int bpkfs_close(struct device_d *dev, FILE *file)
> +static int bpkfs_close(FILE *file)
> {
>   struct bpkfs_handle_data *d = file->priv;
> 
> @@ -179,7 +179,7 @@ static int bpkfs_close(struct device_d *dev, FILE *file)
>   return 0;
> }
> 
> -static int bpkfs_read(struct device_d *dev, FILE *file, void *buf, size_t 
> insize)
> +static int bpkfs_read(FILE *file, void *buf, size_t insize)
> {
>   struct bpkfs_handle_data *d = file->priv;
> 
> @@ -191,7 +191,7 @@ static int bpkfs_read(struct device_d *dev, FILE *file, 
> void *buf, size_t insize
>   }
> }
> 
> -static loff_t bpkfs_lseek(struct device_d *dev, FILE *file, loff_t pos)
> +static loff_t bpkfs_lseek(FILE *file, loff_t pos)
> {
>   struct bpkfs_handle_data *d = file->priv;
> 
> diff --git a/fs/cramfs/cramfs.c b/fs/cramfs/cramfs.c
> index fb92714..d53421b 100644
> --- a/fs/cramfs/cramfs.c
> +++ b/fs/cramfs/cramfs.c
> @@ -274,9 +274,9 @@ static int cramfs_closedir(struct device_d *dev, DIR 
> *_dir)
>   return 0;
> }
> 
> -static int cramfs_open(struct device_d *_dev, FILE *file, const char 
> *filename)
> +static int cramfs_open(FILE *file, const char *filename)
> {
> - struct cramfs_priv *priv = _dev->priv;
> + struct cramfs_priv *priv = fs_driver_priv(file);
>   struct cramfs_inode_info *inodei;
>   char *f;
> 
> @@ -299,7 +299,7 @@ static int cramfs_open(struct device_d *_dev, FILE *file, 
> const char *filename)
>   return 0;
> }
> 
> -static int cramfs_close(struct device_d *dev, FILE *file)
> +static int cramfs_close(FILE *file)
> {
>   struct cramfs_inode_info *inodei = file->priv;
> 
> @@ -309,9 +309,9 @@ static int cramfs_close(struct device_d *dev, FILE *file)
>   return 0;
> }
> 
> -static int cramfs_read(struct device_d *_dev, FILE *f, void *buf, size_t 
> size)
> +static int cramfs_read(FILE *f, void *buf, size_t size)
> {
> - struct cramfs_priv *priv = _dev->priv;
> + struct cramfs_priv *priv = fs_driver_priv(f);
>   struct cramfs_inode_info *inodei = f->priv;
>   struct cramfs_inode *inode = &inodei->inode;
>   unsigned int blocknr;
> @@ -358,7 +358,7 @@ static int cramfs_read(struct device_d *_dev, FILE *f, 
> void *buf, size_t size)
>   return outsize;
> }
> 
> -static loff_t cramfs_lseek(struct device_d *dev, FILE *f, loff_t pos)
> +static loff_t cramfs_lseek(FILE *f, loff_t pos)
> {
>   f->pos = pos;
>   return f->pos;
> diff --git a/fs/devfs.c b/fs/devfs.c
> index c6db25c..4da21d4 100644
> --- a/fs/devfs.c
> +++ b/fs/devfs.c
> @@ -35,14 +35,14 @@
> 
> extern struct list_head cdev_list;
> 
> -static int devfs_read(struct device_d *_dev, FILE *f, void *buf, size_t size)
> +static int devfs_read(FILE *f, void *buf, size_t size)
> {
>   struct cdev *cdev = f->priv;
> 
>   return cdev_read(cdev, buf, size, f->pos, f->flags);
> }
> 
> -static int devfs_write(struct device_d *_dev, FILE *f, const void *buf, 
> size_t size)
> +static int devfs_write(FILE *f, const void *buf, size_t size)
> {
>   struct cdev *cdev = f->priv;
> 
> @@ -52,7 +52,7 @@ static int devfs_write(struct device_d *_dev, FILE *f, 
> const void *buf, size_t s
>   return cdev_write(cdev, buf, size, f->pos, f->flags);
> }
> 
> -static 

[PATCH 2/2] ARM: i.MX: remove __naked from imx*_barebox_entry

2015-03-04 Thread Sascha Hauer
Since the stack is already configured when entering imx*_barebox_entry
we can remove the __naked attribute. This fixes some compilation issues
when some of the imx*_barebox_entry got too complicated to compile without
stack.

Signed-off-by: Sascha Hauer 
---
 arch/arm/mach-imx/esdctl.c  | 14 +++---
 arch/arm/mach-imx/include/mach/esdctl.h | 16 
 2 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/arch/arm/mach-imx/esdctl.c b/arch/arm/mach-imx/esdctl.c
index c6479a0..0a71db6 100644
--- a/arch/arm/mach-imx/esdctl.c
+++ b/arch/arm/mach-imx/esdctl.c
@@ -480,7 +480,7 @@ upper_or_coalesced_range(unsigned long base0, unsigned long 
size0,
}
 }
 
-void __naked __noreturn imx1_barebox_entry(void *boarddata)
+void __noreturn imx1_barebox_entry(void *boarddata)
 {
unsigned long base, size;
 
@@ -493,7 +493,7 @@ void __naked __noreturn imx1_barebox_entry(void *boarddata)
barebox_arm_entry(base, size, boarddata);
 }
 
-void __naked __noreturn imx25_barebox_entry(void *boarddata)
+void __noreturn imx25_barebox_entry(void *boarddata)
 {
unsigned long base, size;
 
@@ -506,7 +506,7 @@ void __naked __noreturn imx25_barebox_entry(void *boarddata)
barebox_arm_entry(base, size, boarddata);
 }
 
-void __naked __noreturn imx27_barebox_entry(void *boarddata)
+void __noreturn imx27_barebox_entry(void *boarddata)
 {
unsigned long base, size;
 
@@ -521,7 +521,7 @@ void __naked __noreturn imx27_barebox_entry(void *boarddata)
barebox_arm_entry(base, size, boarddata);
 }
 
-void __naked __noreturn imx31_barebox_entry(void *boarddata)
+void __noreturn imx31_barebox_entry(void *boarddata)
 {
unsigned long base, size;
 
@@ -536,7 +536,7 @@ void __naked __noreturn imx31_barebox_entry(void *boarddata)
barebox_arm_entry(base, size, boarddata);
 }
 
-void __naked __noreturn imx35_barebox_entry(void *boarddata)
+void __noreturn imx35_barebox_entry(void *boarddata)
 {
unsigned long base, size;
 
@@ -551,7 +551,7 @@ void __naked __noreturn imx35_barebox_entry(void *boarddata)
barebox_arm_entry(base, size, boarddata);
 }
 
-void __naked __noreturn imx51_barebox_entry(void *boarddata)
+void __noreturn imx51_barebox_entry(void *boarddata)
 {
unsigned long base, size;
 
@@ -564,7 +564,7 @@ void __naked __noreturn imx51_barebox_entry(void *boarddata)
barebox_arm_entry(base, size, boarddata);
 }
 
-void __naked __noreturn imx53_barebox_entry(void *boarddata)
+void __noreturn imx53_barebox_entry(void *boarddata)
 {
unsigned long base, size;
 
diff --git a/arch/arm/mach-imx/include/mach/esdctl.h 
b/arch/arm/mach-imx/include/mach/esdctl.h
index 28d44da..468a928 100644
--- a/arch/arm/mach-imx/include/mach/esdctl.h
+++ b/arch/arm/mach-imx/include/mach/esdctl.h
@@ -128,14 +128,14 @@
 #define ESDCFGx_tRC_16 0x000f
 
 #ifndef __ASSEMBLY__
-void __naked __noreturn imx1_barebox_entry(void *boarddata);
-void __naked __noreturn imx25_barebox_entry(void *boarddata);
-void __naked __noreturn imx27_barebox_entry(void *boarddata);
-void __naked __noreturn imx31_barebox_entry(void *boarddata);
-void __naked __noreturn imx35_barebox_entry(void *boarddata);
-void __naked __noreturn imx51_barebox_entry(void *boarddata);
-void __naked __noreturn imx53_barebox_entry(void *boarddata);
-void __naked __noreturn imx6_barebox_entry(void *boarddata);
+void __noreturn imx1_barebox_entry(void *boarddata);
+void __noreturn imx25_barebox_entry(void *boarddata);
+void __noreturn imx27_barebox_entry(void *boarddata);
+void __noreturn imx31_barebox_entry(void *boarddata);
+void __noreturn imx35_barebox_entry(void *boarddata);
+void __noreturn imx51_barebox_entry(void *boarddata);
+void __noreturn imx53_barebox_entry(void *boarddata);
+void __noreturn imx6_barebox_entry(void *boarddata);
 void imx_esdctl_disable(void);
 #endif
 
-- 
2.1.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


[PATCH 1/2] ARM: i.MX: boards: Setup stack before calling imx*_barebox_entry

2015-03-04 Thread Sascha Hauer
This allows imx*_barebox_entry to use the stack.

Signed-off-by: Sascha Hauer 
---
 arch/arm/boards/eukrea_cpuimx25/lowlevel.c |  9 -
 arch/arm/boards/eukrea_cpuimx27/lowlevel_init.S|  5 ++---
 arch/arm/boards/eukrea_cpuimx35/lowlevel.c |  5 ++---
 arch/arm/boards/eukrea_cpuimx51/lowlevel.c |  1 +
 arch/arm/boards/freescale-mx25-3ds/lowlevel_init.S |  6 +++---
 arch/arm/boards/freescale-mx27-ads/lowlevel_init.S |  2 ++
 arch/arm/boards/freescale-mx35-3ds/lowlevel_init.S |  6 +++---
 arch/arm/boards/freescale-mx51-babbage/lowlevel.c  |  1 +
 arch/arm/boards/freescale-mx53-qsb/lowlevel.c  |  2 ++
 arch/arm/boards/freescale-mx53-smd/lowlevel.c  |  1 +
 arch/arm/boards/freescale-mx53-vmx53/lowlevel.c|  1 +
 arch/arm/boards/guf-cupid/lowlevel.c   |  3 ---
 arch/arm/boards/guf-neso/lowlevel.c|  8 +++-
 arch/arm/boards/guf-vincell/lowlevel.c |  1 +
 arch/arm/boards/karo-tx51/lowlevel.c   |  1 +
 arch/arm/boards/karo-tx53/lowlevel.c   |  1 +
 arch/arm/boards/phytec-phycore-imx31/lowlevel.c| 10 --
 arch/arm/boards/phytec-phycore-imx35/lowlevel.c|  5 ++---
 arch/arm/boards/scb9328/lowlevel_init.S|  4 +++-
 19 files changed, 37 insertions(+), 35 deletions(-)

diff --git a/arch/arm/boards/eukrea_cpuimx25/lowlevel.c 
b/arch/arm/boards/eukrea_cpuimx25/lowlevel.c
index 4edbbe4..7ae8a18 100644
--- a/arch/arm/boards/eukrea_cpuimx25/lowlevel.c
+++ b/arch/arm/boards/eukrea_cpuimx25/lowlevel.c
@@ -37,6 +37,8 @@ void __bare_init __naked barebox_arm_reset_vector(void)
 
arm_cpu_lowlevel_init();
 
+   arm_setup_stack(MX25_IRAM_BASE_ADDR + MX25_IRAM_SIZE - 12);
+
/* restart the MPLL and wait until it's stable */
writel(readl(MX25_CCM_BASE_ADDR + MX25_CCM_CCTL) | (1 << 27),
MX25_CCM_BASE_ADDR + MX25_CCM_CCTL);
@@ -127,12 +129,9 @@ void __bare_init __naked barebox_arm_reset_vector(void)
writeb(0xda, MX25_CSD0_BASE_ADDR + 0x100);
writel(0x82216080, MX25_ESDCTL_BASE_ADDR + IMX_ESDCTL0);
 
-   if (IS_ENABLED(CONFIG_ARCH_IMX_EXTERNAL_BOOT_NAND)) {
-   /* setup a stack to be able to call 
imx25_barebox_boot_nand_external() */
-   arm_setup_stack(MX25_IRAM_BASE_ADDR + MX25_IRAM_SIZE - 12);
-
+   if (IS_ENABLED(CONFIG_ARCH_IMX_EXTERNAL_BOOT_NAND))
imx25_barebox_boot_nand_external(0);
-   }
+
 out:
imx25_barebox_entry(NULL);
 }
diff --git a/arch/arm/boards/eukrea_cpuimx27/lowlevel_init.S 
b/arch/arm/boards/eukrea_cpuimx27/lowlevel_init.S
index f8e3c23..b350483 100644
--- a/arch/arm/boards/eukrea_cpuimx27/lowlevel_init.S
+++ b/arch/arm/boards/eukrea_cpuimx27/lowlevel_init.S
@@ -76,6 +76,8 @@ barebox_arm_reset_vector:
 
bl  arm_cpu_lowlevel_init
 
+   ldr sp, =MX27_IRAM_BASE_ADDR + MX27_IRAM_SIZE - 4;
+
/* ahb lite ip interface */
writel(0x20040304, MX27_AIPI_BASE_ADDR + MX27_AIPI1_PSR0)
writel(0xDFFBFCFB, MX27_AIPI_BASE_ADDR + MX27_AIPI1_PSR1)
@@ -124,9 +126,6 @@ barebox_arm_reset_vector:
sdram_init
 
 #ifdef CONFIG_ARCH_IMX_EXTERNAL_BOOT_NAND
-   /* Setup a temporary stack in SDRAM */
-   ldr sp, =MX27_IRAM_BASE_ADDR + MX27_IRAM_SIZE - 4;
-
mov r0, #0
b   imx27_barebox_boot_nand_external
 #endif /* CONFIG_ARCH_IMX_EXTERNAL_BOOT_NAND */
diff --git a/arch/arm/boards/eukrea_cpuimx35/lowlevel.c 
b/arch/arm/boards/eukrea_cpuimx35/lowlevel.c
index 4788ae2..83c25fe 100644
--- a/arch/arm/boards/eukrea_cpuimx35/lowlevel.c
+++ b/arch/arm/boards/eukrea_cpuimx35/lowlevel.c
@@ -43,6 +43,8 @@ void __bare_init __naked barebox_arm_reset_vector(void)
 
arm_cpu_lowlevel_init();
 
+   arm_setup_stack(MX35_IRAM_BASE_ADDR + MX35_IRAM_SIZE - 8);
+
r = get_cr();
r |= CR_Z; /* Flow prediction (Z) */
r |= CR_U; /* unaligned accesses  */
@@ -137,9 +139,6 @@ void __bare_init __naked barebox_arm_reset_vector(void)
r |= 0x1 << 28;
writel(r, MX35_CCM_BASE_ADDR + MX35_CCM_PDR4);
 
-   /* setup a stack to be able to call 
imx35_barebox_boot_nand_external() */
-   arm_setup_stack(MX35_IRAM_BASE_ADDR + MX35_IRAM_SIZE - 8);
-
imx35_barebox_boot_nand_external(0);
}
 
diff --git a/arch/arm/boards/eukrea_cpuimx51/lowlevel.c 
b/arch/arm/boards/eukrea_cpuimx51/lowlevel.c
index 7a85b48..ad89076 100644
--- a/arch/arm/boards/eukrea_cpuimx51/lowlevel.c
+++ b/arch/arm/boards/eukrea_cpuimx51/lowlevel.c
@@ -6,5 +6,6 @@
 void __naked barebox_arm_reset_vector(void)
 {
imx5_cpu_lowlevel_init();
+   arm_setup_stack(0x2000 - 16);
imx51_barebox_entry(NULL);
 }
diff --git a/arch/arm/boards/freescale-mx25-3ds/lowlevel_init.S 
b/arch/arm/boards/freescale-mx25-3ds/lowlevel_init.S
index 4ca4c82..16a9c41 100644
--- a/arch/arm/boards/freescale-mx25-3ds/lowlevel_init.S
+++ b/arch/arm/boards/freesc

[PATCH] ARM: i.MX53 QSB: remove unused /dev/env0 partition

2015-03-04 Thread Sascha Hauer
The environment on the QSB is configured via devicetree, but in
the code there's also a /dev/env0 registered which is unused. Remove
it.

Signed-off-by: Sascha Hauer 
---
 arch/arm/boards/freescale-mx53-qsb/board.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/arch/arm/boards/freescale-mx53-qsb/board.c 
b/arch/arm/boards/freescale-mx53-qsb/board.c
index f65b556..dd2abb5 100644
--- a/arch/arm/boards/freescale-mx53-qsb/board.c
+++ b/arch/arm/boards/freescale-mx53-qsb/board.c
@@ -85,10 +85,6 @@ static int loco_late_init(void)
!of_machine_is_compatible("fsl,imx53-qsrb"))
return 0;
 
-   device_detect_by_name("mmc0");
-
-   devfs_add_partition("mmc0", 0x4, 0x2, DEVFS_PARTITION_FIXED, 
"env0");
-
mc34708 = mc13xxx_get();
if (mc34708) {
unsigned int val;
-- 
2.1.4


___
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox