Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

openamp-xlnx: Parse non-dedicated IPIs for OpenAMP channels #1

Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions assists/openamp-xlnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,52 @@
from lopper import Lopper
from lopper import LopperFmt
import lopper
from lopper_tree import *

openamp_file_name = "openamp_lopper_gen.h"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ben, Do we think that the filename might vary ? In that case, this can be the default and we could check the options dictionary in the assist callback for a filename. That way it could passed via a lop file and changed if needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point. added option to set file name via input r5 lop file in later commit


# given interrupt list, write interrupt base addresses and adequate register width to header file
# TODO append memory carveout-related info
def generate_openamp_file(ipi_list):
f = open(openamp_file_name, "w")
# for each pair of ipi's present, write a master+remote ipi
f.write("#ifndef OPENAMP_LOPPER_INFO_H_\n")
f.write("#define OPENAMP_LOPPER_INFO_H_\n\n")

for index,value in enumerate(ipi_list):
f.write("#define ")
# first ipi in pair for master, second for remote
ipi = "CHANNEL_"
ipi += str(index//2) # 1 channel per pair of IPIs

if (index % 2 == 0):
ipi += "_MASTER_"
else:
ipi += "_REMOTE_"
ipi += "IPI_BASE_ADDR_" + str(index)
ipi += "\t"+value+"\n"
f.write(ipi)
f.write("\n\n#endif /* OPENAMP_LOPPER_INFO_H_\n")
f.close()


def parse_ipis_for_rpu(sdt, domain_node, rpu_cpu_node, options):
try:
verbose = options['verbose']
except:
verbose = 0

ipi_list = []
for k,v in sdt.tree.__nodes__.items():
if "ps_ipi" in k:
ipi_list.append((v["reg"]).hex()[0])

if verbose:
print( "[INFO]: Dedicated IPIs for OpenAMP: %s" % ipi_list)

ipis_prop = LopperProp(name="ipis", value=ipi_list)
rpu_cpu_node + ipis_prop
return ipi_list

def is_compat( node, compat_string_to_test ):
if re.search( "openamp,xlnx-rpu", compat_string_to_test):
Expand Down Expand Up @@ -276,6 +322,8 @@ def xlnx_openamp_rpu( tgt_node, sdt, options ):
rpu_cpu_node["mbox-names"].value = mbox_names
rpu_cpu_node.sync( sdt.FDT )

ipis = parse_ipis_for_rpu(sdt, domain_node, rpu_cpu_node, options)
generate_openamp_file(ipis)

return True

31 changes: 29 additions & 2 deletions device-trees/system-device-tree.dts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#size-cells = <0x2>;
model = "Xilinx Versal A2197 Processor board revA";



cpus {
#address-cells = <0x1>;
#size-cells = <0x0>;
Expand Down Expand Up @@ -54,6 +56,30 @@
};
};
};
ps_ipi_1 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recall feedback that if there's a reg property in the node, the name should include the unit address, i.e. https://elinux.org/Device_Tree_Usage#Node_Names

If so, should we add some @ to these ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added unit address to name in later commit.

compatible = "ps-interrupt";
#address-cells = <2>;
#size-cells = <2>;
reg = <0xFF340000 0x1000>;
};
ps_ipi_2 {
compatible = "ps-interrupt";
#address-cells = <2>;
#size-cells = <2>;
reg = <0xFF350000 0x1000>;
};
ps_ipi_3 {
compatible = "ps-interrupt";
#address-cells = <2>;
#size-cells = <2>;
reg = <0xFF360000 0x1000>;
};
ps_ipi_4 {
compatible = "ps-interrupt";
#address-cells = <2>;
#size-cells = <2>;
reg = <0xFF370000 0x1000>;
};

cpus_r5: cpus-cluster@0 {
#address-cells = <0x1>;
Expand All @@ -68,7 +94,8 @@
<0xf9000000 &amba_rpu 0xf9000000 0x10000>,
<0x0 &memory 0x0 0x80000000>,
<0x0 &tcm 0xFFE90000 0x10000>;

// <0x0 &ps_ipi_0 0xFF340000 0x1000>,
// <0x0 &ps_ipi_1 0xFF350000 0x1000>;
cpu@0 {
compatible = "arm,cortex-r5";
device_type = "cpu";
Expand Down Expand Up @@ -188,7 +215,6 @@
reg = <0x0 0xf9000000 0x0 0x1000 0x0 0xf9000000 0x0 0x100>;
};
};

amba: bus@f1000000 {
compatible = "simple-bus";
#address-cells = <0x2>;
Expand Down Expand Up @@ -787,6 +813,7 @@
*/
access = <&tcm 0x1>, <&ethernet0 0x0>;

//ipis = <&ps_ipi_0 0x0>, <&ps_ipi_1 0x1>;
chosen {
bootargs = "console=ttyAMA0";
};
Expand Down