mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* Re: [PATCH 11/20] i.MX: Add VF610 clock tree initialization code
From: Andrey Smirnov @ 2016-10-04 13:44 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox@lists.infradead.org
In-Reply-To: <20161004065811.vsvvya5csazebcfg@pengutronix.de>

On Mon, Oct 3, 2016 at 11:58 PM, Sascha Hauer <s.hauer@pengutronix.de> wrote:
> On Mon, Oct 03, 2016 at 07:40:48AM -0700, Andrey Smirnov wrote:
>> Based on analogous code from Linux kernel
>>
>> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
>> ---
>>  drivers/clk/imx/Makefile    |    1 +
>>  drivers/clk/imx/clk-vf610.c | 1224 +++++++++++++++++++++++++++++++++++++++++++
>>  2 files changed, 1225 insertions(+)
>>  create mode 100644 drivers/clk/imx/clk-vf610.c
>>
>> diff --git a/drivers/clk/imx/Makefile b/drivers/clk/imx/Makefile
>> index 0303c0b..2665f49 100644
>> --- a/drivers/clk/imx/Makefile
>> +++ b/drivers/clk/imx/Makefile
>> @@ -1 +1,2 @@
>>  obj-y += clk.o
>> +obj-$(CONFIG_ARCH_VF610) += clk-vf610.o
>> +static struct clk *clk[VF610_CLK_END];
>> +struct clk_onecell_data clk_data;
>> +
>> +static struct clk * __init vf610_get_fixed_clock(struct device_node *np,
>> +                                              const char *name)
>> +{
>> +     struct clk *clk = of_clk_get_by_name(np, name);
>> +
>> +     /* Backward compatibility if device tree is missing clks assignments */
>> +     if (IS_ERR(clk))
>> +             clk = imx_obtain_fixed_clock(name, 0);
>
> Ah, that explains it. No, we don't need this since we are compiling the
> device trees into barebox and can make sure they are compatible with our
> code.

OK, will fix in v2.
Thanks,
Andrey

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

^ permalink raw reply

* Re: [PATCH 10/20] i.MX: clk: Port imx_check_clocks() and imx_obtain_fixed_clock()
From: Andrey Smirnov @ 2016-10-04 13:43 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox@lists.infradead.org
In-Reply-To: <20161004064923.txvdncnm57xwor5h@pengutronix.de>

On Mon, Oct 3, 2016 at 11:49 PM, Sascha Hauer <s.hauer@pengutronix.de> wrote:
> On Mon, Oct 03, 2016 at 07:40:47AM -0700, Andrey Smirnov wrote:
>> Port imx_check_clocks() and imx_obtain_fixed_clock() from Linux kernel.
>>
>> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
>> ---
>>  arch/arm/mach-imx/clk.h  |  4 ++++
>>  drivers/clk/Makefile     |  1 +
>>  drivers/clk/imx/Makefile |  1 +
>>  drivers/clk/imx/clk.c    | 49 ++++++++++++++++++++++++++++++++++++++++++++++++
>>  4 files changed, 55 insertions(+)
>>  create mode 100644 drivers/clk/imx/Makefile
>>  create mode 100644 drivers/clk/imx/clk.c
>>
>> diff --git a/arch/arm/mach-imx/clk.h b/arch/arm/mach-imx/clk.h
>> index 35e480f..f96e5d2 100644
>> --- a/arch/arm/mach-imx/clk.h
>> +++ b/arch/arm/mach-imx/clk.h
>> @@ -109,4 +109,8 @@ static inline struct clk *imx_clk_busy_mux(const char *name, void __iomem *reg,
>>  struct clk *imx_clk_gate_exclusive(const char *name, const char *parent,
>>               void __iomem *reg, u8 shift, u32 exclusive_mask);
>>
>> +void imx_check_clocks(struct clk *clks[], unsigned int count);
>> +struct clk * __init imx_obtain_fixed_clock(const char *name, unsigned long rate);
>> +
>> +
>>  #endif /* __IMX_CLK_H */
>> diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
>> index 0fe8f1e..6dc82ea 100644
>> --- a/drivers/clk/Makefile
>> +++ b/drivers/clk/Makefile
>> @@ -9,3 +9,4 @@ obj-$(CONFIG_ARCH_ROCKCHIP)   += rockchip/
>>  obj-$(CONFIG_ARCH_TEGRA)     += tegra/
>>  obj-$(CONFIG_CLK_SOCFPGA)    += socfpga.o
>>  obj-$(CONFIG_MACH_MIPS_ATH79)        += clk-ar933x.o
>> +obj-$(CONFIG_COMMON_CLK)     += imx/
>> diff --git a/drivers/clk/imx/Makefile b/drivers/clk/imx/Makefile
>> new file mode 100644
>> index 0000000..0303c0b
>> --- /dev/null
>> +++ b/drivers/clk/imx/Makefile
>> @@ -0,0 +1 @@
>> +obj-y += clk.o
>> diff --git a/drivers/clk/imx/clk.c b/drivers/clk/imx/clk.c
>> new file mode 100644
>> index 0000000..0357048
>> --- /dev/null
>> +++ b/drivers/clk/imx/clk.c
>
> We currently have the i.MX clock support in arch/arm/mach-imx/. This may
> or may not be changed, but until it is, other i.MX clock support code
> should go to arch/arm/mach-imx/ aswell.

My preference would be to try to move the rest of i.MX clock code to
drivers/clk, to reconcile with how it is done in Linux kernel. Is that
OK with you or would you rather I move everything to
arch/arm/mach-imx?

>
>> @@ -0,0 +1,49 @@
>> +#include <common.h>
>> +#include <init.h>
>> +#include <driver.h>
>> +#include <linux/clk.h>
>> +#include <io.h>
>> +#include <of.h>
>> +#include <linux/clkdev.h>
>> +#include <linux/err.h>
>> +
>> +#include "../../../arch/arm/mach-imx/clk.h"
>
> #include <mach/clk.h>
>
>> +
>> +void __init imx_check_clocks(struct clk *clks[], unsigned int count)
>> +{
>> +     unsigned i;
>> +
>> +     for (i = 0; i < count; i++)
>> +             if (IS_ERR(clks[i]))
>> +                     pr_err("i.MX clk %u: register failed with %ld\n",
>> +                            i, PTR_ERR(clks[i]));
>> +}
>> +
>> +static struct clk * __init imx_obtain_fixed_clock_from_dt(const char *name)
>> +{
>> +     struct of_phandle_args phandle;
>> +     struct clk *clk = ERR_PTR(-ENODEV);
>> +     char *path;
>> +
>> +     path = basprintf("/clocks/%s", name);
>> +     if (!path)
>> +             return ERR_PTR(-ENOMEM);
>> +
>> +     phandle.np = of_find_node_by_path(path);
>> +     kfree(path);
>> +
>> +     if (phandle.np)
>> +             clk = of_clk_get_from_provider(&phandle);
>> +
>> +     return clk;
>> +}
>
> Do we need this anyway? We already have clk providers for fixed-clock.
> Hm, looking further, maybe a later patch explains.

OK, I'll remove it and add DT fixes if needed in v2.

Thanks,
Andrey

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

^ permalink raw reply

* Re: [PATCH 07/20] clk: Port of_clk_set_defautls()
From: Andrey Smirnov @ 2016-10-04 13:36 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox@lists.infradead.org
In-Reply-To: <20161004063853.5p7xulewpbuuacxv@pengutronix.de>

On Mon, Oct 3, 2016 at 11:38 PM, Sascha Hauer <s.hauer@pengutronix.de> wrote:
> On Mon, Oct 03, 2016 at 07:40:44AM -0700, Andrey Smirnov wrote:
>> Port of_clk_set_defautls() from Linux kernel in order to support DT
>> configurations that require it (e. g. Vybrid).
>
> s/of_clk_set_defautls/of_clk_set_defaults/ here and in the subject.
>
>> diff --git a/include/linux/clk/clk-conf.h b/include/linux/clk/clk-conf.h
>> new file mode 100644
>> index 0000000..2c0a39e
>> --- /dev/null
>> +++ b/include/linux/clk/clk-conf.h
>> @@ -0,0 +1,22 @@
>> +/*
>> + * Copyright (C) 2014 Samsung Electronics Co., Ltd.
>> + * Sylwester Nawrocki <s.nawrocki@samsung.com>
>> + *
>> + * This program is free software; you can redistribute it and/or modify
>> + * it under the terms of the GNU General Public License version 2 as
>> + * published by the Free Software Foundation.
>> + */
>> +
>> +#include <linux/types.h>
>> +
>> +struct device_node;
>> +
>> +#if defined(CONFIG_OFTREE) && defined(CONFIG_COMMON_CLK)
>> +int of_clk_set_defaults(struct device_node *node, bool clk_supplier);
>> +#else
>> +static inline int of_clk_set_defaults(struct device_node *node,
>> +                                   bool clk_supplier)
>> +{
>> +     return 0;
>> +}
>> +#endif
>
> We shouldn't need this static inline variant. The caller already exists for OF
> enabled builds only.

OK, will remove in v2.

Thanks,
Andrey

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

^ permalink raw reply

* Re: [PATCH 04/20] i.MX: Add support for VF610 Tower board
From: Andrey Smirnov @ 2016-10-04 13:34 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox@lists.infradead.org
In-Reply-To: <20161004063214.2rguzsvtq4aste5x@pengutronix.de>

On Mon, Oct 3, 2016 at 11:32 PM, Sascha Hauer <s.hauer@pengutronix.de> wrote:
> On Mon, Oct 03, 2016 at 07:40:41AM -0700, Andrey Smirnov wrote:
>> Add support for VF610 Tower board.
>>
>> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
>> ---
>>  arch/arm/boards/Makefile                           |   3 +-
>>  arch/arm/boards/freescale-vf610-twr/Makefile       |   4 +
>>  arch/arm/boards/freescale-vf610-twr/board.c        |  61 +++++
>>  .../flash-header-vf610-twr.imxcfg                  | 277 +++++++++++++++++++++
>>  arch/arm/boards/freescale-vf610-twr/lowlevel.c     |  45 ++++
>>  arch/arm/dts/Makefile                              |   1 +
>>  arch/arm/dts/vf610-twr.dts                         |  14 ++
>>  arch/arm/mach-imx/Kconfig                          |   4 +
>>  arch/arm/mach-imx/include/mach/clock-vf610.h       | 215 ++++++++++++++++
>>  arch/arm/mach-imx/include/mach/iomux-vf610.h       | 258 +++++++++++++++++++
>>  images/Makefile.imx                                |   5 +
>>  11 files changed, 886 insertions(+), 1 deletion(-)
>>  create mode 100644 arch/arm/boards/freescale-vf610-twr/Makefile
>>  create mode 100644 arch/arm/boards/freescale-vf610-twr/board.c
>>  create mode 100644 arch/arm/boards/freescale-vf610-twr/flash-header-vf610-twr.imxcfg
>>  create mode 100644 arch/arm/boards/freescale-vf610-twr/lowlevel.c
>>  create mode 100644 arch/arm/dts/vf610-twr.dts
>>  create mode 100644 arch/arm/mach-imx/include/mach/clock-vf610.h
>>  create mode 100644 arch/arm/mach-imx/include/mach/iomux-vf610.h
>>
>> diff --git a/arch/arm/boards/Makefile b/arch/arm/boards/Makefile
>> index 23a8dbd..c8bc565 100644
>> --- a/arch/arm/boards/Makefile
>> +++ b/arch/arm/boards/Makefile
>> @@ -10,7 +10,7 @@ obj-$(CONFIG_MACH_AT91SAM9G20EK)            += at91sam9260ek/
>>  obj-$(CONFIG_MACH_AT91SAM9M10G45EK)          += at91sam9m10g45ek/
>>  obj-$(CONFIG_MACH_AT91SAM9M10IHD)            += at91sam9m10ihd/
>>  obj-$(CONFIG_MACH_AT91SAM9N12EK)             += at91sam9n12ek/
>> -obj-$(CONFIG_MACH_AT91SAM9X5EK)                      += at91sam9x5ek/
>> +nobj-$(CONFIG_MACH_AT91SAM9X5EK)                     += at91sam9x5ek/
>>  obj-$(CONFIG_MACH_BEAGLE)                    += beagle/
>>  obj-$(CONFIG_MACH_BEAGLEBONE)                        += beaglebone/
>>  obj-$(CONFIG_MACH_CANON_A1100)                       += canon-a1100/
>> @@ -138,3 +138,4 @@ obj-$(CONFIG_MACH_ZEDBOARD)                       += avnet-zedboard/
>>  obj-$(CONFIG_MACH_ZYLONITE)                  += zylonite/
>>  obj-$(CONFIG_MACH_VARISCITE_MX6)             += variscite-mx6/
>>  obj-$(CONFIG_MACH_QEMU_VIRT64)                       += qemu-virt64/
>> +obj-$(CONFIG_MACH_VF610_TWR)                 += freescale-vf610-twr/
>> diff --git a/arch/arm/boards/freescale-vf610-twr/Makefile b/arch/arm/boards/freescale-vf610-twr/Makefile
>> new file mode 100644
>> index 0000000..32a7da5
>> --- /dev/null
>> +++ b/arch/arm/boards/freescale-vf610-twr/Makefile
>> @@ -0,0 +1,4 @@
>> +obj-y += board.o
>> +obj-y += flash-header-vf610-twr.dcd.o
>> +extra-y += flash-header-vf610-twr.dcd.S flash-header-vf610-twr.dcd
>> +lwl-y += lowlevel.o
>> diff --git a/arch/arm/boards/freescale-vf610-twr/board.c b/arch/arm/boards/freescale-vf610-twr/board.c
>> new file mode 100644
>> index 0000000..0879f74
>> --- /dev/null
>> +++ b/arch/arm/boards/freescale-vf610-twr/board.c
>> @@ -0,0 +1,61 @@
>> +/*
>> + * Copyright (c) 2016 Zodiac Inflight Innovation
>> + * Author: Andrey Smirnov <andrew.smirnov@gmail.com>
>> + *
>> + * 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 <config.h>
>> +#include <common.h>
>> +#include <dma.h>
>> +#include <driver.h>
>> +#include <init.h>
>> +#include <of.h>
>> +#include <malloc.h>
>> +#include <mci.h>
>> +#include <clock.h>
>> +#include <io.h>
>> +#include <linux/clk.h>
>> +#include <linux/err.h>
>> +
>> +/*
>> + * Make sure that esdhc1's clock divider is 1
>> + */
>> +static int vf610_twr_sdhc1_clock_init(void)
>> +{
>> +     int err;
>> +     struct clk *esdhc1_div, *esdhc1_div_parent;
>> +
>> +     if (!of_machine_is_compatible("fsl,vf610-twr"))
>> +             return 0;
>> +
>> +     esdhc1_div = clk_lookup("esdhc1_div");
>> +
>> +     if (IS_ERR(esdhc1_div))
>> +             return PTR_ERR(esdhc1_div);
>> +
>> +     esdhc1_div_parent = clk_get_parent(esdhc1_div);
>> +     if (IS_ERR(esdhc1_div_parent))
>> +             return PTR_ERR(esdhc1_div_parent);
>> +
>> +     err = clk_set_rate(esdhc1_div,
>> +                        clk_get_rate(esdhc1_div_parent));
>> +     if (err)
>> +             return err;
>> +
>> +     clk_put(esdhc1_div);
>> +
>> +     return 0;
>> +}
>> +coredevice_initcall(vf610_twr_sdhc1_clock_init);
>
> What's the background for this? Should it be made SoC specific?

The divider that peripheral bus clock is connected to before that
clock goes to SDHC controller is not set to one, so if this is not set
the parent clock ends up being something around 12Mhz.


>
>> diff --git a/arch/arm/boards/freescale-vf610-twr/flash-header-vf610-twr.imxcfg b/arch/arm/boards/freescale-vf610-twr/flash-header-vf610-twr.imxcfg
>> new file mode 100644
>> index 0000000..18138d2
>> --- /dev/null
>> +++ b/arch/arm/boards/freescale-vf610-twr/flash-header-vf610-twr.imxcfg
>> @@ -0,0 +1,277 @@
>> +soc vf610
>> +loadaddr 0x80000000
>> +dcdofs 0x400
>> +
>> +#define VF610_DDR_PAD_CTRL   0x00000180 /* 25 Ohm drive strength */
>> +#define VF610_DDR_PAD_CTRL_1 0x00010180 /* 25 Ohm drive strength + differential input */
>> +
>> +#define DDRMC_PHY_DQ_TIMING  0x00002613
>> +#define DDRMC_PHY_DQS_TIMING 0x00002615
>> +#define DDRMC_PHY_CTRL               0x00210000
>> +#define DDRMC_PHY_MASTER_CTRL        0x0001012a
>> +#define DDRMC_PHY_SLAVE_CTRL 0x00002000
>> +#define DDRMC_PHY_OFF                0x00000000
>> +#define DDRMC_PHY_PROC_PAD_ODT       0x00010101
>> +
>> +#ifdef DEBUG
>> +#define CHECKPOINT(n) wm 32 0x3f000000 n
>> +#else
>> +#define CHECKPOINT(n)
>> +#endif
>> +
>> +CHECKPOINT(1)
>> +
>> +/* ======================= Clock initialization =======================*/
>> +
>> +/*
>> + * Ungate all IP block clocks
>> + */
>> +wm 32 0x4006b040 0xffffffff
>> +wm 32 0x4006b044 0xffffffff
>> +wm 32 0x4006b048 0xffffffff
>> +wm 32 0x4006b04c 0xffffffff
>> +wm 32 0x4006b050 0xffffffff
>> +wm 32 0x4006b058 0xffffffff
>> +wm 32 0x4006b05c 0xffffffff
>> +wm 32 0x4006b060 0xffffffff
>> +wm 32 0x4006b064 0xffffffff
>> +wm 32 0x4006b068 0xffffffff
>> +wm 32 0x4006b06c 0xffffffff
>> +
>> +
>> +/*
>> + * We have to options to clock DDR controller:
>> + *
>> + *  - Use Core-A5 clock
>> + *  - Use PLL2 PFD2 clock
>> + *
>> +
>> + * Using first option without changing PLL settings doesn't seem to be
>> + * possible given that DDRMC requires minimum of 300Mhz and MaskROM
>> + * configures it to be clocked at 264Mhz. Changing PLL1 settings
>> + * proved to be challenging becuase MaskROM code executing this DCD
>> + * will also be fetching the rest of the bootloader via some
>> + * peripheral interface whose clock is derived from Cortex-A5 clock.
>> + *
>> + * As a result this DCD configuration code uses the second option of
>> + * clocking DDR wiht PLL2 PFD2 clock output
>> + *
>> + * Turn PLL2 on
>> + */
>> +wm 32 0x40050030 0x00002001 /* Fout = Fin * 22 */
>> +
>> +CHECKPOINT(2)
>> +
>> +/*
>> + * Wait for PLLs to lock
>> + */
>> +check 32 while_any_bit_clear 0x40050030 0x80000000
>> +
>> +
>> +CHECKPOINT(3)
>> +
>> +/*
>> + * Switch DDRMC to be clocked with PLL2 PFD2 and enable PFD2 output
>> + */
>> +clear_bits 32 0x4006b008 0x00000040
>> +set_bits   32 0x4006b008 0x00002000
>> +
>> +
>> +
>> +/* ======================= DDR IOMUX ======================= */
>> +
>> +CHECKPOINT(4)
>> +
>> +wm 32 0x40048220 VF610_DDR_PAD_CTRL
>> +wm 32 0x40048224 VF610_DDR_PAD_CTRL
>> +wm 32 0x40048228 VF610_DDR_PAD_CTRL
>> +wm 32 0x4004822c VF610_DDR_PAD_CTRL
>> +wm 32 0x40048230 VF610_DDR_PAD_CTRL
>> +wm 32 0x40048234 VF610_DDR_PAD_CTRL
>> +wm 32 0x40048238 VF610_DDR_PAD_CTRL
>> +wm 32 0x4004823c VF610_DDR_PAD_CTRL
>> +wm 32 0x40048240 VF610_DDR_PAD_CTRL
>> +wm 32 0x40048244 VF610_DDR_PAD_CTRL
>> +wm 32 0x40048248 VF610_DDR_PAD_CTRL
>> +wm 32 0x4004824c VF610_DDR_PAD_CTRL
>> +wm 32 0x40048250 VF610_DDR_PAD_CTRL
>> +wm 32 0x40048254 VF610_DDR_PAD_CTRL
>> +wm 32 0x40048258 VF610_DDR_PAD_CTRL
>> +wm 32 0x4004825c VF610_DDR_PAD_CTRL
>> +wm 32 0x40048260 VF610_DDR_PAD_CTRL
>> +wm 32 0x40048264 VF610_DDR_PAD_CTRL
>> +wm 32 0x40048268 VF610_DDR_PAD_CTRL
>> +wm 32 0x4004826c VF610_DDR_PAD_CTRL
>> +wm 32 0x40048270 VF610_DDR_PAD_CTRL
>> +wm 32 0x40048274 VF610_DDR_PAD_CTRL
>> +wm 32 0x40048278 VF610_DDR_PAD_CTRL
>> +wm 32 0x4004827c VF610_DDR_PAD_CTRL_1
>> +wm 32 0x40048280 VF610_DDR_PAD_CTRL_1
>> +wm 32 0x40048284 VF610_DDR_PAD_CTRL_1
>> +wm 32 0x40048288 VF610_DDR_PAD_CTRL_1
>> +wm 32 0x4004828c VF610_DDR_PAD_CTRL_1
>> +wm 32 0x40048290 VF610_DDR_PAD_CTRL_1
>> +wm 32 0x40048294 VF610_DDR_PAD_CTRL_1
>> +wm 32 0x40048298 VF610_DDR_PAD_CTRL_1
>> +wm 32 0x4004829c VF610_DDR_PAD_CTRL_1
>> +wm 32 0x400482a0 VF610_DDR_PAD_CTRL_1
>> +wm 32 0x400482a4 VF610_DDR_PAD_CTRL_1
>> +wm 32 0x400482a8 VF610_DDR_PAD_CTRL_1
>> +wm 32 0x400482ac VF610_DDR_PAD_CTRL_1
>> +wm 32 0x400482b0 VF610_DDR_PAD_CTRL_1
>> +wm 32 0x400482b4 VF610_DDR_PAD_CTRL_1
>> +wm 32 0x400482b8 VF610_DDR_PAD_CTRL_1
>> +wm 32 0x400482bc VF610_DDR_PAD_CTRL_1
>> +wm 32 0x400482c0 VF610_DDR_PAD_CTRL_1
>> +wm 32 0x400482c4 VF610_DDR_PAD_CTRL_1
>> +wm 32 0x400482c8 VF610_DDR_PAD_CTRL_1
>> +wm 32 0x400482cc VF610_DDR_PAD_CTRL
>> +wm 32 0x400482d0 VF610_DDR_PAD_CTRL
>> +wm 32 0x400482d4 VF610_DDR_PAD_CTRL
>> +wm 32 0x400482d8 VF610_DDR_PAD_CTRL
>> +wm 32 0x4004821c VF610_DDR_PAD_CTRL
>> +
>> +/* ======================= DDR Controller =======================*/
>> +
>> +CHECKPOINT(5)
>> +
>> +wm 32 0x400ae000 0x00000600
>> +wm 32 0x400ae008 0x00000020
>> +wm 32 0x400ae028 0x00013880
>> +wm 32 0x400ae02c 0x00030d40
>> +wm 32 0x400ae030 0x0000050c
>> +wm 32 0x400ae034 0x15040400
>> +wm 32 0x400ae038 0x1406040f
>> +wm 32 0x400ae040 0x04040000
>> +wm 32 0x400ae044 0x006db00c
>> +wm 32 0x400ae048 0x00000403
>> +wm 32 0x400ae050 0x01000000
>> +wm 32 0x400ae054 0x00060001
>> +wm 32 0x400ae058 0x000c0000
>> +wm 32 0x400ae05c 0x03000200
>> +wm 32 0x400ae060 0x00000006
>> +wm 32 0x400ae064 0x00010000
>> +wm 32 0x400ae068 0x0c30002c
>> +wm 32 0x400ae070 0x00000000
>> +wm 32 0x400ae074 0x00000003
>> +wm 32 0x400ae078 0x0000000a
>> +wm 32 0x400ae07c 0x003001d4
>> +wm 32 0x400ae084 0x00010000
>> +wm 32 0x400ae088 0x00050500
>> +wm 32 0x400ae098 0x00000000
>> +wm 32 0x400ae09c 0x04001002
>> +wm 32 0x400ae0a4 0x00000001
>> +wm 32 0x400ae0c0 0x00460420
>> +wm 32 0x400ae108 0x01000200
>> +wm 32 0x400ae10c 0x00000040
>> +wm 32 0x400ae114 0x00000200
>> +wm 32 0x400ae118 0x00000040
>> +wm 32 0x400ae120 0x00000000
>> +wm 32 0x400ae124 0x0a010300
>> +wm 32 0x400ae128 0x01014040
>> +wm 32 0x400ae12c 0x01010101
>> +wm 32 0x400ae130 0x03030100
>> +wm 32 0x400ae134 0x01000101
>> +wm 32 0x400ae138 0x0700000c
>> +wm 32 0x400ae13c 0x00000000
>> +wm 32 0x400ae148 0x10000000
>> +wm 32 0x400ae15c 0x01000000
>> +wm 32 0x400ae160 0x00040000
>> +wm 32 0x400ae164 0x00000002
>> +wm 32 0x400ae16c 0x00020000
>> +wm 32 0x400ae180 0x00002819
>> +wm 32 0x400ae184 0x01000000
>> +wm 32 0x400ae188 0x00000000
>> +wm 32 0x400ae18c 0x00000000
>> +wm 32 0x400ae198 0x00010100
>> +wm 32 0x400ae1a4 0x00000000
>> +wm 32 0x400ae1a8 0x00000004
>> +wm 32 0x400ae1b8 0x00040000
>> +wm 32 0x400ae1c8 0x00000000
>> +wm 32 0x400ae1cc 0x00000000
>> +wm 32 0x400ae1d4 0x00000000
>> +wm 32 0x400ae1d8 0x01010000
>> +wm 32 0x400ae1e0 0x02020000
>> +wm 32 0x400ae1e4 0x00000202
>> +wm 32 0x400ae1e8 0x01010064
>> +wm 32 0x400ae1ec 0x00010101
>> +wm 32 0x400ae1f0 0x00000064
>> +wm 32 0x400ae1f8 0x00000800
>> +wm 32 0x400ae210 0x00000506
>> +wm 32 0x400ae224 0x00020000
>> +wm 32 0x400ae228 0x01000000
>> +wm 32 0x400ae22c 0x04070303
>> +wm 32 0x400ae230 0x00000040
>> +wm 32 0x400ae23c 0x06000080
>> +wm 32 0x400ae240 0x04070303
>> +wm 32 0x400ae244 0x00000040
>> +wm 32 0x400ae248 0x00000040
>> +wm 32 0x400ae24c 0x000f0000
>> +wm 32 0x400ae250 0x000f0000
>> +wm 32 0x400ae25c 0x00000101
>> +wm 32 0x400ae268 0x682c4000
>> +wm 32 0x400ae26c 0x00000012
>> +wm 32 0x400ae278 0x00000006
>> +wm 32 0x400ae284 0x00010202
>> +
>> +/* ======================= DDR PHY =======================*/
>> +
>> +CHECKPOINT(6)
>> +
>> +wm 32 0x400ae400 DDRMC_PHY_DQ_TIMING
>> +wm 32 0x400ae440 DDRMC_PHY_DQ_TIMING
>> +wm 32 0x400ae480 DDRMC_PHY_DQ_TIMING
>> +wm 32 0x400ae404 DDRMC_PHY_DQS_TIMING
>> +wm 32 0x400ae444 DDRMC_PHY_DQS_TIMING
>> +wm 32 0x400ae408 DDRMC_PHY_CTRL
>> +wm 32 0x400ae448 DDRMC_PHY_CTRL
>> +wm 32 0x400ae488 DDRMC_PHY_CTRL
>> +wm 32 0x400ae40c DDRMC_PHY_CTRL
>> +wm 32 0x400ae44c DDRMC_PHY_CTRL
>> +wm 32 0x400ae48c DDRMC_PHY_CTRL
>> +wm 32 0x400ae410 DDRMC_PHY_SLAVE_CTRL
>> +wm 32 0x400ae450 DDRMC_PHY_SLAVE_CTRL
>> +wm 32 0x400ae490 DDRMC_PHY_SLAVE_CTRL
>> +wm 32 0x400ae4c4 DDRMC_PHY_OFF
>> +wm 32 0x400ae4c8 0x00001100
>> +wm 32 0x400ae4d0 DDRMC_PHY_PROC_PAD_ODT
>> +wm 32 0x400ae000 0x00000601
>> +
>> +CHECKPOINT(7)
>> +
>> +check 32 while_any_bit_clear 0x400ae140 0x100
>> +
>> +CHECKPOINT(8)
>> +
>> +/*
>> + * Cargo cult DDR controller initialization here we come!
>> + *
>> + * Experemintation with VF610 Tower Board shows that without the
>
> s/Experemintation/Experimentation/

Will fix in v2.

>
>> + * following code the board would not boot off of SD card when
>> + * power-cycled. It will however happily boot when reset via SW3/Reset
>> + * button. For whatever reason the following actions appear to be
>> + * necessary:
>> + *
>> + *          - Initialize DDRMC as usual
>> + *       - Issue a read to location in DDR address space
>> + *       - Disable DDRMC
>> + *       - Enable DDRMC and wait for it to finish initializing
>> + *
>> + * I am sure this is all going to be extrememly embarrassing to read
>> + * if/when the real problem and real solution is found.
>> + */
>> +
>> +/*
>> + * Because there's no standalone read command what we do here instead
>> + * is write a pattern to memory and then checking that memory address
>> + * against that pattern
>> + */
>> +wm 32 0x80000000 0xa5a5a5a5
>> +check 32 while_any_bit_clear 0x80000000 0xa5a5a5a5
>> +
>> +wm 32 0x400ae000 0x00000600
>> +wm 32 0x400ae000 0x00000601
>> +
>> +check 32 while_any_bit_clear 0x400ae140 0x100
>> +
>> +CHECKPOINT(9)
>> \ No newline at end of file
>> diff --git a/arch/arm/boards/freescale-vf610-twr/lowlevel.c b/arch/arm/boards/freescale-vf610-twr/lowlevel.c
>> new file mode 100644
>> index 0000000..6504273
>> --- /dev/null
>> +++ b/arch/arm/boards/freescale-vf610-twr/lowlevel.c
>> @@ -0,0 +1,45 @@
>> +#include <common.h>
>> +#include <linux/sizes.h>
>> +#include <mach/generic.h>
>> +#include <asm/barebox-arm-head.h>
>> +#include <asm/barebox-arm.h>
>> +#include <mach/vf610-regs.h>
>> +#include <mach/clock-vf610.h>
>> +#include <mach/iomux-vf610.h>
>> +#include <debug_ll.h>
>> +
>> +static inline void setup_uart(void)
>> +{
>> +     void __iomem *iomuxbase = IOMEM(VF610_IOMUXC_BASE_ADDR);
>> +
>> +     vf610_ungate_all_peripherals();
>> +
>> +     /*
>> +      * VF610_PAD_PTB4__UART1_TX
>> +      */
>> +     writel(VF610_UART_PAD_CTRL | (2 << 20), iomuxbase + 0x0068);
>> +     writel(0, iomuxbase + 0x0380);
>> +
>> +     vf610_uart_setup_ll();
>> +}
>> +
>> +extern char __dtb_vf610_twr_start[];
>> +
>> +ENTRY_FUNCTION(start_vf610_twr, r0, r1, r2)
>> +{
>> +     int i;
>> +     void *fdt;
>> +     void __iomem *mscm = IOMEM(VF610_MSCM_BASE_ADDR);
>> +
>> +     vf610_cpu_lowlevel_init();
>> +
>> +     for (i = 0; i < VF610_MSCM_IRSPRC_NUM; i++)
>> +             writew(VF610_MSCM_IRSPRC_CP0_EN,
>> +                    mscm + VF610_MSCM_IRSPRC(i));
>> +
>> +     if (IS_ENABLED(CONFIG_DEBUG_LL))
>> +             setup_uart();
>> +
>> +     fdt = __dtb_vf610_twr_start - get_runtime_offset();
>> +     barebox_arm_entry(0x80000000, SZ_128M, fdt);
>> +}
>> diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
>> index d1a3fe8..f93152c 100644
>> --- a/arch/arm/dts/Makefile
>> +++ b/arch/arm/dts/Makefile
>> @@ -76,5 +76,6 @@ pbl-dtb-$(CONFIG_MACH_TX6X) += imx6q-tx6q.dtb.o
>>  pbl-dtb-$(CONFIG_MACH_UDOO) += imx6q-udoo.dtb.o
>>  pbl-dtb-$(CONFIG_MACH_USI_TOPKICK) += kirkwood-topkick-bb.dtb.o
>>  pbl-dtb-$(CONFIG_MACH_VARISCITE_MX6) += imx6q-var-custom.dtb.o
>> +pbl-dtb-$(CONFIG_MACH_VF610_TWR) += vf610-twr.dtb.o
>>
>>  clean-files := *.dtb *.dtb.S .*.dtc .*.pre .*.dts *.dtb.lzo
>> diff --git a/arch/arm/dts/vf610-twr.dts b/arch/arm/dts/vf610-twr.dts
>> new file mode 100644
>> index 0000000..54b4435
>> --- /dev/null
>> +++ b/arch/arm/dts/vf610-twr.dts
>> @@ -0,0 +1,14 @@
>> +/*
>> + * Copyright 2013 Freescale Semiconductor, Inc.
>> + *
>> + * 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.
>> + */
>> +
>> +#include <arm/vf610-twr.dts>
>> +
>> +&usbdev0 {
>> +     status = "disabled";
>> +};
>> diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
>> index 71862ef..0284a8f 100644
>> --- a/arch/arm/mach-imx/Kconfig
>> +++ b/arch/arm/mach-imx/Kconfig
>> @@ -332,6 +332,10 @@ config MACH_CM_FX6
>>       bool "CM FX6"
>>       select ARCH_IMX6
>>
>> +config MACH_VF610_TWR
>> +     bool "Freescale VF610 Tower Board"
>> +     select ARCH_VF610
>> +
>>  endif
>>
>>  # ----------------------------------------------------------
>> diff --git a/arch/arm/mach-imx/include/mach/clock-vf610.h b/arch/arm/mach-imx/include/mach/clock-vf610.h
>
> Should be added in a SoC specific patch.

OK, unless you object I'll move this file to commit introducing other regs in v2

>
>> +#define CCM_CCR_FIRC_EN                              (1 << 16)
>> +#define CCM_CCR_OSCNT_MASK                   0xff
>> +#define CCM_CCR_OSCNT(v)                     ((v) & 0xff)
>> +
>
> [...]
>
>> +#define ENET_EXTERNAL_CLK    50000000
>> +#define AUDIO_EXTERNAL_CLK   24576000
>
> VF610_ prefix?

I don't think any of that is use, so I'll remove it in v2

>
>> diff --git a/arch/arm/mach-imx/include/mach/iomux-vf610.h b/arch/arm/mach-imx/include/mach/iomux-vf610.h
>
> Should also be added in a SoC specific patch.

Will move to patch with registers in v2.

Thanks,
Andrey

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

^ permalink raw reply

* Re: [PATCH 02/20] i.MX: Add DEBUG_LL hooks for VF610
From: Andrey Smirnov @ 2016-10-04 13:27 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox@lists.infradead.org
In-Reply-To: <20161004062420.uie22nvogkeqyndz@pengutronix.de>

On Mon, Oct 3, 2016 at 11:24 PM, Sascha Hauer <s.hauer@pengutronix.de> wrote:
> On Mon, Oct 03, 2016 at 07:40:39AM -0700, Andrey Smirnov wrote:
>> Add code to support DEBUG_LL functionality on VF610/Vybrid platform.
>>
>> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
>> ---
>>  arch/arm/mach-imx/include/mach/debug_ll.h   |  27 ++-
>>  arch/arm/mach-imx/include/mach/vf610-regs.h | 126 +++++++++++++
>>  common/Kconfig                              |  10 +-
>>  include/serial/lpuart.h                     | 265 ++++++++++++++++++++++++++++
>>  4 files changed, 426 insertions(+), 2 deletions(-)
>>  create mode 100644 arch/arm/mach-imx/include/mach/vf610-regs.h
>>  create mode 100644 include/serial/lpuart.h
>>
>> diff --git a/arch/arm/mach-imx/include/mach/debug_ll.h b/arch/arm/mach-imx/include/mach/debug_ll.h
>> index 5c2db6c..a132f3c 100644
>> --- a/arch/arm/mach-imx/include/mach/debug_ll.h
>> +++ b/arch/arm/mach-imx/include/mach/debug_ll.h
>> @@ -14,8 +14,10 @@
>>  #include <mach/imx51-regs.h>
>>  #include <mach/imx53-regs.h>
>>  #include <mach/imx6-regs.h>
>> +#include <mach/vf610-regs.h>
>>
>>  #include <serial/imx-uart.h>
>> +#include <serial/lpuart.h>
>>
>>  #ifdef CONFIG_DEBUG_LL
>>
>> @@ -42,6 +44,8 @@
>>  #define IMX_DEBUG_SOC MX53
>>  #elif defined CONFIG_DEBUG_IMX6Q_UART
>>  #define IMX_DEBUG_SOC MX6
>> +#elif defined CONFIG_DEBUG_VF610_UART
>> +#define IMX_DEBUG_SOC VF610
>>  #else
>>  #error "unknown i.MX debug uart soc type"
>>  #endif
>> @@ -74,6 +78,13 @@ static inline void imx6_uart_setup_ll(void)
>>       imx6_uart_setup(base);
>>  }
>>
>> +static inline void vf610_uart_setup_ll(void)
>> +{
>> +     void *base = IOMEM(IMX_UART_BASE(IMX_DEBUG_SOC, CONFIG_DEBUG_IMX_UART_PORT));
>> +
>> +     lpuart_setup(base, 66000000);
>> +}
>> +
>>  static inline void PUTC_LL(int c)
>>  {
>>       void __iomem *base = IOMEM(IMX_UART_BASE(IMX_DEBUG_SOC,
>> @@ -82,14 +93,19 @@ static inline void PUTC_LL(int c)
>>       if (!base)
>>               return;
>>
>> -     imx_uart_putc(base, c);
>> +     if (IS_ENABLED(CONFIG_DEBUG_VF610_UART))
>> +             lpuart_putc(base, c);
>> +     else
>> +             imx_uart_putc(base, c);
>>  }
>> +
>>  #else
>>
>>  static inline void imx50_uart_setup_ll(void) {}
>>  static inline void imx51_uart_setup_ll(void) {}
>>  static inline void imx53_uart_setup_ll(void) {}
>>  static inline void imx6_uart_setup_ll(void)  {}
>> +static inline void vf610_uart_setup_ll(void) {}
>>
>>  #endif /* CONFIG_DEBUG_LL */
>>
>> @@ -115,4 +131,13 @@ static inline void imx53_ungate_all_peripherals(void)
>>       imx_ungate_all_peripherals(IOMEM(MX53_CCM_BASE_ADDR));
>>  }
>>
>> +static inline void vf610_ungate_all_peripherals(void)
>> +{
>> +     void __iomem *ccmbase = IOMEM(VF610_CCM_BASE_ADDR);
>> +     int i;
>> +
>> +     for (i = 0x40; i <= 0x6c; i += 4)
>> +             writel(0xffffffff, ccmbase + i);
>> +}
>> +
>>  #endif /* __MACH_DEBUG_LL_H__ */
>> diff --git a/arch/arm/mach-imx/include/mach/vf610-regs.h b/arch/arm/mach-imx/include/mach/vf610-regs.h
>
> This is probably not the right patch to add this file.

OK, unless you prefer something different, I'll split this file into a
separate patch in v2

>
>> new file mode 100644
>> index 0000000..a1c1a09
>> --- /dev/null
>> +++ b/arch/arm/mach-imx/include/mach/vf610-regs.h
>> @@ -0,0 +1,126 @@
>> +/*
>> + * Copyright 2013-2014 Freescale Semiconductor, Inc.
>> + *
>> + * SPDX-License-Identifier:  GPL-2.0+
>> + */
>> +
>> +#ifndef __ASM_ARCH_IMX_REGS_H__
>> +#define __ASM_ARCH_IMX_REGS_H__
>
> MACH_VF610_REGS_H ?

OK, will do in v2

>
>> +/* System Reset Controller (SRC) */
>> +#define SRC_SRSR_SW_RST                                      (0x1 << 18)
>> +#define SRC_SRSR_RESETB                                      (0x1 << 7)
>> +#define SRC_SRSR_JTAG_RST                            (0x1 << 5)
>> +#define SRC_SRSR_WDOG_M4                             (0x1 << 4)
>> +#define SRC_SRSR_WDOG_A5                             (0x1 << 3)
>> +#define SRC_SRSR_POR_RST                             (0x1 << 0)
>> +#define SRC_SBMR2_BMOD_MASK             (0x3 << 24)
>> +#define SRC_SBMR2_BMOD_SHIFT            24
>> +#define SRC_SBMR2_BMOD_FUSES            0x0
>> +#define SRC_SBMR2_BMOD_SERIAL           0x1
>> +#define SRC_SBMR2_BMOD_RCON             0x2
>
> Please add a VF610_ prefix.

I have a suspicion that I am not using those definitions anywhere, so
I'll ether remove them or add said prefix in v2.

Thanks,
Andrey

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

^ permalink raw reply

* [PATCH 2/5] fs: squashfs: port lz4 compression support from kernel
From: Enrico Jorns @ 2016-10-04 10:10 UTC (permalink / raw)
  To: barebox; +Cc: Enrico Jorns
In-Reply-To: <20161004101048.12970-1-ejo@pengutronix.de>

Signed-off-by: Enrico Jorns <ejo@pengutronix.de>
---
 fs/squashfs/Kconfig       |  13 +++++
 fs/squashfs/Makefile      |   1 +
 fs/squashfs/lz4_wrapper.c | 140 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 154 insertions(+)
 create mode 100644 fs/squashfs/lz4_wrapper.c

diff --git a/fs/squashfs/Kconfig b/fs/squashfs/Kconfig
index d8ee554..d2de168 100644
--- a/fs/squashfs/Kconfig
+++ b/fs/squashfs/Kconfig
@@ -17,6 +17,19 @@ menuconfig FS_SQUASHFS
 	  embedded systems where low overhead is needed.  Further information
 	  and tools are available from http://squashfs.sourceforge.net.
 
+config SQUASHFS_LZ4
+	bool "Include support for LZ4 compressed file systems"
+	depends on FS_SQUASHFS
+	select LZ4_DECOMPRESS
+	help
+	  Saying Y here includes support for reading Squashfs file systems
+	  compressed with LZ4 compression.  LZ4 compression is mainly
+	  aimed at embedded systems with slower CPUs where the overheads
+	  of zlib are too high.
+
+	  LZ4 is not the standard compression used in Squashfs and so most
+	  file systems will be readable without selecting this option.
+
 config SQUASHFS_LZO
 	bool "Include support for LZO compressed file systems"
 	default y
diff --git a/fs/squashfs/Makefile b/fs/squashfs/Makefile
index 447e15e..8590b09 100644
--- a/fs/squashfs/Makefile
+++ b/fs/squashfs/Makefile
@@ -12,3 +12,4 @@ obj-y	+= namei.o
 obj-y	+= super.o
 obj-$(CONFIG_SQUASHFS_XZ) += xz_wrapper.o
 obj-$(CONFIG_SQUASHFS_LZO) += lzo_wrapper.o
+obj-$(CONFIG_SQUASHFS_LZ4) += lz4_wrapper.o
diff --git a/fs/squashfs/lz4_wrapper.c b/fs/squashfs/lz4_wrapper.c
new file mode 100644
index 0000000..6ca6a32
--- /dev/null
+++ b/fs/squashfs/lz4_wrapper.c
@@ -0,0 +1,140 @@
+/*
+ * Copyright (c) 2013, 2014
+ * Phillip Lougher <phillip@squashfs.org.uk>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2. See
+ * the COPYING file in the top-level directory.
+ */
+
+#include <types.h>
+#include <linux/mutex.h>
+#include <linux/lz4.h>
+
+#include "squashfs_fs.h"
+#include "squashfs_fs_sb.h"
+#include "squashfs.h"
+#include "decompressor.h"
+#include "page_actor.h"
+
+#define LZ4_LEGACY	1
+
+struct lz4_comp_opts {
+	__le32 version;
+	__le32 flags;
+};
+
+struct squashfs_lz4 {
+	void *input;
+	void *output;
+};
+
+
+static void *lz4_comp_opts(struct squashfs_sb_info *msblk,
+	void *buff, int len)
+{
+	struct lz4_comp_opts *comp_opts = buff;
+
+	/* LZ4 compressed filesystems always have compression options */
+	if (comp_opts == NULL || len < sizeof(*comp_opts))
+		return ERR_PTR(-EIO);
+
+	if (le32_to_cpu(comp_opts->version) != LZ4_LEGACY) {
+		/* LZ4 format currently used by the kernel is the 'legacy'
+		 * format */
+		ERROR("Unknown LZ4 version\n");
+		return ERR_PTR(-EINVAL);
+	}
+
+	return NULL;
+}
+
+
+static void *lz4_init(struct squashfs_sb_info *msblk, void *buff)
+{
+	int block_size = max_t(int, msblk->block_size, SQUASHFS_METADATA_SIZE);
+	struct squashfs_lz4 *stream;
+
+	stream = kzalloc(sizeof(*stream), GFP_KERNEL);
+	if (stream == NULL)
+		goto failed;
+	stream->input = vmalloc(block_size);
+	if (stream->input == NULL)
+		goto failed2;
+	stream->output = vmalloc(block_size);
+	if (stream->output == NULL)
+		goto failed3;
+
+	return stream;
+
+failed3:
+	vfree(stream->input);
+failed2:
+	kfree(stream);
+failed:
+	ERROR("Failed to initialise LZ4 decompressor\n");
+	return ERR_PTR(-ENOMEM);
+}
+
+
+static void lz4_free(void *strm)
+{
+	struct squashfs_lz4 *stream = strm;
+
+	if (stream) {
+		vfree(stream->input);
+		vfree(stream->output);
+	}
+	kfree(stream);
+}
+
+
+static int lz4_uncompress(struct squashfs_sb_info *msblk, void *strm,
+	char **bh, int b, int offset, int length,
+	struct squashfs_page_actor *output)
+{
+	struct squashfs_lz4 *stream = strm;
+	void *buff = stream->input, *data;
+	int avail, i, bytes = length, res;
+	size_t dest_len = output->length;
+
+	for (i = 0; i < b; i++) {
+		avail = min(bytes, msblk->devblksize - offset);
+		memcpy(buff, bh[i] + offset, avail);
+		buff += avail;
+		bytes -= avail;
+		offset = 0;
+		kfree(bh[i]);
+	}
+
+	res = lz4_decompress_unknownoutputsize(stream->input, length,
+					stream->output, &dest_len);
+	if (res)
+		return -EIO;
+
+	bytes = dest_len;
+	data = squashfs_first_page(output);
+	buff = stream->output;
+	while (data) {
+		if (bytes <= PAGE_CACHE_SIZE) {
+			memcpy(data, buff, bytes);
+			break;
+		}
+		memcpy(data, buff, PAGE_CACHE_SIZE);
+		buff += PAGE_CACHE_SIZE;
+		bytes -= PAGE_CACHE_SIZE;
+		data = squashfs_next_page(output);
+	}
+	squashfs_finish_page(output);
+
+	return dest_len;
+}
+
+const struct squashfs_decompressor squashfs_lz4_comp_ops = {
+	.init = lz4_init,
+	.comp_opts = lz4_comp_opts,
+	.free = lz4_free,
+	.decompress = lz4_uncompress,
+	.id = LZ4_COMPRESSION,
+	.name = "lz4",
+	.supported = 1
+};
-- 
2.9.3


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

^ permalink raw reply related

* [PATCH 5/5] fs: squashfs: append linux rootarg for ubi volume
From: Enrico Jorns @ 2016-10-04 10:10 UTC (permalink / raw)
  To: barebox; +Cc: Enrico Jorns
In-Reply-To: <20161004101048.12970-1-ejo@pengutronix.de>

If squashfs runs from an ubi volume, append appropriate root kernel
options.

Note that ubiblock support is required in the kernel for that.

Signed-off-by: Enrico Jorns <ejo@pengutronix.de>
---
 fs/squashfs/squashfs.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/fs/squashfs/squashfs.c b/fs/squashfs/squashfs.c
index 6d04681..c4d0bac 100644
--- a/fs/squashfs/squashfs.c
+++ b/fs/squashfs/squashfs.c
@@ -9,12 +9,16 @@
 #include <linux/fs.h>
 #include <linux/stat.h>
 #include <linux/pagemap.h>
+#include <linux/mtd/ubi.h>
+#include <linux/mtd/mtd.h>
 
 #include "squashfs_fs.h"
 #include "squashfs_fs_sb.h"
 #include "squashfs_fs_i.h"
 #include "squashfs.h"
 
+struct ubi_volume_desc;
+
 char *squashfs_devread(struct squashfs_sb_info *fs, int byte_offset,
 		int byte_len)
 {
@@ -108,6 +112,31 @@ static struct inode *squashfs_findfile(struct super_block *sb,
 	return NULL;
 }
 
+void squashfs_set_rootarg(struct squashfs_priv *priv, struct fs_device_d *fsdev)
+{
+	struct ubi_volume_desc *ubi_vol;
+	struct ubi_volume_info vi = {};
+	struct ubi_device_info di = {};
+	struct mtd_info *mtd;
+	char *str;
+
+	ubi_vol = ubi_open_volume_cdev(fsdev->cdev, UBI_READONLY);
+
+	if (IS_ERR(ubi_vol))
+		return;
+
+	ubi_get_volume_info(ubi_vol, &vi);
+	ubi_get_device_info(vi.ubi_num, &di);
+	mtd = di.mtd;
+
+	str = basprintf("root=/dev/ubiblock%d_%d ubi.mtd=%s ubi.block=%d,%d rootfstype=squashfs",
+			vi.ubi_num, vi.vol_id, mtd->cdev.partname, vi.ubi_num, vi.vol_id);
+
+	fsdev_set_linux_rootarg(fsdev, str);
+
+	free(str);
+}
+
 static int squashfs_probe(struct device_d *dev)
 {
 	struct fs_device_d *fsdev;
@@ -130,6 +159,8 @@ static int squashfs_probe(struct device_d *dev)
 		goto err_out;
 	}
 
+	squashfs_set_rootarg(priv, fsdev);
+
 	return 0;
 
 err_out:
-- 
2.9.3


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

^ permalink raw reply related

* [PATCH 3/5] fs: squashfs: port zlib compression support from kernel
From: Enrico Jorns @ 2016-10-04 10:10 UTC (permalink / raw)
  To: barebox; +Cc: Enrico Jorns
In-Reply-To: <20161004101048.12970-1-ejo@pengutronix.de>

As this is the default compression method for squashfs, make this the
default in kconfig selection, too

Signed-off-by: Enrico Jorns <ejo@pengutronix.de>
---
 fs/squashfs/Kconfig        |  20 ++++++-
 fs/squashfs/Makefile       |   1 +
 fs/squashfs/zlib_wrapper.c | 132 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 152 insertions(+), 1 deletion(-)
 create mode 100644 fs/squashfs/zlib_wrapper.c

diff --git a/fs/squashfs/Kconfig b/fs/squashfs/Kconfig
index d2de168..1cb1ac5 100644
--- a/fs/squashfs/Kconfig
+++ b/fs/squashfs/Kconfig
@@ -17,6 +17,19 @@ menuconfig FS_SQUASHFS
 	  embedded systems where low overhead is needed.  Further information
 	  and tools are available from http://squashfs.sourceforge.net.
 
+config SQUASHFS_ZLIB
+	bool "Include support for ZLIB compressed file systems"
+	depends on FS_SQUASHFS
+	select ZLIB
+	default y
+	help
+	  ZLIB compression is the standard compression used by Squashfs
+	  file systems.  It offers a good trade-off between compression
+	  achieved and the amount of CPU time and memory necessary to
+	  compress and decompress.
+
+	  If unsure, say Y.
+
 config SQUASHFS_LZ4
 	bool "Include support for LZ4 compressed file systems"
 	depends on FS_SQUASHFS
@@ -30,9 +43,10 @@ config SQUASHFS_LZ4
 	  LZ4 is not the standard compression used in Squashfs and so most
 	  file systems will be readable without selecting this option.
 
+	  If unsure, say N.
+
 config SQUASHFS_LZO
 	bool "Include support for LZO compressed file systems"
-	default y
 	depends on FS_SQUASHFS
 	select LZO_DECOMPRESS
 	help
@@ -44,6 +58,8 @@ config SQUASHFS_LZO
 	  LZO is not the standard compression used in Squashfs and so most
 	  file systems will be readable without selecting this option.
 
+	  If unsure, say N.
+
 config SQUASHFS_XZ
 	bool "Include support for XZ compressed file systems"
 	default y
@@ -57,3 +73,5 @@ config SQUASHFS_XZ
 
 	  XZ is not the standard compression used in Squashfs and so most
 	  file systems will be readable without selecting this option.
+
+	  If unsure, say N.
diff --git a/fs/squashfs/Makefile b/fs/squashfs/Makefile
index 8590b09..7976e3f 100644
--- a/fs/squashfs/Makefile
+++ b/fs/squashfs/Makefile
@@ -13,3 +13,4 @@ obj-y	+= super.o
 obj-$(CONFIG_SQUASHFS_XZ) += xz_wrapper.o
 obj-$(CONFIG_SQUASHFS_LZO) += lzo_wrapper.o
 obj-$(CONFIG_SQUASHFS_LZ4) += lz4_wrapper.o
+obj-$(CONFIG_SQUASHFS_ZLIB) += zlib_wrapper.o
diff --git a/fs/squashfs/zlib_wrapper.c b/fs/squashfs/zlib_wrapper.c
new file mode 100644
index 0000000..f422515
--- /dev/null
+++ b/fs/squashfs/zlib_wrapper.c
@@ -0,0 +1,132 @@
+/*
+ * Squashfs - a compressed read only filesystem for Linux
+ *
+ * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
+ * Phillip Lougher <phillip@squashfs.org.uk>
+ *
+ * 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,
+ * or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * zlib_wrapper.c
+ */
+
+
+#include <linux/mutex.h>
+#include <linux/zlib.h>
+
+#include "squashfs_fs.h"
+#include "squashfs_fs_sb.h"
+#include "squashfs.h"
+#include "decompressor.h"
+#include "page_actor.h"
+
+static void *zlib_init(struct squashfs_sb_info *dummy, void *buff)
+{
+	z_stream *stream = kmalloc(sizeof(z_stream), GFP_KERNEL);
+	if (stream == NULL)
+		goto failed;
+	stream->workspace = vmalloc(zlib_inflate_workspacesize());
+	if (stream->workspace == NULL)
+		goto failed;
+
+	return stream;
+
+failed:
+	ERROR("Failed to allocate zlib workspace\n");
+	kfree(stream);
+	return ERR_PTR(-ENOMEM);
+}
+
+
+static void zlib_free(void *strm)
+{
+	z_stream *stream = strm;
+
+	if (stream)
+		vfree(stream->workspace);
+	kfree(stream);
+}
+
+
+static int zlib_uncompress(struct squashfs_sb_info *msblk, void *strm,
+	char **bh, int b, int offset, int length,
+	struct squashfs_page_actor *output)
+{
+	int zlib_err, zlib_init = 0, k = 0;
+	z_stream *stream = strm;
+
+	stream->avail_out = PAGE_CACHE_SIZE;
+	stream->next_out = squashfs_first_page(output);
+	stream->avail_in = 0;
+
+	do {
+		if (stream->avail_in == 0 && k < b) {
+			int avail = min(length, msblk->devblksize - offset);
+			length -= avail;
+			stream->next_in = bh[k] + offset;
+			stream->avail_in = avail;
+			offset = 0;
+		}
+
+		if (stream->avail_out == 0) {
+			stream->next_out = squashfs_next_page(output);
+			if (stream->next_out != NULL)
+				stream->avail_out = PAGE_CACHE_SIZE;
+		}
+
+		if (!zlib_init) {
+			zlib_err = zlib_inflateInit(stream);
+			if (zlib_err != Z_OK) {
+				squashfs_finish_page(output);
+				goto out;
+			}
+			zlib_init = 1;
+		}
+
+		zlib_err = zlib_inflate(stream, Z_SYNC_FLUSH);
+
+		if (stream->avail_in == 0 && k < b)
+			kfree(bh[k++]);
+	} while (zlib_err == Z_OK);
+
+	squashfs_finish_page(output);
+
+	if (zlib_err != Z_STREAM_END)
+		goto out;
+
+	zlib_err = zlib_inflateEnd(stream);
+	if (zlib_err != Z_OK)
+		goto out;
+
+	if (k < b)
+		goto out;
+
+	return stream->total_out;
+
+out:
+	for (; k < b; k++)
+		kfree(bh[k]);
+
+	return -EIO;
+}
+
+const struct squashfs_decompressor squashfs_zlib_comp_ops = {
+	.init = zlib_init,
+	.free = zlib_free,
+	.decompress = zlib_uncompress,
+	.id = ZLIB_COMPRESSION,
+	.name = "zlib",
+	.supported = 1
+};
+
-- 
2.9.3


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

^ permalink raw reply related

* [PATCH 4/5] Add filetype and detection for squashfs images
From: Enrico Jorns @ 2016-10-04 10:10 UTC (permalink / raw)
  To: barebox; +Cc: Enrico Jorns
In-Reply-To: <20161004101048.12970-1-ejo@pengutronix.de>

This adds `filetype_squashfs` to the list of known filetypes and adds a
detection for squashfs files to file_detect_type(). This currently
matches on the `hsqs` start sequence of an image file.

Additionally, the newly introduced filetype is registered as the type of
the squashfs_driver which allows, for example, to mount squashfs without
the need to specify a type parameter.

This changes enable booting a squashfs with the simple `boot` command
pointing to the location (device) that holds the squashfs.

Note that booting with blspec is limited as the current squashfs driver
is not capable of handling symbolic links.

Signed-off-by: Enrico Jorns <ejo@pengutronix.de>
---
 common/filetype.c      | 4 ++++
 fs/squashfs/squashfs.c | 1 +
 include/filetype.h     | 1 +
 3 files changed, 6 insertions(+)

diff --git a/common/filetype.c b/common/filetype.c
index 4728f87..8d72933 100644
--- a/common/filetype.c
+++ b/common/filetype.c
@@ -40,6 +40,7 @@ static const struct filetype_str filetype_str[] = {
 	[filetype_uimage] = { "U-Boot uImage", "u-boot" },
 	[filetype_ubi] = { "UBI image", "ubi" },
 	[filetype_jffs2] = { "JFFS2 image", "jffs2" },
+	[filetype_squashfs] = { "Squashfs image", "squashfs" },
 	[filetype_gzip] = { "GZIP compressed", "gzip" },
 	[filetype_bzip2] = { "BZIP2 compressed", "bzip2" },
 	[filetype_oftree] = { "open firmware Device Tree flattened Binary", "dtb" },
@@ -278,6 +279,9 @@ enum filetype file_detect_type(const void *_buf, size_t bufsize)
 	if (buf8[0] == 0xfd && buf8[1] == 0x37 && buf8[2] == 0x7a &&
 			buf8[3] == 0x58 && buf8[4] == 0x5a && buf8[5] == 0x00)
 		return filetype_xz_compressed;
+	if (buf8[0] == 'h' && buf8[1] == 's' && buf8[2] == 'q' &&
+			buf8[3] == 's')
+		return filetype_squashfs;
 	if (buf[0] == be32_to_cpu(0xd00dfeed))
 		return filetype_oftree;
 	if (strncmp(buf8, "ANDROID!", 8) == 0)
diff --git a/fs/squashfs/squashfs.c b/fs/squashfs/squashfs.c
index d00dee6..6d04681 100644
--- a/fs/squashfs/squashfs.c
+++ b/fs/squashfs/squashfs.c
@@ -353,6 +353,7 @@ static struct fs_driver_d squashfs_driver = {
 	.readdir	= squashfs_readdir,
 	.closedir	= squashfs_closedir,
 	.stat		= squashfs_stat,
+	.type		= filetype_squashfs,
 	.drv = {
 		.probe = squashfs_probe,
 		.remove = squashfs_remove,
diff --git a/include/filetype.h b/include/filetype.h
index cde73c1..65bd6ef 100644
--- a/include/filetype.h
+++ b/include/filetype.h
@@ -16,6 +16,7 @@ enum filetype {
 	filetype_uimage,
 	filetype_ubi,
 	filetype_jffs2,
+	filetype_squashfs,
 	filetype_gzip,
 	filetype_bzip2,
 	filetype_oftree,
-- 
2.9.3


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

^ permalink raw reply related

* [PATCH 1/5] fs: squashfs: port lzo compression support from kernel
From: Enrico Jorns @ 2016-10-04 10:10 UTC (permalink / raw)
  To: barebox; +Cc: Enrico Jorns
In-Reply-To: <20161004101048.12970-1-ejo@pengutronix.de>

This ports lzo_wrapper from kernel code and adds some minimal adaptions
to make squashfs lzo compression work in barebox.

Signed-off-by: Enrico Jorns <ejo@pengutronix.de>
---
 fs/squashfs/Kconfig       |  14 +++++
 fs/squashfs/Makefile      |   1 +
 fs/squashfs/lzo_wrapper.c | 128 ++++++++++++++++++++++++++++++++++++++++++++++
 include/linux/lzo.h       |  47 +++++++++++++++++
 4 files changed, 190 insertions(+)
 create mode 100644 fs/squashfs/lzo_wrapper.c
 create mode 100644 include/linux/lzo.h

diff --git a/fs/squashfs/Kconfig b/fs/squashfs/Kconfig
index dc25d93..d8ee554 100644
--- a/fs/squashfs/Kconfig
+++ b/fs/squashfs/Kconfig
@@ -17,6 +17,20 @@ menuconfig FS_SQUASHFS
 	  embedded systems where low overhead is needed.  Further information
 	  and tools are available from http://squashfs.sourceforge.net.
 
+config SQUASHFS_LZO
+	bool "Include support for LZO compressed file systems"
+	default y
+	depends on FS_SQUASHFS
+	select LZO_DECOMPRESS
+	help
+	  Saying Y here includes support for reading Squashfs file systems
+	  compressed with LZO compression.  LZO compression is mainly
+	  aimed at embedded systems with slower CPUs where the overheads
+	  of zlib are too high.
+
+	  LZO is not the standard compression used in Squashfs and so most
+	  file systems will be readable without selecting this option.
+
 config SQUASHFS_XZ
 	bool "Include support for XZ compressed file systems"
 	default y
diff --git a/fs/squashfs/Makefile b/fs/squashfs/Makefile
index c0d024c..447e15e 100644
--- a/fs/squashfs/Makefile
+++ b/fs/squashfs/Makefile
@@ -11,3 +11,4 @@ obj-y	+= inode.o
 obj-y	+= namei.o
 obj-y	+= super.o
 obj-$(CONFIG_SQUASHFS_XZ) += xz_wrapper.o
+obj-$(CONFIG_SQUASHFS_LZO) += lzo_wrapper.o
diff --git a/fs/squashfs/lzo_wrapper.c b/fs/squashfs/lzo_wrapper.c
new file mode 100644
index 0000000..b457955
--- /dev/null
+++ b/fs/squashfs/lzo_wrapper.c
@@ -0,0 +1,128 @@
+/*
+ * Squashfs - a compressed read only filesystem for Linux
+ *
+ * Copyright (c) 2010 LG Electronics
+ * Chan Jeong <chan.jeong@lge.com>
+ *
+ * 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,
+ * or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * lzo_wrapper.c
+ */
+
+#include <linux/mutex.h>
+#include <linux/lzo.h>
+#include <types.h>
+
+#include "squashfs_fs.h"
+#include "squashfs_fs_sb.h"
+#include "squashfs.h"
+#include "decompressor.h"
+#include "page_actor.h"
+
+struct squashfs_lzo {
+	void	*input;
+	void	*output;
+};
+
+static void *lzo_init(struct squashfs_sb_info *msblk, void *buff)
+{
+	int block_size = max_t(int, msblk->block_size, SQUASHFS_METADATA_SIZE);
+
+	struct squashfs_lzo *stream = kzalloc(sizeof(*stream), GFP_KERNEL);
+	if (stream == NULL)
+		goto failed;
+	stream->input = vmalloc(block_size);
+	if (stream->input == NULL)
+		goto failed;
+	stream->output = vmalloc(block_size);
+	if (stream->output == NULL)
+		goto failed2;
+
+	return stream;
+
+failed2:
+	vfree(stream->input);
+failed:
+	ERROR("Failed to allocate lzo workspace\n");
+	kfree(stream);
+	return ERR_PTR(-ENOMEM);
+}
+
+
+static void lzo_free(void *strm)
+{
+	struct squashfs_lzo *stream = strm;
+
+	if (stream) {
+		vfree(stream->input);
+		vfree(stream->output);
+	}
+	kfree(stream);
+}
+
+
+static int lzo_uncompress(struct squashfs_sb_info *msblk, void *strm,
+	char **bh, int b, int offset, int length,
+	struct squashfs_page_actor *output)
+{
+	struct squashfs_lzo *stream = strm;
+	void *buff = stream->input, *data;
+	int avail, i, bytes = length, res;
+	size_t out_len = output->length;
+
+	for (i = 0; i < b; i++) {
+		avail = min(bytes, msblk->devblksize - offset);
+		memcpy(buff, bh[i] + offset, avail);
+		buff += avail;
+		bytes -= avail;
+		offset = 0;
+		kfree(bh[i]);
+	}
+
+	res = lzo1x_decompress_safe(stream->input, (size_t)length,
+					stream->output, &out_len);
+	if (res != LZO_E_OK)
+		goto failed;
+
+	res = bytes = (int)out_len;
+	data = squashfs_first_page(output);
+	buff = stream->output;
+	while (data) {
+		if (bytes <= PAGE_CACHE_SIZE) {
+			memcpy(data, buff, bytes);
+			break;
+		} else {
+			memcpy(data, buff, PAGE_CACHE_SIZE);
+			buff += PAGE_CACHE_SIZE;
+			bytes -= PAGE_CACHE_SIZE;
+			data = squashfs_next_page(output);
+		}
+	}
+	squashfs_finish_page(output);
+
+	return res;
+
+failed:
+	return -EIO;
+}
+
+const struct squashfs_decompressor squashfs_lzo_comp_ops = {
+	.init = lzo_init,
+	.free = lzo_free,
+	.decompress = lzo_uncompress,
+	.id = LZO_COMPRESSION,
+	.name = "lzo",
+	.supported = 1
+};
diff --git a/include/linux/lzo.h b/include/linux/lzo.h
new file mode 100644
index 0000000..ae52d79
--- /dev/null
+++ b/include/linux/lzo.h
@@ -0,0 +1,47 @@
+#ifndef __LZO_H__
+#define __LZO_H__
+/*
+ *  LZO Public Kernel Interface
+ *  A mini subset of the LZO real-time data compression library
+ *
+ *  Copyright (C) 1996-2012 Markus F.X.J. Oberhumer <markus@oberhumer.com>
+ *
+ *  The full LZO package can be found at:
+ *  http://www.oberhumer.com/opensource/lzo/
+ *
+ *  Changed for Linux kernel use by:
+ *  Nitin Gupta <nitingupta910@gmail.com>
+ *  Richard Purdie <rpurdie@openedhand.com>
+ */
+
+#include <types.h>
+
+#define LZO1X_1_MEM_COMPRESS	(8192 * sizeof(unsigned short))
+#define LZO1X_MEM_COMPRESS	LZO1X_1_MEM_COMPRESS
+
+#define lzo1x_worst_compress(x) ((x) + ((x) / 16) + 64 + 3)
+
+/* This requires 'wrkmem' of size LZO1X_1_MEM_COMPRESS */
+int lzo1x_1_compress(const unsigned char *src, size_t src_len,
+		     unsigned char *dst, size_t *dst_len, void *wrkmem);
+
+/* safe decompression with overrun testing */
+int lzo1x_decompress_safe(const unsigned char *src, size_t src_len,
+			  unsigned char *dst, size_t *dst_len);
+
+/*
+ * Return values (< 0 = Error)
+ */
+#define LZO_E_OK			0
+#define LZO_E_ERROR			(-1)
+#define LZO_E_OUT_OF_MEMORY		(-2)
+#define LZO_E_NOT_COMPRESSIBLE		(-3)
+#define LZO_E_INPUT_OVERRUN		(-4)
+#define LZO_E_OUTPUT_OVERRUN		(-5)
+#define LZO_E_LOOKBEHIND_OVERRUN	(-6)
+#define LZO_E_EOF_NOT_FOUND		(-7)
+#define LZO_E_INPUT_NOT_CONSUMED	(-8)
+#define LZO_E_NOT_YET_IMPLEMENTED	(-9)
+#define LZO_E_INVALID_ARGUMENT		(-10)
+
+#endif
-- 
2.9.3


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

^ permalink raw reply related

* [PATCH 0/5] Extend squashfs support
From: Enrico Jorns @ 2016-10-04 10:10 UTC (permalink / raw)
  To: barebox; +Cc: Enrico Jorns

This adds missing compression methods: lz4, lzo, zlib

It also creates missing links in driver and detection code in order to allow
using squashfs with those nice barebox autodetection features and especially
for bootspec booting.

The appendroot mechanism currently (only) supports booting form an ubi volume.

Enrico Jorns (5):
  fs: squashfs: port lzo compression support from kernel
  fs: squashfs: port lz4 compression support from kernel
  fs: squashfs: port zlib compression support from kernel
  Add filetype and detection for squashfs images
  fs: squashfs: append linux rootarg for ubi volume

 common/filetype.c          |   4 ++
 fs/squashfs/Kconfig        |  45 +++++++++++++++
 fs/squashfs/Makefile       |   3 +
 fs/squashfs/lz4_wrapper.c  | 140 +++++++++++++++++++++++++++++++++++++++++++++
 fs/squashfs/lzo_wrapper.c  | 128 +++++++++++++++++++++++++++++++++++++++++
 fs/squashfs/squashfs.c     |  32 +++++++++++
 fs/squashfs/zlib_wrapper.c | 132 ++++++++++++++++++++++++++++++++++++++++++
 include/filetype.h         |   1 +
 include/linux/lzo.h        |  47 +++++++++++++++
 9 files changed, 532 insertions(+)
 create mode 100644 fs/squashfs/lz4_wrapper.c
 create mode 100644 fs/squashfs/lzo_wrapper.c
 create mode 100644 fs/squashfs/zlib_wrapper.c
 create mode 100644 include/linux/lzo.h

-- 
2.9.3


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

^ permalink raw reply

* Re: [PATCH] pinctrl: mvebu: armada-370 fix gpio name for mpp63
From: Sascha Hauer @ 2016-10-04  7:29 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: barebox
In-Reply-To: <20161004070633.19328-1-u.kleine-koenig@pengutronix.de>

On Tue, Oct 04, 2016 at 09:06:33AM +0200, Uwe Kleine-König wrote:
> It was found that pin 63 also works as input and so the respective function
> is renamed from "gpo" to "gpio". The respective commit in Linux is:
> 
> 	a526973e0291 ("pinctrl: mvebu: Fix mapping of pin 63 (gpo -> gpio)")
> 
> which appeared in v4.1-rc3. The devicetrees are fixed accordingly since
> commit
> 
> 	ce5cad51f381 ("ARM: dts: armada-370: Update the mpp63 function in the device tree on Armada 370")
> 
> which appeared in v4.6-rc1.
> 
> This fixes a runtime warning on the affected machines
> (globalscale-mirabox and netgear-rn104) and makes the pin functional
> again.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
>  drivers/pinctrl/mvebu/armada-370.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

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-5555 |

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

^ permalink raw reply

* Re: [PATCH 14/20] i.MX: i2c-imx: Add Vybrid support
From: Sascha Hauer @ 2016-10-04  7:20 UTC (permalink / raw)
  To: Andrey Smirnov; +Cc: barebox
In-Reply-To: <1475505657-898-15-git-send-email-andrew.smirnov@gmail.com>

On Mon, Oct 03, 2016 at 07:40:51AM -0700, Andrey Smirnov wrote:
> Vybrid flavour of the I2C controller requires some additional quirks on
> part of the driver. This commit ports those quirks code from analogous
> Linux kernel driver.
> 
> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
> ---
>  drivers/i2c/busses/i2c-imx.c | 215 ++++++++++++++++++++++++++++++++-----------
>  1 file changed, 160 insertions(+), 55 deletions(-)
> 
> diff --git a/drivers/i2c/busses/i2c-imx.c b/drivers/i2c/busses/i2c-imx.c
> index e407896..dbc76c2 100644
> --- a/drivers/i2c/busses/i2c-imx.c
> +++ b/drivers/i2c/busses/i2c-imx.c
> @@ -43,6 +43,7 @@
> +static inline void fsl_i2c_write_reg(unsigned int val,
> +				     struct fsl_i2c_struct *i2c_fsl,
> +				     unsigned int reg)
> +{
> +	writeb(val, i2c_fsl->base + (reg << i2c_fsl->hwdata->regshift));
> +}
> +
> +static inline unsigned char fsl_i2c_read_reg(struct fsl_i2c_struct *i2c_fsl,
> +					     unsigned int reg)
> +{
> +	return readb(i2c_fsl->base + (reg << i2c_fsl->hwdata->regshift));
> +}

Can we have the introduction of the read/write accessor functions as a
separate patch (with regshift hardcoded to 0)? This would make reviewing
the rest easier.

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-5555 |

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

^ permalink raw reply

* Re: [PATCH 13/20] i.MX: Add 'lpuart' serial driver
From: Sascha Hauer @ 2016-10-04  7:13 UTC (permalink / raw)
  To: Andrey Smirnov; +Cc: barebox
In-Reply-To: <1475505657-898-14-git-send-email-andrew.smirnov@gmail.com>

On Mon, Oct 03, 2016 at 07:40:50AM -0700, Andrey Smirnov wrote:
> Add 'lpuart' serial driver, based on analogous driver from U-Boot
> 
> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
> ---
>  drivers/serial/Kconfig         |   4 +
>  drivers/serial/Makefile        |   1 +
>  drivers/serial/serial_lpuart.c | 217 +++++++++++++++++++++++++++++++++++++++++
>  include/serial/lpuart.h        |  28 ++++--
>  4 files changed, 244 insertions(+), 6 deletions(-)
>  create mode 100644 drivers/serial/serial_lpuart.c
> 
> diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
> index 146bf1e..02e869a 100644
> --- a/drivers/serial/Kconfig
> +++ b/drivers/serial/Kconfig
> @@ -137,4 +137,8 @@ config DRIVER_SERIAL_DIGIC
>  	bool "Canon DIGIC serial driver"
>  	depends on ARCH_DIGIC
>  
> +config DRIVER_SERIAL_LPUART
> +	depends on ARCH_IMX
> +	bool "LPUART serial driver"
> +
>  endmenu
> diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
> index 189e777..7d1bae1 100644
> --- a/drivers/serial/Makefile
> +++ b/drivers/serial/Makefile
> @@ -20,3 +20,4 @@ obj-$(CONFIG_DRIVER_SERIAL_AUART)		+= serial_auart.o
>  obj-$(CONFIG_DRIVER_SERIAL_CADENCE)		+= serial_cadence.o
>  obj-$(CONFIG_DRIVER_SERIAL_EFI_STDIO)		+= efi-stdio.o
>  obj-$(CONFIG_DRIVER_SERIAL_DIGIC)		+= serial_digic.o
> +obj-$(CONFIG_DRIVER_SERIAL_LPUART)		+= serial_lpuart.o
> diff --git a/drivers/serial/serial_lpuart.c b/drivers/serial/serial_lpuart.c
> new file mode 100644
> index 0000000..52fb6d3
> --- /dev/null
> +++ b/drivers/serial/serial_lpuart.c
> @@ -0,0 +1,217 @@
> +/*
> + * Copyright (c) 2016 Zodiac Inflight Innovation
> + * Author: Andrey Smirnov <andrew.smirnov@gmail.com>
> + *
> + * Based on analogous driver from U-Boot
> + *
> + * 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 <driver.h>
> +#include <init.h>
> +#include <malloc.h>
> +#include <notifier.h>
> +#include <io.h>
> +#include <of.h>
> +#include <linux/err.h>
> +#include <linux/clk.h>
> +#include <serial/lpuart.h>
> +
> +struct lpuart {
> +	struct console_device cdev;
> +	int baudrate;
> +	int dte_mode;
> +	struct notifier_block notify;
> +	struct resource *io;
> +	void __iomem *base;
> +	struct clk *clk;
> +};
> +
> +static struct lpuart *cdev_to_lpuart(struct console_device *cdev)
> +{
> +	return container_of(cdev, struct lpuart, cdev);
> +}
> +
> +static struct lpuart *nb_to_lpuart(struct notifier_block *nb)
> +{
> +	return container_of(nb, struct lpuart, notify);
> +}
> +
> +static void lpuart_enable(struct lpuart *lpuart, bool on)
> +{
> +	u8 ctrl;
> +
> +	ctrl = readb(lpuart->base + UARTCR2);
> +	if (on)
> +		ctrl |= UARTCR2_TE | UARTCR2_RE;
> +	else
> +		ctrl &= ~(UARTCR2_TE | UARTCR2_RE);
> +	writeb(ctrl, lpuart->base + UARTCR2);
> +}
> +
> +static int lpuart_serial_setbaudrate(struct console_device *cdev,
> +				     int baudrate)
> +{
> +	struct lpuart *lpuart = cdev_to_lpuart(cdev);
> +
> +	lpuart_enable(lpuart, false);
> +
> +	lpuart_setbrg(lpuart->base,
> +		      clk_get_rate(lpuart->clk),
> +		      baudrate);
> +
> +	lpuart_enable(lpuart, true);
> +
> +	lpuart->baudrate = baudrate;
> +
> +	return 0;
> +}
> +
> +static int lpuart_serial_getc(struct console_device *cdev)
> +{
> +	bool ready;
> +	struct lpuart *lpuart = cdev_to_lpuart(cdev);
> +
> +	do {
> +		const u8 sr1 = readb(lpuart->base + UARTSR1);
> +		ready = !!(sr1 & (UARTSR1_OR | UARTSR1_RDRF));
> +	} while (!ready);
> +
> +	return readb(lpuart->base + UARTDR);
> +}
> +
> +static void lpuart_serial_putc(struct console_device *cdev, char c)
> +{
> +	lpuart_putc(cdev_to_lpuart(cdev)->base, c);
> +}
> +
> +/* Test whether a character is in the RX buffer */
> +static int lpuart_serial_tstc(struct console_device *cdev)
> +{
> +	return !!readb(cdev_to_lpuart(cdev)->base + UARTRCFIFO);
> +}
> +
> +static void lpuart_serial_flush(struct console_device *cdev)
> +{
> +	bool tx_empty;
> +	struct lpuart *lpuart = cdev_to_lpuart(cdev);
> +
> +	do {
> +		const u8 sr1 = readb(lpuart->base + UARTSR1);
> +		tx_empty = !!(sr1 & UARTSR1_TDRE);
> +	} while (!tx_empty);
> +}
> +
> +static int lpuart_clocksource_clock_change(struct notifier_block *nb,
> +					   unsigned long event, void *data)
> +{
> +	struct lpuart *lpuart = nb_to_lpuart(nb);
> +
> +	return lpuart_serial_setbaudrate(&lpuart->cdev, lpuart->baudrate);
> +}

This doesn't make sense in this form. I introduced this code in the i.MX
uart driver since I had the need to change PLL rates while the uart is
active. When this happens I had to adjust the dividers for the new uart
base clock. The code above doesn't react to base clock changes though,
it takes the old rate stored in lpuart->baudrate.

If you don't have to adjust PLL rates while the uart is active then I
suggest that you just remove this code.

> @@ -225,25 +225,35 @@ static inline void lpuart_setbrg(void __iomem *base,
>  				 unsigned int refclock,
>  				 unsigned int baudrate)
>  {
> +	unsigned int bfra;
>  	u16 sbr;
> +
>  	sbr = (u16) (refclock / (16 * baudrate));
>  
>  	writeb(sbr >> 8,   base + UARTBDH);
>  	writeb(sbr & 0xff, base + UARTBDL);
> +
> +	bfra  = DIV_ROUND_UP(2 * refclock, baudrate) - 32 * sbr;
> +	bfra &= UARTCR4_BRFA_MASK;
> +	writeb(bfra, base + UARTCR4);
>  }
>  
> -static inline void lpuart_setup(void __iomem *base,
> -				unsigned int refclock)
> +static inline void lpuart_setup_with_fifo(void __iomem *base,
> +					  unsigned int refclock,
> +					  unsigned int twfifo)
>  {
> -
>  	/* Disable UART */
>  	writeb(0, base + UARTCR2);
>  	writeb(0, base + UARTMODEM);
>  	writeb(0, base + UARTCR1);
>  
> -	/* Disable FIFOs */
> -	writeb(0, base + UARTPFIFO);
> -	writeb(0, base + UARTTWFIFO);
> +	if (twfifo) {
> +		writeb(UARTPFIFO_TXFE | UARTPFIFO_RXFE, base + UARTPFIFO);
> +		writeb((u8)twfifo, base + UARTTWFIFO);
> +	} else {
> +		writeb(0, base + UARTPFIFO);
> +		writeb(0, base + UARTTWFIFO);
> +	}
>  	writeb(1, base + UARTRWFIFO);
>  	writeb(UARTCFIFO_RXFLUSH | UARTCFIFO_TXFLUSH, base + UARTCFIFO);
>  
> @@ -252,6 +262,12 @@ static inline void lpuart_setup(void __iomem *base,
>  	writeb(UARTCR2_TE | UARTCR2_RE, base + UARTCR2);
>  }
>  
> +static inline void lpuart_setup(void __iomem *base,
> +				unsigned int refclock)
> +{
> +	lpuart_setup_with_fifo(base, refclock, 0x00);
> +}
> +
>  static inline void lpuart_putc(void __iomem *base, int c)
>  {
>  	if (!(readb(base + UARTCR2) & UARTCR2_TE))

This was introduced earlier with this series. No need to change it, just
create it correctly in the first place.

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-5555 |

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

^ permalink raw reply

* [PATCH] pinctrl: mvebu: armada-370 fix gpio name for mpp63
From: Uwe Kleine-König @ 2016-10-04  7:06 UTC (permalink / raw)
  To: barebox

It was found that pin 63 also works as input and so the respective function
is renamed from "gpo" to "gpio". The respective commit in Linux is:

	a526973e0291 ("pinctrl: mvebu: Fix mapping of pin 63 (gpo -> gpio)")

which appeared in v4.1-rc3. The devicetrees are fixed accordingly since
commit

	ce5cad51f381 ("ARM: dts: armada-370: Update the mpp63 function in the device tree on Armada 370")

which appeared in v4.6-rc1.

This fixes a runtime warning on the affected machines
(globalscale-mirabox and netgear-rn104) and makes the pin functional
again.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 drivers/pinctrl/mvebu/armada-370.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pinctrl/mvebu/armada-370.c b/drivers/pinctrl/mvebu/armada-370.c
index 1c79bd62af92..c2c1a0fa6399 100644
--- a/drivers/pinctrl/mvebu/armada-370.c
+++ b/drivers/pinctrl/mvebu/armada-370.c
@@ -362,7 +362,7 @@ static struct mvebu_mpp_mode mv88f6710_mpp_modes[] = {
 	   MPP_FUNCTION(0x5, "audio", "mclk"),
 	   MPP_FUNCTION(0x6, "uart0", "cts")),
 	MPP_MODE(63, "mpp63", armada_370_mpp_ctrl,
-	   MPP_FUNCTION(0x0, "gpo", NULL),
+	   MPP_FUNCTION(0x0, "gpio", NULL),
 	   MPP_FUNCTION(0x1, "spi0", "sck"),
 	   MPP_FUNCTION(0x2, "tclk", NULL)),
 	MPP_MODE(64, "mpp64", armada_370_mpp_ctrl,
-- 
2.9.3


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

^ permalink raw reply related

* Re: [PATCH 11/20] i.MX: Add VF610 clock tree initialization code
From: Sascha Hauer @ 2016-10-04  6:58 UTC (permalink / raw)
  To: Andrey Smirnov; +Cc: barebox
In-Reply-To: <1475505657-898-12-git-send-email-andrew.smirnov@gmail.com>

On Mon, Oct 03, 2016 at 07:40:48AM -0700, Andrey Smirnov wrote:
> Based on analogous code from Linux kernel
> 
> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
> ---
>  drivers/clk/imx/Makefile    |    1 +
>  drivers/clk/imx/clk-vf610.c | 1224 +++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 1225 insertions(+)
>  create mode 100644 drivers/clk/imx/clk-vf610.c
> 
> diff --git a/drivers/clk/imx/Makefile b/drivers/clk/imx/Makefile
> index 0303c0b..2665f49 100644
> --- a/drivers/clk/imx/Makefile
> +++ b/drivers/clk/imx/Makefile
> @@ -1 +1,2 @@
>  obj-y += clk.o
> +obj-$(CONFIG_ARCH_VF610) += clk-vf610.o
> +static struct clk *clk[VF610_CLK_END];
> +struct clk_onecell_data clk_data;
> +
> +static struct clk * __init vf610_get_fixed_clock(struct device_node *np,
> +						 const char *name)
> +{
> +	struct clk *clk = of_clk_get_by_name(np, name);
> +
> +	/* Backward compatibility if device tree is missing clks assignments */
> +	if (IS_ERR(clk))
> +		clk = imx_obtain_fixed_clock(name, 0);

Ah, that explains it. No, we don't need this since we are compiling the
device trees into barebox and can make sure they are compatible with our
code.

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-5555 |

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

^ permalink raw reply

* Re: [PATCH 10/20] i.MX: clk: Port imx_check_clocks() and imx_obtain_fixed_clock()
From: Sascha Hauer @ 2016-10-04  6:49 UTC (permalink / raw)
  To: Andrey Smirnov; +Cc: barebox
In-Reply-To: <1475505657-898-11-git-send-email-andrew.smirnov@gmail.com>

On Mon, Oct 03, 2016 at 07:40:47AM -0700, Andrey Smirnov wrote:
> Port imx_check_clocks() and imx_obtain_fixed_clock() from Linux kernel.
> 
> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
> ---
>  arch/arm/mach-imx/clk.h  |  4 ++++
>  drivers/clk/Makefile     |  1 +
>  drivers/clk/imx/Makefile |  1 +
>  drivers/clk/imx/clk.c    | 49 ++++++++++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 55 insertions(+)
>  create mode 100644 drivers/clk/imx/Makefile
>  create mode 100644 drivers/clk/imx/clk.c
> 
> diff --git a/arch/arm/mach-imx/clk.h b/arch/arm/mach-imx/clk.h
> index 35e480f..f96e5d2 100644
> --- a/arch/arm/mach-imx/clk.h
> +++ b/arch/arm/mach-imx/clk.h
> @@ -109,4 +109,8 @@ static inline struct clk *imx_clk_busy_mux(const char *name, void __iomem *reg,
>  struct clk *imx_clk_gate_exclusive(const char *name, const char *parent,
>  		void __iomem *reg, u8 shift, u32 exclusive_mask);
>  
> +void imx_check_clocks(struct clk *clks[], unsigned int count);
> +struct clk * __init imx_obtain_fixed_clock(const char *name, unsigned long rate);
> +
> +
>  #endif /* __IMX_CLK_H */
> diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile
> index 0fe8f1e..6dc82ea 100644
> --- a/drivers/clk/Makefile
> +++ b/drivers/clk/Makefile
> @@ -9,3 +9,4 @@ obj-$(CONFIG_ARCH_ROCKCHIP)	+= rockchip/
>  obj-$(CONFIG_ARCH_TEGRA)	+= tegra/
>  obj-$(CONFIG_CLK_SOCFPGA)	+= socfpga.o
>  obj-$(CONFIG_MACH_MIPS_ATH79)	+= clk-ar933x.o
> +obj-$(CONFIG_COMMON_CLK)	+= imx/
> diff --git a/drivers/clk/imx/Makefile b/drivers/clk/imx/Makefile
> new file mode 100644
> index 0000000..0303c0b
> --- /dev/null
> +++ b/drivers/clk/imx/Makefile
> @@ -0,0 +1 @@
> +obj-y += clk.o
> diff --git a/drivers/clk/imx/clk.c b/drivers/clk/imx/clk.c
> new file mode 100644
> index 0000000..0357048
> --- /dev/null
> +++ b/drivers/clk/imx/clk.c

We currently have the i.MX clock support in arch/arm/mach-imx/. This may
or may not be changed, but until it is, other i.MX clock support code
should go to arch/arm/mach-imx/ aswell.

> @@ -0,0 +1,49 @@
> +#include <common.h>
> +#include <init.h>
> +#include <driver.h>
> +#include <linux/clk.h>
> +#include <io.h>
> +#include <of.h>
> +#include <linux/clkdev.h>
> +#include <linux/err.h>
> +
> +#include "../../../arch/arm/mach-imx/clk.h"

#include <mach/clk.h>

> +
> +void __init imx_check_clocks(struct clk *clks[], unsigned int count)
> +{
> +	unsigned i;
> +
> +	for (i = 0; i < count; i++)
> +		if (IS_ERR(clks[i]))
> +			pr_err("i.MX clk %u: register failed with %ld\n",
> +			       i, PTR_ERR(clks[i]));
> +}
> +
> +static struct clk * __init imx_obtain_fixed_clock_from_dt(const char *name)
> +{
> +	struct of_phandle_args phandle;
> +	struct clk *clk = ERR_PTR(-ENODEV);
> +	char *path;
> +
> +	path = basprintf("/clocks/%s", name);
> +	if (!path)
> +		return ERR_PTR(-ENOMEM);
> +
> +	phandle.np = of_find_node_by_path(path);
> +	kfree(path);
> +
> +	if (phandle.np)
> +		clk = of_clk_get_from_provider(&phandle);
> +
> +	return clk;
> +}

Do we need this anyway? We already have clk providers for fixed-clock.
Hm, looking further, maybe a later patch explains.

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-5555 |

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

^ permalink raw reply

* Re: [PATCH 07/20] clk: Port of_clk_set_defautls()
From: Sascha Hauer @ 2016-10-04  6:38 UTC (permalink / raw)
  To: Andrey Smirnov; +Cc: barebox
In-Reply-To: <1475505657-898-8-git-send-email-andrew.smirnov@gmail.com>

On Mon, Oct 03, 2016 at 07:40:44AM -0700, Andrey Smirnov wrote:
> Port of_clk_set_defautls() from Linux kernel in order to support DT
> configurations that require it (e. g. Vybrid).

s/of_clk_set_defautls/of_clk_set_defaults/ here and in the subject.

> diff --git a/include/linux/clk/clk-conf.h b/include/linux/clk/clk-conf.h
> new file mode 100644
> index 0000000..2c0a39e
> --- /dev/null
> +++ b/include/linux/clk/clk-conf.h
> @@ -0,0 +1,22 @@
> +/*
> + * Copyright (C) 2014 Samsung Electronics Co., Ltd.
> + * Sylwester Nawrocki <s.nawrocki@samsung.com>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + */
> +
> +#include <linux/types.h>
> +
> +struct device_node;
> +
> +#if defined(CONFIG_OFTREE) && defined(CONFIG_COMMON_CLK)
> +int of_clk_set_defaults(struct device_node *node, bool clk_supplier);
> +#else
> +static inline int of_clk_set_defaults(struct device_node *node,
> +				      bool clk_supplier)
> +{
> +	return 0;
> +}
> +#endif

We shouldn't need this static inline variant. The caller already exists for OF
enabled builds only.

Sascha

> -- 
> 2.5.5
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
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-5555 |

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

^ permalink raw reply

* Re: [PATCH 04/20] i.MX: Add support for VF610 Tower board
From: Sascha Hauer @ 2016-10-04  6:32 UTC (permalink / raw)
  To: Andrey Smirnov; +Cc: barebox
In-Reply-To: <1475505657-898-5-git-send-email-andrew.smirnov@gmail.com>

On Mon, Oct 03, 2016 at 07:40:41AM -0700, Andrey Smirnov wrote:
> Add support for VF610 Tower board.
> 
> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
> ---
>  arch/arm/boards/Makefile                           |   3 +-
>  arch/arm/boards/freescale-vf610-twr/Makefile       |   4 +
>  arch/arm/boards/freescale-vf610-twr/board.c        |  61 +++++
>  .../flash-header-vf610-twr.imxcfg                  | 277 +++++++++++++++++++++
>  arch/arm/boards/freescale-vf610-twr/lowlevel.c     |  45 ++++
>  arch/arm/dts/Makefile                              |   1 +
>  arch/arm/dts/vf610-twr.dts                         |  14 ++
>  arch/arm/mach-imx/Kconfig                          |   4 +
>  arch/arm/mach-imx/include/mach/clock-vf610.h       | 215 ++++++++++++++++
>  arch/arm/mach-imx/include/mach/iomux-vf610.h       | 258 +++++++++++++++++++
>  images/Makefile.imx                                |   5 +
>  11 files changed, 886 insertions(+), 1 deletion(-)
>  create mode 100644 arch/arm/boards/freescale-vf610-twr/Makefile
>  create mode 100644 arch/arm/boards/freescale-vf610-twr/board.c
>  create mode 100644 arch/arm/boards/freescale-vf610-twr/flash-header-vf610-twr.imxcfg
>  create mode 100644 arch/arm/boards/freescale-vf610-twr/lowlevel.c
>  create mode 100644 arch/arm/dts/vf610-twr.dts
>  create mode 100644 arch/arm/mach-imx/include/mach/clock-vf610.h
>  create mode 100644 arch/arm/mach-imx/include/mach/iomux-vf610.h
> 
> diff --git a/arch/arm/boards/Makefile b/arch/arm/boards/Makefile
> index 23a8dbd..c8bc565 100644
> --- a/arch/arm/boards/Makefile
> +++ b/arch/arm/boards/Makefile
> @@ -10,7 +10,7 @@ obj-$(CONFIG_MACH_AT91SAM9G20EK)		+= at91sam9260ek/
>  obj-$(CONFIG_MACH_AT91SAM9M10G45EK)		+= at91sam9m10g45ek/
>  obj-$(CONFIG_MACH_AT91SAM9M10IHD)		+= at91sam9m10ihd/
>  obj-$(CONFIG_MACH_AT91SAM9N12EK)		+= at91sam9n12ek/
> -obj-$(CONFIG_MACH_AT91SAM9X5EK)			+= at91sam9x5ek/
> +nobj-$(CONFIG_MACH_AT91SAM9X5EK)			+= at91sam9x5ek/
>  obj-$(CONFIG_MACH_BEAGLE)			+= beagle/
>  obj-$(CONFIG_MACH_BEAGLEBONE)			+= beaglebone/
>  obj-$(CONFIG_MACH_CANON_A1100)			+= canon-a1100/
> @@ -138,3 +138,4 @@ obj-$(CONFIG_MACH_ZEDBOARD)			+= avnet-zedboard/
>  obj-$(CONFIG_MACH_ZYLONITE)			+= zylonite/
>  obj-$(CONFIG_MACH_VARISCITE_MX6)		+= variscite-mx6/
>  obj-$(CONFIG_MACH_QEMU_VIRT64)			+= qemu-virt64/
> +obj-$(CONFIG_MACH_VF610_TWR)			+= freescale-vf610-twr/
> diff --git a/arch/arm/boards/freescale-vf610-twr/Makefile b/arch/arm/boards/freescale-vf610-twr/Makefile
> new file mode 100644
> index 0000000..32a7da5
> --- /dev/null
> +++ b/arch/arm/boards/freescale-vf610-twr/Makefile
> @@ -0,0 +1,4 @@
> +obj-y += board.o
> +obj-y += flash-header-vf610-twr.dcd.o
> +extra-y += flash-header-vf610-twr.dcd.S flash-header-vf610-twr.dcd
> +lwl-y += lowlevel.o
> diff --git a/arch/arm/boards/freescale-vf610-twr/board.c b/arch/arm/boards/freescale-vf610-twr/board.c
> new file mode 100644
> index 0000000..0879f74
> --- /dev/null
> +++ b/arch/arm/boards/freescale-vf610-twr/board.c
> @@ -0,0 +1,61 @@
> +/*
> + * Copyright (c) 2016 Zodiac Inflight Innovation
> + * Author: Andrey Smirnov <andrew.smirnov@gmail.com>
> + *
> + * 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 <config.h>
> +#include <common.h>
> +#include <dma.h>
> +#include <driver.h>
> +#include <init.h>
> +#include <of.h>
> +#include <malloc.h>
> +#include <mci.h>
> +#include <clock.h>
> +#include <io.h>
> +#include <linux/clk.h>
> +#include <linux/err.h>
> +
> +/*
> + * Make sure that esdhc1's clock divider is 1
> + */
> +static int vf610_twr_sdhc1_clock_init(void)
> +{
> +	int err;
> +	struct clk *esdhc1_div, *esdhc1_div_parent;
> +
> +	if (!of_machine_is_compatible("fsl,vf610-twr"))
> +		return 0;
> +
> +	esdhc1_div = clk_lookup("esdhc1_div");
> +
> +	if (IS_ERR(esdhc1_div))
> +		return PTR_ERR(esdhc1_div);
> +
> +	esdhc1_div_parent = clk_get_parent(esdhc1_div);
> +	if (IS_ERR(esdhc1_div_parent))
> +		return PTR_ERR(esdhc1_div_parent);
> +
> +	err = clk_set_rate(esdhc1_div,
> +			   clk_get_rate(esdhc1_div_parent));
> +	if (err)
> +		return err;
> +
> +	clk_put(esdhc1_div);
> +
> +	return 0;
> +}
> +coredevice_initcall(vf610_twr_sdhc1_clock_init);

What's the background for this? Should it be made SoC specific?

> diff --git a/arch/arm/boards/freescale-vf610-twr/flash-header-vf610-twr.imxcfg b/arch/arm/boards/freescale-vf610-twr/flash-header-vf610-twr.imxcfg
> new file mode 100644
> index 0000000..18138d2
> --- /dev/null
> +++ b/arch/arm/boards/freescale-vf610-twr/flash-header-vf610-twr.imxcfg
> @@ -0,0 +1,277 @@
> +soc vf610
> +loadaddr 0x80000000
> +dcdofs 0x400
> +
> +#define VF610_DDR_PAD_CTRL	0x00000180 /* 25 Ohm drive strength */
> +#define VF610_DDR_PAD_CTRL_1	0x00010180 /* 25 Ohm drive strength + differential input */
> +
> +#define DDRMC_PHY_DQ_TIMING	0x00002613
> +#define DDRMC_PHY_DQS_TIMING	0x00002615
> +#define DDRMC_PHY_CTRL		0x00210000
> +#define DDRMC_PHY_MASTER_CTRL	0x0001012a
> +#define DDRMC_PHY_SLAVE_CTRL	0x00002000
> +#define DDRMC_PHY_OFF		0x00000000
> +#define DDRMC_PHY_PROC_PAD_ODT	0x00010101
> +
> +#ifdef DEBUG
> +#define CHECKPOINT(n) wm 32 0x3f000000 n
> +#else
> +#define CHECKPOINT(n)
> +#endif
> +
> +CHECKPOINT(1)
> +
> +/* ======================= Clock initialization =======================*/
> +
> +/*
> + * Ungate all IP block clocks
> + */
> +wm 32 0x4006b040 0xffffffff
> +wm 32 0x4006b044 0xffffffff
> +wm 32 0x4006b048 0xffffffff
> +wm 32 0x4006b04c 0xffffffff
> +wm 32 0x4006b050 0xffffffff
> +wm 32 0x4006b058 0xffffffff
> +wm 32 0x4006b05c 0xffffffff
> +wm 32 0x4006b060 0xffffffff
> +wm 32 0x4006b064 0xffffffff
> +wm 32 0x4006b068 0xffffffff
> +wm 32 0x4006b06c 0xffffffff
> +
> +
> +/*
> + * We have to options to clock DDR controller:
> + *
> + *  - Use Core-A5 clock
> + *  - Use PLL2 PFD2 clock
> + *
> +
> + * Using first option without changing PLL settings doesn't seem to be
> + * possible given that DDRMC requires minimum of 300Mhz and MaskROM
> + * configures it to be clocked at 264Mhz. Changing PLL1 settings
> + * proved to be challenging becuase MaskROM code executing this DCD
> + * will also be fetching the rest of the bootloader via some
> + * peripheral interface whose clock is derived from Cortex-A5 clock.
> + *
> + * As a result this DCD configuration code uses the second option of
> + * clocking DDR wiht PLL2 PFD2 clock output
> + *
> + * Turn PLL2 on
> + */
> +wm 32 0x40050030 0x00002001 /* Fout = Fin * 22 */
> +
> +CHECKPOINT(2)
> +
> +/*
> + * Wait for PLLs to lock
> + */
> +check 32 while_any_bit_clear 0x40050030 0x80000000
> +
> +
> +CHECKPOINT(3)
> +
> +/*
> + * Switch DDRMC to be clocked with PLL2 PFD2 and enable PFD2 output
> + */
> +clear_bits 32 0x4006b008 0x00000040
> +set_bits   32 0x4006b008 0x00002000
> +
> +
> +
> +/* ======================= DDR IOMUX ======================= */
> +
> +CHECKPOINT(4)
> +
> +wm 32 0x40048220 VF610_DDR_PAD_CTRL
> +wm 32 0x40048224 VF610_DDR_PAD_CTRL
> +wm 32 0x40048228 VF610_DDR_PAD_CTRL
> +wm 32 0x4004822c VF610_DDR_PAD_CTRL
> +wm 32 0x40048230 VF610_DDR_PAD_CTRL
> +wm 32 0x40048234 VF610_DDR_PAD_CTRL
> +wm 32 0x40048238 VF610_DDR_PAD_CTRL
> +wm 32 0x4004823c VF610_DDR_PAD_CTRL
> +wm 32 0x40048240 VF610_DDR_PAD_CTRL
> +wm 32 0x40048244 VF610_DDR_PAD_CTRL
> +wm 32 0x40048248 VF610_DDR_PAD_CTRL
> +wm 32 0x4004824c VF610_DDR_PAD_CTRL
> +wm 32 0x40048250 VF610_DDR_PAD_CTRL
> +wm 32 0x40048254 VF610_DDR_PAD_CTRL
> +wm 32 0x40048258 VF610_DDR_PAD_CTRL
> +wm 32 0x4004825c VF610_DDR_PAD_CTRL
> +wm 32 0x40048260 VF610_DDR_PAD_CTRL
> +wm 32 0x40048264 VF610_DDR_PAD_CTRL
> +wm 32 0x40048268 VF610_DDR_PAD_CTRL
> +wm 32 0x4004826c VF610_DDR_PAD_CTRL
> +wm 32 0x40048270 VF610_DDR_PAD_CTRL
> +wm 32 0x40048274 VF610_DDR_PAD_CTRL
> +wm 32 0x40048278 VF610_DDR_PAD_CTRL
> +wm 32 0x4004827c VF610_DDR_PAD_CTRL_1
> +wm 32 0x40048280 VF610_DDR_PAD_CTRL_1
> +wm 32 0x40048284 VF610_DDR_PAD_CTRL_1
> +wm 32 0x40048288 VF610_DDR_PAD_CTRL_1
> +wm 32 0x4004828c VF610_DDR_PAD_CTRL_1
> +wm 32 0x40048290 VF610_DDR_PAD_CTRL_1
> +wm 32 0x40048294 VF610_DDR_PAD_CTRL_1
> +wm 32 0x40048298 VF610_DDR_PAD_CTRL_1
> +wm 32 0x4004829c VF610_DDR_PAD_CTRL_1
> +wm 32 0x400482a0 VF610_DDR_PAD_CTRL_1
> +wm 32 0x400482a4 VF610_DDR_PAD_CTRL_1
> +wm 32 0x400482a8 VF610_DDR_PAD_CTRL_1
> +wm 32 0x400482ac VF610_DDR_PAD_CTRL_1
> +wm 32 0x400482b0 VF610_DDR_PAD_CTRL_1
> +wm 32 0x400482b4 VF610_DDR_PAD_CTRL_1
> +wm 32 0x400482b8 VF610_DDR_PAD_CTRL_1
> +wm 32 0x400482bc VF610_DDR_PAD_CTRL_1
> +wm 32 0x400482c0 VF610_DDR_PAD_CTRL_1
> +wm 32 0x400482c4 VF610_DDR_PAD_CTRL_1
> +wm 32 0x400482c8 VF610_DDR_PAD_CTRL_1
> +wm 32 0x400482cc VF610_DDR_PAD_CTRL
> +wm 32 0x400482d0 VF610_DDR_PAD_CTRL
> +wm 32 0x400482d4 VF610_DDR_PAD_CTRL
> +wm 32 0x400482d8 VF610_DDR_PAD_CTRL
> +wm 32 0x4004821c VF610_DDR_PAD_CTRL
> +
> +/* ======================= DDR Controller =======================*/
> +
> +CHECKPOINT(5)
> +
> +wm 32 0x400ae000 0x00000600
> +wm 32 0x400ae008 0x00000020
> +wm 32 0x400ae028 0x00013880
> +wm 32 0x400ae02c 0x00030d40
> +wm 32 0x400ae030 0x0000050c
> +wm 32 0x400ae034 0x15040400
> +wm 32 0x400ae038 0x1406040f
> +wm 32 0x400ae040 0x04040000
> +wm 32 0x400ae044 0x006db00c
> +wm 32 0x400ae048 0x00000403
> +wm 32 0x400ae050 0x01000000
> +wm 32 0x400ae054 0x00060001
> +wm 32 0x400ae058 0x000c0000
> +wm 32 0x400ae05c 0x03000200
> +wm 32 0x400ae060 0x00000006
> +wm 32 0x400ae064 0x00010000
> +wm 32 0x400ae068 0x0c30002c
> +wm 32 0x400ae070 0x00000000
> +wm 32 0x400ae074 0x00000003
> +wm 32 0x400ae078 0x0000000a
> +wm 32 0x400ae07c 0x003001d4
> +wm 32 0x400ae084 0x00010000
> +wm 32 0x400ae088 0x00050500
> +wm 32 0x400ae098 0x00000000
> +wm 32 0x400ae09c 0x04001002
> +wm 32 0x400ae0a4 0x00000001
> +wm 32 0x400ae0c0 0x00460420
> +wm 32 0x400ae108 0x01000200
> +wm 32 0x400ae10c 0x00000040
> +wm 32 0x400ae114 0x00000200
> +wm 32 0x400ae118 0x00000040
> +wm 32 0x400ae120 0x00000000
> +wm 32 0x400ae124 0x0a010300
> +wm 32 0x400ae128 0x01014040
> +wm 32 0x400ae12c 0x01010101
> +wm 32 0x400ae130 0x03030100
> +wm 32 0x400ae134 0x01000101
> +wm 32 0x400ae138 0x0700000c
> +wm 32 0x400ae13c 0x00000000
> +wm 32 0x400ae148 0x10000000
> +wm 32 0x400ae15c 0x01000000
> +wm 32 0x400ae160 0x00040000
> +wm 32 0x400ae164 0x00000002
> +wm 32 0x400ae16c 0x00020000
> +wm 32 0x400ae180 0x00002819
> +wm 32 0x400ae184 0x01000000
> +wm 32 0x400ae188 0x00000000
> +wm 32 0x400ae18c 0x00000000
> +wm 32 0x400ae198 0x00010100
> +wm 32 0x400ae1a4 0x00000000
> +wm 32 0x400ae1a8 0x00000004
> +wm 32 0x400ae1b8 0x00040000
> +wm 32 0x400ae1c8 0x00000000
> +wm 32 0x400ae1cc 0x00000000
> +wm 32 0x400ae1d4 0x00000000
> +wm 32 0x400ae1d8 0x01010000
> +wm 32 0x400ae1e0 0x02020000
> +wm 32 0x400ae1e4 0x00000202
> +wm 32 0x400ae1e8 0x01010064
> +wm 32 0x400ae1ec 0x00010101
> +wm 32 0x400ae1f0 0x00000064
> +wm 32 0x400ae1f8 0x00000800
> +wm 32 0x400ae210 0x00000506
> +wm 32 0x400ae224 0x00020000
> +wm 32 0x400ae228 0x01000000
> +wm 32 0x400ae22c 0x04070303
> +wm 32 0x400ae230 0x00000040
> +wm 32 0x400ae23c 0x06000080
> +wm 32 0x400ae240 0x04070303
> +wm 32 0x400ae244 0x00000040
> +wm 32 0x400ae248 0x00000040
> +wm 32 0x400ae24c 0x000f0000
> +wm 32 0x400ae250 0x000f0000
> +wm 32 0x400ae25c 0x00000101
> +wm 32 0x400ae268 0x682c4000
> +wm 32 0x400ae26c 0x00000012
> +wm 32 0x400ae278 0x00000006
> +wm 32 0x400ae284 0x00010202
> +
> +/* ======================= DDR PHY =======================*/
> +
> +CHECKPOINT(6)
> +
> +wm 32 0x400ae400 DDRMC_PHY_DQ_TIMING
> +wm 32 0x400ae440 DDRMC_PHY_DQ_TIMING
> +wm 32 0x400ae480 DDRMC_PHY_DQ_TIMING
> +wm 32 0x400ae404 DDRMC_PHY_DQS_TIMING
> +wm 32 0x400ae444 DDRMC_PHY_DQS_TIMING
> +wm 32 0x400ae408 DDRMC_PHY_CTRL
> +wm 32 0x400ae448 DDRMC_PHY_CTRL
> +wm 32 0x400ae488 DDRMC_PHY_CTRL
> +wm 32 0x400ae40c DDRMC_PHY_CTRL
> +wm 32 0x400ae44c DDRMC_PHY_CTRL
> +wm 32 0x400ae48c DDRMC_PHY_CTRL
> +wm 32 0x400ae410 DDRMC_PHY_SLAVE_CTRL
> +wm 32 0x400ae450 DDRMC_PHY_SLAVE_CTRL
> +wm 32 0x400ae490 DDRMC_PHY_SLAVE_CTRL
> +wm 32 0x400ae4c4 DDRMC_PHY_OFF
> +wm 32 0x400ae4c8 0x00001100
> +wm 32 0x400ae4d0 DDRMC_PHY_PROC_PAD_ODT
> +wm 32 0x400ae000 0x00000601
> +
> +CHECKPOINT(7)
> +
> +check 32 while_any_bit_clear 0x400ae140 0x100
> +
> +CHECKPOINT(8)
> +
> +/*
> + * Cargo cult DDR controller initialization here we come!
> + *
> + * Experemintation with VF610 Tower Board shows that without the

s/Experemintation/Experimentation/

> + * following code the board would not boot off of SD card when
> + * power-cycled. It will however happily boot when reset via SW3/Reset
> + * button. For whatever reason the following actions appear to be
> + * necessary:
> + *
> + *          - Initialize DDRMC as usual
> + *	    - Issue a read to location in DDR address space
> + *	    - Disable DDRMC
> + *	    - Enable DDRMC and wait for it to finish initializing
> + *
> + * I am sure this is all going to be extrememly embarrassing to read
> + * if/when the real problem and real solution is found.
> + */
> +
> +/*
> + * Because there's no standalone read command what we do here instead
> + * is write a pattern to memory and then checking that memory address
> + * against that pattern
> + */
> +wm 32 0x80000000 0xa5a5a5a5
> +check 32 while_any_bit_clear 0x80000000 0xa5a5a5a5
> +
> +wm 32 0x400ae000 0x00000600
> +wm 32 0x400ae000 0x00000601
> +
> +check 32 while_any_bit_clear 0x400ae140 0x100
> +
> +CHECKPOINT(9)
> \ No newline at end of file
> diff --git a/arch/arm/boards/freescale-vf610-twr/lowlevel.c b/arch/arm/boards/freescale-vf610-twr/lowlevel.c
> new file mode 100644
> index 0000000..6504273
> --- /dev/null
> +++ b/arch/arm/boards/freescale-vf610-twr/lowlevel.c
> @@ -0,0 +1,45 @@
> +#include <common.h>
> +#include <linux/sizes.h>
> +#include <mach/generic.h>
> +#include <asm/barebox-arm-head.h>
> +#include <asm/barebox-arm.h>
> +#include <mach/vf610-regs.h>
> +#include <mach/clock-vf610.h>
> +#include <mach/iomux-vf610.h>
> +#include <debug_ll.h>
> +
> +static inline void setup_uart(void)
> +{
> +	void __iomem *iomuxbase = IOMEM(VF610_IOMUXC_BASE_ADDR);
> +
> +	vf610_ungate_all_peripherals();
> +
> +	/*
> +	 * VF610_PAD_PTB4__UART1_TX
> +	 */
> +	writel(VF610_UART_PAD_CTRL | (2 << 20), iomuxbase + 0x0068);
> +	writel(0, iomuxbase + 0x0380);
> +
> +	vf610_uart_setup_ll();
> +}
> +
> +extern char __dtb_vf610_twr_start[];
> +
> +ENTRY_FUNCTION(start_vf610_twr, r0, r1, r2)
> +{
> +	int i;
> +	void *fdt;
> +	void __iomem *mscm = IOMEM(VF610_MSCM_BASE_ADDR);
> +
> +	vf610_cpu_lowlevel_init();
> +
> +	for (i = 0; i < VF610_MSCM_IRSPRC_NUM; i++)
> +		writew(VF610_MSCM_IRSPRC_CP0_EN,
> +		       mscm + VF610_MSCM_IRSPRC(i));
> +
> +	if (IS_ENABLED(CONFIG_DEBUG_LL))
> +		setup_uart();
> +
> +	fdt = __dtb_vf610_twr_start - get_runtime_offset();
> +	barebox_arm_entry(0x80000000, SZ_128M, fdt);
> +}
> diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
> index d1a3fe8..f93152c 100644
> --- a/arch/arm/dts/Makefile
> +++ b/arch/arm/dts/Makefile
> @@ -76,5 +76,6 @@ pbl-dtb-$(CONFIG_MACH_TX6X) += imx6q-tx6q.dtb.o
>  pbl-dtb-$(CONFIG_MACH_UDOO) += imx6q-udoo.dtb.o
>  pbl-dtb-$(CONFIG_MACH_USI_TOPKICK) += kirkwood-topkick-bb.dtb.o
>  pbl-dtb-$(CONFIG_MACH_VARISCITE_MX6) += imx6q-var-custom.dtb.o
> +pbl-dtb-$(CONFIG_MACH_VF610_TWR) += vf610-twr.dtb.o
>  
>  clean-files := *.dtb *.dtb.S .*.dtc .*.pre .*.dts *.dtb.lzo
> diff --git a/arch/arm/dts/vf610-twr.dts b/arch/arm/dts/vf610-twr.dts
> new file mode 100644
> index 0000000..54b4435
> --- /dev/null
> +++ b/arch/arm/dts/vf610-twr.dts
> @@ -0,0 +1,14 @@
> +/*
> + * Copyright 2013 Freescale Semiconductor, Inc.
> + *
> + * 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.
> + */
> +
> +#include <arm/vf610-twr.dts>
> +
> +&usbdev0 {
> +	status = "disabled";
> +};
> diff --git a/arch/arm/mach-imx/Kconfig b/arch/arm/mach-imx/Kconfig
> index 71862ef..0284a8f 100644
> --- a/arch/arm/mach-imx/Kconfig
> +++ b/arch/arm/mach-imx/Kconfig
> @@ -332,6 +332,10 @@ config MACH_CM_FX6
>  	bool "CM FX6"
>  	select ARCH_IMX6
>  
> +config MACH_VF610_TWR
> +	bool "Freescale VF610 Tower Board"
> +	select ARCH_VF610
> +
>  endif
>  
>  # ----------------------------------------------------------
> diff --git a/arch/arm/mach-imx/include/mach/clock-vf610.h b/arch/arm/mach-imx/include/mach/clock-vf610.h

Should be added in a SoC specific patch.

> +#define CCM_CCR_FIRC_EN				(1 << 16)
> +#define CCM_CCR_OSCNT_MASK			0xff
> +#define CCM_CCR_OSCNT(v)			((v) & 0xff)
> +

[...]

> +#define ENET_EXTERNAL_CLK	50000000
> +#define AUDIO_EXTERNAL_CLK	24576000

VF610_ prefix?

> diff --git a/arch/arm/mach-imx/include/mach/iomux-vf610.h b/arch/arm/mach-imx/include/mach/iomux-vf610.h

Should also be added in a SoC specific patch.

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-5555 |

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

^ permalink raw reply

* Re: [PATCH 02/20] i.MX: Add DEBUG_LL hooks for VF610
From: Sascha Hauer @ 2016-10-04  6:24 UTC (permalink / raw)
  To: Andrey Smirnov; +Cc: barebox
In-Reply-To: <1475505657-898-3-git-send-email-andrew.smirnov@gmail.com>

On Mon, Oct 03, 2016 at 07:40:39AM -0700, Andrey Smirnov wrote:
> Add code to support DEBUG_LL functionality on VF610/Vybrid platform.
> 
> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
> ---
>  arch/arm/mach-imx/include/mach/debug_ll.h   |  27 ++-
>  arch/arm/mach-imx/include/mach/vf610-regs.h | 126 +++++++++++++
>  common/Kconfig                              |  10 +-
>  include/serial/lpuart.h                     | 265 ++++++++++++++++++++++++++++
>  4 files changed, 426 insertions(+), 2 deletions(-)
>  create mode 100644 arch/arm/mach-imx/include/mach/vf610-regs.h
>  create mode 100644 include/serial/lpuart.h
> 
> diff --git a/arch/arm/mach-imx/include/mach/debug_ll.h b/arch/arm/mach-imx/include/mach/debug_ll.h
> index 5c2db6c..a132f3c 100644
> --- a/arch/arm/mach-imx/include/mach/debug_ll.h
> +++ b/arch/arm/mach-imx/include/mach/debug_ll.h
> @@ -14,8 +14,10 @@
>  #include <mach/imx51-regs.h>
>  #include <mach/imx53-regs.h>
>  #include <mach/imx6-regs.h>
> +#include <mach/vf610-regs.h>
>  
>  #include <serial/imx-uart.h>
> +#include <serial/lpuart.h>
>  
>  #ifdef CONFIG_DEBUG_LL
>  
> @@ -42,6 +44,8 @@
>  #define IMX_DEBUG_SOC MX53
>  #elif defined CONFIG_DEBUG_IMX6Q_UART
>  #define IMX_DEBUG_SOC MX6
> +#elif defined CONFIG_DEBUG_VF610_UART
> +#define IMX_DEBUG_SOC VF610
>  #else
>  #error "unknown i.MX debug uart soc type"
>  #endif
> @@ -74,6 +78,13 @@ static inline void imx6_uart_setup_ll(void)
>  	imx6_uart_setup(base);
>  }
>  
> +static inline void vf610_uart_setup_ll(void)
> +{
> +	void *base = IOMEM(IMX_UART_BASE(IMX_DEBUG_SOC, CONFIG_DEBUG_IMX_UART_PORT));
> +
> +	lpuart_setup(base, 66000000);
> +}
> +
>  static inline void PUTC_LL(int c)
>  {
>  	void __iomem *base = IOMEM(IMX_UART_BASE(IMX_DEBUG_SOC,
> @@ -82,14 +93,19 @@ static inline void PUTC_LL(int c)
>  	if (!base)
>  		return;
>  
> -	imx_uart_putc(base, c);
> +	if (IS_ENABLED(CONFIG_DEBUG_VF610_UART))
> +		lpuart_putc(base, c);
> +	else
> +		imx_uart_putc(base, c);
>  }
> +
>  #else
>  
>  static inline void imx50_uart_setup_ll(void) {}
>  static inline void imx51_uart_setup_ll(void) {}
>  static inline void imx53_uart_setup_ll(void) {}
>  static inline void imx6_uart_setup_ll(void)  {}
> +static inline void vf610_uart_setup_ll(void) {}
>  
>  #endif /* CONFIG_DEBUG_LL */
>  
> @@ -115,4 +131,13 @@ static inline void imx53_ungate_all_peripherals(void)
>  	imx_ungate_all_peripherals(IOMEM(MX53_CCM_BASE_ADDR));
>  }
>  
> +static inline void vf610_ungate_all_peripherals(void)
> +{
> +	void __iomem *ccmbase = IOMEM(VF610_CCM_BASE_ADDR);
> +	int i;
> +
> +	for (i = 0x40; i <= 0x6c; i += 4)
> +		writel(0xffffffff, ccmbase + i);
> +}
> +
>  #endif /* __MACH_DEBUG_LL_H__ */
> diff --git a/arch/arm/mach-imx/include/mach/vf610-regs.h b/arch/arm/mach-imx/include/mach/vf610-regs.h

This is probably not the right patch to add this file.

> new file mode 100644
> index 0000000..a1c1a09
> --- /dev/null
> +++ b/arch/arm/mach-imx/include/mach/vf610-regs.h
> @@ -0,0 +1,126 @@
> +/*
> + * Copyright 2013-2014 Freescale Semiconductor, Inc.
> + *
> + * SPDX-License-Identifier:	GPL-2.0+
> + */
> +
> +#ifndef __ASM_ARCH_IMX_REGS_H__
> +#define __ASM_ARCH_IMX_REGS_H__

MACH_VF610_REGS_H ?

> +/* System Reset Controller (SRC) */
> +#define SRC_SRSR_SW_RST					(0x1 << 18)
> +#define SRC_SRSR_RESETB					(0x1 << 7)
> +#define SRC_SRSR_JTAG_RST				(0x1 << 5)
> +#define SRC_SRSR_WDOG_M4				(0x1 << 4)
> +#define SRC_SRSR_WDOG_A5				(0x1 << 3)
> +#define SRC_SRSR_POR_RST				(0x1 << 0)
> +#define SRC_SBMR2_BMOD_MASK             (0x3 << 24)
> +#define SRC_SBMR2_BMOD_SHIFT            24
> +#define SRC_SBMR2_BMOD_FUSES            0x0
> +#define SRC_SBMR2_BMOD_SERIAL           0x1
> +#define SRC_SBMR2_BMOD_RCON             0x2

Please add a VF610_ prefix.

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-5555 |

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

^ permalink raw reply

* Re: [PATCH] sandbox: Makefile: drop unused SUBARCH stuff
From: Sascha Hauer @ 2016-10-04  6:16 UTC (permalink / raw)
  To: Antony Pavlov; +Cc: barebox
In-Reply-To: <20161003115657.17953-1-antonynpavlov@gmail.com>

On Mon, Oct 03, 2016 at 02:56:57PM +0300, Antony Pavlov wrote:
> Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
> ---
>  arch/sandbox/Makefile | 5 -----
>  1 file changed, 5 deletions(-)

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-5555 |

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

^ permalink raw reply

* Re: [PATCH] net/phy: marvell: fix error handling
From: Sascha Hauer @ 2016-10-04  6:15 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: barebox
In-Reply-To: <20160930201008.4136-1-u.kleine-koenig@pengutronix.de>

On Fri, Sep 30, 2016 at 10:10:08PM +0200, Uwe Kleine-König wrote:
> Without first assigning to ret it doesn't make sense to check it.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
>  drivers/net/phy/marvell.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

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-5555 |

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

^ permalink raw reply

* Re: [PATCH 01/10] serial: arm_dcc: depend on !CPU_V8
From: Sascha Hauer @ 2016-10-04  6:13 UTC (permalink / raw)
  To: Lucas Stach; +Cc: barebox
In-Reply-To: <20160930103607.15791-1-l.stach@pengutronix.de>

On Fri, Sep 30, 2016 at 12:35:58PM +0200, Lucas Stach wrote:
> The DCC console uses coprocessor registers registers accesses, the
> implementation of those for ARMv8 is currently missing.
> 
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
> ---
>  drivers/serial/Kconfig | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

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-5555 |

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

^ permalink raw reply

* Re: [PATCH 1/2] i.MX: Introduce imx6_cpu_revision()
From: Sascha Hauer @ 2016-10-04  6:10 UTC (permalink / raw)
  To: Andrey Smirnov; +Cc: barebox
In-Reply-To: <1475187703-5748-1-git-send-email-andrew.smirnov@gmail.com>

On Thu, Sep 29, 2016 at 03:21:42PM -0700, Andrey Smirnov wrote:
> Factor out CPU revision identification code from imx6_init() into a
> standalone inline function (similar to imx6_cpu_type()), so that it
> would be possible to use that functionality in PBL code.
> 
> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
> ---
> 
> Sascha:
> 
> I have an almost ready to send, board support patch that uses this in
> PBL. Unfortunately at the last minute a regression in functionality
> was discovered in that code, so I can't post it until that is
> resolved, meanwhile I am hoping I can get this code in while I am
> debugging.
> 
> Let me know if you'd rathe I send everything together.

Looks good as is. Just send your board support when the remaining issues
are resolved. Thanks, applied.

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-5555 |

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

^ permalink raw reply

* Re: [PATCH] pinctrl: mvebu: add newline to error message
From: Sascha Hauer @ 2016-10-04  6:05 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: barebox
In-Reply-To: <1475092260-12749-1-git-send-email-uwe@kleine-koenig.org>

On Wed, Sep 28, 2016 at 09:51:00PM +0200, Uwe Kleine-König wrote:
> Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org>
> ---
>  drivers/pinctrl/mvebu/common.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Applied, thanks

Sascha

> 
> diff --git a/drivers/pinctrl/mvebu/common.c b/drivers/pinctrl/mvebu/common.c
> index 532705286795..ae16b39268d7 100644
> --- a/drivers/pinctrl/mvebu/common.c
> +++ b/drivers/pinctrl/mvebu/common.c
> @@ -78,7 +78,8 @@ static int mvebu_pinctrl_set_state(struct pinctrl_device *pdev,
>  
>  		set = mvebu_pinctrl_find_setting_by_name(pctl, mode, function);
>  		if (!set) {
> -			dev_err(pdev->dev, "unsupported function %s on pin %s",
> +			dev_err(pdev->dev,
> +				"unsupported function %s on pin %s\n",
>  				function, group);
>  			continue;
>  		}
> -- 
> 2.8.1
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox

-- 
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-5555 |

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

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox