5 # This program is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by the
7 # Free Software Foundation; either version 2 of the License, or (at your
8 # option) any later version.
11 # XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS" AS A
12 # COURTESY TO YOU. BY PROVIDING THIS DESIGN, CODE, OR INFORMATION AS
13 # ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE, APPLICATION OR STANDARD,
14 # XILINX IS MAKING NO REPRESENTATION THAT THIS IMPLEMENTATION IS FREE
15 # FROM ANY CLAIMS OF INFRINGEMENT, AND YOU ARE RESPONSIBLE FOR OBTAINING
16 # ANY THIRD PARTY RIGHTS YOU MAY REQUIRE FOR YOUR IMPLEMENTATION.
17 # XILINX EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH RESPECT TO
18 # THE ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO ANY
19 # WARRANTIES OR REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE FROM
20 # CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND
21 # FITNESS FOR A PARTICULAR PURPOSE.
24 # Xilinx hardware products are not intended for use in life support
25 # appliances, devices, or systems. Use in such applications is
26 # expressly prohibited.
29 # (c) Copyright 2002-2004 Xilinx Inc.
30 # All rights reserved.
33 # You should have received a copy of the GNU General Public License along
34 # with this program; if not, write to the Free Software Foundation, Inc.,
35 # 675 Mass Ave, Cambridge, MA 02139, USA.
39 set ltypes "../../../sw_services/uboot_v1_00_a/data/Ltypes"
41 proc uboot_drc {lib_handle} {
45 proc generate {libname} {
49 # Get list of peripherals connected to uboot
50 set conn_periphs [xget_handle $libname "ARRAY" "connected_periphs"]
52 if {[string compare -nocase $conn_periphs ""] != 0} {
53 set conn_periphs_elems [xget_handle $conn_periphs "ELEMENTS" "*"]
55 foreach periph_elem $conn_periphs_elems {
56 set periph [xget_value $periph_elem "PARAMETER" "periph_name"]
58 set drv [xget_swhandle $periph]
59 set posn [lsearch -exact $drvlist $drv]
65 set file_handle [xopen_include_file "xparameters.h"]
66 puts $file_handle "\n/******************************************************************/\n"
67 puts $file_handle "/* U-Boot Redefines */"
68 puts $file_handle "\n/******************************************************************/\n"
71 foreach drv $drvlist {
72 set drvname [xget_value $drv "NAME"]
74 #Redefines xparameters.h
75 if {[string compare -nocase $drvname "uartns550"] == 0} {
76 xredefine_uartns550 $drv "xparameters.h"
77 } elseif {[string compare -nocase $drvname "emac"] == 0} {
78 xredefine_emac $drv "xparameters.h"
84 xredefine_params $libname "xparameters.h" "CORE_CLOCK_FREQ_HZ"
87 proc xget_corefreq {} {
88 set processor [xget_processor]
89 set name [xget_value $processor "NAME"]
90 puts "procname : $name"
91 set processor_driver [xget_swhandle [xget_value $processor "NAME"]]
92 puts "procdrv : $processor_driver"
93 if {[string compare -nocase $processor_driver ""] != 0} {
94 set arg "CORE_CLOCK_FREQ_HZ"
95 #set retval [xget_value $processor_driver "PARAMETER" $arg]
96 set retval [xget_dname [xget_value $processor_driver "NAME"] $arg]
101 # procedure that adds # defines to xparameters.h as XPAR_argument
102 proc xredefine_params {handle file_name args} {
106 set file_handle [xopen_include_file $file_name]
110 if {[string compare -nocase $arg "CORE_CLOCK_FREQ_HZ"] == 0} {
111 set value [xget_corefreq]
112 puts "corefreq : $value"
114 set value [xget_value $handle "PARAMETER" $arg]
115 puts "value : $value"
119 set value [xformat_addr_string $value $arg]
120 set name [string toupper $arg]
121 set name [format "XPAR_%s" $name]
122 puts $file_handle "#define $name $value"
126 puts $file_handle "\n/******************************************************************/\n"
131 proc xredefine_uartns550 {drvhandle file_name} {
133 xredefine_include_file $drvhandle $file_name "uartns550" "C_BASEADDR" "C_HIGHADDR" "CLOCK_HZ" "DEVICE_ID"
137 proc xredefine_emac {drvhandle file_name} {
139 xredefine_include_file $drvhandle $file_name "emac" "C_BASEADDR" "C_HIGHADDR" "C_DMA_PRESENT" "C_MII_EXIST" "C_ERR_COUNT_EXIST" "DEVICE_ID"
143 #######################
145 proc xredefine_include_file {drv_handle file_name drv_string args} {
148 set file_handle [xopen_include_file $file_name]
150 # Get all peripherals connected to this driver
151 set periphs [xget_periphs $drv_handle]
153 set pname [format "XPAR_%s_" [string toupper $drv_string]]
155 # Print all parameters for all peripherals
158 foreach periph $periphs {
159 puts "$periph : $drv_string : $sub_periphs"
161 for {set i 0} {$i < $sub_periphs} {incr i} {
163 set name "${pname}${device_id}_"
165 if {[string compare -nocase "CLOCK_HZ" $arg] == 0} {
166 set xdrv_string [format "%s%s" "X" $drv_string]
167 set value [xget_dname $xdrv_string $arg]
168 set name "${name}CLOCK_FREQ_HZ"
170 if {[string match C_* $arg]} {
171 set name [format "%s%s" $name [string range $arg 2 end]]
173 set name "${name}${arg}"
175 set value [xget_name $periph $arg]
178 if {[string compare -nocase "uartns550" $drv_string] == 0} {
179 if {[string compare -nocase "C_BASEADDR" $arg] == 0} {
180 set value [format "(%s%s%s)" $value "+" "0x1000"]
184 puts $file_handle "#define $name $value"
185 if {[string compare -nocase "DEVICE_ID" $arg] == 0} {
191 puts $file_handle "\n/******************************************************************/\n"
195 ##################################################
196 # procedure post_generate
197 # This generates the drivers directory for uboot
198 # and runs the ltypes script
199 ##################################################
201 proc post_generate {lib_handle} {
205 # Create U-Boot tree structure
207 set common_dir "uboot/board/xilinx/common"
208 set xilinx_enet_dir "uboot/board/xilinx/xilinx_enet"
209 set ml300_dir "uboot/board/xilinx/ml300"
211 exec bash -c "mkdir -p $common_dir $xilinx_enet_dir $ml300_dir"
213 # Copy files for xilinx_ocp
216 foreach drv $drvlist {
217 set drvname [xget_value $drv "NAME"]
218 set ver [xget_value $drv "PARAMETER" "DRIVER_VER"]
219 set ver [string map {. _} $ver]
220 set dirname [format "%s_v%s" $drvname $ver]
222 if {[string compare -nocase $drvname "emac"] == 0} {
223 xcopy_emac $drv $dirname
227 # Call Ltypes Script here
231 # Move xparameters.h around
232 exec bash -c "cp ../../include/xparameters.h $ml300_dir"
234 # copy the whole U-Boot BSP to its final destination
235 set value [xget_value $lib_handle "PARAMETER" TARGET_DIR]
236 puts "TARGET_DIR : $value"
239 if {[file isdirectory $value] == 0} {
240 exec bash -c "mkdir -p $value"
242 exec bash -c "cp -Rp uboot/* $value"
246 proc xcopy_commonfiles {} {
250 set common_dir "uboot/board/xilinx/common"
252 foreach drv $drvlist {
253 set depends [xget_value $drv "OPTION" "DEPENDS"]
254 foreach dep $depends {
256 if {[file isdirectory "../$dep"] == 1} {
257 exec bash -c "cp -f ../$dep/src/*.c $common_dir"
258 exec bash -c "cp -f ../$dep/src/*.h $common_dir"
265 proc xcopy_emac {drv_handle dirname} {
266 set emac "board/xilinx/xilinx_enet"
267 xcopy_dir $dirname $emac
270 proc xcopy_dir {srcdir dstdir} {
272 set dstdirname [format "%s%s" "uboot/" $dstdir]
273 if {[file isdirectory "../$srcdir"] == 1} {
274 # Copy files from src to dst
275 exec bash -c "mkdir -p $dstdirname"
276 exec bash -c "cp -f ../$srcdir/src/*.c $dstdirname"
277 exec bash -c "cp -f ../$srcdir/src/*.h $dstdirname"
279 puts "$srcdir does not exist ..."
284 proc xltype_file {filename} {
290 if {[file isdirectory $filename]} {
291 foreach entry [glob -nocomplain [file join $filename *]] {
295 exec bash -c "$ltypes $filename"