[U-Boot] [PATCH v2 1/2] ARC: HSDK: add platform-specific commands

2018-03-26 Thread Eugeniy Paltsev
This patch add support of hsdk platform-specific commands:

hsdk_clock set - set clock from axi_freq, cpu_freq and tun_freq
environment variables/command line arguments

hsdk_clock get - save clock frequencies to axi_freq, cpu_freq
and tun_freq environment variables

hsdk_clock print - show CPU, AXI, DDR and TUNNEL current
clock frequencies.

hsdk_clock print_all - show all currently used clock frequencies.

hsdk_init - setup board HW in one of pre-defined configuration
(hsdk_hs34 / hsdk_hs36 / hsdk_hs36_ccm / hsdk_hs38 /
hsdk_hs38_ccm / hsdk_hs38x2 / hsdk_hs38x3 / hsdk_hs38x4)

hsdk_go - run baremetal application on hsdk configured
by hsdk_init command.

This patch changes default behaviour of 'bootm' command:
now we are able to set number of CPUs to be kicked by setting
'core_mask' environment variable before 'bootm' command run.

Signed-off-by: Eugeniy Paltsev 
---
 arch/arc/dts/hsdk.dts   |   30 ++
 board/synopsys/hsdk/MAINTAINERS |4 +-
 board/synopsys/hsdk/Makefile|2 +
 board/synopsys/hsdk/clk-lib.c   |   75 +++
 board/synopsys/hsdk/clk-lib.h   |   38 ++
 board/synopsys/hsdk/env-lib.c   |  302 +++
 board/synopsys/hsdk/env-lib.h   |   58 +++
 board/synopsys/hsdk/hsdk.c  | 1046 +--
 configs/hsdk_defconfig  |4 +
 include/configs/hsdk.h  |   56 ++-
 10 files changed, 1564 insertions(+), 51 deletions(-)
 create mode 100644 board/synopsys/hsdk/clk-lib.c
 create mode 100644 board/synopsys/hsdk/clk-lib.h
 create mode 100644 board/synopsys/hsdk/env-lib.c
 create mode 100644 board/synopsys/hsdk/env-lib.h

diff --git a/arch/arc/dts/hsdk.dts b/arch/arc/dts/hsdk.dts
index 67dfb93ca8..09f3fe9a37 100644
--- a/arch/arc/dts/hsdk.dts
+++ b/arch/arc/dts/hsdk.dts
@@ -6,6 +6,7 @@
 /dts-v1/;
 
 #include "skeleton.dtsi"
+#include "dt-bindings/clock/snps,hsdk-cgu.h"
 
 / {
#address-cells = <1>;
@@ -24,6 +25,35 @@
};
};
 
