4 # helper function to convert from DOS to Unix, if necessary, and handle
7 fix_newlines_in_macros() {
8 sed -n ':next;s/\r$//;/[^\\]\\$/ {N;s/\\\n//;b next};p' $1
11 #filter out only what we need from a10 hps.xml
12 grep_a10_hps_config() {
13 egrep "clk_hz|i_clk_mgr|i_io48_pin_mux|AXI_SLAVE|AXI_MASTER"
21 process_a10_hps_config() {
26 // SPDX-License-Identifier: BSD-3-Clause
28 * Intel Arria 10 SoCFPGA configuration
31 #ifndef __SOCFPGA_ARRIA10_CONFIG_H__
32 #define __SOCFPGA_ARRIA10_CONFIG_H__
37 fix_newlines_in_macros \
38 ${hps_xml} | egrep "clk_hz" |
39 awk -F"'" '{ gsub("\\.","_",$2) ; \
40 print "#define" " " toupper($2) " " $4}' |
42 sed 's/I_CLK_MGR_//' |
44 fix_newlines_in_macros \
45 ${hps_xml} | egrep "i_clk_mgr_mainpll" |
46 awk -F"'" '{ gsub("\\.","_",$2) ; \
47 print "#define" " " toupper($2) " " $4}' |
49 sed 's/I_CLK_MGR_//' |
51 fix_newlines_in_macros \
52 ${hps_xml} | egrep "i_clk_mgr_perpll" |
53 awk -F"'" '{ gsub("\\.","_",$2) ; \
54 print "#define" " " toupper($2) " " $4}' |
56 sed 's/I_CLK_MGR_//' |
58 fix_newlines_in_macros \
59 ${hps_xml} | egrep "i_clk_mgr_clkmgr" |
60 awk -F"'" '{ gsub("\\.","_",$2) ; \
61 print "#define" " " toupper($2) " " $4}' |
63 sed 's/I_CLK_MGR_//' |
65 fix_newlines_in_macros \
66 ${hps_xml} | egrep "i_clk_mgr_alteragrp" |
67 awk -F"'" '{ gsub("\\.","_",$2) ; \
68 print "#define" " " toupper($2) " " $4}' |
70 sed 's/I_CLK_MGR_//' |
72 echo "#define ALTERAGRP_MPUCLK ((ALTERAGRP_MPUCLK_PERICNT << 16) | \\"
73 echo " (ALTERAGRP_MPUCLK_MAINCNT))"
74 echo "#define ALTERAGRP_NOCCLK ((ALTERAGRP_NOCCLK_PERICNT << 16) | \\"
75 echo " (ALTERAGRP_NOCCLK_MAINCNT))"
78 echo "/* Pin Mux Configuration */"
79 fix_newlines_in_macros \
80 ${hps_xml} | egrep "i_io48_pin_mux" |
81 awk -F"'" '{ gsub("\\.","_",$2) ; \
82 print "#define" " " toupper($2) " " $4}' |
83 sed 's/I_IO48_PIN_MUX_//' |
84 sed 's/SHARED_3V_IO_GRP_//' |
85 sed 's/FPGA_INTERFACE_GRP_//' |
86 sed 's/DEDICATED_IO_GRP_//' |
87 sed 's/CONFIGURATION_DEDICATED/CONFIG/' |
91 echo "/* Bridge Configuration */"
92 fix_newlines_in_macros \
93 ${hps_xml} | egrep "AXI_SLAVE|AXI_MASTER" |
94 awk -F"'" '{ gsub("\\.","_",$2) ; \
95 print "#define" " " toupper($2) " " $4}' |
101 echo "/* Voltage Select for Config IO */"
102 echo "#define CONFIG_IO_BANK_VSEL \\"
103 echo " (((CONFIG_IO_BANK_VOLTAGE_SEL_CLKRST_IO & 0x3) << 8) | \\"
104 echo " (CONFIG_IO_BANK_VOLTAGE_SEL_PERI_IO & 0x3))"
107 echo "/* Macro for Config IO bit mapping */"
108 echo -n "#define CONFIG_IO_MACRO(NAME) "
109 echo "(((NAME ## _RTRIM & 0xff) << 19) | \\"
110 echo " ((NAME ## _INPUT_BUF_EN & 0x3) << 17) | \\"
111 echo " ((NAME ## _WK_PU_EN & 0x1) << 16) | \\"
112 echo " ((NAME ## _PU_SLW_RT & 0x1) << 13) | \\"
113 echo " ((NAME ## _PU_DRV_STRG & 0xf) << 8) | \\"
114 echo " ((NAME ## _PD_SLW_RT & 0x1) << 5) | \\"
115 echo " (NAME ## _PD_DRV_STRG & 0x1f))"
119 #endif /* __SOCFPGA_ARRIA10_CONFIG_H__ */
125 echo "$0 [hps_xml] [output_file]"
126 echo "Process QTS-generated hps.xml into devicetree header."
128 echo " hps_xml - hps.xml file from hps_isw_handoff"
129 echo " output_file - Output header file for dtsi include"
136 if [ "$#" -ne 2 ] ; then
141 process_a10_hps_config "${hps_xml}" "${outfile}"