Re: [PATCH v4 06/11] remoteproc: uclass: Add remoteproc resource handling helpers

2022-02-09 Thread Amjad Ouled-Ameur

Hi Simon,

Thank you for your feedback.

Since the patchset has already been applied, I will address your comments

in follow-up patches.


Kindly,

Amjad

On 27/01/2022 16:43, Simon Glass wrote:

Hi Amjad,

On Thu, 27 Jan 2022 at 05:17, Amjad Ouled-Ameur
 wrote:

From: Keerthy 

Add remoteproc resource handling helpers. These functions
are primarily to parse the resource table and to handle
different types of resources. Carveout, devmem, trace &
vring resources are handled.

Signed-off-by: Keerthy 
[Amjad: fix redefinition of "struct resource_table" and compile warnings ]
Signed-off-by: Amjad Ouled-Ameur 

---

(no changes since v2)

Changes in v2:
- Add useful checks and remove redundant code.

  drivers/remoteproc/rproc-uclass.c | 534 ++
  include/remoteproc.h  | 384 -
  2 files changed, 917 insertions(+), 1 deletion(-)

Sorry my comments are a bit late - I sent them on v3.

Regards,
Simon


Re: [PATCH v3 04/11] drivers: misc: Makefile: Enable fs_loader compilation at SPL Level

2022-01-27 Thread Amjad Ouled-Ameur

Hi Tom,

On 26/01/2022 04:37, Tom Rini wrote:

On Tue, Jan 18, 2022 at 11:12:42AM +0100, Amjad Ouled-Ameur wrote:


From: Keerthy 

Enable fs_loader compilation at SPL Level.

Signed-off-by: Keerthy 
[Amjad: fix compilation failures for J721e platform]
Signed-off-by: Amjad Ouled-Ameur 

This causes j7200_evm_r5 and socfpga_arria10 to fail to build now.

Fixed in V4, thank you !




[PATCH v4 11/11] dts: am57xx*: Add ipu early boot DT changes

2022-01-27 Thread Amjad Ouled-Ameur
From: Keerthy 

Add support for ipu early boot.

Signed-off-by: Keerthy 
Signed-off-by: Amjad Ouled-Ameur 

---

(no changes since v1)

 MAINTAINERS  | 1 +
 arch/arm/dts/am57xx-beagle-x15-revb1-u-boot.dtsi | 7 +++
 arch/arm/dts/am57xx-beagle-x15-revc-u-boot.dtsi  | 7 +++
 arch/arm/dts/am57xx-beagle-x15-u-boot.dtsi   | 7 +++
 arch/arm/dts/am57xx-cl-som-am57x-u-boot.dtsi | 7 +++
 arch/arm/dts/am57xx-sbc-am57x-u-boot.dtsi| 7 +++
 6 files changed, 36 insertions(+)
 create mode 100644 arch/arm/dts/am57xx-beagle-x15-revb1-u-boot.dtsi
 create mode 100644 arch/arm/dts/am57xx-beagle-x15-revc-u-boot.dtsi
 create mode 100644 arch/arm/dts/am57xx-beagle-x15-u-boot.dtsi
 create mode 100644 arch/arm/dts/am57xx-cl-som-am57x-u-boot.dtsi
 create mode 100644 arch/arm/dts/am57xx-sbc-am57x-u-boot.dtsi

diff --git a/MAINTAINERS b/MAINTAINERS
index 7adc28dbfd87..c73739a15a4b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -514,6 +514,7 @@ ARM TI
 M: Tom Rini 
 S: Maintained
 T: git https://source.denx.de/u-boot/custodians/u-boot-ti.git
+F: arch/arm/dts/am57xx*
 F: arch/arm/dts/dra7*
 F: arch/arm/mach-davinci/
 F: arch/arm/mach-k3/
diff --git a/arch/arm/dts/am57xx-beagle-x15-revb1-u-boot.dtsi 
b/arch/arm/dts/am57xx-beagle-x15-revb1-u-boot.dtsi
new file mode 100644
index ..49b16215e528
--- /dev/null
+++ b/arch/arm/dts/am57xx-beagle-x15-revb1-u-boot.dtsi
@@ -0,0 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
+ */
+
+#include "omap5-u-boot.dtsi"
+#include "dra7-ipu-common-early-boot.dtsi"
diff --git a/arch/arm/dts/am57xx-beagle-x15-revc-u-boot.dtsi 
b/arch/arm/dts/am57xx-beagle-x15-revc-u-boot.dtsi
new file mode 100644
index ..49b16215e528
--- /dev/null
+++ b/arch/arm/dts/am57xx-beagle-x15-revc-u-boot.dtsi
@@ -0,0 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
+ */
+
+#include "omap5-u-boot.dtsi"
+#include "dra7-ipu-common-early-boot.dtsi"
diff --git a/arch/arm/dts/am57xx-beagle-x15-u-boot.dtsi 
b/arch/arm/dts/am57xx-beagle-x15-u-boot.dtsi
new file mode 100644
index ..49b16215e528
--- /dev/null
+++ b/arch/arm/dts/am57xx-beagle-x15-u-boot.dtsi
@@ -0,0 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
+ */
+
+#include "omap5-u-boot.dtsi"
+#include "dra7-ipu-common-early-boot.dtsi"
diff --git a/arch/arm/dts/am57xx-cl-som-am57x-u-boot.dtsi 
b/arch/arm/dts/am57xx-cl-som-am57x-u-boot.dtsi
new file mode 100644
index ..49b16215e528
--- /dev/null
+++ b/arch/arm/dts/am57xx-cl-som-am57x-u-boot.dtsi
@@ -0,0 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
+ */
+
+#include "omap5-u-boot.dtsi"
+#include "dra7-ipu-common-early-boot.dtsi"
diff --git a/arch/arm/dts/am57xx-sbc-am57x-u-boot.dtsi 
b/arch/arm/dts/am57xx-sbc-am57x-u-boot.dtsi
new file mode 100644
index ..49b16215e528
--- /dev/null
+++ b/arch/arm/dts/am57xx-sbc-am57x-u-boot.dtsi
@@ -0,0 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
+ */
+
+#include "omap5-u-boot.dtsi"
+#include "dra7-ipu-common-early-boot.dtsi"
-- 
2.25.1



[PATCH v4 10/11] arm: dts: dra7*/am57xx-idk-evm-u-boot: Add ipu early boot DT changes

2022-01-27 Thread Amjad Ouled-Ameur
From: Keerthy 

Add support for ipu early boot.

Signed-off-by: Keerthy 
Signed-off-by: Amjad Ouled-Ameur 
---

(no changes since v1)

 arch/arm/dts/am57xx-idk-common-u-boot.dtsi | 1 +
 arch/arm/dts/dra7-evm-u-boot.dtsi  | 1 +
 arch/arm/dts/dra71-evm-u-boot.dtsi | 1 +
 arch/arm/dts/dra72-evm-revc-u-boot.dtsi| 1 +
 arch/arm/dts/dra76-evm-u-boot.dtsi | 1 +
 5 files changed, 5 insertions(+)

diff --git a/arch/arm/dts/am57xx-idk-common-u-boot.dtsi 
b/arch/arm/dts/am57xx-idk-common-u-boot.dtsi
index b07aea0048d5..d0ce469f9189 100644
--- a/arch/arm/dts/am57xx-idk-common-u-boot.dtsi
+++ b/arch/arm/dts/am57xx-idk-common-u-boot.dtsi
@@ -3,6 +3,7 @@
  * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
  */
 #include "omap5-u-boot.dtsi"