+   clk-fmeas {
+   clocks = <&cgu_clk CLK_ARC_PLL>, <&cgu_clk CLK_SYS_PLL>,
+<&cgu_clk CLK_TUN_PLL>, <&cgu_clk CLK_DDR_PLL>,
+<&cgu_clk CLK_ARC>, <&cgu_clk CLK_HDMI_PLL>,
+<&cgu_clk CLK_TUN_TUN>, <&cgu_clk CLK_HDMI>,
+<&cgu_clk CLK_SYS_APB>, <&cgu_clk CLK_SYS_AXI>,
+<&cgu_clk CLK_SYS_ETH>, <&cgu_clk CLK_SYS_USB>,
+<&cgu_clk CLK_SYS_SDIO>, <&cgu_clk CLK_SYS_HDMI>,
+<&cgu_clk CLK_SYS_GFX_CORE>, <&cgu_clk 
CLK_SYS_GFX_DMA>,
+<&cgu_clk CLK_SYS_GFX_CFG>, <&cgu_clk 
CLK_SYS_DMAC_CORE>,
+<&cgu_clk CLK_SYS_DMAC_CFG>, <&cgu_clk 
CLK_SYS_SDIO_REF>,
+<&cgu_clk CLK_SYS_SPI_REF>, <&cgu_clk CLK_SYS_I2C_REF>,
+<&cgu_clk CLK_SYS_UART_REF>, <&cgu_clk 
CLK_SYS_EBI_REF>,
+<&cgu_clk CLK_TUN_ROM>, <&cgu_clk CLK_TUN_PWM>;
+   clock-names = "cpu-pll", "sys-pll",
+ "tun-pll", "ddr-clk",
+ "cpu-clk", "hdmi-pll",
+ "tun-clk", "hdmi-clk",
+ "apb-clk", "axi-clk",
+ "eth-clk", "usb-clk",
+ "sdio-clk", "hdmi-sys-clk",
+ "gfx-core-clk", "gfx-dma-clk",
+ "gfx-cfg-clk", "dmac-core-clk",
+ "dmac-cfg-clk", "sdio-ref-clk",
+ "spi-clk", "i2c-clk",
+ "uart-clk", "ebi-clk",
+ "rom-clk", "pwm-clk";
+   };
+
cgu_clk: cgu-clk@f000 {
compatible = "snps,hsdk-cgu-clock";
reg = <0xf000 0x10>, <0xf00014B8 0x4>;
diff --git a/board/synopsys/hsdk/MAINTAINERS b/board/synopsys/hsdk/MAINTAINERS
index d034bc479d..e22bd1e40b 100644
--- a/board/synopsys/hsdk/MAINTAINERS
+++ b/board/synopsys/hsdk/MAINTAINERS
@@ -1,5 +1,5 @@
-AXS10X BOARD
-M: Alexey Brodkin 
+HSDK BOARD
+M: Eugeniy Paltsev 
 S: Maintained
 F: board/synopsys/hsdk/
 F: configs/hsdk_defconfig
diff --git a/board/synopsys/hsdk/Makefile b/board/synopsys/hsdk/Makefile
index d84dd03265..7ecff3d740 100644
--- a/board/synopsys/hsdk/Makefile
+++ b/board/synopsys/hsdk/Makefile
@@ -5,3 +5,5 @@
 #
 
 obj-y  += hsdk.o
+obj-y  += env-lib.o
+obj-y  += clk-lib.o
diff --git a/board/synopsys/hsdk/clk-lib.c b/board/synopsys/hsdk/clk-lib.c
new file mode 100644
index 00..1ce54afffe
--- /dev/null
+++ b/board/synopsys/hsdk/clk-lib.c
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2018 Synopsys, Inc. All rights reserved.
+ * Author: Eugeniy Paltsev 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+
+#include "clk-lib.h"
+
+#define HZ_IN_MHZ  100
+#define ceil(x, y) ({ ulong __x = (x), __y = (y); (__x + __y - 1) / __y; })
+
+int soc_clk_ctl(const char *name, u

Re: [U-Boot] [PATCH v2 1/2] ARC: HSDK: add platform-specific commands

2018-03-30 Thread Alexey Brodkin
Hi Tom,

On Mon, 2018-03-26 at 15:57 +0300, Eugeniy Paltsev wrote:
> This patch add support of hsdk platform-specific commands:
> 
> hsdk_clock set - set clock from axi_freq, cpu_freq and tun_freq
> environment variables/command line arguments
> 
> hsdk_clock get - save clock frequencies to axi_freq, cpu_freq
> and tun_freq environment variables
> 
> hsdk_clock print - show CPU, AXI, DDR and TUNNEL current
> clock frequencies.
> 
> hsdk_clock print_all - show all currently used clock frequencies.
> 
> hsdk_init - setup board HW in one of pre-defined configuration
> (hsdk_hs34 / hsdk_hs36 / hsdk_hs36_ccm / hsdk_hs38 /
> hsdk_hs38_ccm / hsdk_hs38x2 / hsdk_hs38x3 / hsdk_hs38x4)
> 
> hsdk_go - run baremetal application on hsdk configured
> by hsdk_init command.
> 
> This patch changes default behaviour of 'bootm' command:
> now we are able to set number of CPUs to be kicked by setting
> 'core_mask' environment variable before 'bootm' command run.
> 
> Signed-off-by: Eugeniy Paltsev 
> ---

I was about to send you a pull-request containing this one but
decided to give TravisCI a shot. And what I got was a warning
due to not yet supported "naked" attribute in GCC 6.x for ARC,
see https://travis-ci.org/abrodkin/u-boot/jobs/360259472

Ok I bumped ARC tools to the most recent arc-2017.09 based on
GCC 7.1 where "naked" attr for ARC is already supported.
But then I got another warning:
->8---
board/synopsys/hsdk/hsdk.c: In function "hsdk_core_init_f":
board/synopsys/hsdk/hsdk.c:345:1: error: stack usage computation not supported 
for this target [-Werror]
 }
 ^
->8---
see https://travis-ci.org/abrodkin/u-boot/jobs/360274604


That happens because GCC for ARC unconditionally tries to compute
stack requirements for all functions even if they are "naked".
And for "naked" computed value is negative thus the warning above.

So far I didn't manage to find a simple way to disable that warning.

And my question would be how to proceed with this [patch]?
Given we're seeing a problem in GCC it most probably won't be fixed
in U-Boot and we'll need to wait before new tools are available.

Or otherwise we'll start to see "failing" ARC jobs in TravisCI.

-Alexey
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 1/2] ARC: HSDK: add platform-specific commands

