[PATCH v4 3/6] ARM: dts: sync Actions Semi S700 DT from Linux v5.16-rc3

2021-12-02 Thread Amit Singh Tomar
From: Amit Singh Tomar 

This Synchronizes the Actions Semi S700 SoC DT changes from
commit "g58e1100fdc59" ("Linux v5.16-rc3").

Signed-off-by: Amit Singh Tomar 
---
 arch/arm/dts/s700.dtsi| 17 -
 .../dt-bindings/power/owl-s700-powergate.h| 19 +++
 2 files changed, 35 insertions(+), 1 deletion(-)
 create mode 100644 include/dt-bindings/power/owl-s700-powergate.h

diff --git a/arch/arm/dts/s700.dtsi b/arch/arm/dts/s700.dtsi
index 2006ad5424fa..2c78caebf515 100644
--- a/arch/arm/dts/s700.dtsi
+++ b/arch/arm/dts/s700.dtsi
@@ -5,6 +5,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 / {
@@ -231,7 +232,7 @@
 
pinctrl: pinctrl@e01b {
compatible = "actions,s700-pinctrl";
-   reg = <0x0 0xe01b 0x0 0x1000>;
+   reg = <0x0 0xe01b 0x0 0x100>;
clocks = <&cmu CLK_GPIO>;
gpio-controller;
gpio-ranges = <&pinctrl 0 0 136>;
@@ -244,5 +245,19 @@
 ,
 ;
};
+
+   dma: dma-controller@e023 {
+   compatible = "actions,s700-dma";
+   reg = <0x0 0xe023 0x0 0x1000>;
+   interrupts = ,
+,
+,
+;
+   #dma-cells = <1>;
+   dma-channels = <10>;
+   dma-requests = <44>;
+   clocks = <&cmu CLK_DMAC>;
+   power-domains = <&sps S700_PD_DMA>;
+   };
};
 };
diff --git a/include/dt-bindings/power/owl-s700-powergate.h 
b/include/dt-bindings/power/owl-s700-powergate.h
new file mode 100644
index ..4cf1aefbf09c
--- /dev/null
+++ b/include/dt-bindings/power/owl-s700-powergate.h
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Actions Semi S700 SPS
+ *
+ * Copyright (c) 2017 Andreas Färber
+ */
+#ifndef DT_BINDINGS_POWER_OWL_S700_POWERGATE_H
+#define DT_BINDINGS_POWER_OWL_S700_POWERGATE_H
+
+#define S700_PD_VDE0
+#define S700_PD_VCE_SI 1
+#define S700_PD_USB2_1 2
+#define S700_PD_HDE3
+#define S700_PD_DMA4
+#define S700_PD_DS 5
+#define S700_PD_USB3   6
+#define S700_PD_USB2_0 7
+
+#endif
-- 
2.27.0



[PATCH v4 5/6] mmc: actions: add MMC driver for Actions OWL S700/S900

2021-11-28 Thread Amit Singh Tomar
From: Amit Singh Tomar 

This commit adds support for MMC controllers found on Actions OWL
SoC platform(S700/S900).

Signed-off-by: Amit Singh Tomar 
---
Changes since v3:
* Re-based to latest master (2ad8d0cb950da)

  There are some "dm: treewide" changes have been
  made since v3, for instance:
  
  dm: treewide: Rename ofdata_to_platdata() to of_to_plat()
  
  It is addressed in v4 for this MMC driver.

* Used setbits_le32( wherever possible.
* Properly write the OWL_REG_SD_BUF_SIZE register.
* Updated the mode handling as suggested by Ander:
  mode = 0;
  if (cmd->resp_type != MMC_RSP_NONE)
  cmd_rsp_mask = OWL_SD_STATE_CLNR | OWL_SD_STATE_CRC7ER;

  if (md->resp_type == MMC_RSP_R1) {
   (always assign to "mode")
* Properly handled the unsupported SD clock rate.
* Wait for DMA transfer to complete before stoping the DMA.
Changes since v2:
* Progammed read/write delays as suggested by
  Jaehoon, its more readable now.
* Updated commit message and source file to reflect
  it supports S900 as well.
* Updated SD_DMA_CHANNEL macro to include channel offset.
* Checked the command response Error based on SDC STATU register
  bits.
* Replaced switch/case with if/else to correlate with MMC_RSP_Rx bitmask
  values, as suggested by Andre.
* Introduced clk_disable based on mmc->clk_disable flag.
* Guarded the clk_set_rate under if statment to avoid reprogramming the
  rate.
* Fetched the DRQ number from using args.args[0].
Changes since previous version
* Corrected block count to 512.
* Changed the command timeout value to 30ms.
* Used readl_poll_timeout.
* Read DMA parameters from DT instead of hardcoding it.
* Reduced number of arguments passed to own_dma_cofig.
* Removed debug leftover.
* Used mmc_of_parse().
---
 drivers/mmc/Kconfig   |   7 +
 drivers/mmc/Makefile  |   1 +
 drivers/mmc/owl_mmc.c | 408 ++
 3 files changed, 416 insertions(+)
 create mode 100644 drivers/mmc/owl_mmc.c

diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index e0927ce1c9bd..f04cc44e1973 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -295,6 +295,13 @@ config MMC_MXC
 
  If unsure, say N.
 
+config MMC_OWL
+   bool "Actions OWL Multimedia Card Interface support"
+   depends on ARCH_OWL && DM_MMC && BLK
+   help
+ This selects the OWL SD/MMC host controller found on board
+ based on Actions S700/S900 SoC.
+
 config MMC_MXS
bool "Freescale MXS Multimedia Card Interface support"
depends on MX23 || MX28 || MX6 || MX7
diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile
index 7e819d2b3a25..17ebc04203ed 100644
--- a/drivers/mmc/Makefile
+++ b/drivers/mmc/Makefile
@@ -39,6 +39,7 @@ obj-$(CONFIG_MMC_OMAP_HS) += omap_hsmmc.o
 obj-$(CONFIG_MMC_MXC)  += mxcmmc.o
 obj-$(CONFIG_MMC_MXS)  += mxsmmc.o
 obj-$(CONFIG_MMC_OCTEONTX) += octeontx_hsmmc.o
+obj-$(CONFIG_MMC_OWL)  += owl_mmc.o
 obj-$(CONFIG_MMC_PCI)  += pci_mmc.o
 obj-$(CONFIG_PXA_MMC_GENERIC) += pxa_mmc_gen.o
 obj-$(CONFIG_$(SPL_TPL_)SUPPORT_EMMC_RPMB) += rpmb.o
diff --git a/drivers/mmc/owl_mmc.c b/drivers/mmc/owl_mmc.c
new file mode 100644
index ..e84171a661a7
--- /dev/null
+++ b/drivers/mmc/owl_mmc.c
@@ -0,0 +1,408 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2020 Amit Singh Tomar 
+ *
+ * Driver for SD/MMC controller present on Actions Semi S700/S900 SoC, based
+ * on Linux Driver "drivers/mmc/host/owl-mmc.c".
+ *
+ * Though, there is a bit (BSEL, BUS or DMA Special Channel Selection) that
+ * controls the data transfer from SDx_DAT register either using CPU AHB Bus
+ * or DMA channel, but seems like, it only works correctly using external DMA
+ * channel, and those special bits used in this driver is picked from vendor
+ * source exclusively for MMC/SD.
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * SDC registers
+ */
+#define OWL_REG_SD_EN  0x
+#define OWL_REG_SD_CTL 0x0004
+#define OWL_REG_SD_STATE   0x0008
+#define OWL_REG_SD_CMD 0x000c
+#define OWL_REG_SD_ARG 0x0010
+#define OWL_REG_SD_RSPBUF0 0x0014
+#define OWL_REG_SD_RSPBUF1 0x0018
+#define OWL_REG_SD_RSPBUF2 0x001c
+#define OWL_REG_SD_RSPBUF3 0x0020
+#define OWL_REG_SD_RSPBUF4 0x0024
+#define OWL_REG_SD_DAT 0x0028
+#define OWL_REG_SD_BLK_SIZE0x002c

[PATCH v4 6/6] configs: Enable mmc support

2021-11-28 Thread Amit Singh Tomar
From: Amit Singh Tomar 

This commits enables mmc on the Actions Cubieboard7 board.

Signed-off-by: Amit Singh Tomar 
---
Changes since previous versions
* No change.
---
 configs/cubieboard7_defconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/configs/cubieboard7_defconfig b/configs/cubieboard7_defconfig
index 2937a54d1195..536b023a3eec 100644
--- a/configs/cubieboard7_defconfig
+++ b/configs/cubieboard7_defconfig
@@ -16,3 +16,6 @@ CONFIG_PHY_REALTEK=y
 CONFIG_RTL8201F_PHY_S700_RMII_TIMINGS=y
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_ETH_DESIGNWARE_S700=y
+CONFIG_DM_MMC=y
+CONFIG_MMC_OWL=y
+CONFIG_CMD_MMC=y
-- 
2.27.0



[PATCH v4 4/6] ARM: dts: s700: add MMC/SD controller node

2021-11-28 Thread Amit Singh Tomar
From: Amit Singh Tomar 

This patch adds node for mmc/sd controller found on Action Semi OWL
S700 SoC.

Since, upstream Linux binding has not been merged for S700 MMC/SD
controller, Changes are put in u-boot specific dtsi file.

Signed-off-by: Amit Singh Tomar 
---
Changes since previous versions
* No change.
---
 arch/arm/dts/s700-u-boot.dtsi | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/arch/arm/dts/s700-u-boot.dtsi b/arch/arm/dts/s700-u-boot.dtsi
index 1b2768272c62..3c3396bccf11 100644
--- a/arch/arm/dts/s700-u-boot.dtsi
+++ b/arch/arm/dts/s700-u-boot.dtsi
@@ -19,6 +19,16 @@
status = "okay";
 };
 
+   mmc0: mmc@e021 {
+   compatible = "actions,s700-mmc", "actions,owl-mmc";
+   reg = <0x0 0xe021 0x0 0x4000>;
+   interrupts = ;
+   clocks = <&cmu CLK_SD0>;
+   dmas = <&dma 2>;
+   dma-names = "mmc";
+   bus-width = <4>;
+   status = "okay";
+   };
};
 };
 
-- 
2.27.0



[PATCH v4 3/6] ARM: dts: sync Actions Semi S700 DT from Linux 5.10-rc7

2021-11-28 Thread Amit Singh Tomar
From: Amit Singh Tomar 

This Synchronizes the Actions Semi S700 SoC DT changes from
commit "0477e9288185" ("Linux 5.10-rc7").

Signed-off-by: Amit Singh Tomar 
---
Changes since previous versions
* No change.
---
 arch/arm/dts/s700.dtsi| 17 -
 .../dt-bindings/power/owl-s700-powergate.h| 19 +++
 2 files changed, 35 insertions(+), 1 deletion(-)
 create mode 100644 include/dt-bindings/power/owl-s700-powergate.h

diff --git a/arch/arm/dts/s700.dtsi b/arch/arm/dts/s700.dtsi
index 2006ad5424fa..2c78caebf515 100644
--- a/arch/arm/dts/s700.dtsi
+++ b/arch/arm/dts/s700.dtsi
@@ -5,6 +5,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 / {
@@ -231,7 +232,7 @@
 
pinctrl: pinctrl@e01b {
compatible = "actions,s700-pinctrl";
-   reg = <0x0 0xe01b 0x0 0x1000>;
+   reg = <0x0 0xe01b 0x0 0x100>;
clocks = <&cmu CLK_GPIO>;
gpio-controller;
gpio-ranges = <&pinctrl 0 0 136>;
@@ -244,5 +245,19 @@
 ,
 ;
};
+
+   dma: dma-controller@e023 {
+   compatible = "actions,s700-dma";
+   reg = <0x0 0xe023 0x0 0x1000>;
+   interrupts = ,
+,
+,
+;
+   #dma-cells = <1>;
+   dma-channels = <10>;
+   dma-requests = <44>;
+   clocks = <&cmu CLK_DMAC>;
+   power-domains = <&sps S700_PD_DMA>;
+   };
};
 };
diff --git a/include/dt-bindings/power/owl-s700-powergate.h 
b/include/dt-bindings/power/owl-s700-powergate.h
new file mode 100644
index ..4cf1aefbf09c
--- /dev/null
+++ b/include/dt-bindings/power/owl-s700-powergate.h
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Actions Semi S700 SPS
+ *
+ * Copyright (c) 2017 Andreas Färber
+ */
+#ifndef DT_BINDINGS_POWER_OWL_S700_POWERGATE_H
+#define DT_BINDINGS_POWER_OWL_S700_POWERGATE_H
+
+#define S700_PD_VDE0
+#define S700_PD_VCE_SI 1
+#define S700_PD_USB2_1 2
+#define S700_PD_HDE3
+#define S700_PD_DMA4
+#define S700_PD_DS 5
+#define S700_PD_USB3   6
+#define S700_PD_USB2_0 7
+
+#endif
-- 
2.27.0



[PATCH v4 2/6] clk: actions: Add SD/MMC clocks

2021-11-28 Thread Amit Singh Tomar
From: Amit Singh Tomar 

This commit adds SD/MMC clocks, and provides .set/get_rate callbacks
for SD/MMC device present on Actions OWL S700 SoCs.

Signed-off-by: Amit Singh Tomar 
---
Changes since v3:
* No change.
Changes since v2:
* Fixed the weird div assignment.
* Moved the clock bit for SD from header file
  to driver file.
* Removed "< 0" part while comparing unsigned.
Changes since previous version:
* Removed rate *= 2 as this just overclocks.
* Separated the divide by 128 bit from divider value.
* Provided the separate routine to get sd parent rate
  based on bit 9.
* Removed unnecessary initialization.
---
 drivers/clk/owl/clk_owl.c | 73 +++
 1 file changed, 73 insertions(+)

diff --git a/drivers/clk/owl/clk_owl.c b/drivers/clk/owl/clk_owl.c
index f78e5fa3f08d..678fdd5a4540 100644
--- a/drivers/clk/owl/clk_owl.c
+++ b/drivers/clk/owl/clk_owl.c
@@ -20,6 +20,8 @@
 #include 
 #include 
 
+#define CMU_DEVCLKEN0_SD0  BIT(22)
+
 void owl_clk_init(struct owl_clk_priv *priv)
 {
u32 bus_clk = 0, core_pll, dev_pll;
@@ -92,6 +94,9 @@ int owl_clk_enable(struct clk *clk)
setbits_le32(priv->base + CMU_DEVCLKEN1, CMU_DEVCLKEN1_ETH);
setbits_le32(priv->base + CMU_ETHERNETPLL, 5);
break;
+   case CLK_SD0:
+   setbits_le32(priv->base + CMU_DEVCLKEN0, CMU_DEVCLKEN0_SD0);
+   break;
default:
return -EINVAL;
}
@@ -121,6 +126,9 @@ int owl_clk_disable(struct clk *clk)
case CLK_ETHERNET:
clrbits_le32(priv->base + CMU_DEVCLKEN1, CMU_DEVCLKEN1_ETH);
break;
+   case CLK_SD0:
+   clrbits_le32(priv->base + CMU_DEVCLKEN0, CMU_DEVCLKEN0_SD0);
+   break;
default:
return -EINVAL;
}
@@ -128,11 +136,72 @@ int owl_clk_disable(struct clk *clk)
return 0;
 }
 
+static ulong get_sd_parent_rate(struct owl_clk_priv *priv, u32 dev_index)
+{
+   ulong rate;
+   u32 reg;
+
+   reg = readl(priv->base + (CMU_SD0CLK + dev_index * 0x4));
+   /* Clock output of DEV/NAND_PLL
+* Range: 48M ~ 756M
+* Frequency= PLLCLK * 6
+*/
+   if (reg & 0x200)
+   rate = readl(priv->base + CMU_NANDPLL) & 0x7f;
+   else
+   rate = readl(priv->base + CMU_DEVPLL) & 0x7f;
+
+   rate *= 600;
+
+   return rate;
+}
+
+static ulong owl_get_sd_clk_rate(struct owl_clk_priv *priv, int sd_index)
+{
+   uint div, val;
+   ulong parent_rate = get_sd_parent_rate(priv, sd_index);
+
+   val = readl(priv->base + (CMU_SD0CLK + sd_index * 0x4));
+   div = (val & 0x1f) + 1;
+
+   return (parent_rate / div);
+}
+
+static ulong owl_set_sd_clk_rate(struct owl_clk_priv *priv, ulong rate,
+int sd_index)
+{
+   uint div, val;
+   ulong parent_rate = get_sd_parent_rate(priv, sd_index);
+
+   if (rate == 0)
+   return rate;
+
+   div = (parent_rate / rate);
+
+   val = readl(priv->base + (CMU_SD0CLK + sd_index * 0x4));
+   /* Bits 4..0 is used to program div value and bit 8 to enable
+* divide by 128 circuit
+*/
+   val &= ~0x11f;
+   if (div >= 128) {
+   div = div / 128;
+   val |= 0x100; /* enable divide by 128 circuit */
+   }
+   val |= ((div - 1) & 0x1f);
+   writel(val, priv->base + (CMU_SD0CLK + sd_index * 0x4));
+
+   return owl_get_sd_clk_rate(priv, 0);
+}
+
 static ulong owl_clk_get_rate(struct clk *clk)
 {
+   struct owl_clk_priv *priv = dev_get_priv(clk->dev);
ulong rate;
 
switch (clk->id) {
+   case CLK_SD0:
+   rate = owl_get_sd_clk_rate(priv, 0);
+   break;
default:
return -ENOENT;
}
@@ -142,9 +211,13 @@ static ulong owl_clk_get_rate(struct clk *clk)
 
 static ulong owl_clk_set_rate(struct clk *clk, ulong rate)
 {
+   struct owl_clk_priv *priv = dev_get_priv(clk->dev);
ulong new_rate;
 
switch (clk->id) {
+   case CLK_SD0:
+   new_rate = owl_set_sd_clk_rate(priv, rate, 0);
+   break;
default:
return -ENOENT;
}
-- 
2.27.0



[PATCH v4 1/6] clk: actions: Introduce dummy get/set_rate callbacks

2021-11-28 Thread Amit Singh Tomar
From: Amit Singh Tomar 

This commit introduces get/set_rate callbacks, these are dummy at
the moment, and can be used to get/set clock for various devices
based on the clk id.

Signed-off-by: Amit Singh Tomar 
---
Changes since v3:
* No changes.
Changes since v2:
* No changes.
Changes since previous version:
* Removed premature initialization to avoid
  compiler warnings.
---
 drivers/clk/owl/clk_owl.c | 26 ++
 1 file changed, 26 insertions(+)

diff --git a/drivers/clk/owl/clk_owl.c b/drivers/clk/owl/clk_owl.c
index 96ab7fed1f37..f78e5fa3f08d 100644
--- a/drivers/clk/owl/clk_owl.c
+++ b/drivers/clk/owl/clk_owl.c
@@ -128,6 +128,30 @@ int owl_clk_disable(struct clk *clk)
return 0;
 }
 
+static ulong owl_clk_get_rate(struct clk *clk)
+{
+   ulong rate;
+
+   switch (clk->id) {
+   default:
+   return -ENOENT;
+   }
+
+   return rate;
+}
+
+static ulong owl_clk_set_rate(struct clk *clk, ulong rate)
+{
+   ulong new_rate;
+
+   switch (clk->id) {
+   default:
+   return -ENOENT;
+   }
+
+   return new_rate;
+}
+
 static int owl_clk_probe(struct udevice *dev)
 {
struct owl_clk_priv *priv = dev_get_priv(dev);
@@ -145,6 +169,8 @@ static int owl_clk_probe(struct udevice *dev)
 static const struct clk_ops owl_clk_ops = {
.enable = owl_clk_enable,
.disable = owl_clk_disable,
+   .get_rate = owl_clk_get_rate,
+   .set_rate = owl_clk_set_rate,
 };
 
 static const struct udevice_id owl_clk_ids[] = {
-- 
2.27.0



[PATCH v4 0/6] Add MMC/SD support for S700/S900

2021-11-28 Thread Amit Singh Tomar
Hi,

Sorry, it took me some time to come up with v4. For v3, all the
comments are from MMC driver(patch 5/6), and tried to address in 
this series(v4) with changelog mentioned in the patch (5/6)
itself.


This series(v3) addresses review comments provided by Andre and Jaehoon. Earlier
in MMC driver, we were *not* checking the command response errors(for instance,
the CRC error) based on STATU register. This is now addressed in patch 5/6.

Also, MMC driver(patch 5/6) now has replaced the switch/case with if/else to
correlate MMC_RSP_Rx bitmask values with register bits as suggested by Andre.

Apart from it, there are changes in patch 2/6 to fix weird assignments to div
variable.

--
Series(v2) has few important updates, while loading large files we found
that MMC framework puts "0x1fffe00" into DMA Frame Length(DMA_FRAME_LEN 0x000C)
but register itself is limited to 24 bits and hence it was failing.
It is due to the wrong Block count(cfg->b_max) used in driver, that should be
just 512. This is now fixed in patch 5/6.

Apart from it, as Andre pointed that we might be just overclocking the MMC/SD
clock, and to confirm this we run following test:

$ md5sum clang
349eac46cbbe28f8e44da2dce07fa7b7  clang

U-Boot => ext4load mmc 0:2 0x0 clang
503316480 bytes read in 19516 ms (24.6 MiB/s)
U-Boot => md5sum 0x0 0x1e00
md5 for  ... 1dff ==> d793bb51c4a1cf83c96d1980927461ff

Even though file gets loaded but md5sum doesn't match. This is now fixed in
patch 2/6

U-Boot => ext4load mmc 0:2 0x0 clang
503316480 bytes read in 41524 ms (11.6 MiB/s)
U-Boot => md5sum 0x0 0x1e00
md5 for  ... 1dff ==> 349eac46cbbe28f8e44da2dce07fa7b7

-
At the moment on S700 based platforms, only way to load/boot the Kernel
is from Ethernet, and with these patches one can now load/boot the
Kernel from uSD card.

Patches(1/6 and 2/6) adds changes needed for MMC/SD clock. It introduces
set/get callback routine and get/set MMC/SD clock rate based on device id.

Patch 4/6 adds MMC/SD node in U-boot specific dtsi file, which is used by MMC/SD
driver to read controller base address later on.

Patch 5/6 adds driver for MMC/SD controller present on S700 SoC, and its based
on Mainline Linux driver and DMA related bits is picked and simpilified from
vendor source.

Final patch 6/6 enables the driver support along with MMC commands in
Cubieboard7 config file.

Also, while at it just took the opportunity to synchronize the S700 SoC DT with
Linux in patch 3/6.

This patch-set is tested on Cubieboard7-lite board with following results:

U-Boot 2021.01-rc1-04434-g6589149-dirty (Dec 13 2020 - 13:51:07 +0530)
cubieboard7

DRAM:  1 GiB
PSCI:  v0.2
MMC:   mmc@e021: 0
In:serial@e0126000
Out:   serial@e0126000
Err:   serial@e0126000
Net:   eth0: ethernet@e022
Hit any key to stop autoboot:  0
U-Boot =>
U-Boot =>
U-Boot =>
U-Boot => mmc info
Device: mmc@e021
Manufacturer ID: 3
OEM: 5344
Name: SC16G
Bus Speed: 5000
Mode: SD High Speed (50MHz)
Rd Block Len: 512
SD version 3.0
High Capacity: Yes
Capacity: 14.8 GiB
Bus Width: 4-bit
Erase Group Size: 512 Bytes
U-Boot => setenv bootargs console=ttyOWL3,115200n8 earlycon=owl,0xe0126000 
init=/sbin/init  root=/dev/mmcblk0p2 rw rootwait
U-Boot => setenv kernel_addr_r 0x8;setenv fdt_addr_r 0x1000;
U-Boot => fatload mmc 0:1 ${kernel_addr_r} image ;fatload mmc 0:1 ${fdt_addr_r} 
s700-cubieboard7.dtb
27480576 bytes read in 1041 ms (25.2 MiB/s)
7056 bytes read in 2 ms (3.4 MiB/s)
U-Boot => booti $kernel_addr_r - $fdt_addr_r
## Flattened Device Tree blob at 1000
   Booting using the fdt blob at 0x1000
   Loading Device Tree to 3df56000, end 3df5ab8f ... OK

Starting kernel ...

[0.00] Booting Linux on physical CPU 0x00 [0x410fd034]
[0.00] Linux version 5.7.0-rc6-00022-g99f1c330923b-dirty 
(amit@amit-ThinkPad-X230) (gcc version 7.3.1 20180425 [linaro-7.3-2018.05 
revision d29120a424ecfbc167ef90065c0eeb7f91977701] (Linaro GCC 7.3-2018.05), 
GNU ld (GNU Binutils for Ubuntu) 2.26.1) #474 SMP PREEMPT Thu Aug 13 15:27:10 
IST 2020
[0.00] Machine model: CubieBoard7
[0.00] earlycon: owl0 at MMIO 0xe0126000 (options '')
[0.00] printk: bootconsole [owl0] enabled
[0.00] efi: UEFI not found.
[0.00] cma: Reserved 32 MiB at 0x3e00

Amit Singh Tomar (6):
  clk: actions: Introduce dummy get/set_rate callbacks
  clk: actions: Add SD/MMC clocks
  ARM: dts: sync Actions Semi S700 DT from Linux 5.10-rc7
  ARM: dts: s700: add MMC/SD controller node
  mmc: actions: add MMC driver for Actions OWL S700/S900
  configs: Enable mmc support

 arch/arm/dts/s700-u-boot.dtsi |  10 +
 arch/arm/dts/s7

[PATCH v3 5/6] mmc: actions: add MMC driver for Actions OWL S700/S900

2021-01-16 Thread Amit Singh Tomar
From: Amit Singh Tomar 

This commit adds support for MMC controllers found on Actions OWL
SoC platform(S700/S900).

Signed-off-by: Amit Singh Tomar 
---
Changes since v2:
* Progammed read/write delays as suggested by
  Jaehoon, its more readable now.
* Updated commit message and source file to reflect
  it supports S900 as well.
* Updated SD_DMA_CHANNEL macro to include channel offset.
* Checked the command response Error based on SDC STATU register
  bits.
* Replaced switch/case with if/else to correlate with MMC_RSP_Rx bitmask
  values, as suggested by Andre.
* Introduced clk_disable based on mmc->clk_disable flag.
* Guarded the clk_set_rate under if statment to avoid reprogramming the
  rate.
* Fetched the DRQ number from using args.args[0].
Changes since previous version
* Corrected block count to 512.
* Changed the command timeout value to 30ms.
* Used readl_poll_timeout.
* Read DMA parameters from DT instead of hardcoding it.
* Reduced number of arguments passed to own_dma_cofig.
* Removed debug leftover.
* Used mmc_of_parse().
---
 drivers/mmc/Kconfig   |   7 +
 drivers/mmc/Makefile  |   1 +
 drivers/mmc/owl_mmc.c | 401 ++
 3 files changed, 409 insertions(+)
 create mode 100644 drivers/mmc/owl_mmc.c

diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index 14d7913..3478a4e 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -289,6 +289,13 @@ config MMC_MXC
 
  If unsure, say N.
 
+config MMC_OWL
+   bool "Actions OWL Multimedia Card Interface support"
+   depends on ARCH_OWL && DM_MMC && BLK
+   help
+ This selects the OWL SD/MMC host controller found on board
+ based on Actions S700/S900 SoC.
+
 config MMC_MXS
bool "Freescale MXS Multimedia Card Interface support"
depends on MX23 || MX28 || MX6 || MX7
diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile
index 1c849cb..f270f6c 100644
--- a/drivers/mmc/Makefile
+++ b/drivers/mmc/Makefile
@@ -38,6 +38,7 @@ obj-$(CONFIG_MMC_OMAP_HS) += omap_hsmmc.o
 obj-$(CONFIG_MMC_MXC)  += mxcmmc.o
 obj-$(CONFIG_MMC_MXS)  += mxsmmc.o
 obj-$(CONFIG_MMC_OCTEONTX) += octeontx_hsmmc.o
+obj-$(CONFIG_MMC_OWL)  += owl_mmc.o
 obj-$(CONFIG_MMC_PCI)  += pci_mmc.o
 obj-$(CONFIG_PXA_MMC_GENERIC) += pxa_mmc_gen.o
 obj-$(CONFIG_$(SPL_TPL_)SUPPORT_EMMC_RPMB) += rpmb.o
diff --git a/drivers/mmc/owl_mmc.c b/drivers/mmc/owl_mmc.c
new file mode 100644
index 000..de52583
--- /dev/null
+++ b/drivers/mmc/owl_mmc.c
@@ -0,0 +1,401 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2020 Amit Singh Tomar 
+ *
+ * Driver for SD/MMC controller present on Actions Semi S700/S900 SoC, based
+ * on Linux Driver "drivers/mmc/host/owl-mmc.c".
+ *
+ * Though, there is a bit (BSEL, BUS or DMA Special Channel Selection) that
+ * controls the data transfer from SDx_DAT register either using CPU AHB Bus
+ * or DMA channel, but seems like, it only works correctly using external DMA
+ * channel, and those special bits used in this driver is picked from vendor
+ * source exclusively for MMC/SD.
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * SDC registers
+ */
+#define OWL_REG_SD_EN  0x
+#define OWL_REG_SD_CTL 0x0004
+#define OWL_REG_SD_STATE   0x0008
+#define OWL_REG_SD_CMD 0x000c
+#define OWL_REG_SD_ARG 0x0010
+#define OWL_REG_SD_RSPBUF0 0x0014
+#define OWL_REG_SD_RSPBUF1 0x0018
+#define OWL_REG_SD_RSPBUF2 0x001c
+#define OWL_REG_SD_RSPBUF3 0x0020
+#define OWL_REG_SD_RSPBUF4 0x0024
+#define OWL_REG_SD_DAT 0x0028
+#define OWL_REG_SD_BLK_SIZE0x002c
+#define OWL_REG_SD_BLK_NUM 0x0030
+#define OWL_REG_SD_BUF_SIZE0x0034
+
+/* SD_EN Bits */
+#define OWL_SD_EN_RANE BIT(31)
+#define OWL_SD_EN_RESE BIT(10)
+#define OWL_SD_ENABLE  BIT(7)
+#define OWL_SD_EN_BSEL BIT(6)
+#define OWL_SD_EN_DATAWID(x)   (((x) & 0x3) << 0)
+#define OWL_SD_EN_DATAWID_MASK 0x03
+
+/* SD_CTL Bits */
+#define OWL_SD_CTL_TOUTEN  BIT(31)
+#define OWL_SD_CTL_DELAY_MSK   GENMASK(23, 16)
+#define OWL_SD_CTL_RDELAY(x)   (((x) & 0xf) << 20)
+#define OWL_SD_CTL_WDELAY(x)   (((x) & 0xf) << 16)
+#define OWL_SD_CTL_TS  BIT(7)
+#define OWL_SD_CTL_LBE BIT(6)
+#define OWL_SD_CTL_TM(x)   (((x) & 0xf) << 0)
+
+#define OWL_SD_DELAY_LOW_CL

[PATCH v3 6/6] configs: Enable mmc support

2021-01-16 Thread Amit Singh Tomar
From: Amit Singh Tomar 

This commits enables mmc on the Actions Cubieboard7 board.

Signed-off-by: Amit Singh Tomar 
---
Changes since previous versions
* No change.
---
 configs/cubieboard7_defconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/configs/cubieboard7_defconfig b/configs/cubieboard7_defconfig
index 64dc593..d1ee862 100644
--- a/configs/cubieboard7_defconfig
+++ b/configs/cubieboard7_defconfig
@@ -14,3 +14,6 @@ CONFIG_PHY_REALTEK=y
 CONFIG_RTL8201F_PHY_S700_RMII_TIMINGS=y
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_ETH_DESIGNWARE_S700=y
+CONFIG_DM_MMC=y
+CONFIG_MMC_OWL=y
+CONFIG_CMD_MMC=y
-- 
2.7.4



[PATCH v3 4/6] ARM: dts: s700: add MMC/SD controller node

2021-01-16 Thread Amit Singh Tomar
From: Amit Singh Tomar 

This patch adds node for mmc/sd controller found on Action Semi OWL
S700 SoC.

Since, upstream Linux binding has not been merged for S700 MMC/SD
controller, Changes are put in u-boot specific dtsi file.

Signed-off-by: Amit Singh Tomar 
---
Changes since previous versions
* No change.
---
 arch/arm/dts/s700-u-boot.dtsi | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/arch/arm/dts/s700-u-boot.dtsi b/arch/arm/dts/s700-u-boot.dtsi
index 1b27682..3c3396b 100644
--- a/arch/arm/dts/s700-u-boot.dtsi
+++ b/arch/arm/dts/s700-u-boot.dtsi
@@ -19,6 +19,16 @@
status = "okay";
 };
 
+   mmc0: mmc@e021 {
+   compatible = "actions,s700-mmc", "actions,owl-mmc";
+   reg = <0x0 0xe021 0x0 0x4000>;
+   interrupts = ;
+   clocks = <&cmu CLK_SD0>;
+   dmas = <&dma 2>;
+   dma-names = "mmc";
+   bus-width = <4>;
+   status = "okay";
+   };
};
 };
 
-- 
2.7.4



[PATCH v3 3/6] ARM: dts: sync Actions Semi S700 DT from Linux 5.10-rc7

2021-01-16 Thread Amit Singh Tomar
From: Amit Singh Tomar 

This Synchronizes the Actions Semi S700 SoC DT changes from
commit "0477e9288185" ("Linux 5.10-rc7").

Signed-off-by: Amit Singh Tomar 
---
Changes since previous versions
* No change.
---
 arch/arm/dts/s700.dtsi | 17 -
 include/dt-bindings/power/owl-s700-powergate.h | 19 +++
 2 files changed, 35 insertions(+), 1 deletion(-)
 create mode 100644 include/dt-bindings/power/owl-s700-powergate.h

diff --git a/arch/arm/dts/s700.dtsi b/arch/arm/dts/s700.dtsi
index 2006ad5..2c78cae 100644
--- a/arch/arm/dts/s700.dtsi
+++ b/arch/arm/dts/s700.dtsi
@@ -5,6 +5,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 / {
@@ -231,7 +232,7 @@
 
pinctrl: pinctrl@e01b {
compatible = "actions,s700-pinctrl";
-   reg = <0x0 0xe01b 0x0 0x1000>;
+   reg = <0x0 0xe01b 0x0 0x100>;
clocks = <&cmu CLK_GPIO>;
gpio-controller;
gpio-ranges = <&pinctrl 0 0 136>;
@@ -244,5 +245,19 @@
 ,
 ;
};
+
+   dma: dma-controller@e023 {
+   compatible = "actions,s700-dma";
+   reg = <0x0 0xe023 0x0 0x1000>;
+   interrupts = ,
+,
+,
+;
+   #dma-cells = <1>;
+   dma-channels = <10>;
+   dma-requests = <44>;
+   clocks = <&cmu CLK_DMAC>;
+   power-domains = <&sps S700_PD_DMA>;
+   };
};
 };
diff --git a/include/dt-bindings/power/owl-s700-powergate.h 
b/include/dt-bindings/power/owl-s700-powergate.h
new file mode 100644
index 000..4cf1aef
--- /dev/null
+++ b/include/dt-bindings/power/owl-s700-powergate.h
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Actions Semi S700 SPS
+ *
+ * Copyright (c) 2017 Andreas Färber
+ */
+#ifndef DT_BINDINGS_POWER_OWL_S700_POWERGATE_H
+#define DT_BINDINGS_POWER_OWL_S700_POWERGATE_H
+
+#define S700_PD_VDE0
+#define S700_PD_VCE_SI 1
+#define S700_PD_USB2_1 2
+#define S700_PD_HDE3
+#define S700_PD_DMA4
+#define S700_PD_DS 5
+#define S700_PD_USB3   6
+#define S700_PD_USB2_0 7
+
+#endif
-- 
2.7.4



[PATCH v3 2/6] clk: actions: Add SD/MMC clocks

2021-01-16 Thread Amit Singh Tomar
From: Amit Singh Tomar 

This commit adds SD/MMC clocks, and provides .set/get_rate callbacks
for SD/MMC device present on Actions OWL S700 SoCs.

Signed-off-by: Amit Singh Tomar 
---
Changes since v2:
* Fixed the not weird div assignment.
* Moved the clock bit for SD from header file 
  to driver file.
* Removed "< 0" part while comparing unsigned.
Changes since previous version:
* Removed rate *= 2 as this just overclocks.
* Separated the divide by 128 bit from divider value.
* Provided the separate routine to get sd parent rate
  based on bit 9.
* Removed unnecessary initialization.
---
 drivers/clk/owl/clk_owl.c | 73 +++
 1 file changed, 73 insertions(+)

diff --git a/drivers/clk/owl/clk_owl.c b/drivers/clk/owl/clk_owl.c
index 5be1b3b..34cee7d 100644
--- a/drivers/clk/owl/clk_owl.c
+++ b/drivers/clk/owl/clk_owl.c
@@ -20,6 +20,8 @@
 #include 
 #include 
 
+#define CMU_DEVCLKEN0_SD0  BIT(22)
+
 void owl_clk_init(struct owl_clk_priv *priv)
 {
u32 bus_clk = 0, core_pll, dev_pll;
@@ -92,6 +94,9 @@ int owl_clk_enable(struct clk *clk)
setbits_le32(priv->base + CMU_DEVCLKEN1, CMU_DEVCLKEN1_ETH);
setbits_le32(priv->base + CMU_ETHERNETPLL, 5);
break;
+   case CLK_SD0:
+   setbits_le32(priv->base + CMU_DEVCLKEN0, CMU_DEVCLKEN0_SD0);
+   break;
default:
return -EINVAL;
}
@@ -121,6 +126,9 @@ int owl_clk_disable(struct clk *clk)
case CLK_ETHERNET:
clrbits_le32(priv->base + CMU_DEVCLKEN1, CMU_DEVCLKEN1_ETH);
break;
+   case CLK_SD0:
+   clrbits_le32(priv->base + CMU_DEVCLKEN0, CMU_DEVCLKEN0_SD0);
+   break;
default:
return -EINVAL;
}
@@ -128,11 +136,72 @@ int owl_clk_disable(struct clk *clk)
return 0;
 }
 
+static ulong get_sd_parent_rate(struct owl_clk_priv *priv, u32 dev_index)
+{
+   ulong rate;
+   u32 reg;
+
+   reg = readl(priv->base + (CMU_SD0CLK + dev_index * 0x4));
+   /* Clock output of DEV/NAND_PLL
+* Range: 48M ~ 756M
+* Frequency= PLLCLK * 6
+*/
+   if (reg & 0x200)
+   rate = readl(priv->base + CMU_NANDPLL) & 0x7f;
+   else
+   rate = readl(priv->base + CMU_DEVPLL) & 0x7f;
+
+   rate *= 600;
+
+   return rate;
+}
+
+static ulong owl_get_sd_clk_rate(struct owl_clk_priv *priv, int sd_index)
+{
+   uint div, val;
+   ulong parent_rate = get_sd_parent_rate(priv, sd_index);
+
+   val = readl(priv->base + (CMU_SD0CLK + sd_index * 0x4));
+   div = (val & 0x1f) + 1;
+
+   return (parent_rate / div);
+}
+
+static ulong owl_set_sd_clk_rate(struct owl_clk_priv *priv, ulong rate,
+int sd_index)
+{
+   uint div, val;
+   ulong parent_rate = get_sd_parent_rate(priv, sd_index);
+
+   if (rate == 0)
+   return rate;
+
+   div = (parent_rate / rate);
+
+   val = readl(priv->base + (CMU_SD0CLK + sd_index * 0x4));
+   /* Bits 4..0 is used to program div value and bit 8 to enable
+* divide by 128 circuit
+*/
+   val &= ~0x11f;
+   if (div >= 128) {
+   div = div / 128;
+   val |= 0x100; /* enable divide by 128 circuit */
+   }
+   val |= ((div - 1) & 0x1f);
+   writel(val, priv->base + (CMU_SD0CLK + sd_index * 0x4));
+
+   return owl_get_sd_clk_rate(priv, 0);
+}
+
 static ulong owl_clk_get_rate(struct clk *clk)
 {
+   struct owl_clk_priv *priv = dev_get_priv(clk->dev);
ulong rate;
 
switch (clk->id) {
+   case CLK_SD0:
+   rate = owl_get_sd_clk_rate(priv, 0);
+   break;
default:
return -ENOENT;
}
@@ -142,9 +211,13 @@ static ulong owl_clk_get_rate(struct clk *clk)
 
 static ulong owl_clk_set_rate(struct clk *clk, ulong rate)
 {
+   struct owl_clk_priv *priv = dev_get_priv(clk->dev);
ulong new_rate;
 
switch (clk->id) {
+   case CLK_SD0:
+   new_rate = owl_set_sd_clk_rate(priv, rate, 0);
+   break;
default:
return -ENOENT;
}
-- 
2.7.4



[PATCH v3 1/6] clk: actions: Introduce dummy get/set_rate callbacks

2021-01-16 Thread Amit Singh Tomar
From: Amit Singh Tomar 

This commit introduces get/set_rate callbacks, these are dummy at
the moment, and can be used to get/set clock for various devices
based on the clk id.

Signed-off-by: Amit Singh Tomar 
---
Changes since v2:
* No changes.
Changes since previous version:
* Removed premature initialization to avoid
  compiler warnings.
---
 drivers/clk/owl/clk_owl.c | 26 ++
 1 file changed, 26 insertions(+)

diff --git a/drivers/clk/owl/clk_owl.c b/drivers/clk/owl/clk_owl.c
index 1999c87..5be1b3b 100644
--- a/drivers/clk/owl/clk_owl.c
+++ b/drivers/clk/owl/clk_owl.c
@@ -128,6 +128,30 @@ int owl_clk_disable(struct clk *clk)
return 0;
 }
 
+static ulong owl_clk_get_rate(struct clk *clk)
+{
+   ulong rate;
+
+   switch (clk->id) {
+   default:
+   return -ENOENT;
+   }
+
+   return rate;
+}
+
+static ulong owl_clk_set_rate(struct clk *clk, ulong rate)
+{
+   ulong new_rate;
+
+   switch (clk->id) {
+   default:
+   return -ENOENT;
+   }
+
+   return new_rate;
+}
+
 static int owl_clk_probe(struct udevice *dev)
 {
struct owl_clk_priv *priv = dev_get_priv(dev);
@@ -145,6 +169,8 @@ static int owl_clk_probe(struct udevice *dev)
 static const struct clk_ops owl_clk_ops = {
.enable = owl_clk_enable,
.disable = owl_clk_disable,
+   .get_rate = owl_clk_get_rate,
+   .set_rate = owl_clk_set_rate,
 };
 
 static const struct udevice_id owl_clk_ids[] = {
-- 
2.7.4



[PATCH v3 0/6] Add MMC/SD support for S700/S900

2021-01-16 Thread Amit Singh Tomar
From: Amit Singh Tomar 

This series(v3) addresses review comments provided by Andre and Jaehoon. Earlier
in MMC driver, we were *not* checking the command response errors(for instance,
the CRC error) based on STATU register. This is now addressed in patch 5/6.

Also, MMC driver(pacth 5/6) now has replaced the switch/case with if/else to 
correlate MMC_RSP_Rx bitmask values with register bits as suggested by Andre.

Apart from it, there are changes in patch 2/6 to fix weird assignments to div
variable.

--
Series(v2) has few important updates, while loading large files we found
that MMC framework puts "0x1fffe00" into DMA Frame Length(DMA_FRAME_LEN 0x000C)
but register itself is limited to 24 bits and hence it was failing.
It is due to the wrong Block count(cfg->b_max) used in driver, that should be
just 512. This is now fixed in patch 5/6.

Apart from it, as Andre pointed that we might be just overclocking the MMC/SD
clock, and to confirm this we run following test:

$ md5sum clang 
349eac46cbbe28f8e44da2dce07fa7b7  clang

U-Boot => ext4load mmc 0:2 0x0 clang
503316480 bytes read in 19516 ms (24.6 MiB/s)
U-Boot => md5sum 0x0 0x1e00
md5 for  ... 1dff ==> d793bb51c4a1cf83c96d1980927461ff

Even though file gets loaded but md5sum doesn't match. This is now fixed in
patch 2/6

U-Boot => ext4load mmc 0:2 0x0 clang
503316480 bytes read in 41524 ms (11.6 MiB/s)
U-Boot => md5sum 0x0 0x1e00
md5 for  ... 1dff ==> 349eac46cbbe28f8e44da2dce07fa7b7

-
At the moment on S700 based platforms, only way to load/boot the Kernel
is from Ethernet, and with these patches one can now load/boot the
Kernel from uSD card.

Patches(1/6 and 2/6) adds changes needed for MMC/SD clock. It introduces
set/get callback routine and get/set MMC/SD clock rate based on device id.

Patch 4/6 adds MMC/SD node in U-boot specific dtsi file, which is used by MMC/SD
driver to read controller base address later on.

Patch 5/6 adds driver for MMC/SD controller present on S700 SoC, and its based
on Mainline Linux driver and DMA related bits is picked and simpilified from 
vendor source.

Final patch 6/6 enables the driver support along with MMC commands in
Cubieboard7 config file.

Also, while at it just took the opportunity to synchronize the S700 SoC DT with
Linux in patch 3/6.

This patch-set is tested on Cubieboard7-lite board with following results:

U-Boot 2021.01-rc1-04434-g6589149-dirty (Dec 13 2020 - 13:51:07 +0530)
cubieboard7

DRAM:  1 GiB
PSCI:  v0.2
MMC:   mmc@e021: 0
In:serial@e0126000
Out:   serial@e0126000
Err:   serial@e0126000
Net:   eth0: ethernet@e022
Hit any key to stop autoboot:  0 
U-Boot => 
U-Boot => 
U-Boot => 
U-Boot => mmc info
Device: mmc@e021
Manufacturer ID: 3
OEM: 5344
Name: SC16G 
Bus Speed: 5000
Mode: SD High Speed (50MHz)
Rd Block Len: 512
SD version 3.0
High Capacity: Yes
Capacity: 14.8 GiB
Bus Width: 4-bit
Erase Group Size: 512 Bytes
U-Boot => setenv bootargs console=ttyOWL3,115200n8 earlycon=owl,0xe0126000 
init=/sbin/init  root=/dev/mmcblk0p2 rw rootwait
U-Boot => setenv kernel_addr_r 0x8;setenv fdt_addr_r 0x1000;
U-Boot => fatload mmc 0:1 ${kernel_addr_r} image ;fatload mmc 0:1 ${fdt_addr_r} 
s700-cubieboard7.dtb
27480576 bytes read in 1041 ms (25.2 MiB/s)
7056 bytes read in 2 ms (3.4 MiB/s)
U-Boot => booti $kernel_addr_r - $fdt_addr_r
## Flattened Device Tree blob at 1000
   Booting using the fdt blob at 0x1000
   Loading Device Tree to 3df56000, end 3df5ab8f ... OK

Starting kernel ...

[0.00] Booting Linux on physical CPU 0x00 [0x410fd034]
[0.00] Linux version 5.7.0-rc6-00022-g99f1c330923b-dirty 
(amit@amit-ThinkPad-X230) (gcc version 7.3.1 20180425 [linaro-7.3-2018.05 
revision d29120a424ecfbc167ef90065c0eeb7f91977701] (Linaro GCC 7.3-2018.05), 
GNU ld (GNU Binutils for Ubuntu) 2.26.1) #474 SMP PREEMPT Thu Aug 13 15:27:10 
IST 2020
[0.00] Machine model: CubieBoard7
[0.00] earlycon: owl0 at MMIO 0xe0126000 (options '')
[0.00] printk: bootconsole [owl0] enabled
[0.00] efi: UEFI not found.
[0.00] cma: Reserved 32 MiB at 0x3e00

Amit Singh Tomar (6):
  clk: actions: Introduce dummy get/set_rate callbacks
  clk: actions: Add SD/MMC clocks
  ARM: dts: sync Actions Semi S700 DT from Linux 5.10-rc7
  ARM: dts: s700: add MMC/SD controller node
  mmc: actions: add MMC driver for Actions OWL S700/S900
  configs: Enable mmc support

 arch/arm/dts/s700-u-boot.dtsi  |  10 +
 arch/arm/dts/s700.dtsi |  17 +-
 configs/cubieboard7_defconfig  |   3 +
 drivers/clk/owl/clk_owl.c  |  99 ++
 drivers/mmc/Kconfig|   7 +
 drivers

[PATCH v2 6/6] configs: Enable mmc support

2020-12-19 Thread Amit Singh Tomar
From: Amit Singh Tomar 

This commits enables mmc on the Actions Cubieboard7 board.

Signed-off-by: Amit Singh Tomar 
---
Changes since previous version
* No change
---
 configs/cubieboard7_defconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/configs/cubieboard7_defconfig b/configs/cubieboard7_defconfig
index 64dc593..d1ee862 100644
--- a/configs/cubieboard7_defconfig
+++ b/configs/cubieboard7_defconfig
@@ -14,3 +14,6 @@ CONFIG_PHY_REALTEK=y
 CONFIG_RTL8201F_PHY_S700_RMII_TIMINGS=y
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_ETH_DESIGNWARE_S700=y
+CONFIG_DM_MMC=y
+CONFIG_MMC_OWL=y
+CONFIG_CMD_MMC=y
-- 
2.7.4



[PATCH v2 5/6] mmc: actions: add MMC driver for Actions OWL S700

2020-12-19 Thread Amit Singh Tomar
From: Amit Singh Tomar 

This commit adds support for MMC controllers found on Actions OWL
S700 SoC platform.

Signed-off-by: Amit Singh Tomar 
---
Changes since previous version
* Corrected block count to 512.
* Changed the command timeout value to 30ms.
* Used readl_poll_timeout. 
* Read DMA parameters from DT instead of hardcoding it.
* Reduced number of arguments passed to own_dma_cofig.
* Removed debug leftover.
* Used mmc_of_parse().
---
 drivers/mmc/Kconfig   |   7 +
 drivers/mmc/Makefile  |   1 +
 drivers/mmc/owl_mmc.c | 399 ++
 3 files changed, 407 insertions(+)
 create mode 100644 drivers/mmc/owl_mmc.c

diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index 14d7913..61f9c67 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -289,6 +289,13 @@ config MMC_MXC
 
  If unsure, say N.
 
+config MMC_OWL
+   bool "Actions OWL Multimedia Card Interface support"
+   depends on ARCH_OWL && DM_MMC && BLK
+   help
+ This selects the OWL SD/MMC host controller found on board
+ based on Actions S700 SoC.
+
 config MMC_MXS
bool "Freescale MXS Multimedia Card Interface support"
depends on MX23 || MX28 || MX6 || MX7
diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile
index 1c849cb..f270f6c 100644
--- a/drivers/mmc/Makefile
+++ b/drivers/mmc/Makefile
@@ -38,6 +38,7 @@ obj-$(CONFIG_MMC_OMAP_HS) += omap_hsmmc.o
 obj-$(CONFIG_MMC_MXC)  += mxcmmc.o
 obj-$(CONFIG_MMC_MXS)  += mxsmmc.o
 obj-$(CONFIG_MMC_OCTEONTX) += octeontx_hsmmc.o
+obj-$(CONFIG_MMC_OWL)  += owl_mmc.o
 obj-$(CONFIG_MMC_PCI)  += pci_mmc.o
 obj-$(CONFIG_PXA_MMC_GENERIC) += pxa_mmc_gen.o
 obj-$(CONFIG_$(SPL_TPL_)SUPPORT_EMMC_RPMB) += rpmb.o
diff --git a/drivers/mmc/owl_mmc.c b/drivers/mmc/owl_mmc.c
new file mode 100644
index 000..5c48307
--- /dev/null
+++ b/drivers/mmc/owl_mmc.c
@@ -0,0 +1,399 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2020 Amit Singh Tomar 
+ *
+ * Driver for SD/MMC controller present on Actions Semi S700 SoC, based
+ * on Linux Driver "drivers/mmc/host/owl-mmc.c".
+ *
+ * Though, there is a bit (BSEL, BUS or DMA Special Channel Selection) that
+ * controls the data transfer from SDx_DAT register either using CPU AHB Bus
+ * or DMA channel, but seems like, it only works correctly using external DMA
+ * channel, and those special bits used in this driver is picked from vendor
+ * source exclusively for MMC/SD.
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * SDC registers
+ */
+#define OWL_REG_SD_EN   0x
+#define OWL_REG_SD_CTL  0x0004
+#define OWL_REG_SD_STATE0x0008
+#define OWL_REG_SD_CMD  0x000c
+#define OWL_REG_SD_ARG  0x0010
+#define OWL_REG_SD_RSPBUF0  0x0014
+#define OWL_REG_SD_RSPBUF1  0x0018
+#define OWL_REG_SD_RSPBUF2  0x001c
+#define OWL_REG_SD_RSPBUF3  0x0020
+#define OWL_REG_SD_RSPBUF4  0x0024
+#define OWL_REG_SD_DAT  0x0028
+#define OWL_REG_SD_BLK_SIZE 0x002c
+#define OWL_REG_SD_BLK_NUM  0x0030
+#define OWL_REG_SD_BUF_SIZE 0x0034
+
+/* SD_EN Bits */
+#define OWL_SD_EN_RANE  BIT(31)
+#define OWL_SD_EN_RESE  BIT(10)
+#define OWL_SD_ENABLE   BIT(7)
+#define OWL_SD_EN_BSEL  BIT(6)
+#define OWL_SD_EN_DATAWID(x)(((x) & 0x3) << 0)
+#define OWL_SD_EN_DATAWID_MASK 0x03
+
+/* SD_CTL Bits */
+#define OWL_SD_CTL_TOUTEN   BIT(31)
+#define OWL_SD_CTL_DELAY_MSKGENMASK(23, 16)
+#define OWL_SD_CTL_RDELAY(x)(((x) & 0xf) << 20)
+#define OWL_SD_CTL_WDELAY(x)(((x) & 0xf) << 16)
+#define OWL_SD_CTL_TS   BIT(7)
+#define OWL_SD_CTL_LBE  BIT(6)
+#define OWL_SD_CTL_TM(x)(((x) & 0xf) << 0)
+
+#define OWL_SD_DELAY_LOW_CLK0x0f
+#define OWL_SD_DELAY_MID_CLK0x0a
+#define OWL_SD_RDELAY_HIGH 0x08
+#define OWL_SD_WDELAY_HIGH 0x09
+
+/* SD_STATE Bits */
+#define OWL_SD_STATE_DAT0S  BIT(7)
+#define OWL_SD_STATE_CLNR   BIT(4)
+#define OWL_SD_STATE_CRC7ER BIT(0)
+
+#define OWL_MMC_OCR (MMC_VDD_32_33 | MMC_VDD_33_34 | \
+MMC_VDD_165_195)
+
+#define DATA_TRANSFER_TIMEOUT  3
+
+/*
+ * Simple DMA transfer operations defines for MMC/SD card
+ */
+#define SD_DMA_CHANNEL(base, channel)   ((base) + 0x100 * (channel))
+
+#define DMA_MODE   0x
+#define DMA_SO

[PATCH v2 4/6] ARM: dts: s700: add MMC/SD controller node

2020-12-19 Thread Amit Singh Tomar
From: Amit Singh Tomar 

This patch adds node for ethernet controller found on Action Semi OWL
S700 SoC.

Since, upstream Linux binding has not been merged for S700 MMC/SD
controller, Changes are put in u-boot specific dtsi file.

Signed-off-by: Amit Singh Tomar 
---
Changes since previous version
* No change.
---
 arch/arm/dts/s700-u-boot.dtsi | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/arch/arm/dts/s700-u-boot.dtsi b/arch/arm/dts/s700-u-boot.dtsi
index 1b27682..3c3396b 100644
--- a/arch/arm/dts/s700-u-boot.dtsi
+++ b/arch/arm/dts/s700-u-boot.dtsi
@@ -19,6 +19,16 @@
status = "okay";
 };
 
+   mmc0: mmc@e021 {
+   compatible = "actions,s700-mmc", "actions,owl-mmc";
+   reg = <0x0 0xe021 0x0 0x4000>;
+   interrupts = ;
+   clocks = <&cmu CLK_SD0>;
+   dmas = <&dma 2>;
+   dma-names = "mmc";
+   bus-width = <4>;
+   status = "okay";
+   };
};
 };
 
-- 
2.7.4



[PATCH v2 3/6] ARM: dts: sync Actions Semi S700 DT from Linux 5.10-rc7

2020-12-19 Thread Amit Singh Tomar
From: Amit Singh Tomar 

This Synchronizes the Actions Semi S700 SoC DT changes from
commit "0477e9288185" ("Linux 5.10-rc7").

Signed-off-by: Amit Singh Tomar 
---
Changes since previous version
* No change.
---
 arch/arm/dts/s700.dtsi | 17 -
 include/dt-bindings/power/owl-s700-powergate.h | 19 +++
 2 files changed, 35 insertions(+), 1 deletion(-)
 create mode 100644 include/dt-bindings/power/owl-s700-powergate.h

diff --git a/arch/arm/dts/s700.dtsi b/arch/arm/dts/s700.dtsi
index 2006ad5..2c78cae 100644
--- a/arch/arm/dts/s700.dtsi
+++ b/arch/arm/dts/s700.dtsi
@@ -5,6 +5,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 / {
@@ -231,7 +232,7 @@
 
pinctrl: pinctrl@e01b {
compatible = "actions,s700-pinctrl";
-   reg = <0x0 0xe01b 0x0 0x1000>;
+   reg = <0x0 0xe01b 0x0 0x100>;
clocks = <&cmu CLK_GPIO>;
gpio-controller;
gpio-ranges = <&pinctrl 0 0 136>;
@@ -244,5 +245,19 @@
 ,
 ;
};
+
+   dma: dma-controller@e023 {
+   compatible = "actions,s700-dma";
+   reg = <0x0 0xe023 0x0 0x1000>;
+   interrupts = ,
+,
+,
+;
+   #dma-cells = <1>;
+   dma-channels = <10>;
+   dma-requests = <44>;
+   clocks = <&cmu CLK_DMAC>;
+   power-domains = <&sps S700_PD_DMA>;
+   };
};
 };
diff --git a/include/dt-bindings/power/owl-s700-powergate.h 
b/include/dt-bindings/power/owl-s700-powergate.h
new file mode 100644
index 000..4cf1aef
--- /dev/null
+++ b/include/dt-bindings/power/owl-s700-powergate.h
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Actions Semi S700 SPS
+ *
+ * Copyright (c) 2017 Andreas Färber
+ */
+#ifndef DT_BINDINGS_POWER_OWL_S700_POWERGATE_H
+#define DT_BINDINGS_POWER_OWL_S700_POWERGATE_H
+
+#define S700_PD_VDE0
+#define S700_PD_VCE_SI 1
+#define S700_PD_USB2_1 2
+#define S700_PD_HDE3
+#define S700_PD_DMA4
+#define S700_PD_DS 5
+#define S700_PD_USB3   6
+#define S700_PD_USB2_0 7
+
+#endif
-- 
2.7.4



[PATCH v2 2/6] clk: actions: Add SD/MMC clocks

2020-12-19 Thread Amit Singh Tomar
From: Amit Singh Tomar 

This commit adds SD/MMC clocks, and provides .set/get_rate callbacks
for SD/MMC device present on Actions OWL S700 SoCs.

Signed-off-by: Amit Singh Tomar 
---
Changes since previous version:
* Removed rate *= 2 as this just overclocks.
* Separated the divide by 128 bit from divider value.
* Provided the separate routine to get sd parent rate
  based on bit 9.   
* Removed unnecessary initialization.
---
 drivers/clk/owl/clk_owl.c | 72 +++
 drivers/clk/owl/clk_owl.h |  2 ++
 2 files changed, 74 insertions(+)

diff --git a/drivers/clk/owl/clk_owl.c b/drivers/clk/owl/clk_owl.c
index 5be1b3b..cac8e6e 100644
--- a/drivers/clk/owl/clk_owl.c
+++ b/drivers/clk/owl/clk_owl.c
@@ -92,6 +92,9 @@ int owl_clk_enable(struct clk *clk)
setbits_le32(priv->base + CMU_DEVCLKEN1, CMU_DEVCLKEN1_ETH);
setbits_le32(priv->base + CMU_ETHERNETPLL, 5);
break;
+   case CLK_SD0:
+   setbits_le32(priv->base + CMU_DEVCLKEN0, CMU_DEVCLKEN0_SD0);
+   break;
default:
return -EINVAL;
}
@@ -121,6 +124,9 @@ int owl_clk_disable(struct clk *clk)
case CLK_ETHERNET:
clrbits_le32(priv->base + CMU_DEVCLKEN1, CMU_DEVCLKEN1_ETH);
break;
+   case CLK_SD0:
+   clrbits_le32(priv->base + CMU_DEVCLKEN0, CMU_DEVCLKEN0_SD0);
+   break;
default:
return -EINVAL;
}
@@ -128,11 +134,73 @@ int owl_clk_disable(struct clk *clk)
return 0;
 }
 
+static ulong get_sd_parent_rate(struct owl_clk_priv *priv, u32 dev_index)
+{
+   ulong rate;
+   u32 reg;
+
+   reg = readl(priv->base + (CMU_SD0CLK + dev_index * 0x4));
+   /* Clock output of DEV/NAND_PLL
+* Range: 48M ~ 756M
+* Frequency= PLLCLK * 6
+*/
+   if (reg & 0x200)
+   rate = readl(priv->base + CMU_NANDPLL) & 0x7f;
+   else
+   rate = readl(priv->base + CMU_DEVPLL) & 0x7f;
+
+   rate *= 600;
+
+   return rate;
+}
+
+static ulong owl_get_sd_clk_rate(struct owl_clk_priv *priv, int sd_index)
+{
+   uint div;
+   ulong parent_rate = get_sd_parent_rate(priv, sd_index);
+
+   div = readl(priv->base + (CMU_SD0CLK + sd_index * 0x4)) & 0x1f;
+   div++;
+
+   return (parent_rate / div);
+}
+
+static ulong owl_set_sd_clk_rate(struct owl_clk_priv *priv, ulong rate,
+int sd_index)
+{
+   uint div, val;
+   ulong parent_rate = get_sd_parent_rate(priv, sd_index);
+
+   if (rate <= 0)
+   return rate;
+
+   div = (parent_rate / rate);
+
+   val = readl(priv->base + (CMU_SD0CLK + sd_index * 0x4));
+   /* Bits 4..0 is used to program div value and bit 8 to enable
+* divide by 128 circuit
+*/
+   val &= ~0x11f;
+   if (div >= 128) {
+   div = div / 128;
+   val |= 0x100; /* enable divide by 128 circuit */
+   }
+   div--;
+   val |= (div & 0x1f);
+   writel(val, priv->base + (CMU_SD0CLK + sd_index * 0x4));
+
+   return owl_get_sd_clk_rate(priv, 0);
+}
+
 static ulong owl_clk_get_rate(struct clk *clk)
 {
+   struct owl_clk_priv *priv = dev_get_priv(clk->dev);
ulong rate;
 
switch (clk->id) {
+   case CLK_SD0:
+   rate = owl_get_sd_clk_rate(priv, 0);
+   break;
default:
return -ENOENT;
}
@@ -142,9 +210,13 @@ static ulong owl_clk_get_rate(struct clk *clk)
 
 static ulong owl_clk_set_rate(struct clk *clk, ulong rate)
 {
+   struct owl_clk_priv *priv = dev_get_priv(clk->dev);
ulong new_rate;
 
switch (clk->id) {
+   case CLK_SD0:
+   new_rate = owl_set_sd_clk_rate(priv, rate, 0);
+   break;
default:
return -ENOENT;
}
diff --git a/drivers/clk/owl/clk_owl.h b/drivers/clk/owl/clk_owl.h
index a01f81a..ee5eba4 100644
--- a/drivers/clk/owl/clk_owl.h
+++ b/drivers/clk/owl/clk_owl.h
@@ -62,4 +62,6 @@ struct owl_clk_priv {
 #define CMU_DEVCLKEN1_UART5BIT(21)
 #define CMU_DEVCLKEN1_UART3BIT(11)
 
+#define CMU_DEVCLKEN0_SD0  BIT(22)
+
 #endif
-- 
2.7.4



[PATCH v2 1/6] clk: actions: Introduce dummy get/set_rate callbacks

2020-12-19 Thread Amit Singh Tomar
From: Amit Singh Tomar 

This commit introduces get/set_rate callbacks, these are dummy at
the moment, and can be used to get/set clock for various devices
based on the clk id.

Signed-off-by: Amit Singh Tomar 
---
Changes since previous version:
* Removed premature initialization to avoid 
  compiler warnings.
---
 drivers/clk/owl/clk_owl.c | 26 ++
 1 file changed, 26 insertions(+)

diff --git a/drivers/clk/owl/clk_owl.c b/drivers/clk/owl/clk_owl.c
index 1999c87..5be1b3b 100644
--- a/drivers/clk/owl/clk_owl.c
+++ b/drivers/clk/owl/clk_owl.c
@@ -128,6 +128,30 @@ int owl_clk_disable(struct clk *clk)
return 0;
 }
 
+static ulong owl_clk_get_rate(struct clk *clk)
+{
+   ulong rate;
+
+   switch (clk->id) {
+   default:
+   return -ENOENT;
+   }
+
+   return rate;
+}
+
+static ulong owl_clk_set_rate(struct clk *clk, ulong rate)
+{
+   ulong new_rate;
+
+   switch (clk->id) {
+   default:
+   return -ENOENT;
+   }
+
+   return new_rate;
+}
+
 static int owl_clk_probe(struct udevice *dev)
 {
struct owl_clk_priv *priv = dev_get_priv(dev);
@@ -145,6 +169,8 @@ static int owl_clk_probe(struct udevice *dev)
 static const struct clk_ops owl_clk_ops = {
.enable = owl_clk_enable,
.disable = owl_clk_disable,
+   .get_rate = owl_clk_get_rate,
+   .set_rate = owl_clk_set_rate,
 };
 
 static const struct udevice_id owl_clk_ids[] = {
-- 
2.7.4



[PATCH v2 0/6] Add MMC/SD support for S700

2020-12-19 Thread Amit Singh Tomar
From: Amit Singh Tomar 

This series(v2) has few important updates, while loading large files we found
that MMC framework puts "0x1fffe00" into DMA Frame Length(DMA_FRAME_LEN 0x000C)
but register itself is limited to 24 bits and hence it was failing.
It is due to the wrong Block count(cfg->b_max) used in driver, that should be
just 512. This is now fixed in patch 5/6.

Apart from it, as Andre pointed that we might be just overclocking the MMC/SD
clock, and to confirm this we run following test:

$ md5sum clang 
349eac46cbbe28f8e44da2dce07fa7b7  clang

U-Boot => ext4load mmc 0:2 0x0 clang
503316480 bytes read in 19516 ms (24.6 MiB/s)
U-Boot => md5sum 0x0 0x1e00
md5 for  ... 1dff ==> d793bb51c4a1cf83c96d1980927461ff

Even though file gets loaded but md5sum doesn't match. This is now fixed in
patch 2/6

U-Boot => ext4load mmc 0:2 0x0 clang
503316480 bytes read in 41524 ms (11.6 MiB/s)
U-Boot => md5sum 0x0 0x1e00
md5 for  ... 1dff ==> 349eac46cbbe28f8e44da2dce07fa7b7

-
At the moment on S700 based platforms, only way to load/boot the Kernel
is from Ethernet, and with these patches one can now load/boot the
Kernel from uSD card.

Patches(1/6 and 2/6) adds changes needed for MMC/SD clock. It introduces
set/get callback routine and get/set MMC/SD clock rate based on device id.

Patch 4/6 adds MMC/SD node in U-boot specific dtsi file, which is used by MMC/SD
driver to read controller base address later on.

Patch 5/6 adds driver for MMC/SD controller present on S700 SoC, and its based
on Mainline Linux driver and DMA related bits is picked and simpilified from 
vendor source.

Final patch 6/6 enables the driver support along with MMC commands in
Cubieboard7 config file.

Also, while at it just took the opportunity to synchronize the S700 SoC DT with
Linux in patch 3/6.

This patch-set is tested on Cubieboard7-lite board with following results:

U-Boot 2021.01-rc1-04434-g6589149-dirty (Dec 13 2020 - 13:51:07 +0530)
cubieboard7

DRAM:  1 GiB
PSCI:  v0.2
MMC:   mmc@e021: 0
In:serial@e0126000
Out:   serial@e0126000
Err:   serial@e0126000
Net:   eth0: ethernet@e022
Hit any key to stop autoboot:  0 
U-Boot => 
U-Boot => 
U-Boot => 
U-Boot => mmc info
Device: mmc@e021
Manufacturer ID: 3
OEM: 5344
Name: SC16G 
Bus Speed: 5000
Mode: SD High Speed (50MHz)
Rd Block Len: 512
SD version 3.0
High Capacity: Yes
Capacity: 14.8 GiB
Bus Width: 4-bit
Erase Group Size: 512 Bytes
U-Boot => setenv bootargs console=ttyOWL3,115200n8 earlycon=owl,0xe0126000 
init=/sbin/init  root=/dev/mmcblk0p2 rw rootwait
U-Boot => setenv kernel_addr_r 0x8;setenv fdt_addr_r 0x1000;
U-Boot => fatload mmc 0:1 ${kernel_addr_r} image ;fatload mmc 0:1 ${fdt_addr_r} 
s700-cubieboard7.dtb
27480576 bytes read in 1041 ms (25.2 MiB/s)
7056 bytes read in 2 ms (3.4 MiB/s)
U-Boot => booti $kernel_addr_r - $fdt_addr_r
## Flattened Device Tree blob at 1000
   Booting using the fdt blob at 0x1000
   Loading Device Tree to 00003df56000, end 3df5ab8f ... OK

Amit Singh Tomar (6):
  clk: actions: Introduce dummy get/set_rate callbacks
  clk: actions: Add SD/MMC clocks
  ARM: dts: sync Actions Semi S700 DT from Linux 5.10-rc7
  ARM: dts: s700: add MMC/SD controller node
  mmc: actions: add MMC driver for Actions OWL S700
  configs: Enable mmc support

 arch/arm/dts/s700-u-boot.dtsi  |  10 +
 arch/arm/dts/s700.dtsi |  17 +-
 configs/cubieboard7_defconfig  |   3 +
 drivers/clk/owl/clk_owl.c  |  98 ++
 drivers/clk/owl/clk_owl.h  |   2 +
 drivers/mmc/Kconfig|   7 +
 drivers/mmc/Makefile   |   1 +
 drivers/mmc/owl_mmc.c  | 399 +
 include/dt-bindings/power/owl-s700-powergate.h |  19 ++
 9 files changed, 555 insertions(+), 1 deletion(-)
 create mode 100644 drivers/mmc/owl_mmc.c
 create mode 100644 include/dt-bindings/power/owl-s700-powergate.h

-- 
2.7.4



[PATCH 5/6] mmc: actions: add MMC driver for Actions OWL S700

2020-12-13 Thread Amit Singh Tomar
From: Amit Singh Tomar 

This commit adds support for MMC controllers found on Actions OWL
S700 SoC platform.

Signed-off-by: Amit Singh Tomar 
---
 drivers/mmc/Kconfig   |   7 +
 drivers/mmc/Makefile  |   1 +
 drivers/mmc/owl_mmc.c | 404 ++
 3 files changed, 412 insertions(+)
 create mode 100644 drivers/mmc/owl_mmc.c

diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig
index 14d7913..61f9c67 100644
--- a/drivers/mmc/Kconfig
+++ b/drivers/mmc/Kconfig
@@ -289,6 +289,13 @@ config MMC_MXC
 
  If unsure, say N.
 
+config MMC_OWL
+   bool "Actions OWL Multimedia Card Interface support"
+   depends on ARCH_OWL && DM_MMC && BLK
+   help
+ This selects the OWL SD/MMC host controller found on board
+ based on Actions S700 SoC.
+
 config MMC_MXS
bool "Freescale MXS Multimedia Card Interface support"
depends on MX23 || MX28 || MX6 || MX7
diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile
index 1c849cb..f270f6c 100644
--- a/drivers/mmc/Makefile
+++ b/drivers/mmc/Makefile
@@ -38,6 +38,7 @@ obj-$(CONFIG_MMC_OMAP_HS) += omap_hsmmc.o
 obj-$(CONFIG_MMC_MXC)  += mxcmmc.o
 obj-$(CONFIG_MMC_MXS)  += mxsmmc.o
 obj-$(CONFIG_MMC_OCTEONTX) += octeontx_hsmmc.o
+obj-$(CONFIG_MMC_OWL)  += owl_mmc.o
 obj-$(CONFIG_MMC_PCI)  += pci_mmc.o
 obj-$(CONFIG_PXA_MMC_GENERIC) += pxa_mmc_gen.o
 obj-$(CONFIG_$(SPL_TPL_)SUPPORT_EMMC_RPMB) += rpmb.o
diff --git a/drivers/mmc/owl_mmc.c b/drivers/mmc/owl_mmc.c
new file mode 100644
index 000..aa0ccb7
--- /dev/null
+++ b/drivers/mmc/owl_mmc.c
@@ -0,0 +1,404 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2020 Amit Singh Tomar 
+ *
+ * Driver for SD/MMC controller present on Actions Semi S700 SoC, based
+ * on Linux Driver "drivers/mmc/host/owl-mmc.c".
+ *
+ * Though, there is a bit (BSEL, BUS or DMA Special Channel Selection) that
+ * controls the data transfer from SDx_DAT register either using CPU AHB Bus
+ * or DMA channel, but seems like, it only works correctly using external DMA
+ * channel, and those special bits used in this driver is picked from vendor
+ * source exclusively for MMC/SD.
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * SDC registers
+ */
+#define OWL_REG_SD_EN   0x
+#define OWL_REG_SD_CTL  0x0004
+#define OWL_REG_SD_STATE0x0008
+#define OWL_REG_SD_CMD  0x000c
+#define OWL_REG_SD_ARG  0x0010
+#define OWL_REG_SD_RSPBUF0  0x0014
+#define OWL_REG_SD_RSPBUF1  0x0018
+#define OWL_REG_SD_RSPBUF2  0x001c
+#define OWL_REG_SD_RSPBUF3  0x0020
+#define OWL_REG_SD_RSPBUF4  0x0024
+#define OWL_REG_SD_DAT  0x0028
+#define OWL_REG_SD_BLK_SIZE 0x002c
+#define OWL_REG_SD_BLK_NUM  0x0030
+#define OWL_REG_SD_BUF_SIZE 0x0034
+
+/* SD_EN Bits */
+#define OWL_SD_EN_RANE  BIT(31)
+#define OWL_SD_EN_RESE  BIT(10)
+#define OWL_SD_ENABLE   BIT(7)
+#define OWL_SD_EN_BSEL  BIT(6)
+#define OWL_SD_EN_DATAWID(x)(((x) & 0x3) << 0)
+
+/* SD_CTL Bits */
+#define OWL_SD_CTL_TOUTEN   BIT(31)
+#define OWL_SD_CTL_DELAY_MSKGENMASK(23, 16)
+#define OWL_SD_CTL_RDELAY(x)(((x) & 0xf) << 20)
+#define OWL_SD_CTL_WDELAY(x)(((x) & 0xf) << 16)
+#define OWL_SD_CTL_TS   BIT(7)
+#define OWL_SD_CTL_LBE  BIT(6)
+#define OWL_SD_CTL_TM(x)(((x) & 0xf) << 0)
+
+#define OWL_SD_DELAY_LOW_CLK0x0f
+#define OWL_SD_DELAY_MID_CLK0x0a
+#define OWL_SD_RDELAY_HIGH 0x08
+#define OWL_SD_WDELAY_HIGH 0x09
+
+/* SD_STATE Bits */
+#define OWL_SD_STATE_CLNR   BIT(4)
+#define OWL_SD_STATE_CRC7ER BIT(0)
+#define OWL_SD_STATE_DAT0S  BIT(7)
+
+#define OWL_MMC_OCR (MMC_VDD_32_33 | MMC_VDD_33_34 | \
+MMC_VDD_165_195)
+
+#define DATA_TRANSFER_TIMEOUT  (3 * (100 * 1000))
+
+/*
+ * Simple DMA transfer operations defines for MMC/SD card
+ */
+#define DMA0_CHANNEL_BASE(x)   (0xe0230100 + 0x100 * (x))
+
+#define DMA_MODE   0x
+#define DMA_SOURCE 0x0004
+#define DMA_DESTINATION0x0008
+#define DMA_FRAME_LEN  0x000C
+#define DMA_FRAME_CNT  0x0010
+#define DMA_START  0x0024
+
+/* DMAx_MODE */
+#define DMA_MODE_ST(x)  (((x) & 0x3) << 8)
+#define DMA_MODE_ST_DEV DMA_MODE_ST(0)
+#define DMA_MODE_DT(x)  

[PATCH 6/6] configs: Enable mmc support

2020-12-13 Thread Amit Singh Tomar
From: Amit Singh Tomar 

This commits enables mmc on the Actions Cubieboard7 board.

Signed-off-by: Amit Singh Tomar 
---
 configs/cubieboard7_defconfig | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/configs/cubieboard7_defconfig b/configs/cubieboard7_defconfig
index 64dc593..d1ee862 100644
--- a/configs/cubieboard7_defconfig
+++ b/configs/cubieboard7_defconfig
@@ -14,3 +14,6 @@ CONFIG_PHY_REALTEK=y
 CONFIG_RTL8201F_PHY_S700_RMII_TIMINGS=y
 CONFIG_ETH_DESIGNWARE=y
 CONFIG_ETH_DESIGNWARE_S700=y
+CONFIG_DM_MMC=y
+CONFIG_MMC_OWL=y
+CONFIG_CMD_MMC=y
-- 
2.7.4



[PATCH 4/6] ARM: dts: s700: add MMC/SD controller node

2020-12-13 Thread Amit Singh Tomar
From: Amit Singh Tomar 

This patch adds node for ethernet controller found on Action Semi OWL
S700 SoC.

Since, upstream Linux binding has not been merged for S700 MMC/SD
controller, Changes are put in u-boot specific dtsi file.

Signed-off-by: Amit Singh Tomar 
---
 arch/arm/dts/s700-u-boot.dtsi | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/arch/arm/dts/s700-u-boot.dtsi b/arch/arm/dts/s700-u-boot.dtsi
index 1b27682..3c3396b 100644
--- a/arch/arm/dts/s700-u-boot.dtsi
+++ b/arch/arm/dts/s700-u-boot.dtsi
@@ -19,6 +19,16 @@
status = "okay";
 };
 
+   mmc0: mmc@e021 {
+   compatible = "actions,s700-mmc", "actions,owl-mmc";
+   reg = <0x0 0xe021 0x0 0x4000>;
+   interrupts = ;
+   clocks = <&cmu CLK_SD0>;
+   dmas = <&dma 2>;
+   dma-names = "mmc";
+   bus-width = <4>;
+   status = "okay";
+   };
};
 };
 
-- 
2.7.4



[PATCH 2/6] clk: actions: Add SD/MMC clocks

2020-12-13 Thread Amit Singh Tomar
From: Amit Singh Tomar 

This commit adds SD/MMC clocks, and provides .set/get_rate callbacks
for SD/MMC device present on Actions OWL S700 SoCs.

Signed-off-by: Amit Singh Tomar 
---
 drivers/clk/owl/clk_owl.c | 66 +++
 drivers/clk/owl/clk_owl.h |  2 ++
 2 files changed, 68 insertions(+)

diff --git a/drivers/clk/owl/clk_owl.c b/drivers/clk/owl/clk_owl.c
index c9bc5c2..49a492c 100644
--- a/drivers/clk/owl/clk_owl.c
+++ b/drivers/clk/owl/clk_owl.c
@@ -92,6 +92,9 @@ int owl_clk_enable(struct clk *clk)
setbits_le32(priv->base + CMU_DEVCLKEN1, CMU_DEVCLKEN1_ETH);
setbits_le32(priv->base + CMU_ETHERNETPLL, 5);
break;
+   case CLK_SD0:
+   setbits_le32(priv->base + CMU_DEVCLKEN0, CMU_DEVCLKEN0_SD0);
+   break;
default:
return -EINVAL;
}
@@ -121,6 +124,9 @@ int owl_clk_disable(struct clk *clk)
case CLK_ETHERNET:
clrbits_le32(priv->base + CMU_DEVCLKEN1, CMU_DEVCLKEN1_ETH);
break;
+   case CLK_SD0:
+   clrbits_le32(priv->base + CMU_DEVCLKEN0, CMU_DEVCLKEN0_SD0);
+   break;
default:
return -EINVAL;
}
@@ -128,12 +134,69 @@ int owl_clk_disable(struct clk *clk)
return 0;
 }
 
+static ulong owl_get_sd_clk_rate(struct owl_clk_priv *priv, int sd_index)
+{
+   ulong parent_rate;
+   uint div = 1;
+
+   /* Clock output of DEV_PLL
+* Range: 48M ~ 756M
+* Frequency= DEVPLLCLK * 6
+*/
+   parent_rate = readl(priv->base + CMU_DEVPLL) & 0x7f;
+   parent_rate *= 600;
+
+   div += readl(priv->base + (CMU_SD0CLK + sd_index*0x4)) & 0x1f;
+
+   return (parent_rate / div);
+}
+
+static ulong owl_set_sd_clk_rate(struct owl_clk_priv *priv, ulong rate,
+int sd_index)
+{
+   ulong parent_rate;
+   uint div = 1, val;
+
+   /* Clock output of DEV_PLL
+* Range: 48M ~ 756M
+* Frequency= DEVPLLCLK * 6
+*/
+   parent_rate = readl(priv->base + CMU_DEVPLL) & 0x7f;
+   parent_rate *= 600;
+
+   rate *= 2;
+   div = (parent_rate / rate) - 1;
+
+   if (div >= 128)
+   div |= 0x100;
+
+   val = readl(priv->base + (CMU_SD0CLK + sd_index*0x4));
+   /* Bits 4..0 is used to program div value */
+   val &= ~0x1f;
+   val |= div;
+   /* As per Manuals Bits 31..10 are reserved but Bits 11 and
+* 10 needed to be set for proper operation
+*/
+   val |= 0xc00;
+   /* Bit 9 and 8 must be cleared */
+   if (div < 128)
+   val &= ~0x300;
+   else
+   val &= ~0x200;
+   writel(val, priv->base + (CMU_SD0CLK + sd_index*0x4));
+
+   return owl_get_sd_clk_rate(priv, 0);
+}
+
 static ulong owl_clk_get_rate(struct clk *clk)
 {
struct owl_clk_priv *priv = dev_get_priv(clk->dev);
ulong rate;
 
switch (clk->id) {
+   case CLK_SD0:
+   rate = owl_get_sd_clk_rate(priv, 0);
+   break;
default:
return -ENOENT;
}
@@ -147,6 +210,9 @@ static ulong owl_clk_set_rate(struct clk *clk, ulong rate)
ulong new_rate;
 
switch (clk->id) {
+   case CLK_SD0:
+   new_rate = owl_set_sd_clk_rate(priv, rate, 0);
+   break;
default:
return -ENOENT;
}
diff --git a/drivers/clk/owl/clk_owl.h b/drivers/clk/owl/clk_owl.h
index a01f81a..ee5eba4 100644
--- a/drivers/clk/owl/clk_owl.h
+++ b/drivers/clk/owl/clk_owl.h
@@ -62,4 +62,6 @@ struct owl_clk_priv {
 #define CMU_DEVCLKEN1_UART5BIT(21)
 #define CMU_DEVCLKEN1_UART3BIT(11)
 
+#define CMU_DEVCLKEN0_SD0  BIT(22)
+
 #endif
-- 
2.7.4



[PATCH 3/6] ARM: dts: sync Actions Semi S700 DT from Linux 5.10-rc7

2020-12-13 Thread Amit Singh Tomar
From: Amit Singh Tomar 

This Synchronizes the Actions Semi S700 SoC DT changes from
commit "0477e9288185" ("Linux 5.10-rc7").

Signed-off-by: Amit Singh Tomar 
---
 arch/arm/dts/s700.dtsi | 17 -
 include/dt-bindings/power/owl-s700-powergate.h | 19 +++
 2 files changed, 35 insertions(+), 1 deletion(-)
 create mode 100644 include/dt-bindings/power/owl-s700-powergate.h

diff --git a/arch/arm/dts/s700.dtsi b/arch/arm/dts/s700.dtsi
index 2006ad5..2c78cae 100644
--- a/arch/arm/dts/s700.dtsi
+++ b/arch/arm/dts/s700.dtsi
@@ -5,6 +5,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 / {
@@ -231,7 +232,7 @@
 
pinctrl: pinctrl@e01b {
compatible = "actions,s700-pinctrl";
-   reg = <0x0 0xe01b 0x0 0x1000>;
+   reg = <0x0 0xe01b 0x0 0x100>;
clocks = <&cmu CLK_GPIO>;
gpio-controller;
gpio-ranges = <&pinctrl 0 0 136>;
@@ -244,5 +245,19 @@
 ,
 ;
};
+
+   dma: dma-controller@e023 {
+   compatible = "actions,s700-dma";
+   reg = <0x0 0xe023 0x0 0x1000>;
+   interrupts = ,
+,
+,
+;
+   #dma-cells = <1>;
+   dma-channels = <10>;
+   dma-requests = <44>;
+   clocks = <&cmu CLK_DMAC>;
+   power-domains = <&sps S700_PD_DMA>;
+   };
};
 };
diff --git a/include/dt-bindings/power/owl-s700-powergate.h 
b/include/dt-bindings/power/owl-s700-powergate.h
new file mode 100644
index 000..4cf1aef
--- /dev/null
+++ b/include/dt-bindings/power/owl-s700-powergate.h
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Actions Semi S700 SPS
+ *
+ * Copyright (c) 2017 Andreas Färber
+ */
+#ifndef DT_BINDINGS_POWER_OWL_S700_POWERGATE_H
+#define DT_BINDINGS_POWER_OWL_S700_POWERGATE_H
+
+#define S700_PD_VDE0
+#define S700_PD_VCE_SI 1
+#define S700_PD_USB2_1 2
+#define S700_PD_HDE3
+#define S700_PD_DMA4
+#define S700_PD_DS 5
+#define S700_PD_USB3   6
+#define S700_PD_USB2_0 7
+
+#endif
-- 
2.7.4



[PATCH 0/6] Add MMC/SD support for S700

2020-12-13 Thread Amit Singh Tomar
From: Amit Singh Tomar 

At the moment on S700 based platforms, only way to load/boot the Kernel
is from Ethernet, and with these patches one can now load/boot the
Kernel from uSD card.

Patches(1/6 and 2/6) adds changes needed for MMC/SD clock. It introduces
set/get callback routine and get/set MMC/SD clock rate based on device id.

Patch 4/6 adds MMC/SD node in U-boot specific dtsi file, which is used by MMC/SD
driver to read controller base address later on.

Patch 5/6 adds driver for MMC/SD controller present on S700 SoC, and its based
on Mainline Linux driver and DMA related bits is picked and simpilified from 
vendor source.

Final patch 6/6 enables the driver support along with MMC commands in
Cubieboard7 config file.

Also, while at it just took the opportunity to synchronize the S700 SoC DT with
Linux in patch 3/6.

This patch-set is tested on Cubieboard7-lite board with following results:

U-Boot 2021.01-rc1-04434-g6589149-dirty (Dec 13 2020 - 13:51:07 +0530)
cubieboard7

DRAM:  1 GiB
PSCI:  v0.2
MMC:   mmc@e021: 0
In:serial@e0126000
Out:   serial@e0126000
Err:   serial@e0126000
Net:   eth0: ethernet@e022
Hit any key to stop autoboot:  0 
U-Boot => 
U-Boot => 
U-Boot => 
U-Boot => mmc info
Device: mmc@e021
Manufacturer ID: 3
OEM: 5344
Name: SC16G 
Bus Speed: 5000
Mode: SD High Speed (50MHz)
Rd Block Len: 512
SD version 3.0
High Capacity: Yes
Capacity: 14.8 GiB
Bus Width: 4-bit
Erase Group Size: 512 Bytes
U-Boot => setenv bootargs console=ttyOWL3,115200n8 earlycon=owl,0xe0126000 
init=/sbin/init  root=/dev/mmcblk0p2 rw rootwait
U-Boot => setenv kernel_addr_r 0x8;setenv fdt_addr_r 0x1000;
U-Boot => fatload mmc 0:1 ${kernel_addr_r} image ;fatload mmc 0:1 ${fdt_addr_r} 
s700-cubieboard7.dtb
27480576 bytes read in 1041 ms (25.2 MiB/s)
7056 bytes read in 2 ms (3.4 MiB/s)
U-Boot => booti $kernel_addr_r - $fdt_addr_r
## Flattened Device Tree blob at 1000
   Booting using the fdt blob at 0x1000
   Loading Device Tree to 3df56000, end 3df5ab8f ... OK

Starting kernel ...

[0.00] Booting Linux on physical CPU 0x00 [0x410fd034]
[0.00] Linux version 5.7.0-rc6-00022-g99f1c330923b-dirty 
(amit@amit-ThinkPad-X230) (gcc version 7.3.1 20180425 [linaro-7.3-2018.05 
revision d29120a424ecfbc167ef90065c0eeb7f91977701] (Linaro GCC 7.3-2018.05), 
GNU ld (GNU Binutils for Ubuntu) 2.26.1) #474 SMP PREEMPT Thu Aug 13 15:27:10 
IST 2020
[0.00] Machine model: CubieBoard7
[0.00] earlycon: owl0 at MMIO 0xe0126000 (options '')
[0.00] printk: bootconsole [owl0] enabled
[0.00] efi: UEFI not found.
[0.00] cma: Reserved 32 MiB at 0x3e00

Amit Singh Tomar (6):
  clk: actions: Introduce dummy get/set_rate callbacks
  clk: actions: Add SD/MMC clocks
  ARM: dts: sync Actions Semi S700 DT from Linux 5.10-rc7
  ARM: dts: s700: add MMC/SD controller node
  mmc: actions: add MMC driver for Actions OWL S700
  configs: Enable mmc support

 arch/arm/dts/s700-u-boot.dtsi  |  10 +
 arch/arm/dts/s700.dtsi |  17 +-
 configs/cubieboard7_defconfig  |   3 +
 drivers/clk/owl/clk_owl.c  |  94 ++
 drivers/clk/owl/clk_owl.h  |   2 +
 drivers/mmc/Kconfig|   7 +
 drivers/mmc/Makefile   |   1 +
 drivers/mmc/owl_mmc.c  | 404 +
 include/dt-bindings/power/owl-s700-powergate.h |  19 ++
 9 files changed, 556 insertions(+), 1 deletion(-)
 create mode 100644 drivers/mmc/owl_mmc.c
 create mode 100644 include/dt-bindings/power/owl-s700-powergate.h

-- 
2.7.4



[PATCH 1/6] clk: actions: Introduce dummy get/set_rate callbacks

2020-12-13 Thread Amit Singh Tomar
From: Amit Singh Tomar 

This commit introduces get/set_rate callbacks, these are dummy at
the moment, and can be used to get/set clock for various devices
based on the clk id.

Signed-off-by: Amit Singh Tomar 
---
 drivers/clk/owl/clk_owl.c | 28 
 1 file changed, 28 insertions(+)

diff --git a/drivers/clk/owl/clk_owl.c b/drivers/clk/owl/clk_owl.c
index 1999c87..c9bc5c2 100644
--- a/drivers/clk/owl/clk_owl.c
+++ b/drivers/clk/owl/clk_owl.c
@@ -128,6 +128,32 @@ int owl_clk_disable(struct clk *clk)
return 0;
 }
 
+static ulong owl_clk_get_rate(struct clk *clk)
+{
+   struct owl_clk_priv *priv = dev_get_priv(clk->dev);
+   ulong rate;
+
+   switch (clk->id) {
+   default:
+   return -ENOENT;
+   }
+
+   return rate;
+}
+
+static ulong owl_clk_set_rate(struct clk *clk, ulong rate)
+{
+   struct owl_clk_priv *priv = dev_get_priv(clk->dev);
+   ulong new_rate;
+
+   switch (clk->id) {
+   default:
+   return -ENOENT;
+   }
+
+   return new_rate;
+}
+
 static int owl_clk_probe(struct udevice *dev)
 {
struct owl_clk_priv *priv = dev_get_priv(dev);
@@ -145,6 +171,8 @@ static int owl_clk_probe(struct udevice *dev)
 static const struct clk_ops owl_clk_ops = {
.enable = owl_clk_enable,
.disable = owl_clk_disable,
+   .get_rate = owl_clk_get_rate,
+   .set_rate = owl_clk_set_rate,
 };
 
 static const struct udevice_id owl_clk_ids[] = {
-- 
2.7.4



[PATCH] arm: actions: increase SYS_MALLOC_F_LEN

2020-11-09 Thread Amit Singh Tomar
after commit 4ab3817ff16a ("clk: fixed-rate: Enable DM_FLAG_PRE_RELOC flag")
Cubieboard7 (based on actions S700 SoC) fails to boot.

It is due to the fact that the default value of CONFIG_SYS_MALLOC_F_LEN (0x400)
would not provide enough memory for clock device to probe (before relocation)
well.

This commit fixes it, by increasing SYS_MALLOC_F_LEN to value 0x2000.

Suggested-by: Andre Przywara 
Signed-off-by: Amit Singh Tomar 
---
 Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Kconfig b/Kconfig
index c94b10e9fa72..6dc20ed25b29 100644
--- a/Kconfig
+++ b/Kconfig
@@ -200,7 +200,7 @@ config SYS_MALLOC_F_LEN
default 0x2000 if (ARCH_IMX8 || ARCH_IMX8M || ARCH_MX7 || \
   ARCH_MX7ULP || ARCH_MX6 || ARCH_MX5 || \
   ARCH_LS1012A || ARCH_LS1021A || ARCH_LS1043A || \
-  ARCH_LS1046A || ARCH_QEMU || ARCH_SUNXI)
+  ARCH_LS1046A || ARCH_QEMU || ARCH_SUNXI || ARCH_OWL)
default 0x400
help
  Before relocation, memory is very limited on many platforms. Still,
-- 
2.7.4



[PATCH v1 5/7] arm: dts: s700: add node for ethernet controller

2020-05-09 Thread Amit Singh Tomar
This patch adds node for ethernet controller found on Action Semi OWL
S700 SoC.

Since, there is no upstream Linux binding exist for S700 ethernet
controller, Changes are put in u-boot specific dtsi file.

Signed-off-by: Amit Singh Tomar 
---
 arch/arm/dts/s700-u-boot.dtsi | 13 +
 1 file changed, 13 insertions(+)

diff --git a/arch/arm/dts/s700-u-boot.dtsi b/arch/arm/dts/s700-u-boot.dtsi
index a52775f2..1b2768272c62 100644
--- a/arch/arm/dts/s700-u-boot.dtsi
+++ b/arch/arm/dts/s700-u-boot.dtsi
@@ -6,6 +6,19 @@
 /{
soc {
u-boot,dm-pre-reloc;
+
+   gmac:  ethernet@e022 {
+   compatible = "actions,s700-ethernet";
+   reg = <0 0xe022 0 0x2000>;
+   interrupts = ;
+   interrupt-names = "macirq";
+   local-mac-address = [ 00 18 fe 66 66 66 ];
+   clocks = <&cmu CLK_ETHERNET>, <&cmu CLK_RMII_REF>;
+   clock-names = "ethernet", "rmii_ref";
+   phy-mode = "rmii";
+   status = "okay";
+};
+
};
 };
 
-- 
2.7.4



[PATCH v1 7/7] configs: Enable mac and phy configs

2020-05-09 Thread Amit Singh Tomar
This patch adds MAC and PHY related configs (needed for proper
ethernet operations) for Action Semi S700 SoC.

Signed-off-by: Amit Singh Tomar 
---
 configs/cubieboard7_defconfig | 4 
 1 file changed, 4 insertions(+)

diff --git a/configs/cubieboard7_defconfig b/configs/cubieboard7_defconfig
index 637dc9e9fb79..c82afc340313 100644
--- a/configs/cubieboard7_defconfig
+++ b/configs/cubieboard7_defconfig
@@ -10,3 +10,7 @@ CONFIG_BOOTARGS="console=ttyOWL3,115200n8"
 # CONFIG_DISPLAY_BOARDINFO is not set
 CONFIG_SYS_PROMPT="U-Boot => "
 CONFIG_DEFAULT_DEVICE_TREE="s700-cubieboard7"
+CONFIG_ETH_DESIGNWARE_S700=y
+CONFIG_ETH_DESIGNWARE=y
+CONFIG_PHY_REALTEK=y
+CONFIG_RTL8201F_PHY_S700_RMII_TIMINGS=y
-- 
2.7.4



[PATCH v1 6/7] owl: Kconfig: Enable DM eth for OWL platform

2020-05-09 Thread Amit Singh Tomar
This patch selects CONFIG_DM_ETH (ethernet driver is base on DM model)
for Action semi owl SoC.

Signed-off-by: Amit Singh Tomar 
---
 arch/arm/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 0d463088a2e4..80e07f92febc 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -904,6 +904,7 @@ config ARCH_MX5
 config ARCH_OWL
bool "Actions Semi OWL SoCs"
select DM
+   select DM_ETH
select DM_SERIAL
select OWL_SERIAL
select CLK
-- 
2.7.4



[PATCH v1 4/7] net: designware: s700: Add glue code for S700 mac

2020-05-09 Thread Amit Singh Tomar
This patchs adds glue logic to enable designware mac present on
Action Semi based S700 SoC, Configures SoC specific bits.

Undocumented bit that programs the PHY interface select register
comes from vendor source. 

It has been tested on Cubieboard7-lite based on S700 SoC.

Signed-off-by: Amit Singh Tomar 
---
 arch/arm/include/asm/arch-owl/regs_s700.h |  6 +++
 drivers/net/Kconfig   |  7 
 drivers/net/Makefile  |  1 +
 drivers/net/dwmac_s700.c  | 66 +++
 4 files changed, 80 insertions(+)
 create mode 100644 drivers/net/dwmac_s700.c

diff --git a/arch/arm/include/asm/arch-owl/regs_s700.h 
b/arch/arm/include/asm/arch-owl/regs_s700.h
index 90459ae95eeb..0f79faec69c1 100644
--- a/arch/arm/include/asm/arch-owl/regs_s700.h
+++ b/arch/arm/include/asm/arch-owl/regs_s700.h
@@ -55,4 +55,10 @@
 
 #define CMU_DEVCLKEN1_ETH  BIT(23)
 
+#define GPIO_MFP_PWM   (0xE01B)
+#define MFP_CTL0   (GPIO_MFP_PWM + 0x40)
+#define MFP_CTL1   (GPIO_MFP_PWM + 0x44)
+#define MFP_CTL2   (GPIO_MFP_PWM + 0x48)
+#define MFP_CTL3   (GPIO_MFP_PWM + 0x4C)
+
 #endif
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index a2587a29e165..1a04e333efdf 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -225,6 +225,13 @@ config ETH_DESIGNWARE_SOCFPGA
  Altera system manager to correctly interface with the PHY.
  This code handles those SoC specifics.
 
+config ETH_DESIGNWARE_S700
+   bool "Actins S700 glue driver for Synopsys Designware Ethernet MAC"
+   depends on DM_ETH && ETH_DESIGNWARE
+   help
+ This provides glue layer to use Synopsys Designware Ethernet MAC
+ present on Actions S700 SoC.
+
 config ETHOC
bool "OpenCores 10/100 Mbps Ethernet MAC"
help
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 6d9b8772b1a5..6f01d0169240 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -18,6 +18,7 @@ obj-$(CONFIG_CS8900) += cs8900.o
 obj-$(CONFIG_TULIP) += dc2114x.o
 obj-$(CONFIG_ETH_DESIGNWARE) += designware.o
 obj-$(CONFIG_ETH_DESIGNWARE_SOCFPGA) += dwmac_socfpga.o
+obj-$(CONFIG_ETH_DESIGNWARE_S700) += dwmac_s700.o
 obj-$(CONFIG_DRIVER_DM9000) += dm9000x.o
 obj-$(CONFIG_DNET) += dnet.o
 obj-$(CONFIG_E1000) += e1000.o
diff --git a/drivers/net/dwmac_s700.c b/drivers/net/dwmac_s700.c
new file mode 100644
index ..a5d544e91e06
--- /dev/null
+++ b/drivers/net/dwmac_s700.c
@@ -0,0 +1,66 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2020 Amit Singh Tomar 
+ *
+ * Actions DWMAC specific glue layer
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "designware.h"
+#include 
+
+/* pin control for MAC */
+#define RMII_TXD01_MFP_CTL0(0x0 << 16)
+#define RMII_RXD01_MFP_CTL0(0x0 << 8)
+#define RMII_TXEN_TXER_MFP_CTL0(0x0 << 13)
+#define RMII_REF_CLK_MFP_CTL0  (0x0 << 6)
+#define CLKO_25M_EN_MFP_CTL3   BIT(30)
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static void dwmac_board_setup(void)
+{
+   clrbits_le32(MFP_CTL0, (RMII_TXD01_MFP_CTL0 | RMII_RXD01_MFP_CTL0 |
+RMII_TXEN_TXER_MFP_CTL0 | RMII_REF_CLK_MFP_CTL0));
+
+   setbits_le32(MFP_CTL3, CLKO_25M_EN_MFP_CTL3);
+}
+
+static int dwmac_s700_probe(struct udevice *dev)
+{
+   dwmac_board_setup();
+
+   /* This is undocumented, phy interface select register */
+   writel(0x4, 0xe024c0a0);
+
+   return designware_eth_probe(dev);
+}
+
+static int dwmac_s700_ofdata_to_platdata(struct udevice *dev)
+{
+   return designware_eth_ofdata_to_platdata(dev);
+}
+
+static const struct udevice_id dwmac_s700_ids[] = {
+   {.compatible = "actions,s700-ethernet"},
+   { }
+};
+
+U_BOOT_DRIVER(dwmac_s700) = {
+   .name   = "dwmac_s700",
+   .id = UCLASS_ETH,
+   .of_match = dwmac_s700_ids,
+   .ofdata_to_platdata = dwmac_s700_ofdata_to_platdata,
+   .probe  = dwmac_s700_probe,
+   .ops= &designware_eth_ops,
+   .priv_auto_alloc_size = sizeof(struct dw_eth_dev),
+   .platdata_auto_alloc_size = sizeof(struct eth_pdata),
+   .flags = DM_FLAG_ALLOC_PRIV_DMA,
+};
-- 
2.7.4



[PATCH v1 3/7] net: phy: realtek: Introduce PHY_RTL8201F_S700_RMII_TIMINGS to adjust rx/tx timings

2020-05-09 Thread Amit Singh Tomar
RTL8201F PHY module found on Actions Semi Cubieboard7 seems to have
specific Rx/Tx interface timings requirement for proper PHY operations.
These timing values are not documented anywhere and picked from vendor
code.

This commits lets proper packets to be transmitted over the network.

Signed-off-by: Amit Singh Tomar 
---
 drivers/net/phy/Kconfig   |  9 +
 drivers/net/phy/realtek.c | 35 +++
 2 files changed, 44 insertions(+)

diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig
index d1f049e62ab7..123c17c04458 100644
--- a/drivers/net/phy/Kconfig
+++ b/drivers/net/phy/Kconfig
@@ -235,6 +235,15 @@ config RTL8211F_PHY_FORCE_EEE_RXC_ON
  Default n, which means that the PHY state is not changed. To work
  around the issues, change this setting to y.
 
+config RTL8201F_PHY_S700_RMII_TIMINGS
+   bool "Ethernet PHY RTL8201F: adjust RMII Tx Interface timings"
+   depends on PHY_REALTEK
+   help
+ This provides an option to configure specific timing requirements 
(needed
+ for proper PHY operations) for the PHY module present on ACTION SEMI 
S700
+ based cubieboard7. Exact timing requiremnets seems to be SoC specific
+ (and it's undocumented) that comes from vendor code itself.
+
 config PHY_SMSC
bool  "Microchip(SMSC) Ethernet PHYs support"
 
diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
index b9c373bfe3cc..a549a106876f 100644
--- a/drivers/net/phy/realtek.c
+++ b/drivers/net/phy/realtek.c
@@ -13,6 +13,7 @@
 #define PHY_RTL8211x_FORCE_MASTER BIT(1)
 #define PHY_RTL8211E_PINE64_GIGABIT_FIX BIT(2)
 #define PHY_RTL8211F_FORCE_EEE_RXC_ON BIT(3)
+#define PHY_RTL8201F_S700_RMII_TIMINGS BIT(4)
 
 #define PHY_AUTONEGOTIATE_TIMEOUT 5000
 
@@ -58,6 +59,15 @@
 #define MIIM_RTL8211F_TX_DELAY 0x100
 #define MIIM_RTL8211F_LCR  0x10
 
+#define RTL8201F_RMSR  0x10
+
+#define RMSR_RX_TIMING_SHIFT   BIT(2)
+#define RMSR_RX_TIMING_MASKGENMASK(7, 4)
+#define RMSR_RX_TIMING_VAL 0x4
+#define RMSR_TX_TIMING_SHIFT   BIT(3)
+#define RMSR_TX_TIMING_MASKGENMASK(11, 8)
+#define RMSR_TX_TIMING_VAL 0x5
+
 static int rtl8211f_phy_extread(struct phy_device *phydev, int addr,
int devaddr, int regnum)
 {
@@ -112,6 +122,15 @@ static int rtl8211f_probe(struct phy_device *phydev)
return 0;
 }
 
+static int rtl8210f_probe(struct phy_device *phydev)
+{
+#ifdef CONFIG_RTL8201F_PHY_S700_RMII_TIMINGS
+   phydev->flags |= PHY_RTL8201F_S700_RMII_TIMINGS;
+#endif
+
+   return 0;
+}
+
 /* RealTek RTL8211x */
 static int rtl8211x_config(struct phy_device *phydev)
 {
@@ -160,6 +179,21 @@ static int rtl8211x_config(struct phy_device *phydev)
 /* RealTek RTL8201F */
 static int rtl8201f_config(struct phy_device *phydev)
 {
+   unsigned int reg;
+
+   if (phydev->flags & PHY_RTL8201F_S700_RMII_TIMINGS) {
+   phy_write(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211F_PAGE_SELECT,
+ 7);
+   reg = phy_read(phydev, MDIO_DEVAD_NONE, RTL8201F_RMSR);
+   reg &= ~(RMSR_RX_TIMING_MASK | RMSR_TX_TIMING_MASK);
+   /* Set the needed Rx/Tx Timings for proper PHY operation */
+   reg |= (RMSR_RX_TIMING_VAL << RMSR_RX_TIMING_SHIFT)
+  | (RMSR_TX_TIMING_VAL << RMSR_TX_TIMING_SHIFT);
+   phy_write(phydev, MDIO_DEVAD_NONE, RTL8201F_RMSR, reg);
+   phy_write(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211F_PAGE_SELECT,
+ 0);
+   }
+
genphy_config_aneg(phydev);
 
return 0;
@@ -400,6 +434,7 @@ static struct phy_driver RTL8201F_driver = {
.uid = 0x1cc816,
.mask = 0xff,
.features = PHY_BASIC_FEATURES,
+   .probe = &rtl8210f_probe,
.config = &rtl8201f_config,
.startup = &rtl8211e_startup,
.shutdown = &genphy_shutdown,
-- 
2.7.4



[PATCH v1 2/7] net: phy: realtek: Add support for RTL8201F PHY module.

2020-05-09 Thread Amit Singh Tomar
This patch adds support for Realtek PHY RTL8201F 10/100Mbs
(with variants: RTL8201FN and RTL8201FL) PHYceiver. It is
present on Actions Semi Cubieboard7 board.

Signed-off-by: Amit Singh Tomar 
---
 drivers/net/phy/realtek.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
index 8f1d75963259..b9c373bfe3cc 100644
--- a/drivers/net/phy/realtek.c
+++ b/drivers/net/phy/realtek.c
@@ -157,6 +157,14 @@ static int rtl8211x_config(struct phy_device *phydev)
return 0;
 }
 
+/* RealTek RTL8201F */
+static int rtl8201f_config(struct phy_device *phydev)
+{
+   genphy_config_aneg(phydev);
+
+   return 0;
+}
+
 static int rtl8211f_config(struct phy_device *phydev)
 {
u16 reg;
@@ -386,12 +394,24 @@ static struct phy_driver RTL8211F_driver = {
.writeext = &rtl8211f_phy_extwrite,
 };
 
+/* Support for RTL8201F PHY */
+static struct phy_driver RTL8201F_driver = {
+   .name = "RealTek RTL8201F 10/100Mbps Ethernet",
+   .uid = 0x1cc816,
+   .mask = 0xff,
+   .features = PHY_BASIC_FEATURES,
+   .config = &rtl8201f_config,
+   .startup = &rtl8211e_startup,
+   .shutdown = &genphy_shutdown,
+};
+
 int phy_realtek_init(void)
 {
phy_register(&RTL8211B_driver);
phy_register(&RTL8211E_driver);
phy_register(&RTL8211F_driver);
phy_register(&RTL8211DN_driver);
+   phy_register(&RTL8201F_driver);
 
return 0;
 }
-- 
2.7.4



[PATCH v1 1/7] clk: actions: Add Ethernet clocks

2020-05-09 Thread Amit Singh Tomar
This commit adds clocks needed for ethernet operations for
Actions OWL family of SoCs (S700 and S900).

Signed-off-by: Amit Singh Tomar 
---
 arch/arm/include/asm/arch-owl/regs_s700.h | 2 ++
 arch/arm/include/asm/arch-owl/regs_s900.h | 4 
 drivers/clk/owl/clk_owl.c | 9 +
 drivers/clk/owl/clk_owl.h | 2 --
 4 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/arch/arm/include/asm/arch-owl/regs_s700.h 
b/arch/arm/include/asm/arch-owl/regs_s700.h
index 2f21c15cca8c..90459ae95eeb 100644
--- a/arch/arm/include/asm/arch-owl/regs_s700.h
+++ b/arch/arm/include/asm/arch-owl/regs_s700.h
@@ -53,4 +53,6 @@
 #define CMU_CVBSPLL0x00B8
 #define CMU_SSTSCLK0x00C0
 
+#define CMU_DEVCLKEN1_ETH  BIT(23)
+
 #endif
diff --git a/arch/arm/include/asm/arch-owl/regs_s900.h 
b/arch/arm/include/asm/arch-owl/regs_s900.h
index 9e9106ddaab9..084bc9b8c3fb 100644
--- a/arch/arm/include/asm/arch-owl/regs_s900.h
+++ b/arch/arm/include/asm/arch-owl/regs_s900.h
@@ -61,4 +61,8 @@
 #define CMU_TVOUTPLLDEBUG0 (0x00EC)
 #define CMU_TVOUTPLLDEBUG1 (0x00FC)
 
+#define CMU_DEVCLKEN1_ETH  BIT(22)
+#define CLK_ETHERNET   CLK_ETH_MAC
+#define CMU_ETHERNETPLLCMU_ASSISTPLL
+
 #endif
diff --git a/drivers/clk/owl/clk_owl.c b/drivers/clk/owl/clk_owl.c
index 5607b2b7b516..b80862e17f51 100644
--- a/drivers/clk/owl/clk_owl.c
+++ b/drivers/clk/owl/clk_owl.c
@@ -85,6 +85,11 @@ int owl_clk_enable(struct clk *clk)
/* Enable UART3 interface clock */
setbits_le32(priv->base + CMU_DEVCLKEN1, CMU_DEVCLKEN1_UART3);
break;
+   case CLK_RMII_REF:
+   case CLK_ETHERNET:
+   setbits_le32(priv->base + CMU_DEVCLKEN1, CMU_DEVCLKEN1_ETH);
+   setbits_le32(priv->base + CMU_ETHERNETPLL, 5);
+   break;
default:
return -EINVAL;
}
@@ -110,6 +115,10 @@ int owl_clk_disable(struct clk *clk)
/* Disable UART3 interface clock */
clrbits_le32(priv->base + CMU_DEVCLKEN1, CMU_DEVCLKEN1_UART3);
break;
+   case CLK_RMII_REF:
+   case CLK_ETHERNET:
+   clrbits_le32(priv->base + CMU_DEVCLKEN1, CMU_DEVCLKEN1_ETH);
+   break;
default:
return -EINVAL;
}
diff --git a/drivers/clk/owl/clk_owl.h b/drivers/clk/owl/clk_owl.h
index b8d33624c5f5..a2065a726d46 100644
--- a/drivers/clk/owl/clk_owl.h
+++ b/drivers/clk/owl/clk_owl.h
@@ -59,6 +59,4 @@ struct owl_clk_priv {
 #define CMU_DEVCLKEN1_UART5BIT(21)
 #define CMU_DEVCLKEN1_UART3BIT(11)
 
-#define CMU_DEVCLKEN1_ETH_S700 BIT(23)
-
 #endif
-- 
2.7.4



[PATCH v1 0/7] add Ethernet support for S700

2020-05-09 Thread Amit Singh Tomar
This series adds Ethernet Support Actions Semi OWL S700 SoC.

First patch(1/7) series adds Ethernet clock for S900 and S700, S900
part is just compiled tested.

Patches(from 2/7 and 3/7) adds support for RTL 8201F PHY module and
introduce configuration option "RTL8201F_PHY_S700_RMII_TIMINGS" to
fulfil specific timing requirements for S700.

Patches(from 4/21 to 7/21) are there to enable Ethenet support in S700, MAC
is based on Designware IP.

These patches re-uses the existing driver(drivers/net/designware.c) and
programs SoC specific bits to enable ethernet. SoC specific glue code is
kept in dwmac_s700.c file, did it this way as found it more cleaner but
having done that I am not really sure, if it's bit of a overkill to have
it place in glue code or we can keep this glue code somewhere in machine
file ?

Series is tested on Cubieboard7-lite by tftping all the images needed
to boot Linux.

Amit Singh Tomar (7):
  clk: actions: Add Ethernet clocks
  net: phy: realtek: Add support for RTL8201F PHY module.
  net: phy: realtek: Introduce PHY_RTL8201F_S700_RMII_TIMINGS to adjust
rx/tx timings
  net: designware: s700: Add glue code for S700 mac
  arm: dts: s700: add node for ethernet controller
  owl: Kconfig: Enable DM eth for OWL platform
  configs: Enable mac and phy configs

 arch/arm/Kconfig  |  1 +
 arch/arm/dts/s700-u-boot.dtsi | 13 ++
 arch/arm/include/asm/arch-owl/regs_s700.h |  8 
 arch/arm/include/asm/arch-owl/regs_s900.h |  4 ++
 configs/cubieboard7_defconfig |  4 ++
 drivers/clk/owl/clk_owl.c |  9 +
 drivers/clk/owl/clk_owl.h |  2 -
 drivers/net/Kconfig   |  7 
 drivers/net/Makefile  |  1 +
 drivers/net/dwmac_s700.c  | 66 +++
 drivers/net/phy/Kconfig   |  9 +
 drivers/net/phy/realtek.c | 55 ++
 12 files changed, 177 insertions(+), 2 deletions(-)
 create mode 100644 drivers/net/dwmac_s700.c

-- 
2.7.4



[PATCH v4 0/2] Calculate SDRAM size for Actions OWL SoCs

2020-05-09 Thread Amit Singh Tomar
Mani pointed out that changes in previous version were not good enough
for S900 and he provide snippet that seems to work on S900.

This series v4 fixes the S900 Support by taking in changes suggested
by Mani. 

-
 
Realized that sent the wrong version(v2) that has typos and didn't get
compile for S900. Just fixed this in v3.

This small series allows us to calculate SDRAM size instead
of guessing it.

Patch (1/2) is re-worked to support S900 SoC along with S700.

These changes have been tested on S700 based Cubieboard7-lite board, and
it would be great if this can be tested on S900.

Amit Singh Tomar (2):
  Actions: OWL: Calculate SDRAM size
  arm: actions: remove "CONFIG_SYS_SDRAM_SIZE" for Actions Owl Semi SoCs

 arch/arm/mach-owl/soc.c  | 22 +-
 include/configs/owl-common.h |  1 -
 2 files changed, 21 insertions(+), 2 deletions(-)

-- 
2.7.4



[PATCH v4 1/2] Actions: OWL: Calculate SDRAM size

2020-05-09 Thread Amit Singh Tomar
Calculate the SDRAM size from DDR capacity register registers instead
of using hard-coded value. This is quite useful to get correct size
on differnt boards based on Actions OWL family of SoCs (S700 and S900).

There is no documentation available that talks about DDR registers, and
this is very much taken from vendor source.

This commit lets Linux boot on Cubieboard7-lite(based on S700).

Signed-off-by: Amit Singh Tomar 
---
Changes since v3:
* Fixed S900 support as suggested by Mani.
* Changes the function name to owl_get_ddrcap.
Changes since v2:
* Fixed the variable name so that it can compile
  for S900. 
Changes since v1:
* added support for S900
* updated the commit message to reflect common OWL
  support.
---
 arch/arm/mach-owl/soc.c | 22 +-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-owl/soc.c b/arch/arm/mach-owl/soc.c
index 409cbd319f20..fcf61d39b63a 100644
--- a/arch/arm/mach-owl/soc.c
+++ b/arch/arm/mach-owl/soc.c
@@ -13,14 +13,34 @@
 #include 
 #include 
 
+#define DMM_INTERLEAVE_PER_CH_CFG  0xe0290028
+
 DECLARE_GLOBAL_DATA_PTR;
 
+unsigned int owl_get_ddrcap(void)
+{
+   unsigned int val, cap;
+
+   /* ddr capacity register initialized by ddr driver
+* in early bootloader
+*/
+#if defined(CONFIG_MACH_S700)
+   val = (readl(DMM_INTERLEAVE_PER_CH_CFG) >> 8) & 0x7;
+   cap =  (val + 1) * 256;
+#elif defined(CONFIG_MACH_S900)
+   val = (readl(DMM_INTERLEAVE_PER_CH_CFG) >> 8) & 0xf;
+   cap =  64 * (1 << val);
+#endif
+
+   return cap;
+}
+
 /*
  * dram_init - sets uboots idea of sdram size
  */
 int dram_init(void)
 {
-   gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
+   gd->ram_size = owl_get_ddrcap() * 1024 * 1024;
return 0;
 }
 
-- 
2.7.4



[PATCH v4 2/2] arm: actions: remove "CONFIG_SYS_SDRAM_SIZE" for Actions Owl Semi SoCs

2020-05-09 Thread Amit Singh Tomar
Now that, we calculate SDRAM size by reading DDR registers,
"CONFIG_SYS_SDRAM_SIZE" is no more needed.

This commit removes "CONFIG_SYS_SDRAM_SIZE" from common configuration
file.

Signed-off-by: Amit Singh Tomar 
---
* No change since previous version.
---
 include/configs/owl-common.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/include/configs/owl-common.h b/include/configs/owl-common.h
index f77a5fa4c114..7634578f856d 100644
--- a/include/configs/owl-common.h
+++ b/include/configs/owl-common.h
@@ -12,7 +12,6 @@
 
 /* SDRAM Definitions */
 #define CONFIG_SYS_SDRAM_BASE  0x0
-#define CONFIG_SYS_SDRAM_SIZE  0x8000
 
 /* Generic Timer Definitions */
 #define COUNTER_FREQUENCY  (2400)  /* 24MHz */
-- 
2.7.4



[PATCH v3 2/2] arm: actions: remove "CONFIG_SYS_SDRAM_SIZE" for Actions Owl Semi SoCs

2020-05-09 Thread Amit Singh Tomar
Now that, we calculate SDRAM size by reading DDR registers,
"CONFIG_SYS_SDRAM_SIZE" is no more needed.

This commit removes "CONFIG_SYS_SDRAM_SIZE" from common configuration
file.

Signed-off-by: Amit Singh Tomar 
---
* No change from previous versions.
---
 include/configs/owl-common.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/include/configs/owl-common.h b/include/configs/owl-common.h
index f77a5fa4c114..7634578f856d 100644
--- a/include/configs/owl-common.h
+++ b/include/configs/owl-common.h
@@ -12,7 +12,6 @@
 
 /* SDRAM Definitions */
 #define CONFIG_SYS_SDRAM_BASE  0x0
-#define CONFIG_SYS_SDRAM_SIZE  0x8000
 
 /* Generic Timer Definitions */
 #define COUNTER_FREQUENCY  (2400)  /* 24MHz */
-- 
2.7.4



[PATCH v3 1/2] Actions: OWL: Calculate SDRAM size

2020-05-09 Thread Amit Singh Tomar
Calculate the SDRAM size from DDR capacity register registers instead
of using hard-coded value. This is quite useful to get correct size
on differnt boards based on Actions OWL family of SoCs (S700 and S900).

There is no documentation available that talks about DDR registers, and
this is very much taken from vendor source.

This commit lets Linux boot on Cubieboard7-lite(based on S700).

Signed-off-by: Amit Singh Tomar 
---
Changes since v2:
* Fixed the variable name so that it can compile
  for S900. 
Changes since v1:
* added support for S900
* updated the commit message to reflect common OWL
  support.
---
 arch/arm/mach-owl/soc.c | 27 ++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-owl/soc.c b/arch/arm/mach-owl/soc.c
index 409cbd319f20..2b2b0226cdb2 100644
--- a/arch/arm/mach-owl/soc.c
+++ b/arch/arm/mach-owl/soc.c
@@ -13,15 +13,40 @@
 #include 
 #include 
 
+#define DMM_INTERLEAVE_BASE (0xe0290020)
+#define DMM_INTERLEAVE_PER_CH_CFG   (DMM_INTERLEAVE_BASE +  0x08)
+#define DMM_MASTER_READ_TO  (DMM_INTERLEAVE_BASE +  0x48)
+
 DECLARE_GLOBAL_DATA_PTR;
 
+unsigned int get_owl_ram_size(void)
+{
+   __maybe_unused unsigned int val, cap, channel, channel_num;
+
+   /* ddr capacity register initialized by ddr driver
+* in early bootloader
+*/
+#if defined(CONFIG_MACH_S700)
+   val = (readl(DMM_INTERLEAVE_PER_CH_CFG) >> 8) & 0x7;
+   cap =  (val + 1) * 256;
+#elif defined(CONFIG_MACH_S900)
+   channel_num = (readl(DMM_INTERLEAVE_BASE) >> 24) & 0xf;
+   channel = (channel_num >= 3) ? 1 : 0;
+   val = (readl(DMM_MASTER_READ_TO)) & 0xf;
+   cap = ((val + 1) << channel) * 256;
+#endif
+
+   return cap;
+}
+
 /*
  * dram_init - sets uboots idea of sdram size
  */
 int dram_init(void)
 {
-   gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
+   gd->ram_size = get_owl_ram_size() * 1024 * 1024;
return 0;
+
 }
 
 /* This is called after dram_init() so use get_ram_size result */
-- 
2.7.4



[PATCH v3 0/2] Calculate SDRAM size for Actions OWL SoCs

2020-05-09 Thread Amit Singh Tomar
Realized that sent the wrong version(v2) that has typos and didn't get
compile for S900. Just fixed this in v3.

Sorry for the noise.
--

This small series allows us to calculate SDRAM size instead
of guessing it.

Patch (1/2) is re-worked to support S900 SoC along with S700.

These changes have been tested on S700 based Cubieboard7-lite board, and
it would be great if this can be tested on S900. 


Amit Singh Tomar (2):
  Actions: OWL: Calculate SDRAM size
  arm: actions: remove "CONFIG_SYS_SDRAM_SIZE" for Actions Owl Semi SoCs

 arch/arm/mach-owl/soc.c  | 27 ++-
 include/configs/owl-common.h |  1 -
 2 files changed, 26 insertions(+), 2 deletions(-)

-- 
2.7.4



[PATCH v2 1/2] Actions: OWL: Calculate SDRAM size

2020-05-08 Thread Amit Singh Tomar
Calculate the SDRAM size from DDR capacity register registers instead
of using hard-coded value. This is quite useful to get correct size
on differnt boards based on Actions OWL family of SoCs (S700 and S900).

There is no documentation available that talks about DDR registers, and
this is very much taken from vendor source.

This commit lets Linux boot on Cubieboard7-lite(based on S700).

Signed-off-by: Amit Singh Tomar 
---
Changes since v1:
* added support for S900
* updated the commit message to reflect common OWL
  support.
---
 arch/arm/mach-owl/soc.c | 27 ++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mach-owl/soc.c b/arch/arm/mach-owl/soc.c
index 409cbd319f20..2ae357e3672a 100644
--- a/arch/arm/mach-owl/soc.c
+++ b/arch/arm/mach-owl/soc.c
@@ -13,15 +13,40 @@
 #include 
 #include 
 
+#define DMM_INTERLEAVE_BASE (0xe0290020)
+#define DMM_INTERLEAVE_PER_CH_CFG   (DMM_INTERLEAVE_BASE +  0x08)
+#define DMM_MASTER_READ_TO  (DMM_INTERLEAVE_BASE +  0x48)
+
 DECLARE_GLOBAL_DATA_PTR;
 
+unsigned int get_owl_ram_size(void)
+{
+   __maybe_unused unsigned int val, cap, channel, channel_num;
+
+   /* ddr capacity register initialized by ddr driver
+* in early bootloader
+*/
+#if defined(CONFIG_MACH_S700)
+   val = (readl(DMM_INTERLEAVE_PER_CH_CFG) >> 8) & 0x7;
+   cap =  (val + 1) * 256;
+#elif defined(CONFIG_MACH_S900)
+   chennel_num = (readl(DMM_INTERLEAVE_BASE) >> 24) & 0xf;
+   channel = (ch_num >= 3) ? 1 : 0;
+   val = (readl(DMM_MASTER_READ_TO)) & 0xf;
+   cap = ((val + 1) << channel) * 256;
+#endif
+
+   return cap;
+}
+
 /*
  * dram_init - sets uboots idea of sdram size
  */
 int dram_init(void)
 {
-   gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
+   gd->ram_size = get_owl_ram_size() * 1024 * 1024;
return 0;
+
 }
 
 /* This is called after dram_init() so use get_ram_size result */
-- 
2.7.4



[PATCH v2 0/2] Calculate SDRAM size for Actions OWL SoCs

2020-05-08 Thread Amit Singh Tomar
This small series allows us to calculate SDRAM size instead
of guessing it.

Patch (1/2) is re-worked to support S900 SoC along with S700.

These changes have been tested on S700 based Cubieboard7-lite board, and
it would be great if this can be tested on S900. 

Amit Singh Tomar (2):
  Actions: OWL: Calculate SDRAM size
  arm: actions: remove "CONFIG_SYS_SDRAM_SIZE" for Actions Owl Semi SoCs

 arch/arm/mach-owl/soc.c  | 27 ++-
 include/configs/owl-common.h |  1 -
 2 files changed, 26 insertions(+), 2 deletions(-)

-- 
2.7.4



[PATCH v2 2/2] arm: actions: remove "CONFIG_SYS_SDRAM_SIZE" for Actions Owl Semi SoCs

2020-05-08 Thread Amit Singh Tomar
Now that, we calculate SDRAM size by reading DDR registers,
"CONFIG_SYS_SDRAM_SIZE" is no more needed.

This commit removes "CONFIG_SYS_SDRAM_SIZE" from common configuration
file.

Signed-off-by: Amit Singh Tomar 
---
 include/configs/owl-common.h | 1 -
 1 file changed, 1 deletion(-)

diff --git a/include/configs/owl-common.h b/include/configs/owl-common.h
index f77a5fa4c114..7634578f856d 100644
--- a/include/configs/owl-common.h
+++ b/include/configs/owl-common.h
@@ -12,7 +12,6 @@
 
 /* SDRAM Definitions */
 #define CONFIG_SYS_SDRAM_BASE  0x0
-#define CONFIG_SYS_SDRAM_SIZE  0x8000
 
 /* Generic Timer Definitions */
 #define COUNTER_FREQUENCY  (2400)  /* 24MHz */
-- 
2.7.4



[PATCH] Actions: S700 Calculate SDRAM size

2020-05-02 Thread Amit Singh Tomar
Calculate the SDRAM size from DDR capacity register registers instead of using
hard-coded value. This is quite useful to get correct size on differnt boards
based on S700 SoC.

There is no documentation available that talks about DDR registers, and this
is very much taken from vendor source.

This commit lets Linux boot on Cubieboard7-lite (based on S700).

Signed-off-by: Amit Singh Tomar 
---
There is bit of a story about it:
 
Wasn't really aware that working on a board (CubieBoard7-Lite) that actually
has only 1GB of RAM untill I see the Kernel crash[1], and DDR size is
hard-coded to 2GB(as CubieBoard7 comes with 2 GB). With this set-up Kernel
was trying to access the memory that doesn't exist leads to the crash.

[1]:
 
Starting kernel ...

[0.00] Booting Linux on physical CPU 0x00 [0x410fd034]
[0.00] Linux version 5.6.0-rc6-00012-g7080a8a-dirty 
(amit@amit-ThinkPad-X230) (gcc version 7.3.1 20180425 [linaro-7.3-2018.05 
revision d29120a424ecfbc167ef90065c0eeb7f91977701] (Linaro GCC 7.3-2018.05)) 
#10 SMP PREEMPT Fri Mar 27 21:52:07 IST 2020
[0.00] Machine model: CubieBoard7
[0.00] earlycon: owl0 at MMIO 0xe0126000 (options '')
[0.00] printk: bootconsole [owl0] enabled
[0.00] efi: Getting EFI parameters from FDT:
[0.00] efi: UEFI not found.
[0.00] cma: Reserved 32 MiB at 0x7e00
[0.00] NUMA: No NUMA configuration found
[0.00] NUMA: Faking a node at [mem 
0x-0x7fff]
[0.00] NUMA: NODE_DATA [mem 0x7dbfb100-0x7dbfcfff]
[0.00] Zone ranges:
[0.00]   DMA  [mem 0x-0x3fff]
[0.00]   DMA32[mem 0x4000-0x7fff]
[0.00]   Normal   empty
[0.00] Movable zone start for each node
[0.00] Early memory node ranges
[0.00]   node   0: [mem 0x-0x1eff]
[0.00]   node   0: [mem 0x2000-0x7fff]
[0.00] Initmem setup node 0 [mem 0x-0x7fff]
[0.00] psci: probing for conduit method from DT.
[0.00] psci: PSCIv0.2 detected in firmware.
[0.00] psci: Using standard PSCI v0.2 function IDs
[0.00] psci: Trusted OS migration not required
[0.00] percpu: Embedded 23 pages/cpu s53272 r8192 d32744 u94208
[0.00] Detected VIPT I-cache on CPU0
[0.00] CPU features: detected: ARM erratum 845719
[0.00] Built 1 zonelists, mobility grouping on.  Total pages: 512000
[0.00] Policy zone: DMA32
[0.00] Kernel command line: console=ttyOWL,115200 
earlycon=owl,0xe0126000 root=/dev/mmcblk0p2
[0.00] Dentry cache hash table entries: 262144 (order: 9, 2097152 
bytes, linear)
[0.00] Inode-cache hash table entries: 131072 (order: 8, 1048576 bytes, 
linear)
[0.00] mem auto-init: stack:off, heap alloc:off, heap free:off
[0.00] Unable to handle kernel paging request at virtual address 
3de18000
[0.00] Mem abort info:
[0.00]   ESR = 0x9647
[0.00]   EC = 0x25: DABT (current EL), IL = 32 bits
[0.00]   SET = 0, FnV = 0
[0.00]   EA = 0, S1PTW = 0
[0.00] Data abort info:
[0.00]   ISV = 0, ISS = 0x0047
[0.00]   CM = 0, WnR = 1
[0.00] swapper pgtable: 4k pages, 48-bit VAs, pgdp=01399000
  
---
 arch/arm/mach-owl/soc.c | 23 +++
 1 file changed, 23 insertions(+)

diff --git a/arch/arm/mach-owl/soc.c b/arch/arm/mach-owl/soc.c
index 409cbd3..f63f1a8 100644
--- a/arch/arm/mach-owl/soc.c
+++ b/arch/arm/mach-owl/soc.c
@@ -13,15 +13,38 @@
 #include 
 #include 
 
+#define DMM_INTERLEAVE_PER_CH_CFG   (0xe0290028)
+
 DECLARE_GLOBAL_DATA_PTR;
 
+unsigned int get_owl_ram_size(void)
+{
+   unsigned int val, cap;
+
+   /* ddr capacity register initialized by ddr driver
+* in early bootloader
+* DMM_INTERLEAVE_PER_CH_CFG  bit[10:8]
+* (val + 1) * 256
+*/
+   val = (readl(DMM_INTERLEAVE_PER_CH_CFG) >> 8) & 0x7;
+   cap =  (val + 1) * 256;
+
+   return cap;
+}
+
 /*
  * dram_init - sets uboots idea of sdram size
  */
 int dram_init(void)
 {
gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
+
+#if defined(CONFIG_MACH_S700)
+   gd->ram_size = get_owl_ram_size() * 1024 * 1024;
+#endif
+
return 0;
+
 }
 
 /* This is called after dram_init() so use get_ram_size result */
-- 
2.7.4



[PATCH v11 00/13] Actions S700 SoC support

2020-04-19 Thread Amit Singh Tomar
This adds Cubieboard7[1] support based on Action Semi's S700 SoC[2], It's 
Quad-core ARMv8 SoC
with Cortex-A53 cores. Peripheral like UART seems to be compatible with S900 
SoC(basic support
for it is alreay present in u-boot).

This series(v11) takes care of the issues(breaks few boards unfortunately) 
pointed out by Tom.
Changes has been made to patches 10/13 and 11/13 and some of config options is 
moved from
arch/arm/mach-owl/Kconfig to appropriate config files.

Apart from it, new patch 13/13 is added that updates MAINTAINER file with 
cubieboard7_defconfig
entry.

Previous series(v10) takes care the commments provided by Mani and patches 
04/12, 07/12 and 12/12
has been changed to address those comments. 

Series(v9) fixes a Bug that breaks bubblegum96 board boot(reported by Mani). It 
was
due to fact that driver data read is not proper in the clock driver. There are 
changes in
patch 06/12 to fix it.

Series(v8) removes the SoC specific include instead just uses owl-common. For 
this
patch 01/12 and 09/12 changes a bit.

Series(v7) fixes a serious Bug that breaks S900, it was there since v5.Thanks 
to Andre
for pointing it out.

Series(v6)[3] does following changes:

* [PATCH v5 06/11] becomes [PATCH v6 03/11]
* [PATCH v5 03/11] becomes [PATCH v6 04/11]
* Introduce a new patch to move defconfig options to Kconfig which is [PATCH v6 
10/12]

Series(v5)[4] just re-orders the patches so that U-BOOT(with 
bubblegum96_defconfig) builds
after every patch of the series(suggested by Andre).

S700 support is tested[5] on Cubieboard7-lite board and S900 support is just 
compiled tested.

This patch series can be tested using below tree:
https://github.com/Atomar25/u-boot/commits/s700_v11

[1]: http://www.cubietech.com/product-detail/cubieboard7/
[2]: http://www.actions-semi.com/en/productview.aspx?id=225
[3]: 
http://u-boot.10912.n7.nabble.com/PATCH-v6-00-12-Actions-S700-SoC-support-td403562.html#a403567
[4]: 
http://u-boot.10912.n7.nabble.com/PATCH-v5-00-11-Actions-S700-SoC-support-td402752.html#a402762
[5]: https://paste.ubuntu.com/p/4nhCWryRNR/

Amit Singh Tomar (13):
  arm: actions: Add common framework for Actions Owl Semi SoCs
  arm: actions: rename sysmap-s900 to sysmap-owl
  serial: actions: add compatible string
  arm: dts: sync dts for Action Semi S900
  arm: dts: actions: s900: add u-boot specific dtsi file
  clk: actions: Add common clock driver
  arm: actions: add S700 SoC device tree
  arm: dts: actions: s700: add u-boot specific dtsi file
  arm: add support Actions Semi S700
  actions: Move defconfig options to Kconfig
  arm: add Cubieboard7 board support
  doc: boards: add Cubieboard7 documentation
  MAINTAINERS: add entry for cubieboard7 config

 Kconfig|   2 +-
 MAINTAINERS|   4 +-
 arch/arm/Kconfig   |   6 +-
 arch/arm/dts/Makefile  |   4 +-
 arch/arm/dts/s700-cubieboard7.dts  |  92 +++
 arch/arm/dts/s700-u-boot.dtsi  |  18 ++
 arch/arm/dts/s700.dtsi | 248 +++
 arch/arm/dts/s900-u-boot.dtsi  |  17 ++
 arch/arm/dts/s900.dtsi | 322 +++--
 arch/arm/include/asm/arch-owl/clk_s900.h   |  57 -
 arch/arm/include/asm/arch-owl/regs_s700.h  |  56 +
 arch/arm/mach-owl/Kconfig  |  34 +--
 arch/arm/mach-owl/Makefile |   3 +-
 arch/arm/mach-owl/soc.c|  57 +
 arch/arm/mach-owl/sysmap-owl.c |  32 +++
 arch/arm/mach-owl/sysmap-s900.c|  32 ---
 board/ucRobotics/bubblegum_96/Kconfig  |  15 --
 board/ucRobotics/bubblegum_96/MAINTAINERS  |   6 -
 board/ucRobotics/bubblegum_96/Makefile |   3 -
 board/ucRobotics/bubblegum_96/bubblegum_96.c   |  57 -
 configs/bubblegum_96_defconfig |   9 +-
 configs/cubieboard7_defconfig  |  12 +
 doc/board/actions/cubieboard7.rst  | 114 +
 doc/board/actions/index.rst|  10 +
 doc/board/index.rst|   1 +
 drivers/clk/owl/Kconfig|   8 +-
 drivers/clk/owl/Makefile   |   2 +-
 drivers/clk/owl/clk_owl.c  | 155 
 drivers/clk/owl/clk_owl.h  |  64 +
 drivers/clk/owl/clk_s900.c | 137 ---
 drivers/serial/serial_owl.c|   2 +-
 include/configs/bubblegum_96.h |  40 ---
 include/configs/owl-common.h   |  40 +++
 include/dt-bindings/clock/actions,s700-cmu.h   | 118 +
 include/dt-bindings/clock/actions,s900-cmu.h   | 129 ++
 include/dt-bindings/clock/s900_cmu.h   |  77 --
 include/dt-bindings/reset/actions,s700-reset.h |  34 +++
 include/dt-bindings/reset/actions,s900-reset.h |  65 +

[PATCH v11 12/13] doc: boards: add Cubieboard7 documentation

2020-04-19 Thread Amit Singh Tomar
This adds build and flash steps for Actions S700
based Cubieboard7 board.

Reviewed-by: Manivannan Sadhasivam 
Signed-off-by: Amit Singh Tomar 
---
Changes since v10:
* Added Mani's reviewed-by Tag.
Changes since v9:
* Updated the heading to CUBIEBOARD7 to ACTIONS.
* Added shorthand for mkimage command.
Changes since v8:
* No changes.
Changes since v7:
* No changes.
Changes since v6:
* No changes.
Changes since v5:
* No changes.
Changes since v4:
* No changes.
Changes since v3:
* Convert plain text documentation to reStructuredText format.
Changes since v2:
* No Change.
Changes since v1:
* No Change.
---
 doc/board/actions/cubieboard7.rst | 114 ++
 doc/board/actions/index.rst   |  10 
 doc/board/index.rst   |   1 +
 3 files changed, 125 insertions(+)
 create mode 100644 doc/board/actions/cubieboard7.rst
 create mode 100644 doc/board/actions/index.rst

diff --git a/doc/board/actions/cubieboard7.rst 
b/doc/board/actions/cubieboard7.rst
new file mode 100644
index 000..e01d2d0
--- /dev/null
+++ b/doc/board/actions/cubieboard7.rst
@@ -0,0 +1,114 @@
+.. SPDX-License-Identifier: GPL-2.0+
+.. Copyright (C) 2020 Amit Singh Tomar 
+
+CUBIEBOARD7
+===
+
+About this
+--
+
+This document describes build and flash steps for Actions S700 SoC based 
Cubieboard7
+board.
+
+Cubieboard7 initial configuration
+-
+
+Default Cubieboard7 comes with pre-installed Android where U-Boot is 
configured with
+a bootdelay of 0, entering a prompt by pressing keys does not seem to work.
+
+Though, one can enter ADFU mode and flash debian image(from host machine) where
+getting into u-boot prompt is easy.
+
+Enter ADFU Mode
+
+
+Before write the firmware, let the development board entering the ADFU mode: 
insert
+one end of the USB cable to the PC, press and hold the ADFU button, and then 
connect
+the other end of the USB cable to the Mini USB port of the development board, 
release
+the ADFU button, after connecting it will enter the ADFU mode.
+
+Check whether entered ADFU Mode
+
+
+The user needs to run the following command on the PC side to check if the ADFU
+device is detected. ID realted to "Actions Semiconductor Co., Ltd"  means that
+the PC side has been correctly detected ADFU device, the development board
+also enter into the ADFU mode.
+
+.. code-block:: none
+
+   $ lsusb
+   Bus 001 Device 005: ID 04f2:b2eb Chicony Electronics Co., Ltd
+   Bus 001 Device 004: ID 0a5c:21e6 Broadcom Corp. BCM20702 Bluetooth 4.0 
[ThinkPad]
+   Bus 001 Device 003: ID 046d:c534 Logitech, Inc. Unifying Receiver
+   Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
+   Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
+   Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
+   Bus 003 Device 013: ID 10d6:10d6 Actions Semiconductor Co., Ltd
+   Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
+
+Flashing debian image
+-
+
+.. code-block:: none
+
+   $ sudo ./ActionsFWU.py --fw=debian-stretch-desktop-cb7-emmc-v2.0.fw
+   ActionsFWU.py   : 1.0.150828.0830
+   libScript.so: 2.3.150825.0951
+   libFileSystem.so: 2.3.150825.0952
+   libProduction.so: 2.3.150915.1527
+   =burn all partition
+   FW_VER: 3.10.37.180608
+   3% DOWNLOAD ADFUDEC ...
+   5% DOWNLOAD BOOT PARA ...
+   7% SWITCH ADFUDEC ...
+   12% DOWNLOAD BL31 ...
+   13% DOWNLOAD BL32 ...
+   15% DOWNLOAD VMLINUX ...
+   20% DOWNLOAD INITRD ...
+   24% DOWNLOAD FDT ...
+   27% DOWNLOAD ADFUS ...
+   30% SWITCH ADFUS ...
+   32% DOWNLOAD MBR ...
+   35% DOWNLOAD PARTITIONS ...
+   WRITE_MBRC_PARTITION
+   35% write p0 size = 2048 : ok
+   WRITE_BOOT_PARTITION
+   35% write p1 size = 2048 : ok
+   WRITE_MISC_PARTITION
+   36% write p2 size = 98304 : ok
+   WRITE_SYSTEM_PARTITION
+   94% write p3 size = 4608000 : ok
+   FORMAT_SWAP_PARTITION
+   94% write p4 size = 20480 : ok
+   95% TRANSFER OVER ...
+   Firmware upgrade successfully!
+
+Debian image can be downloaded from here[1].
+
+Once debian image is flashed, one can get into u-boot prompt by pressing any 
key and from
+there run ums command(make sure, usb cable is connected between host and 
target):
+
+.. code-block:: none
+
+   owl> ums 0 mmc 1
+
+Above command would mount debian image partition on host machine.
+
+Building U-BOOT proper image
+
+
+.. code-block:: none
+
+   $ make clean
+   $ export CROSS_COMPILE=aarch64-linux-gnu-
+   $ make ARCH=arm cubieboard7_defconfig
+   $ make u-boot-dtb.img -j16
+
+u-boot-dtb.img can now be flashed to debian image partition mounted on host 
machine.
+
+.. code-block:: none
+
+   $ sudo dd if=u-boot-dtb.img of=/dev/sdb bs=1024 seek=3072
+
+[1]: 
https://pan.baidu.com/s/1uawPr0Jao2HgWFLZCLzHAg#list/path=%2FC

[PATCH v11 13/13] MAINTAINERS: add entry for cubieboard7 config

2020-04-19 Thread Amit Singh Tomar
This commit adds entry for cubieboard7 config under Actions Semi
OWL family.

Signed-off-by: Amit Singh Tomar 
---
* Newly added patch, was not there in earlier versions.

Hi Mani,

Hope, this is file with you to have this under ARCH_OWL?
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index cae7004..31c6e6b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -276,6 +276,7 @@ F:  drivers/clk/owl/
 F: drivers/serial/serial_owl.c
 F: include/configs/owl-common.h
 F: configs/bubblegum_96_defconfig
+F: configs/cubieboard7_defconfig
 
 ARM RENESAS RMOBILE/R-CAR
 M: Nobuhiro Iwamatsu 
-- 
2.7.4



[PATCH v11 07/13] arm: actions: add S700 SoC device tree

2020-04-19 Thread Amit Singh Tomar
This patch adds .dtsi file(sync with Linux 5.5-rc6 with hash "b3a987b0264d")
and required binding for S700 SoC that is a 64-bit Quad-core ARM
Cortex-A53 cores.

It also provisions dts file to be built based on selected
platform(CONFIG_MACH_S900/S700).

Reviewed-by: Manivannan Sadhasivam 
Reviewed-by: Andre Przywara 
Signed-off-by: Amit Singh Tomar 
---
Changes since v10:
* No change.
Changes since v9:
* Moved changes(that enables bubblegum-96 DT build) to patch 04/12.
Changes since v8:
* No changes.
Changes since v7:
* No changes.
Changes since v6:
* No changes.
Changes since v5:
* Added reviwed-by tag.
Changes since v4:
* Move it to 07/11 from 05/11.
Changes since v3:
* Updated commit message to the Linux tag to
  which the dtsi file is synced.
Changes since v2:
* Synced DTS bindings with Linux 5.5.
Changes since v1:
* Moved the u-boot specific changes to s700-u-boot.dtsi, now
  s700.dtsi is in complete sync with Linux 4.20.
---
 arch/arm/dts/Makefile  |   2 +
 arch/arm/dts/s700.dtsi | 248 +
 include/dt-bindings/clock/actions,s700-cmu.h   | 118 
 include/dt-bindings/reset/actions,s700-reset.h |  34 
 4 files changed, 402 insertions(+)
 create mode 100644 arch/arm/dts/s700.dtsi
 create mode 100644 include/dt-bindings/clock/actions,s700-cmu.h
 create mode 100644 include/dt-bindings/reset/actions,s700-reset.h

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 7f35cc0..0eeb62f 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -66,6 +66,8 @@ dtb-$(CONFIG_KIRKWOOD) += \
 
 dtb-$(CONFIG_MACH_S900) += \
bubblegum_96.dtb
+dtb-$(CONFIG_MACH_S700) += \
+   s700-cubieboard7.dtb
 
 dtb-$(CONFIG_ROCKCHIP_PX30) += \
px30-evb.dtb \
diff --git a/arch/arm/dts/s700.dtsi b/arch/arm/dts/s700.dtsi
new file mode 100644
index 000..2006ad5
--- /dev/null
+++ b/arch/arm/dts/s700.dtsi
@@ -0,0 +1,248 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2017 Andreas Färber
+ */
+
+#include 
+#include 
+#include 
+
+/ {
+   compatible = "actions,s700";
+   interrupt-parent = <&gic>;
+   #address-cells = <2>;
+   #size-cells = <2>;
+
+   cpus {
+   #address-cells = <2>;
+   #size-cells = <0>;
+
+   cpu0: cpu@0 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x0>;
+   enable-method = "psci";
+   };
+
+   cpu1: cpu@1 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x1>;
+   enable-method = "psci";
+   };
+
+   cpu2: cpu@2 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x2>;
+   enable-method = "psci";
+   };
+
+   cpu3: cpu@3 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x3>;
+   enable-method = "psci";
+   };
+   };
+
+   reserved-memory {
+   #address-cells = <2>;
+   #size-cells = <2>;
+   ranges;
+
+   secmon@1f00 {
+   reg = <0x0 0x1f00 0x0 0x100>;
+   no-map;
+   };
+   };
+
+   psci {
+   compatible = "arm,psci-0.2";
+   method = "smc";
+   };
+
+   arm-pmu {
+   compatible = "arm,cortex-a53-pmu";
+   interrupts = ,
+,
+,
+;
+   interrupt-affinity = <&cpu0>, <&cpu1>, <&cpu2>, <&cpu3>;
+   };
+
+   timer {
+   compatible = "arm,armv8-timer";
+   interrupts = ,
+,
+,
+;
+   };
+
+   hosc: hosc {
+   compatible = "fixed-clock";
+   clock-frequency = <2400>;
+   #clock-cells = <0>;
+   };
+
+   losc: losc {
+   compatible = "fixed-clock";
+   clock-frequency = <32768>;
+   #clock-cells = <0>;
+   };
+
+   soc {
+   compatible = "simple-bus";
+   #address-cel

[PATCH v11 10/13] actions: Move defconfig options to Kconfig

2020-04-19 Thread Amit Singh Tomar
This patch moves some of the config options from bubblegum_96_defconfig
to respective Kconfig files.

Signed-off-by: Amit Singh Tomar 
---
Changes since v10:
* Moved out some of config options from mach-owl/Kconfig
  to appropriate config files.
Changes since v9:
* Added Reviewed-by tag from Mani.
Changes since v8:
* No changes.
Changes since v7:
* No changes.
Changes since v6:
* remove unnecessary string from SYS_PROMPT.
Changes since v5:
* Newly added patch, was not there in earlier versions.
---
 Kconfig| 2 +-
 arch/arm/Kconfig   | 1 +
 configs/bubblegum_96_defconfig | 2 --
 3 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/Kconfig b/Kconfig
index 8bae87e..663ca15 100644
--- a/Kconfig
+++ b/Kconfig
@@ -111,7 +111,7 @@ config ENV_VARS_UBOOT_CONFIG
 
 config NR_DRAM_BANKS
int "Number of DRAM banks"
-   default 1 if ARCH_SUNXI
+   default 1 if ARCH_SUNXI || ARCH_OWL
default 4
help
  This defines the number of DRAM banks.
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 84499b3..dd1649c 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -879,6 +879,7 @@ config ARCH_OWL
select CLK
select CLK_OWL
select OF_CONTROL
+   select CONFIG_SYS_RELOC_GD_ENV_ADDR
imply CMD_DM
 
 config ARCH_QEMU
diff --git a/configs/bubblegum_96_defconfig b/configs/bubblegum_96_defconfig
index e76e9a2..2228faf 100644
--- a/configs/bubblegum_96_defconfig
+++ b/configs/bubblegum_96_defconfig
@@ -1,7 +1,6 @@
 CONFIG_ARM=y
 CONFIG_ARCH_OWL=y
 CONFIG_ENV_SIZE=0x2000
-CONFIG_NR_DRAM_BANKS=1
 CONFIG_MACH_S900=y
 CONFIG_IDENT_STRING="\nBubblegum-96"
 CONFIG_DISTRO_DEFAULTS=y
@@ -16,4 +15,3 @@ CONFIG_CMD_MEMINFO=y
 CONFIG_CMD_CACHE=y
 CONFIG_CMD_TIMER=y
 CONFIG_DEFAULT_DEVICE_TREE="bubblegum_96"
-CONFIG_SYS_RELOC_GD_ENV_ADDR=y
-- 
2.7.4



[PATCH v11 11/13] arm: add Cubieboard7 board support

2020-04-19 Thread Amit Singh Tomar
The Cubieboard is a single board computer containing a
Actions S700 SoC(with 4 ARMv8 Cortex-A53 cores).

This patch adds respective defconfig alongwith .dts(copied
from Linux v5.5-rc6 with hash "b3a987b0264d").

Signed-off-by: Amit Singh Tomar 
---
Changes since v10:
Brought back following option to cubieboard7 defconfig
* CONFIG_DISTRO_DEFAULTS 
* CONFIG_DISPLAY_BOARDINFO
* CONFIG_SYS_PROMPT
Changes since v9:
* Added Reviewed-by tag from Mani.
Changes since v8:
* No changes.
Changes since v7:
* No changes.
Changes since v6:
* Added Reviewed-by tag.
Changes since v5:
* Trimmed of the cubieboard7_defconfig.
Changes since v4:
* No changes.
Changes since v3:
* added reviewed-by: tag.
Changes since v2:
* No changes.
Changes since v1:
* No changes.
---
 arch/arm/dts/s700-cubieboard7.dts | 92 +++
 configs/cubieboard7_defconfig | 12 +
 2 files changed, 104 insertions(+)
 create mode 100644 arch/arm/dts/s700-cubieboard7.dts
 create mode 100644 configs/cubieboard7_defconfig

diff --git a/arch/arm/dts/s700-cubieboard7.dts 
b/arch/arm/dts/s700-cubieboard7.dts
new file mode 100644
index 000..63e375c
--- /dev/null
+++ b/arch/arm/dts/s700-cubieboard7.dts
@@ -0,0 +1,92 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2017 Andreas Färber
+ */
+
+/dts-v1/;
+
+#include "s700.dtsi"
+
+/ {
+   compatible = "cubietech,cubieboard7", "actions,s700";
+   model = "CubieBoard7";
+
+   aliases {
+   serial3 = &uart3;
+   };
+
+   chosen {
+   stdout-path = "serial3:115200n8";
+   };
+
+   memory@0 {
+   device_type = "memory";
+   reg = <0x0 0x0 0x0 0x8000>;
+   };
+
+   memory@1,e000 {
+   device_type = "memory";
+   reg = <0x1 0xe000 0x0 0x0>;
+   };
+};
+
+&i2c0 {
+   status = "okay";
+   pinctrl-names = "default";
+   pinctrl-0 = <&i2c0_default>;
+};
+
+&i2c1 {
+   status = "okay";
+   pinctrl-names = "default";
+   pinctrl-0 = <&i2c1_default>;
+};
+
+&i2c2 {
+   status = "disabled";
+   pinctrl-names = "default";
+   pinctrl-0 = <&i2c2_default>;
+};
+
+&pinctrl {
+   i2c0_default: i2c0_default {
+   pinmux {
+   groups = "i2c0_mfp";
+   function = "i2c0";
+   };
+   pinconf {
+   pins = "i2c0_sclk", "i2c0_sdata";
+   bias-pull-up;
+   };
+   };
+
+   i2c1_default: i2c1_default {
+   pinmux {
+   groups = "i2c1_dummy";
+   function = "i2c1";
+   };
+   pinconf {
+   pins = "i2c1_sclk", "i2c1_sdata";
+   bias-pull-up;
+   };
+   };
+
+   i2c2_default: i2c2_default {
+   pinmux {
+   groups = "i2c2_dummy";
+   function = "i2c2";
+   };
+   pinconf {
+   pins = "i2c2_sclk", "i2c2_sdata";
+   bias-pull-up;
+   };
+   };
+};
+
+&timer {
+   clocks = <&hosc>;
+};
+
+&uart3 {
+   status = "okay";
+};
diff --git a/configs/cubieboard7_defconfig b/configs/cubieboard7_defconfig
new file mode 100644
index 000..637dc9e
--- /dev/null
+++ b/configs/cubieboard7_defconfig
@@ -0,0 +1,12 @@
+CONFIG_ARM=y
+CONFIG_ARCH_OWL=y
+CONFIG_MACH_S700=y
+CONFIG_IDENT_STRING="\ncubieboard7"
+CONFIG_DISTRO_DEFAULTS=y
+CONFIG_BOOTDELAY=5
+CONFIG_USE_BOOTARGS=y
+CONFIG_BOOTARGS="console=ttyOWL3,115200n8"
+# CONFIG_DISPLAY_CPUINFO is not set
+# CONFIG_DISPLAY_BOARDINFO is not set
+CONFIG_SYS_PROMPT="U-Boot => "
+CONFIG_DEFAULT_DEVICE_TREE="s700-cubieboard7"
-- 
2.7.4



[PATCH v11 06/13] clk: actions: Add common clock driver

2020-04-19 Thread Amit Singh Tomar
This patch converts S900 clock driver to something common that can
be used for other SoCs, for instance S700(few of clk registers are same).

Reviewed-by: Andre Przywara 
Signed-off-by: Amit Singh Tomar 
---
Changes since v10:
* No change.
Changes since v9:
* Checked the relevant SoC model.
Changes since v8:
* Fixed the bubblegum-96 boot issue by introducing
  dev_get_driver_data API to read driver data.
Changes since v7:
* No changes.
Changes since v6:
* Fixed the bug that breaks S900(missing break in switch statement).
Changes since v5:
* No changes.
Changes since v4:
* This patch is re-ordered, moved from 08/11 to 04/11.
Changes since v3:
* Replaced dtsi with dts in subject line along with arm:dts:
  to the prefix.
* Added reviewed-by tag.
Changes since v2:
* Newly added patch, not there in v2/v1.
---
 arch/arm/Kconfig  |   2 +
 arch/arm/include/asm/arch-owl/clk_s900.h  |  57 ---
 arch/arm/include/asm/arch-owl/regs_s700.h |  56 +++
 configs/bubblegum_96_defconfig|   3 -
 drivers/clk/owl/Kconfig   |   8 +-
 drivers/clk/owl/Makefile  |   2 +-
 drivers/clk/owl/clk_owl.c | 155 ++
 drivers/clk/owl/clk_owl.h |  64 
 drivers/clk/owl/clk_s900.c| 137 --
 9 files changed, 280 insertions(+), 204 deletions(-)
 delete mode 100644 arch/arm/include/asm/arch-owl/clk_s900.h
 create mode 100644 arch/arm/include/asm/arch-owl/regs_s700.h
 create mode 100644 drivers/clk/owl/clk_owl.c
 create mode 100644 drivers/clk/owl/clk_owl.h
 delete mode 100644 drivers/clk/owl/clk_s900.c

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index d04442d..84499b3 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -876,6 +876,8 @@ config ARCH_OWL
select DM
select DM_SERIAL
select OWL_SERIAL
+   select CLK
+   select CLK_OWL
select OF_CONTROL
imply CMD_DM
 
diff --git a/arch/arm/include/asm/arch-owl/clk_s900.h 
b/arch/arm/include/asm/arch-owl/clk_s900.h
deleted file mode 100644
index 88e88f7..000
--- a/arch/arm/include/asm/arch-owl/clk_s900.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * Actions Semi S900 Clock Definitions
- *
- * Copyright (C) 2015 Actions Semi Co., Ltd.
- * Copyright (C) 2018 Manivannan Sadhasivam 
- *
- */
-
-#ifndef _OWL_CLK_S900_H_
-#define _OWL_CLK_S900_H_
-
-#include 
-
-struct owl_clk_priv {
-   phys_addr_t base;
-};
-
-/* BUSCLK register definitions */
-#define CMU_PDBGDIV_8  7
-#define CMU_PDBGDIV_SHIFT  26
-#define CMU_PDBGDIV_DIV(CMU_PDBGDIV_8 << CMU_PDBGDIV_SHIFT)
-#define CMU_PERDIV_8   7
-#define CMU_PERDIV_SHIFT   20
-#define CMU_PERDIV_DIV (CMU_PERDIV_8 << CMU_PERDIV_SHIFT)
-#define CMU_NOCDIV_2   1
-#define CMU_NOCDIV_SHIFT   19
-#define CMU_NOCDIV_DIV (CMU_NOCDIV_2 << CMU_NOCDIV_SHIFT)
-#define CMU_DMMCLK_SRC_APLL2
-#define CMU_DMMCLK_SRC_SHIFT   10
-#define CMU_DMMCLK_SRC (CMU_DMMCLK_SRC_APLL << CMU_DMMCLK_SRC_SHIFT)
-#define CMU_APBCLK_DIV BIT(8)
-#define CMU_NOCCLK_SRC BIT(7)
-#define CMU_AHBCLK_DIV BIT(4)
-#define CMU_CORECLK_MASK   3
-#define CMU_CORECLK_CPLL   BIT(1)
-#define CMU_CORECLK_HOSC   BIT(0)
-
-/* COREPLL register definitions */
-#define CMU_COREPLL_EN BIT(9)
-#define CMU_COREPLL_HOSC_ENBIT(8)
-#define CMU_COREPLL_OUT(1104 / 24)
-
-/* DEVPLL register definitions */
-#define CMU_DEVPLL_CLK BIT(12)
-#define CMU_DEVPLL_EN  BIT(8)
-#define CMU_DEVPLL_OUT (660 / 6)
-
-/* UARTCLK register definitions */
-#define CMU_UARTCLK_SRC_DEVPLL BIT(16)
-
-/* DEVCLKEN1 register definitions */
-#define CMU_DEVCLKEN1_UART5BIT(21)
-
-#define PLL_STABILITY_WAIT_US  50
-
-#endif
diff --git a/arch/arm/include/asm/arch-owl/regs_s700.h 
b/arch/arm/include/asm/arch-owl/regs_s700.h
new file mode 100644
index 000..2f21c15
--- /dev/null
+++ b/arch/arm/include/asm/arch-owl/regs_s700.h
@@ -0,0 +1,56 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Actions Semi S700 Register Definitions
+ *
+ */
+
+#ifndef _OWL_REGS_S700_H_
+#define _OWL_REGS_S700_H_
+
+#define CMU_COREPLL0x
+#define CMU_DEVPLL 0x0004
+#define CMU_DDRPLL 0x0008
+#define CMU_NANDPLL0x000C
+#define CMU_DISPLAYPLL 0x0010
+#define CMU_AUDIOPLL   0x0014
+#define CMU_TVOUTPLL   0x0018
+#define CMU_BUSCLK 0x001C
+#define CMU_SENSORCLK  0x0020
+#define CMU_LCDCLK 0x0024
+#define CMU_DSIPLLCLK  0x0028
+#define CMU_CSICLK 0x002C
+#define CMU_DECLK  0x0030
+#define CMU_SICLK  0x0034
+#define CMU_BUSCLK10x0038
+#define CMU_H

[PATCH v11 08/13] arm: dts: actions: s700: add u-boot specific dtsi file

2020-04-19 Thread Amit Singh Tomar
Devices like uart and clk are needed to be enabled before relocation.
this patch adds u-boot.dtsi file that mark these device as dm-pre-reloc.

Reviewed-by: Manivannan Sadhasivam 
Reviewed-by: Andre Przywara 
Signed-off-by: Amit Singh Tomar 
---
Changes since v10:
* No change.
Changes since v9:
* Added Reviewed-by tag from Mani.
Changes since v8:
* No changes.
Changes since v7:
* No changes.
Changes since v6:
* No changes.
Changes since v5:
* Added reviwed-by tag.
Changes since v4:
* Moved it to 08/11 to 06/11.
Changes since v3:
* Replaced dtsi with dts in subject line along with arm:dts:
  to the prefix.
Changes since v2:
* Added License.
Changes since v1:
* This is newly added file that was *not* present in v1 and
  contains u-boot specific changes.
---
 arch/arm/dts/s700-u-boot.dtsi | 18 ++
 1 file changed, 18 insertions(+)
 create mode 100644 arch/arm/dts/s700-u-boot.dtsi

diff --git a/arch/arm/dts/s700-u-boot.dtsi b/arch/arm/dts/s700-u-boot.dtsi
new file mode 100644
index 000..a527ccc
--- /dev/null
+++ b/arch/arm/dts/s700-u-boot.dtsi
@@ -0,0 +1,18 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2020 Amit Singh Tomar 
+ */
+
+/{
+   soc {
+   u-boot,dm-pre-reloc;
+   };
+};
+
+&uart3 {
+   u-boot,dm-pre-reloc;
+};
+
+&cmu {
+   u-boot,dm-pre-reloc;
+};
-- 
2.7.4



[PATCH v11 05/13] arm: dts: actions: s900: add u-boot specific dtsi file

2020-04-19 Thread Amit Singh Tomar
Devices like uart and clk are needed to be enabled before relocation.
This patch adds u-boot.dtsi file that mark these device as dm-pre-reloc.

Reviewed-by: Manivannan Sadhasivam 
Reviewed-by: Andre Przywara 
Signed-off-by: Amit Singh Tomar 
---
Changes since v10:
* No change.
Changes since v9:
* Added Reviewed-by tag from Mani.
Changes since v8:
* No changes.
Changes since v7:
* No changes.
Changes since v6:
* No changes.
Changes since v5:
* No changes.
Changes since v4:
* This patch is re-ordered, moved from 08/11 to 04/11.
Changes since v3:
* Replaced dtsi with dts in subject line along with arm:dts:
  to the prefix.
* Added reviewed-by tag.
Changes since v2:
* Newly added patch, not there in v2/v1.
---
 arch/arm/dts/s900-u-boot.dtsi | 17 +
 1 file changed, 17 insertions(+)
 create mode 100644 arch/arm/dts/s900-u-boot.dtsi

diff --git a/arch/arm/dts/s900-u-boot.dtsi b/arch/arm/dts/s900-u-boot.dtsi
new file mode 100644
index 000..a95f2cc
--- /dev/null
+++ b/arch/arm/dts/s900-u-boot.dtsi
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ */
+
+/{
+   soc {
+   u-boot,dm-pre-reloc;
+   };
+};
+
+&uart5 {
+   u-boot,dm-pre-reloc;
+};
+
+&cmu {
+   u-boot,dm-pre-reloc;
+};
-- 
2.7.4



[PATCH v11 09/13] arm: add support Actions Semi S700

2020-04-19 Thread Amit Singh Tomar
This patch adds basic support for Actions Semi based S700
SoC, which is driven by common owl framework.

Reviewed-by: Manivannan Sadhasivam 
Reviewed-by: Andre Przywara 
Signed-off-by: Amit Singh Tomar 
---
Changes since v10:
* No change.
Changes since v9:
* Added Reviewed-by tag from Mani.
Changes since v8:
* Added Reviewed-by tag.
Changes since v7:
* Removed S700 include file.
Changes since v6:
* No changes.
Changes since v5:
* Added reviewed-by tag.
Changes since v4:
* Moved it to 09/11 to 04/11.
Changes since v3:
* Added "SoC" keyword to Actions Semi S700.
Changes since v2:
* Fixed the commit message.
* Checked for the clk->id.
* Added a .data member with SoC type.
* Removed #ifdefs from few places.
Changes since v1:
* Moved CLK and CLK_OWL symbols from defconfig to arch/arm/Kconfig.
---
 arch/arm/mach-owl/Kconfig | 5 +
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/mach-owl/Kconfig b/arch/arm/mach-owl/Kconfig
index 28984c1..cde2ade 100644
--- a/arch/arm/mach-owl/Kconfig
+++ b/arch/arm/mach-owl/Kconfig
@@ -8,6 +8,10 @@ config MACH_S900
 bool "Actions Semi S900 SoC"
 select ARM64
 
+config MACH_S700
+bool "Actions Semi S700 SoC"
+select ARM64
+
 endchoice
 
 config SYS_TEXT_BASE
@@ -18,5 +22,6 @@ config SYS_CONFIG_NAME
 
 config SYS_SOC
 default "s900" if MACH_S900
+default "s700" if MACH_S700
 
 endif
-- 
2.7.4



[PATCH v11 04/13] arm: dts: sync dts for Action Semi S900

2020-04-19 Thread Amit Singh Tomar
Synchronize device tree bindings with v5.5-rc6 tag with commit id
"b3a987b0264d".

Also, it removes older clock binding defined for S900 along with undocumented
compatible string "actions,s900-serial" from serial driver and adapts clock
driver to cater to new bindings.

Reviewed-by: Manivannan Sadhasivam 
Reviewed-by: Andre Przywara 
Signed-off-by: Amit Singh Tomar 
---
Changes since v10:
* No change.
Changes since v9:
* Added Reviewed-by tag from Mani.
* Pulled in changes(that enables bubblegum DT build based on 
CONFIG_MACH_S900)
  from patch 07/12.
Changes since v8:
* No changes.
Changes since v7:
* No changes.
Changes since v6:
* Added Reviewed-by tag.
Changes since v5:
* Moved it 04/11 from 03/11.
* removed the undocumented compatible string "actions,s900-serial".
* removed the reviewed-by tag.
Changes since v4:
* This patch is re-ordered, moved from 07/11 to 03/11.
* Used the commit-id(12 chars long) in commit message.
Changes since v3:
* Added Reviewed-by: tag.
Changes since v2:
* Newly added patch, not there in v2/v1.
---
 arch/arm/dts/Makefile  |   2 +-
 arch/arm/dts/s900.dtsi | 322 +++--
 drivers/clk/owl/clk_s900.c |   6 +-
 drivers/serial/serial_owl.c|   1 -
 include/dt-bindings/clock/actions,s900-cmu.h   | 129 ++
 include/dt-bindings/clock/s900_cmu.h   |  77 --
 include/dt-bindings/reset/actions,s900-reset.h |  65 +
 7 files changed, 499 insertions(+), 103 deletions(-)
 create mode 100644 include/dt-bindings/clock/actions,s900-cmu.h
 delete mode 100644 include/dt-bindings/clock/s900_cmu.h
 create mode 100644 include/dt-bindings/reset/actions,s900-reset.h

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 6d1e866..7f35cc0 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -64,7 +64,7 @@ dtb-$(CONFIG_KIRKWOOD) += \
kirkwood-pogo_e02.dtb \
kirkwood-sheevaplug.dtb
 
-dtb-$(CONFIG_ARCH_OWL) += \
+dtb-$(CONFIG_MACH_S900) += \
bubblegum_96.dtb
 
 dtb-$(CONFIG_ROCKCHIP_PX30) += \
diff --git a/arch/arm/dts/s900.dtsi b/arch/arm/dts/s900.dtsi
index 2bbb30a..eb35cf7 100644
--- a/arch/arm/dts/s900.dtsi
+++ b/arch/arm/dts/s900.dtsi
@@ -1,17 +1,94 @@
-// SPDX-License-Identifier: GPL-2.0+
-//
-// Device Tree Source for Actions Semi S900 SoC
-//
-// Copyright (C) 2015 Actions Semi Co., Ltd.
-// Copyright (C) 2018 Manivannan Sadhasivam 
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2017 Andreas Färber
+ */
 
-/dts-v1/;
-#include 
+#include 
+#include 
+#include 
+#include 
 
 / {
compatible = "actions,s900";
-   #address-cells = <0x2>;
-   #size-cells = <0x2>;
+   interrupt-parent = <&gic>;
+   #address-cells = <2>;
+   #size-cells = <2>;
+
+   cpus {
+   #address-cells = <2>;
+   #size-cells = <0>;
+
+   cpu0: cpu@0 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x0>;
+   enable-method = "psci";
+   };
+
+   cpu1: cpu@1 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x1>;
+   enable-method = "psci";
+   };
+
+   cpu2: cpu@2 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x2>;
+   enable-method = "psci";
+   };
+
+   cpu3: cpu@3 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x3>;
+   enable-method = "psci";
+   };
+   };
+
+   reserved-memory {
+   #address-cells = <2>;
+   #size-cells = <2>;
+   ranges;
+
+   secmon@1f00 {
+   reg = <0x0 0x1f00 0x0 0x100>;
+   no-map;
+   };
+   };
+
+   psci {
+   compatible = "arm,psci-0.2";
+   method = "smc";
+   };
+
+   arm-pmu {
+   compatible = "arm,cortex-a53-pmu";
+   interrupts = ,
+,
+,
+;
+   interrupt-affinity = <&cpu0>, <&cpu1>, <&cpu2>, <&cpu3>;
+   };
+
+   timer {

[PATCH v11 01/13] arm: actions: Add common framework for Actions Owl Semi SoCs

2020-04-19 Thread Amit Singh Tomar
This commit adds common arch support for Actions Semi Owl
series SoCs and removes the Bubblegum96 board files.

Reviewed-by: Manivannan Sadhasivam 
Reviewed-by: Andre Przywara 
Signed-off-by: Amit Singh Tomar 
---
Changes since v10:
* No change.
Changes since v9:
* Added Reviewed-by tag from Mani.
Changes since v8:
* Added Reviewed-by tag.
Changes since v7:
* Removed S900 specific include file.
* Removed the file list entry in MAINTAINERS file.
Changes since v6:
* No change.
Changes since v5:
* No change.
Changes since v4:
* No change.
Changes since v3:
* Corrected the file list entry in MAINTAINERS file.
Changes since v2:
* Moved the file list details to root MAINTAINERS file.
* Updated the commit message as suggested by Mani.
* Used the "Owl" keyword to describe SoC family.
Changes since v1:
* Moved S700 specific changes to patch 4 of 9.
* Moved couple of symbols from defconfig to arch/arm/Kconfig
  and platform owl Kconfig.
---
 MAINTAINERS  |  3 +-
 arch/arm/Kconfig |  3 +-
 arch/arm/mach-owl/Kconfig| 29 ++
 arch/arm/mach-owl/Makefile   |  1 +
 arch/arm/mach-owl/soc.c  | 57 
 board/ucRobotics/bubblegum_96/Kconfig| 15 
 board/ucRobotics/bubblegum_96/MAINTAINERS|  6 ---
 board/ucRobotics/bubblegum_96/Makefile   |  3 --
 board/ucRobotics/bubblegum_96/bubblegum_96.c | 57 
 configs/bubblegum_96_defconfig   |  4 +-
 include/configs/bubblegum_96.h   | 40 ---
 include/configs/owl-common.h | 40 +++
 12 files changed, 114 insertions(+), 144 deletions(-)
 create mode 100644 arch/arm/mach-owl/soc.c
 delete mode 100644 board/ucRobotics/bubblegum_96/Kconfig
 delete mode 100644 board/ucRobotics/bubblegum_96/MAINTAINERS
 delete mode 100644 board/ucRobotics/bubblegum_96/Makefile
 delete mode 100644 board/ucRobotics/bubblegum_96/bubblegum_96.c
 delete mode 100644 include/configs/bubblegum_96.h
 create mode 100644 include/configs/owl-common.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 7ac7e21..cae7004 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -272,9 +272,10 @@ M: Manivannan Sadhasivam 
 S: Maintained
 F: arch/arm/include/asm/arch-owl/
 F: arch/arm/mach-owl/
-F: board/ucRobotics/
 F: drivers/clk/owl/
 F: drivers/serial/serial_owl.c
+F: include/configs/owl-common.h
+F: configs/bubblegum_96_defconfig
 
 ARM RENESAS RMOBILE/R-CAR
 M: Nobuhiro Iwamatsu 
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index dd41090..d04442d 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -873,9 +873,9 @@ config ARCH_MX5
 
 config ARCH_OWL
bool "Actions Semi OWL SoCs"
-   select ARM64
select DM
select DM_SERIAL
+   select OWL_SERIAL
select OF_CONTROL
imply CMD_DM
 
@@ -1869,7 +1869,6 @@ source "board/spear/spear600/Kconfig"
 source "board/spear/x600/Kconfig"
 source "board/st/stv0991/Kconfig"
 source "board/tcl/sl50/Kconfig"
-source "board/ucRobotics/bubblegum_96/Kconfig"
 source "board/birdland/bav335x/Kconfig"
 source "board/toradex/colibri_pxa270/Kconfig"
 source "board/variscite/dart_6ul/Kconfig"
diff --git a/arch/arm/mach-owl/Kconfig b/arch/arm/mach-owl/Kconfig
index 199e772..28984c1 100644
--- a/arch/arm/mach-owl/Kconfig
+++ b/arch/arm/mach-owl/Kconfig
@@ -1,27 +1,22 @@
 if ARCH_OWL
 
-config SYS_SOC
-   default "owl"
-
 choice
-prompt "Actions Semi OWL SoCs board select"
+prompt "Actions Semi Owl SoC Variant"
 optional
 
-config TARGET_BUBBLEGUM_96
-   bool "96Boards Bubblegum-96"
-   help
- Support for 96Boards Bubblegum-96. This board complies with
- 96Board Consumer Edition Specification. Features:
- - Actions Semi S900 SoC (4xCortex A53, Power VR G6230 GPU)
- - 2GiB RAM
- - 8GiB eMMC, uSD slot
- - WiFi, Bluetooth and GPS module
- - 2x Host, 1x Device USB port
- - HDMI
- - 20-pin low speed and 40-pin high speed expanders, 6 LED, 3 buttons
+config MACH_S900
+bool "Actions Semi S900 SoC"
+select ARM64
 
 endchoice
 
-source "board/ucRobotics/bubblegum_96/Kconfig"
+config SYS_TEXT_BASE
+default 0x1100
+
+config SYS_CONFIG_NAME
+default "owl-common"
+
+config SYS_SOC
+default "s900" if MACH_S900
 
 endif
diff --git a/arch/arm/mach-owl/Makefile b/arch/arm/mach-owl/Makefile
index 1b43dc2..0b181c6 100644
--- a/arch/arm/mach-owl/Makefile
+++ b/arch/arm/mach-owl/Makefile
@@ -1,3 +1,4 @@
 # SPDX-License-Identifier: GPL-2.

[PATCH v11 03/13] serial: actions: add compatible string

2020-04-19 Thread Amit Singh Tomar
This patch adds "actions,owl-uart" string to the owl uart driver. It
is also defined in Linux kernel.

Reviewed-by: Manivannan Sadhasivam 
Reviewed-by: Andre Przywara 
Signed-off-by: Amit Singh Tomar 
---
Changes since v10:
* No change.
Changes since v9:
* Added Reviewed-by tag from Mani.
Changes since v8:
* No changes.
Changes since v7:
* No changes.
Changes since v6:
* Added Reviewd-by tag.
Changes since v5:
* Moved it to from 06/11 to 03/11.
* Used appropriate commit message.
* Removed the reviwed-by tag.
Changes since v4:
* Moved it to from 09/11 to 06/11.
Changes since v3:
* Used only owl-uart for compatible string.
Changes since v2:
* No changes.
Changes since v1:
* No changes.
---
 drivers/serial/serial_owl.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/serial/serial_owl.c b/drivers/serial/serial_owl.c
index 7ead73e..539acdc 100644
--- a/drivers/serial/serial_owl.c
+++ b/drivers/serial/serial_owl.c
@@ -121,6 +121,7 @@ static const struct dm_serial_ops owl_serial_ops = {
 
 static const struct udevice_id owl_serial_ids[] = {
{ .compatible = "actions,s900-serial" },
+   { .compatible = "actions,owl-uart" },
{ }
 };
 
-- 
2.7.4



[PATCH v11 02/13] arm: actions: rename sysmap-s900 to sysmap-owl

2020-04-19 Thread Amit Singh Tomar
Now that memory maps(for both S700 and S900 SoCs) can be managed using
a common file, rename sysmap-s900 to sysmap-owl to reflect the same.

Reviewed-by: Manivannan Sadhasivam 
Signed-off-by: Amit Singh Tomar 
---
Changes since v10:
* No change.
Changes since v9:
* No changes.
Changes since v8:
* No changes.
Changes since v7:
* No changes.
Changes since v6:
* No changes.
Changes since v5:
* No changes.
Changes since v4:
* No changes.
Changes since v3:
* Added reviewed-by tag.
Changes since v2:
* Fixed the commit message and header.
Changes since v1:
* compile sysmap-owl.c against CONFIG_ARM64 now.
---
 arch/arm/mach-owl/Makefile  |  2 +-
 arch/arm/mach-owl/sysmap-owl.c  | 32 
 arch/arm/mach-owl/sysmap-s900.c | 32 
 3 files changed, 33 insertions(+), 33 deletions(-)
 create mode 100644 arch/arm/mach-owl/sysmap-owl.c
 delete mode 100644 arch/arm/mach-owl/sysmap-s900.c

diff --git a/arch/arm/mach-owl/Makefile b/arch/arm/mach-owl/Makefile
index 0b181c6..f3a69eb 100644
--- a/arch/arm/mach-owl/Makefile
+++ b/arch/arm/mach-owl/Makefile
@@ -1,4 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0+
 
 obj-y += soc.o
-obj-y += sysmap-s900.o
+obj-$(CONFIG_ARM64) += sysmap-owl.o
diff --git a/arch/arm/mach-owl/sysmap-owl.c b/arch/arm/mach-owl/sysmap-owl.c
new file mode 100644
index 000..81f6ca2
--- /dev/null
+++ b/arch/arm/mach-owl/sysmap-owl.c
@@ -0,0 +1,32 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Memory map for Actions Semi Owl series SoCs.
+ *
+ * Copyright (C) 2015 Actions Semi Co., Ltd.
+ * Copyright (C) 2018 Manivannan Sadhasivam 
+ */
+
+#include 
+#include 
+
+static struct mm_region owl_mem_map[] = {
+   {
+   .virt = 0x0UL, /* DDR */
+   .phys = 0x0UL, /* DDR */
+   .size = 0x8000UL,
+   .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
+PTE_BLOCK_INNER_SHARE
+   }, {
+   .virt = 0xE000UL, /* Peripheral block */
+   .phys = 0xE000UL, /* Peripheral block */
+   .size = 0x0800UL,
+   .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+PTE_BLOCK_NON_SHARE |
+PTE_BLOCK_PXN | PTE_BLOCK_UXN
+   }, {
+   /* List terminator */
+   0,
+   }
+};
+
+struct mm_region *mem_map = owl_mem_map;
diff --git a/arch/arm/mach-owl/sysmap-s900.c b/arch/arm/mach-owl/sysmap-s900.c
deleted file mode 100644
index f78b639..000
--- a/arch/arm/mach-owl/sysmap-s900.c
+++ /dev/null
@@ -1,32 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Actions Semi S900 Memory map
- *
- * Copyright (C) 2015 Actions Semi Co., Ltd.
- * Copyright (C) 2018 Manivannan Sadhasivam 
- */
-
-#include 
-#include 
-
-static struct mm_region s900_mem_map[] = {
-   {
-   .virt = 0x0UL, /* DDR */
-   .phys = 0x0UL, /* DDR */
-   .size = 0x8000UL,
-   .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
-PTE_BLOCK_INNER_SHARE
-   }, {
-   .virt = 0xE000UL, /* Peripheral block */
-   .phys = 0xE000UL, /* Peripheral block */
-   .size = 0x0800UL,
-   .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
-PTE_BLOCK_NON_SHARE |
-PTE_BLOCK_PXN | PTE_BLOCK_UXN
-   }, {
-   /* List terminator */
-   0,
-   }
-};
-
-struct mm_region *mem_map = s900_mem_map;
-- 
2.7.4



[PATCH v11 00/13] Actions S700 SoC support

2020-04-19 Thread Amit Singh Tomar
This adds Cubieboard7[1] support based on Action Semi's S700 SoC[2], It's 
Quad-core ARMv8 SoC
with Cortex-A53 cores. Peripheral like UART seems to be compatible with S900 
SoC(basic support
for it is alreay present in u-boot).

This series(v11) takes care of the issues(breaks few boards unfortunately) 
pointed out by Tom.
Changes has been made to patches 10/13 and 11/13 and some of config options is 
moved from
arch/arm/mach-owl/Kconfig to appropriate config files.

Apart from it, new patch 13/13 is added that updates MAINTAINER file with 
cubieboard7_defconfig
entry.

Previous series(v10) takes care the commments provided by Mani and patches 
04/12, 07/12 and 12/12
has been changed to address those comments. 

Series(v9) fixes a Bug that breaks bubblegum96 board boot(reported by Mani). It 
was
due to fact that driver data read is not proper in the clock driver. There are 
changes in
patch 06/12 to fix it.

Series(v8) removes the SoC specific include instead just uses owl-common. For 
this
patch 01/12 and 09/12 changes a bit.

Series(v7) fixes a serious Bug that breaks S900, it was there since v5.Thanks 
to Andre
for pointing it out.

Series(v6)[3] does following changes:

* [PATCH v5 06/11] becomes [PATCH v6 03/11]
* [PATCH v5 03/11] becomes [PATCH v6 04/11]
* Introduce a new patch to move defconfig options to Kconfig which is [PATCH v6 
10/12]

Series(v5)[4] just re-orders the patches so that U-BOOT(with 
bubblegum96_defconfig) builds
after every patch of the series(suggested by Andre).

S700 support is tested[5] on Cubieboard7-lite board and S900 support is just 
compiled tested.

This patch series can be tested using below tree:
https://github.com/Atomar25/u-boot/commits/s700_v10

[1]: http://www.cubietech.com/product-detail/cubieboard7/
[2]: http://www.actions-semi.com/en/productview.aspx?id=225
[3]: 
http://u-boot.10912.n7.nabble.com/PATCH-v6-00-12-Actions-S700-SoC-support-td403562.html#a403567
[4]: 
http://u-boot.10912.n7.nabble.com/PATCH-v5-00-11-Actions-S700-SoC-support-td402752.html#a402762
[5]: https://paste.ubuntu.com/p/4nhCWryRNR/

Amit Singh Tomar (13):
  arm: actions: Add common framework for Actions Owl Semi SoCs
  arm: actions: rename sysmap-s900 to sysmap-owl
  serial: actions: add compatible string
  arm: dts: sync dts for Action Semi S900
  arm: dts: actions: s900: add u-boot specific dtsi file
  clk: actions: Add common clock driver
  arm: actions: add S700 SoC device tree
  arm: dts: actions: s700: add u-boot specific dtsi file
  arm: add support Actions Semi S700
  actions: Move defconfig options to Kconfig
  arm: add Cubieboard7 board support
  doc: boards: add Cubieboard7 documentation
  MAINTAINERS: add entry for cubieboard7 config

 Kconfig|   2 +-
 MAINTAINERS|   4 +-
 arch/arm/Kconfig   |   6 +-
 arch/arm/dts/Makefile  |   4 +-
 arch/arm/dts/s700-cubieboard7.dts  |  92 +++
 arch/arm/dts/s700-u-boot.dtsi  |  18 ++
 arch/arm/dts/s700.dtsi | 248 +++
 arch/arm/dts/s900-u-boot.dtsi  |  17 ++
 arch/arm/dts/s900.dtsi | 322 +++--
 arch/arm/include/asm/arch-owl/clk_s900.h   |  57 -
 arch/arm/include/asm/arch-owl/regs_s700.h  |  56 +
 arch/arm/mach-owl/Kconfig  |  34 +--
 arch/arm/mach-owl/Makefile |   3 +-
 arch/arm/mach-owl/soc.c|  57 +
 arch/arm/mach-owl/sysmap-owl.c |  32 +++
 arch/arm/mach-owl/sysmap-s900.c|  32 ---
 board/ucRobotics/bubblegum_96/Kconfig  |  15 --
 board/ucRobotics/bubblegum_96/MAINTAINERS  |   6 -
 board/ucRobotics/bubblegum_96/Makefile |   3 -
 board/ucRobotics/bubblegum_96/bubblegum_96.c   |  57 -
 configs/bubblegum_96_defconfig |   9 +-
 configs/cubieboard7_defconfig  |  12 +
 doc/board/actions/cubieboard7.rst  | 114 +
 doc/board/actions/index.rst|  10 +
 doc/board/index.rst|   1 +
 drivers/clk/owl/Kconfig|   8 +-
 drivers/clk/owl/Makefile   |   2 +-
 drivers/clk/owl/clk_owl.c  | 155 
 drivers/clk/owl/clk_owl.h  |  64 +
 drivers/clk/owl/clk_s900.c | 137 ---
 drivers/serial/serial_owl.c|   2 +-
 include/configs/bubblegum_96.h |  40 ---
 include/configs/owl-common.h   |  40 +++
 include/dt-bindings/clock/actions,s700-cmu.h   | 118 +
 include/dt-bindings/clock/actions,s900-cmu.h   | 129 ++
 include/dt-bindings/clock/s900_cmu.h   |  77 --
 include/dt-bindings/reset/actions,s700-reset.h |  34 +++
 include/dt-bindings/reset/actions,s900-reset.h |  65 +

[PATCH v10 11/12] arm: add Cubieboard7 board support

2020-04-06 Thread Amit Singh Tomar
The Cubieboard is a single board computer containing a
Actions S700 SoC(with 4 ARMv8 Cortex-A53 cores).

This patch adds respective defconfig alongwith .dts(copied
from Linux v5.5-rc6 with hash "b3a987b0264d").

Reviewed-by: Manivannan Sadhasivam 
Reviewed-by: Andre Przywara 
Signed-off-by: Amit Singh Tomar 
---
Changes since v9:
* Added Reviewed-by tag from Mani.
Changes since v8:
* No changes.
Changes since v7:
* No changes.
Changes since v6:
* Added Reviewed-by tag.
Changes since v5:
* Trimmed of the cubieboard7_defconfig.
Changes since v4:
* No changes.
Changes since v3:
* added reviewed-by: tag.
Changes since v2:
* No changes.
Changes since v1:
* No changes.
---
 arch/arm/dts/s700-cubieboard7.dts | 92 +++
 configs/cubieboard7_defconfig |  9 
 2 files changed, 101 insertions(+)
 create mode 100644 arch/arm/dts/s700-cubieboard7.dts
 create mode 100644 configs/cubieboard7_defconfig

diff --git a/arch/arm/dts/s700-cubieboard7.dts 
b/arch/arm/dts/s700-cubieboard7.dts
new file mode 100644
index 000..63e375c
--- /dev/null
+++ b/arch/arm/dts/s700-cubieboard7.dts
@@ -0,0 +1,92 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2017 Andreas Färber
+ */
+
+/dts-v1/;
+
+#include "s700.dtsi"
+
+/ {
+   compatible = "cubietech,cubieboard7", "actions,s700";
+   model = "CubieBoard7";
+
+   aliases {
+   serial3 = &uart3;
+   };
+
+   chosen {
+   stdout-path = "serial3:115200n8";
+   };
+
+   memory@0 {
+   device_type = "memory";
+   reg = <0x0 0x0 0x0 0x8000>;
+   };
+
+   memory@1,e000 {
+   device_type = "memory";
+   reg = <0x1 0xe000 0x0 0x0>;
+   };
+};
+
+&i2c0 {
+   status = "okay";
+   pinctrl-names = "default";
+   pinctrl-0 = <&i2c0_default>;
+};
+
+&i2c1 {
+   status = "okay";
+   pinctrl-names = "default";
+   pinctrl-0 = <&i2c1_default>;
+};
+
+&i2c2 {
+   status = "disabled";
+   pinctrl-names = "default";
+   pinctrl-0 = <&i2c2_default>;
+};
+
+&pinctrl {
+   i2c0_default: i2c0_default {
+   pinmux {
+   groups = "i2c0_mfp";
+   function = "i2c0";
+   };
+   pinconf {
+   pins = "i2c0_sclk", "i2c0_sdata";
+   bias-pull-up;
+   };
+   };
+
+   i2c1_default: i2c1_default {
+   pinmux {
+   groups = "i2c1_dummy";
+   function = "i2c1";
+   };
+   pinconf {
+   pins = "i2c1_sclk", "i2c1_sdata";
+   bias-pull-up;
+   };
+   };
+
+   i2c2_default: i2c2_default {
+   pinmux {
+   groups = "i2c2_dummy";
+   function = "i2c2";
+   };
+   pinconf {
+   pins = "i2c2_sclk", "i2c2_sdata";
+   bias-pull-up;
+   };
+   };
+};
+
+&timer {
+   clocks = <&hosc>;
+};
+
+&uart3 {
+   status = "okay";
+};
diff --git a/configs/cubieboard7_defconfig b/configs/cubieboard7_defconfig
new file mode 100644
index 000..d12c293
--- /dev/null
+++ b/configs/cubieboard7_defconfig
@@ -0,0 +1,9 @@
+CONFIG_ARM=y
+CONFIG_ARCH_OWL=y
+CONFIG_MACH_S700=y
+CONFIG_IDENT_STRING="\ncubieboard7"
+CONFIG_BOOTDELAY=5
+CONFIG_USE_BOOTARGS=y
+CONFIG_BOOTARGS="console=ttyOWL3,115200n8"
+# CONFIG_DISPLAY_CPUINFO is not set
+CONFIG_DEFAULT_DEVICE_TREE="s700-cubieboard7"
-- 
2.7.4



[PATCH v10 12/12] doc: boards: add Cubieboard7 documentation

2020-04-06 Thread Amit Singh Tomar
This adds build and flash steps for Actions S700
based Cubieboard7 board.

Signed-off-by: Amit Singh Tomar 
---
Changes since v9:
* Updated the heading to CUBIEBOARD7 to ACTIONS.
* Added shorthand for mkimage command.
Changes since v8:
* No changes.
Changes since v7:
* No changes.
Changes since v6:
* No changes.
Changes since v5:
* No changes.
Changes since v4:
* No changes.
Changes since v3:
* Convert plain text documentation to reStructuredText format.
Changes since v2:
* No Change.
Changes since v1:
* No Change.
---
 doc/board/actions/cubieboard7.rst | 114 ++
 doc/board/actions/index.rst   |  10 
 doc/board/index.rst   |   1 +
 3 files changed, 125 insertions(+)
 create mode 100644 doc/board/actions/cubieboard7.rst
 create mode 100644 doc/board/actions/index.rst

diff --git a/doc/board/actions/cubieboard7.rst 
b/doc/board/actions/cubieboard7.rst
new file mode 100644
index 000..e01d2d0
--- /dev/null
+++ b/doc/board/actions/cubieboard7.rst
@@ -0,0 +1,114 @@
+.. SPDX-License-Identifier: GPL-2.0+
+.. Copyright (C) 2020 Amit Singh Tomar 
+
+CUBIEBOARD7
+===
+
+About this
+--
+
+This document describes build and flash steps for Actions S700 SoC based 
Cubieboard7
+board.
+
+Cubieboard7 initial configuration
+-
+
+Default Cubieboard7 comes with pre-installed Android where U-Boot is 
configured with
+a bootdelay of 0, entering a prompt by pressing keys does not seem to work.
+
+Though, one can enter ADFU mode and flash debian image(from host machine) where
+getting into u-boot prompt is easy.
+
+Enter ADFU Mode
+
+
+Before write the firmware, let the development board entering the ADFU mode: 
insert
+one end of the USB cable to the PC, press and hold the ADFU button, and then 
connect
+the other end of the USB cable to the Mini USB port of the development board, 
release
+the ADFU button, after connecting it will enter the ADFU mode.
+
+Check whether entered ADFU Mode
+
+
+The user needs to run the following command on the PC side to check if the ADFU
+device is detected. ID realted to "Actions Semiconductor Co., Ltd"  means that
+the PC side has been correctly detected ADFU device, the development board
+also enter into the ADFU mode.
+
+.. code-block:: none
+
+   $ lsusb
+   Bus 001 Device 005: ID 04f2:b2eb Chicony Electronics Co., Ltd
+   Bus 001 Device 004: ID 0a5c:21e6 Broadcom Corp. BCM20702 Bluetooth 4.0 
[ThinkPad]
+   Bus 001 Device 003: ID 046d:c534 Logitech, Inc. Unifying Receiver
+   Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
+   Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
+   Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
+   Bus 003 Device 013: ID 10d6:10d6 Actions Semiconductor Co., Ltd
+   Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
+
+Flashing debian image
+-
+
+.. code-block:: none
+
+   $ sudo ./ActionsFWU.py --fw=debian-stretch-desktop-cb7-emmc-v2.0.fw
+   ActionsFWU.py   : 1.0.150828.0830
+   libScript.so: 2.3.150825.0951
+   libFileSystem.so: 2.3.150825.0952
+   libProduction.so: 2.3.150915.1527
+   =burn all partition
+   FW_VER: 3.10.37.180608
+   3% DOWNLOAD ADFUDEC ...
+   5% DOWNLOAD BOOT PARA ...
+   7% SWITCH ADFUDEC ...
+   12% DOWNLOAD BL31 ...
+   13% DOWNLOAD BL32 ...
+   15% DOWNLOAD VMLINUX ...
+   20% DOWNLOAD INITRD ...
+   24% DOWNLOAD FDT ...
+   27% DOWNLOAD ADFUS ...
+   30% SWITCH ADFUS ...
+   32% DOWNLOAD MBR ...
+   35% DOWNLOAD PARTITIONS ...
+   WRITE_MBRC_PARTITION
+   35% write p0 size = 2048 : ok
+   WRITE_BOOT_PARTITION
+   35% write p1 size = 2048 : ok
+   WRITE_MISC_PARTITION
+   36% write p2 size = 98304 : ok
+   WRITE_SYSTEM_PARTITION
+   94% write p3 size = 4608000 : ok
+   FORMAT_SWAP_PARTITION
+   94% write p4 size = 20480 : ok
+   95% TRANSFER OVER ...
+   Firmware upgrade successfully!
+
+Debian image can be downloaded from here[1].
+
+Once debian image is flashed, one can get into u-boot prompt by pressing any 
key and from
+there run ums command(make sure, usb cable is connected between host and 
target):
+
+.. code-block:: none
+
+   owl> ums 0 mmc 1
+
+Above command would mount debian image partition on host machine.
+
+Building U-BOOT proper image
+
+
+.. code-block:: none
+
+   $ make clean
+   $ export CROSS_COMPILE=aarch64-linux-gnu-
+   $ make ARCH=arm cubieboard7_defconfig
+   $ make u-boot-dtb.img -j16
+
+u-boot-dtb.img can now be flashed to debian image partition mounted on host 
machine.
+
+.. code-block:: none
+
+   $ sudo dd if=u-boot-dtb.img of=/dev/sdb bs=1024 seek=3072
+
+[1]: 
https://pan.baidu.com/s/1uawPr0Jao2HgWFLZCLzHAg#list/path=%2FCubieBoard_Download%2FBoard%2FCubieBoard7%2F%E6%96%B9%E7%B3%96%E6%96%B9%E6%A1%88%E5%BC%80%E5%8F%91%E8%B

[PATCH v10 06/12] clk: actions: Add common clock driver

2020-04-06 Thread Amit Singh Tomar
This patch converts S900 clock driver to something common that can
be used for other SoCs, for instance S700(few of clk registers are same).

Reviewed-by: Andre Przywara 
Signed-off-by: Amit Singh Tomar 
---
Changes since v9:
* Checked the relevant SoC model.
Changes since v8:
* Fixed the bubblegum-96 boot issue by introducing
  dev_get_driver_data API to read driver data.
Changes since v7:
* No changes.
Changes since v6:
* Fixed the bug that breaks S900(missing break in switch statement).
Changes since v5:
* No changes.
Changes since v4:
* This patch is re-ordered, moved from 08/11 to 04/11.
Changes since v3:
* Replaced dtsi with dts in subject line along with arm:dts:
  to the prefix.
* Added reviewed-by tag.
Changes since v2:
* Newly added patch, not there in v2/v1.
---
 arch/arm/Kconfig  |   2 +
 arch/arm/include/asm/arch-owl/clk_s900.h  |  57 ---
 arch/arm/include/asm/arch-owl/regs_s700.h |  56 +++
 configs/bubblegum_96_defconfig|   3 -
 drivers/clk/owl/Kconfig   |   8 +-
 drivers/clk/owl/Makefile  |   2 +-
 drivers/clk/owl/clk_owl.c | 155 ++
 drivers/clk/owl/clk_owl.h |  64 
 drivers/clk/owl/clk_s900.c| 137 --
 9 files changed, 280 insertions(+), 204 deletions(-)
 delete mode 100644 arch/arm/include/asm/arch-owl/clk_s900.h
 create mode 100644 arch/arm/include/asm/arch-owl/regs_s700.h
 create mode 100644 drivers/clk/owl/clk_owl.c
 create mode 100644 drivers/clk/owl/clk_owl.h
 delete mode 100644 drivers/clk/owl/clk_s900.c

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index de6b7f9..05658cf 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -876,6 +876,8 @@ config ARCH_OWL
select DM
select DM_SERIAL
select OWL_SERIAL
+   select CLK
+   select CLK_OWL
select OF_CONTROL
imply CMD_DM
 
diff --git a/arch/arm/include/asm/arch-owl/clk_s900.h 
b/arch/arm/include/asm/arch-owl/clk_s900.h
deleted file mode 100644
index 88e88f7..000
--- a/arch/arm/include/asm/arch-owl/clk_s900.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * Actions Semi S900 Clock Definitions
- *
- * Copyright (C) 2015 Actions Semi Co., Ltd.
- * Copyright (C) 2018 Manivannan Sadhasivam 
- *
- */
-
-#ifndef _OWL_CLK_S900_H_
-#define _OWL_CLK_S900_H_
-
-#include 
-
-struct owl_clk_priv {
-   phys_addr_t base;
-};
-
-/* BUSCLK register definitions */
-#define CMU_PDBGDIV_8  7
-#define CMU_PDBGDIV_SHIFT  26
-#define CMU_PDBGDIV_DIV(CMU_PDBGDIV_8 << CMU_PDBGDIV_SHIFT)
-#define CMU_PERDIV_8   7
-#define CMU_PERDIV_SHIFT   20
-#define CMU_PERDIV_DIV (CMU_PERDIV_8 << CMU_PERDIV_SHIFT)
-#define CMU_NOCDIV_2   1
-#define CMU_NOCDIV_SHIFT   19
-#define CMU_NOCDIV_DIV (CMU_NOCDIV_2 << CMU_NOCDIV_SHIFT)
-#define CMU_DMMCLK_SRC_APLL2
-#define CMU_DMMCLK_SRC_SHIFT   10
-#define CMU_DMMCLK_SRC (CMU_DMMCLK_SRC_APLL << CMU_DMMCLK_SRC_SHIFT)
-#define CMU_APBCLK_DIV BIT(8)
-#define CMU_NOCCLK_SRC BIT(7)
-#define CMU_AHBCLK_DIV BIT(4)
-#define CMU_CORECLK_MASK   3
-#define CMU_CORECLK_CPLL   BIT(1)
-#define CMU_CORECLK_HOSC   BIT(0)
-
-/* COREPLL register definitions */
-#define CMU_COREPLL_EN BIT(9)
-#define CMU_COREPLL_HOSC_ENBIT(8)
-#define CMU_COREPLL_OUT(1104 / 24)
-
-/* DEVPLL register definitions */
-#define CMU_DEVPLL_CLK BIT(12)
-#define CMU_DEVPLL_EN  BIT(8)
-#define CMU_DEVPLL_OUT (660 / 6)
-
-/* UARTCLK register definitions */
-#define CMU_UARTCLK_SRC_DEVPLL BIT(16)
-
-/* DEVCLKEN1 register definitions */
-#define CMU_DEVCLKEN1_UART5BIT(21)
-
-#define PLL_STABILITY_WAIT_US  50
-
-#endif
diff --git a/arch/arm/include/asm/arch-owl/regs_s700.h 
b/arch/arm/include/asm/arch-owl/regs_s700.h
new file mode 100644
index 000..2f21c15
--- /dev/null
+++ b/arch/arm/include/asm/arch-owl/regs_s700.h
@@ -0,0 +1,56 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Actions Semi S700 Register Definitions
+ *
+ */
+
+#ifndef _OWL_REGS_S700_H_
+#define _OWL_REGS_S700_H_
+
+#define CMU_COREPLL0x
+#define CMU_DEVPLL 0x0004
+#define CMU_DDRPLL 0x0008
+#define CMU_NANDPLL0x000C
+#define CMU_DISPLAYPLL 0x0010
+#define CMU_AUDIOPLL   0x0014
+#define CMU_TVOUTPLL   0x0018
+#define CMU_BUSCLK 0x001C
+#define CMU_SENSORCLK  0x0020
+#define CMU_LCDCLK 0x0024
+#define CMU_DSIPLLCLK  0x0028
+#define CMU_CSICLK 0x002C
+#define CMU_DECLK  0x0030
+#define CMU_SICLK  0x0034
+#define CMU_BUSCLK10x0038
+#define CMU_HDECLK 0x003C
+#define CMU_V

[PATCH v10 09/12] arm: add support Actions Semi S700

2020-04-06 Thread Amit Singh Tomar
This patch adds basic support for Actions Semi based S700
SoC, which is driven by common owl framework.

Reviewed-by: Manivannan Sadhasivam 
Reviewed-by: Andre Przywara 
Signed-off-by: Amit Singh Tomar 
---
Changes since v9:
* Added Reviewed-by tag from Mani.
Changes since v8:
* Added Reviewed-by tag.
Changes since v7:
* Removed S700 include file.
Changes since v6:
* No changes.
Changes since v5:
* Added reviewed-by tag.
Changes since v4:
* Moved it to 09/11 to 04/11.
Changes since v3:
* Added "SoC" keyword to Actions Semi S700.
Changes since v2:
* Fixed the commit message.
* Checked for the clk->id.
* Added a .data member with SoC type.
* Removed #ifdefs from few places.
Changes since v1:
* Moved CLK and CLK_OWL symbols from defconfig to arch/arm/Kconfig.
---
 arch/arm/mach-owl/Kconfig | 5 +
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/mach-owl/Kconfig b/arch/arm/mach-owl/Kconfig
index 28984c1..cde2ade 100644
--- a/arch/arm/mach-owl/Kconfig
+++ b/arch/arm/mach-owl/Kconfig
@@ -8,6 +8,10 @@ config MACH_S900
 bool "Actions Semi S900 SoC"
 select ARM64
 
+config MACH_S700
+bool "Actions Semi S700 SoC"
+select ARM64
+
 endchoice
 
 config SYS_TEXT_BASE
@@ -18,5 +22,6 @@ config SYS_CONFIG_NAME
 
 config SYS_SOC
 default "s900" if MACH_S900
+default "s700" if MACH_S700
 
 endif
-- 
2.7.4



[PATCH v10 07/12] arm: actions: add S700 SoC device tree

2020-04-06 Thread Amit Singh Tomar
This patch adds .dtsi file(sync with Linux 5.5-rc6 with hash "b3a987b0264d")
and required binding for S700 SoC that is a 64-bit Quad-core ARM
Cortex-A53 cores.

It also provisions dts file to be built based on selected
platform(CONFIG_MACH_S900/S700).

Reviewed-by: Manivannan Sadhasivam 
Reviewed-by: Andre Przywara 
Signed-off-by: Amit Singh Tomar 
---
Changes since v9:
* Moved changes(that enables bubblegum-96 DT build) to patch 04/12.
Changes since v8:
* No changes.
Changes since v7:
* No changes.
Changes since v6:
* No changes.
Changes since v5:
* Added reviwed-by tag.
Changes since v4:
* Move it to 07/11 from 05/11.
Changes since v3:
* Updated commit message to the Linux tag to
  which the dtsi file is synced.
Changes since v2:
* Synced DTS bindings with Linux 5.5.
Changes since v1:
* Moved the u-boot specific changes to s700-u-boot.dtsi, now
  s700.dtsi is in complete sync with Linux 4.20.
---
 arch/arm/dts/Makefile  |   2 +
 arch/arm/dts/s700.dtsi | 248 +
 include/dt-bindings/clock/actions,s700-cmu.h   | 118 
 include/dt-bindings/reset/actions,s700-reset.h |  34 
 4 files changed, 402 insertions(+)
 create mode 100644 arch/arm/dts/s700.dtsi
 create mode 100644 include/dt-bindings/clock/actions,s700-cmu.h
 create mode 100644 include/dt-bindings/reset/actions,s700-reset.h

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 2834245..bd5b1e2 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -66,6 +66,8 @@ dtb-$(CONFIG_KIRKWOOD) += \
 
 dtb-$(CONFIG_MACH_S900) += \
bubblegum_96.dtb
+dtb-$(CONFIG_MACH_S700) += \
+   s700-cubieboard7.dtb
 
 dtb-$(CONFIG_ROCKCHIP_PX30) += \
px30-evb.dtb \
diff --git a/arch/arm/dts/s700.dtsi b/arch/arm/dts/s700.dtsi
new file mode 100644
index 000..2006ad5
--- /dev/null
+++ b/arch/arm/dts/s700.dtsi
@@ -0,0 +1,248 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2017 Andreas Färber
+ */
+
+#include 
+#include 
+#include 
+
+/ {
+   compatible = "actions,s700";
+   interrupt-parent = <&gic>;
+   #address-cells = <2>;
+   #size-cells = <2>;
+
+   cpus {
+   #address-cells = <2>;
+   #size-cells = <0>;
+
+   cpu0: cpu@0 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x0>;
+   enable-method = "psci";
+   };
+
+   cpu1: cpu@1 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x1>;
+   enable-method = "psci";
+   };
+
+   cpu2: cpu@2 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x2>;
+   enable-method = "psci";
+   };
+
+   cpu3: cpu@3 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x3>;
+   enable-method = "psci";
+   };
+   };
+
+   reserved-memory {
+   #address-cells = <2>;
+   #size-cells = <2>;
+   ranges;
+
+   secmon@1f00 {
+   reg = <0x0 0x1f00 0x0 0x100>;
+   no-map;
+   };
+   };
+
+   psci {
+   compatible = "arm,psci-0.2";
+   method = "smc";
+   };
+
+   arm-pmu {
+   compatible = "arm,cortex-a53-pmu";
+   interrupts = ,
+,
+,
+;
+   interrupt-affinity = <&cpu0>, <&cpu1>, <&cpu2>, <&cpu3>;
+   };
+
+   timer {
+   compatible = "arm,armv8-timer";
+   interrupts = ,
+,
+,
+;
+   };
+
+   hosc: hosc {
+   compatible = "fixed-clock";
+   clock-frequency = <2400>;
+   #clock-cells = <0>;
+   };
+
+   losc: losc {
+   compatible = "fixed-clock";
+   clock-frequency = <32768>;
+   #clock-cells = <0>;
+   };
+
+   soc {
+   compatible = "simple-bus";
+   #address-cells = <2>;
+   #size

[PATCH v10 08/12] arm: dts: actions: s700: add u-boot specific dtsi file

2020-04-06 Thread Amit Singh Tomar
Devices like uart and clk are needed to be enabled before relocation.
this patch adds u-boot.dtsi file that mark these device as dm-pre-reloc.

Reviewed-by: Manivannan Sadhasivam 
Reviewed-by: Andre Przywara 
Signed-off-by: Amit Singh Tomar 
---
Changes since v9:
* Added Reviewed-by tag from Mani.
Changes since v8:
* No changes.
Changes since v7:
* No changes.
Changes since v6:
* No changes.
Changes since v5:
* Added reviwed-by tag.
Changes since v4:
* Moved it to 08/11 to 06/11.
Changes since v3:
* Replaced dtsi with dts in subject line along with arm:dts:
  to the prefix.
Changes since v2:
* Added License.
Changes since v1:
* This is newly added file that was *not* present in v1 and
  contains u-boot specific changes.
---
 arch/arm/dts/s700-u-boot.dtsi | 18 ++
 1 file changed, 18 insertions(+)
 create mode 100644 arch/arm/dts/s700-u-boot.dtsi

diff --git a/arch/arm/dts/s700-u-boot.dtsi b/arch/arm/dts/s700-u-boot.dtsi
new file mode 100644
index 000..a527ccc
--- /dev/null
+++ b/arch/arm/dts/s700-u-boot.dtsi
@@ -0,0 +1,18 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2020 Amit Singh Tomar 
+ */
+
+/{
+   soc {
+   u-boot,dm-pre-reloc;
+   };
+};
+
+&uart3 {
+   u-boot,dm-pre-reloc;
+};
+
+&cmu {
+   u-boot,dm-pre-reloc;
+};
-- 
2.7.4



[PATCH v10 10/12] actions: Move defconfig options to Kconfig

2020-04-06 Thread Amit Singh Tomar
This patch moves some of the config options from bubblegum_96_defconfig
to platform specific Kconfig file.

Reviewed-by: Manivannan Sadhasivam 
Reviewed-by: Andre Przywara 
Signed-off-by: Amit Singh Tomar 
---
Changes since v9:
* Added Reviewed-by tag from Mani.
Changes since v8:
* No changes.
Changes since v7:
* No changes.
Changes since v6:
* remove unnecessary string from SYS_PROMPT.
Changes since v5:
* Newly added patch, was not there in earlier versions.
---
 arch/arm/mach-owl/Kconfig  | 15 +++
 configs/bubblegum_96_defconfig |  5 -
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-owl/Kconfig b/arch/arm/mach-owl/Kconfig
index cde2ade..2b5d725 100644
--- a/arch/arm/mach-owl/Kconfig
+++ b/arch/arm/mach-owl/Kconfig
@@ -24,4 +24,19 @@ config SYS_SOC
 default "s900" if MACH_S900
 default "s700" if MACH_S700
 
+config DISTRO_DEFAULTS
+   default y
+
+config NR_DRAM_BANKS
+   default 1
+
+config SYS_RELOC_GD_ENV_ADDR
+   default y
+
+config SYS_PROMPT
+   default "U-Boot => "
+
+config DISPLAY_BOARDINFO
+   default n
+
 endif
diff --git a/configs/bubblegum_96_defconfig b/configs/bubblegum_96_defconfig
index e76e9a2..0883167 100644
--- a/configs/bubblegum_96_defconfig
+++ b/configs/bubblegum_96_defconfig
@@ -1,19 +1,14 @@
 CONFIG_ARM=y
 CONFIG_ARCH_OWL=y
 CONFIG_ENV_SIZE=0x2000
-CONFIG_NR_DRAM_BANKS=1
 CONFIG_MACH_S900=y
 CONFIG_IDENT_STRING="\nBubblegum-96"
-CONFIG_DISTRO_DEFAULTS=y
 CONFIG_BOOTDELAY=5
 CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="console=ttyOWL5,115200n8"
 # CONFIG_DISPLAY_CPUINFO is not set
-# CONFIG_DISPLAY_BOARDINFO is not set
-CONFIG_SYS_PROMPT="U-Boot => "
 CONFIG_CMD_MD5SUM=y
 CONFIG_CMD_MEMINFO=y
 CONFIG_CMD_CACHE=y
 CONFIG_CMD_TIMER=y
 CONFIG_DEFAULT_DEVICE_TREE="bubblegum_96"
-CONFIG_SYS_RELOC_GD_ENV_ADDR=y
-- 
2.7.4



[PATCH v10 05/12] arm: dts: actions: s900: add u-boot specific dtsi file

2020-04-06 Thread Amit Singh Tomar
Devices like uart and clk are needed to be enabled before relocation.
This patch adds u-boot.dtsi file that mark these device as dm-pre-reloc.

Reviewed-by: Manivannan Sadhasivam 
Reviewed-by: Andre Przywara 
Signed-off-by: Amit Singh Tomar 
---
Changes since v9:
* Added Reviewed-by tag from Mani.
Changes since v8:
* No changes.
Changes since v7:
* No changes.
Changes since v6:
* No changes.
Changes since v5:
* No changes.
Changes since v4:
* This patch is re-ordered, moved from 08/11 to 04/11.
Changes since v3:
* Replaced dtsi with dts in subject line along with arm:dts:
  to the prefix.
* Added reviewed-by tag.
Changes since v2:
* Newly added patch, not there in v2/v1.
---
 arch/arm/dts/s900-u-boot.dtsi | 17 +
 1 file changed, 17 insertions(+)
 create mode 100644 arch/arm/dts/s900-u-boot.dtsi

diff --git a/arch/arm/dts/s900-u-boot.dtsi b/arch/arm/dts/s900-u-boot.dtsi
new file mode 100644
index 000..a95f2cc
--- /dev/null
+++ b/arch/arm/dts/s900-u-boot.dtsi
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ */
+
+/{
+   soc {
+   u-boot,dm-pre-reloc;
+   };
+};
+
+&uart5 {
+   u-boot,dm-pre-reloc;
+};
+
+&cmu {
+   u-boot,dm-pre-reloc;
+};
-- 
2.7.4



[PATCH v10 02/12] arm: actions: rename sysmap-s900 to sysmap-owl

2020-04-06 Thread Amit Singh Tomar
Now that memory maps(for both S700 and S900 SoCs) can be managed using
a common file, rename sysmap-s900 to sysmap-owl to reflect the same.

Reviewed-by: Manivannan Sadhasivam 
Signed-off-by: Amit Singh Tomar 
---
Changes since v9:
* No changes.
Changes since v8:
* No changes.
Changes since v7:
* No changes.
Changes since v6:
* No changes.
Changes since v5:
* No changes.
Changes since v4:
* No changes.
Changes since v3:
* Added reviewed-by tag.
Changes since v2:
* Fixed the commit message and header.
Changes since v1:
* compile sysmap-owl.c against CONFIG_ARM64 now.
---
 arch/arm/mach-owl/Makefile  |  2 +-
 arch/arm/mach-owl/sysmap-owl.c  | 32 
 arch/arm/mach-owl/sysmap-s900.c | 32 
 3 files changed, 33 insertions(+), 33 deletions(-)
 create mode 100644 arch/arm/mach-owl/sysmap-owl.c
 delete mode 100644 arch/arm/mach-owl/sysmap-s900.c

diff --git a/arch/arm/mach-owl/Makefile b/arch/arm/mach-owl/Makefile
index 0b181c6..f3a69eb 100644
--- a/arch/arm/mach-owl/Makefile
+++ b/arch/arm/mach-owl/Makefile
@@ -1,4 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0+
 
 obj-y += soc.o
-obj-y += sysmap-s900.o
+obj-$(CONFIG_ARM64) += sysmap-owl.o
diff --git a/arch/arm/mach-owl/sysmap-owl.c b/arch/arm/mach-owl/sysmap-owl.c
new file mode 100644
index 000..81f6ca2
--- /dev/null
+++ b/arch/arm/mach-owl/sysmap-owl.c
@@ -0,0 +1,32 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Memory map for Actions Semi Owl series SoCs.
+ *
+ * Copyright (C) 2015 Actions Semi Co., Ltd.
+ * Copyright (C) 2018 Manivannan Sadhasivam 
+ */
+
+#include 
+#include 
+
+static struct mm_region owl_mem_map[] = {
+   {
+   .virt = 0x0UL, /* DDR */
+   .phys = 0x0UL, /* DDR */
+   .size = 0x8000UL,
+   .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
+PTE_BLOCK_INNER_SHARE
+   }, {
+   .virt = 0xE000UL, /* Peripheral block */
+   .phys = 0xE000UL, /* Peripheral block */
+   .size = 0x0800UL,
+   .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+PTE_BLOCK_NON_SHARE |
+PTE_BLOCK_PXN | PTE_BLOCK_UXN
+   }, {
+   /* List terminator */
+   0,
+   }
+};
+
+struct mm_region *mem_map = owl_mem_map;
diff --git a/arch/arm/mach-owl/sysmap-s900.c b/arch/arm/mach-owl/sysmap-s900.c
deleted file mode 100644
index f78b639..000
--- a/arch/arm/mach-owl/sysmap-s900.c
+++ /dev/null
@@ -1,32 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Actions Semi S900 Memory map
- *
- * Copyright (C) 2015 Actions Semi Co., Ltd.
- * Copyright (C) 2018 Manivannan Sadhasivam 
- */
-
-#include 
-#include 
-
-static struct mm_region s900_mem_map[] = {
-   {
-   .virt = 0x0UL, /* DDR */
-   .phys = 0x0UL, /* DDR */
-   .size = 0x8000UL,
-   .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
-PTE_BLOCK_INNER_SHARE
-   }, {
-   .virt = 0xE000UL, /* Peripheral block */
-   .phys = 0xE000UL, /* Peripheral block */
-   .size = 0x0800UL,
-   .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
-PTE_BLOCK_NON_SHARE |
-PTE_BLOCK_PXN | PTE_BLOCK_UXN
-   }, {
-   /* List terminator */
-   0,
-   }
-};
-
-struct mm_region *mem_map = s900_mem_map;
-- 
2.7.4



[PATCH v10 03/12] serial: actions: add compatible string

2020-04-06 Thread Amit Singh Tomar
This patch adds "actions,owl-uart" string to the owl uart driver. It
is also defined in Linux kernel.

Reviewed-by: Manivannan Sadhasivam 
Reviewed-by: Andre Przywara 
Signed-off-by: Amit Singh Tomar 
---
Changes since v9:
* Added Reviewed-by tag from Mani.
Changes since v8:
* No changes.
Changes since v7:
* No changes.
Changes since v6:
* Added Reviewd-by tag.
Changes since v5:
* Moved it to from 06/11 to 03/11.
* Used appropriate commit message.
* Removed the reviwed-by tag.
Changes since v4:
* Moved it to from 09/11 to 06/11.
Changes since v3:
* Used only owl-uart for compatible string.
Changes since v2:
* No changes.
Changes since v1:
* No changes.
---
 drivers/serial/serial_owl.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/serial/serial_owl.c b/drivers/serial/serial_owl.c
index 7ead73e..539acdc 100644
--- a/drivers/serial/serial_owl.c
+++ b/drivers/serial/serial_owl.c
@@ -121,6 +121,7 @@ static const struct dm_serial_ops owl_serial_ops = {
 
 static const struct udevice_id owl_serial_ids[] = {
{ .compatible = "actions,s900-serial" },
+   { .compatible = "actions,owl-uart" },
{ }
 };
 
-- 
2.7.4



[PATCH v10 04/12] arm: dts: sync dts for Action Semi S900

2020-04-06 Thread Amit Singh Tomar
Synchronize device tree bindings with v5.5-rc6 tag with commit id
"b3a987b0264d".

Also, it removes older clock binding defined for S900 along with undocumented
compatible string "actions,s900-serial" from serial driver and adapts clock
driver to cater to new bindings.

Reviewed-by: Manivannan Sadhasivam 
Reviewed-by: Andre Przywara 
Signed-off-by: Amit Singh Tomar 
---
Changes since v9:
* Added Reviewed-by tag from Mani.
* Pulled in changes(that enables bubblegum DT build based on 
CONFIG_MACH_S900)
  from patch 07/12.
Changes since v8:
* No changes.
Changes since v7:
* No changes.
Changes since v6:
* Added Reviewed-by tag.
Changes since v5:
* Moved it 04/11 from 03/11.
* removed the undocumented compatible string "actions,s900-serial".
* removed the reviewed-by tag.
Changes since v4:
* This patch is re-ordered, moved from 07/11 to 03/11.
* Used the commit-id(12 chars long) in commit message.
Changes since v3:
* Added Reviewed-by: tag.
Changes since v2:
* Newly added patch, not there in v2/v1.
---
 arch/arm/dts/Makefile  |   2 +-
 arch/arm/dts/s900.dtsi | 322 +++--
 drivers/clk/owl/clk_s900.c |   6 +-
 drivers/serial/serial_owl.c|   1 -
 include/dt-bindings/clock/actions,s900-cmu.h   | 129 ++
 include/dt-bindings/clock/s900_cmu.h   |  77 --
 include/dt-bindings/reset/actions,s900-reset.h |  65 +
 7 files changed, 499 insertions(+), 103 deletions(-)
 create mode 100644 include/dt-bindings/clock/actions,s900-cmu.h
 delete mode 100644 include/dt-bindings/clock/s900_cmu.h
 create mode 100644 include/dt-bindings/reset/actions,s900-reset.h

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 9c593b2..2834245 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -64,7 +64,7 @@ dtb-$(CONFIG_KIRKWOOD) += \
kirkwood-pogo_e02.dtb \
kirkwood-sheevaplug.dtb
 
-dtb-$(CONFIG_ARCH_OWL) += \
+dtb-$(CONFIG_MACH_S900) += \
bubblegum_96.dtb
 
 dtb-$(CONFIG_ROCKCHIP_PX30) += \
diff --git a/arch/arm/dts/s900.dtsi b/arch/arm/dts/s900.dtsi
index 2bbb30a..eb35cf7 100644
--- a/arch/arm/dts/s900.dtsi
+++ b/arch/arm/dts/s900.dtsi
@@ -1,17 +1,94 @@
-// SPDX-License-Identifier: GPL-2.0+
-//
-// Device Tree Source for Actions Semi S900 SoC
-//
-// Copyright (C) 2015 Actions Semi Co., Ltd.
-// Copyright (C) 2018 Manivannan Sadhasivam 
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2017 Andreas Färber
+ */
 
-/dts-v1/;
-#include 
+#include 
+#include 
+#include 
+#include 
 
 / {
compatible = "actions,s900";
-   #address-cells = <0x2>;
-   #size-cells = <0x2>;
+   interrupt-parent = <&gic>;
+   #address-cells = <2>;
+   #size-cells = <2>;
+
+   cpus {
+   #address-cells = <2>;
+   #size-cells = <0>;
+
+   cpu0: cpu@0 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x0>;
+   enable-method = "psci";
+   };
+
+   cpu1: cpu@1 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x1>;
+   enable-method = "psci";
+   };
+
+   cpu2: cpu@2 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x2>;
+   enable-method = "psci";
+   };
+
+   cpu3: cpu@3 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x3>;
+   enable-method = "psci";
+   };
+   };
+
+   reserved-memory {
+   #address-cells = <2>;
+   #size-cells = <2>;
+   ranges;
+
+   secmon@1f00 {
+   reg = <0x0 0x1f00 0x0 0x100>;
+   no-map;
+   };
+   };
+
+   psci {
+   compatible = "arm,psci-0.2";
+   method = "smc";
+   };
+
+   arm-pmu {
+   compatible = "arm,cortex-a53-pmu";
+   interrupts = ,
+,
+,
+;
+   interrupt-affinity = <&cpu0>, <&cpu1>, <&cpu2>, <&cpu3>;
+   };
+
+   timer {
+   compatible = "arm,

[PATCH v10 01/12] arm: actions: Add common framework for Actions Owl Semi SoCs

2020-04-06 Thread Amit Singh Tomar
This commit adds common arch support for Actions Semi Owl
series SoCs and removes the Bubblegum96 board files.

Reviewed-by: Manivannan Sadhasivam 
Reviewed-by: Andre Przywara 
Signed-off-by: Amit Singh Tomar 
---
Changes since v9:
* Added Reviewed-by tag from Mani.
Changes since v8:
* Added Reviewed-by tag.
Changes since v7:
* Removed S900 specific include file.
* Removed the file list entry in MAINTAINERS file.
Changes since v6:
* No change.
Changes since v5:
* No change.
Changes since v4:
* No change.
Changes since v3:
* Corrected the file list entry in MAINTAINERS file.
Changes since v2:
* Moved the file list details to root MAINTAINERS file.
* Updated the commit message as suggested by Mani.
* Used the "Owl" keyword to describe SoC family.
Changes since v1:
* Moved S700 specific changes to patch 4 of 9.
* Moved couple of symbols from defconfig to arch/arm/Kconfig
  and platform owl Kconfig.
---
 MAINTAINERS  |  3 +-
 arch/arm/Kconfig |  3 +-
 arch/arm/mach-owl/Kconfig| 29 ++
 arch/arm/mach-owl/Makefile   |  1 +
 arch/arm/mach-owl/soc.c  | 57 
 board/ucRobotics/bubblegum_96/Kconfig| 15 
 board/ucRobotics/bubblegum_96/MAINTAINERS|  6 ---
 board/ucRobotics/bubblegum_96/Makefile   |  3 --
 board/ucRobotics/bubblegum_96/bubblegum_96.c | 57 
 configs/bubblegum_96_defconfig   |  4 +-
 include/configs/bubblegum_96.h   | 40 ---
 include/configs/owl-common.h | 40 +++
 12 files changed, 114 insertions(+), 144 deletions(-)
 create mode 100644 arch/arm/mach-owl/soc.c
 delete mode 100644 board/ucRobotics/bubblegum_96/Kconfig
 delete mode 100644 board/ucRobotics/bubblegum_96/MAINTAINERS
 delete mode 100644 board/ucRobotics/bubblegum_96/Makefile
 delete mode 100644 board/ucRobotics/bubblegum_96/bubblegum_96.c
 delete mode 100644 include/configs/bubblegum_96.h
 create mode 100644 include/configs/owl-common.h

diff --git a/MAINTAINERS b/MAINTAINERS
index b50652b..2eaacb7 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -272,9 +272,10 @@ M: Manivannan Sadhasivam 
 S: Maintained
 F: arch/arm/include/asm/arch-owl/
 F: arch/arm/mach-owl/
-F: board/ucRobotics/
 F: drivers/clk/owl/
 F: drivers/serial/serial_owl.c
+F: include/configs/owl-common.h
+F: configs/bubblegum_96_defconfig
 
 ARM RENESAS RMOBILE/R-CAR
 M: Nobuhiro Iwamatsu 
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index bbb1e27..de6b7f9 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -873,9 +873,9 @@ config ARCH_MX5
 
 config ARCH_OWL
bool "Actions Semi OWL SoCs"
-   select ARM64
select DM
select DM_SERIAL
+   select OWL_SERIAL
select OF_CONTROL
imply CMD_DM
 
@@ -1868,7 +1868,6 @@ source "board/spear/spear600/Kconfig"
 source "board/spear/x600/Kconfig"
 source "board/st/stv0991/Kconfig"
 source "board/tcl/sl50/Kconfig"
-source "board/ucRobotics/bubblegum_96/Kconfig"
 source "board/birdland/bav335x/Kconfig"
 source "board/toradex/colibri_pxa270/Kconfig"
 source "board/variscite/dart_6ul/Kconfig"
diff --git a/arch/arm/mach-owl/Kconfig b/arch/arm/mach-owl/Kconfig
index 199e772..28984c1 100644
--- a/arch/arm/mach-owl/Kconfig
+++ b/arch/arm/mach-owl/Kconfig
@@ -1,27 +1,22 @@
 if ARCH_OWL
 
-config SYS_SOC
-   default "owl"
-
 choice
-prompt "Actions Semi OWL SoCs board select"
+prompt "Actions Semi Owl SoC Variant"
 optional
 
-config TARGET_BUBBLEGUM_96
-   bool "96Boards Bubblegum-96"
-   help
- Support for 96Boards Bubblegum-96. This board complies with
- 96Board Consumer Edition Specification. Features:
- - Actions Semi S900 SoC (4xCortex A53, Power VR G6230 GPU)
- - 2GiB RAM
- - 8GiB eMMC, uSD slot
- - WiFi, Bluetooth and GPS module
- - 2x Host, 1x Device USB port
- - HDMI
- - 20-pin low speed and 40-pin high speed expanders, 6 LED, 3 buttons
+config MACH_S900
+bool "Actions Semi S900 SoC"
+select ARM64
 
 endchoice
 
-source "board/ucRobotics/bubblegum_96/Kconfig"
+config SYS_TEXT_BASE
+default 0x1100
+
+config SYS_CONFIG_NAME
+default "owl-common"
+
+config SYS_SOC
+default "s900" if MACH_S900
 
 endif
diff --git a/arch/arm/mach-owl/Makefile b/arch/arm/mach-owl/Makefile
index 1b43dc2..0b181c6 100644
--- a/arch/arm/mach-owl/Makefile
+++ b/arch/arm/mach-owl/Makefile
@@ -1,3 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0+
 
+obj-y += soc.o
 obj-y += sysmap-s90

[PATCH v10 00/12] Actions S700 SoC support

2020-04-06 Thread Amit Singh Tomar
This adds Cubieboard7[1] support based on Action Semi's S700 SoC[2], It's 
Quad-core ARMv8 SoC
with Cortex-A53 cores. Peripheral like UART seems to be compatible with S900 
SoC(basic support
for it is alreay present in u-boot).

This series(v10) takes care the commments provided by Mani and patches 04/12, 
07/12 and 12/12
has been changed to address those comments.

Previous series(v9) fixes a Bug that breaks bubblegum96 board boot(reported by 
Mani). It was
due to fact that driver data read is not proper in the clock driver. There are 
changes in
patch 06/12 to fix it.

Series(v8) removes the SoC specific include instead just uses owl-common. For 
this
patch 01/12 and 09/12 changes a bit.

Series(v7) fixes a serious Bug that breaks S900, it was there since v5.Thanks 
to Andre
for pointing it out. 

Series(v6)[3] does following changes:

* [PATCH v5 06/11] becomes [PATCH v6 03/11]
* [PATCH v5 03/11] becomes [PATCH v6 04/11]
* Introduce a new patch to move defconfig options to Kconfig which is [PATCH v6 
10/12]

Series(v5)[4] just re-orders the patches so that U-BOOT(with 
bubblegum96_defconfig) builds
after every patch of the series(suggested by Andre).

S700 support is tested[5] on Cubieboard7-lite board and S900 support is just 
compiled tested.

This patch series can be tested using below tree:
https://github.com/Atomar25/u-boot/commits/s700_v10

[1]: http://www.cubietech.com/product-detail/cubieboard7/
[2]: http://www.actions-semi.com/en/productview.aspx?id=225
[3]: 
http://u-boot.10912.n7.nabble.com/PATCH-v6-00-12-Actions-S700-SoC-support-td403562.html#a403567
[4]: 
http://u-boot.10912.n7.nabble.com/PATCH-v5-00-11-Actions-S700-SoC-support-td402752.html#a402762
[5]: https://paste.ubuntu.com/p/TbBtk5dPGS/

Amit Singh Tomar (12):
  arm: actions: Add common framework for Actions Owl Semi SoCs
  arm: actions: rename sysmap-s900 to sysmap-owl
  serial: actions: add compatible string
  arm: dts: sync dts for Action Semi S900
  arm: dts: actions: s900: add u-boot specific dtsi file
  clk: actions: Add common clock driver
  arm: actions: add S700 SoC device tree
  arm: dts: actions: s700: add u-boot specific dtsi file
  arm: add support Actions Semi S700
  actions: Move defconfig options to Kconfig
  arm: add Cubieboard7 board support
  doc: boards: add Cubieboard7 documentation

 MAINTAINERS|   3 +-
 arch/arm/Kconfig   |   5 +-
 arch/arm/dts/Makefile  |   4 +-
 arch/arm/dts/s700-cubieboard7.dts  |  92 +++
 arch/arm/dts/s700-u-boot.dtsi  |  18 ++
 arch/arm/dts/s700.dtsi | 248 +++
 arch/arm/dts/s900-u-boot.dtsi  |  17 ++
 arch/arm/dts/s900.dtsi | 322 +++--
 arch/arm/include/asm/arch-owl/clk_s900.h   |  57 -
 arch/arm/include/asm/arch-owl/regs_s700.h  |  56 +
 arch/arm/mach-owl/Kconfig  |  49 ++--
 arch/arm/mach-owl/Makefile |   3 +-
 arch/arm/mach-owl/soc.c|  57 +
 arch/arm/mach-owl/sysmap-owl.c |  32 +++
 arch/arm/mach-owl/sysmap-s900.c|  32 ---
 board/ucRobotics/bubblegum_96/Kconfig  |  15 --
 board/ucRobotics/bubblegum_96/MAINTAINERS  |   6 -
 board/ucRobotics/bubblegum_96/Makefile |   3 -
 board/ucRobotics/bubblegum_96/bubblegum_96.c   |  57 -
 configs/bubblegum_96_defconfig |  12 +-
 configs/cubieboard7_defconfig  |   9 +
 doc/board/actions/cubieboard7.rst  | 114 +
 doc/board/actions/index.rst|  10 +
 doc/board/index.rst|   1 +
 drivers/clk/owl/Kconfig|   8 +-
 drivers/clk/owl/Makefile   |   2 +-
 drivers/clk/owl/clk_owl.c  | 155 
 drivers/clk/owl/clk_owl.h  |  64 +
 drivers/clk/owl/clk_s900.c | 137 ---
 drivers/serial/serial_owl.c|   2 +-
 include/configs/bubblegum_96.h |  40 ---
 include/configs/owl-common.h   |  40 +++
 include/dt-bindings/clock/actions,s700-cmu.h   | 118 +
 include/dt-bindings/clock/actions,s900-cmu.h   | 129 ++
 include/dt-bindings/clock/s900_cmu.h   |  77 --
 include/dt-bindings/reset/actions,s700-reset.h |  34 +++
 include/dt-bindings/reset/actions,s900-reset.h |  65 +
 37 files changed, 1607 insertions(+), 486 deletions(-)
 create mode 100644 arch/arm/dts/s700-cubieboard7.dts
 create mode 100644 arch/arm/dts/s700-u-boot.dtsi
 create mode 100644 arch/arm/dts/s700.dtsi
 create mode 100644 arch/arm/dts/s900-u-boot.dtsi
 delete mode 100644 arch/arm/include/asm/arch-owl/clk_s900.h
 create mode 100644 arch/arm/include/asm/arch-owl/regs_s700.h
 create mode 100644 arch/arm/mach-owl/soc.c
 create mode 100644 arch/ar

[PATCH v9 09/12] arm: add support Actions Semi S700

2020-04-01 Thread Amit Singh Tomar
This patch adds basic support for Actions Semi based S700
SoC, which is driven by common owl framework.

Reviewed-by: Andre Przywara 
Signed-off-by: Amit Singh Tomar 
---
Changes since v8:
* Added Reviewed-by tag.
Changes since v7:
* Removed S700 include file.
Changes since v6:
* No changes.
Changes since v5:
* Added reviewed-by tag.
Changes since v4:
* Moved it to 09/11 to 04/11.
Changes since v3:
* Added "SoC" keyword to Actions Semi S700.
Changes since v2:
* Fixed the commit message.
* Checked for the clk->id.
* Added a .data member with SoC type.
* Removed #ifdefs from few places.
Changes since v1:
* Moved CLK and CLK_OWL symbols from defconfig to arch/arm/Kconfig.
---
 arch/arm/mach-owl/Kconfig | 5 +
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/mach-owl/Kconfig b/arch/arm/mach-owl/Kconfig
index 28984c1..cde2ade 100644
--- a/arch/arm/mach-owl/Kconfig
+++ b/arch/arm/mach-owl/Kconfig
@@ -8,6 +8,10 @@ config MACH_S900
 bool "Actions Semi S900 SoC"
 select ARM64
 
+config MACH_S700
+bool "Actions Semi S700 SoC"
+select ARM64
+
 endchoice
 
 config SYS_TEXT_BASE
@@ -18,5 +22,6 @@ config SYS_CONFIG_NAME
 
 config SYS_SOC
 default "s900" if MACH_S900
+default "s700" if MACH_S700
 
 endif
-- 
2.7.4



[PATCH v9 10/12] actions: Move defconfig options to Kconfig

2020-04-01 Thread Amit Singh Tomar
This patch moves some of the config options from bubblegum_96_defconfig
to platform specific Kconfig file.

Reviewed-by: Andre Przywara 
Signed-off-by: Amit Singh Tomar 
---
Changes since v8:
* No changes.
Changes since v7:
* No changes.
Changes since v6:
* remove unnecessary string from SYS_PROMPT.
Changes since v5:
* Newly added patch, was not there in earlier versions.
---
 arch/arm/mach-owl/Kconfig  | 15 +++
 configs/bubblegum_96_defconfig |  5 -
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-owl/Kconfig b/arch/arm/mach-owl/Kconfig
index cde2ade..2b5d725 100644
--- a/arch/arm/mach-owl/Kconfig
+++ b/arch/arm/mach-owl/Kconfig
@@ -24,4 +24,19 @@ config SYS_SOC
 default "s900" if MACH_S900
 default "s700" if MACH_S700
 
+config DISTRO_DEFAULTS
+   default y
+
+config NR_DRAM_BANKS
+   default 1
+
+config SYS_RELOC_GD_ENV_ADDR
+   default y
+
+config SYS_PROMPT
+   default "U-Boot => "
+
+config DISPLAY_BOARDINFO
+   default n
+
 endif
diff --git a/configs/bubblegum_96_defconfig b/configs/bubblegum_96_defconfig
index e76e9a2..0883167 100644
--- a/configs/bubblegum_96_defconfig
+++ b/configs/bubblegum_96_defconfig
@@ -1,19 +1,14 @@
 CONFIG_ARM=y
 CONFIG_ARCH_OWL=y
 CONFIG_ENV_SIZE=0x2000
-CONFIG_NR_DRAM_BANKS=1
 CONFIG_MACH_S900=y
 CONFIG_IDENT_STRING="\nBubblegum-96"
-CONFIG_DISTRO_DEFAULTS=y
 CONFIG_BOOTDELAY=5
 CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="console=ttyOWL5,115200n8"
 # CONFIG_DISPLAY_CPUINFO is not set
-# CONFIG_DISPLAY_BOARDINFO is not set
-CONFIG_SYS_PROMPT="U-Boot => "
 CONFIG_CMD_MD5SUM=y
 CONFIG_CMD_MEMINFO=y
 CONFIG_CMD_CACHE=y
 CONFIG_CMD_TIMER=y
 CONFIG_DEFAULT_DEVICE_TREE="bubblegum_96"
-CONFIG_SYS_RELOC_GD_ENV_ADDR=y
-- 
2.7.4



[PATCH v9 08/12] arm: dts: actions: s700: add u-boot specific dtsi file

2020-04-01 Thread Amit Singh Tomar
Devices like uart and clk are needed to be enabled before relocation.
this patch adds u-boot.dtsi file that mark these device as dm-pre-reloc.

Reviewed-by: Andre Przywara 
Signed-off-by: Amit Singh Tomar 
---
Changes since v8:
* No changes.
Changes since v7:
* No changes.
Changes since v6:
* No changes.
Changes since v5:
* Added reviwed-by tag.
Changes since v4:
* Moved it to 08/11 to 06/11.
Changes since v3:
* Replaced dtsi with dts in subject line along with arm:dts:
  to the prefix.
Changes since v2:
* Added License.
Changes since v1:
* This is newly added file that was *not* present in v1 and
  contains u-boot specific changes.
---
 arch/arm/dts/s700-u-boot.dtsi | 18 ++
 1 file changed, 18 insertions(+)
 create mode 100644 arch/arm/dts/s700-u-boot.dtsi

diff --git a/arch/arm/dts/s700-u-boot.dtsi b/arch/arm/dts/s700-u-boot.dtsi
new file mode 100644
index 000..a527ccc
--- /dev/null
+++ b/arch/arm/dts/s700-u-boot.dtsi
@@ -0,0 +1,18 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2020 Amit Singh Tomar 
+ */
+
+/{
+   soc {
+   u-boot,dm-pre-reloc;
+   };
+};
+
+&uart3 {
+   u-boot,dm-pre-reloc;
+};
+
+&cmu {
+   u-boot,dm-pre-reloc;
+};
-- 
2.7.4



[PATCH v9 12/12] doc: boards: add Cubieboard7 documentation

2020-04-01 Thread Amit Singh Tomar
This adds build and flash steps for Actions S700
based Cubieboard7 board.

Signed-off-by: Amit Singh Tomar 
---
Changes since v8:
* No changes.
Changes since v7:
* No changes.
Changes since v6:
* No changes.
Changes since v5:
* No changes.
Changes since v4:
* No changes.
Changes since v3:
* Convert plain text documentation to reStructuredText format.
Changes since v2:
* No Change.
Changes since v1:
* No Change.
---
 doc/board/actions/cubieboard7.rst | 115 ++
 doc/board/actions/index.rst   |  10 
 doc/board/index.rst   |   1 +
 3 files changed, 126 insertions(+)
 create mode 100644 doc/board/actions/cubieboard7.rst
 create mode 100644 doc/board/actions/index.rst

diff --git a/doc/board/actions/cubieboard7.rst 
b/doc/board/actions/cubieboard7.rst
new file mode 100644
index 000..ce39e6b
--- /dev/null
+++ b/doc/board/actions/cubieboard7.rst
@@ -0,0 +1,115 @@
+.. SPDX-License-Identifier: GPL-2.0+
+.. Copyright (C) 2020 Amit Singh Tomar 
+
+ACTIONS
+
+
+About this
+--
+
+This document describes build and flash steps for Actions S700 SoC based 
Cubieboard7
+board.
+
+Cubieboard7 initial configuration
+-
+
+Default Cubieboard7 comes with pre-installed Android where U-Boot is 
configured with
+a bootdelay of 0, entering a prompt by pressing keys does not seem to work.
+
+Though, one can enter ADFU mode and flash debian image(from host machine) where
+getting into u-boot prompt is easy.
+
+Enter ADFU Mode
+
+
+Before write the firmware, let the development board entering the ADFU mode: 
insert
+one end of the USB cable to the PC, press and hold the ADFU button, and then 
connect
+the other end of the USB cable to the Mini USB port of the development board, 
release
+the ADFU button, after connecting it will enter the ADFU mode.
+
+Check whether entered ADFU Mode
+
+
+The user needs to run the following command on the PC side to check if the ADFU
+device is detected. ID realted to "Actions Semiconductor Co., Ltd"  means that
+the PC side has been correctly detected ADFU device, the development board
+also enter into the ADFU mode.
+
+.. code-block:: none
+
+   $ lsusb
+   Bus 001 Device 005: ID 04f2:b2eb Chicony Electronics Co., Ltd
+   Bus 001 Device 004: ID 0a5c:21e6 Broadcom Corp. BCM20702 Bluetooth 4.0 
[ThinkPad]
+   Bus 001 Device 003: ID 046d:c534 Logitech, Inc. Unifying Receiver
+   Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
+   Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
+   Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
+   Bus 003 Device 013: ID 10d6:10d6 Actions Semiconductor Co., Ltd
+   Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
+
+Flashing debian image
+-
+
+.. code-block:: none
+
+   $ sudo ./ActionsFWU.py --fw=debian-stretch-desktop-cb7-emmc-v2.0.fw
+   ActionsFWU.py   : 1.0.150828.0830
+   libScript.so: 2.3.150825.0951
+   libFileSystem.so: 2.3.150825.0952
+   libProduction.so: 2.3.150915.1527
+   =burn all partition
+   FW_VER: 3.10.37.180608
+   3% DOWNLOAD ADFUDEC ...
+   5% DOWNLOAD BOOT PARA ...
+   7% SWITCH ADFUDEC ...
+   12% DOWNLOAD BL31 ...
+   13% DOWNLOAD BL32 ...
+   15% DOWNLOAD VMLINUX ...
+   20% DOWNLOAD INITRD ...
+   24% DOWNLOAD FDT ...
+   27% DOWNLOAD ADFUS ...
+   30% SWITCH ADFUS ...
+   32% DOWNLOAD MBR ...
+   35% DOWNLOAD PARTITIONS ...
+   WRITE_MBRC_PARTITION
+   35% write p0 size = 2048 : ok
+   WRITE_BOOT_PARTITION
+   35% write p1 size = 2048 : ok
+   WRITE_MISC_PARTITION
+   36% write p2 size = 98304 : ok
+   WRITE_SYSTEM_PARTITION
+   94% write p3 size = 4608000 : ok
+   FORMAT_SWAP_PARTITION
+   94% write p4 size = 20480 : ok
+   95% TRANSFER OVER ...
+   Firmware upgrade successfully!
+
+Debian image can be downloaded from here[1].
+
+Once debian image is flashed, one can get into u-boot prompt by pressing any 
key and from
+there run ums command(make sure, usb cable is connected between host and 
target):
+
+.. code-block:: none
+
+   owl> ums 0 mmc 1
+
+Above command would mount debian image partition on host machine.
+
+Building U-BOOT proper image
+
+
+.. code-block:: none
+
+   $ make clean
+   $ export CROSS_COMPILE=aarch64-linux-gnu-
+   $ make ARCH=arm cubieboard7_defconfig
+   $ make -j16
+   $ mkimage -A arm -T firmware -C none -O u-boot -a 0x1100 -e 0x1100 
-d u-boot-dtb.bin u-boot-dtb.img  >/dev/null
+
+u-boot-dtb.img can now be flashed to debian image partition mounted on host 
machine.
+
+.. code-block:: none
+
+   $ sudo dd if=u-boot-dtb.img of=/dev/sdb bs=1024 seek=3072
+
+[1]: 
https://pan.baidu.com/s/1uawPr0Jao2HgWFLZCLzHAg#list/path=%2FCubieBoard_Download%2FBoard%2FCubieBoard7%2F%E6%96%B9%E7%B3%96%E6%96%B9%E6%A1%88%E5%BC%80%E5%8F%91%E8%B5%84%E6%96%99%

[PATCH v9 11/12] arm: add Cubieboard7 board support

2020-04-01 Thread Amit Singh Tomar
The Cubieboard is a single board computer containing a
Actions S700 SoC(with 4 ARMv8 Cortex-A53 cores).

This patch adds respective defconfig alongwith .dts(copied
from Linux v5.5-rc6 with hash "b3a987b0264d").

Reviewed-by: Andre Przywara 
Signed-off-by: Amit Singh Tomar 
---
Changes since v8:
* No changes.
Changes since v7:
* No changes.
Changes since v6:
* Added Reviewed-by tag.
Changes since v5:
* Trimmed of the cubieboard7_defconfig.
Changes since v4:
* No changes.
Changes since v3:
* added reviewed-by: tag.
Changes since v2:
* No changes.
Changes since v1:
* No changes.
---
 arch/arm/dts/s700-cubieboard7.dts | 92 +++
 configs/cubieboard7_defconfig |  9 
 2 files changed, 101 insertions(+)
 create mode 100644 arch/arm/dts/s700-cubieboard7.dts
 create mode 100644 configs/cubieboard7_defconfig

diff --git a/arch/arm/dts/s700-cubieboard7.dts 
b/arch/arm/dts/s700-cubieboard7.dts
new file mode 100644
index 000..63e375c
--- /dev/null
+++ b/arch/arm/dts/s700-cubieboard7.dts
@@ -0,0 +1,92 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2017 Andreas Färber
+ */
+
+/dts-v1/;
+
+#include "s700.dtsi"
+
+/ {
+   compatible = "cubietech,cubieboard7", "actions,s700";
+   model = "CubieBoard7";
+
+   aliases {
+   serial3 = &uart3;
+   };
+
+   chosen {
+   stdout-path = "serial3:115200n8";
+   };
+
+   memory@0 {
+   device_type = "memory";
+   reg = <0x0 0x0 0x0 0x8000>;
+   };
+
+   memory@1,e000 {
+   device_type = "memory";
+   reg = <0x1 0xe000 0x0 0x0>;
+   };
+};
+
+&i2c0 {
+   status = "okay";
+   pinctrl-names = "default";
+   pinctrl-0 = <&i2c0_default>;
+};
+
+&i2c1 {
+   status = "okay";
+   pinctrl-names = "default";
+   pinctrl-0 = <&i2c1_default>;
+};
+
+&i2c2 {
+   status = "disabled";
+   pinctrl-names = "default";
+   pinctrl-0 = <&i2c2_default>;
+};
+
+&pinctrl {
+   i2c0_default: i2c0_default {
+   pinmux {
+   groups = "i2c0_mfp";
+   function = "i2c0";
+   };
+   pinconf {
+   pins = "i2c0_sclk", "i2c0_sdata";
+   bias-pull-up;
+   };
+   };
+
+   i2c1_default: i2c1_default {
+   pinmux {
+   groups = "i2c1_dummy";
+   function = "i2c1";
+   };
+   pinconf {
+   pins = "i2c1_sclk", "i2c1_sdata";
+   bias-pull-up;
+   };
+   };
+
+   i2c2_default: i2c2_default {
+   pinmux {
+   groups = "i2c2_dummy";
+   function = "i2c2";
+   };
+   pinconf {
+   pins = "i2c2_sclk", "i2c2_sdata";
+   bias-pull-up;
+   };
+   };
+};
+
+&timer {
+   clocks = <&hosc>;
+};
+
+&uart3 {
+   status = "okay";
+};
diff --git a/configs/cubieboard7_defconfig b/configs/cubieboard7_defconfig
new file mode 100644
index 000..d12c293
--- /dev/null
+++ b/configs/cubieboard7_defconfig
@@ -0,0 +1,9 @@
+CONFIG_ARM=y
+CONFIG_ARCH_OWL=y
+CONFIG_MACH_S700=y
+CONFIG_IDENT_STRING="\ncubieboard7"
+CONFIG_BOOTDELAY=5
+CONFIG_USE_BOOTARGS=y
+CONFIG_BOOTARGS="console=ttyOWL3,115200n8"
+# CONFIG_DISPLAY_CPUINFO is not set
+CONFIG_DEFAULT_DEVICE_TREE="s700-cubieboard7"
-- 
2.7.4



[PATCH v9 07/12] arm: actions: add S700 SoC device tree

2020-04-01 Thread Amit Singh Tomar
This patch adds .dtsi file(sync with Linux 5.5-rc6 with hash "b3a987b0264d")
and required binding for S700 SoC that is a 64-bit Quad-core ARM
Cortex-A53 cores.

It also provisions dts file to be built based on selected
platform(CONFIG_MACH_S900/S700).

Reviewed-by: Andre Przywara 
Signed-off-by: Amit Singh Tomar 
---
Changes since v8:
* No changes.
Changes since v7:
* No changes.
Changes since v6:
* No changes.
Changes since v5:
* Added reviwed-by tag.
Changes since v4:
* Move it to 07/11 from 05/11.
Changes since v3:
* Updated commit message to the Linux tag to
  which the dtsi file is synced.
Changes since v2:
* Synced DTS bindings with Linux 5.5.
Changes since v1:
* Moved the u-boot specific changes to s700-u-boot.dtsi, now
  s700.dtsi is in complete sync with Linux 4.20.
---
 arch/arm/dts/Makefile  |   6 +-
 arch/arm/dts/s700.dtsi | 248 +
 include/dt-bindings/clock/actions,s700-cmu.h   | 118 
 include/dt-bindings/reset/actions,s700-reset.h |  34 
 4 files changed, 404 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/dts/s700.dtsi
 create mode 100644 include/dt-bindings/clock/actions,s700-cmu.h
 create mode 100644 include/dt-bindings/reset/actions,s700-reset.h

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 9c593b2..308c76b 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -64,8 +64,10 @@ dtb-$(CONFIG_KIRKWOOD) += \
kirkwood-pogo_e02.dtb \
kirkwood-sheevaplug.dtb
 
-dtb-$(CONFIG_ARCH_OWL) += \
-   bubblegum_96.dtb
+dtb-$(CONFIG_MACH_S900) += \
+bubblegum_96.dtb
+dtb-$(CONFIG_MACH_S700) += \
+s700-cubieboard7.dtb
 
 dtb-$(CONFIG_ROCKCHIP_PX30) += \
px30-evb.dtb \
diff --git a/arch/arm/dts/s700.dtsi b/arch/arm/dts/s700.dtsi
new file mode 100644
index 000..2006ad5
--- /dev/null
+++ b/arch/arm/dts/s700.dtsi
@@ -0,0 +1,248 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2017 Andreas Färber
+ */
+
+#include 
+#include 
+#include 
+
+/ {
+   compatible = "actions,s700";
+   interrupt-parent = <&gic>;
+   #address-cells = <2>;
+   #size-cells = <2>;
+
+   cpus {
+   #address-cells = <2>;
+   #size-cells = <0>;
+
+   cpu0: cpu@0 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x0>;
+   enable-method = "psci";
+   };
+
+   cpu1: cpu@1 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x1>;
+   enable-method = "psci";
+   };
+
+   cpu2: cpu@2 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x2>;
+   enable-method = "psci";
+   };
+
+   cpu3: cpu@3 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x3>;
+   enable-method = "psci";
+   };
+   };
+
+   reserved-memory {
+   #address-cells = <2>;
+   #size-cells = <2>;
+   ranges;
+
+   secmon@1f00 {
+   reg = <0x0 0x1f00 0x0 0x100>;
+   no-map;
+   };
+   };
+
+   psci {
+   compatible = "arm,psci-0.2";
+   method = "smc";
+   };
+
+   arm-pmu {
+   compatible = "arm,cortex-a53-pmu";
+   interrupts = ,
+,
+,
+;
+   interrupt-affinity = <&cpu0>, <&cpu1>, <&cpu2>, <&cpu3>;
+   };
+
+   timer {
+   compatible = "arm,armv8-timer";
+   interrupts = ,
+,
+,
+;
+   };
+
+   hosc: hosc {
+   compatible = "fixed-clock";
+   clock-frequency = <2400>;
+   #clock-cells = <0>;
+   };
+
+   losc: losc {
+   compatible = "fixed-clock";
+   clock-frequency = <32768>;
+   #clock-cells = <0>;
+   };
+
+   soc {
+   compatible = "simple-bus";
+   #address-cel

[PATCH v9 03/12] serial: actions: add compatible string

2020-04-01 Thread Amit Singh Tomar
This patch adds "actions,owl-uart" string to the owl uart driver. It
is also defined in Linux kernel.

Reviewed-by: Andre Przywara 
Signed-off-by: Amit Singh Tomar 
---
Changes since v8:
* No changes.
Changes since v7:
* No changes.
Changes since v6:
* Added Reviewd-by tag.
Changes since v5:
* Moved it to from 06/11 to 03/11.
* Used appropriate commit message.
* Removed the reviwed-by tag.
Changes since v4:
* Moved it to from 09/11 to 06/11.
Changes since v3:
* Used only owl-uart for compatible string.
Changes since v2:
* No changes.
Changes since v1:
* No changes.
---
 drivers/serial/serial_owl.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/serial/serial_owl.c b/drivers/serial/serial_owl.c
index 7ead73e..539acdc 100644
--- a/drivers/serial/serial_owl.c
+++ b/drivers/serial/serial_owl.c
@@ -121,6 +121,7 @@ static const struct dm_serial_ops owl_serial_ops = {
 
 static const struct udevice_id owl_serial_ids[] = {
{ .compatible = "actions,s900-serial" },
+   { .compatible = "actions,owl-uart" },
{ }
 };
 
-- 
2.7.4



[PATCH v9 06/12] clk: actions: Add common clock driver

2020-04-01 Thread Amit Singh Tomar
This patch converts S900 clock driver to something common that can
be used for other SoCs, for instance S700(few of clk registers are same).

Reviewed-by: Andre Przywara 
Signed-off-by: Amit Singh Tomar 
---
Changes since v8:
* Fixed the bubblegum-96 boot issue by introducing
  dev_get_driver_data API to read driver data.
Changes since v7:
* No changes.
Changes since v6:
* Fixed the bug that breaks S900(missing break in switch statement).
Changes since v5:
* No changes.
Changes since v4:
* This patch is re-ordered, moved from 08/11 to 04/11.
Changes since v3:
* Replaced dtsi with dts in subject line along with arm:dts:
  to the prefix.
* Added reviewed-by tag.
Changes since v2:
* Newly added patch, not there in v2/v1.
---
 arch/arm/Kconfig  |   2 +
 arch/arm/include/asm/arch-owl/clk_s900.h  |  57 ---
 arch/arm/include/asm/arch-owl/regs_s700.h |  56 +++
 configs/bubblegum_96_defconfig|   3 -
 drivers/clk/owl/Kconfig   |   8 +-
 drivers/clk/owl/Makefile  |   2 +-
 drivers/clk/owl/clk_owl.c | 155 ++
 drivers/clk/owl/clk_owl.h |  64 
 drivers/clk/owl/clk_s900.c| 137 --
 9 files changed, 280 insertions(+), 204 deletions(-)
 delete mode 100644 arch/arm/include/asm/arch-owl/clk_s900.h
 create mode 100644 arch/arm/include/asm/arch-owl/regs_s700.h
 create mode 100644 drivers/clk/owl/clk_owl.c
 create mode 100644 drivers/clk/owl/clk_owl.h
 delete mode 100644 drivers/clk/owl/clk_s900.c

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index de6b7f9..05658cf 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -876,6 +876,8 @@ config ARCH_OWL
select DM
select DM_SERIAL
select OWL_SERIAL
+   select CLK
+   select CLK_OWL
select OF_CONTROL
imply CMD_DM
 
diff --git a/arch/arm/include/asm/arch-owl/clk_s900.h 
b/arch/arm/include/asm/arch-owl/clk_s900.h
deleted file mode 100644
index 88e88f7..000
--- a/arch/arm/include/asm/arch-owl/clk_s900.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * Actions Semi S900 Clock Definitions
- *
- * Copyright (C) 2015 Actions Semi Co., Ltd.
- * Copyright (C) 2018 Manivannan Sadhasivam 
- *
- */
-
-#ifndef _OWL_CLK_S900_H_
-#define _OWL_CLK_S900_H_
-
-#include 
-
-struct owl_clk_priv {
-   phys_addr_t base;
-};
-
-/* BUSCLK register definitions */
-#define CMU_PDBGDIV_8  7
-#define CMU_PDBGDIV_SHIFT  26
-#define CMU_PDBGDIV_DIV(CMU_PDBGDIV_8 << CMU_PDBGDIV_SHIFT)
-#define CMU_PERDIV_8   7
-#define CMU_PERDIV_SHIFT   20
-#define CMU_PERDIV_DIV (CMU_PERDIV_8 << CMU_PERDIV_SHIFT)
-#define CMU_NOCDIV_2   1
-#define CMU_NOCDIV_SHIFT   19
-#define CMU_NOCDIV_DIV (CMU_NOCDIV_2 << CMU_NOCDIV_SHIFT)
-#define CMU_DMMCLK_SRC_APLL2
-#define CMU_DMMCLK_SRC_SHIFT   10
-#define CMU_DMMCLK_SRC (CMU_DMMCLK_SRC_APLL << CMU_DMMCLK_SRC_SHIFT)
-#define CMU_APBCLK_DIV BIT(8)
-#define CMU_NOCCLK_SRC BIT(7)
-#define CMU_AHBCLK_DIV BIT(4)
-#define CMU_CORECLK_MASK   3
-#define CMU_CORECLK_CPLL   BIT(1)
-#define CMU_CORECLK_HOSC   BIT(0)
-
-/* COREPLL register definitions */
-#define CMU_COREPLL_EN BIT(9)
-#define CMU_COREPLL_HOSC_ENBIT(8)
-#define CMU_COREPLL_OUT(1104 / 24)
-
-/* DEVPLL register definitions */
-#define CMU_DEVPLL_CLK BIT(12)
-#define CMU_DEVPLL_EN  BIT(8)
-#define CMU_DEVPLL_OUT (660 / 6)
-
-/* UARTCLK register definitions */
-#define CMU_UARTCLK_SRC_DEVPLL BIT(16)
-
-/* DEVCLKEN1 register definitions */
-#define CMU_DEVCLKEN1_UART5BIT(21)
-
-#define PLL_STABILITY_WAIT_US  50
-
-#endif
diff --git a/arch/arm/include/asm/arch-owl/regs_s700.h 
b/arch/arm/include/asm/arch-owl/regs_s700.h
new file mode 100644
index 000..2f21c15
--- /dev/null
+++ b/arch/arm/include/asm/arch-owl/regs_s700.h
@@ -0,0 +1,56 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Actions Semi S700 Register Definitions
+ *
+ */
+
+#ifndef _OWL_REGS_S700_H_
+#define _OWL_REGS_S700_H_
+
+#define CMU_COREPLL0x
+#define CMU_DEVPLL 0x0004
+#define CMU_DDRPLL 0x0008
+#define CMU_NANDPLL0x000C
+#define CMU_DISPLAYPLL 0x0010
+#define CMU_AUDIOPLL   0x0014
+#define CMU_TVOUTPLL   0x0018
+#define CMU_BUSCLK 0x001C
+#define CMU_SENSORCLK  0x0020
+#define CMU_LCDCLK 0x0024
+#define CMU_DSIPLLCLK  0x0028
+#define CMU_CSICLK 0x002C
+#define CMU_DECLK  0x0030
+#define CMU_SICLK  0x0034
+#define CMU_BUSCLK10x0038
+#define CMU_HDECLK 0x003C
+#define CMU_VDECLK 0x0040
+#define CMU_VCECLK 0x00

[PATCH v9 04/12] arm: dts: sync dts for Action Semi S900

2020-04-01 Thread Amit Singh Tomar
Synchronize device tree bindings with v5.5-rc6 tag with commit id
"b3a987b0264d".

Also, it removes older clock binding defined for S900 along with undocumented
compatible string "actions,s900-serial" from serial driver and adapts clock
driver to cater to new bindings.

Reviewed-by: Andre Przywara 
Signed-off-by: Amit Singh Tomar 
---
Changes since v8:
* No changes.
Changes since v7:
* No changes.
Changes since v6:
* Added Reviewed-by tag.
Changes since v5:
* Moved it 04/11 from 03/11.
* removed the undocumented compatible string "actions,s900-serial".
* removed the reviewed-by tag.
Changes since v4:
* This patch is re-ordered, moved from 07/11 to 03/11.
* Used the commit-id(12 chars long) in commit message.
Changes since v3:
* Added Reviewed-by: tag.
Changes since v2:
* Newly added patch, not there in v2/v1.
---
 arch/arm/dts/s900.dtsi | 322 +++--
 drivers/clk/owl/clk_s900.c |   6 +-
 drivers/serial/serial_owl.c|   1 -
 include/dt-bindings/clock/actions,s900-cmu.h   | 129 ++
 include/dt-bindings/clock/s900_cmu.h   |  77 --
 include/dt-bindings/reset/actions,s900-reset.h |  65 +
 6 files changed, 498 insertions(+), 102 deletions(-)
 create mode 100644 include/dt-bindings/clock/actions,s900-cmu.h
 delete mode 100644 include/dt-bindings/clock/s900_cmu.h
 create mode 100644 include/dt-bindings/reset/actions,s900-reset.h

diff --git a/arch/arm/dts/s900.dtsi b/arch/arm/dts/s900.dtsi
index 2bbb30a..eb35cf7 100644
--- a/arch/arm/dts/s900.dtsi
+++ b/arch/arm/dts/s900.dtsi
@@ -1,17 +1,94 @@
-// SPDX-License-Identifier: GPL-2.0+
-//
-// Device Tree Source for Actions Semi S900 SoC
-//
-// Copyright (C) 2015 Actions Semi Co., Ltd.
-// Copyright (C) 2018 Manivannan Sadhasivam 
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2017 Andreas Färber
+ */
 
-/dts-v1/;
-#include 
+#include 
+#include 
+#include 
+#include 
 
 / {
compatible = "actions,s900";
-   #address-cells = <0x2>;
-   #size-cells = <0x2>;
+   interrupt-parent = <&gic>;
+   #address-cells = <2>;
+   #size-cells = <2>;
+
+   cpus {
+   #address-cells = <2>;
+   #size-cells = <0>;
+
+   cpu0: cpu@0 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x0>;
+   enable-method = "psci";
+   };
+
+   cpu1: cpu@1 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x1>;
+   enable-method = "psci";
+   };
+
+   cpu2: cpu@2 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x2>;
+   enable-method = "psci";
+   };
+
+   cpu3: cpu@3 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x3>;
+   enable-method = "psci";
+   };
+   };
+
+   reserved-memory {
+   #address-cells = <2>;
+   #size-cells = <2>;
+   ranges;
+
+   secmon@1f00 {
+   reg = <0x0 0x1f00 0x0 0x100>;
+   no-map;
+   };
+   };
+
+   psci {
+   compatible = "arm,psci-0.2";
+   method = "smc";
+   };
+
+   arm-pmu {
+   compatible = "arm,cortex-a53-pmu";
+   interrupts = ,
+,
+,
+;
+   interrupt-affinity = <&cpu0>, <&cpu1>, <&cpu2>, <&cpu3>;
+   };
+
+   timer {
+   compatible = "arm,armv8-timer";
+   interrupts = ,
+,
+,
+;
+   };
+
+   hosc: hosc {
+   compatible = "fixed-clock";
+   clock-frequency = <2400>;
+   #clock-cells = <0>;
+   };
 
losc: losc {
compatible = "fixed-clock";
@@ -26,28 +103,231 @@
};
 
soc {
-   u-boot,dm-pre-reloc;
compatible = "simple-bus";
-   #address-cells = <0x2>;
-   #size-cells = <0x2&g

[PATCH v9 05/12] arm: dts: actions: s900: add u-boot specific dtsi file

2020-04-01 Thread Amit Singh Tomar
Devices like uart and clk are needed to be enabled before relocation.
This patch adds u-boot.dtsi file that mark these device as dm-pre-reloc.

Reviewed-by: Manivannan Sadhasivam 
Signed-off-by: Amit Singh Tomar 
---
Changes since v8:
* No changes.
Changes since v7:
* No changes.
Changes since v6:
* No changes.
Changes since v5:
* No changes.
Changes since v4:
* This patch is re-ordered, moved from 08/11 to 04/11.
Changes since v3:
* Replaced dtsi with dts in subject line along with arm:dts:
  to the prefix.
* Added reviewed-by tag.
Changes since v2:
* Newly added patch, not there in v2/v1.
---
 arch/arm/dts/s900-u-boot.dtsi | 17 +
 1 file changed, 17 insertions(+)
 create mode 100644 arch/arm/dts/s900-u-boot.dtsi

diff --git a/arch/arm/dts/s900-u-boot.dtsi b/arch/arm/dts/s900-u-boot.dtsi
new file mode 100644
index 000..a95f2cc
--- /dev/null
+++ b/arch/arm/dts/s900-u-boot.dtsi
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ */
+
+/{
+   soc {
+   u-boot,dm-pre-reloc;
+   };
+};
+
+&uart5 {
+   u-boot,dm-pre-reloc;
+};
+
+&cmu {
+   u-boot,dm-pre-reloc;
+};
-- 
2.7.4



[PATCH v9 02/12] arm: actions: rename sysmap-s900 to sysmap-owl

2020-04-01 Thread Amit Singh Tomar
Now that memory maps(for both S700 and S900 SoCs) can be managed using
a common file, rename sysmap-s900 to sysmap-owl to reflect the same.

Reviewed-by: Manivannan Sadhasivam 
Signed-off-by: Amit Singh Tomar 
---
Changes since v8:
* No changes.
Changes since v7:
* No changes.
Changes since v6:
* No changes.
Changes since v5:
* No changes.
Changes since v4:
* No changes.
Changes since v3:
* Added reviewed-by tag.
Changes since v2:
* Fixed the commit message and header.
Changes since v1:
* compile sysmap-owl.c against CONFIG_ARM64 now.
---
 arch/arm/mach-owl/Makefile  |  2 +-
 arch/arm/mach-owl/sysmap-owl.c  | 32 
 arch/arm/mach-owl/sysmap-s900.c | 32 
 3 files changed, 33 insertions(+), 33 deletions(-)
 create mode 100644 arch/arm/mach-owl/sysmap-owl.c
 delete mode 100644 arch/arm/mach-owl/sysmap-s900.c

diff --git a/arch/arm/mach-owl/Makefile b/arch/arm/mach-owl/Makefile
index 0b181c6..f3a69eb 100644
--- a/arch/arm/mach-owl/Makefile
+++ b/arch/arm/mach-owl/Makefile
@@ -1,4 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0+
 
 obj-y += soc.o
-obj-y += sysmap-s900.o
+obj-$(CONFIG_ARM64) += sysmap-owl.o
diff --git a/arch/arm/mach-owl/sysmap-owl.c b/arch/arm/mach-owl/sysmap-owl.c
new file mode 100644
index 000..81f6ca2
--- /dev/null
+++ b/arch/arm/mach-owl/sysmap-owl.c
@@ -0,0 +1,32 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Memory map for Actions Semi Owl series SoCs.
+ *
+ * Copyright (C) 2015 Actions Semi Co., Ltd.
+ * Copyright (C) 2018 Manivannan Sadhasivam 
+ */
+
+#include 
+#include 
+
+static struct mm_region owl_mem_map[] = {
+   {
+   .virt = 0x0UL, /* DDR */
+   .phys = 0x0UL, /* DDR */
+   .size = 0x8000UL,
+   .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
+PTE_BLOCK_INNER_SHARE
+   }, {
+   .virt = 0xE000UL, /* Peripheral block */
+   .phys = 0xE000UL, /* Peripheral block */
+   .size = 0x0800UL,
+   .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+PTE_BLOCK_NON_SHARE |
+PTE_BLOCK_PXN | PTE_BLOCK_UXN
+   }, {
+   /* List terminator */
+   0,
+   }
+};
+
+struct mm_region *mem_map = owl_mem_map;
diff --git a/arch/arm/mach-owl/sysmap-s900.c b/arch/arm/mach-owl/sysmap-s900.c
deleted file mode 100644
index f78b639..000
--- a/arch/arm/mach-owl/sysmap-s900.c
+++ /dev/null
@@ -1,32 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Actions Semi S900 Memory map
- *
- * Copyright (C) 2015 Actions Semi Co., Ltd.
- * Copyright (C) 2018 Manivannan Sadhasivam 
- */
-
-#include 
-#include 
-
-static struct mm_region s900_mem_map[] = {
-   {
-   .virt = 0x0UL, /* DDR */
-   .phys = 0x0UL, /* DDR */
-   .size = 0x8000UL,
-   .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
-PTE_BLOCK_INNER_SHARE
-   }, {
-   .virt = 0xE000UL, /* Peripheral block */
-   .phys = 0xE000UL, /* Peripheral block */
-   .size = 0x0800UL,
-   .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
-PTE_BLOCK_NON_SHARE |
-PTE_BLOCK_PXN | PTE_BLOCK_UXN
-   }, {
-   /* List terminator */
-   0,
-   }
-};
-
-struct mm_region *mem_map = s900_mem_map;
-- 
2.7.4



[PATCH v9 01/12] arm: actions: Add common framework for Actions Owl Semi SoCs

2020-04-01 Thread Amit Singh Tomar
This commit adds common arch support for Actions Semi Owl
series SoCs and removes the Bubblegum96 board files.

Reviewed-by: Andre Przywara 
Signed-off-by: Amit Singh Tomar 
---
Changes since v8:
* Added Reviewed-by tag.
Changes since v7:
* Removed S900 specific include file.
* Removed the file list entry in MAINTAINERS file.
Changes since v6:
* No change.
Changes since v5:
* No change.
Changes since v4:
* No change.
Changes since v3:
* Corrected the file list entry in MAINTAINERS file.
Changes since v2:
* Moved the file list details to root MAINTAINERS file.
* Updated the commit message as suggested by Mani.
* Used the "Owl" keyword to describe SoC family.
Changes since v1:
* Moved S700 specific changes to patch 4 of 9.
* Moved couple of symbols from defconfig to arch/arm/Kconfig
  and platform owl Kconfig.
---
 MAINTAINERS  |  3 +-
 arch/arm/Kconfig |  3 +-
 arch/arm/mach-owl/Kconfig| 29 ++
 arch/arm/mach-owl/Makefile   |  1 +
 arch/arm/mach-owl/soc.c  | 57 
 board/ucRobotics/bubblegum_96/Kconfig| 15 
 board/ucRobotics/bubblegum_96/MAINTAINERS|  6 ---
 board/ucRobotics/bubblegum_96/Makefile   |  3 --
 board/ucRobotics/bubblegum_96/bubblegum_96.c | 57 
 configs/bubblegum_96_defconfig   |  4 +-
 include/configs/bubblegum_96.h   | 40 ---
 include/configs/owl-common.h | 40 +++
 12 files changed, 114 insertions(+), 144 deletions(-)
 create mode 100644 arch/arm/mach-owl/soc.c
 delete mode 100644 board/ucRobotics/bubblegum_96/Kconfig
 delete mode 100644 board/ucRobotics/bubblegum_96/MAINTAINERS
 delete mode 100644 board/ucRobotics/bubblegum_96/Makefile
 delete mode 100644 board/ucRobotics/bubblegum_96/bubblegum_96.c
 delete mode 100644 include/configs/bubblegum_96.h
 create mode 100644 include/configs/owl-common.h

diff --git a/MAINTAINERS b/MAINTAINERS
index b50652b..2eaacb7 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -272,9 +272,10 @@ M: Manivannan Sadhasivam 
 S: Maintained
 F: arch/arm/include/asm/arch-owl/
 F: arch/arm/mach-owl/
-F: board/ucRobotics/
 F: drivers/clk/owl/
 F: drivers/serial/serial_owl.c
+F: include/configs/owl-common.h
+F: configs/bubblegum_96_defconfig
 
 ARM RENESAS RMOBILE/R-CAR
 M: Nobuhiro Iwamatsu 
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index bbb1e27..de6b7f9 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -873,9 +873,9 @@ config ARCH_MX5
 
 config ARCH_OWL
bool "Actions Semi OWL SoCs"
-   select ARM64
select DM
select DM_SERIAL
+   select OWL_SERIAL
select OF_CONTROL
imply CMD_DM
 
@@ -1868,7 +1868,6 @@ source "board/spear/spear600/Kconfig"
 source "board/spear/x600/Kconfig"
 source "board/st/stv0991/Kconfig"
 source "board/tcl/sl50/Kconfig"
-source "board/ucRobotics/bubblegum_96/Kconfig"
 source "board/birdland/bav335x/Kconfig"
 source "board/toradex/colibri_pxa270/Kconfig"
 source "board/variscite/dart_6ul/Kconfig"
diff --git a/arch/arm/mach-owl/Kconfig b/arch/arm/mach-owl/Kconfig
index 199e772..28984c1 100644
--- a/arch/arm/mach-owl/Kconfig
+++ b/arch/arm/mach-owl/Kconfig
@@ -1,27 +1,22 @@
 if ARCH_OWL
 
-config SYS_SOC
-   default "owl"
-
 choice
-prompt "Actions Semi OWL SoCs board select"
+prompt "Actions Semi Owl SoC Variant"
 optional
 
-config TARGET_BUBBLEGUM_96
-   bool "96Boards Bubblegum-96"
-   help
- Support for 96Boards Bubblegum-96. This board complies with
- 96Board Consumer Edition Specification. Features:
- - Actions Semi S900 SoC (4xCortex A53, Power VR G6230 GPU)
- - 2GiB RAM
- - 8GiB eMMC, uSD slot
- - WiFi, Bluetooth and GPS module
- - 2x Host, 1x Device USB port
- - HDMI
- - 20-pin low speed and 40-pin high speed expanders, 6 LED, 3 buttons
+config MACH_S900
+bool "Actions Semi S900 SoC"
+select ARM64
 
 endchoice
 
-source "board/ucRobotics/bubblegum_96/Kconfig"
+config SYS_TEXT_BASE
+default 0x1100
+
+config SYS_CONFIG_NAME
+default "owl-common"
+
+config SYS_SOC
+default "s900" if MACH_S900
 
 endif
diff --git a/arch/arm/mach-owl/Makefile b/arch/arm/mach-owl/Makefile
index 1b43dc2..0b181c6 100644
--- a/arch/arm/mach-owl/Makefile
+++ b/arch/arm/mach-owl/Makefile
@@ -1,3 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0+
 
+obj-y += soc.o
 obj-y += sysmap-s900.o
diff --git a/arch/arm/mach-owl/soc.c b/arch/arm/mach-owl/soc.c
new file mode 100644
index 

[PATCH v9 00/12] Actions S700 SoC support

2020-04-01 Thread Amit Singh Tomar
This adds Cubieboard7[1] support based on Action Semi's S700 SoC[2], It's 
Quad-core ARMv8 SoC
with Cortex-A53 cores. Peripheral like UART seems to be compatible with S900 
SoC(basic support
for it is alreay present in u-boot).

This series(v9) fixes a Bug that breaks bubblegum96 board boot(reported by 
Mani). It was
due to fact that driver data read is not proper in the clock driver. There are 
changes in
patch 06/12 to fix it.

Previous series(v8) removes the SoC specific include instead just uses 
owl-common. For this
patch 01/12 and 09/12 changes a bit.

Series(v7) fixes a serious Bug that breaks S900, it was there since v5.Thanks 
to Andre
for pointing it out. 

Series(v6)[3] does following changes:

* [PATCH v5 06/11] becomes [PATCH v6 03/11]
* [PATCH v5 03/11] becomes [PATCH v6 04/11]
* Introduce a new patch to move defconfig options to Kconfig which is [PATCH v6 
10/12]

Series(v5)[4] just re-orders the patches so that U-BOOT(with 
bubblegum96_defconfig) builds
after every patch of the series(suggested by Andre).

S700 support is tested[5] on Cubieboard7 board and S900 support is just 
compiled tested.

This patch series can be tested using below tree:
https://github.com/Atomar25/u-boot/commits/s700_v9

[1]: http://www.cubietech.com/product-detail/cubieboard7/
[2]: http://www.actions-semi.com/en/productview.aspx?id=225
[3]: 
http://u-boot.10912.n7.nabble.com/PATCH-v6-00-12-Actions-S700-SoC-support-td403562.html#a403567
[4]: 
http://u-boot.10912.n7.nabble.com/PATCH-v5-00-11-Actions-S700-SoC-support-td402752.html#a402762
[5]: https://paste.ubuntu.com/p/6HWYM3bwr6/

Amit Singh Tomar (12):
  arm: actions: Add common framework for Actions Owl Semi SoCs
  arm: actions: rename sysmap-s900 to sysmap-owl
  serial: actions: add compatible string
  arm: dts: sync dts for Action Semi S900
  arm: dts: actions: s900: add u-boot specific dtsi file
  clk: actions: Add common clock driver
  arm: actions: add S700 SoC device tree
  arm: dts: actions: s700: add u-boot specific dtsi file
  arm: add support Actions Semi S700
  actions: Move defconfig options to Kconfig
  arm: add Cubieboard7 board support
  doc: boards: add Cubieboard7 documentation

 MAINTAINERS|   2 +
 arch/arm/Kconfig   |   5 +-
 arch/arm/dts/Makefile  |   6 +-
 arch/arm/dts/s700-cubieboard7.dts  |  92 +++
 arch/arm/dts/s700-u-boot.dtsi  |  18 ++
 arch/arm/dts/s700.dtsi | 248 +++
 arch/arm/dts/s900-u-boot.dtsi  |  17 ++
 arch/arm/dts/s900.dtsi | 322 +++--
 arch/arm/include/asm/arch-owl/clk_s900.h   |  57 -
 arch/arm/include/asm/arch-owl/regs_s700.h  |  56 +
 arch/arm/mach-owl/Kconfig  |  50 ++--
 arch/arm/mach-owl/Makefile |   3 +-
 arch/arm/mach-owl/soc.c|  57 +
 arch/arm/mach-owl/sysmap-owl.c |  32 +++
 arch/arm/mach-owl/sysmap-s900.c|  32 ---
 board/ucRobotics/bubblegum_96/Kconfig  |  15 --
 board/ucRobotics/bubblegum_96/MAINTAINERS  |   6 -
 board/ucRobotics/bubblegum_96/Makefile |   3 -
 board/ucRobotics/bubblegum_96/bubblegum_96.c   |  57 -
 configs/bubblegum_96_defconfig |  12 +-
 configs/cubieboard7_defconfig  |   9 +
 doc/board/actions/cubieboard7.rst  | 115 +
 doc/board/actions/index.rst|  10 +
 doc/board/index.rst|   1 +
 drivers/clk/owl/Kconfig|   8 +-
 drivers/clk/owl/Makefile   |   2 +-
 drivers/clk/owl/clk_owl.c  | 153 
 drivers/clk/owl/clk_owl.h  |  65 +
 drivers/clk/owl/clk_s900.c | 137 ---
 drivers/serial/serial_owl.c|   2 +-
 include/configs/bubblegum_96.h |  40 ---
 include/configs/owl-common.h   |  40 +++
 include/configs/s700.h |  13 +
 include/configs/s900.h |  16 ++
 include/dt-bindings/clock/actions,s700-cmu.h   | 118 +
 include/dt-bindings/clock/actions,s900-cmu.h   | 129 ++
 include/dt-bindings/clock/s900_cmu.h   |  77 --
 include/dt-bindings/reset/actions,s700-reset.h |  34 +++
 include/dt-bindings/reset/actions,s900-reset.h |  65 +
 39 files changed, 1638 insertions(+), 486 deletions(-)
 create mode 100644 arch/arm/dts/s700-cubieboard7.dts
 create mode 100644 arch/arm/dts/s700-u-boot.dtsi
 create mode 100644 arch/arm/dts/s700.dtsi
 create mode 100644 arch/arm/dts/s900-u-boot.dtsi
 delete mode 100644 arch/arm/include/asm/arch-owl/clk_s900.h
 create mode 100644 arch/arm/include/asm/arch-owl/regs_s700.h
 create mode 100644 arch/arm/mach-owl/soc.c
 create mode 100644 arch/arm/mach-owl/sysmap-owl.c
 delete m

[PATCH v8 12/12] doc: boards: add Cubieboard7 documentation

2020-03-21 Thread Amit Singh Tomar
This adds build and flash steps for Actions S700
based Cubieboard7 board.

Signed-off-by: Amit Singh Tomar 
---
Changes since v7:
* No changes.
Changes since v6:
* No changes.
Changes since v5:
* No changes.
Changes since v4:
* No changes.
Changes since v3:
* Convert plain text documentation to reStructuredText format.
Changes since v2:
* No Change.
Changes since v1:
* No Change.
---
 doc/board/actions/cubieboard7.rst | 115 ++
 doc/board/actions/index.rst   |  10 
 doc/board/index.rst   |   1 +
 3 files changed, 126 insertions(+)
 create mode 100644 doc/board/actions/cubieboard7.rst
 create mode 100644 doc/board/actions/index.rst

diff --git a/doc/board/actions/cubieboard7.rst 
b/doc/board/actions/cubieboard7.rst
new file mode 100644
index 000..ce39e6b
--- /dev/null
+++ b/doc/board/actions/cubieboard7.rst
@@ -0,0 +1,115 @@
+.. SPDX-License-Identifier: GPL-2.0+
+.. Copyright (C) 2020 Amit Singh Tomar 
+
+ACTIONS
+
+
+About this
+--
+
+This document describes build and flash steps for Actions S700 SoC based 
Cubieboard7
+board.
+
+Cubieboard7 initial configuration
+-
+
+Default Cubieboard7 comes with pre-installed Android where U-Boot is 
configured with
+a bootdelay of 0, entering a prompt by pressing keys does not seem to work.
+
+Though, one can enter ADFU mode and flash debian image(from host machine) where
+getting into u-boot prompt is easy.
+
+Enter ADFU Mode
+
+
+Before write the firmware, let the development board entering the ADFU mode: 
insert
+one end of the USB cable to the PC, press and hold the ADFU button, and then 
connect
+the other end of the USB cable to the Mini USB port of the development board, 
release
+the ADFU button, after connecting it will enter the ADFU mode.
+
+Check whether entered ADFU Mode
+
+
+The user needs to run the following command on the PC side to check if the ADFU
+device is detected. ID realted to "Actions Semiconductor Co., Ltd"  means that
+the PC side has been correctly detected ADFU device, the development board
+also enter into the ADFU mode.
+
+.. code-block:: none
+
+   $ lsusb
+   Bus 001 Device 005: ID 04f2:b2eb Chicony Electronics Co., Ltd
+   Bus 001 Device 004: ID 0a5c:21e6 Broadcom Corp. BCM20702 Bluetooth 4.0 
[ThinkPad]
+   Bus 001 Device 003: ID 046d:c534 Logitech, Inc. Unifying Receiver
+   Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
+   Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
+   Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
+   Bus 003 Device 013: ID 10d6:10d6 Actions Semiconductor Co., Ltd
+   Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
+
+Flashing debian image
+-
+
+.. code-block:: none
+
+   $ sudo ./ActionsFWU.py --fw=debian-stretch-desktop-cb7-emmc-v2.0.fw
+   ActionsFWU.py   : 1.0.150828.0830
+   libScript.so: 2.3.150825.0951
+   libFileSystem.so: 2.3.150825.0952
+   libProduction.so: 2.3.150915.1527
+   =burn all partition
+   FW_VER: 3.10.37.180608
+   3% DOWNLOAD ADFUDEC ...
+   5% DOWNLOAD BOOT PARA ...
+   7% SWITCH ADFUDEC ...
+   12% DOWNLOAD BL31 ...
+   13% DOWNLOAD BL32 ...
+   15% DOWNLOAD VMLINUX ...
+   20% DOWNLOAD INITRD ...
+   24% DOWNLOAD FDT ...
+   27% DOWNLOAD ADFUS ...
+   30% SWITCH ADFUS ...
+   32% DOWNLOAD MBR ...
+   35% DOWNLOAD PARTITIONS ...
+   WRITE_MBRC_PARTITION
+   35% write p0 size = 2048 : ok
+   WRITE_BOOT_PARTITION
+   35% write p1 size = 2048 : ok
+   WRITE_MISC_PARTITION
+   36% write p2 size = 98304 : ok
+   WRITE_SYSTEM_PARTITION
+   94% write p3 size = 4608000 : ok
+   FORMAT_SWAP_PARTITION
+   94% write p4 size = 20480 : ok
+   95% TRANSFER OVER ...
+   Firmware upgrade successfully!
+
+Debian image can be downloaded from here[1].
+
+Once debian image is flashed, one can get into u-boot prompt by pressing any 
key and from
+there run ums command(make sure, usb cable is connected between host and 
target):
+
+.. code-block:: none
+
+   owl> ums 0 mmc 1
+
+Above command would mount debian image partition on host machine.
+
+Building U-BOOT proper image
+
+
+.. code-block:: none
+
+   $ make clean
+   $ export CROSS_COMPILE=aarch64-linux-gnu-
+   $ make ARCH=arm cubieboard7_defconfig
+   $ make -j16
+   $ mkimage -A arm -T firmware -C none -O u-boot -a 0x1100 -e 0x1100 
-d u-boot-dtb.bin u-boot-dtb.img  >/dev/null
+
+u-boot-dtb.img can now be flashed to debian image partition mounted on host 
machine.
+
+.. code-block:: none
+
+   $ sudo dd if=u-boot-dtb.img of=/dev/sdb bs=1024 seek=3072
+
+[1]: 
https://pan.baidu.com/s/1uawPr0Jao2HgWFLZCLzHAg#list/path=%2FCubieBoard_Download%2FBoard%2FCubieBoard7%2F%E6%96%B9%E7%B3%96%E6%96%B9%E6%A1%88%E5%BC%80%E5%8F%91%E8%B5%84%E6%96%99%2FImage%2FDebian%2FV2.1-test&parentPath=

[PATCH v8 11/12] arm: add Cubieboard7 board support

2020-03-21 Thread Amit Singh Tomar
The Cubieboard is a single board computer containing a
Actions S700 SoC(with 4 ARMv8 Cortex-A53 cores).

This patch adds respective defconfig alongwith .dts(copied
from Linux v5.5-rc6 with hash "b3a987b0264d").

Reviewed-by: Andre Przywara 
Signed-off-by: Amit Singh Tomar 
---
Changes since v7:
* No changes.
Changes since v6:
* Added Reviewed-by tag.
Changes since v5:
* Trimmed of the cubieboard7_defconfig.
Changes since v4:
* No changes.
Changes since v3:
* added reviewed-by: tag.
Changes since v2:
* No changes.
Changes since v1:
* No changes.
---
 arch/arm/dts/s700-cubieboard7.dts | 92 +++
 configs/cubieboard7_defconfig |  9 
 2 files changed, 101 insertions(+)
 create mode 100644 arch/arm/dts/s700-cubieboard7.dts
 create mode 100644 configs/cubieboard7_defconfig

diff --git a/arch/arm/dts/s700-cubieboard7.dts 
b/arch/arm/dts/s700-cubieboard7.dts
new file mode 100644
index 000..63e375c
--- /dev/null
+++ b/arch/arm/dts/s700-cubieboard7.dts
@@ -0,0 +1,92 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2017 Andreas Färber
+ */
+
+/dts-v1/;
+
+#include "s700.dtsi"
+
+/ {
+   compatible = "cubietech,cubieboard7", "actions,s700";
+   model = "CubieBoard7";
+
+   aliases {
+   serial3 = &uart3;
+   };
+
+   chosen {
+   stdout-path = "serial3:115200n8";
+   };
+
+   memory@0 {
+   device_type = "memory";
+   reg = <0x0 0x0 0x0 0x8000>;
+   };
+
+   memory@1,e000 {
+   device_type = "memory";
+   reg = <0x1 0xe000 0x0 0x0>;
+   };
+};
+
+&i2c0 {
+   status = "okay";
+   pinctrl-names = "default";
+   pinctrl-0 = <&i2c0_default>;
+};
+
+&i2c1 {
+   status = "okay";
+   pinctrl-names = "default";
+   pinctrl-0 = <&i2c1_default>;
+};
+
+&i2c2 {
+   status = "disabled";
+   pinctrl-names = "default";
+   pinctrl-0 = <&i2c2_default>;
+};
+
+&pinctrl {
+   i2c0_default: i2c0_default {
+   pinmux {
+   groups = "i2c0_mfp";
+   function = "i2c0";
+   };
+   pinconf {
+   pins = "i2c0_sclk", "i2c0_sdata";
+   bias-pull-up;
+   };
+   };
+
+   i2c1_default: i2c1_default {
+   pinmux {
+   groups = "i2c1_dummy";
+   function = "i2c1";
+   };
+   pinconf {
+   pins = "i2c1_sclk", "i2c1_sdata";
+   bias-pull-up;
+   };
+   };
+
+   i2c2_default: i2c2_default {
+   pinmux {
+   groups = "i2c2_dummy";
+   function = "i2c2";
+   };
+   pinconf {
+   pins = "i2c2_sclk", "i2c2_sdata";
+   bias-pull-up;
+   };
+   };
+};
+
+&timer {
+   clocks = <&hosc>;
+};
+
+&uart3 {
+   status = "okay";
+};
diff --git a/configs/cubieboard7_defconfig b/configs/cubieboard7_defconfig
new file mode 100644
index 000..d12c293
--- /dev/null
+++ b/configs/cubieboard7_defconfig
@@ -0,0 +1,9 @@
+CONFIG_ARM=y
+CONFIG_ARCH_OWL=y
+CONFIG_MACH_S700=y
+CONFIG_IDENT_STRING="\ncubieboard7"
+CONFIG_BOOTDELAY=5
+CONFIG_USE_BOOTARGS=y
+CONFIG_BOOTARGS="console=ttyOWL3,115200n8"
+# CONFIG_DISPLAY_CPUINFO is not set
+CONFIG_DEFAULT_DEVICE_TREE="s700-cubieboard7"
-- 
2.7.4



[PATCH v8 07/12] arm: actions: add S700 SoC device tree

2020-03-21 Thread Amit Singh Tomar
This patch adds .dtsi file(sync with Linux 5.5-rc6 with hash "b3a987b0264d")
and required binding for S700 SoC that is a 64-bit Quad-core ARM
Cortex-A53 cores.

It also provisions dts file to be built based on selected
platform(CONFIG_MACH_S900/S700).

Reviewed-by: Andre Przywara 
Signed-off-by: Amit Singh Tomar 
---
Changes since v7:
* No changes.
Changes since v6:
* No changes.
Changes since v5:
* Added reviwed-by tag.
Changes since v4:
* Move it to 07/11 from 05/11.
Changes since v3:
* Updated commit message to the Linux tag to
  which the dtsi file is synced.
Changes since v2:
* Synced DTS bindings with Linux 5.5.
Changes since v1:
* Moved the u-boot specific changes to s700-u-boot.dtsi, now
  s700.dtsi is in complete sync with Linux 4.20.
---
 arch/arm/dts/Makefile  |   6 +-
 arch/arm/dts/s700.dtsi | 248 +
 include/dt-bindings/clock/actions,s700-cmu.h   | 118 
 include/dt-bindings/reset/actions,s700-reset.h |  34 
 4 files changed, 404 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/dts/s700.dtsi
 create mode 100644 include/dt-bindings/clock/actions,s700-cmu.h
 create mode 100644 include/dt-bindings/reset/actions,s700-reset.h

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 9c593b2..308c76b 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -64,8 +64,10 @@ dtb-$(CONFIG_KIRKWOOD) += \
kirkwood-pogo_e02.dtb \
kirkwood-sheevaplug.dtb
 
-dtb-$(CONFIG_ARCH_OWL) += \
-   bubblegum_96.dtb
+dtb-$(CONFIG_MACH_S900) += \
+bubblegum_96.dtb
+dtb-$(CONFIG_MACH_S700) += \
+s700-cubieboard7.dtb
 
 dtb-$(CONFIG_ROCKCHIP_PX30) += \
px30-evb.dtb \
diff --git a/arch/arm/dts/s700.dtsi b/arch/arm/dts/s700.dtsi
new file mode 100644
index 000..2006ad5
--- /dev/null
+++ b/arch/arm/dts/s700.dtsi
@@ -0,0 +1,248 @@
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2017 Andreas Färber
+ */
+
+#include 
+#include 
+#include 
+
+/ {
+   compatible = "actions,s700";
+   interrupt-parent = <&gic>;
+   #address-cells = <2>;
+   #size-cells = <2>;
+
+   cpus {
+   #address-cells = <2>;
+   #size-cells = <0>;
+
+   cpu0: cpu@0 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x0>;
+   enable-method = "psci";
+   };
+
+   cpu1: cpu@1 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x1>;
+   enable-method = "psci";
+   };
+
+   cpu2: cpu@2 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x2>;
+   enable-method = "psci";
+   };
+
+   cpu3: cpu@3 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x3>;
+   enable-method = "psci";
+   };
+   };
+
+   reserved-memory {
+   #address-cells = <2>;
+   #size-cells = <2>;
+   ranges;
+
+   secmon@1f00 {
+   reg = <0x0 0x1f00 0x0 0x100>;
+   no-map;
+   };
+   };
+
+   psci {
+   compatible = "arm,psci-0.2";
+   method = "smc";
+   };
+
+   arm-pmu {
+   compatible = "arm,cortex-a53-pmu";
+   interrupts = ,
+,
+,
+;
+   interrupt-affinity = <&cpu0>, <&cpu1>, <&cpu2>, <&cpu3>;
+   };
+
+   timer {
+   compatible = "arm,armv8-timer";
+   interrupts = ,
+,
+,
+;
+   };
+
+   hosc: hosc {
+   compatible = "fixed-clock";
+   clock-frequency = <2400>;
+   #clock-cells = <0>;
+   };
+
+   losc: losc {
+   compatible = "fixed-clock";
+   clock-frequency = <32768>;
+   #clock-cells = <0>;
+   };
+
+   soc {
+   compatible = "simple-bus";
+   #address-cells = <2>;
+   #size-cells = <2>;
+ 

[PATCH v8 04/12] arm: dts: sync dts for Action Semi S900

2020-03-21 Thread Amit Singh Tomar
Synchronize device tree bindings with v5.5-rc6 tag with commit id
"b3a987b0264d".

Also, it removes older clock binding defined for S900 along with undocumented
compatible string "actions,s900-serial" from serial driver and adapts clock
driver to cater to new bindings.

Reviewed-by: Andre Przywara 
Signed-off-by: Amit Singh Tomar 
---
Changes since v7:
* No changes.
Changes since v6:
* Added Reviewed-by tag.
Changes since v5:
* Moved it 04/11 from 03/11.
* removed the undocumented compatible string "actions,s900-serial".
* removed the reviewed-by tag.
Changes since v4:
* This patch is re-ordered, moved from 07/11 to 03/11.
* Used the commit-id(12 chars long) in commit message.
Changes since v3:
* Added Reviewed-by: tag.
Changes since v2:
* Newly added patch, not there in v2/v1.
---
 arch/arm/dts/s900.dtsi | 322 +++--
 drivers/clk/owl/clk_s900.c |   6 +-
 drivers/serial/serial_owl.c|   1 -
 include/dt-bindings/clock/actions,s900-cmu.h   | 129 ++
 include/dt-bindings/clock/s900_cmu.h   |  77 --
 include/dt-bindings/reset/actions,s900-reset.h |  65 +
 6 files changed, 498 insertions(+), 102 deletions(-)
 create mode 100644 include/dt-bindings/clock/actions,s900-cmu.h
 delete mode 100644 include/dt-bindings/clock/s900_cmu.h
 create mode 100644 include/dt-bindings/reset/actions,s900-reset.h

diff --git a/arch/arm/dts/s900.dtsi b/arch/arm/dts/s900.dtsi
index 2bbb30a..eb35cf7 100644
--- a/arch/arm/dts/s900.dtsi
+++ b/arch/arm/dts/s900.dtsi
@@ -1,17 +1,94 @@
-// SPDX-License-Identifier: GPL-2.0+
-//
-// Device Tree Source for Actions Semi S900 SoC
-//
-// Copyright (C) 2015 Actions Semi Co., Ltd.
-// Copyright (C) 2018 Manivannan Sadhasivam 
+// SPDX-License-Identifier: (GPL-2.0+ OR MIT)
+/*
+ * Copyright (c) 2017 Andreas Färber
+ */
 
-/dts-v1/;
-#include 
+#include 
+#include 
+#include 
+#include 
 
 / {
compatible = "actions,s900";
-   #address-cells = <0x2>;
-   #size-cells = <0x2>;
+   interrupt-parent = <&gic>;
+   #address-cells = <2>;
+   #size-cells = <2>;
+
+   cpus {
+   #address-cells = <2>;
+   #size-cells = <0>;
+
+   cpu0: cpu@0 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x0>;
+   enable-method = "psci";
+   };
+
+   cpu1: cpu@1 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x1>;
+   enable-method = "psci";
+   };
+
+   cpu2: cpu@2 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x2>;
+   enable-method = "psci";
+   };
+
+   cpu3: cpu@3 {
+   device_type = "cpu";
+   compatible = "arm,cortex-a53";
+   reg = <0x0 0x3>;
+   enable-method = "psci";
+   };
+   };
+
+   reserved-memory {
+   #address-cells = <2>;
+   #size-cells = <2>;
+   ranges;
+
+   secmon@1f00 {
+   reg = <0x0 0x1f00 0x0 0x100>;
+   no-map;
+   };
+   };
+
+   psci {
+   compatible = "arm,psci-0.2";
+   method = "smc";
+   };
+
+   arm-pmu {
+   compatible = "arm,cortex-a53-pmu";
+   interrupts = ,
+,
+,
+;
+   interrupt-affinity = <&cpu0>, <&cpu1>, <&cpu2>, <&cpu3>;
+   };
+
+   timer {
+   compatible = "arm,armv8-timer";
+   interrupts = ,
+,
+,
+;
+   };
+
+   hosc: hosc {
+   compatible = "fixed-clock";
+   clock-frequency = <2400>;
+   #clock-cells = <0>;
+   };
 
losc: losc {
compatible = "fixed-clock";
@@ -26,28 +103,231 @@
};
 
soc {
-   u-boot,dm-pre-reloc;
compatible = "simple-bus";
-   #address-cells = <0x2>;
-   #size-cells = <0x2>;
+   #address-cells = <2>;
+   

[PATCH v8 10/12] actions: Move defconfig options to Kconfig

2020-03-21 Thread Amit Singh Tomar
This patch moves some of the config options from bubblegum_96_defconfig
to platform specific Kconfig file.

Reviewed-by: Andre Przywara 
Signed-off-by: Amit Singh Tomar 
---
Changes since v7:
* No changes.
Changes since v6:
* remove unnecessary string from SYS_PROMPT. 
Changes since v5:
* Newly added patch, was not there in earlier versions.
---
 arch/arm/mach-owl/Kconfig  | 15 +++
 configs/bubblegum_96_defconfig |  5 -
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-owl/Kconfig b/arch/arm/mach-owl/Kconfig
index 1d59d8f..8344081 100644
--- a/arch/arm/mach-owl/Kconfig
+++ b/arch/arm/mach-owl/Kconfig
@@ -25,4 +25,19 @@ config SYS_SOC
 default "s900" if MACH_S900
 default "s700" if MACH_S700
 
+config DISTRO_DEFAULTS
+   default y
+
+config NR_DRAM_BANKS
+   default 1
+
+config SYS_RELOC_GD_ENV_ADDR
+   default y
+
+config SYS_PROMPT
+   default "U-Boot => "
+
+config DISPLAY_BOARDINFO
+   default n
+
 endif
diff --git a/configs/bubblegum_96_defconfig b/configs/bubblegum_96_defconfig
index e76e9a2..0883167 100644
--- a/configs/bubblegum_96_defconfig
+++ b/configs/bubblegum_96_defconfig
@@ -1,19 +1,14 @@
 CONFIG_ARM=y
 CONFIG_ARCH_OWL=y
 CONFIG_ENV_SIZE=0x2000
-CONFIG_NR_DRAM_BANKS=1
 CONFIG_MACH_S900=y
 CONFIG_IDENT_STRING="\nBubblegum-96"
-CONFIG_DISTRO_DEFAULTS=y
 CONFIG_BOOTDELAY=5
 CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="console=ttyOWL5,115200n8"
 # CONFIG_DISPLAY_CPUINFO is not set
-# CONFIG_DISPLAY_BOARDINFO is not set
-CONFIG_SYS_PROMPT="U-Boot => "
 CONFIG_CMD_MD5SUM=y
 CONFIG_CMD_MEMINFO=y
 CONFIG_CMD_CACHE=y
 CONFIG_CMD_TIMER=y
 CONFIG_DEFAULT_DEVICE_TREE="bubblegum_96"
-CONFIG_SYS_RELOC_GD_ENV_ADDR=y
-- 
2.7.4



[PATCH v8 09/12] arm: add support Actions Semi S700

2020-03-21 Thread Amit Singh Tomar
This patch adds basic support for Actions Semi based S700
SoC, which is driven by common owl framework.

Signed-off-by: Amit Singh Tomar 
---
Changes since v7:
* Removed S700 include file.
Changes since v6:
* No changes.
Changes since v5:
* Added reviewed-by tag.
Changes since v4:
* Moved it to 09/11 to 04/11.
Changes since v3:
* Added "SoC" keyword to Actions Semi S700.
Changes since v2:
* Fixed the commit message.
* Checked for the clk->id.
* Added a .data member with SoC type.
* Removed #ifdefs from few places.
Changes since v1:
* Moved CLK and CLK_OWL symbols from defconfig to arch/arm/Kconfig.
---
 arch/arm/mach-owl/Kconfig | 5 +
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/mach-owl/Kconfig b/arch/arm/mach-owl/Kconfig
index 28984c1..cde2ade 100644
--- a/arch/arm/mach-owl/Kconfig
+++ b/arch/arm/mach-owl/Kconfig
@@ -8,6 +8,10 @@ config MACH_S900
 bool "Actions Semi S900 SoC"
 select ARM64
 
+config MACH_S700
+bool "Actions Semi S700 SoC"
+select ARM64
+
 endchoice
 
 config SYS_TEXT_BASE
@@ -18,5 +22,6 @@ config SYS_CONFIG_NAME
 
 config SYS_SOC
 default "s900" if MACH_S900
+default "s700" if MACH_S700
 
 endif
-- 
2.7.4



[PATCH v8 08/12] arm: dts: actions: s700: add u-boot specific dtsi file

2020-03-21 Thread Amit Singh Tomar
Devices like uart and clk are needed to be enabled before relocation.
this patch adds u-boot.dtsi file that mark these device as dm-pre-reloc.

Reviewed-by: Andre Przywara 
Signed-off-by: Amit Singh Tomar 
---
Changes since v7:
* No changes.
Changes since v6:
* No changes.
Changes since v5:
* Added reviwed-by tag.
Changes since v4:
* Moved it to 08/11 to 06/11.
Changes since v3:
* Replaced dtsi with dts in subject line along with arm:dts:
  to the prefix.
Changes since v2:
* Added License.
Changes since v1:
* This is newly added file that was *not* present in v1 and
  contains u-boot specific changes.
---
 arch/arm/dts/s700-u-boot.dtsi | 18 ++
 1 file changed, 18 insertions(+)
 create mode 100644 arch/arm/dts/s700-u-boot.dtsi

diff --git a/arch/arm/dts/s700-u-boot.dtsi b/arch/arm/dts/s700-u-boot.dtsi
new file mode 100644
index 000..a527ccc
--- /dev/null
+++ b/arch/arm/dts/s700-u-boot.dtsi
@@ -0,0 +1,18 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2020 Amit Singh Tomar 
+ */
+
+/{
+   soc {
+   u-boot,dm-pre-reloc;
+   };
+};
+
+&uart3 {
+   u-boot,dm-pre-reloc;
+};
+
+&cmu {
+   u-boot,dm-pre-reloc;
+};
-- 
2.7.4



[PATCH v8 06/12] clk: actions: Add common clock driver

2020-03-21 Thread Amit Singh Tomar
This patch converts S900 clock driver to something common that can
be used for other SoCs, for instance S700(few of clk registers are same).

Reviewed-by: Andre Przywara 
Signed-off-by: Amit Singh Tomar 
---
Changes since v7:
* No changes.
Changes since v6:
* Fixed the bug that breaks S900(missing break in switch statement).
Changes since v5:
* No changes.
Changes since v4:
* This patch is re-ordered, moved from 08/11 to 04/11.
Changes since v3:
* Replaced dtsi with dts in subject line along with arm:dts:
  to the prefix.
* Added reviewed-by tag.
Changes since v2:
* Newly added patch, not there in v2/v1.
---
 arch/arm/Kconfig  |   2 +
 arch/arm/include/asm/arch-owl/clk_s900.h  |  57 ---
 arch/arm/include/asm/arch-owl/regs_s700.h |  56 +++
 configs/bubblegum_96_defconfig|   3 -
 drivers/clk/owl/Kconfig   |   8 +-
 drivers/clk/owl/Makefile  |   2 +-
 drivers/clk/owl/clk_owl.c | 153 ++
 drivers/clk/owl/clk_owl.h |  65 +
 drivers/clk/owl/clk_s900.c| 137 --
 9 files changed, 279 insertions(+), 204 deletions(-)
 delete mode 100644 arch/arm/include/asm/arch-owl/clk_s900.h
 create mode 100644 arch/arm/include/asm/arch-owl/regs_s700.h
 create mode 100644 drivers/clk/owl/clk_owl.c
 create mode 100644 drivers/clk/owl/clk_owl.h
 delete mode 100644 drivers/clk/owl/clk_s900.c

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 1cfdcb6..dba4d8c 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -876,6 +876,8 @@ config ARCH_OWL
select DM
select DM_SERIAL
select OWL_SERIAL
+   select CLK
+   select CLK_OWL
select OF_CONTROL
imply CMD_DM
 
diff --git a/arch/arm/include/asm/arch-owl/clk_s900.h 
b/arch/arm/include/asm/arch-owl/clk_s900.h
deleted file mode 100644
index 88e88f7..000
--- a/arch/arm/include/asm/arch-owl/clk_s900.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * Actions Semi S900 Clock Definitions
- *
- * Copyright (C) 2015 Actions Semi Co., Ltd.
- * Copyright (C) 2018 Manivannan Sadhasivam 
- *
- */
-
-#ifndef _OWL_CLK_S900_H_
-#define _OWL_CLK_S900_H_
-
-#include 
-
-struct owl_clk_priv {
-   phys_addr_t base;
-};
-
-/* BUSCLK register definitions */
-#define CMU_PDBGDIV_8  7
-#define CMU_PDBGDIV_SHIFT  26
-#define CMU_PDBGDIV_DIV(CMU_PDBGDIV_8 << CMU_PDBGDIV_SHIFT)
-#define CMU_PERDIV_8   7
-#define CMU_PERDIV_SHIFT   20
-#define CMU_PERDIV_DIV (CMU_PERDIV_8 << CMU_PERDIV_SHIFT)
-#define CMU_NOCDIV_2   1
-#define CMU_NOCDIV_SHIFT   19
-#define CMU_NOCDIV_DIV (CMU_NOCDIV_2 << CMU_NOCDIV_SHIFT)
-#define CMU_DMMCLK_SRC_APLL2
-#define CMU_DMMCLK_SRC_SHIFT   10
-#define CMU_DMMCLK_SRC (CMU_DMMCLK_SRC_APLL << CMU_DMMCLK_SRC_SHIFT)
-#define CMU_APBCLK_DIV BIT(8)
-#define CMU_NOCCLK_SRC BIT(7)
-#define CMU_AHBCLK_DIV BIT(4)
-#define CMU_CORECLK_MASK   3
-#define CMU_CORECLK_CPLL   BIT(1)
-#define CMU_CORECLK_HOSC   BIT(0)
-
-/* COREPLL register definitions */
-#define CMU_COREPLL_EN BIT(9)
-#define CMU_COREPLL_HOSC_ENBIT(8)
-#define CMU_COREPLL_OUT(1104 / 24)
-
-/* DEVPLL register definitions */
-#define CMU_DEVPLL_CLK BIT(12)
-#define CMU_DEVPLL_EN  BIT(8)
-#define CMU_DEVPLL_OUT (660 / 6)
-
-/* UARTCLK register definitions */
-#define CMU_UARTCLK_SRC_DEVPLL BIT(16)
-
-/* DEVCLKEN1 register definitions */
-#define CMU_DEVCLKEN1_UART5BIT(21)
-
-#define PLL_STABILITY_WAIT_US  50
-
-#endif
diff --git a/arch/arm/include/asm/arch-owl/regs_s700.h 
b/arch/arm/include/asm/arch-owl/regs_s700.h
new file mode 100644
index 000..2f21c15
--- /dev/null
+++ b/arch/arm/include/asm/arch-owl/regs_s700.h
@@ -0,0 +1,56 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Actions Semi S700 Register Definitions
+ *
+ */
+
+#ifndef _OWL_REGS_S700_H_
+#define _OWL_REGS_S700_H_
+
+#define CMU_COREPLL0x
+#define CMU_DEVPLL 0x0004
+#define CMU_DDRPLL 0x0008
+#define CMU_NANDPLL0x000C
+#define CMU_DISPLAYPLL 0x0010
+#define CMU_AUDIOPLL   0x0014
+#define CMU_TVOUTPLL   0x0018
+#define CMU_BUSCLK 0x001C
+#define CMU_SENSORCLK  0x0020
+#define CMU_LCDCLK 0x0024
+#define CMU_DSIPLLCLK  0x0028
+#define CMU_CSICLK 0x002C
+#define CMU_DECLK  0x0030
+#define CMU_SICLK  0x0034
+#define CMU_BUSCLK10x0038
+#define CMU_HDECLK 0x003C
+#define CMU_VDECLK 0x0040
+#define CMU_VCECLK 0x0044
+#define CMU_NANDCCLK   0x004C
+#define CMU_SD0CLK 0x0050
+#define CMU_SD1CLK 0x0054
+#define CMU_S

[PATCH v8 02/12] arm: actions: rename sysmap-s900 to sysmap-owl

2020-03-21 Thread Amit Singh Tomar
Now that memory maps(for both S700 and S900 SoCs) can be managed using
a common file, rename sysmap-s900 to sysmap-owl to reflect the same.

Reviewed-by: Manivannan Sadhasivam 
Signed-off-by: Amit Singh Tomar 
---
Changes since v7:
* No changes.
Changes since v6:
* No changes.
Changes since v5:
* No changes.
Changes since v4:
* No changes.
Changes since v3:
* Added reviewed-by tag.
Changes since v2:
* Fixed the commit message and header.
Changes since v1:
* compile sysmap-owl.c against CONFIG_ARM64 now.
---
 arch/arm/mach-owl/Makefile  |  2 +-
 arch/arm/mach-owl/sysmap-owl.c  | 32 
 arch/arm/mach-owl/sysmap-s900.c | 32 
 3 files changed, 33 insertions(+), 33 deletions(-)
 create mode 100644 arch/arm/mach-owl/sysmap-owl.c
 delete mode 100644 arch/arm/mach-owl/sysmap-s900.c

diff --git a/arch/arm/mach-owl/Makefile b/arch/arm/mach-owl/Makefile
index 0b181c6..f3a69eb 100644
--- a/arch/arm/mach-owl/Makefile
+++ b/arch/arm/mach-owl/Makefile
@@ -1,4 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0+
 
 obj-y += soc.o
-obj-y += sysmap-s900.o
+obj-$(CONFIG_ARM64) += sysmap-owl.o
diff --git a/arch/arm/mach-owl/sysmap-owl.c b/arch/arm/mach-owl/sysmap-owl.c
new file mode 100644
index 000..81f6ca2
--- /dev/null
+++ b/arch/arm/mach-owl/sysmap-owl.c
@@ -0,0 +1,32 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Memory map for Actions Semi Owl series SoCs.
+ *
+ * Copyright (C) 2015 Actions Semi Co., Ltd.
+ * Copyright (C) 2018 Manivannan Sadhasivam 
+ */
+
+#include 
+#include 
+
+static struct mm_region owl_mem_map[] = {
+   {
+   .virt = 0x0UL, /* DDR */
+   .phys = 0x0UL, /* DDR */
+   .size = 0x8000UL,
+   .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
+PTE_BLOCK_INNER_SHARE
+   }, {
+   .virt = 0xE000UL, /* Peripheral block */
+   .phys = 0xE000UL, /* Peripheral block */
+   .size = 0x0800UL,
+   .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
+PTE_BLOCK_NON_SHARE |
+PTE_BLOCK_PXN | PTE_BLOCK_UXN
+   }, {
+   /* List terminator */
+   0,
+   }
+};
+
+struct mm_region *mem_map = owl_mem_map;
diff --git a/arch/arm/mach-owl/sysmap-s900.c b/arch/arm/mach-owl/sysmap-s900.c
deleted file mode 100644
index f78b639..000
--- a/arch/arm/mach-owl/sysmap-s900.c
+++ /dev/null
@@ -1,32 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0+
-/*
- * Actions Semi S900 Memory map
- *
- * Copyright (C) 2015 Actions Semi Co., Ltd.
- * Copyright (C) 2018 Manivannan Sadhasivam 
- */
-
-#include 
-#include 
-
-static struct mm_region s900_mem_map[] = {
-   {
-   .virt = 0x0UL, /* DDR */
-   .phys = 0x0UL, /* DDR */
-   .size = 0x8000UL,
-   .attrs = PTE_BLOCK_MEMTYPE(MT_NORMAL) |
-PTE_BLOCK_INNER_SHARE
-   }, {
-   .virt = 0xE000UL, /* Peripheral block */
-   .phys = 0xE000UL, /* Peripheral block */
-   .size = 0x0800UL,
-   .attrs = PTE_BLOCK_MEMTYPE(MT_DEVICE_NGNRNE) |
-PTE_BLOCK_NON_SHARE |
-PTE_BLOCK_PXN | PTE_BLOCK_UXN
-   }, {
-   /* List terminator */
-   0,
-   }
-};
-
-struct mm_region *mem_map = s900_mem_map;
-- 
2.7.4



[PATCH v8 01/12] arm: actions: Add common framework for Actions Owl Semi SoCs

2020-03-21 Thread Amit Singh Tomar
This commit adds common arch support for Actions Semi Owl
series SoCs and removes the Bubblegum96 board files.

Signed-off-by: Amit Singh Tomar 
---
Changes since v7:
* Removed S900 specific include file.
* Removed the file list entry in MAINTAINERS file.
Changes since v6:
* No change.
Changes since v5:
* No change.
Changes since v4:
* No change.
Changes since v3:
* Corrected the file list entry in MAINTAINERS file.
Changes since v2:
* Moved the file list details to root MAINTAINERS file.
* Updated the commit message as suggested by Mani.
* Used the "Owl" keyword to describe SoC family.
Changes since v1:
* Moved S700 specific changes to patch 4 of 9.
* Moved couple of symbols from defconfig to arch/arm/Kconfig
  and platform owl Kconfig.
---
 MAINTAINERS  |  3 +-
 arch/arm/Kconfig |  3 +-
 arch/arm/mach-owl/Kconfig| 29 ++
 arch/arm/mach-owl/Makefile   |  1 +
 arch/arm/mach-owl/soc.c  | 57 
 board/ucRobotics/bubblegum_96/Kconfig| 15 
 board/ucRobotics/bubblegum_96/MAINTAINERS|  6 ---
 board/ucRobotics/bubblegum_96/Makefile   |  3 --
 board/ucRobotics/bubblegum_96/bubblegum_96.c | 57 
 configs/bubblegum_96_defconfig   |  4 +-
 include/configs/bubblegum_96.h   | 40 ---
 include/configs/owl-common.h | 40 +++
 12 files changed, 114 insertions(+), 144 deletions(-)
 create mode 100644 arch/arm/mach-owl/soc.c
 delete mode 100644 board/ucRobotics/bubblegum_96/Kconfig
 delete mode 100644 board/ucRobotics/bubblegum_96/MAINTAINERS
 delete mode 100644 board/ucRobotics/bubblegum_96/Makefile
 delete mode 100644 board/ucRobotics/bubblegum_96/bubblegum_96.c
 delete mode 100644 include/configs/bubblegum_96.h
 create mode 100644 include/configs/owl-common.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 92dda40..73ee1ac 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -272,9 +272,10 @@ M: Manivannan Sadhasivam 
 S: Maintained
 F: arch/arm/include/asm/arch-owl/
 F: arch/arm/mach-owl/
-F: board/ucRobotics/
 F: drivers/clk/owl/
 F: drivers/serial/serial_owl.c
+F: include/configs/owl-common.h
+F: configs/bubblegum_96_defconfig
 
 ARM RENESAS RMOBILE/R-CAR
 M: Nobuhiro Iwamatsu 
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 5d36788..1cfdcb6 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -873,9 +873,9 @@ config ARCH_MX5
 
 config ARCH_OWL
bool "Actions Semi OWL SoCs"
-   select ARM64
select DM
select DM_SERIAL
+   select OWL_SERIAL
select OF_CONTROL
imply CMD_DM
 
@@ -1865,7 +1865,6 @@ source "board/spear/spear600/Kconfig"
 source "board/spear/x600/Kconfig"
 source "board/st/stv0991/Kconfig"
 source "board/tcl/sl50/Kconfig"
-source "board/ucRobotics/bubblegum_96/Kconfig"
 source "board/birdland/bav335x/Kconfig"
 source "board/toradex/colibri_pxa270/Kconfig"
 source "board/variscite/dart_6ul/Kconfig"
diff --git a/arch/arm/mach-owl/Kconfig b/arch/arm/mach-owl/Kconfig
index 199e772..28984c1 100644
--- a/arch/arm/mach-owl/Kconfig
+++ b/arch/arm/mach-owl/Kconfig
@@ -1,27 +1,22 @@
 if ARCH_OWL
 
-config SYS_SOC
-   default "owl"
-
 choice
-prompt "Actions Semi OWL SoCs board select"
+prompt "Actions Semi Owl SoC Variant"
 optional
 
-config TARGET_BUBBLEGUM_96
-   bool "96Boards Bubblegum-96"
-   help
- Support for 96Boards Bubblegum-96. This board complies with
- 96Board Consumer Edition Specification. Features:
- - Actions Semi S900 SoC (4xCortex A53, Power VR G6230 GPU)
- - 2GiB RAM
- - 8GiB eMMC, uSD slot
- - WiFi, Bluetooth and GPS module
- - 2x Host, 1x Device USB port
- - HDMI
- - 20-pin low speed and 40-pin high speed expanders, 6 LED, 3 buttons
+config MACH_S900
+bool "Actions Semi S900 SoC"
+select ARM64
 
 endchoice
 
-source "board/ucRobotics/bubblegum_96/Kconfig"
+config SYS_TEXT_BASE
+default 0x1100
+
+config SYS_CONFIG_NAME
+default "owl-common"
+
+config SYS_SOC
+default "s900" if MACH_S900
 
 endif
diff --git a/arch/arm/mach-owl/Makefile b/arch/arm/mach-owl/Makefile
index 1b43dc2..0b181c6 100644
--- a/arch/arm/mach-owl/Makefile
+++ b/arch/arm/mach-owl/Makefile
@@ -1,3 +1,4 @@
 # SPDX-License-Identifier: GPL-2.0+
 
+obj-y += soc.o
 obj-y += sysmap-s900.o
diff --git a/arch/arm/mach-owl/soc.c b/arch/arm/mach-owl/soc.c
new file mode 100644
index 000..409cbd3
--- /dev/null
+++ b/arch/arm/mach-owl/soc.c
@@ -0,0 +1,57 @@
+// S

[PATCH v8 03/12] serial: actions: add compatible string

2020-03-21 Thread Amit Singh Tomar
This patch adds "actions,owl-uart" string to the owl uart driver. It
is also defined in Linux kernel.

Reviewed-by: Andre Przywara 
Signed-off-by: Amit Singh Tomar 
---
Changes since v7:
* No changes.
Changes since v6:
* Added Reviewd-by tag.
Changes since v5:
* Moved it to from 06/11 to 03/11.
* Used appropriate commit message.
* Removed the reviwed-by tag.
Changes since v4:
* Moved it to from 09/11 to 06/11.
Changes since v3:
* Used only owl-uart for compatible string.
Changes since v2:
* No changes.
Changes since v1:
* No changes.
---
 drivers/serial/serial_owl.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/serial/serial_owl.c b/drivers/serial/serial_owl.c
index 7ead73e..539acdc 100644
--- a/drivers/serial/serial_owl.c
+++ b/drivers/serial/serial_owl.c
@@ -121,6 +121,7 @@ static const struct dm_serial_ops owl_serial_ops = {
 
 static const struct udevice_id owl_serial_ids[] = {
{ .compatible = "actions,s900-serial" },
+   { .compatible = "actions,owl-uart" },
{ }
 };
 
-- 
2.7.4



  1   2   >