+#include "dra7-ipu-common-early-boot.dtsi"
 
 / {
xtal25mhz: xtal25mhz {
diff --git a/arch/arm/dts/dra7-evm-u-boot.dtsi 
b/arch/arm/dts/dra7-evm-u-boot.dtsi
index f06c701dbd1f..5622512b2401 100644
--- a/arch/arm/dts/dra7-evm-u-boot.dtsi
+++ b/arch/arm/dts/dra7-evm-u-boot.dtsi
@@ -4,6 +4,7 @@
  */
 
 #include "omap5-u-boot.dtsi"
+#include "dra7-ipu-common-early-boot.dtsi"
 
 _gpio_21{
u-boot,i2c-offset-len = <0>;
diff --git a/arch/arm/dts/dra71-evm-u-boot.dtsi 
b/arch/arm/dts/dra71-evm-u-boot.dtsi
index b56d4fc9d896..40443da5c855 100644
--- a/arch/arm/dts/dra71-evm-u-boot.dtsi
+++ b/arch/arm/dts/dra71-evm-u-boot.dtsi
@@ -4,6 +4,7 @@
  */
 
 #include "omap5-u-boot.dtsi"
+#include "dra7-ipu-common-early-boot.dtsi"
 
 _gpio_21{
u-boot,i2c-offset-len = <0>;
diff --git a/arch/arm/dts/dra72-evm-revc-u-boot.dtsi 
b/arch/arm/dts/dra72-evm-revc-u-boot.dtsi
index b56d4fc9d896..40443da5c855 100644
--- a/arch/arm/dts/dra72-evm-revc-u-boot.dtsi
+++ b/arch/arm/dts/dra72-evm-revc-u-boot.dtsi
@@ -4,6 +4,7 @@
  */
 
 #include "omap5-u-boot.dtsi"
+#include "dra7-ipu-common-early-boot.dtsi"
 
 _gpio_21{
u-boot,i2c-offset-len = <0>;
diff --git a/arch/arm/dts/dra76-evm-u-boot.dtsi 
b/arch/arm/dts/dra76-evm-u-boot.dtsi
index a4dfbe7e601a..5fae6ba91936 100644
--- a/arch/arm/dts/dra76-evm-u-boot.dtsi
+++ b/arch/arm/dts/dra76-evm-u-boot.dtsi
@@ -4,6 +4,7 @@
  */
 
 #include "omap5-u-boot.dtsi"
+#include "dra7-ipu-common-early-boot.dtsi"
 
 _emac0 {
phy-handle = <_0>;
-- 
2.25.1



[PATCH v4 09/11] arm: dts: dra7: Add ipu and related nodes

2022-01-27 Thread Amjad Ouled-Ameur
From: Keerthy 

Add ipu and the associated nodes.

Signed-off-by: Keerthy 
Signed-off-by: Amjad Ouled-Ameur 
---

(no changes since v1)

 arch/arm/dts/dra7.dtsi | 45 +-
 1 file changed, 44 insertions(+), 1 deletion(-)

diff --git a/arch/arm/dts/dra7.dtsi b/arch/arm/dts/dra7.dtsi
index fd1aea0b1b16..e2e958b36626 100644
--- a/arch/arm/dts/dra7.dtsi
+++ b/arch/arm/dts/dra7.dtsi
@@ -41,6 +41,8 @@
d_can0 = 
d_can1 = 
spi0 = 
+   remoteproc0 = 
+   remoteproc1 = 
};
 
timer {
@@ -263,9 +265,12 @@
};
 
prm: prm@6000 {
-   compatible = "ti,dra7-prm";
+   compatible = "ti,dra7-prm", "simple-bus";
reg = <0x6000 0x3000>;
interrupts = ;
+   #address-cells = <1>;
+   #size-cells = <1>;
+   ranges = <0 0x6000 0x3000>;
 
prm_clocks: clocks {
#address-cells = <1>;
@@ -274,6 +279,20 @@
 
prm_clockdomains: clockdomains {
};
+
+   ipu1_rst: ipu1_rst@510 {
+   compatible = "ti,dra7-reset";
+   reg = <0x510 0x8>;
+   ti,nresets = <3>;
+   #reset-cells = <1>;
+   };
+
+   ipu2_rst: ipu2_rst@910 {
+   compatible = "ti,dra7-reset";
+   reg = <0x910 0x8>;
+   ti,nresets = <3>;
+   #reset-cells = <1>;
+   };
};
 
scm_wkup: scm_conf@c000 {
@@ -2032,6 +2051,30 @@
clocks = <_iclk_div>;
clock-names = "fck";
};
+
+   ipu1: ipu@5882 {
+   compatible = "ti,dra7-ipu";
+   reg = <0x5882 0x1>;
+   reg-names = "l2ram";
+   ti,hwmods = "ipu1";
+   resets = <_rst 0>, <_rst 1>, <_rst 2>;
+   iommus = <_ipu1>;
+   ti,rproc-standby-info = <0x4a005520>;
+   timers = <>;
+   watchdog-timers = <>, <>;
+   };
+
+   ipu2: ipu@5502 {
+   compatible = "ti,dra7-ipu";
+   reg = <0x5502 0x1>;
+   reg-names = "l2ram";
+   ti,hwmods = "ipu2";
+   resets = <_rst 0>, <_rst 1>, <_rst 2>;
+   iommus = <_ipu2>;
+   ti,rproc-standby-info = <0x4a008920>;
+   timers = <>;
+   watchdog-timers = <>, <>;
+   };
};
 
thermal_zones: thermal-zones {
-- 
2.25.1



[PATCH v4 08/11] dts: dra7-ipu-common-early-boot.dtsi: Add all the ipu early boot related nodes

2022-01-27 Thread Amjad Ouled-Ameur
From: Keerthy 

Add all the ipu early boot related nodes

Signed-off-by: Keerthy 
Signed-off-by: Amjad Ouled-Ameur 
---

(no changes since v1)

 MAINTAINERS  |   1 +
 arch/arm/dts/dra7-ipu-common-early-boot.dtsi | 113 +++
 2 files changed, 114 insertions(+)
 create mode 100644 arch/arm/dts/dra7-ipu-common-early-boot.dtsi

diff --git a/MAINTAINERS b/MAINTAINERS
index 311397137b27..7adc28dbfd87 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -514,6 +514,7 @@ ARM TI
 M: Tom Rini 
 S: Maintained
 T: git https://source.denx.de/u-boot/custodians/u-boot-ti.git
+F: arch/arm/dts/dra7*
 F: arch/arm/mach-davinci/
 F: arch/arm/mach-k3/
 F: arch/arm/mach-keystone/
diff --git a/arch/arm/dts/dra7-ipu-common-early-boot.dtsi 
b/arch/arm/dts/dra7-ipu-common-early-boot.dtsi
new file mode 100644
index ..ec6040ff93eb
--- /dev/null
+++ b/arch/arm/dts/dra7-ipu-common-early-boot.dtsi
@@ -0,0 +1,113 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
+ */
+
+/ {
+   chosen {
+   firmware-loader = _loader0;
+   };
+
+   fs_loader0: fs_loader@0 {
+   u-boot,dm-pre-reloc;
+   compatible = "u-boot,fs-loader";
+   phandlepart = < 1>;
+   };
+
+   reserved-memory {
+   #address-cells = <2>;
+   #size-cells = <2>;
+   ranges;
+   u-boot,dm-spl;
+
+   ipu2_memory_region: ipu2-memory@9580 {
+   compatible = "shared-dma-pool";
+   reg = <0x0 0x9580 0x0 0x380>;
+   reusable;
+   status = "okay";
+   u-boot,dm-spl;
+   };
+
+   ipu1_memory_region: ipu1-memory@9d00 {
+   compatible = "shared-dma-pool";
+   reg = <0x0 0x9d00 0x0 0x200>;
+   reusable;
+   status = "okay";
+   u-boot,dm-spl;
+   };
+
+   ipu1_pgtbl: ipu1-pgtbl@9570 {
+   reg = <0x0 0x9570 0x0 0x4>;
+   no-map;
+   u-boot,dm-spl;
+   };
+
+   ipu2_pgtbl: ipu2-pgtbl@9574 {
+   reg = <0x0 0x9574 0x0 0x4>;
+   no-map;
+   u-boot,dm-spl;
+   };
+   };
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+_ipu1 {
+   u-boot,dm-spl;
+};
+
+_ipu2 {
+   u-boot,dm-spl;
+};
+
+ {
+   status = "okay";
+   memory-region = <_memory_region>;
+   pg-tbl = <_pgtbl>;
+   u-boot,dm-spl;
+};
+
+ {
+   status = "okay";
+   memory-region = <_memory_region>;
+   pg-tbl = <_pgtbl>;
+   u-boot,dm-spl;
+};
+
+_wkup {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+_rst {
+   u-boot,dm-spl;
+};
+
+_rst {
+   u-boot,dm-spl;
+};
-- 
2.25.1



[PATCH v4 06/11] remoteproc: uclass: Add remoteproc resource handling helpers

2022-01-27 Thread Amjad Ouled-Ameur
From: Keerthy 

Add remoteproc resource handling helpers. These functions
are primarily to parse the resource table and to handle
different types of resources. Carveout, devmem, trace &
vring resources are handled.

Signed-off-by: Keerthy 
[Amjad: fix redefinition of "struct resource_table" and compile warnings ]
Signed-off-by: Amjad Ouled-Ameur 

---

(no changes since v2)

Changes in v2:
- Add useful checks and remove redundant code.

 drivers/remoteproc/rproc-uclass.c | 534 ++
 include/remoteproc.h  | 384 -
 2 files changed, 917 insertions(+), 1 deletion(-)

diff --git a/drivers/remoteproc/rproc-uclass.c 
b/drivers/remoteproc/rproc-uclass.c
index 87e1ec7ad7f0..50bcc9030e98 100644
--- a/drivers/remoteproc/rproc-uclass.c
+++ b/drivers/remoteproc/rproc-uclass.c
@@ -8,15 +8,31 @@
 
 #define pr_fmt(fmt) "%s: " fmt, __func__
 #include 
+#include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+struct resource_table {
+   u32 ver;
+   u32 num;
+   u32 reserved[2];
+   u32 offset[0];
+} __packed;
+
+typedef int (*handle_resource_t) (struct udevice *, void *, int offset, int 
avail);
+
+static struct resource_table *rsc_table;
 
 /**
  * for_each_remoteproc_device() - iterate through the list of rproc devices
@@ -196,6 +212,80 @@ static int rproc_post_probe(struct udevice *dev)
return 0;
 }
 
+/**
+ * rproc_add_res() - After parsing the resource table add the mappings
+ * @dev:   device we finished probing
+ * @mapping: rproc_mem_entry for the resource
+ *
+ * Return: if the remote proc driver has a add_res routine, invokes it and
+ * hands over the return value. overall, 0 if all went well, else appropriate
+ * error value.
+ */
+static int rproc_add_res(struct udevice *dev, struct rproc_mem_entry *mapping)
+{
+   const struct dm_rproc_ops *ops = rproc_get_ops(dev);
+
+   if (!ops->add_res)
+   return -ENOSYS;
+
+   return ops->add_res(dev, mapping);
+}
+
+/**
+ * rproc_alloc_mem() - After parsing the resource table allocat mem
+ * @dev:   device we finished probing
+ * @len: rproc_mem_entry for the resource
+ * @align: alignment for the resource
+ *
+ * Return: if the remote proc driver has a add_res routine, invokes it and
+ * hands over the return value. overall, 0 if all went well, else appropriate
+ * error value.
+ */
+static void *rproc_alloc_mem(struct udevice *dev, unsigned long len,
+unsigned long align)
+{
+   const struct dm_rproc_ops *ops;
+
+   ops = rproc_get_ops(dev);
+   if (!ops) {
+   debug("%s driver has no ops?\n", dev->name);
+   return NULL;
+   }
+
+   if (ops->alloc_mem)
+   return ops->alloc_mem(dev, len, align);
+
+   return NULL;
+}
+
+/**
+ * rproc_config_pagetable() - Configure page table for remote processor
+ * @dev:   device we finished probing
+ * @virt: Virtual address of the resource
+ * @phys: Physical address the resource
+ * @len: length the resource
+ *
+ * Return: if the remote proc driver has a add_res routine, invokes it and
+ * hands over the return value. overall, 0 if all went well, else appropriate
+ * error value.
+ */
+static int rproc_config_pagetable(struct udevice *dev, unsigned int virt,
+ unsigned int phys, unsigned int len)
+{
+   const struct dm_rproc_ops *ops;
+
+   ops = rproc_get_ops(dev);
+   if (!ops) {
+   debug("%s driver has no ops?\n", dev->name);
+   return -EINVAL;
+   }
+
+   if (ops->config_pagetable)
+   return ops->config_pagetable(dev, virt, phys, len);
+
+   return 0;
+}
+
 UCLASS_DRIVER(rproc) = {
.id = UCLASS_REMOTEPROC,
.name = "remoteproc",
@@ -426,3 +516,447 @@ int rproc_is_running(int id)
 {
return _rproc_ops_wrapper(id, RPROC_RUNNING);
 };
+
+
+static int handle_trace(struct udevice *dev, struct fw_rsc_trace *rsc,
+   int offset, int avail)
+{
+   if (sizeof(*rsc) > avail) {
+   debug("trace rsc is truncated\n");
+   return -EINVAL;
+   }
+
+   /*
+* make sure reserved bytes are zeroes
+*/
+   if (rsc->reserved) {
+   debug("trace rsc has non zero reserved bytes\n");
+   return -EINVAL;
+   }
+
+   debug("trace rsc: da 0x%x, len 0x%x\n", rsc->da, rsc->len);
+
+   return 0;
+}
+
+static int handle_devmem(struct udevice *dev, struct fw_rsc_devmem *rsc,
+int offset, int avail)
+{
+   struct rproc_mem_entry *mapping;
+
+   if (sizeof(*rsc) > avail) {
+   debug("devmem rsc is truncated\n");
+   return -EINVAL;
+   }
+

[PATCH v4 07/11] remoteproc: ipu: Add driver to bring up ipu

2022-01-27 Thread Amjad Ouled-Ameur
From: Keerthy 

The driver enables IPU support. Basically enables the clocks,
timers, watchdog timers and bare minimal MMU and supports
loading the firmware from mmc.

Signed-off-by: Keerthy 
[Amjad: fix compile warnings]
Signed-off-by: Amjad Ouled-Ameur 
---

(no changes since v1)

 MAINTAINERS|   1 +
 drivers/remoteproc/Kconfig |  10 +
 drivers/remoteproc/Makefile|   1 +
 drivers/remoteproc/ipu_rproc.c | 759 +
 4 files changed, 771 insertions(+)
 create mode 100644 drivers/remoteproc/ipu_rproc.c

diff --git a/MAINTAINERS b/MAINTAINERS
index bd9cc4107cbe..311397137b27 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -533,6 +533,7 @@ F:  drivers/phy/omap-usb2-phy.c
 F: drivers/phy/phy-ti-am654.c
 F: drivers/phy/ti-pipe3-phy.c
 F: drivers/ram/k3*
+F: drivers/remoteproc/ipu_rproc.c
 F: drivers/remoteproc/k3_system_controller.c
 F: drivers/remoteproc/pruc_rpoc.c
 F: drivers/remoteproc/ti*
diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
index 24e536463bbd..27e4a60ff5b1 100644
--- a/drivers/remoteproc/Kconfig
+++ b/drivers/remoteproc/Kconfig
@@ -92,4 +92,14 @@ config REMOTEPROC_TI_PRU
help
  Say 'y' here to add support for TI' K3 remoteproc driver.
 
+config REMOTEPROC_TI_IPU
+   bool "Support for TI's K3 based IPU remoteproc driver"
+   select REMOTEPROC
+   depends on DM
+   depends on SPL_DRIVERS_MISC
+   depends on SPL_FS_LOADER
+   depends on OF_CONTROL
+   help
+ Say 'y' here to add support for TI' K3 remoteproc driver.
+
 endmenu
diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile
index f0e83451d66f..fbe9c172bc04 100644
--- a/drivers/remoteproc/Makefile
+++ b/drivers/remoteproc/Makefile
@@ -15,3 +15,4 @@ obj-$(CONFIG_REMOTEPROC_TI_K3_DSP) += ti_k3_dsp_rproc.o
 obj-$(CONFIG_REMOTEPROC_TI_K3_R5F) += ti_k3_r5f_rproc.o
 obj-$(CONFIG_REMOTEPROC_TI_POWER) += ti_power_proc.o
 obj-$(CONFIG_REMOTEPROC_TI_PRU) += pru_rproc.o
+obj-$(CONFIG_REMOTEPROC_TI_IPU) += ipu_rproc.o
diff --git a/drivers/remoteproc/ipu_rproc.c b/drivers/remoteproc/ipu_rproc.c
new file mode 100644
index ..b4a06bc955a9
--- /dev/null
+++ b/drivers/remoteproc/ipu_rproc.c
@@ -0,0 +1,759 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * IPU remoteproc driver for various SoCs
+ *
+ * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
+ * Angela Stegmaier  
+ * Venkateswara Rao Mandela 
+ *  Keerthy 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define IPU1_LOAD_ADDR (0xa17ff000)
+#define MAX_REMOTECORE_BIN_SIZE (8 * 0x10)
+
+enum ipu_num {
+   IPU1 = 0,
+   IPU2,
+   RPROC_END_ENUMS,
+};
+
+#define IPU2_LOAD_ADDR (IPU1_LOAD_ADDR + MAX_REMOTECORE_BIN_SIZE)
+
+#define PAGE_SHIFT 12
+#define PAGESIZE_1M  0x0
+#define PAGESIZE_64K 0x1
+#define PAGESIZE_4K  0x2
+#define PAGESIZE_16M 0x3
+#define LE   0
+#define BE   1
+#define ELEMSIZE_8   0x0
+#define ELEMSIZE_16  0x1
+#define ELEMSIZE_32  0x2
+#define MIXED_TLB0x0
+#define MIXED_CPU0x1
+
+#define PGT_SMALLPAGE_SIZE   0x1000
+#define PGT_LARGEPAGE_SIZE   0x0001
+#define PGT_SECTION_SIZE 0x0010
+#define PGT_SUPERSECTION_SIZE0x0100
+
+#define PGT_L1_DESC_PAGE 0x1
+#define PGT_L1_DESC_SECTION  0x2
+#define PGT_L1_DESC_SUPERSECTION 0x40002
+
+#define PGT_L1_DESC_PAGE_MASK0xfC00
+#define PGT_L1_DESC_SECTION_MASK 0xfff0
+#define PGT_L1_DESC_SUPERSECTION_MASK0xff00
+
+#define PGT_L1_DESC_SMALLPAGE_INDEX_SHIFT12
+#define PGT_L1_DESC_LARGEPAGE_INDEX_SHIFT16
+#define PGT_L1_DESC_SECTION_INDEX_SHIFT  20
+#define PGT_L1_DESC_SUPERSECTION_INDEX_SHIFT 24
+
+#define PGT_L2_DESC_SMALLPAGE   0x02
+#define PGT_L2_DESC_LARGEPAGE   0x01
+
+#define PGT_L2_DESC_SMALLPAGE_MASK  0xf000
+#define PGT_L2_DESC_LARGEPAGE_MASK  0x
+
+/*
+ * The memory for the page tables (256 KB per IPU) is placed just before
+ * the carveout memories for the remote processors. 16 KB of memory is
+ * needed for the L1 page table (4096 entries * 4 bytes per 1 MB section).
+ * Any smaller page (64 KB or 4 KB) entries are supported through L2 page
+ * tables (1 KB per table). The remaining 240 KB can provide support for

[PATCH v4 05/11] linux: bitmap.h: Add find_next_zero_area function

2022-01-27 Thread Amjad Ouled-Ameur
From: Keerthy 

Add find_next_zero_area to fetch the next zero area in the map.

Signed-off-by: Keerthy 
Signed-off-by: Amjad Ouled-Ameur 
---

(no changes since v1)

 include/linux/bitmap.h | 26 ++
 1 file changed, 26 insertions(+)

diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
index dae4225be549..0a8503af9f14 100644
--- a/include/linux/bitmap.h
+++ b/include/linux/bitmap.h
@@ -159,6 +159,32 @@ static inline unsigned long find_first_bit(const unsigned 
long *addr, unsigned l
 (bit) < (size);\
 (bit) = find_next_bit((addr), (size), (bit) + 1))
 
+static inline unsigned long
+bitmap_find_next_zero_area(unsigned long *map,
+  unsigned long size,
+  unsigned long start,
+  unsigned int nr, unsigned long align_mask)
+{
+   unsigned long index, end, i;
+again:
+   index = find_next_zero_bit(map, size, start);
+
+   /*
+* Align allocation
+*/
+   index = (index + align_mask) & ~align_mask;
+
+   end = index + nr;
+   if (end > size)
+   return end;
+   i = find_next_bit(map, end, index);
+   if (i < end) {
+   start = i + 1;
+   goto again;
+   }
+   return index;
+}
+
 static inline void bitmap_fill(unsigned long *dst, unsigned int nbits)
 {
if (small_const_nbits(nbits)) {
-- 
2.25.1



[PATCH v4 04/11] drivers: misc: Makefile: Enable fs_loader compilation at SPL Level

2022-01-27 Thread Amjad Ouled-Ameur
From: Keerthy 

Enable fs_loader compilation at SPL Level.

Signed-off-by: Keerthy 
[Amjad: fix compilation failures for J721e platform]
Signed-off-by: Amjad Ouled-Ameur 

---

Changes in v4:
- Enable SPL fs_loader for j7200_evm_r5 and socfpga_arria10.

 arch/arm/mach-k3/common.c | 10 +++---
 configs/j7200_evm_r5_defconfig|  1 +
 configs/j721e_evm_r5_defconfig|  1 +
 configs/j721e_hs_evm_r5_defconfig |  1 +
 configs/socfpga_arria10_defconfig |  1 +
 drivers/misc/Kconfig  |  9 +
 drivers/misc/Makefile |  2 +-
 7 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c
index 39d00270b7fa..b4b75f4e6c86 100644
--- a/arch/arm/mach-k3/common.c
+++ b/arch/arm/mach-k3/common.c
@@ -156,13 +156,15 @@ void init_env(void)
 #endif
 }
 
-#ifdef CONFIG_FS_LOADER
 int load_firmware(char *name_fw, char *name_loadaddr, u32 *loadaddr)
 {
struct udevice *fsdev;
char *name = NULL;
int size = 0;
 
+   if (!IS_ENABLED(CONFIG_FS_LOADER))
+   return 0;
+
*loadaddr = 0;
 #ifdef CONFIG_SPL_ENV_SUPPORT
switch (spl_boot_device()) {
@@ -186,12 +188,6 @@ int load_firmware(char *name_fw, char *name_loadaddr, u32 
*loadaddr)
 
return size;
 }
-#else
-int load_firmware(char *name_fw, char *name_loadaddr, u32 *loadaddr)
-{
-   return 0;
-}
-#endif
 
 __weak void release_resources_for_core_shutdown(void)
 {
diff --git a/configs/j7200_evm_r5_defconfig b/configs/j7200_evm_r5_defconfig
index aeb76e8023f1..f5a8f325c0f1 100644
--- a/configs/j7200_evm_r5_defconfig
+++ b/configs/j7200_evm_r5_defconfig
@@ -91,6 +91,7 @@ CONFIG_SYS_I2C_OMAP24XX=y
 CONFIG_DM_MAILBOX=y
 CONFIG_K3_SEC_PROXY=y
 CONFIG_FS_LOADER=y
+CONFIG_SPL_FS_LOADER=y
 CONFIG_K3_AVS0=y
 CONFIG_SUPPORT_EMMC_BOOT=y
 CONFIG_SPL_MMC_HS400_SUPPORT=y
diff --git a/configs/j721e_evm_r5_defconfig b/configs/j721e_evm_r5_defconfig
index b0759d1f305d..1fb13a8a707d 100644
--- a/configs/j721e_evm_r5_defconfig
+++ b/configs/j721e_evm_r5_defconfig
@@ -88,6 +88,7 @@ CONFIG_SYS_I2C_OMAP24XX=y
 CONFIG_DM_MAILBOX=y
 CONFIG_K3_SEC_PROXY=y
 CONFIG_FS_LOADER=y
+CONFIG_SPL_FS_LOADER=y
 CONFIG_ESM_K3=y
 CONFIG_K3_AVS0=y
 CONFIG_ESM_PMIC=y
diff --git a/configs/j721e_hs_evm_r5_defconfig 
b/configs/j721e_hs_evm_r5_defconfig
index 3d2bbb4844e8..1e4a93ff53fe 100644
--- a/configs/j721e_hs_evm_r5_defconfig
+++ b/configs/j721e_hs_evm_r5_defconfig
@@ -82,6 +82,7 @@ CONFIG_SYS_I2C_OMAP24XX=y
 CONFIG_DM_MAILBOX=y
 CONFIG_K3_SEC_PROXY=y
 CONFIG_FS_LOADER=y
+CONFIG_SPL_FS_LOADER=y
 CONFIG_K3_AVS0=y
 CONFIG_MMC_SDHCI=y
 CONFIG_SPL_MMC_SDHCI_ADMA=y
diff --git a/configs/socfpga_arria10_defconfig 
b/configs/socfpga_arria10_defconfig
index d6b744475039..63284cb0eb54 100644
--- a/configs/socfpga_arria10_defconfig
+++ b/configs/socfpga_arria10_defconfig
@@ -40,6 +40,7 @@ CONFIG_VERSION_VARIABLE=y
 CONFIG_SPL_DM_SEQ_ALIAS=y
 CONFIG_DWAPB_GPIO=y
 CONFIG_FS_LOADER=y
+CONFIG_SPL_FS_LOADER=y
 CONFIG_MMC_DW=y
 CONFIG_MTD=y
 CONFIG_PHY_MICREL=y
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index a8baaeaf5cfe..0ade3e32b0ef 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -453,6 +453,15 @@ config FS_LOADER
  The consumer driver would then use this loader to program whatever,
  ie. the FPGA device.
 
+config SPL_FS_LOADER
+   bool "Enable loader driver for file system"
+   help
+ This is file system generic loader which can be used to load
+ the file image from the storage into target such as memory.
+
+ The consumer driver would then use this loader to program whatever,
+ ie. the FPGA device.
+
 config GDSYS_SOC
bool "Enable gdsys SOC driver"
depends on MISC
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index f9826d2462d1..bca7b24e99ad 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -37,7 +37,7 @@ obj-$(CONFIG_FSL_IFC) += fsl_ifc.o
 obj-$(CONFIG_FSL_IIM) += fsl_iim.o
 obj-$(CONFIG_FSL_MC9SDZ60) += mc9sdz60.o
 obj-$(CONFIG_FSL_SEC_MON) += fsl_sec_mon.o
-obj-$(CONFIG_FS_LOADER) += fs_loader.o
+obj-$(CONFIG_$(SPL_)FS_LOADER) += fs_loader.o
 obj-$(CONFIG_GDSYS_IOEP) += gdsys_ioep.o
 obj-$(CONFIG_GDSYS_RXAUI_CTRL) += gdsys_rxaui_ctrl.o
 obj-$(CONFIG_GDSYS_SOC) += gdsys_soc.o
-- 
2.25.1



[PATCH v4 02/11] reset: dra7: Add a reset driver

2022-01-27 Thread Amjad Ouled-Ameur
From: Keerthy 

Add a reset driver to bring IPs out of reset.

Signed-off-by: Keerthy 
[Amjad: reset_ops structure member "free" has been renamed to "rfree",
use the latter instead]
Signed-off-by: Amjad Ouled-Ameur 
---

(no changes since v1)

 MAINTAINERS|  1 +
 drivers/reset/Kconfig  |  6 +++
 drivers/reset/Makefile |  1 +
 drivers/reset/reset-dra7.c | 97 ++
 4 files changed, 105 insertions(+)
 create mode 100644 drivers/reset/reset-dra7.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 38c68ee87d41..bd9cc4107cbe 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -536,6 +536,7 @@ F:  drivers/ram/k3*
 F: drivers/remoteproc/k3_system_controller.c
 F: drivers/remoteproc/pruc_rpoc.c
 F: drivers/remoteproc/ti*
+F: drivers/reset/reset-dra7.c
 F: drivers/reset/reset-ti-sci.c
 F: drivers/rtc/davinci.c
 F: drivers/serial/serial_omap.c
diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig
index d73daf5e3189..b57714111b5a 100644
--- a/drivers/reset/Kconfig
+++ b/drivers/reset/Kconfig
@@ -206,4 +206,10 @@ config RESET_ZYNQMP
  passing request via Xilinx firmware interface to TF-A and PMU
  firmware.
 
+config RESET_DRA7
+   bool "Support for TI's DRA7 Reset driver"
+   depends on DM_RESET
+   help
+ Support for TI DRA7-RESET subsystem. Basic Assert/Deassert
+ is supported.
 endmenu
diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile
index d69486bdeb9e..97e3a782c0d8 100644
--- a/drivers/reset/Makefile
+++ b/drivers/reset/Makefile
@@ -30,3 +30,4 @@ obj-$(CONFIG_RESET_SYSCON) += reset-syscon.o
 obj-$(CONFIG_RESET_RASPBERRYPI) += reset-raspberrypi.o
 obj-$(CONFIG_RESET_SCMI) += reset-scmi.o
 obj-$(CONFIG_RESET_ZYNQMP) += reset-zynqmp.o
+obj-$(CONFIG_RESET_DRA7) += reset-dra7.o
diff --git a/drivers/reset/reset-dra7.c b/drivers/reset/reset-dra7.c
new file mode 100644
index ..585f8323c52e
--- /dev/null
+++ b/drivers/reset/reset-dra7.c
@@ -0,0 +1,97 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Texas Instruments DRA7 reset driver
+ *
+ * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
+ * Author: Keerthy 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct dra7_reset_priv {
+   u32 rstctrl;
+   u32 rstst;
+   u8 nreset;
+};
+
+static int dra7_reset_request(struct reset_ctl *reset_ctl)
+{
+   return 0;
+}
+
+static int dra7_reset_free(struct reset_ctl *reset_ctl)
+{
+   return 0;
+}
+
+static inline void dra7_reset_rmw(u32 addr, u32 value, u32 mask)
+{
+   writel(((readl(addr) & (~mask)) | (value & mask)), addr);
+}
+
+static int dra7_reset_deassert(struct reset_ctl *reset_ctl)
+{
+   struct dra7_reset_priv *priv = dev_get_priv(reset_ctl->dev);
+   int mask = 1 << reset_ctl->id;
+
+   if (reset_ctl->id < 0 || reset_ctl->id >= priv->nreset)
+   return -EINVAL;
+
+   dra7_reset_rmw(priv->rstctrl, 0x0, mask);
+
+   while ((readl(priv->rstst) & mask) != mask)
+   ;
+
+   return 0;
+}
+
+static int dra7_reset_assert(struct reset_ctl *reset_ctl)
+{
+   struct dra7_reset_priv *priv = dev_get_priv(reset_ctl->dev);
+   int mask = 1 << reset_ctl->id;
+
+   if (reset_ctl->id < 0 || reset_ctl->id >= priv->nreset)
+   return -EINVAL;
+
+   dra7_reset_rmw(priv->rstctrl, mask, 0x0);
+
+   return 0;
+}
+
+struct reset_ops dra7_reset_ops = {
+   .request = dra7_reset_request,
+   .rfree = dra7_reset_free,
+   .rst_assert = dra7_reset_assert,
+   .rst_deassert = dra7_reset_deassert,
+};
+
+static const struct udevice_id dra7_reset_ids[] = {
+   { .compatible = "ti,dra7-reset" },
+   { }
+};
+
+static int dra7_reset_probe(struct udevice *dev)
+{
+   struct dra7_reset_priv *priv = dev_get_priv(dev);
+
+   priv->rstctrl = dev_read_addr(dev);
+   priv->rstst = priv->rstctrl + 0x4;
+   priv->nreset = dev_read_u32_default(dev, "ti,nresets", 1);
+
+   dev_info(dev, "dra7-reset successfully probed %s\n", dev->name);
+
+   return 0;
+}
+
+U_BOOT_DRIVER(dra7_reset) = {
+   .name = "dra7_reset",
+   .id = UCLASS_RESET,
+   .of_match = dra7_reset_ids,
+   .probe = dra7_reset_probe,
+   .ops = _reset_ops,
+   .priv_auto = sizeof(struct dra7_reset_priv),
+};
-- 
2.25.1



[PATCH v4 03/11] arm: mach-omap2: load/start remoteproc IPU1/IPU2

2022-01-27 Thread Amjad Ouled-Ameur
From: Keerthy 

First check the presence of the ipu firmware in the boot partition.
If present enable the ipu and the related clocks & then move
on to load the firmware and eventually start remoteproc IPU1/IPU2.

do_enable_clocks by default puts the clock domains into auto
which does not work well with reset. Hence adding do_enable_ipu_clocks
function.

Signed-off-by: Keerthy 
[Amjad: fix IPU1_LOAD_ADDR and compile warnings]
Signed-off-by: Amjad Ouled-Ameur 
---

(no changes since v1)

 arch/arm/include/asm/arch-omap5/clock.h |  3 +
 arch/arm/include/asm/omap_common.h  | 10 +++
 arch/arm/mach-omap2/boot-common.c   | 95 +
 arch/arm/mach-omap2/clocks-common.c | 33 +
 arch/arm/mach-omap2/omap5/hw_data.c | 92 ++--
 arch/arm/mach-omap2/omap5/prcm-regs.c   |  9 ++-
 6 files changed, 235 insertions(+), 7 deletions(-)

diff --git a/arch/arm/include/asm/arch-omap5/clock.h 
b/arch/arm/include/asm/arch-omap5/clock.h
index 87eb3f335ab0..a00626e357c9 100644
--- a/arch/arm/include/asm/arch-omap5/clock.h
+++ b/arch/arm/include/asm/arch-omap5/clock.h
@@ -135,6 +135,9 @@
 #define HSMMC_CLKCTRL_CLKSEL_MASK  (1 << 24)
 #define HSMMC_CLKCTRL_CLKSEL_DIV_MASK  (3 << 25)
 
+/* CM_IPU1_IPU1_CLKCTRL CLKSEL MASK */
+#define IPU1_CLKCTRL_CLKSEL_MASK   BIT(24)
+
 /* CM_L3INIT_SATA_CLKCTRL */
 #define SATA_CLKCTRL_OPTFCLKEN_MASK(1 << 8)
 
diff --git a/arch/arm/include/asm/omap_common.h 
b/arch/arm/include/asm/omap_common.h
index de8fc99d0478..264a2e717a70 100644
--- a/arch/arm/include/asm/omap_common.h
+++ b/arch/arm/include/asm/omap_common.h
@@ -362,6 +362,10 @@ struct prcm_regs {
/* IPU */
u32 cm_ipu_clkstctrl;
u32 cm_ipu_i2c5_clkctrl;
+   u32 cm_ipu1_clkstctrl;
+   u32 cm_ipu1_ipu1_clkctrl;
+   u32 cm_ipu2_clkstctrl;
+   u32 cm_ipu2_ipu2_clkctrl;
 
/*l3main1 edma*/
u32 cm_l3main1_tptc1_clkctrl;
@@ -632,6 +636,12 @@ void do_disable_clocks(u32 const *clk_domains,
   u8 wait_for_disable);
 #endif /* CONFIG_OMAP44XX || CONFIG_OMAP54XX */
 
+void do_enable_ipu_clocks(u32 const *clk_domains,
+ u32 const *clk_modules_hw_auto,
+ u32 const *clk_modules_explicit_en,
+ u8 wait_for_enable);
+void enable_ipu1_clocks(void);
+void enable_ipu2_clocks(void);
 void setup_post_dividers(u32 const base,
const struct dpll_params *params);
 u32 omap_ddr_clk(void);
diff --git a/arch/arm/mach-omap2/boot-common.c 
b/arch/arm/mach-omap2/boot-common.c
index fdb8b479ea01..afc358564191 100644
--- a/arch/arm/mach-omap2/boot-common.c
+++ b/arch/arm/mach-omap2/boot-common.c
@@ -10,6 +10,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -19,9 +21,14 @@
 #include 
 #include 
 #include 
+#include 
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#define IPU1_LOAD_ADDR (0xa17ff000)
+#define MAX_REMOTECORE_BIN_SIZE (8 * 0x10)
+#define IPU2_LOAD_ADDR (IPU1_LOAD_ADDR + MAX_REMOTECORE_BIN_SIZE)
+
 __weak u32 omap_sys_boot_device(void)
 {
return BOOT_DEVICE_NONE;
@@ -194,6 +201,91 @@ u32 spl_mmc_boot_mode(const u32 boot_device)
return gd->arch.omap_boot_mode;
 }
 
+int load_firmware(char *name_fw, u32 *loadaddr)
+{
+   struct udevice *fsdev;
+   int size = 0;
+
+   if (!IS_ENABLED(CONFIG_FS_LOADER))
+   return 0;
+
+   if (!*loadaddr)
+   return 0;
+
+   if (!uclass_get_device(UCLASS_FS_FIRMWARE_LOADER, 0, )) {
+   size = request_firmware_into_buf(fsdev, name_fw,
+(void *)*loadaddr, 0, 0);
+   }
+
+   return size;
+}
+
+void spl_boot_ipu(void)
+{
+   int ret, size;
+   u32 loadaddr = IPU1_LOAD_ADDR;
+
+   if (!IS_ENABLED(CONFIG_SPL_BUILD) ||
+   !IS_ENABLED(CONFIG_REMOTEPROC_TI_IPU))
+   return;
+
+   size = load_firmware("dra7-ipu1-fw.xem4", );
+   if (size <= 0) {
+   pr_err("Firmware loading failed\n");
+   goto skip_ipu1;
+   }
+
+   enable_ipu1_clocks();
+   ret = rproc_dev_init(0);
+   if (ret) {
+   debug("%s: IPU1 failed to initialize on rproc (%d)\n",
+ __func__, ret);
+   goto skip_ipu1;
+   }
+
+   ret = rproc_load(0, IPU1_LOAD_ADDR, 0x200);
+   if (ret) {
+   debug("%s: IPU1 failed to load on rproc (%d)\n", __func__,
+ ret);
+   goto skip_ipu1;
+   }
+
+   debug("Starting IPU1...\n");
+
+   ret = rproc_start(0);
+   if (ret)
+   debug("%s: IPU1 failed to start (%d)\n", __func__, ret);
+
+skip_ipu1:
+   loadaddr = IPU2_LOAD_ADDR;
+   size = load_firmware("dra7-ipu2-fw.xem4", );
+   if 

[PATCH v4 01/11] configs: dra7xx_evm: Increase the size of SPL_MULTI_DTB_FIT

2022-01-27 Thread Amjad Ouled-Ameur
Expand SPL_MULTI_DTB_FIT to accommodate new SPL IPU nodes.

Signed-off-by: Amjad Ouled-Ameur 
---

(no changes since v1)

 configs/dra7xx_evm_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configs/dra7xx_evm_defconfig b/configs/dra7xx_evm_defconfig
index d1aa91d676e1..d3a1d3e4d334 100644
--- a/configs/dra7xx_evm_defconfig
+++ b/configs/dra7xx_evm_defconfig
@@ -52,7 +52,7 @@ CONFIG_OF_CONTROL=y
 CONFIG_SPL_OF_CONTROL=y
 CONFIG_OF_LIST="dra7-evm dra72-evm dra72-evm-revc dra71-evm dra76-evm"
 CONFIG_SPL_MULTI_DTB_FIT=y
-CONFIG_SPL_MULTI_DTB_FIT_UNCOMPRESS_SZ=0xA000
+CONFIG_SPL_MULTI_DTB_FIT_UNCOMPRESS_SZ=0x1
 CONFIG_OF_SPL_REMOVE_PROPS="clocks clock-names interrupt-parent"
 CONFIG_ENV_OVERWRITE=y
 # CONFIG_ENV_IS_IN_FAT is not set
-- 
2.25.1



[PATCH v4 00/11] dra7: bring up and support IPU load/start

2022-01-27 Thread Amjad Ouled-Ameur
This patchset enables support for loading and starting IPU firmware,
the following have been implemented:
- Enable fs_loader compilation at SPL Level, that is necessary in order
  to load IPU firmware from /boot partition.
- Define necessary related IPU dts nodes.
- Add necessary drivers and helpers to bring up, load and start IPU
  firmware.

The underlying patches are interdependent, therefore should be applied
in the order they are numbered in this patchset.

Tests:
- Please find SPL, u-boot and kernel console logs in here [1]
- At SPL stage, debug logs have been enabled to make sure that
IPU1 and IPU2 are loaded and started properly. In fact, these two log
messages are only displayed when the firmware has been loaded, and if no
errors appear afterwards, it means that firmware started successfully as
well:
  - Starting IPU1...
  - Starting IPU2...

At U-boot stage, "rproc" command-line tool was used for the testing. In
the logs [1], "rproc list" was run before and after IPU1 and IPU2 are
initialized by "rproc init". The before run gave an empty list, while
the after run listed successfully the two IPUs with their correct
addresses:
  - 0 - Name:'ipu@5882' type:'internal memory mapped'
  - 1 - Name:'ipu@5502' type:'internal memory mapped'

"rproc start" and "rproc stop" were also used for both IPU1 and IPU2,
both were successful as no error logs were displayed.

[0]: https://pastebin.com/QGUYSPRt

These U-boot/SPL flags have been purposely enabled during tests to ensure
IPU load/start work properly:
- CONFIG_DM_RESET=y
- CONFIG_RESET_DRA7=y
- CONFIG_SPL_DM_RESET=y
- CONFIG_FS_LOADER=y
- CONFIG_SPL_FS_LOADER=y
- CONFIG_SPL_DRIVERS_MISC_SUPPORT=y
- CONFIG_REMOTEPROC_TI_IPU=y
- CONFIG_SPL_REMOTEPROC=y
- CONFIG_CMD_REMOTEPROC=y


Changes in v4:
- Enable SPL fs_loader for j7200_evm_r5 and socfpga_arria10.

Changes in v3:
- Add a new patch for dra7xx_evm to expand SPL_MULTI_DTB_FIT

Changes in v2:
- Add useful checks and remove redundant code.

Amjad Ouled-Ameur (1):
  configs: dra7xx_evm: Increase the size of SPL_MULTI_DTB_FIT

Keerthy (10):
  reset: dra7: Add a reset driver
  arm: mach-omap2: load/start remoteproc IPU1/IPU2
  drivers: misc: Makefile: Enable fs_loader compilation at SPL Level
  linux: bitmap.h: Add find_next_zero_area function
  remoteproc: uclass: Add remoteproc resource handling helpers
  remoteproc: ipu: Add driver to bring up ipu
  dts: dra7-ipu-common-early-boot.dtsi: Add all the ipu early boot
related nodes
  arm: dts: dra7: Add ipu and related nodes
  arm: dts: dra7*/am57xx-idk-evm-u-boot: Add ipu early boot DT changes
  dts: am57xx*: Add ipu early boot DT changes

 MAINTAINERS   |   4 +
 .../dts/am57xx-beagle-x15-revb1-u-boot.dtsi   |   7 +
 .../dts/am57xx-beagle-x15-revc-u-boot.dtsi|   7 +
 arch/arm/dts/am57xx-beagle-x15-u-boot.dtsi|   7 +
 arch/arm/dts/am57xx-cl-som-am57x-u-boot.dtsi  |   7 +
 arch/arm/dts/am57xx-idk-common-u-boot.dtsi|   1 +
 arch/arm/dts/am57xx-sbc-am57x-u-boot.dtsi |   7 +
 arch/arm/dts/dra7-evm-u-boot.dtsi |   1 +
 arch/arm/dts/dra7-ipu-common-early-boot.dtsi  | 113 +++
 arch/arm/dts/dra7.dtsi|  45 +-
 arch/arm/dts/dra71-evm-u-boot.dtsi|   1 +
 arch/arm/dts/dra72-evm-revc-u-boot.dtsi   |   1 +
 arch/arm/dts/dra76-evm-u-boot.dtsi|   1 +
 arch/arm/include/asm/arch-omap5/clock.h   |   3 +
 arch/arm/include/asm/omap_common.h|  10 +
 arch/arm/mach-k3/common.c |  10 +-
 arch/arm/mach-omap2/boot-common.c |  95 +++
 arch/arm/mach-omap2/clocks-common.c   |  33 +
 arch/arm/mach-omap2/omap5/hw_data.c   |  92 ++-
 arch/arm/mach-omap2/omap5/prcm-regs.c |   9 +-
 configs/dra7xx_evm_defconfig  |   2 +-
 configs/j7200_evm_r5_defconfig|   1 +
 configs/j721e_evm_r5_defconfig|   1 +
 configs/j721e_hs_evm_r5_defconfig |   1 +
 configs/socfpga_arria10_defconfig |   1 +
 drivers/misc/Kconfig  |   9 +
 drivers/misc/Makefile |   2 +-
 drivers/remoteproc/Kconfig|  10 +
 drivers/remoteproc/Makefile   |   1 +
 drivers/remoteproc/ipu_rproc.c| 759 ++
 drivers/remoteproc/rproc-uclass.c | 534 
 drivers/reset/Kconfig |   6 +
 drivers/reset/Makefile|   1 +
 drivers/reset/reset-dra7.c|  97 +++
 include/linux/bitmap.h|  26 +
 include/remoteproc.h  | 384 -
 36 files changed, 2271 insertions(+), 18 deletions(-)
 create mode 100644 arch/arm/dts/am57xx-beagle-x15-revb1-u-boot.dtsi
 create mode 100644 arch/arm/dts/am57xx-beagle-x15-revc-u-boot.dtsi
 create mode 100644 arch/arm/dts/am57xx-beagle-x15-u-boot.d

[PATCH v3 11/11] dts: am57xx*: Add ipu early boot DT changes

2022-01-18 Thread Amjad Ouled-Ameur
From: Keerthy 

Add support for ipu early boot.

Signed-off-by: Keerthy 
Signed-off-by: Amjad Ouled-Ameur 

---

(no changes since v1)

 MAINTAINERS  | 1 +
 arch/arm/dts/am57xx-beagle-x15-revb1-u-boot.dtsi | 7 +++
 arch/arm/dts/am57xx-beagle-x15-revc-u-boot.dtsi  | 7 +++
 arch/arm/dts/am57xx-beagle-x15-u-boot.dtsi   | 7 +++
 arch/arm/dts/am57xx-cl-som-am57x-u-boot.dtsi | 7 +++
 arch/arm/dts/am57xx-sbc-am57x-u-boot.dtsi| 7 +++
 6 files changed, 36 insertions(+)
 create mode 100644 arch/arm/dts/am57xx-beagle-x15-revb1-u-boot.dtsi
 create mode 100644 arch/arm/dts/am57xx-beagle-x15-revc-u-boot.dtsi
 create mode 100644 arch/arm/dts/am57xx-beagle-x15-u-boot.dtsi
 create mode 100644 arch/arm/dts/am57xx-cl-som-am57x-u-boot.dtsi
 create mode 100644 arch/arm/dts/am57xx-sbc-am57x-u-boot.dtsi

diff --git a/MAINTAINERS b/MAINTAINERS
index 7adc28dbfd87..c73739a15a4b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -514,6 +514,7 @@ ARM TI
 M: Tom Rini 
 S: Maintained
 T: git https://source.denx.de/u-boot/custodians/u-boot-ti.git
+F: arch/arm/dts/am57xx*
 F: arch/arm/dts/dra7*
 F: arch/arm/mach-davinci/
 F: arch/arm/mach-k3/
diff --git a/arch/arm/dts/am57xx-beagle-x15-revb1-u-boot.dtsi 
b/arch/arm/dts/am57xx-beagle-x15-revb1-u-boot.dtsi
new file mode 100644
index ..49b16215e528
--- /dev/null
+++ b/arch/arm/dts/am57xx-beagle-x15-revb1-u-boot.dtsi
@@ -0,0 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
+ */
+
+#include "omap5-u-boot.dtsi"
+#include "dra7-ipu-common-early-boot.dtsi"
diff --git a/arch/arm/dts/am57xx-beagle-x15-revc-u-boot.dtsi 
b/arch/arm/dts/am57xx-beagle-x15-revc-u-boot.dtsi
new file mode 100644
index ..49b16215e528
--- /dev/null
+++ b/arch/arm/dts/am57xx-beagle-x15-revc-u-boot.dtsi
@@ -0,0 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
+ */
+
+#include "omap5-u-boot.dtsi"
+#include "dra7-ipu-common-early-boot.dtsi"
diff --git a/arch/arm/dts/am57xx-beagle-x15-u-boot.dtsi 
b/arch/arm/dts/am57xx-beagle-x15-u-boot.dtsi
new file mode 100644
index ..49b16215e528
--- /dev/null
+++ b/arch/arm/dts/am57xx-beagle-x15-u-boot.dtsi
@@ -0,0 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
+ */
+
+#include "omap5-u-boot.dtsi"
+#include "dra7-ipu-common-early-boot.dtsi"
diff --git a/arch/arm/dts/am57xx-cl-som-am57x-u-boot.dtsi 
b/arch/arm/dts/am57xx-cl-som-am57x-u-boot.dtsi
new file mode 100644
index ..49b16215e528
--- /dev/null
+++ b/arch/arm/dts/am57xx-cl-som-am57x-u-boot.dtsi
@@ -0,0 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
+ */
+
+#include "omap5-u-boot.dtsi"
+#include "dra7-ipu-common-early-boot.dtsi"
diff --git a/arch/arm/dts/am57xx-sbc-am57x-u-boot.dtsi 
b/arch/arm/dts/am57xx-sbc-am57x-u-boot.dtsi
new file mode 100644
index ..49b16215e528
--- /dev/null
+++ b/arch/arm/dts/am57xx-sbc-am57x-u-boot.dtsi
@@ -0,0 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
+ */
+
+#include "omap5-u-boot.dtsi"
+#include "dra7-ipu-common-early-boot.dtsi"
-- 
2.25.1



[PATCH v3 06/11] remoteproc: uclass: Add remoteproc resource handling helpers

2022-01-18 Thread Amjad Ouled-Ameur
From: Keerthy 

Add remoteproc resource handling helpers. These functions
are primarily to parse the resource table and to handle
different types of resources. Carveout, devmem, trace &
vring resources are handled.

Signed-off-by: Keerthy 
[Amjad: fix redefinition of "struct resource_table" and compile warnings ]
Signed-off-by: Amjad Ouled-Ameur 

---

(no changes since v2)

Changes in v2:
- Add useful checks and remove redundant code.

 drivers/remoteproc/rproc-uclass.c | 534 ++
 include/remoteproc.h  | 384 -
 2 files changed, 917 insertions(+), 1 deletion(-)

diff --git a/drivers/remoteproc/rproc-uclass.c 
b/drivers/remoteproc/rproc-uclass.c
index 87e1ec7ad7f0..50bcc9030e98 100644
--- a/drivers/remoteproc/rproc-uclass.c
+++ b/drivers/remoteproc/rproc-uclass.c
@@ -8,15 +8,31 @@
 
 #define pr_fmt(fmt) "%s: " fmt, __func__
 #include 
+#include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+struct resource_table {
+   u32 ver;
+   u32 num;
+   u32 reserved[2];
+   u32 offset[0];
+} __packed;
+
+typedef int (*handle_resource_t) (struct udevice *, void *, int offset, int 
avail);
+
+static struct resource_table *rsc_table;
 
 /**
  * for_each_remoteproc_device() - iterate through the list of rproc devices
@@ -196,6 +212,80 @@ static int rproc_post_probe(struct udevice *dev)
return 0;
 }
 
+/**
+ * rproc_add_res() - After parsing the resource table add the mappings
+ * @dev:   device we finished probing
+ * @mapping: rproc_mem_entry for the resource
+ *
+ * Return: if the remote proc driver has a add_res routine, invokes it and
+ * hands over the return value. overall, 0 if all went well, else appropriate
+ * error value.
+ */
+static int rproc_add_res(struct udevice *dev, struct rproc_mem_entry *mapping)
+{
+   const struct dm_rproc_ops *ops = rproc_get_ops(dev);
+
+   if (!ops->add_res)
+   return -ENOSYS;
+
+   return ops->add_res(dev, mapping);
+}
+
+/**
+ * rproc_alloc_mem() - After parsing the resource table allocat mem
+ * @dev:   device we finished probing
+ * @len: rproc_mem_entry for the resource
+ * @align: alignment for the resource
+ *
+ * Return: if the remote proc driver has a add_res routine, invokes it and
+ * hands over the return value. overall, 0 if all went well, else appropriate
+ * error value.
+ */
+static void *rproc_alloc_mem(struct udevice *dev, unsigned long len,
+unsigned long align)
+{
+   const struct dm_rproc_ops *ops;
+
+   ops = rproc_get_ops(dev);
+   if (!ops) {
+   debug("%s driver has no ops?\n", dev->name);
+   return NULL;
+   }
+
+   if (ops->alloc_mem)
+   return ops->alloc_mem(dev, len, align);
+
+   return NULL;
+}
+
+/**
+ * rproc_config_pagetable() - Configure page table for remote processor
+ * @dev:   device we finished probing
+ * @virt: Virtual address of the resource
+ * @phys: Physical address the resource
+ * @len: length the resource
+ *
+ * Return: if the remote proc driver has a add_res routine, invokes it and
+ * hands over the return value. overall, 0 if all went well, else appropriate
+ * error value.
+ */
+static int rproc_config_pagetable(struct udevice *dev, unsigned int virt,
+ unsigned int phys, unsigned int len)
+{
+   const struct dm_rproc_ops *ops;
+
+   ops = rproc_get_ops(dev);
+   if (!ops) {
+   debug("%s driver has no ops?\n", dev->name);
+   return -EINVAL;
+   }
+
+   if (ops->config_pagetable)
+   return ops->config_pagetable(dev, virt, phys, len);
+
+   return 0;
+}
+
 UCLASS_DRIVER(rproc) = {
.id = UCLASS_REMOTEPROC,
.name = "remoteproc",
@@ -426,3 +516,447 @@ int rproc_is_running(int id)
 {
return _rproc_ops_wrapper(id, RPROC_RUNNING);
 };
+
+
+static int handle_trace(struct udevice *dev, struct fw_rsc_trace *rsc,
+   int offset, int avail)
+{
+   if (sizeof(*rsc) > avail) {
+   debug("trace rsc is truncated\n");
+   return -EINVAL;
+   }
+
+   /*
+* make sure reserved bytes are zeroes
+*/
+   if (rsc->reserved) {
+   debug("trace rsc has non zero reserved bytes\n");
+   return -EINVAL;
+   }
+
+   debug("trace rsc: da 0x%x, len 0x%x\n", rsc->da, rsc->len);
+
+   return 0;
+}
+
+static int handle_devmem(struct udevice *dev, struct fw_rsc_devmem *rsc,
+int offset, int avail)
+{
+   struct rproc_mem_entry *mapping;
+
+   if (sizeof(*rsc) > avail) {
+   debug("devmem rsc is truncated\n");
+   return -EINVAL;
+   }
+

[PATCH v3 07/11] remoteproc: ipu: Add driver to bring up ipu

2022-01-18 Thread Amjad Ouled-Ameur
From: Keerthy 

The driver enables IPU support. Basically enables the clocks,
timers, watchdog timers and bare minimal MMU and supports
loading the firmware from mmc.

Signed-off-by: Keerthy 
[Amjad: fix compile warnings]
Signed-off-by: Amjad Ouled-Ameur 
---

(no changes since v1)

 MAINTAINERS|   1 +
 drivers/remoteproc/Kconfig |  10 +
 drivers/remoteproc/Makefile|   1 +
 drivers/remoteproc/ipu_rproc.c | 759 +
 4 files changed, 771 insertions(+)
 create mode 100644 drivers/remoteproc/ipu_rproc.c

diff --git a/MAINTAINERS b/MAINTAINERS
index bd9cc4107cbe..311397137b27 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -533,6 +533,7 @@ F:  drivers/phy/omap-usb2-phy.c
 F: drivers/phy/phy-ti-am654.c
 F: drivers/phy/ti-pipe3-phy.c
 F: drivers/ram/k3*
+F: drivers/remoteproc/ipu_rproc.c
 F: drivers/remoteproc/k3_system_controller.c
 F: drivers/remoteproc/pruc_rpoc.c
 F: drivers/remoteproc/ti*
diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
index 24e536463bbd..27e4a60ff5b1 100644
--- a/drivers/remoteproc/Kconfig
+++ b/drivers/remoteproc/Kconfig
@@ -92,4 +92,14 @@ config REMOTEPROC_TI_PRU
help
  Say 'y' here to add support for TI' K3 remoteproc driver.
 
+config REMOTEPROC_TI_IPU
+   bool "Support for TI's K3 based IPU remoteproc driver"
+   select REMOTEPROC
+   depends on DM
+   depends on SPL_DRIVERS_MISC
+   depends on SPL_FS_LOADER
+   depends on OF_CONTROL
+   help
+ Say 'y' here to add support for TI' K3 remoteproc driver.
+
 endmenu
diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile
index f0e83451d66f..fbe9c172bc04 100644
--- a/drivers/remoteproc/Makefile
+++ b/drivers/remoteproc/Makefile
@@ -15,3 +15,4 @@ obj-$(CONFIG_REMOTEPROC_TI_K3_DSP) += ti_k3_dsp_rproc.o
 obj-$(CONFIG_REMOTEPROC_TI_K3_R5F) += ti_k3_r5f_rproc.o
 obj-$(CONFIG_REMOTEPROC_TI_POWER) += ti_power_proc.o
 obj-$(CONFIG_REMOTEPROC_TI_PRU) += pru_rproc.o
+obj-$(CONFIG_REMOTEPROC_TI_IPU) += ipu_rproc.o
diff --git a/drivers/remoteproc/ipu_rproc.c b/drivers/remoteproc/ipu_rproc.c
new file mode 100644
index ..b4a06bc955a9
--- /dev/null
+++ b/drivers/remoteproc/ipu_rproc.c
@@ -0,0 +1,759 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * IPU remoteproc driver for various SoCs
+ *
+ * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
+ * Angela Stegmaier  
+ * Venkateswara Rao Mandela 
+ *  Keerthy 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define IPU1_LOAD_ADDR (0xa17ff000)
+#define MAX_REMOTECORE_BIN_SIZE (8 * 0x10)
+
+enum ipu_num {
+   IPU1 = 0,
+   IPU2,
+   RPROC_END_ENUMS,
+};
+
+#define IPU2_LOAD_ADDR (IPU1_LOAD_ADDR + MAX_REMOTECORE_BIN_SIZE)
+
+#define PAGE_SHIFT 12
+#define PAGESIZE_1M  0x0
+#define PAGESIZE_64K 0x1
+#define PAGESIZE_4K  0x2
+#define PAGESIZE_16M 0x3
+#define LE   0
+#define BE   1
+#define ELEMSIZE_8   0x0
+#define ELEMSIZE_16  0x1
+#define ELEMSIZE_32  0x2
+#define MIXED_TLB0x0
+#define MIXED_CPU0x1
+
+#define PGT_SMALLPAGE_SIZE   0x1000
+#define PGT_LARGEPAGE_SIZE   0x0001
+#define PGT_SECTION_SIZE 0x0010
+#define PGT_SUPERSECTION_SIZE0x0100
+
+#define PGT_L1_DESC_PAGE 0x1
+#define PGT_L1_DESC_SECTION  0x2
+#define PGT_L1_DESC_SUPERSECTION 0x40002
+
+#define PGT_L1_DESC_PAGE_MASK0xfC00
+#define PGT_L1_DESC_SECTION_MASK 0xfff0
+#define PGT_L1_DESC_SUPERSECTION_MASK0xff00
+
+#define PGT_L1_DESC_SMALLPAGE_INDEX_SHIFT12
+#define PGT_L1_DESC_LARGEPAGE_INDEX_SHIFT16
+#define PGT_L1_DESC_SECTION_INDEX_SHIFT  20
+#define PGT_L1_DESC_SUPERSECTION_INDEX_SHIFT 24
+
+#define PGT_L2_DESC_SMALLPAGE   0x02
+#define PGT_L2_DESC_LARGEPAGE   0x01
+
+#define PGT_L2_DESC_SMALLPAGE_MASK  0xf000
+#define PGT_L2_DESC_LARGEPAGE_MASK  0x
+
+/*
+ * The memory for the page tables (256 KB per IPU) is placed just before
+ * the carveout memories for the remote processors. 16 KB of memory is
+ * needed for the L1 page table (4096 entries * 4 bytes per 1 MB section).
+ * Any smaller page (64 KB or 4 KB) entries are supported through L2 page
+ * tables (1 KB per table). The remaining 240 KB can provide support for

[PATCH v3 10/11] arm: dts: dra7*/am57xx-idk-evm-u-boot: Add ipu early boot DT changes

2022-01-18 Thread Amjad Ouled-Ameur
From: Keerthy 

Add support for ipu early boot.

Signed-off-by: Keerthy 
Signed-off-by: Amjad Ouled-Ameur 
---

(no changes since v1)

 arch/arm/dts/am57xx-idk-common-u-boot.dtsi | 1 +
 arch/arm/dts/dra7-evm-u-boot.dtsi  | 1 +
 arch/arm/dts/dra71-evm-u-boot.dtsi | 1 +
 arch/arm/dts/dra72-evm-revc-u-boot.dtsi| 1 +
 arch/arm/dts/dra76-evm-u-boot.dtsi | 1 +
 5 files changed, 5 insertions(+)

diff --git a/arch/arm/dts/am57xx-idk-common-u-boot.dtsi 
b/arch/arm/dts/am57xx-idk-common-u-boot.dtsi
index b07aea0048d5..d0ce469f9189 100644
--- a/arch/arm/dts/am57xx-idk-common-u-boot.dtsi
+++ b/arch/arm/dts/am57xx-idk-common-u-boot.dtsi
@@ -3,6 +3,7 @@
  * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
  */
 #include "omap5-u-boot.dtsi"
+#include "dra7-ipu-common-early-boot.dtsi"
 
 / {
xtal25mhz: xtal25mhz {
diff --git a/arch/arm/dts/dra7-evm-u-boot.dtsi 
b/arch/arm/dts/dra7-evm-u-boot.dtsi
index f06c701dbd1f..5622512b2401 100644
--- a/arch/arm/dts/dra7-evm-u-boot.dtsi
+++ b/arch/arm/dts/dra7-evm-u-boot.dtsi
@@ -4,6 +4,7 @@
  */
 
 #include "omap5-u-boot.dtsi"
+#include "dra7-ipu-common-early-boot.dtsi"
 
 _gpio_21{
u-boot,i2c-offset-len = <0>;
diff --git a/arch/arm/dts/dra71-evm-u-boot.dtsi 
b/arch/arm/dts/dra71-evm-u-boot.dtsi
index b56d4fc9d896..40443da5c855 100644
--- a/arch/arm/dts/dra71-evm-u-boot.dtsi
+++ b/arch/arm/dts/dra71-evm-u-boot.dtsi
@@ -4,6 +4,7 @@
  */
 
 #include "omap5-u-boot.dtsi"
+#include "dra7-ipu-common-early-boot.dtsi"
 
 _gpio_21{
u-boot,i2c-offset-len = <0>;
diff --git a/arch/arm/dts/dra72-evm-revc-u-boot.dtsi 
b/arch/arm/dts/dra72-evm-revc-u-boot.dtsi
index b56d4fc9d896..40443da5c855 100644
--- a/arch/arm/dts/dra72-evm-revc-u-boot.dtsi
+++ b/arch/arm/dts/dra72-evm-revc-u-boot.dtsi
@@ -4,6 +4,7 @@
  */
 
 #include "omap5-u-boot.dtsi"
+#include "dra7-ipu-common-early-boot.dtsi"
 
 _gpio_21{
u-boot,i2c-offset-len = <0>;
diff --git a/arch/arm/dts/dra76-evm-u-boot.dtsi 
b/arch/arm/dts/dra76-evm-u-boot.dtsi
index a4dfbe7e601a..5fae6ba91936 100644
--- a/arch/arm/dts/dra76-evm-u-boot.dtsi
+++ b/arch/arm/dts/dra76-evm-u-boot.dtsi
@@ -4,6 +4,7 @@
  */
 
 #include "omap5-u-boot.dtsi"
+#include "dra7-ipu-common-early-boot.dtsi"
 
 _emac0 {
phy-handle = <_0>;
-- 
2.25.1



[PATCH v3 09/11] arm: dts: dra7: Add ipu and related nodes

2022-01-18 Thread Amjad Ouled-Ameur
From: Keerthy 

Add ipu and the associated nodes.

Signed-off-by: Keerthy 
Signed-off-by: Amjad Ouled-Ameur 
---

(no changes since v1)

 arch/arm/dts/dra7.dtsi | 45 +-
 1 file changed, 44 insertions(+), 1 deletion(-)

diff --git a/arch/arm/dts/dra7.dtsi b/arch/arm/dts/dra7.dtsi
index fd1aea0b1b16..e2e958b36626 100644
--- a/arch/arm/dts/dra7.dtsi
+++ b/arch/arm/dts/dra7.dtsi
@@ -41,6 +41,8 @@
d_can0 = 
d_can1 = 
spi0 = 
+   remoteproc0 = 
+   remoteproc1 = 
};
 
timer {
@@ -263,9 +265,12 @@
};
 
prm: prm@6000 {
-   compatible = "ti,dra7-prm";
+   compatible = "ti,dra7-prm", "simple-bus";
reg = <0x6000 0x3000>;
interrupts = ;
+   #address-cells = <1>;
+   #size-cells = <1>;
+   ranges = <0 0x6000 0x3000>;
 
prm_clocks: clocks {
#address-cells = <1>;
@@ -274,6 +279,20 @@
 
prm_clockdomains: clockdomains {
};
+
+   ipu1_rst: ipu1_rst@510 {
+   compatible = "ti,dra7-reset";
+   reg = <0x510 0x8>;
+   ti,nresets = <3>;
+   #reset-cells = <1>;
+   };
+
+   ipu2_rst: ipu2_rst@910 {
+   compatible = "ti,dra7-reset";
+   reg = <0x910 0x8>;
+   ti,nresets = <3>;
+   #reset-cells = <1>;
+   };
};
 
scm_wkup: scm_conf@c000 {
@@ -2032,6 +2051,30 @@
clocks = <_iclk_div>;
clock-names = "fck";
};
+
+   ipu1: ipu@5882 {
+   compatible = "ti,dra7-ipu";
+   reg = <0x5882 0x1>;
+   reg-names = "l2ram";
+   ti,hwmods = "ipu1";
+   resets = <_rst 0>, <_rst 1>, <_rst 2>;
+   iommus = <_ipu1>;
+   ti,rproc-standby-info = <0x4a005520>;
+   timers = <>;
+   watchdog-timers = <>, <>;
+   };
+
+   ipu2: ipu@5502 {
+   compatible = "ti,dra7-ipu";
+   reg = <0x5502 0x1>;
+   reg-names = "l2ram";
+   ti,hwmods = "ipu2";
+   resets = <_rst 0>, <_rst 1>, <_rst 2>;
+   iommus = <_ipu2>;
+   ti,rproc-standby-info = <0x4a008920>;
+   timers = <>;
+   watchdog-timers = <>, <>;
+   };
};
 
thermal_zones: thermal-zones {
-- 
2.25.1



[PATCH v3 08/11] dts: dra7-ipu-common-early-boot.dtsi: Add all the ipu early boot related nodes

2022-01-18 Thread Amjad Ouled-Ameur
From: Keerthy 

Add all the ipu early boot related nodes

Signed-off-by: Keerthy 
Signed-off-by: Amjad Ouled-Ameur 
---

(no changes since v1)

 MAINTAINERS  |   1 +
 arch/arm/dts/dra7-ipu-common-early-boot.dtsi | 113 +++
 2 files changed, 114 insertions(+)
 create mode 100644 arch/arm/dts/dra7-ipu-common-early-boot.dtsi

diff --git a/MAINTAINERS b/MAINTAINERS
index 311397137b27..7adc28dbfd87 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -514,6 +514,7 @@ ARM TI
 M: Tom Rini 
 S: Maintained
 T: git https://source.denx.de/u-boot/custodians/u-boot-ti.git
+F: arch/arm/dts/dra7*
 F: arch/arm/mach-davinci/
 F: arch/arm/mach-k3/
 F: arch/arm/mach-keystone/
diff --git a/arch/arm/dts/dra7-ipu-common-early-boot.dtsi 
b/arch/arm/dts/dra7-ipu-common-early-boot.dtsi
new file mode 100644
index ..ec6040ff93eb
--- /dev/null
+++ b/arch/arm/dts/dra7-ipu-common-early-boot.dtsi
@@ -0,0 +1,113 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
+ */
+
+/ {
+   chosen {
+   firmware-loader = _loader0;
+   };
+
+   fs_loader0: fs_loader@0 {
+   u-boot,dm-pre-reloc;
+   compatible = "u-boot,fs-loader";
+   phandlepart = < 1>;
+   };
+
+   reserved-memory {
+   #address-cells = <2>;
+   #size-cells = <2>;
+   ranges;
+   u-boot,dm-spl;
+
+   ipu2_memory_region: ipu2-memory@9580 {
+   compatible = "shared-dma-pool";
+   reg = <0x0 0x9580 0x0 0x380>;
+   reusable;
+   status = "okay";
+   u-boot,dm-spl;
+   };
+
+   ipu1_memory_region: ipu1-memory@9d00 {
+   compatible = "shared-dma-pool";
+   reg = <0x0 0x9d00 0x0 0x200>;
+   reusable;
+   status = "okay";
+   u-boot,dm-spl;
+   };
+
+   ipu1_pgtbl: ipu1-pgtbl@9570 {
+   reg = <0x0 0x9570 0x0 0x4>;
+   no-map;
+   u-boot,dm-spl;
+   };
+
+   ipu2_pgtbl: ipu2-pgtbl@9574 {
+   reg = <0x0 0x9574 0x0 0x4>;
+   no-map;
+   u-boot,dm-spl;
+   };
+   };
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+_ipu1 {
+   u-boot,dm-spl;
+};
+
+_ipu2 {
+   u-boot,dm-spl;
+};
+
+ {
+   status = "okay";
+   memory-region = <_memory_region>;
+   pg-tbl = <_pgtbl>;
+   u-boot,dm-spl;
+};
+
+ {
+   status = "okay";
+   memory-region = <_memory_region>;
+   pg-tbl = <_pgtbl>;
+   u-boot,dm-spl;
+};
+
+_wkup {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+_rst {
+   u-boot,dm-spl;
+};
+
+_rst {
+   u-boot,dm-spl;
+};
-- 
2.25.1



[PATCH v3 05/11] linux: bitmap.h: Add find_next_zero_area function

2022-01-18 Thread Amjad Ouled-Ameur
From: Keerthy 

Add find_next_zero_area to fetch the next zero area in the map.

Signed-off-by: Keerthy 
Signed-off-by: Amjad Ouled-Ameur 
---

(no changes since v1)

 include/linux/bitmap.h | 26 ++
 1 file changed, 26 insertions(+)

diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
index dae4225be549..0a8503af9f14 100644
--- a/include/linux/bitmap.h
+++ b/include/linux/bitmap.h
@@ -159,6 +159,32 @@ static inline unsigned long find_first_bit(const unsigned 
long *addr, unsigned l
 (bit) < (size);\
 (bit) = find_next_bit((addr), (size), (bit) + 1))
 
+static inline unsigned long
+bitmap_find_next_zero_area(unsigned long *map,
+  unsigned long size,
+  unsigned long start,
+  unsigned int nr, unsigned long align_mask)
+{
+   unsigned long index, end, i;
+again:
+   index = find_next_zero_bit(map, size, start);
+
+   /*
+* Align allocation
+*/
+   index = (index + align_mask) & ~align_mask;
+
+   end = index + nr;
+   if (end > size)
+   return end;
+   i = find_next_bit(map, end, index);
+   if (i < end) {
+   start = i + 1;
+   goto again;
+   }
+   return index;
+}
+
 static inline void bitmap_fill(unsigned long *dst, unsigned int nbits)
 {
if (small_const_nbits(nbits)) {
-- 
2.25.1



[PATCH v3 04/11] drivers: misc: Makefile: Enable fs_loader compilation at SPL Level

2022-01-18 Thread Amjad Ouled-Ameur
From: Keerthy 

Enable fs_loader compilation at SPL Level.

Signed-off-by: Keerthy 
[Amjad: fix compilation failures for J721e platform]
Signed-off-by: Amjad Ouled-Ameur 
---

(no changes since v1)

 arch/arm/mach-k3/common.c | 10 +++---
 configs/j721e_evm_r5_defconfig|  1 +
 configs/j721e_hs_evm_r5_defconfig |  1 +
 drivers/misc/Kconfig  |  9 +
 drivers/misc/Makefile |  2 +-
 5 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c
index 39d00270b7fa..b4b75f4e6c86 100644
--- a/arch/arm/mach-k3/common.c
+++ b/arch/arm/mach-k3/common.c
@@ -156,13 +156,15 @@ void init_env(void)
 #endif
 }
 
-#ifdef CONFIG_FS_LOADER
 int load_firmware(char *name_fw, char *name_loadaddr, u32 *loadaddr)
 {
struct udevice *fsdev;
char *name = NULL;
int size = 0;
 
+   if (!IS_ENABLED(CONFIG_FS_LOADER))
+   return 0;
+
*loadaddr = 0;
 #ifdef CONFIG_SPL_ENV_SUPPORT
switch (spl_boot_device()) {
@@ -186,12 +188,6 @@ int load_firmware(char *name_fw, char *name_loadaddr, u32 
*loadaddr)
 
return size;
 }
-#else
-int load_firmware(char *name_fw, char *name_loadaddr, u32 *loadaddr)
-{
-   return 0;
-}
-#endif
 
 __weak void release_resources_for_core_shutdown(void)
 {
diff --git a/configs/j721e_evm_r5_defconfig b/configs/j721e_evm_r5_defconfig
index b0759d1f305d..1fb13a8a707d 100644
--- a/configs/j721e_evm_r5_defconfig
+++ b/configs/j721e_evm_r5_defconfig
@@ -88,6 +88,7 @@ CONFIG_SYS_I2C_OMAP24XX=y
 CONFIG_DM_MAILBOX=y
 CONFIG_K3_SEC_PROXY=y
 CONFIG_FS_LOADER=y
+CONFIG_SPL_FS_LOADER=y
 CONFIG_ESM_K3=y
 CONFIG_K3_AVS0=y
 CONFIG_ESM_PMIC=y
diff --git a/configs/j721e_hs_evm_r5_defconfig 
b/configs/j721e_hs_evm_r5_defconfig
index 3d2bbb4844e8..1e4a93ff53fe 100644
--- a/configs/j721e_hs_evm_r5_defconfig
+++ b/configs/j721e_hs_evm_r5_defconfig
@@ -82,6 +82,7 @@ CONFIG_SYS_I2C_OMAP24XX=y
 CONFIG_DM_MAILBOX=y
 CONFIG_K3_SEC_PROXY=y
 CONFIG_FS_LOADER=y
+CONFIG_SPL_FS_LOADER=y
 CONFIG_K3_AVS0=y
 CONFIG_MMC_SDHCI=y
 CONFIG_SPL_MMC_SDHCI_ADMA=y
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index a8baaeaf5cfe..0ade3e32b0ef 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -453,6 +453,15 @@ config FS_LOADER
  The consumer driver would then use this loader to program whatever,
  ie. the FPGA device.
 
+config SPL_FS_LOADER
+   bool "Enable loader driver for file system"
+   help
+ This is file system generic loader which can be used to load
+ the file image from the storage into target such as memory.
+
+ The consumer driver would then use this loader to program whatever,
+ ie. the FPGA device.
+
 config GDSYS_SOC
bool "Enable gdsys SOC driver"
depends on MISC
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index f9826d2462d1..bca7b24e99ad 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -37,7 +37,7 @@ obj-$(CONFIG_FSL_IFC) += fsl_ifc.o
 obj-$(CONFIG_FSL_IIM) += fsl_iim.o
 obj-$(CONFIG_FSL_MC9SDZ60) += mc9sdz60.o
 obj-$(CONFIG_FSL_SEC_MON) += fsl_sec_mon.o
-obj-$(CONFIG_FS_LOADER) += fs_loader.o
+obj-$(CONFIG_$(SPL_)FS_LOADER) += fs_loader.o
 obj-$(CONFIG_GDSYS_IOEP) += gdsys_ioep.o
 obj-$(CONFIG_GDSYS_RXAUI_CTRL) += gdsys_rxaui_ctrl.o
 obj-$(CONFIG_GDSYS_SOC) += gdsys_soc.o
-- 
2.25.1



[PATCH v3 03/11] arm: mach-omap2: load/start remoteproc IPU1/IPU2

2022-01-18 Thread Amjad Ouled-Ameur
From: Keerthy 

First check the presence of the ipu firmware in the boot partition.
If present enable the ipu and the related clocks & then move
on to load the firmware and eventually start remoteproc IPU1/IPU2.

do_enable_clocks by default puts the clock domains into auto
which does not work well with reset. Hence adding do_enable_ipu_clocks
function.

Signed-off-by: Keerthy 
[Amjad: fix IPU1_LOAD_ADDR and compile warnings]
Signed-off-by: Amjad Ouled-Ameur 
---

(no changes since v1)

 arch/arm/include/asm/arch-omap5/clock.h |  3 +
 arch/arm/include/asm/omap_common.h  | 10 +++
 arch/arm/mach-omap2/boot-common.c   | 95 +
 arch/arm/mach-omap2/clocks-common.c | 33 +
 arch/arm/mach-omap2/omap5/hw_data.c | 92 ++--
 arch/arm/mach-omap2/omap5/prcm-regs.c   |  9 ++-
 6 files changed, 235 insertions(+), 7 deletions(-)

diff --git a/arch/arm/include/asm/arch-omap5/clock.h 
b/arch/arm/include/asm/arch-omap5/clock.h
index 87eb3f335ab0..a00626e357c9 100644
--- a/arch/arm/include/asm/arch-omap5/clock.h
+++ b/arch/arm/include/asm/arch-omap5/clock.h
@@ -135,6 +135,9 @@
 #define HSMMC_CLKCTRL_CLKSEL_MASK  (1 << 24)
 #define HSMMC_CLKCTRL_CLKSEL_DIV_MASK  (3 << 25)
 
+/* CM_IPU1_IPU1_CLKCTRL CLKSEL MASK */
+#define IPU1_CLKCTRL_CLKSEL_MASK   BIT(24)
+
 /* CM_L3INIT_SATA_CLKCTRL */
 #define SATA_CLKCTRL_OPTFCLKEN_MASK(1 << 8)
 
diff --git a/arch/arm/include/asm/omap_common.h 
b/arch/arm/include/asm/omap_common.h
index de8fc99d0478..264a2e717a70 100644
--- a/arch/arm/include/asm/omap_common.h
+++ b/arch/arm/include/asm/omap_common.h
@@ -362,6 +362,10 @@ struct prcm_regs {
/* IPU */
u32 cm_ipu_clkstctrl;
u32 cm_ipu_i2c5_clkctrl;
+   u32 cm_ipu1_clkstctrl;
+   u32 cm_ipu1_ipu1_clkctrl;
+   u32 cm_ipu2_clkstctrl;
+   u32 cm_ipu2_ipu2_clkctrl;
 
/*l3main1 edma*/
u32 cm_l3main1_tptc1_clkctrl;
@@ -632,6 +636,12 @@ void do_disable_clocks(u32 const *clk_domains,
   u8 wait_for_disable);
 #endif /* CONFIG_OMAP44XX || CONFIG_OMAP54XX */
 
+void do_enable_ipu_clocks(u32 const *clk_domains,
+ u32 const *clk_modules_hw_auto,
+ u32 const *clk_modules_explicit_en,
+ u8 wait_for_enable);
+void enable_ipu1_clocks(void);
+void enable_ipu2_clocks(void);
 void setup_post_dividers(u32 const base,
const struct dpll_params *params);
 u32 omap_ddr_clk(void);
diff --git a/arch/arm/mach-omap2/boot-common.c 
b/arch/arm/mach-omap2/boot-common.c
index fdb8b479ea01..afc358564191 100644
--- a/arch/arm/mach-omap2/boot-common.c
+++ b/arch/arm/mach-omap2/boot-common.c
@@ -10,6 +10,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -19,9 +21,14 @@
 #include 
 #include 
 #include 
+#include 
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#define IPU1_LOAD_ADDR (0xa17ff000)
+#define MAX_REMOTECORE_BIN_SIZE (8 * 0x10)
+#define IPU2_LOAD_ADDR (IPU1_LOAD_ADDR + MAX_REMOTECORE_BIN_SIZE)
+
 __weak u32 omap_sys_boot_device(void)
 {
return BOOT_DEVICE_NONE;
@@ -194,6 +201,91 @@ u32 spl_mmc_boot_mode(const u32 boot_device)
return gd->arch.omap_boot_mode;
 }
 
+int load_firmware(char *name_fw, u32 *loadaddr)
+{
+   struct udevice *fsdev;
+   int size = 0;
+
+   if (!IS_ENABLED(CONFIG_FS_LOADER))
+   return 0;
+
+   if (!*loadaddr)
+   return 0;
+
+   if (!uclass_get_device(UCLASS_FS_FIRMWARE_LOADER, 0, )) {
+   size = request_firmware_into_buf(fsdev, name_fw,
+(void *)*loadaddr, 0, 0);
+   }
+
+   return size;
+}
+
+void spl_boot_ipu(void)
+{
+   int ret, size;
+   u32 loadaddr = IPU1_LOAD_ADDR;
+
+   if (!IS_ENABLED(CONFIG_SPL_BUILD) ||
+   !IS_ENABLED(CONFIG_REMOTEPROC_TI_IPU))
+   return;
+
+   size = load_firmware("dra7-ipu1-fw.xem4", );
+   if (size <= 0) {
+   pr_err("Firmware loading failed\n");
+   goto skip_ipu1;
+   }
+
+   enable_ipu1_clocks();
+   ret = rproc_dev_init(0);
+   if (ret) {
+   debug("%s: IPU1 failed to initialize on rproc (%d)\n",
+ __func__, ret);
+   goto skip_ipu1;
+   }
+
+   ret = rproc_load(0, IPU1_LOAD_ADDR, 0x200);
+   if (ret) {
+   debug("%s: IPU1 failed to load on rproc (%d)\n", __func__,
+ ret);
+   goto skip_ipu1;
+   }
+
+   debug("Starting IPU1...\n");
+
+   ret = rproc_start(0);
+   if (ret)
+   debug("%s: IPU1 failed to start (%d)\n", __func__, ret);
+
+skip_ipu1:
+   loadaddr = IPU2_LOAD_ADDR;
+   size = load_firmware("dra7-ipu2-fw.xem4", );
+   if 

[PATCH v3 02/11] reset: dra7: Add a reset driver

2022-01-18 Thread Amjad Ouled-Ameur
From: Keerthy 

Add a reset driver to bring IPs out of reset.

Signed-off-by: Keerthy 
[Amjad: reset_ops structure member "free" has been renamed to "rfree",
use the latter instead]
Signed-off-by: Amjad Ouled-Ameur 
---

(no changes since v1)

 MAINTAINERS|  1 +
 drivers/reset/Kconfig  |  6 +++
 drivers/reset/Makefile |  1 +
 drivers/reset/reset-dra7.c | 97 ++
 4 files changed, 105 insertions(+)
 create mode 100644 drivers/reset/reset-dra7.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 38c68ee87d41..bd9cc4107cbe 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -536,6 +536,7 @@ F:  drivers/ram/k3*
 F: drivers/remoteproc/k3_system_controller.c
 F: drivers/remoteproc/pruc_rpoc.c
 F: drivers/remoteproc/ti*
+F: drivers/reset/reset-dra7.c
 F: drivers/reset/reset-ti-sci.c
 F: drivers/rtc/davinci.c
 F: drivers/serial/serial_omap.c
diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig
index d73daf5e3189..b57714111b5a 100644
--- a/drivers/reset/Kconfig
+++ b/drivers/reset/Kconfig
@@ -206,4 +206,10 @@ config RESET_ZYNQMP
  passing request via Xilinx firmware interface to TF-A and PMU
  firmware.
 
+config RESET_DRA7
+   bool "Support for TI's DRA7 Reset driver"
+   depends on DM_RESET
+   help
+ Support for TI DRA7-RESET subsystem. Basic Assert/Deassert
+ is supported.
 endmenu
diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile
index d69486bdeb9e..97e3a782c0d8 100644
--- a/drivers/reset/Makefile
+++ b/drivers/reset/Makefile
@@ -30,3 +30,4 @@ obj-$(CONFIG_RESET_SYSCON) += reset-syscon.o
 obj-$(CONFIG_RESET_RASPBERRYPI) += reset-raspberrypi.o
 obj-$(CONFIG_RESET_SCMI) += reset-scmi.o
 obj-$(CONFIG_RESET_ZYNQMP) += reset-zynqmp.o
+obj-$(CONFIG_RESET_DRA7) += reset-dra7.o
diff --git a/drivers/reset/reset-dra7.c b/drivers/reset/reset-dra7.c
new file mode 100644
index ..585f8323c52e
--- /dev/null
+++ b/drivers/reset/reset-dra7.c
@@ -0,0 +1,97 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Texas Instruments DRA7 reset driver
+ *
+ * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
+ * Author: Keerthy 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct dra7_reset_priv {
+   u32 rstctrl;
+   u32 rstst;
+   u8 nreset;
+};
+
+static int dra7_reset_request(struct reset_ctl *reset_ctl)
+{
+   return 0;
+}
+
+static int dra7_reset_free(struct reset_ctl *reset_ctl)
+{
+   return 0;
+}
+
+static inline void dra7_reset_rmw(u32 addr, u32 value, u32 mask)
+{
+   writel(((readl(addr) & (~mask)) | (value & mask)), addr);
+}
+
+static int dra7_reset_deassert(struct reset_ctl *reset_ctl)
+{
+   struct dra7_reset_priv *priv = dev_get_priv(reset_ctl->dev);
+   int mask = 1 << reset_ctl->id;
+
+   if (reset_ctl->id < 0 || reset_ctl->id >= priv->nreset)
+   return -EINVAL;
+
+   dra7_reset_rmw(priv->rstctrl, 0x0, mask);
+
+   while ((readl(priv->rstst) & mask) != mask)
+   ;
+
+   return 0;
+}
+
+static int dra7_reset_assert(struct reset_ctl *reset_ctl)
+{
+   struct dra7_reset_priv *priv = dev_get_priv(reset_ctl->dev);
+   int mask = 1 << reset_ctl->id;
+
+   if (reset_ctl->id < 0 || reset_ctl->id >= priv->nreset)
+   return -EINVAL;
+
+   dra7_reset_rmw(priv->rstctrl, mask, 0x0);
+
+   return 0;
+}
+
+struct reset_ops dra7_reset_ops = {
+   .request = dra7_reset_request,
+   .rfree = dra7_reset_free,
+   .rst_assert = dra7_reset_assert,
+   .rst_deassert = dra7_reset_deassert,
+};
+
+static const struct udevice_id dra7_reset_ids[] = {
+   { .compatible = "ti,dra7-reset" },
+   { }
+};
+
+static int dra7_reset_probe(struct udevice *dev)
+{
+   struct dra7_reset_priv *priv = dev_get_priv(dev);
+
+   priv->rstctrl = dev_read_addr(dev);
+   priv->rstst = priv->rstctrl + 0x4;
+   priv->nreset = dev_read_u32_default(dev, "ti,nresets", 1);
+
+   dev_info(dev, "dra7-reset successfully probed %s\n", dev->name);
+
+   return 0;
+}
+
+U_BOOT_DRIVER(dra7_reset) = {
+   .name = "dra7_reset",
+   .id = UCLASS_RESET,
+   .of_match = dra7_reset_ids,
+   .probe = dra7_reset_probe,
+   .ops = _reset_ops,
+   .priv_auto = sizeof(struct dra7_reset_priv),
+};
-- 
2.25.1



[PATCH v3 01/11] configs: dra7xx_evm: Increase the size of SPL_MULTI_DTB_FIT

2022-01-18 Thread Amjad Ouled-Ameur
Expand SPL_MULTI_DTB_FIT to accommodate new SPL IPU nodes.

Signed-off-by: Amjad Ouled-Ameur 
---

(no changes since v1)

 configs/dra7xx_evm_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configs/dra7xx_evm_defconfig b/configs/dra7xx_evm_defconfig
index d1aa91d676e1..d3a1d3e4d334 100644
--- a/configs/dra7xx_evm_defconfig
+++ b/configs/dra7xx_evm_defconfig
@@ -52,7 +52,7 @@ CONFIG_OF_CONTROL=y
 CONFIG_SPL_OF_CONTROL=y
 CONFIG_OF_LIST="dra7-evm dra72-evm dra72-evm-revc dra71-evm dra76-evm"
 CONFIG_SPL_MULTI_DTB_FIT=y
-CONFIG_SPL_MULTI_DTB_FIT_UNCOMPRESS_SZ=0xA000
+CONFIG_SPL_MULTI_DTB_FIT_UNCOMPRESS_SZ=0x1
 CONFIG_OF_SPL_REMOVE_PROPS="clocks clock-names interrupt-parent"
 CONFIG_ENV_OVERWRITE=y
 # CONFIG_ENV_IS_IN_FAT is not set
-- 
2.25.1



[PATCH v3 00/11] dra7: bring up and support IPU load/start

2022-01-18 Thread Amjad Ouled-Ameur
This patchset enables support for loading and starting IPU firmware,
the following have been implemented:
- Enable fs_loader compilation at SPL Level, that is necessary in order
  to load IPU firmware from /boot partition.
- Define necessary related IPU dts nodes.
- Add necessary drivers and helpers to bring up, load and start IPU
  firmware.

The underlying patches are interdependent, therefore should be applied
in the order they are numbered in this patchset.

Tests:
- Please find SPL, u-boot and kernel console logs in here [1]
- At SPL stage, debug logs have been enabled to make sure that
IPU1 and IPU2 are loaded and started properly. In fact, these two log
messages are only displayed when the firmware has been loaded, and if no
errors appear afterwards, it means that firmware started successfully as
well:
  - Starting IPU1...
  - Starting IPU2...

At U-boot stage, "rproc" command-line tool was used for the testing. In
the logs [1], "rproc list" was run before and after IPU1 and IPU2 are
initialized by "rproc init". The before run gave an empty list, while
the after run listed successfully the two IPUs with their correct
addresses:
  - 0 - Name:'ipu@5882' type:'internal memory mapped'
  - 1 - Name:'ipu@5502' type:'internal memory mapped'

"rproc start" and "rproc stop" were also used for both IPU1 and IPU2,
both were successful as no error logs were displayed.

[0]: https://pastebin.com/QGUYSPRt

These U-boot/SPL flags have been purposely enabled during tests to ensure
IPU load/start work properly:
- CONFIG_DM_RESET=y
- CONFIG_RESET_DRA7=y
- CONFIG_SPL_DM_RESET=y
- CONFIG_FS_LOADER=y
- CONFIG_SPL_FS_LOADER=y
- CONFIG_SPL_DRIVERS_MISC_SUPPORT=y
- CONFIG_REMOTEPROC_TI_IPU=y
- CONFIG_SPL_REMOTEPROC=y
- CONFIG_CMD_REMOTEPROC=y


Changes in v3:
- Add a new patch for dra7xx_evm to expand SPL_MULTI_DTB_FIT

Changes in v2:
- Add useful checks and remove redundant code.

Amjad Ouled-Ameur (1):
  configs: dra7xx_evm: Increase the size of SPL_MULTI_DTB_FIT

Keerthy (10):
  reset: dra7: Add a reset driver
  arm: mach-omap2: load/start remoteproc IPU1/IPU2
  drivers: misc: Makefile: Enable fs_loader compilation at SPL Level
  linux: bitmap.h: Add find_next_zero_area function
  remoteproc: uclass: Add remoteproc resource handling helpers
  remoteproc: ipu: Add driver to bring up ipu
  dts: dra7-ipu-common-early-boot.dtsi: Add all the ipu early boot
related nodes
  arm: dts: dra7: Add ipu and related nodes
  arm: dts: dra7*/am57xx-idk-evm-u-boot: Add ipu early boot DT changes
  dts: am57xx*: Add ipu early boot DT changes

 MAINTAINERS   |   4 +
 .../dts/am57xx-beagle-x15-revb1-u-boot.dtsi   |   7 +
 .../dts/am57xx-beagle-x15-revc-u-boot.dtsi|   7 +
 arch/arm/dts/am57xx-beagle-x15-u-boot.dtsi|   7 +
 arch/arm/dts/am57xx-cl-som-am57x-u-boot.dtsi  |   7 +
 arch/arm/dts/am57xx-idk-common-u-boot.dtsi|   1 +
 arch/arm/dts/am57xx-sbc-am57x-u-boot.dtsi |   7 +
 arch/arm/dts/dra7-evm-u-boot.dtsi |   1 +
 arch/arm/dts/dra7-ipu-common-early-boot.dtsi  | 113 +++
 arch/arm/dts/dra7.dtsi|  45 +-
 arch/arm/dts/dra71-evm-u-boot.dtsi|   1 +
 arch/arm/dts/dra72-evm-revc-u-boot.dtsi   |   1 +
 arch/arm/dts/dra76-evm-u-boot.dtsi|   1 +
 arch/arm/include/asm/arch-omap5/clock.h   |   3 +
 arch/arm/include/asm/omap_common.h|  10 +
 arch/arm/mach-k3/common.c |  10 +-
 arch/arm/mach-omap2/boot-common.c |  95 +++
 arch/arm/mach-omap2/clocks-common.c   |  33 +
 arch/arm/mach-omap2/omap5/hw_data.c   |  92 ++-
 arch/arm/mach-omap2/omap5/prcm-regs.c |   9 +-
 configs/dra7xx_evm_defconfig  |   2 +-
 configs/j721e_evm_r5_defconfig|   1 +
 configs/j721e_hs_evm_r5_defconfig |   1 +
 drivers/misc/Kconfig  |   9 +
 drivers/misc/Makefile |   2 +-
 drivers/remoteproc/Kconfig|  10 +
 drivers/remoteproc/Makefile   |   1 +
 drivers/remoteproc/ipu_rproc.c| 759 ++
 drivers/remoteproc/rproc-uclass.c | 534 
 drivers/reset/Kconfig |   6 +
 drivers/reset/Makefile|   1 +
 drivers/reset/reset-dra7.c|  97 +++
 include/linux/bitmap.h|  26 +
 include/remoteproc.h  | 384 -
 34 files changed, 2269 insertions(+), 18 deletions(-)
 create mode 100644 arch/arm/dts/am57xx-beagle-x15-revb1-u-boot.dtsi
 create mode 100644 arch/arm/dts/am57xx-beagle-x15-revc-u-boot.dtsi
 create mode 100644 arch/arm/dts/am57xx-beagle-x15-u-boot.dtsi
 create mode 100644 arch/arm/dts/am57xx-cl-som-am57x-u-boot.dtsi
 create mode 100644 arch/arm/dts/am57xx-sbc-am57x-u-boot.dtsi
 create mode 100644 arch/arm/dts/dra7-ipu-common-earl

Re: [PATCH v2 07/10] dts: dra7-ipu-common-early-boot.dtsi: Add all the ipu early boot related nodes

2022-01-05 Thread Amjad Ouled-Ameur

Hi Tom,

On 11/10/2021 20:59, Tom Rini wrote:

On Thu, Sep 30, 2021 at 06:21:08PM +0200, Amjad Ouled-Ameur wrote:


From: Keerthy 

Add all the ipu early boot related nodes

Signed-off-by: Keerthy 
Signed-off-by: Amjad Ouled-Ameur 
---

(no changes since v1)

  MAINTAINERS  |   1 +
  arch/arm/dts/dra7-ipu-common-early-boot.dtsi | 113 +++
  2 files changed, 114 insertions(+)
  create mode 100644 arch/arm/dts/dra7-ipu-common-early-boot.dtsi

This causes my J6 Eco board:
CPU  : DRA752-GP ES1.1
Model: TI DRA742
Board: DRA74x EVM REV G.0
to stop booting in SPL with no output.


Thank you for reporting the issue.

After debugging the j6eco board, I realized that board stops booting

in SPL when new nodes with "u-boot,dm-spl;"property are added to the

DTS. The issue seems to be unrelated to this patchset but rather to a

SPL's DTS limitation on j6eco. I am currently looking into SPL's linker 
file


and load addresses to understand better why SPL breaks.


Regards,

Amjad





Re: [PATCH v2] cmd: pxe_utils: sysboot: add label override support

2021-12-13 Thread Amjad Ouled-Ameur

Hi,

Is there any news about this patch please ?

Regards,

Amjad

On 25/11/2021 01:12, Simon Glass wrote:

Hi Amjad,

On Sat, 13 Nov 2021 at 06:09, Amjad Ouled-Ameur
 wrote:

This will allow consumers to choose a pxe label at runtime instead of
having to prompt the user. One good use-case for this, is choosing
whether or not to apply a dtbo depending on the hardware configuration.
e.g: for TI's AM335x EVM, it would be convenient to apply a particular
dtbo only when the J9 jumper is on PRUSS mode. To achieve this, the
pxe menu should have 2 labels, one with the dtbo and the other without,
then the "pxe_label_override" env variable should point to the label with
the dtbo at runtime only when the jumper is on PRUSS mode.

This change can be used for different use-cases and bring more
flexibilty to consumers who use sysboot/pxe_utils.

if "pxe_label_override" is set but does not exist in the pxe menu,
the code should fallback to the default label if given, and no failure
is returned but rather a warning message.


Signed-off-by: Amjad Ouled-Ameur 
---

Changes in v2:
- Use !strcmp() instead of strcmp()==0
- Add "pxe_label_override" documentation

  boot/pxe_utils.c | 15 +++
  doc/README.pxe   |  6 ++
  2 files changed, 21 insertions(+)

Reviewed-by: Simon Glass 

Can I suggest converting the doc to rST?

Regards,
Simon


[PATCH] configs: am43xx_hs_evm: Add SPL_USB_STORAGE Support

2021-12-06 Thread Amjad Ouled-Ameur
Enable CONFIG_SPL_USB_STORAGE to support UBS MSC boot support.

Signed-off-by: Faiz Abbas 
Signed-off-by: Amjad Ouled-Ameur 
---

 configs/am43xx_hs_evm_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/am43xx_hs_evm_defconfig b/configs/am43xx_hs_evm_defconfig
index 3ff2e5b62204..d4bebd2c01e9 100644
--- a/configs/am43xx_hs_evm_defconfig
+++ b/configs/am43xx_hs_evm_defconfig
@@ -33,6 +33,7 @@ CONFIG_SPL_NAND_BASE=y
 CONFIG_SPL_NET=y
 CONFIG_SPL_NET_VCI_STRING="AM43xx U-Boot SPL"
 CONFIG_SPL_USB_HOST=y
+CONFIG_SPL_USB_STORAGE=y
 CONFIG_SPL_USB_GADGET=y
 CONFIG_SPL_USB_ETHER=y
 CONFIG_SYS_I2C_EEPROM_ADDR_LEN=2
-- 
2.25.1



[PATCH v2] cmd: pxe_utils: sysboot: add label override support

2021-11-13 Thread Amjad Ouled-Ameur
This will allow consumers to choose a pxe label at runtime instead of
having to prompt the user. One good use-case for this, is choosing
whether or not to apply a dtbo depending on the hardware configuration.
e.g: for TI's AM335x EVM, it would be convenient to apply a particular
dtbo only when the J9 jumper is on PRUSS mode. To achieve this, the
pxe menu should have 2 labels, one with the dtbo and the other without,
then the "pxe_label_override" env variable should point to the label with
the dtbo at runtime only when the jumper is on PRUSS mode.

This change can be used for different use-cases and bring more
flexibilty to consumers who use sysboot/pxe_utils.

if "pxe_label_override" is set but does not exist in the pxe menu,
the code should fallback to the default label if given, and no failure
is returned but rather a warning message.


Signed-off-by: Amjad Ouled-Ameur 
---

Changes in v2:
- Use !strcmp() instead of strcmp()==0
- Add "pxe_label_override" documentation

 boot/pxe_utils.c | 15 +++
 doc/README.pxe   |  6 ++
 2 files changed, 21 insertions(+)

diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c
index a7a84f26c1d5..defc806fdc4f 100644
--- a/boot/pxe_utils.c
+++ b/boot/pxe_utils.c
@@ -1349,9 +1349,11 @@ static struct menu *pxe_menu_to_menu(struct pxe_menu 
*cfg)
struct pxe_label *label;
struct list_head *pos;
struct menu *m;
+   char *label_override;
int err;
int i = 1;
char *default_num = NULL;
+   char *override_num = NULL;
 
/*
 * Create a menu and add items for all the labels.
@@ -1361,6 +1363,8 @@ static struct menu *pxe_menu_to_menu(struct pxe_menu *cfg)
if (!m)
return NULL;
 
+   label_override = env_get("pxe_label_override");
+
list_for_each(pos, >labels) {
label = list_entry(pos, struct pxe_label, list);
 
@@ -1372,6 +1376,17 @@ static struct menu *pxe_menu_to_menu(struct pxe_menu 
*cfg)
if (cfg->default_label &&
(strcmp(label->name, cfg->default_label) == 0))
default_num = label->num;
+   if (label_override && !strcmp(label->name, label_override))
+   override_num = label->num;
+   }
+
+
+   if (label_override) {
+   if (override_num)
+   default_num = override_num;
+   else
+   printf("Missing override pxe label: %s\n",
+ label_override);
}
 
/*
diff --git a/doc/README.pxe b/doc/README.pxe
index b67151ca510e..a1f0423adbec 100644
--- a/doc/README.pxe
+++ b/doc/README.pxe
@@ -92,6 +92,12 @@ pxe boot
  fdtoverlay_addr_r - location in RAM at which 'pxe boot' will temporarily 
store
  fdt overlay(s) before applying them to the fdt blob stored at 
'fdt_addr_r'.
 
+ pxe_label_override - override label to be used, if exists, instead of the
+ default label. This will allow consumers to choose a pxe label at
+ runtime instead of having to prompt the user. If "pxe_label_override" is 
set
+ but does not exist in the pxe menu, pxe would fallback to the default 
label if
+ given, and no failure is returned but rather a warning message.
+
 pxe file format
 ===
 The pxe file format is nearly a subset of the PXELINUX file format; see
-- 
2.25.1



Re: [PATCH] cmd: pxe_utils: sysboot: add label override support

2021-11-12 Thread Amjad Ouled-Ameur

Hi Simon,

On 06/11/2021 01:18, Amjad Ouled-Ameur wrote:

Hi Simon,

On 05/11/2021 03:02, Simon Glass wrote:

Hi Amjad,

On Fri, 22 Oct 2021 at 09:55, Amjad Ouled-Ameur
 wrote:

This will allow consumers to choose a pxe label at runtime instead of
having to prompt the user. One good use-case for this, is choosing
whether or not to apply a dtbo depending on the hardware configuration.
e.g: for TI's AM335x EVM, it would be convenient to apply a particular
dtbo only when the J9 jumper is on PRUSS mode. To achieve this, the
pxe menu should have 2 labels, one with the dtbo and the other without,
then the "pxe_label_override" env variable should point to the label 
with

the dtbo at runtime only when the jumper is on PRUSS mode.

This change can be used for different use-cases and bring more
flexibilty to consumers who use sysboot/pxe_utils.

if "pxe_label_override" is set but does not exist in the pxe menu,
the code should fallback to the default label if given, and no failure
is returned but rather a warning message.

Signed-off-by: Amjad Ouled-Ameur 

---

  cmd/pxe_utils.c | 15 +++
  1 file changed, 15 insertions(+)

Can we add this to the docs somewhere?


This would be great, I think doc/README.pxe is the best place for it.

Will send a V2 with the doc change, thank you for the suggestion.


Regards,

Amjad


diff --git a/cmd/pxe_utils.c b/cmd/pxe_utils.c
index 067c24e5ff4b..b1009f9c7547 100644
--- a/cmd/pxe_utils.c
+++ b/cmd/pxe_utils.c
@@ -1354,9 +1354,11 @@ static struct menu *pxe_menu_to_menu(struct 
pxe_menu *cfg)

 struct pxe_label *label;
 struct list_head *pos;
 struct menu *m;
+   char *label_override;
 int err;
 int i = 1;
 char *default_num = NULL;
+   char *override_num = NULL;

 /*
  * Create a menu and add items for all the labels.
@@ -1367,6 +1369,8 @@ static struct menu *pxe_menu_to_menu(struct 
pxe_menu *cfg)

 if (!m)
 return NULL;

+   label_override = env_get("pxe_label_override");
+
 list_for_each(pos, >labels) {
 label = list_entry(pos, struct pxe_label, list);

@@ -1375,11 +1379,22 @@ static struct menu *pxe_menu_to_menu(struct 
pxe_menu *cfg)

 menu_destroy(m);
 return NULL;
 }
+   if (label_override &&
+   (strcmp(label->name, label_override) == 0))

!strcmp()


Why !strcmp() and not strcmp() ?


Regards,

Amjad


+   override_num = label->num;
 if (cfg->default_label &&
 (strcmp(label->name, cfg->default_label) == 0))
 default_num = label->num;
 }

+   if (label_override) {
+   if (override_num)
+   default_num = override_num;
+   else
+   printf("Missing override pxe label: %s\n",
+   label_override);
+   }
+
 /*
  * After we've created items for each label in the menu, 
set the

  * menu's default label if one was specified.
--
2.25.1


Regards,
Simon


Re: [PATCH] cmd: pxe_utils: sysboot: add label override support

2021-11-05 Thread Amjad Ouled-Ameur

Hi Simon,

On 05/11/2021 03:02, Simon Glass wrote:

Hi Amjad,

On Fri, 22 Oct 2021 at 09:55, Amjad Ouled-Ameur
 wrote:

This will allow consumers to choose a pxe label at runtime instead of
having to prompt the user. One good use-case for this, is choosing
whether or not to apply a dtbo depending on the hardware configuration.
e.g: for TI's AM335x EVM, it would be convenient to apply a particular
dtbo only when the J9 jumper is on PRUSS mode. To achieve this, the
pxe menu should have 2 labels, one with the dtbo and the other without,
then the "pxe_label_override" env variable should point to the label with
the dtbo at runtime only when the jumper is on PRUSS mode.

This change can be used for different use-cases and bring more
flexibilty to consumers who use sysboot/pxe_utils.

if "pxe_label_override" is set but does not exist in the pxe menu,
the code should fallback to the default label if given, and no failure
is returned but rather a warning message.

Signed-off-by: Amjad Ouled-Ameur 

---

  cmd/pxe_utils.c | 15 +++
  1 file changed, 15 insertions(+)

Can we add this to the docs somewhere?


This would be great, I think doc/README.pxe is the best place for it.

Will send a V2 with the doc change, thank you for the suggestion.


Regards,

Amjad


diff --git a/cmd/pxe_utils.c b/cmd/pxe_utils.c
index 067c24e5ff4b..b1009f9c7547 100644
--- a/cmd/pxe_utils.c
+++ b/cmd/pxe_utils.c
@@ -1354,9 +1354,11 @@ static struct menu *pxe_menu_to_menu(struct pxe_menu 
*cfg)
 struct pxe_label *label;
 struct list_head *pos;
 struct menu *m;
+   char *label_override;
 int err;
 int i = 1;
 char *default_num = NULL;
+   char *override_num = NULL;

 /*
  * Create a menu and add items for all the labels.
@@ -1367,6 +1369,8 @@ static struct menu *pxe_menu_to_menu(struct pxe_menu *cfg)
 if (!m)
 return NULL;

+   label_override = env_get("pxe_label_override");
+
 list_for_each(pos, >labels) {
 label = list_entry(pos, struct pxe_label, list);

@@ -1375,11 +1379,22 @@ static struct menu *pxe_menu_to_menu(struct pxe_menu 
*cfg)
 menu_destroy(m);
 return NULL;
 }
+   if (label_override &&
+   (strcmp(label->name, label_override) == 0))

!strcmp()


+   override_num = label->num;
 if (cfg->default_label &&
 (strcmp(label->name, cfg->default_label) == 0))
 default_num = label->num;
 }

+   if (label_override) {
+   if (override_num)
+   default_num = override_num;
+   else
+   printf("Missing override pxe label: %s\n",
+   label_override);
+   }
+
 /*
  * After we've created items for each label in the menu, set the
  * menu's default label if one was specified.
--
2.25.1


Regards,
Simon


[PATCH] board: ti: am335x: Choose CPSW or PRUSS configuration based on jumper setting

2021-10-29 Thread Amjad Ouled-Ameur
The am335x-ice-v2 board's Ethernet ports can be configured
in 'MII' or 'RMII' mode to be connected to 'PRUSS' or 'CPSW'
Ethernet subsystems.

This patch sets the environment variable 'ice_mii' to
'mii' or 'rmii' accordingly. Based on that we choose the
appropriate board devicetree i.e. 'am335x-ice-v2.dtb' or
'am335x-ice-v2-prueth.dtb'.

Since there are 2 Ethernet ports with 2 modes, there can be 4
configurations but for now we consider both ports in different modes
to be an invalid configuration and prevent boot in that case.

Signed-off-by: Roger Quadros 
[Amjad: use overlay instead of using new am335x-ice-v2-prueth.dtb]
Signed-off-by: Amjad Ouled-Ameur 


---
This depends on the currently in-review patch [0].

[0]: 20211022155526.54368-1-aouledam...@baylibre.com

 board/ti/am335x/board.c   | 17 +
 include/configs/am335x_evm.h  |  5 -
 include/configs/ti_armv7_common.h |  1 +
 3 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/board/ti/am335x/board.c b/board/ti/am335x/board.c
index e8555de9c937..b50e7a0fa466 100644
--- a/board/ti/am335x/board.c
+++ b/board/ti/am335x/board.c
@@ -11,6 +11,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -691,6 +692,8 @@ done:
 }
 #endif
 
+static bool prueth_is_mii = true;
+
 /*
  * Basic board specific setup.  Pinmux has been handled already.
  */
@@ -710,6 +713,8 @@ int board_init(void)
if (board_is_icev2()) {
int rv;
u32 reg;
+   bool eth0_is_mii = true;
+   bool eth1_is_mii = true;
 
REQUEST_AND_SET_GPIO(GPIO_PR1_MII_CTRL);
/* Make J19 status available on GPIO1_26 */
@@ -740,6 +745,7 @@ int board_init(void)
writel(reg, GPIO0_IRQSTATUS1); /* clear irq */
/* RMII mode */
printf("ETH0, CPSW\n");
+   eth0_is_mii = false;
} else {
/* MII mode */
printf("ETH0, PRU\n");
@@ -752,12 +758,21 @@ int board_init(void)
/* RMII mode */
printf("ETH1, CPSW\n");
gpio_set_value(GPIO_MUX_MII_CTRL, 1);
+   eth1_is_mii = false;
} else {
/* MII mode */
printf("ETH1, PRU\n");
cdce913_data.pdiv2 = 4; /* 25MHz PHY clk */
}
 
+   if (eth0_is_mii != eth1_is_mii) {
+   printf("Unsupported Ethernet port configuration\n");
+   printf("Both ports must be set as RMII or MII\n");
+   hang();
+   }
+
+   prueth_is_mii = eth0_is_mii;
+
/* disable rising edge IRQs */
reg = readl(GPIO0_RISINGDETECT) & ~BIT(11);
writel(reg, GPIO0_RISINGDETECT);
@@ -852,6 +867,8 @@ int board_late_init(void)
if (is_valid_ethaddr(mac_addr))
eth_env_set_enetaddr("eth1addr", mac_addr);
}
+
+   env_set("ice_mii", prueth_is_mii ? "mii" : "rmii");
 #endif
 
if (!env_get("serial#")) {
diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h
index 7fb1b3a3e3fa..0f340806efc9 100644
--- a/include/configs/am335x_evm.h
+++ b/include/configs/am335x_evm.h
@@ -143,7 +143,10 @@
"if test $board_name = A335X_SK; then " \
"setenv fdtfile am335x-evmsk.dtb; fi; " \
"if test $board_name = A335_ICE; then " \
-   "setenv fdtfile am335x-icev2.dtb; fi; " \
+   "setenv fdtfile am335x-icev2.dtb; " \
+   "if test $ice_mii = mii; then " \
+   "setenv pxe_label_override Pruss; fi;" \
+   "fi; " \
"if test $fdtfile = undefined; then " \
"echo WARNING: Could not determine device tree to use; 
fi; \0" \
"init_console=" \
diff --git a/include/configs/ti_armv7_common.h 
b/include/configs/ti_armv7_common.h
index fa48cd2818ce..797e1211980d 100644
--- a/include/configs/ti_armv7_common.h
+++ b/include/configs/ti_armv7_common.h
@@ -37,6 +37,7 @@
"fdtaddr=0x8800\0" \
"dtboaddr=0x8900\0" \
"fdt_addr_r=0x8800\0" \
+   "fdtoverlay_addr_r=0x8900\0" \
"rdaddr=0x8808\0" \
"ramdisk_addr_r=0x8808\0" \
"scriptaddr=0x8000\0" \
-- 
2.25.1



[PATCH] cmd: pxe_utils: sysboot: add label override support

2021-10-22 Thread Amjad Ouled-Ameur
This will allow consumers to choose a pxe label at runtime instead of
having to prompt the user. One good use-case for this, is choosing
whether or not to apply a dtbo depending on the hardware configuration.
e.g: for TI's AM335x EVM, it would be convenient to apply a particular
dtbo only when the J9 jumper is on PRUSS mode. To achieve this, the
pxe menu should have 2 labels, one with the dtbo and the other without,
then the "pxe_label_override" env variable should point to the label with
the dtbo at runtime only when the jumper is on PRUSS mode.

This change can be used for different use-cases and bring more
flexibilty to consumers who use sysboot/pxe_utils.

if "pxe_label_override" is set but does not exist in the pxe menu,
the code should fallback to the default label if given, and no failure
is returned but rather a warning message.

Signed-off-by: Amjad Ouled-Ameur 

---

 cmd/pxe_utils.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/cmd/pxe_utils.c b/cmd/pxe_utils.c
index 067c24e5ff4b..b1009f9c7547 100644
--- a/cmd/pxe_utils.c
+++ b/cmd/pxe_utils.c
@@ -1354,9 +1354,11 @@ static struct menu *pxe_menu_to_menu(struct pxe_menu 
*cfg)
struct pxe_label *label;
struct list_head *pos;
struct menu *m;
+   char *label_override;
int err;
int i = 1;
char *default_num = NULL;
+   char *override_num = NULL;
 
/*
 * Create a menu and add items for all the labels.
@@ -1367,6 +1369,8 @@ static struct menu *pxe_menu_to_menu(struct pxe_menu *cfg)
if (!m)
return NULL;
 
+   label_override = env_get("pxe_label_override");
+
list_for_each(pos, >labels) {
label = list_entry(pos, struct pxe_label, list);
 
@@ -1375,11 +1379,22 @@ static struct menu *pxe_menu_to_menu(struct pxe_menu 
*cfg)
menu_destroy(m);
return NULL;
}
+   if (label_override &&
+   (strcmp(label->name, label_override) == 0))
+   override_num = label->num;
if (cfg->default_label &&
(strcmp(label->name, cfg->default_label) == 0))
default_num = label->num;
}
 
+   if (label_override) {
+   if (override_num)
+   default_num = override_num;
+   else
+   printf("Missing override pxe label: %s\n",
+   label_override);
+   }
+
/*
 * After we've created items for each label in the menu, set the
 * menu's default label if one was specified.
-- 
2.25.1



[PATCH] configs: am335x_evm: enable CONFIG_CLK_TI_CTRL

2021-10-11 Thread Amjad Ouled-Ameur
This enables the clock controller driver support on TI's SoCs. This will
fix this GPIO issue at boot time:
request_and_set_gpio: Unable to request GPIO_PR1_MII_CTRL
request_and_set_gpio: Unable to request GPIO_MUX_MII_CTRL
request_and_set_gpio: Unable to request GPIO_FET_SWITCH_CTRL
request_and_set_gpio: Unable to request GPIO_PHY_RESET

This issue comes from the fact that the clock controller is not probed.

Enable the TI's clock controller driver support to solve this.

Signed-off-by: Amjad Ouled-Ameur 

---

 configs/am335x_evm_defconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configs/am335x_evm_defconfig b/configs/am335x_evm_defconfig
index 0f938e7de35c..4dc5d0fe347a 100644
--- a/configs/am335x_evm_defconfig
+++ b/configs/am335x_evm_defconfig
@@ -48,6 +48,7 @@ CONFIG_BOOTP_SEND_HOSTNAME=y
 CONFIG_BOOTCOUNT_LIMIT=y
 CONFIG_CLK=y
 CONFIG_CLK_CDCE9XX=y
+CONFIG_CLK_TI_CTRL=y
 CONFIG_DFU_TFTP=y
 CONFIG_DFU_MMC=y
 CONFIG_DFU_NAND=y
-- 
2.25.1



[PATCH v2 05/10] remoteproc: uclass: Add remoteproc resource handling helpers

2021-09-30 Thread Amjad Ouled-Ameur
From: Keerthy 

Add remoteproc resource handling helpers. These functions
are primarily to parse the resource table and to handle
different types of resources. Carveout, devmem, trace &
vring resources are handled.

Signed-off-by: Keerthy 
[Amjad: fix redefinition of "struct resource_table" and compile warnings ]
Signed-off-by: Amjad Ouled-Ameur 

---

Changes in v2:
- Add useful checks and remove redundant code.

 drivers/remoteproc/rproc-uclass.c | 532 ++
 include/remoteproc.h  | 384 -
 2 files changed, 915 insertions(+), 1 deletion(-)

diff --git a/drivers/remoteproc/rproc-uclass.c 
b/drivers/remoteproc/rproc-uclass.c
index 64c47c1e7225..6adff1f7d877 100644
--- a/drivers/remoteproc/rproc-uclass.c
+++ b/drivers/remoteproc/rproc-uclass.c
@@ -8,10 +8,12 @@
 
 #define pr_fmt(fmt) "%s: " fmt, __func__
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -19,9 +21,21 @@
 #include 
 #include 
 #include 
+#include 
 
 DECLARE_GLOBAL_DATA_PTR;
 
+struct resource_table {
+   u32 ver;
+   u32 num;
+   u32 reserved[2];
+   u32 offset[0];
+} __packed;
+
+typedef int (*handle_resource_t) (struct udevice *, void *, int offset, int 
avail);
+
+static struct resource_table *rsc_table;
+
 /**
  * for_each_remoteproc_device() - iterate through the list of rproc devices
  * @fn: check function to call per match, if this function returns fail,
@@ -208,6 +222,80 @@ static int rproc_post_probe(struct udevice *dev)
return 0;
 }
 
+/**
+ * rproc_add_res() - After parsing the resource table add the mappings
+ * @dev:   device we finished probing
+ * @mapping: rproc_mem_entry for the resource
+ *
+ * Return: if the remote proc driver has a add_res routine, invokes it and
+ * hands over the return value. overall, 0 if all went well, else appropriate
+ * error value.
+ */
+static int rproc_add_res(struct udevice *dev, struct rproc_mem_entry *mapping)
+{
+   const struct dm_rproc_ops *ops = rproc_get_ops(dev);
+
+   if (!ops->add_res)
+   return -ENOSYS;
+
+   return ops->add_res(dev, mapping);
+}
+
+/**
+ * rproc_alloc_mem() - After parsing the resource table allocat mem
+ * @dev:   device we finished probing
+ * @len: rproc_mem_entry for the resource
+ * @align: alignment for the resource
+ *
+ * Return: if the remote proc driver has a add_res routine, invokes it and
+ * hands over the return value. overall, 0 if all went well, else appropriate
+ * error value.
+ */
+static void *rproc_alloc_mem(struct udevice *dev, unsigned long len,
+unsigned long align)
+{
+   const struct dm_rproc_ops *ops;
+
+   ops = rproc_get_ops(dev);
+   if (!ops) {
+   debug("%s driver has no ops?\n", dev->name);
+   return NULL;
+   }
+
+   if (ops->alloc_mem)
+   return ops->alloc_mem(dev, len, align);
+
+   return NULL;
+}
+
+/**
+ * rproc_config_pagetable() - Configure page table for remote processor
+ * @dev:   device we finished probing
+ * @virt: Virtual address of the resource
+ * @phys: Physical address the resource
+ * @len: length the resource
+ *
+ * Return: if the remote proc driver has a add_res routine, invokes it and
+ * hands over the return value. overall, 0 if all went well, else appropriate
+ * error value.
+ */
+static int rproc_config_pagetable(struct udevice *dev, unsigned int virt,
+ unsigned int phys, unsigned int len)
+{
+   const struct dm_rproc_ops *ops;
+
+   ops = rproc_get_ops(dev);
+   if (!ops) {
+   debug("%s driver has no ops?\n", dev->name);
+   return -EINVAL;
+   }
+
+   if (ops->config_pagetable)
+   return ops->config_pagetable(dev, virt, phys, len);
+
+   return 0;
+}
+
 UCLASS_DRIVER(rproc) = {
.id = UCLASS_REMOTEPROC,
.name = "remoteproc",
@@ -438,3 +526,447 @@ int rproc_is_running(int id)
 {
return _rproc_ops_wrapper(id, RPROC_RUNNING);
 };
+
+
+static int handle_trace(struct udevice *dev, struct fw_rsc_trace *rsc,
+   int offset, int avail)
+{
+   if (sizeof(*rsc) > avail) {
+   debug("trace rsc is truncated\n");
+   return -EINVAL;
+   }
+
+   /*
+* make sure reserved bytes are zeroes
+*/
+   if (rsc->reserved) {
+   debug("trace rsc has non zero reserved bytes\n");
+   return -EINVAL;
+   }
+
+   debug("trace rsc: da 0x%x, len 0x%x\n", rsc->da, rsc->len);
+
+   return 0;
+}
+
+static int handle_devmem(struct udevice *dev, struct fw_rsc_devmem *rsc,
+int offset, int avail)
+{
+   struct rproc_mem_entry *mapping;
+
+   if (sizeof(*rsc) > avail) {
+   deb

[PATCH v2 10/10] dts: am57xx*: Add ipu early boot DT changes

2021-09-30 Thread Amjad Ouled-Ameur
From: Keerthy 

Add support for ipu early boot.

Signed-off-by: Keerthy 
Signed-off-by: Amjad Ouled-Ameur 

---

(no changes since v1)

 MAINTAINERS  | 1 +
 arch/arm/dts/am57xx-beagle-x15-revb1-u-boot.dtsi | 7 +++
 arch/arm/dts/am57xx-beagle-x15-revc-u-boot.dtsi  | 7 +++
 arch/arm/dts/am57xx-beagle-x15-u-boot.dtsi   | 7 +++
 arch/arm/dts/am57xx-cl-som-am57x-u-boot.dtsi | 7 +++
 arch/arm/dts/am57xx-sbc-am57x-u-boot.dtsi| 7 +++
 6 files changed, 36 insertions(+)
 create mode 100644 arch/arm/dts/am57xx-beagle-x15-revb1-u-boot.dtsi
 create mode 100644 arch/arm/dts/am57xx-beagle-x15-revc-u-boot.dtsi
 create mode 100644 arch/arm/dts/am57xx-beagle-x15-u-boot.dtsi
 create mode 100644 arch/arm/dts/am57xx-cl-som-am57x-u-boot.dtsi
 create mode 100644 arch/arm/dts/am57xx-sbc-am57x-u-boot.dtsi

diff --git a/MAINTAINERS b/MAINTAINERS
index ffaf2015ca5f..13c6c6e65915 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -493,6 +493,7 @@ F:  arch/arm/mach-omap2/
 F: arch/arm/include/asm/arch-omap*/
 F: arch/arm/include/asm/ti-common/
 F: arch/arm/dts/dra7*
+F: arch/arm/dts/am57xx*
 F: board/ti/
 F: drivers/dma/ti*
 F: drivers/firmware/ti_sci.*
diff --git a/arch/arm/dts/am57xx-beagle-x15-revb1-u-boot.dtsi 
b/arch/arm/dts/am57xx-beagle-x15-revb1-u-boot.dtsi
new file mode 100644
index ..49b16215e528
--- /dev/null
+++ b/arch/arm/dts/am57xx-beagle-x15-revb1-u-boot.dtsi
@@ -0,0 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
+ */
+
+#include "omap5-u-boot.dtsi"
+#include "dra7-ipu-common-early-boot.dtsi"
diff --git a/arch/arm/dts/am57xx-beagle-x15-revc-u-boot.dtsi 
b/arch/arm/dts/am57xx-beagle-x15-revc-u-boot.dtsi
new file mode 100644
index ..49b16215e528
--- /dev/null
+++ b/arch/arm/dts/am57xx-beagle-x15-revc-u-boot.dtsi
@@ -0,0 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
+ */
+
+#include "omap5-u-boot.dtsi"
+#include "dra7-ipu-common-early-boot.dtsi"
diff --git a/arch/arm/dts/am57xx-beagle-x15-u-boot.dtsi 
b/arch/arm/dts/am57xx-beagle-x15-u-boot.dtsi
new file mode 100644
index ..49b16215e528
--- /dev/null
+++ b/arch/arm/dts/am57xx-beagle-x15-u-boot.dtsi
@@ -0,0 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
+ */
+
+#include "omap5-u-boot.dtsi"
+#include "dra7-ipu-common-early-boot.dtsi"
diff --git a/arch/arm/dts/am57xx-cl-som-am57x-u-boot.dtsi 
b/arch/arm/dts/am57xx-cl-som-am57x-u-boot.dtsi
new file mode 100644
index ..49b16215e528
--- /dev/null
+++ b/arch/arm/dts/am57xx-cl-som-am57x-u-boot.dtsi
@@ -0,0 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
+ */
+
+#include "omap5-u-boot.dtsi"
+#include "dra7-ipu-common-early-boot.dtsi"
diff --git a/arch/arm/dts/am57xx-sbc-am57x-u-boot.dtsi 
b/arch/arm/dts/am57xx-sbc-am57x-u-boot.dtsi
new file mode 100644
index ..49b16215e528
--- /dev/null
+++ b/arch/arm/dts/am57xx-sbc-am57x-u-boot.dtsi
@@ -0,0 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
+ */
+
+#include "omap5-u-boot.dtsi"
+#include "dra7-ipu-common-early-boot.dtsi"
-- 
2.25.1



[PATCH v2 09/10] arm: dts: dra7*/am57xx-idk-evm-u-boot: Add ipu early boot DT changes

2021-09-30 Thread Amjad Ouled-Ameur
From: Keerthy 

Add support for ipu early boot.

Signed-off-by: Keerthy 
Signed-off-by: Amjad Ouled-Ameur 
---

(no changes since v1)

 arch/arm/dts/am57xx-idk-common-u-boot.dtsi | 1 +
 arch/arm/dts/dra7-evm-u-boot.dtsi  | 1 +
 arch/arm/dts/dra71-evm-u-boot.dtsi | 1 +
 arch/arm/dts/dra72-evm-revc-u-boot.dtsi| 1 +
 arch/arm/dts/dra76-evm-u-boot.dtsi | 1 +
 5 files changed, 5 insertions(+)

diff --git a/arch/arm/dts/am57xx-idk-common-u-boot.dtsi 
b/arch/arm/dts/am57xx-idk-common-u-boot.dtsi
index b07aea0048d5..d0ce469f9189 100644
--- a/arch/arm/dts/am57xx-idk-common-u-boot.dtsi
+++ b/arch/arm/dts/am57xx-idk-common-u-boot.dtsi
@@ -3,6 +3,7 @@
  * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
  */
 #include "omap5-u-boot.dtsi"
+#include "dra7-ipu-common-early-boot.dtsi"
 
 / {
xtal25mhz: xtal25mhz {
diff --git a/arch/arm/dts/dra7-evm-u-boot.dtsi 
b/arch/arm/dts/dra7-evm-u-boot.dtsi
index f06c701dbd1f..5622512b2401 100644
--- a/arch/arm/dts/dra7-evm-u-boot.dtsi
+++ b/arch/arm/dts/dra7-evm-u-boot.dtsi
@@ -4,6 +4,7 @@
  */
 
 #include "omap5-u-boot.dtsi"
+#include "dra7-ipu-common-early-boot.dtsi"
 
 _gpio_21{
u-boot,i2c-offset-len = <0>;
diff --git a/arch/arm/dts/dra71-evm-u-boot.dtsi 
b/arch/arm/dts/dra71-evm-u-boot.dtsi
index b56d4fc9d896..40443da5c855 100644
--- a/arch/arm/dts/dra71-evm-u-boot.dtsi
+++ b/arch/arm/dts/dra71-evm-u-boot.dtsi
@@ -4,6 +4,7 @@
  */
 
 #include "omap5-u-boot.dtsi"
+#include "dra7-ipu-common-early-boot.dtsi"
 
 _gpio_21{
u-boot,i2c-offset-len = <0>;
diff --git a/arch/arm/dts/dra72-evm-revc-u-boot.dtsi 
b/arch/arm/dts/dra72-evm-revc-u-boot.dtsi
index b56d4fc9d896..40443da5c855 100644
--- a/arch/arm/dts/dra72-evm-revc-u-boot.dtsi
+++ b/arch/arm/dts/dra72-evm-revc-u-boot.dtsi
@@ -4,6 +4,7 @@
  */
 
 #include "omap5-u-boot.dtsi"
+#include "dra7-ipu-common-early-boot.dtsi"
 
 _gpio_21{
u-boot,i2c-offset-len = <0>;
diff --git a/arch/arm/dts/dra76-evm-u-boot.dtsi 
b/arch/arm/dts/dra76-evm-u-boot.dtsi
index a4dfbe7e601a..5fae6ba91936 100644
--- a/arch/arm/dts/dra76-evm-u-boot.dtsi
+++ b/arch/arm/dts/dra76-evm-u-boot.dtsi
@@ -4,6 +4,7 @@
  */
 
 #include "omap5-u-boot.dtsi"
+#include "dra7-ipu-common-early-boot.dtsi"
 
 _emac0 {
phy-handle = <_0>;
-- 
2.25.1



[PATCH v2 06/10] remoteproc: ipu: Add driver to bring up ipu

2021-09-30 Thread Amjad Ouled-Ameur
From: Keerthy 

The driver enables IPU support. Basically enables the clocks,
timers, watchdog timers and bare minimal MMU and supports
loading the firmware from mmc.

Signed-off-by: Keerthy 
[Amjad: fix compile warnings]
Signed-off-by: Amjad Ouled-Ameur 
---

(no changes since v1)

 MAINTAINERS|   1 +
 drivers/remoteproc/Kconfig |  10 +
 drivers/remoteproc/Makefile|   1 +
 drivers/remoteproc/ipu_rproc.c | 759 +
 4 files changed, 771 insertions(+)
 create mode 100644 drivers/remoteproc/ipu_rproc.c

diff --git a/MAINTAINERS b/MAINTAINERS
index ec586ec5466f..f7ec528af73a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -508,6 +508,7 @@ F:  drivers/ram/k3*
 F: drivers/remoteproc/k3_system_controller.c
 F: drivers/remoteproc/pruc_rpoc.c
 F: drivers/remoteproc/ti*
+F: drivers/remoteproc/ipu_rproc.c
 F: drivers/reset/reset-ti-sci.c
 F: drivers/reset/reset-dra7.c
 F: drivers/rtc/davinci.c
diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
index 24e536463bbd..27e4a60ff5b1 100644
--- a/drivers/remoteproc/Kconfig
+++ b/drivers/remoteproc/Kconfig
@@ -92,4 +92,14 @@ config REMOTEPROC_TI_PRU
help
  Say 'y' here to add support for TI' K3 remoteproc driver.
 
+config REMOTEPROC_TI_IPU
+   bool "Support for TI's K3 based IPU remoteproc driver"
+   select REMOTEPROC
+   depends on DM
+   depends on SPL_DRIVERS_MISC
+   depends on SPL_FS_LOADER
+   depends on OF_CONTROL
+   help
+ Say 'y' here to add support for TI' K3 remoteproc driver.
+
 endmenu
diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile
index f0e83451d66f..fbe9c172bc04 100644
--- a/drivers/remoteproc/Makefile
+++ b/drivers/remoteproc/Makefile
@@ -15,3 +15,4 @@ obj-$(CONFIG_REMOTEPROC_TI_K3_DSP) += ti_k3_dsp_rproc.o
 obj-$(CONFIG_REMOTEPROC_TI_K3_R5F) += ti_k3_r5f_rproc.o
 obj-$(CONFIG_REMOTEPROC_TI_POWER) += ti_power_proc.o
 obj-$(CONFIG_REMOTEPROC_TI_PRU) += pru_rproc.o
+obj-$(CONFIG_REMOTEPROC_TI_IPU) += ipu_rproc.o
diff --git a/drivers/remoteproc/ipu_rproc.c b/drivers/remoteproc/ipu_rproc.c
new file mode 100644
index ..b4a06bc955a9
--- /dev/null
+++ b/drivers/remoteproc/ipu_rproc.c
@@ -0,0 +1,759 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * IPU remoteproc driver for various SoCs
+ *
+ * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
+ * Angela Stegmaier  
+ * Venkateswara Rao Mandela 
+ *  Keerthy 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define IPU1_LOAD_ADDR (0xa17ff000)
+#define MAX_REMOTECORE_BIN_SIZE (8 * 0x10)
+
+enum ipu_num {
+   IPU1 = 0,
+   IPU2,
+   RPROC_END_ENUMS,
+};
+
+#define IPU2_LOAD_ADDR (IPU1_LOAD_ADDR + MAX_REMOTECORE_BIN_SIZE)
+
+#define PAGE_SHIFT 12
+#define PAGESIZE_1M  0x0
+#define PAGESIZE_64K 0x1
+#define PAGESIZE_4K  0x2
+#define PAGESIZE_16M 0x3
+#define LE   0
+#define BE   1
+#define ELEMSIZE_8   0x0
+#define ELEMSIZE_16  0x1
+#define ELEMSIZE_32  0x2
+#define MIXED_TLB0x0
+#define MIXED_CPU0x1
+
+#define PGT_SMALLPAGE_SIZE   0x1000
+#define PGT_LARGEPAGE_SIZE   0x0001
+#define PGT_SECTION_SIZE 0x0010
+#define PGT_SUPERSECTION_SIZE0x0100
+
+#define PGT_L1_DESC_PAGE 0x1
+#define PGT_L1_DESC_SECTION  0x2
+#define PGT_L1_DESC_SUPERSECTION 0x40002
+
+#define PGT_L1_DESC_PAGE_MASK0xfC00
+#define PGT_L1_DESC_SECTION_MASK 0xfff0
+#define PGT_L1_DESC_SUPERSECTION_MASK0xff00
+
+#define PGT_L1_DESC_SMALLPAGE_INDEX_SHIFT12
+#define PGT_L1_DESC_LARGEPAGE_INDEX_SHIFT16
+#define PGT_L1_DESC_SECTION_INDEX_SHIFT  20
+#define PGT_L1_DESC_SUPERSECTION_INDEX_SHIFT 24
+
+#define PGT_L2_DESC_SMALLPAGE   0x02
+#define PGT_L2_DESC_LARGEPAGE   0x01
+
+#define PGT_L2_DESC_SMALLPAGE_MASK  0xf000
+#define PGT_L2_DESC_LARGEPAGE_MASK  0x
+
+/*
+ * The memory for the page tables (256 KB per IPU) is placed just before
+ * the carveout memories for the remote processors. 16 KB of memory is
+ * needed for the L1 page table (4096 entries * 4 bytes per 1 MB section).
+ * Any smaller page (64 KB or 4 KB) entries are supported through L2 page
+ * tables (1 KB per table). The remaining 240 KB can provide support for
+ * 2

[PATCH v2 08/10] arm: dts: dra7: Add ipu and related nodes

2021-09-30 Thread Amjad Ouled-Ameur
From: Keerthy 

Add ipu and the associated nodes.

Signed-off-by: Keerthy 
Signed-off-by: Amjad Ouled-Ameur 
---

(no changes since v1)

 arch/arm/dts/dra7.dtsi | 45 +-
 1 file changed, 44 insertions(+), 1 deletion(-)

diff --git a/arch/arm/dts/dra7.dtsi b/arch/arm/dts/dra7.dtsi
index fd1aea0b1b16..e2e958b36626 100644
--- a/arch/arm/dts/dra7.dtsi
+++ b/arch/arm/dts/dra7.dtsi
@@ -41,6 +41,8 @@
d_can0 = 
d_can1 = 
spi0 = 
+   remoteproc0 = 
+   remoteproc1 = 
};
 
timer {
@@ -263,9 +265,12 @@
};
 
prm: prm@6000 {
-   compatible = "ti,dra7-prm";
+   compatible = "ti,dra7-prm", "simple-bus";
reg = <0x6000 0x3000>;
interrupts = ;
+   #address-cells = <1>;
+   #size-cells = <1>;
+   ranges = <0 0x6000 0x3000>;
 
prm_clocks: clocks {
#address-cells = <1>;
@@ -274,6 +279,20 @@
 
prm_clockdomains: clockdomains {
};
+
+   ipu1_rst: ipu1_rst@510 {
+   compatible = "ti,dra7-reset";
+   reg = <0x510 0x8>;
+   ti,nresets = <3>;
+   #reset-cells = <1>;
+   };
+
+   ipu2_rst: ipu2_rst@910 {
+   compatible = "ti,dra7-reset";
+   reg = <0x910 0x8>;
+   ti,nresets = <3>;
+   #reset-cells = <1>;
+   };
};
 
scm_wkup: scm_conf@c000 {
@@ -2032,6 +2051,30 @@
clocks = <_iclk_div>;
clock-names = "fck";
};
+
+   ipu1: ipu@5882 {
+   compatible = "ti,dra7-ipu";
+   reg = <0x5882 0x1>;
+   reg-names = "l2ram";
+   ti,hwmods = "ipu1";
+   resets = <_rst 0>, <_rst 1>, <_rst 2>;
+   iommus = <_ipu1>;
+   ti,rproc-standby-info = <0x4a005520>;
+   timers = <>;
+   watchdog-timers = <>, <>;
+   };
+
+   ipu2: ipu@5502 {
+   compatible = "ti,dra7-ipu";
+   reg = <0x5502 0x1>;
+   reg-names = "l2ram";
+   ti,hwmods = "ipu2";
+   resets = <_rst 0>, <_rst 1>, <_rst 2>;
+   iommus = <_ipu2>;
+   ti,rproc-standby-info = <0x4a008920>;
+   timers = <>;
+   watchdog-timers = <>, <>;
+   };
};
 
thermal_zones: thermal-zones {
-- 
2.25.1



[PATCH v2 07/10] dts: dra7-ipu-common-early-boot.dtsi: Add all the ipu early boot related nodes

2021-09-30 Thread Amjad Ouled-Ameur
From: Keerthy 

Add all the ipu early boot related nodes

Signed-off-by: Keerthy 
Signed-off-by: Amjad Ouled-Ameur 
---

(no changes since v1)

 MAINTAINERS  |   1 +
 arch/arm/dts/dra7-ipu-common-early-boot.dtsi | 113 +++
 2 files changed, 114 insertions(+)
 create mode 100644 arch/arm/dts/dra7-ipu-common-early-boot.dtsi

diff --git a/MAINTAINERS b/MAINTAINERS
index f7ec528af73a..ffaf2015ca5f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -492,6 +492,7 @@ F:  arch/arm/mach-keystone/
 F: arch/arm/mach-omap2/
 F: arch/arm/include/asm/arch-omap*/
 F: arch/arm/include/asm/ti-common/
+F: arch/arm/dts/dra7*
 F: board/ti/
 F: drivers/dma/ti*
 F: drivers/firmware/ti_sci.*
diff --git a/arch/arm/dts/dra7-ipu-common-early-boot.dtsi 
b/arch/arm/dts/dra7-ipu-common-early-boot.dtsi
new file mode 100644
index ..ec6040ff93eb
--- /dev/null
+++ b/arch/arm/dts/dra7-ipu-common-early-boot.dtsi
@@ -0,0 +1,113 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
+ */
+
+/ {
+   chosen {
+   firmware-loader = _loader0;
+   };
+
+   fs_loader0: fs_loader@0 {
+   u-boot,dm-pre-reloc;
+   compatible = "u-boot,fs-loader";
+   phandlepart = < 1>;
+   };
+
+   reserved-memory {
+   #address-cells = <2>;
+   #size-cells = <2>;
+   ranges;
+   u-boot,dm-spl;
+
+   ipu2_memory_region: ipu2-memory@9580 {
+   compatible = "shared-dma-pool";
+   reg = <0x0 0x9580 0x0 0x380>;
+   reusable;
+   status = "okay";
+   u-boot,dm-spl;
+   };
+
+   ipu1_memory_region: ipu1-memory@9d00 {
+   compatible = "shared-dma-pool";
+   reg = <0x0 0x9d00 0x0 0x200>;
+   reusable;
+   status = "okay";
+   u-boot,dm-spl;
+   };
+
+   ipu1_pgtbl: ipu1-pgtbl@9570 {
+   reg = <0x0 0x9570 0x0 0x4>;
+   no-map;
+   u-boot,dm-spl;
+   };
+
+   ipu2_pgtbl: ipu2-pgtbl@9574 {
+   reg = <0x0 0x9574 0x0 0x4>;
+   no-map;
+   u-boot,dm-spl;
+   };
+   };
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+_ipu1 {
+   u-boot,dm-spl;
+};
+
+_ipu2 {
+   u-boot,dm-spl;
+};
+
+ {
+   status = "okay";
+   memory-region = <_memory_region>;
+   pg-tbl = <_pgtbl>;
+   u-boot,dm-spl;
+};
+
+ {
+   status = "okay";
+   memory-region = <_memory_region>;
+   pg-tbl = <_pgtbl>;
+   u-boot,dm-spl;
+};
+
+_wkup {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+_rst {
+   u-boot,dm-spl;
+};
+
+_rst {
+   u-boot,dm-spl;
+};
-- 
2.25.1



[PATCH v2 04/10] linux: bitmap.h: Add find_next_zero_area function

2021-09-30 Thread Amjad Ouled-Ameur
From: Keerthy 

Add find_next_zero_area to fetch the next zero area in the map.

Signed-off-by: Keerthy 
Signed-off-by: Amjad Ouled-Ameur 
---

(no changes since v1)

 include/linux/bitmap.h | 26 ++
 1 file changed, 26 insertions(+)

diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
index dae4225be549..0a8503af9f14 100644
--- a/include/linux/bitmap.h
+++ b/include/linux/bitmap.h
@@ -159,6 +159,32 @@ static inline unsigned long find_first_bit(const unsigned 
long *addr, unsigned l
 (bit) < (size);\
 (bit) = find_next_bit((addr), (size), (bit) + 1))
 
+static inline unsigned long
+bitmap_find_next_zero_area(unsigned long *map,
+  unsigned long size,
+  unsigned long start,
+  unsigned int nr, unsigned long align_mask)
+{
+   unsigned long index, end, i;
+again:
+   index = find_next_zero_bit(map, size, start);
+
+   /*
+* Align allocation
+*/
+   index = (index + align_mask) & ~align_mask;
+
+   end = index + nr;
+   if (end > size)
+   return end;
+   i = find_next_bit(map, end, index);
+   if (i < end) {
+   start = i + 1;
+   goto again;
+   }
+   return index;
+}
+
 static inline void bitmap_fill(unsigned long *dst, unsigned int nbits)
 {
if (small_const_nbits(nbits)) {
-- 
2.25.1



[PATCH v2 03/10] drivers: misc: Makefile: Enable fs_loader compilation at SPL Level

2021-09-30 Thread Amjad Ouled-Ameur
From: Keerthy 

Enable fs_loader compilation at SPL Level.

Signed-off-by: Keerthy 
[Amjad: fix compilation failures for J721e platform]
Signed-off-by: Amjad Ouled-Ameur 
---

(no changes since v1)

 arch/arm/mach-k3/common.c | 10 +++---
 configs/j721e_evm_r5_defconfig|  1 +
 configs/j721e_hs_evm_r5_defconfig |  1 +
 drivers/misc/Kconfig  |  9 +
 drivers/misc/Makefile |  2 +-
 5 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c
index 2666cd2d7b17..dddad8e3b056 100644
--- a/arch/arm/mach-k3/common.c
+++ b/arch/arm/mach-k3/common.c
@@ -156,13 +156,15 @@ void init_env(void)
 #endif
 }
 
-#ifdef CONFIG_FS_LOADER
 int load_firmware(char *name_fw, char *name_loadaddr, u32 *loadaddr)
 {
struct udevice *fsdev;
char *name = NULL;
int size = 0;
 
+   if (!IS_ENABLED(CONFIG_FS_LOADER))
+   return 0;
+
*loadaddr = 0;
 #ifdef CONFIG_SPL_ENV_SUPPORT
switch (spl_boot_device()) {
@@ -186,12 +188,6 @@ int load_firmware(char *name_fw, char *name_loadaddr, u32 
*loadaddr)
 
return size;
 }
-#else
-int load_firmware(char *name_fw, char *name_loadaddr, u32 *loadaddr)
-{
-   return 0;
-}
-#endif
 
 __weak void release_resources_for_core_shutdown(void)
 {
diff --git a/configs/j721e_evm_r5_defconfig b/configs/j721e_evm_r5_defconfig
index b5fd3bf23734..edc003f46b90 100644
--- a/configs/j721e_evm_r5_defconfig
+++ b/configs/j721e_evm_r5_defconfig
@@ -88,6 +88,7 @@ CONFIG_SYS_I2C_OMAP24XX=y
 CONFIG_DM_MAILBOX=y
 CONFIG_K3_SEC_PROXY=y
 CONFIG_FS_LOADER=y
+CONFIG_SPL_FS_LOADER=y
 CONFIG_ESM_K3=y
 CONFIG_K3_AVS0=y
 CONFIG_ESM_PMIC=y
diff --git a/configs/j721e_hs_evm_r5_defconfig 
b/configs/j721e_hs_evm_r5_defconfig
index 3a8e0b1cd15b..6c3675c1726c 100644
--- a/configs/j721e_hs_evm_r5_defconfig
+++ b/configs/j721e_hs_evm_r5_defconfig
@@ -82,6 +82,7 @@ CONFIG_SYS_I2C_OMAP24XX=y
 CONFIG_DM_MAILBOX=y
 CONFIG_K3_SEC_PROXY=y
 CONFIG_FS_LOADER=y
+CONFIG_SPL_FS_LOADER=y
 CONFIG_K3_AVS0=y
 CONFIG_MMC_SDHCI=y
 CONFIG_SPL_MMC_SDHCI_ADMA=y
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 997b71322110..e6a1dc677d6e 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -468,6 +468,15 @@ config FS_LOADER
  The consumer driver would then use this loader to program whatever,
  ie. the FPGA device.
 
+config SPL_FS_LOADER
+   bool "Enable loader driver for file system"
+   help
+ This is file system generic loader which can be used to load
+ the file image from the storage into target such as memory.
+
+ The consumer driver would then use this loader to program whatever,
+ ie. the FPGA device.
+
 config GDSYS_SOC
bool "Enable gdsys SOC driver"
depends on MISC
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index b64cd2a4de91..c7c95ee76767 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -37,7 +37,7 @@ obj-$(CONFIG_FSL_IFC) += fsl_ifc.o
 obj-$(CONFIG_FSL_IIM) += fsl_iim.o
 obj-$(CONFIG_FSL_MC9SDZ60) += mc9sdz60.o
 obj-$(CONFIG_FSL_SEC_MON) += fsl_sec_mon.o
-obj-$(CONFIG_FS_LOADER) += fs_loader.o
+obj-$(CONFIG_$(SPL_)FS_LOADER) += fs_loader.o
 obj-$(CONFIG_GDSYS_IOEP) += gdsys_ioep.o
 obj-$(CONFIG_GDSYS_RXAUI_CTRL) += gdsys_rxaui_ctrl.o
 obj-$(CONFIG_GDSYS_SOC) += gdsys_soc.o
-- 
2.25.1



[PATCH v2 01/10] reset: dra7: Add a reset driver

2021-09-30 Thread Amjad Ouled-Ameur
From: Keerthy 

Add a reset driver to bring IPs out of reset.

Signed-off-by: Keerthy 
[Amjad: reset_ops structure member "free" has been renamed to "rfree",
use the latter instead]
Signed-off-by: Amjad Ouled-Ameur 
---

(no changes since v1)

 MAINTAINERS|  1 +
 drivers/reset/Kconfig  |  6 +++
 drivers/reset/Makefile |  1 +
 drivers/reset/reset-dra7.c | 97 ++
 4 files changed, 105 insertions(+)
 create mode 100644 drivers/reset/reset-dra7.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 5370b550648e..ec586ec5466f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -509,6 +509,7 @@ F:  drivers/remoteproc/k3_system_controller.c
 F: drivers/remoteproc/pruc_rpoc.c
 F: drivers/remoteproc/ti*
 F: drivers/reset/reset-ti-sci.c
+F: drivers/reset/reset-dra7.c
 F: drivers/rtc/davinci.c
 F: drivers/serial/serial_omap.c
 F: drivers/soc/ti/
diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig
index d73daf5e3189..b57714111b5a 100644
--- a/drivers/reset/Kconfig
+++ b/drivers/reset/Kconfig
@@ -206,4 +206,10 @@ config RESET_ZYNQMP
  passing request via Xilinx firmware interface to TF-A and PMU
  firmware.
 
+config RESET_DRA7
+   bool "Support for TI's DRA7 Reset driver"
+   depends on DM_RESET
+   help
+ Support for TI DRA7-RESET subsystem. Basic Assert/Deassert
+ is supported.
 endmenu
diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile
index d69486bdeb9e..97e3a782c0d8 100644
--- a/drivers/reset/Makefile
+++ b/drivers/reset/Makefile
@@ -30,3 +30,4 @@ obj-$(CONFIG_RESET_SYSCON) += reset-syscon.o
 obj-$(CONFIG_RESET_RASPBERRYPI) += reset-raspberrypi.o
 obj-$(CONFIG_RESET_SCMI) += reset-scmi.o
 obj-$(CONFIG_RESET_ZYNQMP) += reset-zynqmp.o
+obj-$(CONFIG_RESET_DRA7) += reset-dra7.o
diff --git a/drivers/reset/reset-dra7.c b/drivers/reset/reset-dra7.c
new file mode 100644
index ..585f8323c52e
--- /dev/null
+++ b/drivers/reset/reset-dra7.c
@@ -0,0 +1,97 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Texas Instruments DRA7 reset driver
+ *
+ * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
+ * Author: Keerthy 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct dra7_reset_priv {
+   u32 rstctrl;
+   u32 rstst;
+   u8 nreset;
+};
+
+static int dra7_reset_request(struct reset_ctl *reset_ctl)
+{
+   return 0;
+}
+
+static int dra7_reset_free(struct reset_ctl *reset_ctl)
+{
+   return 0;
+}
+
+static inline void dra7_reset_rmw(u32 addr, u32 value, u32 mask)
+{
+   writel(((readl(addr) & (~mask)) | (value & mask)), addr);
+}
+
+static int dra7_reset_deassert(struct reset_ctl *reset_ctl)
+{
+   struct dra7_reset_priv *priv = dev_get_priv(reset_ctl->dev);
+   int mask = 1 << reset_ctl->id;
+
+   if (reset_ctl->id < 0 || reset_ctl->id >= priv->nreset)
+   return -EINVAL;
+
+   dra7_reset_rmw(priv->rstctrl, 0x0, mask);
+
+   while ((readl(priv->rstst) & mask) != mask)
+   ;
+
+   return 0;
+}
+
+static int dra7_reset_assert(struct reset_ctl *reset_ctl)
+{
+   struct dra7_reset_priv *priv = dev_get_priv(reset_ctl->dev);
+   int mask = 1 << reset_ctl->id;
+
+   if (reset_ctl->id < 0 || reset_ctl->id >= priv->nreset)
+   return -EINVAL;
+
+   dra7_reset_rmw(priv->rstctrl, mask, 0x0);
+
+   return 0;
+}
+
+struct reset_ops dra7_reset_ops = {
+   .request = dra7_reset_request,
+   .rfree = dra7_reset_free,
+   .rst_assert = dra7_reset_assert,
+   .rst_deassert = dra7_reset_deassert,
+};
+
+static const struct udevice_id dra7_reset_ids[] = {
+   { .compatible = "ti,dra7-reset" },
+   { }
+};
+
+static int dra7_reset_probe(struct udevice *dev)
+{
+   struct dra7_reset_priv *priv = dev_get_priv(dev);
+
+   priv->rstctrl = dev_read_addr(dev);
+   priv->rstst = priv->rstctrl + 0x4;
+   priv->nreset = dev_read_u32_default(dev, "ti,nresets", 1);
+
+   dev_info(dev, "dra7-reset successfully probed %s\n", dev->name);
+
+   return 0;
+}
+
+U_BOOT_DRIVER(dra7_reset) = {
+   .name = "dra7_reset",
+   .id = UCLASS_RESET,
+   .of_match = dra7_reset_ids,
+   .probe = dra7_reset_probe,
+   .ops = _reset_ops,
+   .priv_auto = sizeof(struct dra7_reset_priv),
+};
-- 
2.25.1



[PATCH v2 02/10] arm: mach-omap2: load/start remoteproc IPU1/IPU2

2021-09-30 Thread Amjad Ouled-Ameur
From: Keerthy 

First check the presence of the ipu firmware in the boot partition.
If present enable the ipu and the related clocks & then move
on to load the firmware and eventually start remoteproc IPU1/IPU2.

do_enable_clocks by default puts the clock domains into auto
which does not work well with reset. Hence adding do_enable_ipu_clocks
function.

Signed-off-by: Keerthy 
[Amjad: fix IPU1_LOAD_ADDR and compile warnings]
Signed-off-by: Amjad Ouled-Ameur 
---

(no changes since v1)

 arch/arm/include/asm/arch-omap5/clock.h |  3 +
 arch/arm/include/asm/omap_common.h  | 10 +++
 arch/arm/mach-omap2/boot-common.c   | 95 +
 arch/arm/mach-omap2/clocks-common.c | 33 +
 arch/arm/mach-omap2/omap5/hw_data.c | 92 ++--
 arch/arm/mach-omap2/omap5/prcm-regs.c   |  9 ++-
 6 files changed, 235 insertions(+), 7 deletions(-)

diff --git a/arch/arm/include/asm/arch-omap5/clock.h 
b/arch/arm/include/asm/arch-omap5/clock.h
index 87eb3f335ab0..a00626e357c9 100644
--- a/arch/arm/include/asm/arch-omap5/clock.h
+++ b/arch/arm/include/asm/arch-omap5/clock.h
@@ -135,6 +135,9 @@
 #define HSMMC_CLKCTRL_CLKSEL_MASK  (1 << 24)
 #define HSMMC_CLKCTRL_CLKSEL_DIV_MASK  (3 << 25)
 
+/* CM_IPU1_IPU1_CLKCTRL CLKSEL MASK */
+#define IPU1_CLKCTRL_CLKSEL_MASK   BIT(24)
+
 /* CM_L3INIT_SATA_CLKCTRL */
 #define SATA_CLKCTRL_OPTFCLKEN_MASK(1 << 8)
 
diff --git a/arch/arm/include/asm/omap_common.h 
b/arch/arm/include/asm/omap_common.h
index de8fc99d0478..264a2e717a70 100644
--- a/arch/arm/include/asm/omap_common.h
+++ b/arch/arm/include/asm/omap_common.h
@@ -362,6 +362,10 @@ struct prcm_regs {
/* IPU */
u32 cm_ipu_clkstctrl;
u32 cm_ipu_i2c5_clkctrl;
+   u32 cm_ipu1_clkstctrl;
+   u32 cm_ipu1_ipu1_clkctrl;
+   u32 cm_ipu2_clkstctrl;
+   u32 cm_ipu2_ipu2_clkctrl;
 
/*l3main1 edma*/
u32 cm_l3main1_tptc1_clkctrl;
@@ -632,6 +636,12 @@ void do_disable_clocks(u32 const *clk_domains,
   u8 wait_for_disable);
 #endif /* CONFIG_OMAP44XX || CONFIG_OMAP54XX */
 
+void do_enable_ipu_clocks(u32 const *clk_domains,
+ u32 const *clk_modules_hw_auto,
+ u32 const *clk_modules_explicit_en,
+ u8 wait_for_enable);
+void enable_ipu1_clocks(void);
+void enable_ipu2_clocks(void);
 void setup_post_dividers(u32 const base,
const struct dpll_params *params);
 u32 omap_ddr_clk(void);
diff --git a/arch/arm/mach-omap2/boot-common.c 
b/arch/arm/mach-omap2/boot-common.c
index 7cdf7f158981..2bf4aff74c3a 100644
--- a/arch/arm/mach-omap2/boot-common.c
+++ b/arch/arm/mach-omap2/boot-common.c
@@ -10,6 +10,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -19,9 +21,14 @@
 #include 
 #include 
 #include 
+#include 
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#define IPU1_LOAD_ADDR (0xa17ff000)
+#define MAX_REMOTECORE_BIN_SIZE (8 * 0x10)
+#define IPU2_LOAD_ADDR (IPU1_LOAD_ADDR + MAX_REMOTECORE_BIN_SIZE)
+
 __weak u32 omap_sys_boot_device(void)
 {
return BOOT_DEVICE_NONE;
@@ -194,6 +201,91 @@ u32 spl_mmc_boot_mode(const u32 boot_device)
return gd->arch.omap_boot_mode;
 }
 
+int load_firmware(char *name_fw, u32 *loadaddr)
+{
+   struct udevice *fsdev;
+   int size = 0;
+
+   if (!IS_ENABLED(CONFIG_FS_LOADER))
+   return 0;
+
+   if (!*loadaddr)
+   return 0;
+
+   if (!uclass_get_device(UCLASS_FS_FIRMWARE_LOADER, 0, )) {
+   size = request_firmware_into_buf(fsdev, name_fw,
+(void *)*loadaddr, 0, 0);
+   }
+
+   return size;
+}
+
+void spl_boot_ipu(void)
+{
+   int ret, size;
+   u32 loadaddr = IPU1_LOAD_ADDR;
+
+   if (!IS_ENABLED(CONFIG_SPL_BUILD) ||
+   !IS_ENABLED(CONFIG_REMOTEPROC_TI_IPU))
+   return;
+
+   size = load_firmware("dra7-ipu1-fw.xem4", );
+   if (size <= 0) {
+   pr_err("Firmware loading failed\n");
+   goto skip_ipu1;
+   }
+
+   enable_ipu1_clocks();
+   ret = rproc_dev_init(0);
+   if (ret) {
+   debug("%s: IPU1 failed to initialize on rproc (%d)\n",
+ __func__, ret);
+   goto skip_ipu1;
+   }
+
+   ret = rproc_load(0, IPU1_LOAD_ADDR, 0x200);
+   if (ret) {
+   debug("%s: IPU1 failed to load on rproc (%d)\n", __func__,
+ ret);
+   goto skip_ipu1;
+   }
+
+   debug("Starting IPU1...\n");
+
+   ret = rproc_start(0);
+   if (ret)
+   debug("%s: IPU1 failed to start (%d)\n", __func__, ret);
+
+skip_ipu1:
+   loadaddr = IPU2_LOAD_ADDR;
+   size = load_firmware("dra7-ipu2-fw.xem4", );
+   if 

[PATCH v2 00/10] dra7: bring up and support IPU load/start

2021-09-30 Thread Amjad Ouled-Ameur
This patchset enables support for loading and starting IPU firmware,
the following have been implemented:
- Enable fs_loader compilation at SPL Level, that is necessary in order
  to load IPU firmware from /boot partition.
- Define necessary related IPU dts nodes.
- Add necessary drivers and helpers to bring up, load and start IPU
  firmware.

The underlying patches are interdependent, therefore should be applied
in the order they are numbered in this patchset.

Tests:
- Please find SPL, u-boot and kernel console logs in here [1]
- At SPL stage, debug logs have been enabled to make sure that
IPU1 and IPU2 are loaded and started properly. In fact, these two log
messages are only displayed when the firmware has been loaded, and if no
errors appear afterwards, it means that firmware started successfully as
well:
  - Starting IPU1...
  - Starting IPU2...

At U-boot stage, "rproc" command-line tool was used for the testing. In
the logs [1], "rproc list" was run before and after IPU1 and IPU2 are
initialized by "rproc init". The before run gave an empty list, while
the after run listed successfully the two IPUs with their correct
addresses:
  - 0 - Name:'ipu@5882' type:'internal memory mapped'
  - 1 - Name:'ipu@5502' type:'internal memory mapped'

"rproc start" and "rproc stop" were also used for both IPU1 and IPU2,
both were successful as no error logs were displayed.

[0]: https://pastebin.com/QGUYSPRt

These U-boot/SPL flags have been purposely enabled during tests to ensure
IPU load/start work properly:
- CONFIG_DM_RESET=y
- CONFIG_RESET_DRA7=y
- CONFIG_SPL_DM_RESET=y
- CONFIG_FS_LOADER=y
- CONFIG_SPL_FS_LOADER=y
- CONFIG_SPL_DRIVERS_MISC_SUPPORT=y
- CONFIG_REMOTEPROC_TI_IPU=y
- CONFIG_SPL_REMOTEPROC=y
- CONFIG_CMD_REMOTEPROC=y


Changes in v2:
- Add useful checks and remove redundant code.

Keerthy (10):
  reset: dra7: Add a reset driver
  arm: mach-omap2: load/start remoteproc IPU1/IPU2
  drivers: misc: Makefile: Enable fs_loader compilation at SPL Level
  linux: bitmap.h: Add find_next_zero_area function
  remoteproc: uclass: Add remoteproc resource handling helpers
  remoteproc: ipu: Add driver to bring up ipu
  dts: dra7-ipu-common-early-boot.dtsi: Add all the ipu early boot
related nodes
  arm: dts: dra7: Add ipu and related nodes
  arm: dts: dra7*/am57xx-idk-evm-u-boot: Add ipu early boot DT changes
  dts: am57xx*: Add ipu early boot DT changes

 MAINTAINERS   |   4 +
 .../dts/am57xx-beagle-x15-revb1-u-boot.dtsi   |   7 +
 .../dts/am57xx-beagle-x15-revc-u-boot.dtsi|   7 +
 arch/arm/dts/am57xx-beagle-x15-u-boot.dtsi|   7 +
 arch/arm/dts/am57xx-cl-som-am57x-u-boot.dtsi  |   7 +
 arch/arm/dts/am57xx-idk-common-u-boot.dtsi|   1 +
 arch/arm/dts/am57xx-sbc-am57x-u-boot.dtsi |   7 +
 arch/arm/dts/dra7-evm-u-boot.dtsi |   1 +
 arch/arm/dts/dra7-ipu-common-early-boot.dtsi  | 113 +++
 arch/arm/dts/dra7.dtsi|  45 +-
 arch/arm/dts/dra71-evm-u-boot.dtsi|   1 +
 arch/arm/dts/dra72-evm-revc-u-boot.dtsi   |   1 +
 arch/arm/dts/dra76-evm-u-boot.dtsi|   1 +
 arch/arm/include/asm/arch-omap5/clock.h   |   3 +
 arch/arm/include/asm/omap_common.h|  10 +
 arch/arm/mach-k3/common.c |  10 +-
 arch/arm/mach-omap2/boot-common.c |  95 +++
 arch/arm/mach-omap2/clocks-common.c   |  33 +
 arch/arm/mach-omap2/omap5/hw_data.c   |  92 ++-
 arch/arm/mach-omap2/omap5/prcm-regs.c |   9 +-
 configs/j721e_evm_r5_defconfig|   1 +
 configs/j721e_hs_evm_r5_defconfig |   1 +
 drivers/misc/Kconfig  |   9 +
 drivers/misc/Makefile |   2 +-
 drivers/remoteproc/Kconfig|  10 +
 drivers/remoteproc/Makefile   |   1 +
 drivers/remoteproc/ipu_rproc.c| 759 ++
 drivers/remoteproc/rproc-uclass.c | 532 
 drivers/reset/Kconfig |   6 +
 drivers/reset/Makefile|   1 +
 drivers/reset/reset-dra7.c|  97 +++
 include/linux/bitmap.h|  26 +
 include/remoteproc.h  | 384 -
 33 files changed, 2266 insertions(+), 17 deletions(-)
 create mode 100644 arch/arm/dts/am57xx-beagle-x15-revb1-u-boot.dtsi
 create mode 100644 arch/arm/dts/am57xx-beagle-x15-revc-u-boot.dtsi
 create mode 100644 arch/arm/dts/am57xx-beagle-x15-u-boot.dtsi
 create mode 100644 arch/arm/dts/am57xx-cl-som-am57x-u-boot.dtsi
 create mode 100644 arch/arm/dts/am57xx-sbc-am57x-u-boot.dtsi
 create mode 100644 arch/arm/dts/dra7-ipu-common-early-boot.dtsi
 create mode 100644 drivers/remoteproc/ipu_rproc.c
 create mode 100644 drivers/reset/reset-dra7.c

-- 
2.25.1



[PATCH] board: ti: Add support for the AM335x GP EVM mini board

2021-09-28 Thread Amjad Ouled-Ameur
From: Andreas Dannenberg 

This is not really a new board but rather a minimal bootloader solution
for the AM335x GP EVM. In terms of interfaces, it only supports booting
from MMC0 or UART0 and only activates a minimal set of drivers that are
that are necessary to run the device such as DDR, I2C, and PMIC.

The goal is to provide a bare minimum starting point to boot Linux for
basing custom board-ports on. The limited complexity of this solution
should make it easier to achieve a successful boot to U-Boot prompt vs.
trying to pair down the full-featured multi-platform AM335x U-Boot
available through am335x_evm_defconfig.

Signed-off-by: Andreas Dannenberg 
[Amjad: fix checkpatch and compile warnings]
Signed-off-by: Amjad Ouled-Ameur 

---
Tests:
- This has been tested on Am335x platform, the board boots successfully
to u-boot prompt and runs basic commands seamlessly, please find the logs
here: [0]
However, regarding the kernel boot test, this patch does not actually
guaranteey that since its purpose is to mainly allow the user to achieve a
successful boot to U-boot prompt.

[0]: https://pastebin.com/ixQ2yB9n

 MAINTAINERS  |   1 +
 arch/arm/dts/Makefile|   1 +
 arch/arm/dts/am335x-bone-common.dtsi |   1 +
 arch/arm/dts/am335x-evm-mini.dts | 166 ++
 arch/arm/mach-omap2/am33xx/Kconfig   |  30 
 board/ti/am335x/Kconfig  |  13 +-
 board/ti/am335x/Makefile |   6 +-
 board/ti/am335x/board_hs_mini.h  |  19 ++
 board/ti/am335x/board_mini.c | 249 +++
 board/ti/am335x/board_mini.h |  44 +
 board/ti/am335x/mux_mini.c   | 109 
 configs/am335x_evm_mini_defconfig|  42 +
 configs/am335x_hs_evm_mini_defconfig |  46 +
 include/configs/am335x_evm_mini.h|  96 +++
 14 files changed, 820 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm/dts/am335x-evm-mini.dts
 create mode 100644 board/ti/am335x/board_hs_mini.h
 create mode 100644 board/ti/am335x/board_mini.c
 create mode 100644 board/ti/am335x/board_mini.h
 create mode 100644 board/ti/am335x/mux_mini.c
 create mode 100644 configs/am335x_evm_mini_defconfig
 create mode 100644 configs/am335x_hs_evm_mini_defconfig
 create mode 100644 include/configs/am335x_evm_mini.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 5370b550648e..09b942acd109 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -492,6 +492,7 @@ F:  arch/arm/mach-keystone/
 F: arch/arm/mach-omap2/
 F: arch/arm/include/asm/arch-omap*/
 F: arch/arm/include/asm/ti-common/
+F: arch/arm/dts/am335x*
 F: board/ti/
 F: drivers/dma/ti*
 F: drivers/firmware/ti_sci.*
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index fc16a57e60b0..faf8f438bf29 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -360,6 +360,7 @@ dtb-$(CONFIG_AM33XX) += \
am335x-brsmarc1.dtb \
am335x-draco.dtb \
am335x-evm.dtb \
+   am335x-evm-mini.dtb \
am335x-evmsk.dtb \
am335x-bonegreen.dtb \
am335x-icev2.dtb \
diff --git a/arch/arm/dts/am335x-bone-common.dtsi 
b/arch/arm/dts/am335x-bone-common.dtsi
index 35ec1a8df870..a87558686709 100644
--- a/arch/arm/dts/am335x-bone-common.dtsi
+++ b/arch/arm/dts/am335x-bone-common.dtsi
@@ -211,6 +211,7 @@
 
tps: tps@24 {
reg = <0x24>;
+   #interrupt-cells = <1>;
};
 
baseboard_eeprom: baseboard_eeprom@50 {
diff --git a/arch/arm/dts/am335x-evm-mini.dts b/arch/arm/dts/am335x-evm-mini.dts
new file mode 100644
index ..f45da0fd3f6f
--- /dev/null
+++ b/arch/arm/dts/am335x-evm-mini.dts
@@ -0,0 +1,166 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/
+ */
+/dts-v1/;
+
+#include "am33xx.dtsi"
+#include 
+
+/ {
+   model = "TI AM335x EVM MINI";
+   compatible = "ti,am335x-evm-mini", "ti,am335x-evm", "ti,am33xx";
+
+   chosen {
+   stdout-path = 
+   tick-timer = 
+   };
+
+   cpus {
+   cpu@0 {
+   cpu0-supply = <_reg>;
+   };
+   };
+
+   memory {
+   device_type = "memory";
+   reg = <0x8000 0x1000>; /* 256 MB */
+   };
+
+   vbat: fixedregulator@0 {
+   compatible = "regulator-fixed";
+   regulator-name = "vbat";
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   regulator-boot-on;
+   };
+};
+
+_pinmux {
+   i2c0_pins: pinmux_i2c0_pins {
+   pinctrl-single,pins = <
+   0x188 (PIN_INPUT_PULLUP | MUX_MODE0)/* 
i2c0_sda.i2c0_sda */
+   0x18c (PIN_INPUT_PULLUP | MUX_MODE0)/* 
i2c0_scl.

[PATCH] board: ti: Add support for the AM437x GP EVM mini board

2021-09-28 Thread Amjad Ouled-Ameur
From: Andreas Dannenberg 

This is not really a new board but rather a minimal bootloader solution
for the AM437x GP EVM. In terms of interfaces, it only supports booting
from MMC0 or UART0 and only activates a minimal set of drivers that are
that are necessary to run the device such as DDR, I2C, and PMIC.

The goal is to provide a bare minimum starting point to boot Linux for
basing custom board-ports on. The limited complexity of this solution
should make it easier to achieve a successful boot to U-Boot prompt vs.
trying to pair down the full-featured multi-platform AM437x U-Boot
available through am43xx_evm_defconfig.

Signed-off-by: Andreas Dannenberg 
[Amjad: fix compile and checkpatch warnings]
Signed-off-by: Amjad Ouled-Ameur 

---
Tests:
- This has been tested on AM43xx platform, the board boots successfully
to u-boot prompt and runs basic commands seamlessly, please find the logs
here: [0]
However, regarding the kernel boot test, sometimes it does boot correctly,
sometimes it does not, but this patch does not actually guaranteey that
since its purpose is to mainly allow the user to achieve a successful boot
to U-boot prompt.

[0]: https://pastebin.com/zmCsjQRT

 MAINTAINERS  |   4 +
 arch/arm/dts/Makefile|   5 +-
 arch/arm/dts/am437x-gp-evm-mini.dts  | 171 ++
 arch/arm/mach-omap2/am33xx/Kconfig   |  22 ++
 board/ti/am43xx/Kconfig  |  13 +-
 board/ti/am43xx/Makefile |   6 +-
 board/ti/am43xx/board_hs_mini.h  |  27 ++
 board/ti/am43xx/board_mini.c | 452 +++
 board/ti/am43xx/board_mini.h |  28 ++
 board/ti/am43xx/mux_mini.c   |  53 
 configs/am43xx_evm_mini_defconfig|  39 +++
 configs/am43xx_hs_evm_mini_defconfig |  47 +++
 include/configs/am43xx_evm_mini.h| 120 +++
 13 files changed, 983 insertions(+), 4 deletions(-)
 create mode 100644 arch/arm/dts/am437x-gp-evm-mini.dts
 create mode 100644 board/ti/am43xx/board_hs_mini.h
 create mode 100644 board/ti/am43xx/board_mini.c
 create mode 100644 board/ti/am43xx/board_mini.h
 create mode 100644 board/ti/am43xx/mux_mini.c
 create mode 100644 configs/am43xx_evm_mini_defconfig
 create mode 100644 configs/am43xx_hs_evm_mini_defconfig
 create mode 100644 include/configs/am43xx_evm_mini.h

diff --git a/MAINTAINERS b/MAINTAINERS
index 5370b550648e..0159be0e4673 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -492,6 +492,7 @@ F:  arch/arm/mach-keystone/
 F: arch/arm/mach-omap2/
 F: arch/arm/include/asm/arch-omap*/
 F: arch/arm/include/asm/ti-common/
+F: arch/arm/dts/am437x*
 F: board/ti/
 F: drivers/dma/ti*
 F: drivers/firmware/ti_sci.*
@@ -518,6 +519,7 @@ F:  drivers/timer/omap-timer.c
 F: drivers/watchdog/omap_wdt.c
 F: include/linux/pruss_driver.h
 F: include/linux/soc/ti/
+F: include/configs/am43xx_evm_mini.h
 
 ARM U8500
 M: Stephan Gerhold 
@@ -1134,6 +1136,8 @@ F:arch/arm/mach-k3/config_secure.mk
 F: configs/am335x_hs_evm_defconfig
 F: configs/am335x_hs_evm_uart_defconfig
 F: configs/am43xx_hs_evm_defconfig
+F: configs/am43xx_evm_mini_defconfig
+F: configs/am43xx_hs_evm_mini_defconfig
 F: configs/am57xx_hs_evm_defconfig
 F: configs/am57xx_hs_evm_usb_defconfig
 F: configs/dra7xx_hs_evm_defconfig
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index fc16a57e60b0..3b8c539a6272 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -375,7 +375,10 @@ dtb-$(CONFIG_AM33XX) += \
am335x-guardian.dtb \
am335x-wega-rdk.dtb \
am335x-regor-rdk.dtb
-dtb-$(CONFIG_AM43XX) += am437x-gp-evm.dtb am437x-sk-evm.dtb\
+dtb-$(CONFIG_AM43XX) += \
+   am437x-gp-evm.dtb \
+   am437x-gp-evm-mini.dtb \
+   am437x-sk-evm.dtb \
am43x-epos-evm.dtb \
am437x-idk-evm.dtb \
am4372-generic.dtb \
diff --git a/arch/arm/dts/am437x-gp-evm-mini.dts 
b/arch/arm/dts/am437x-gp-evm-mini.dts
new file mode 100644
index ..07c93c47b638
--- /dev/null
+++ b/arch/arm/dts/am437x-gp-evm-mini.dts
@@ -0,0 +1,171 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2020 Texas Instruments Incorporated - http://www.ti.com/
+ */
+
+/* AM437x GP EVM MINI */
+
+/dts-v1/;
+
+#include "am4372.dtsi"
+#include 
+#include 
+
+/ {
+   model = "TI AM437x GP EVM MINI";
+   compatible = 
"ti,am437x-gp-evm-mini","ti,am437x-gp-evm","ti,am4372","ti,am43";
+
+   chosen {
+   stdout-path = 
+   tick-timer = 
+   };
+
+   ocp {
+   u-boot,dm-spl;
+   };
+
+   vmmcsd_fixed: fixedregulator-sd {
+   compatible = "regulator-fixed";
+   regulator-name = "vmmcsd_fixed";
+   regulator-min-microvolt = <330>;
+   regulator-max-microvolt = <330>;
+   enable-active-high;
+ 

[PATCH 2/2] ARM: DRA7: Enable OPP_HIGH for GPU voltage domain

2021-09-27 Thread Amjad Ouled-Ameur
Enable the OPP_HIGH configuration for GPU voltage domain
by default for various TI DRA7xx and AM57xx boards. This
is being done to meet the performance needs of 1080p
GFX/MultiMedia usecases. This domain does not support DVFS
and the kernel will continue to run at the boot OPP chosen
here.

Based on logic similar to that of DSPEVE and IVA voltage
domains in commit 58a8921fe34fd5 ("ARM: DRA7: Enable OPP_HIGH
for DSPEVE and IVA voltage domains")

Signed-off-by: Subhajit Paul 
Signed-off-by: Suman Anna 
Signed-off-by: Amjad Ouled-Ameur 

---

 configs/am57xx_evm_defconfig| 1 +
 configs/am57xx_hs_evm_defconfig | 1 +
 configs/am57xx_hs_evm_usb_defconfig | 1 +
 configs/dra7xx_evm_defconfig| 1 +
 configs/dra7xx_hs_evm_defconfig | 1 +
 configs/dra7xx_hs_evm_usb_defconfig | 1 +
 6 files changed, 6 insertions(+)

diff --git a/configs/am57xx_evm_defconfig b/configs/am57xx_evm_defconfig
index 62fe2e5b9037..cfd742a3d80a 100644
--- a/configs/am57xx_evm_defconfig
+++ b/configs/am57xx_evm_defconfig
@@ -11,6 +11,7 @@ CONFIG_OMAP54XX=y
 CONFIG_TARGET_AM57XX_EVM=y
 CONFIG_DRA7_DSPEVE_OPP_HIGH=y
 CONFIG_DRA7_IVA_OPP_HIGH=y
+CONFIG_DRA7_GPU_OPP_HIGH=y
 CONFIG_SPL=y
 CONFIG_ENV_OFFSET_REDUND=0x28
 CONFIG_SPL_SPI_FLASH_SUPPORT=y
diff --git a/configs/am57xx_hs_evm_defconfig b/configs/am57xx_hs_evm_defconfig
index 55bc28a533c1..edc3e8e34449 100644
--- a/configs/am57xx_hs_evm_defconfig
+++ b/configs/am57xx_hs_evm_defconfig
@@ -14,6 +14,7 @@ CONFIG_TI_SECURE_EMIF_PROTECTED_REGION_SIZE=0x01c0
 CONFIG_TARGET_AM57XX_EVM=y
 CONFIG_DRA7_DSPEVE_OPP_HIGH=y
 CONFIG_DRA7_IVA_OPP_HIGH=y
+CONFIG_DRA7_GPU_OPP_HIGH=y
 CONFIG_SPL=y
 CONFIG_ENV_OFFSET_REDUND=0x28
 CONFIG_SPL_SPI_FLASH_SUPPORT=y
diff --git a/configs/am57xx_hs_evm_usb_defconfig 
b/configs/am57xx_hs_evm_usb_defconfig
index cdb3af3cb69d..ba1449a6ef07 100644
--- a/configs/am57xx_hs_evm_usb_defconfig
+++ b/configs/am57xx_hs_evm_usb_defconfig
@@ -16,6 +16,7 @@ CONFIG_TI_SECURE_EMIF_PROTECTED_REGION_SIZE=0x01c0
 CONFIG_TARGET_AM57XX_EVM=y
 CONFIG_DRA7_DSPEVE_OPP_HIGH=y
 CONFIG_DRA7_IVA_OPP_HIGH=y
+CONFIG_DRA7_GPU_OPP_HIGH=y
 CONFIG_SPL=y
 CONFIG_ENV_OFFSET_REDUND=0x28
 CONFIG_SPL_SPI_FLASH_SUPPORT=y
diff --git a/configs/dra7xx_evm_defconfig b/configs/dra7xx_evm_defconfig
index 71f6b0b6c3ff..95d4244595ab 100644
--- a/configs/dra7xx_evm_defconfig
+++ b/configs/dra7xx_evm_defconfig
@@ -11,6 +11,7 @@ CONFIG_OMAP54XX=y
 CONFIG_TARGET_DRA7XX_EVM=y
 CONFIG_DRA7_DSPEVE_OPP_HIGH=y
 CONFIG_DRA7_IVA_OPP_HIGH=y
+CONFIG_DRA7_GPU_OPP_HIGH=y
 CONFIG_SPL=y
 CONFIG_ENV_OFFSET_REDUND=0x28
 CONFIG_SPL_SPI_FLASH_SUPPORT=y
diff --git a/configs/dra7xx_hs_evm_defconfig b/configs/dra7xx_hs_evm_defconfig
index 5462a79f10c5..537d7d40fdcf 100644
--- a/configs/dra7xx_hs_evm_defconfig
+++ b/configs/dra7xx_hs_evm_defconfig
@@ -14,6 +14,7 @@ CONFIG_TI_SECURE_EMIF_PROTECTED_REGION_SIZE=0x01c0
 CONFIG_TARGET_DRA7XX_EVM=y
 CONFIG_DRA7_DSPEVE_OPP_HIGH=y
 CONFIG_DRA7_IVA_OPP_HIGH=y
+CONFIG_DRA7_GPU_OPP_HIGH=y
 CONFIG_SPL=y
 CONFIG_ENV_OFFSET_REDUND=0x28
 CONFIG_SPL_SPI_FLASH_SUPPORT=y
diff --git a/configs/dra7xx_hs_evm_usb_defconfig 
b/configs/dra7xx_hs_evm_usb_defconfig
index eff9346221f4..cab7f9f5394d 100644
--- a/configs/dra7xx_hs_evm_usb_defconfig
+++ b/configs/dra7xx_hs_evm_usb_defconfig
@@ -16,6 +16,7 @@ CONFIG_TI_SECURE_EMIF_PROTECTED_REGION_SIZE=0x01c0
 CONFIG_TARGET_DRA7XX_EVM=y
 CONFIG_DRA7_DSPEVE_OPP_HIGH=y
 CONFIG_DRA7_IVA_OPP_HIGH=y
+CONFIG_DRA7_GPU_OPP_HIGH=y
 CONFIG_SPL=y
 CONFIG_ENV_OFFSET_REDUND=0x28
 CONFIG_SPL_SPI_FLASH_SUPPORT=y
-- 
2.25.1



[PATCH 1/2] ARM: DRA7: Enable OPP_HIGH for DSPEVE and IVA voltage domains

2021-09-27 Thread Amjad Ouled-Ameur
Enable the OPP_HIGH configuration for DSPEVE and IVA voltage
domains by default for various TI DRA7xx and AM57xx boards. This
is being done to meet the performance needs of 1080p MultiMedia
usecases and other DSP usecases. These domains do not support
DVFS and the kernel will continue to run at the boot OPPs chosen
here.

Signed-off-by: Suman Anna 
Signed-off-by: Amjad Ouled-Ameur 
---

 configs/am57xx_evm_defconfig| 2 ++
 configs/am57xx_hs_evm_defconfig | 2 ++
 configs/am57xx_hs_evm_usb_defconfig | 2 ++
 configs/dra7xx_evm_defconfig| 2 ++
 configs/dra7xx_hs_evm_defconfig | 2 ++
 configs/dra7xx_hs_evm_usb_defconfig | 2 ++
 6 files changed, 12 insertions(+)

diff --git a/configs/am57xx_evm_defconfig b/configs/am57xx_evm_defconfig
index cc11323b9d51..62fe2e5b9037 100644
--- a/configs/am57xx_evm_defconfig
+++ b/configs/am57xx_evm_defconfig
@@ -9,6 +9,8 @@ CONFIG_DEFAULT_DEVICE_TREE="am572x-idk"
 CONFIG_SPL_TEXT_BASE=0x4030
 CONFIG_OMAP54XX=y
 CONFIG_TARGET_AM57XX_EVM=y
+CONFIG_DRA7_DSPEVE_OPP_HIGH=y
+CONFIG_DRA7_IVA_OPP_HIGH=y
 CONFIG_SPL=y
 CONFIG_ENV_OFFSET_REDUND=0x28
 CONFIG_SPL_SPI_FLASH_SUPPORT=y
diff --git a/configs/am57xx_hs_evm_defconfig b/configs/am57xx_hs_evm_defconfig
index 5763264adb1a..55bc28a533c1 100644
--- a/configs/am57xx_hs_evm_defconfig
+++ b/configs/am57xx_hs_evm_defconfig
@@ -12,6 +12,8 @@ CONFIG_TI_SECURE_EMIF_REGION_START=0xbdb0
 CONFIG_TI_SECURE_EMIF_TOTAL_REGION_SIZE=0x0200
 CONFIG_TI_SECURE_EMIF_PROTECTED_REGION_SIZE=0x01c0
 CONFIG_TARGET_AM57XX_EVM=y
+CONFIG_DRA7_DSPEVE_OPP_HIGH=y
+CONFIG_DRA7_IVA_OPP_HIGH=y
 CONFIG_SPL=y
 CONFIG_ENV_OFFSET_REDUND=0x28
 CONFIG_SPL_SPI_FLASH_SUPPORT=y
diff --git a/configs/am57xx_hs_evm_usb_defconfig 
b/configs/am57xx_hs_evm_usb_defconfig
index f2ae04583739..cdb3af3cb69d 100644
--- a/configs/am57xx_hs_evm_usb_defconfig
+++ b/configs/am57xx_hs_evm_usb_defconfig
@@ -14,6 +14,8 @@ CONFIG_TI_SECURE_EMIF_REGION_START=0xbdb0
 CONFIG_TI_SECURE_EMIF_TOTAL_REGION_SIZE=0x0200
 CONFIG_TI_SECURE_EMIF_PROTECTED_REGION_SIZE=0x01c0
 CONFIG_TARGET_AM57XX_EVM=y
+CONFIG_DRA7_DSPEVE_OPP_HIGH=y
+CONFIG_DRA7_IVA_OPP_HIGH=y
 CONFIG_SPL=y
 CONFIG_ENV_OFFSET_REDUND=0x28
 CONFIG_SPL_SPI_FLASH_SUPPORT=y
diff --git a/configs/dra7xx_evm_defconfig b/configs/dra7xx_evm_defconfig
index 0c253da80cb9..71f6b0b6c3ff 100644
--- a/configs/dra7xx_evm_defconfig
+++ b/configs/dra7xx_evm_defconfig
@@ -9,6 +9,8 @@ CONFIG_DEFAULT_DEVICE_TREE="dra7-evm"
 CONFIG_SPL_TEXT_BASE=0x4030
 CONFIG_OMAP54XX=y
 CONFIG_TARGET_DRA7XX_EVM=y
+CONFIG_DRA7_DSPEVE_OPP_HIGH=y
+CONFIG_DRA7_IVA_OPP_HIGH=y
 CONFIG_SPL=y
 CONFIG_ENV_OFFSET_REDUND=0x28
 CONFIG_SPL_SPI_FLASH_SUPPORT=y
diff --git a/configs/dra7xx_hs_evm_defconfig b/configs/dra7xx_hs_evm_defconfig
index 885b236f1886..5462a79f10c5 100644
--- a/configs/dra7xx_hs_evm_defconfig
+++ b/configs/dra7xx_hs_evm_defconfig
@@ -12,6 +12,8 @@ CONFIG_TI_SECURE_EMIF_REGION_START=0xbdb0
 CONFIG_TI_SECURE_EMIF_TOTAL_REGION_SIZE=0x0200
 CONFIG_TI_SECURE_EMIF_PROTECTED_REGION_SIZE=0x01c0
 CONFIG_TARGET_DRA7XX_EVM=y
+CONFIG_DRA7_DSPEVE_OPP_HIGH=y
+CONFIG_DRA7_IVA_OPP_HIGH=y
 CONFIG_SPL=y
 CONFIG_ENV_OFFSET_REDUND=0x28
 CONFIG_SPL_SPI_FLASH_SUPPORT=y
diff --git a/configs/dra7xx_hs_evm_usb_defconfig 
b/configs/dra7xx_hs_evm_usb_defconfig
index efdd9f31c74a..eff9346221f4 100644
--- a/configs/dra7xx_hs_evm_usb_defconfig
+++ b/configs/dra7xx_hs_evm_usb_defconfig
@@ -14,6 +14,8 @@ CONFIG_TI_SECURE_EMIF_REGION_START=0xbdb0
 CONFIG_TI_SECURE_EMIF_TOTAL_REGION_SIZE=0x0200
 CONFIG_TI_SECURE_EMIF_PROTECTED_REGION_SIZE=0x01c0
 CONFIG_TARGET_DRA7XX_EVM=y
+CONFIG_DRA7_DSPEVE_OPP_HIGH=y
+CONFIG_DRA7_IVA_OPP_HIGH=y
 CONFIG_SPL=y
 CONFIG_ENV_OFFSET_REDUND=0x28
 CONFIG_SPL_SPI_FLASH_SUPPORT=y
-- 
2.25.1



[PATCH 0/2] ARM: DRA7: Enable OPP_HIGH for GPU, DSPEVE and IVA voltage domains

2021-09-27 Thread Amjad Ouled-Ameur
This patchset enables the OPP_HIGH configuration for GPU, DSPEVE and IVA
voltage domains by default for various TI DRA7xx and AM57xx boards. This
is being done to meet the performance needs of 1080p MultiMedia usecases

Amjad Ouled-Ameur (2):
  ARM: DRA7: Enable OPP_HIGH for DSPEVE and IVA voltage domains
  ARM: DRA7: Enable OPP_HIGH for GPU voltage domain

 configs/am57xx_evm_defconfig| 3 +++
 configs/am57xx_hs_evm_defconfig | 3 +++
 configs/am57xx_hs_evm_usb_defconfig | 3 +++
 configs/dra7xx_evm_defconfig| 3 +++
 configs/dra7xx_hs_evm_defconfig | 3 +++
 configs/dra7xx_hs_evm_usb_defconfig | 3 +++
 6 files changed, 18 insertions(+)

-- 
2.25.1



[PATCH 10/10] dts: am57xx*: Add ipu early boot DT changes

2021-09-23 Thread Amjad Ouled-Ameur
From: Keerthy 

Add support for ipu early boot.

Signed-off-by: Keerthy 
Signed-off-by: Amjad Ouled-Ameur 

---

 MAINTAINERS  | 1 +
 arch/arm/dts/am57xx-beagle-x15-revb1-u-boot.dtsi | 7 +++
 arch/arm/dts/am57xx-beagle-x15-revc-u-boot.dtsi  | 7 +++
 arch/arm/dts/am57xx-beagle-x15-u-boot.dtsi   | 7 +++
 arch/arm/dts/am57xx-cl-som-am57x-u-boot.dtsi | 7 +++
 arch/arm/dts/am57xx-sbc-am57x-u-boot.dtsi| 7 +++
 6 files changed, 36 insertions(+)
 create mode 100644 arch/arm/dts/am57xx-beagle-x15-revb1-u-boot.dtsi
 create mode 100644 arch/arm/dts/am57xx-beagle-x15-revc-u-boot.dtsi
 create mode 100644 arch/arm/dts/am57xx-beagle-x15-u-boot.dtsi
 create mode 100644 arch/arm/dts/am57xx-cl-som-am57x-u-boot.dtsi
 create mode 100644 arch/arm/dts/am57xx-sbc-am57x-u-boot.dtsi

diff --git a/MAINTAINERS b/MAINTAINERS
index 404ad283ff4a..c9ce9991c8b0 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -500,6 +500,7 @@ F:  arch/arm/mach-omap2/
 F: arch/arm/include/asm/arch-omap*/
 F: arch/arm/include/asm/ti-common/
 F: arch/arm/dts/dra7*
+F: arch/arm/dts/am57xx*
 F: board/ti/
 F: drivers/dma/ti*
 F: drivers/firmware/ti_sci.*
diff --git a/arch/arm/dts/am57xx-beagle-x15-revb1-u-boot.dtsi 
b/arch/arm/dts/am57xx-beagle-x15-revb1-u-boot.dtsi
new file mode 100644
index ..49b16215e528
--- /dev/null
+++ b/arch/arm/dts/am57xx-beagle-x15-revb1-u-boot.dtsi
@@ -0,0 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
+ */
+
+#include "omap5-u-boot.dtsi"
+#include "dra7-ipu-common-early-boot.dtsi"
diff --git a/arch/arm/dts/am57xx-beagle-x15-revc-u-boot.dtsi 
b/arch/arm/dts/am57xx-beagle-x15-revc-u-boot.dtsi
new file mode 100644
index ..49b16215e528
--- /dev/null
+++ b/arch/arm/dts/am57xx-beagle-x15-revc-u-boot.dtsi
@@ -0,0 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
+ */
+
+#include "omap5-u-boot.dtsi"
+#include "dra7-ipu-common-early-boot.dtsi"
diff --git a/arch/arm/dts/am57xx-beagle-x15-u-boot.dtsi 
b/arch/arm/dts/am57xx-beagle-x15-u-boot.dtsi
new file mode 100644
index ..49b16215e528
--- /dev/null
+++ b/arch/arm/dts/am57xx-beagle-x15-u-boot.dtsi
@@ -0,0 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
+ */
+
+#include "omap5-u-boot.dtsi"
+#include "dra7-ipu-common-early-boot.dtsi"
diff --git a/arch/arm/dts/am57xx-cl-som-am57x-u-boot.dtsi 
b/arch/arm/dts/am57xx-cl-som-am57x-u-boot.dtsi
new file mode 100644
index ..49b16215e528
--- /dev/null
+++ b/arch/arm/dts/am57xx-cl-som-am57x-u-boot.dtsi
@@ -0,0 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
+ */
+
+#include "omap5-u-boot.dtsi"
+#include "dra7-ipu-common-early-boot.dtsi"
diff --git a/arch/arm/dts/am57xx-sbc-am57x-u-boot.dtsi 
b/arch/arm/dts/am57xx-sbc-am57x-u-boot.dtsi
new file mode 100644
index ..49b16215e528
--- /dev/null
+++ b/arch/arm/dts/am57xx-sbc-am57x-u-boot.dtsi
@@ -0,0 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
+ */
+
+#include "omap5-u-boot.dtsi"
+#include "dra7-ipu-common-early-boot.dtsi"
-- 
2.25.1



[PATCH 06/10] remoteproc: ipu: Add driver to bring up ipu

2021-09-23 Thread Amjad Ouled-Ameur
From: Keerthy 

The driver enables IPU support. Basically enables the clocks,
timers, watchdog timers and bare minimal MMU and supports
loading the firmware from mmc.

Signed-off-by: Keerthy 
[Amjad: fix compile warnings]
Signed-off-by: Amjad Ouled-Ameur 
---

 MAINTAINERS|   1 +
 drivers/remoteproc/Kconfig |  10 +
 drivers/remoteproc/Makefile|   1 +
 drivers/remoteproc/ipu_rproc.c | 759 +
 4 files changed, 771 insertions(+)
 create mode 100644 drivers/remoteproc/ipu_rproc.c

diff --git a/MAINTAINERS b/MAINTAINERS
index ce6e7ef08252..9e93c2785cf9 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -515,6 +515,7 @@ F:  drivers/ram/k3*
 F: drivers/remoteproc/k3_system_controller.c
 F: drivers/remoteproc/pruc_rpoc.c
 F: drivers/remoteproc/ti*
+F: drivers/remoteproc/ipu_rproc.c
 F: drivers/reset/reset-ti-sci.c
 F: drivers/reset/reset-dra7.c
 F: drivers/rtc/davinci.c
diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
index 24e536463bbd..27e4a60ff5b1 100644
--- a/drivers/remoteproc/Kconfig
+++ b/drivers/remoteproc/Kconfig
@@ -92,4 +92,14 @@ config REMOTEPROC_TI_PRU
help
  Say 'y' here to add support for TI' K3 remoteproc driver.
 
+config REMOTEPROC_TI_IPU
+   bool "Support for TI's K3 based IPU remoteproc driver"
+   select REMOTEPROC
+   depends on DM
+   depends on SPL_DRIVERS_MISC
+   depends on SPL_FS_LOADER
+   depends on OF_CONTROL
+   help
+ Say 'y' here to add support for TI' K3 remoteproc driver.
+
 endmenu
diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile
index f0e83451d66f..fbe9c172bc04 100644
--- a/drivers/remoteproc/Makefile
+++ b/drivers/remoteproc/Makefile
@@ -15,3 +15,4 @@ obj-$(CONFIG_REMOTEPROC_TI_K3_DSP) += ti_k3_dsp_rproc.o
 obj-$(CONFIG_REMOTEPROC_TI_K3_R5F) += ti_k3_r5f_rproc.o
 obj-$(CONFIG_REMOTEPROC_TI_POWER) += ti_power_proc.o
 obj-$(CONFIG_REMOTEPROC_TI_PRU) += pru_rproc.o
+obj-$(CONFIG_REMOTEPROC_TI_IPU) += ipu_rproc.o
diff --git a/drivers/remoteproc/ipu_rproc.c b/drivers/remoteproc/ipu_rproc.c
new file mode 100644
index ..b4a06bc955a9
--- /dev/null
+++ b/drivers/remoteproc/ipu_rproc.c
@@ -0,0 +1,759 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * IPU remoteproc driver for various SoCs
+ *
+ * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
+ * Angela Stegmaier  
+ * Venkateswara Rao Mandela 
+ *  Keerthy 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define IPU1_LOAD_ADDR (0xa17ff000)
+#define MAX_REMOTECORE_BIN_SIZE (8 * 0x10)
+
+enum ipu_num {
+   IPU1 = 0,
+   IPU2,
+   RPROC_END_ENUMS,
+};
+
+#define IPU2_LOAD_ADDR (IPU1_LOAD_ADDR + MAX_REMOTECORE_BIN_SIZE)
+
+#define PAGE_SHIFT 12
+#define PAGESIZE_1M  0x0
+#define PAGESIZE_64K 0x1
+#define PAGESIZE_4K  0x2
+#define PAGESIZE_16M 0x3
+#define LE   0
+#define BE   1
+#define ELEMSIZE_8   0x0
+#define ELEMSIZE_16  0x1
+#define ELEMSIZE_32  0x2
+#define MIXED_TLB0x0
+#define MIXED_CPU0x1
+
+#define PGT_SMALLPAGE_SIZE   0x1000
+#define PGT_LARGEPAGE_SIZE   0x0001
+#define PGT_SECTION_SIZE 0x0010
+#define PGT_SUPERSECTION_SIZE0x0100
+
+#define PGT_L1_DESC_PAGE 0x1
+#define PGT_L1_DESC_SECTION  0x2
+#define PGT_L1_DESC_SUPERSECTION 0x40002
+
+#define PGT_L1_DESC_PAGE_MASK0xfC00
+#define PGT_L1_DESC_SECTION_MASK 0xfff0
+#define PGT_L1_DESC_SUPERSECTION_MASK0xff00
+
+#define PGT_L1_DESC_SMALLPAGE_INDEX_SHIFT12
+#define PGT_L1_DESC_LARGEPAGE_INDEX_SHIFT16
+#define PGT_L1_DESC_SECTION_INDEX_SHIFT  20
+#define PGT_L1_DESC_SUPERSECTION_INDEX_SHIFT 24
+
+#define PGT_L2_DESC_SMALLPAGE   0x02
+#define PGT_L2_DESC_LARGEPAGE   0x01
+
+#define PGT_L2_DESC_SMALLPAGE_MASK  0xf000
+#define PGT_L2_DESC_LARGEPAGE_MASK  0x
+
+/*
+ * The memory for the page tables (256 KB per IPU) is placed just before
+ * the carveout memories for the remote processors. 16 KB of memory is
+ * needed for the L1 page table (4096 entries * 4 bytes per 1 MB section).
+ * Any smaller page (64 KB or 4 KB) entries are supported through L2 page
+ * tables (1 KB per table). The remaining 240 KB can provide support for
+ * 240 L2 page tables. Any 

[PATCH 05/10] remoteproc: uclass: Add remoteproc resource handling helpers

2021-09-23 Thread Amjad Ouled-Ameur
From: Keerthy 

Add remoteproc resource handling helpers. These functions
are primarily to parse the resource table and to handle
different types of resources. Carveout, devmem, trace &
vring resources are handled.

Signed-off-by: Keerthy 
[Amjad: fix redefinition of "struct resource_table" and compile warnings ]
Signed-off-by: Amjad Ouled-Ameur 
---

 drivers/remoteproc/rproc-uclass.c | 562 ++
 include/remoteproc.h  | 384 +++-
 2 files changed, 945 insertions(+), 1 deletion(-)

diff --git a/drivers/remoteproc/rproc-uclass.c 
b/drivers/remoteproc/rproc-uclass.c
index 64c47c1e7225..3f7096045548 100644
--- a/drivers/remoteproc/rproc-uclass.c
+++ b/drivers/remoteproc/rproc-uclass.c
@@ -8,6 +8,7 @@
 
 #define pr_fmt(fmt) "%s: " fmt, __func__
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -19,9 +20,21 @@
 #include 
 #include 
 #include 
+#include 
 
 DECLARE_GLOBAL_DATA_PTR;
 
+struct resource_table {
+   u32 ver;
+   u32 num;
+   u32 reserved[2];
+   u32 offset[0];
+} __packed;
+
+typedef int (*handle_resource_t) (struct udevice *, void *, int offset, int 
avail);
+
+static struct resource_table *rsc_table;
+
 /**
  * for_each_remoteproc_device() - iterate through the list of rproc devices
  * @fn: check function to call per match, if this function returns fail,
@@ -208,6 +221,86 @@ static int rproc_post_probe(struct udevice *dev)
return 0;
 }
 
+/**
+ * rproc_add_res() - After parsing the resource table add the mappings
+ * @dev:   device we finished probing
+ * @mapping: rproc_mem_entry for the resource
+ *
+ * Return: if the remote proc driver has a add_res routine, invokes it and
+ * hands over the return value. overall, 0 if all went well, else appropriate
+ * error value.
+ */
+static int rproc_add_res(struct udevice *dev, struct rproc_mem_entry *mapping)
+{
+   const struct dm_rproc_ops *ops;
+
+   ops = rproc_get_ops(dev);
+   if (!ops) {
+   debug("%s driver has no ops?\n", dev->name);
+   return -EINVAL;
+   }
+
+   if (ops->add_res)
+   return ops->add_res(dev, mapping);
+
+   return 0;
+}
+
+/**
+ * rproc_alloc_mem() - After parsing the resource table allocat mem
+ * @dev:   device we finished probing
+ * @len: rproc_mem_entry for the resource
+ * @align: alignment for the resource
+ *
+ * Return: if the remote proc driver has a add_res routine, invokes it and
+ * hands over the return value. overall, 0 if all went well, else appropriate
+ * error value.
+ */
+static void *rproc_alloc_mem(struct udevice *dev, unsigned long len,
+unsigned long align)
+{
+   const struct dm_rproc_ops *ops;
+
+   ops = rproc_get_ops(dev);
+   if (!ops) {
+   debug("%s driver has no ops?\n", dev->name);
+   return NULL;
+   }
+
+   if (ops->alloc_mem)
+   return ops->alloc_mem(dev, len, align);
+
+   return NULL;
+}
+
+/**
+ * rproc_config_pagetable() - Configure page table for remote processor
+ * @dev:   device we finished probing
+ * @virt: Virtual address of the resource
+ * @phys: Physical address the resource
+ * @len: length the resource
+ *
+ * Return: if the remote proc driver has a add_res routine, invokes it and
+ * hands over the return value. overall, 0 if all went well, else appropriate
+ * error value.
+ */
+static int rproc_config_pagetable(struct udevice *dev, unsigned int virt,
+ unsigned int phys, unsigned int len)
+{
+   const struct dm_rproc_ops *ops;
+
+   ops = rproc_get_ops(dev);
+   if (!ops) {
+   debug("%s driver has no ops?\n", dev->name);
+   return -EINVAL;
+   }
+
+   if (ops->config_pagetable)
+   return ops->config_pagetable(dev, virt, phys, len);
+
+   return 0;
+}
+
 UCLASS_DRIVER(rproc) = {
.id = UCLASS_REMOTEPROC,
.name = "remoteproc",
@@ -438,3 +531,472 @@ int rproc_is_running(int id)
 {
return _rproc_ops_wrapper(id, RPROC_RUNNING);
 };
+
+/*
+ * Virtio ring descriptors: 16 bytes.  These can chain together via
+ * "next".
+ */
+struct vring_desc {
+   u64 addr;
+   u32 len;
+   u16 flags;
+   u16 next;
+};
+
+/*
+ * u32 is used here for ids for padding reasons.
+ */
+struct vring_used_elem {
+   u32 id;
+   u32 len;
+};
+
+static unsigned int vring_size(unsigned int num, unsigned long align)
+{
+   return ((sizeof(struct vring_desc) * num + sizeof(u16) * (3 + num)
++ align - 1) & ~(align - 1))
+   + sizeof(u16) * 3 + sizeof(struct vring_used_elem) * num;
+}
+
+static int handle_trace(struct udevice *dev, struct fw_rsc_trace *rsc,
+   int offset, int avail)
+{
+   if (sizeof(*rsc) > avail) {
+   debug("trace rsc is tru

[PATCH 09/10] arm: dts: dra7*/am57xx-idk-evm-u-boot: Add ipu early boot DT changes

2021-09-23 Thread Amjad Ouled-Ameur
From: Keerthy 

Add support for ipu early boot.

Signed-off-by: Keerthy 
Signed-off-by: Amjad Ouled-Ameur 
---

 arch/arm/dts/am57xx-idk-common-u-boot.dtsi | 1 +
 arch/arm/dts/dra7-evm-u-boot.dtsi  | 1 +
 arch/arm/dts/dra71-evm-u-boot.dtsi | 1 +
 arch/arm/dts/dra72-evm-revc-u-boot.dtsi| 1 +
 arch/arm/dts/dra76-evm-u-boot.dtsi | 1 +
 5 files changed, 5 insertions(+)

diff --git a/arch/arm/dts/am57xx-idk-common-u-boot.dtsi 
b/arch/arm/dts/am57xx-idk-common-u-boot.dtsi
index b07aea0048d5..d0ce469f9189 100644
--- a/arch/arm/dts/am57xx-idk-common-u-boot.dtsi
+++ b/arch/arm/dts/am57xx-idk-common-u-boot.dtsi
@@ -3,6 +3,7 @@
  * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
  */
 #include "omap5-u-boot.dtsi"
+#include "dra7-ipu-common-early-boot.dtsi"
 
 / {
xtal25mhz: xtal25mhz {
diff --git a/arch/arm/dts/dra7-evm-u-boot.dtsi 
b/arch/arm/dts/dra7-evm-u-boot.dtsi
index f06c701dbd1f..5622512b2401 100644
--- a/arch/arm/dts/dra7-evm-u-boot.dtsi
+++ b/arch/arm/dts/dra7-evm-u-boot.dtsi
@@ -4,6 +4,7 @@
  */
 
 #include "omap5-u-boot.dtsi"
+#include "dra7-ipu-common-early-boot.dtsi"
 
 _gpio_21{
u-boot,i2c-offset-len = <0>;
diff --git a/arch/arm/dts/dra71-evm-u-boot.dtsi 
b/arch/arm/dts/dra71-evm-u-boot.dtsi
index b56d4fc9d896..40443da5c855 100644
--- a/arch/arm/dts/dra71-evm-u-boot.dtsi
+++ b/arch/arm/dts/dra71-evm-u-boot.dtsi
@@ -4,6 +4,7 @@
  */
 
 #include "omap5-u-boot.dtsi"
+#include "dra7-ipu-common-early-boot.dtsi"
 
 _gpio_21{
u-boot,i2c-offset-len = <0>;
diff --git a/arch/arm/dts/dra72-evm-revc-u-boot.dtsi 
b/arch/arm/dts/dra72-evm-revc-u-boot.dtsi
index b56d4fc9d896..40443da5c855 100644
--- a/arch/arm/dts/dra72-evm-revc-u-boot.dtsi
+++ b/arch/arm/dts/dra72-evm-revc-u-boot.dtsi
@@ -4,6 +4,7 @@
  */
 
 #include "omap5-u-boot.dtsi"
+#include "dra7-ipu-common-early-boot.dtsi"
 
 _gpio_21{
u-boot,i2c-offset-len = <0>;
diff --git a/arch/arm/dts/dra76-evm-u-boot.dtsi 
b/arch/arm/dts/dra76-evm-u-boot.dtsi
index a4dfbe7e601a..5fae6ba91936 100644
--- a/arch/arm/dts/dra76-evm-u-boot.dtsi
+++ b/arch/arm/dts/dra76-evm-u-boot.dtsi
@@ -4,6 +4,7 @@
  */
 
 #include "omap5-u-boot.dtsi"
+#include "dra7-ipu-common-early-boot.dtsi"
 
 _emac0 {
phy-handle = <_0>;
-- 
2.25.1



[PATCH 07/10] dts: dra7-ipu-common-early-boot.dtsi: Add all the ipu early boot related nodes

2021-09-23 Thread Amjad Ouled-Ameur
From: Keerthy 

Add all the ipu early boot related nodes

Signed-off-by: Keerthy 
Signed-off-by: Amjad Ouled-Ameur 
---

 MAINTAINERS  |   1 +
 arch/arm/dts/dra7-ipu-common-early-boot.dtsi | 113 +++
 2 files changed, 114 insertions(+)
 create mode 100644 arch/arm/dts/dra7-ipu-common-early-boot.dtsi

diff --git a/MAINTAINERS b/MAINTAINERS
index 9e93c2785cf9..404ad283ff4a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -499,6 +499,7 @@ F:  arch/arm/mach-keystone/
 F: arch/arm/mach-omap2/
 F: arch/arm/include/asm/arch-omap*/
 F: arch/arm/include/asm/ti-common/
+F: arch/arm/dts/dra7*
 F: board/ti/
 F: drivers/dma/ti*
 F: drivers/firmware/ti_sci.*
diff --git a/arch/arm/dts/dra7-ipu-common-early-boot.dtsi 
b/arch/arm/dts/dra7-ipu-common-early-boot.dtsi
new file mode 100644
index ..ec6040ff93eb
--- /dev/null
+++ b/arch/arm/dts/dra7-ipu-common-early-boot.dtsi
@@ -0,0 +1,113 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
+ */
+
+/ {
+   chosen {
+   firmware-loader = _loader0;
+   };
+
+   fs_loader0: fs_loader@0 {
+   u-boot,dm-pre-reloc;
+   compatible = "u-boot,fs-loader";
+   phandlepart = < 1>;
+   };
+
+   reserved-memory {
+   #address-cells = <2>;
+   #size-cells = <2>;
+   ranges;
+   u-boot,dm-spl;
+
+   ipu2_memory_region: ipu2-memory@9580 {
+   compatible = "shared-dma-pool";
+   reg = <0x0 0x9580 0x0 0x380>;
+   reusable;
+   status = "okay";
+   u-boot,dm-spl;
+   };
+
+   ipu1_memory_region: ipu1-memory@9d00 {
+   compatible = "shared-dma-pool";
+   reg = <0x0 0x9d00 0x0 0x200>;
+   reusable;
+   status = "okay";
+   u-boot,dm-spl;
+   };
+
+   ipu1_pgtbl: ipu1-pgtbl@9570 {
+   reg = <0x0 0x9570 0x0 0x4>;
+   no-map;
+   u-boot,dm-spl;
+   };
+
+   ipu2_pgtbl: ipu2-pgtbl@9574 {
+   reg = <0x0 0x9574 0x0 0x4>;
+   no-map;
+   u-boot,dm-spl;
+   };
+   };
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+_ipu1 {
+   u-boot,dm-spl;
+};
+
+_ipu2 {
+   u-boot,dm-spl;
+};
+
+ {
+   status = "okay";
+   memory-region = <_memory_region>;
+   pg-tbl = <_pgtbl>;
+   u-boot,dm-spl;
+};
+
+ {
+   status = "okay";
+   memory-region = <_memory_region>;
+   pg-tbl = <_pgtbl>;
+   u-boot,dm-spl;
+};
+
+_wkup {
+   u-boot,dm-spl;
+};
+
+ {
+   u-boot,dm-spl;
+};
+
+_rst {
+   u-boot,dm-spl;
+};
+
+_rst {
+   u-boot,dm-spl;
+};
-- 
2.25.1



[PATCH 08/10] arm: dts: dra7: Add ipu and related nodes

2021-09-23 Thread Amjad Ouled-Ameur
From: Keerthy 

Add ipu and the associated nodes.

Signed-off-by: Keerthy 
Signed-off-by: Amjad Ouled-Ameur 
---

 arch/arm/dts/dra7.dtsi | 45 +-
 1 file changed, 44 insertions(+), 1 deletion(-)

diff --git a/arch/arm/dts/dra7.dtsi b/arch/arm/dts/dra7.dtsi
index fd1aea0b1b16..e2e958b36626 100644
--- a/arch/arm/dts/dra7.dtsi
+++ b/arch/arm/dts/dra7.dtsi
@@ -41,6 +41,8 @@
d_can0 = 
d_can1 = 
spi0 = 
+   remoteproc0 = 
+   remoteproc1 = 
};
 
timer {
@@ -263,9 +265,12 @@
};
 
prm: prm@6000 {
-   compatible = "ti,dra7-prm";
+   compatible = "ti,dra7-prm", "simple-bus";
reg = <0x6000 0x3000>;
interrupts = ;
+   #address-cells = <1>;
+   #size-cells = <1>;
+   ranges = <0 0x6000 0x3000>;
 
prm_clocks: clocks {
#address-cells = <1>;
@@ -274,6 +279,20 @@
 
prm_clockdomains: clockdomains {
};
+
+   ipu1_rst: ipu1_rst@510 {
+   compatible = "ti,dra7-reset";
+   reg = <0x510 0x8>;
+   ti,nresets = <3>;
+   #reset-cells = <1>;
+   };
+
+   ipu2_rst: ipu2_rst@910 {
+   compatible = "ti,dra7-reset";
+   reg = <0x910 0x8>;
+   ti,nresets = <3>;
+   #reset-cells = <1>;
+   };
};
 
scm_wkup: scm_conf@c000 {
@@ -2032,6 +2051,30 @@
clocks = <_iclk_div>;
clock-names = "fck";
};
+
+   ipu1: ipu@5882 {
+   compatible = "ti,dra7-ipu";
+   reg = <0x5882 0x1>;
+   reg-names = "l2ram";
+   ti,hwmods = "ipu1";
+   resets = <_rst 0>, <_rst 1>, <_rst 2>;
+   iommus = <_ipu1>;
+   ti,rproc-standby-info = <0x4a005520>;
+   timers = <>;
+   watchdog-timers = <>, <>;
+   };
+
+   ipu2: ipu@5502 {
+   compatible = "ti,dra7-ipu";
+   reg = <0x5502 0x1>;
+   reg-names = "l2ram";
+   ti,hwmods = "ipu2";
+   resets = <_rst 0>, <_rst 1>, <_rst 2>;
+   iommus = <_ipu2>;
+   ti,rproc-standby-info = <0x4a008920>;
+   timers = <>;
+   watchdog-timers = <>, <>;
+   };
};
 
thermal_zones: thermal-zones {
-- 
2.25.1



[PATCH 04/10] linux: bitmap.h: Add find_next_zero_area function

2021-09-23 Thread Amjad Ouled-Ameur
From: Keerthy 

Add find_next_zero_area to fetch the next zero area in the map.

Signed-off-by: Keerthy 
Signed-off-by: Amjad Ouled-Ameur 
---

 include/linux/bitmap.h | 26 ++
 1 file changed, 26 insertions(+)

diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
index dae4225be549..0a8503af9f14 100644
--- a/include/linux/bitmap.h
+++ b/include/linux/bitmap.h
@@ -159,6 +159,32 @@ static inline unsigned long find_first_bit(const unsigned 
long *addr, unsigned l
 (bit) < (size);\
 (bit) = find_next_bit((addr), (size), (bit) + 1))
 
+static inline unsigned long
+bitmap_find_next_zero_area(unsigned long *map,
+  unsigned long size,
+  unsigned long start,
+  unsigned int nr, unsigned long align_mask)
+{
+   unsigned long index, end, i;
+again:
+   index = find_next_zero_bit(map, size, start);
+
+   /*
+* Align allocation
+*/
+   index = (index + align_mask) & ~align_mask;
+
+   end = index + nr;
+   if (end > size)
+   return end;
+   i = find_next_bit(map, end, index);
+   if (i < end) {
+   start = i + 1;
+   goto again;
+   }
+   return index;
+}
+
 static inline void bitmap_fill(unsigned long *dst, unsigned int nbits)
 {
if (small_const_nbits(nbits)) {
-- 
2.25.1



[PATCH 03/10] drivers: misc: Makefile: Enable fs_loader compilation at SPL Level

2021-09-23 Thread Amjad Ouled-Ameur
From: Keerthy 

Enable fs_loader compilation at SPL Level.

Signed-off-by: Keerthy 
[Amjad: fix compilation failures for J721e platform]
Signed-off-by: Amjad Ouled-Ameur 
---

 arch/arm/mach-k3/common.c | 10 +++---
 configs/j721e_evm_r5_defconfig|  1 +
 configs/j721e_hs_evm_r5_defconfig |  1 +
 drivers/misc/Kconfig  |  9 +
 drivers/misc/Makefile |  2 +-
 5 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/arch/arm/mach-k3/common.c b/arch/arm/mach-k3/common.c
index 2666cd2d7b17..dddad8e3b056 100644
--- a/arch/arm/mach-k3/common.c
+++ b/arch/arm/mach-k3/common.c
@@ -156,13 +156,15 @@ void init_env(void)
 #endif
 }
 
-#ifdef CONFIG_FS_LOADER
 int load_firmware(char *name_fw, char *name_loadaddr, u32 *loadaddr)
 {
struct udevice *fsdev;
char *name = NULL;
int size = 0;
 
+   if (!IS_ENABLED(CONFIG_FS_LOADER))
+   return 0;
+
*loadaddr = 0;
 #ifdef CONFIG_SPL_ENV_SUPPORT
switch (spl_boot_device()) {
@@ -186,12 +188,6 @@ int load_firmware(char *name_fw, char *name_loadaddr, u32 
*loadaddr)
 
return size;
 }
-#else
-int load_firmware(char *name_fw, char *name_loadaddr, u32 *loadaddr)
-{
-   return 0;
-}
-#endif
 
 __weak void release_resources_for_core_shutdown(void)
 {
diff --git a/configs/j721e_evm_r5_defconfig b/configs/j721e_evm_r5_defconfig
index b5fd3bf23734..edc003f46b90 100644
--- a/configs/j721e_evm_r5_defconfig
+++ b/configs/j721e_evm_r5_defconfig
@@ -88,6 +88,7 @@ CONFIG_SYS_I2C_OMAP24XX=y
 CONFIG_DM_MAILBOX=y
 CONFIG_K3_SEC_PROXY=y
 CONFIG_FS_LOADER=y
+CONFIG_SPL_FS_LOADER=y
 CONFIG_ESM_K3=y
 CONFIG_K3_AVS0=y
 CONFIG_ESM_PMIC=y
diff --git a/configs/j721e_hs_evm_r5_defconfig 
b/configs/j721e_hs_evm_r5_defconfig
index 3a8e0b1cd15b..6c3675c1726c 100644
--- a/configs/j721e_hs_evm_r5_defconfig
+++ b/configs/j721e_hs_evm_r5_defconfig
@@ -82,6 +82,7 @@ CONFIG_SYS_I2C_OMAP24XX=y
 CONFIG_DM_MAILBOX=y
 CONFIG_K3_SEC_PROXY=y
 CONFIG_FS_LOADER=y
+CONFIG_SPL_FS_LOADER=y
 CONFIG_K3_AVS0=y
 CONFIG_MMC_SDHCI=y
 CONFIG_SPL_MMC_SDHCI_ADMA=y
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 997b71322110..e6a1dc677d6e 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -468,6 +468,15 @@ config FS_LOADER
  The consumer driver would then use this loader to program whatever,
  ie. the FPGA device.
 
+config SPL_FS_LOADER
+   bool "Enable loader driver for file system"
+   help
+ This is file system generic loader which can be used to load
+ the file image from the storage into target such as memory.
+
+ The consumer driver would then use this loader to program whatever,
+ ie. the FPGA device.
+
 config GDSYS_SOC
bool "Enable gdsys SOC driver"
depends on MISC
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index b64cd2a4de91..c7c95ee76767 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -37,7 +37,7 @@ obj-$(CONFIG_FSL_IFC) += fsl_ifc.o
 obj-$(CONFIG_FSL_IIM) += fsl_iim.o
 obj-$(CONFIG_FSL_MC9SDZ60) += mc9sdz60.o
 obj-$(CONFIG_FSL_SEC_MON) += fsl_sec_mon.o
-obj-$(CONFIG_FS_LOADER) += fs_loader.o
+obj-$(CONFIG_$(SPL_)FS_LOADER) += fs_loader.o
 obj-$(CONFIG_GDSYS_IOEP) += gdsys_ioep.o
 obj-$(CONFIG_GDSYS_RXAUI_CTRL) += gdsys_rxaui_ctrl.o
 obj-$(CONFIG_GDSYS_SOC) += gdsys_soc.o
-- 
2.25.1



[PATCH 02/10] arm: mach-omap2: load/start remoteproc IPU1/IPU2

2021-09-23 Thread Amjad Ouled-Ameur
From: Keerthy 

First check the presence of the ipu firmware in the boot partition.
If present enable the ipu and the related clocks & then move
on to load the firmware and eventually start remoteproc IPU1/IPU2.

do_enable_clocks by default puts the clock domains into auto
which does not work well with reset. Hence adding do_enable_ipu_clocks
function.

Signed-off-by: Keerthy 
[Amjad: fix IPU1_LOAD_ADDR and compile warnings]
Signed-off-by: Amjad Ouled-Ameur 
---

 arch/arm/include/asm/arch-omap5/clock.h |  3 +
 arch/arm/include/asm/omap_common.h  | 10 +++
 arch/arm/mach-omap2/boot-common.c   | 95 +
 arch/arm/mach-omap2/clocks-common.c | 33 +
 arch/arm/mach-omap2/omap5/hw_data.c | 92 ++--
 arch/arm/mach-omap2/omap5/prcm-regs.c   |  9 ++-
 6 files changed, 235 insertions(+), 7 deletions(-)

diff --git a/arch/arm/include/asm/arch-omap5/clock.h 
b/arch/arm/include/asm/arch-omap5/clock.h
index 87eb3f335ab0..a00626e357c9 100644
--- a/arch/arm/include/asm/arch-omap5/clock.h
+++ b/arch/arm/include/asm/arch-omap5/clock.h
@@ -135,6 +135,9 @@
 #define HSMMC_CLKCTRL_CLKSEL_MASK  (1 << 24)
 #define HSMMC_CLKCTRL_CLKSEL_DIV_MASK  (3 << 25)
 
+/* CM_IPU1_IPU1_CLKCTRL CLKSEL MASK */
+#define IPU1_CLKCTRL_CLKSEL_MASK   BIT(24)
+
 /* CM_L3INIT_SATA_CLKCTRL */
 #define SATA_CLKCTRL_OPTFCLKEN_MASK(1 << 8)
 
diff --git a/arch/arm/include/asm/omap_common.h 
b/arch/arm/include/asm/omap_common.h
index de8fc99d0478..264a2e717a70 100644
--- a/arch/arm/include/asm/omap_common.h
+++ b/arch/arm/include/asm/omap_common.h
@@ -362,6 +362,10 @@ struct prcm_regs {
/* IPU */
u32 cm_ipu_clkstctrl;
u32 cm_ipu_i2c5_clkctrl;
+   u32 cm_ipu1_clkstctrl;
+   u32 cm_ipu1_ipu1_clkctrl;
+   u32 cm_ipu2_clkstctrl;
+   u32 cm_ipu2_ipu2_clkctrl;
 
/*l3main1 edma*/
u32 cm_l3main1_tptc1_clkctrl;
@@ -632,6 +636,12 @@ void do_disable_clocks(u32 const *clk_domains,
   u8 wait_for_disable);
 #endif /* CONFIG_OMAP44XX || CONFIG_OMAP54XX */
 
+void do_enable_ipu_clocks(u32 const *clk_domains,
+ u32 const *clk_modules_hw_auto,
+ u32 const *clk_modules_explicit_en,
+ u8 wait_for_enable);
+void enable_ipu1_clocks(void);
+void enable_ipu2_clocks(void);
 void setup_post_dividers(u32 const base,
const struct dpll_params *params);
 u32 omap_ddr_clk(void);
diff --git a/arch/arm/mach-omap2/boot-common.c 
b/arch/arm/mach-omap2/boot-common.c
index 7cdf7f158981..2bf4aff74c3a 100644
--- a/arch/arm/mach-omap2/boot-common.c
+++ b/arch/arm/mach-omap2/boot-common.c
@@ -10,6 +10,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -19,9 +21,14 @@
 #include 
 #include 
 #include 
+#include 
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#define IPU1_LOAD_ADDR (0xa17ff000)
+#define MAX_REMOTECORE_BIN_SIZE (8 * 0x10)
+#define IPU2_LOAD_ADDR (IPU1_LOAD_ADDR + MAX_REMOTECORE_BIN_SIZE)
+
 __weak u32 omap_sys_boot_device(void)
 {
return BOOT_DEVICE_NONE;
@@ -194,6 +201,91 @@ u32 spl_mmc_boot_mode(const u32 boot_device)
return gd->arch.omap_boot_mode;
 }
 
+int load_firmware(char *name_fw, u32 *loadaddr)
+{
+   struct udevice *fsdev;
+   int size = 0;
+
+   if (!IS_ENABLED(CONFIG_FS_LOADER))
+   return 0;
+
+   if (!*loadaddr)
+   return 0;
+
+   if (!uclass_get_device(UCLASS_FS_FIRMWARE_LOADER, 0, )) {
+   size = request_firmware_into_buf(fsdev, name_fw,
+(void *)*loadaddr, 0, 0);
+   }
+
+   return size;
+}
+
+void spl_boot_ipu(void)
+{
+   int ret, size;
+   u32 loadaddr = IPU1_LOAD_ADDR;
+
+   if (!IS_ENABLED(CONFIG_SPL_BUILD) ||
+   !IS_ENABLED(CONFIG_REMOTEPROC_TI_IPU))
+   return;
+
+   size = load_firmware("dra7-ipu1-fw.xem4", );
+   if (size <= 0) {
+   pr_err("Firmware loading failed\n");
+   goto skip_ipu1;
+   }
+
+   enable_ipu1_clocks();
+   ret = rproc_dev_init(0);
+   if (ret) {
+   debug("%s: IPU1 failed to initialize on rproc (%d)\n",
+ __func__, ret);
+   goto skip_ipu1;
+   }
+
+   ret = rproc_load(0, IPU1_LOAD_ADDR, 0x200);
+   if (ret) {
+   debug("%s: IPU1 failed to load on rproc (%d)\n", __func__,
+ ret);
+   goto skip_ipu1;
+   }
+
+   debug("Starting IPU1...\n");
+
+   ret = rproc_start(0);
+   if (ret)
+   debug("%s: IPU1 failed to start (%d)\n", __func__, ret);
+
+skip_ipu1:
+   loadaddr = IPU2_LOAD_ADDR;
+   size = load_firmware("dra7-ipu2-fw.xem4", );
+   if 

[PATCH 01/10] reset: dra7: Add a reset driver

2021-09-23 Thread Amjad Ouled-Ameur
From: Keerthy 

Add a reset driver to bring IPs out of reset.

Signed-off-by: Keerthy 
[Amjad: reset_ops structure member "free" has been renamed to "rfree",
use the latter instead]
Signed-off-by: Amjad Ouled-Ameur 
---

 MAINTAINERS|  1 +
 drivers/reset/Kconfig  |  6 +++
 drivers/reset/Makefile |  1 +
 drivers/reset/reset-dra7.c | 97 ++
 4 files changed, 105 insertions(+)
 create mode 100644 drivers/reset/reset-dra7.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 67c96a604546..ce6e7ef08252 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -516,6 +516,7 @@ F:  drivers/remoteproc/k3_system_controller.c
 F: drivers/remoteproc/pruc_rpoc.c
 F: drivers/remoteproc/ti*
 F: drivers/reset/reset-ti-sci.c
+F: drivers/reset/reset-dra7.c
 F: drivers/rtc/davinci.c
 F: drivers/serial/serial_omap.c
 F: drivers/soc/ti/
diff --git a/drivers/reset/Kconfig b/drivers/reset/Kconfig
index d73daf5e3189..b57714111b5a 100644
--- a/drivers/reset/Kconfig
+++ b/drivers/reset/Kconfig
@@ -206,4 +206,10 @@ config RESET_ZYNQMP
  passing request via Xilinx firmware interface to TF-A and PMU
  firmware.
 
+config RESET_DRA7
+   bool "Support for TI's DRA7 Reset driver"
+   depends on DM_RESET
+   help
+ Support for TI DRA7-RESET subsystem. Basic Assert/Deassert
+ is supported.
 endmenu
diff --git a/drivers/reset/Makefile b/drivers/reset/Makefile
index d69486bdeb9e..97e3a782c0d8 100644
--- a/drivers/reset/Makefile
+++ b/drivers/reset/Makefile
@@ -30,3 +30,4 @@ obj-$(CONFIG_RESET_SYSCON) += reset-syscon.o
 obj-$(CONFIG_RESET_RASPBERRYPI) += reset-raspberrypi.o
 obj-$(CONFIG_RESET_SCMI) += reset-scmi.o
 obj-$(CONFIG_RESET_ZYNQMP) += reset-zynqmp.o
+obj-$(CONFIG_RESET_DRA7) += reset-dra7.o
diff --git a/drivers/reset/reset-dra7.c b/drivers/reset/reset-dra7.c
new file mode 100644
index ..585f8323c52e
--- /dev/null
+++ b/drivers/reset/reset-dra7.c
@@ -0,0 +1,97 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Texas Instruments DRA7 reset driver
+ *
+ * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
+ * Author: Keerthy 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct dra7_reset_priv {
+   u32 rstctrl;
+   u32 rstst;
+   u8 nreset;
+};
+
+static int dra7_reset_request(struct reset_ctl *reset_ctl)
+{
+   return 0;
+}
+
+static int dra7_reset_free(struct reset_ctl *reset_ctl)
+{
+   return 0;
+}
+
+static inline void dra7_reset_rmw(u32 addr, u32 value, u32 mask)
+{
+   writel(((readl(addr) & (~mask)) | (value & mask)), addr);
+}
+
+static int dra7_reset_deassert(struct reset_ctl *reset_ctl)
+{
+   struct dra7_reset_priv *priv = dev_get_priv(reset_ctl->dev);
+   int mask = 1 << reset_ctl->id;
+
+   if (reset_ctl->id < 0 || reset_ctl->id >= priv->nreset)
+   return -EINVAL;
+
+   dra7_reset_rmw(priv->rstctrl, 0x0, mask);
+
+   while ((readl(priv->rstst) & mask) != mask)
+   ;
+
+   return 0;
+}
+
+static int dra7_reset_assert(struct reset_ctl *reset_ctl)
+{
+   struct dra7_reset_priv *priv = dev_get_priv(reset_ctl->dev);
+   int mask = 1 << reset_ctl->id;
+
+   if (reset_ctl->id < 0 || reset_ctl->id >= priv->nreset)
+   return -EINVAL;
+
+   dra7_reset_rmw(priv->rstctrl, mask, 0x0);
+
+   return 0;
+}
+
+struct reset_ops dra7_reset_ops = {
+   .request = dra7_reset_request,
+   .rfree = dra7_reset_free,
+   .rst_assert = dra7_reset_assert,
+   .rst_deassert = dra7_reset_deassert,
+};
+
+static const struct udevice_id dra7_reset_ids[] = {
+   { .compatible = "ti,dra7-reset" },
+   { }
+};
+
+static int dra7_reset_probe(struct udevice *dev)
+{
+   struct dra7_reset_priv *priv = dev_get_priv(dev);
+
+   priv->rstctrl = dev_read_addr(dev);
+   priv->rstst = priv->rstctrl + 0x4;
+   priv->nreset = dev_read_u32_default(dev, "ti,nresets", 1);
+
+   dev_info(dev, "dra7-reset successfully probed %s\n", dev->name);
+
+   return 0;
+}
+
+U_BOOT_DRIVER(dra7_reset) = {
+   .name = "dra7_reset",
+   .id = UCLASS_RESET,
+   .of_match = dra7_reset_ids,
+   .probe = dra7_reset_probe,
+   .ops = _reset_ops,
+   .priv_auto = sizeof(struct dra7_reset_priv),
+};
-- 
2.25.1



[PATCH 00/10] dra7: bring up and support IPU load/start

2021-09-23 Thread Amjad Ouled-Ameur
This patchset enables support for loading and starting IPU firmware,
the following have been implemented:
- Enable fs_loader compilation at SPL Level, that is necessary in order
  to load IPU firmware from /boot partition.
- Define necessary related IPU dts nodes.
- Add necessary drivers and helpers to bring up, load and start IPU
  firmware.

The underlying patches are interdependent, therefore should be applied
in the order they are numbered in this patchset.

Tests:
- Please find SPL, u-boot and kernel console logs in here [0]
- At SPL stage, debug logs have been enabled to make sure that
IPU1 and IPU2 are loaded and started properly. In fact, these two log
messages are only displayed when the firmware has been loaded, and if no
errors appear afterwards, it means that firmware started successfully as
well:
  - Starting IPU1...
  - Starting IPU2...

At U-boot stage, "rproc" command-line tool was used for the testing. In
the logs [0], "rproc list" was run before and after IPU1 and IPU2 are
initialized by "rproc init". The before run gave an empty list, while
the after run listed successfully the two IPUs with their correct
addresses:
  - 0 - Name:'ipu@5882' type:'internal memory mapped'
  - 1 - Name:'ipu@5502' type:'internal memory mapped'

"rproc start" and "rproc stop" were also used for both IPU1 and IPU2,
both were successful as no error logs were displayed.

[0]: https://pastebin.com/puCZ5GSm

These U-boot/SPL flags have been purposely enabled during tests to ensure
IPU load/start work properly:
- CONFIG_DM_RESET=y
- CONFIG_RESET_DRA7=y
- CONFIG_SPL_DM_RESET=y
- CONFIG_FS_LOADER=y
- CONFIG_SPL_FS_LOADER=y
- CONFIG_SPL_DRIVERS_MISC_SUPPORT=y
- CONFIG_REMOTEPROC_TI_IPU=y
- CONFIG_SPL_REMOTEPROC=y
- CONFIG_CMD_REMOTEPROC=y



Keerthy (10):
  reset: dra7: Add a reset driver
  arm: mach-omap2: load/start remoteproc IPU1/IPU2
  drivers: misc: Makefile: Enable fs_loader compilation at SPL Level
  linux: bitmap.h: Add find_next_zero_area function
  remoteproc: uclass: Add remoteproc resource handling helpers
  remoteproc: ipu: Add driver to bring up ipu
  dts: dra7-ipu-common-early-boot.dtsi: Add all the ipu early boot
related nodes
  arm: dts: dra7: Add ipu and related nodes
  arm: dts: dra7*/am57xx-idk-evm-u-boot: Add ipu early boot DT changes
  dts: am57xx*: Add ipu early boot DT changes

 MAINTAINERS   |   4 +
 .../dts/am57xx-beagle-x15-revb1-u-boot.dtsi   |   7 +
 .../dts/am57xx-beagle-x15-revc-u-boot.dtsi|   7 +
 arch/arm/dts/am57xx-beagle-x15-u-boot.dtsi|   7 +
 arch/arm/dts/am57xx-cl-som-am57x-u-boot.dtsi  |   7 +
 arch/arm/dts/am57xx-idk-common-u-boot.dtsi|   1 +
 arch/arm/dts/am57xx-sbc-am57x-u-boot.dtsi |   7 +
 arch/arm/dts/dra7-evm-u-boot.dtsi |   1 +
 arch/arm/dts/dra7-ipu-common-early-boot.dtsi  | 113 +++
 arch/arm/dts/dra7.dtsi|  45 +-
 arch/arm/dts/dra71-evm-u-boot.dtsi|   1 +
 arch/arm/dts/dra72-evm-revc-u-boot.dtsi   |   1 +
 arch/arm/dts/dra76-evm-u-boot.dtsi|   1 +
 arch/arm/include/asm/arch-omap5/clock.h   |   3 +
 arch/arm/include/asm/omap_common.h|  10 +
 arch/arm/mach-k3/common.c |  10 +-
 arch/arm/mach-omap2/boot-common.c |  95 +++
 arch/arm/mach-omap2/clocks-common.c   |  33 +
 arch/arm/mach-omap2/omap5/hw_data.c   |  92 ++-
 arch/arm/mach-omap2/omap5/prcm-regs.c |   9 +-
 configs/j721e_evm_r5_defconfig|   1 +
 configs/j721e_hs_evm_r5_defconfig |   1 +
 drivers/misc/Kconfig  |   9 +
 drivers/misc/Makefile |   2 +-
 drivers/remoteproc/Kconfig|  10 +
 drivers/remoteproc/Makefile   |   1 +
 drivers/remoteproc/ipu_rproc.c| 759 ++
 drivers/remoteproc/rproc-uclass.c | 562 +
 drivers/reset/Kconfig |   6 +
 drivers/reset/Makefile|   1 +
 drivers/reset/reset-dra7.c|  97 +++
 include/linux/bitmap.h|  26 +
 include/remoteproc.h  | 384 -
 33 files changed, 2296 insertions(+), 17 deletions(-)
 create mode 100644 arch/arm/dts/am57xx-beagle-x15-revb1-u-boot.dtsi
 create mode 100644 arch/arm/dts/am57xx-beagle-x15-revc-u-boot.dtsi
 create mode 100644 arch/arm/dts/am57xx-beagle-x15-u-boot.dtsi
 create mode 100644 arch/arm/dts/am57xx-cl-som-am57x-u-boot.dtsi
 create mode 100644 arch/arm/dts/am57xx-sbc-am57x-u-boot.dtsi
 create mode 100644 arch/arm/dts/dra7-ipu-common-early-boot.dtsi
 create mode 100644 drivers/remoteproc/ipu_rproc.c
 create mode 100644 drivers/reset/reset-dra7.c

-- 
2.25.1