2018-04-01 Thread Tom Rini
On Fri, Mar 30, 2018 at 08:08:19PM +, Alexey Brodkin wrote:
> Hi Tom,
> 
> On Mon, 2018-03-26 at 15:57 +0300, Eugeniy Paltsev wrote:
> > This patch add support of hsdk platform-specific commands:
> > 
> > hsdk_clock set - set clock from axi_freq, cpu_freq and tun_freq
> > environment variables/command line arguments
> > 
> > hsdk_clock get - save clock frequencies to axi_freq, cpu_freq
> > and tun_freq environment variables
> > 
> > hsdk_clock print - show CPU, AXI, DDR and TUNNEL current
> > clock frequencies.
> > 
> > hsdk_clock print_all - show all currently used clock frequencies.
> > 
> > hsdk_init - setup board HW in one of pre-defined configuration
> > (hsdk_hs34 / hsdk_hs36 / hsdk_hs36_ccm / hsdk_hs38 /
> > hsdk_hs38_ccm / hsdk_hs38x2 / hsdk_hs38x3 / hsdk_hs38x4)
> > 
> > hsdk_go - run baremetal application on hsdk configured
> > by hsdk_init command.
> > 
> > This patch changes default behaviour of 'bootm' command:
> > now we are able to set number of CPUs to be kicked by setting
> > 'core_mask' environment variable before 'bootm' command run.
> > 
> > Signed-off-by: Eugeniy Paltsev 
> > ---
> 
> I was about to send you a pull-request containing this one but
> decided to give TravisCI a shot. And what I got was a warning
> due to not yet supported "naked" attribute in GCC 6.x for ARC,
> see https://travis-ci.org/abrodkin/u-boot/jobs/360259472
> 
> Ok I bumped ARC tools to the most recent arc-2017.09 based on
> GCC 7.1 where "naked" attr for ARC is already supported.
> But then I got another warning:
> ->8---
> board/synopsys/hsdk/hsdk.c: In function "hsdk_core_init_f":
> board/synopsys/hsdk/hsdk.c:345:1: error: stack usage computation not 
> supported for this target [-Werror]
>  }
>  ^
> ->8---
> see https://travis-ci.org/abrodkin/u-boot/jobs/360274604
> 
> 
> That happens because GCC for ARC unconditionally tries to compute
> stack requirements for all functions even if they are "naked".
> And for "naked" computed value is negative thus the warning above.
> 
> So far I didn't manage to find a simple way to disable that warning.
> 
> And my question would be how to proceed with this [patch]?
> Given we're seeing a problem in GCC it most probably won't be fixed
> in U-Boot and we'll need to wait before new tools are available.
> 
> Or otherwise we'll start to see "failing" ARC jobs in TravisCI.

Ugh.  (a) get the toolchain fixed to support this correctly and (b)
kludge scripts/gcc-stack-usage.sh to have a 'naked' example too so that
we'll just disable -fstack-usage on ARC for now.

-- 
Tom


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot