angstrom: prefer the git version of tslib
[openembedded.git] / classes / xilinx-bsp.bbclass
blob9776c2364af4570e80253289fcadcb8104355167
1 # Copyright (C) 2007, Stelios Koroneos - Digital OPSiS, All Rights Reserved
2 # Copyright (C) 2010, Adrian Alonso <aalonso00@gmail.com>
3 # Released under the MIT license (see packages/COPYING)
5 #This class handles all the intricasies of getting the required files from the
6 #ISE/EDK/project to the kernel and prepare the kernel for compilation.
7 #The Xilinx EDK supports 2 different architectures : PowerPC (ppc 405,440) and Microblaze
8 #Only the PowerPC BSP has been tested so far
9 #For this to work correctly you need to add XILINX_BSP_PATH and XILINX_BOARD to your 
10 #local.conf
11 #XILINX_BSP_PATH should have the complete path to your project dir
12 #XILINX_BOARD should have the board type i.e ML403
14 #Currently tested on
15 #Xilinx ML405
16 #Xilinx ML507
17 #More to come soon ;)
19 def map_target(a, d):
20         import re
21         board = bb.data.getVar('XILINX_BOARD', d, 1)
22         cpu = bb.data.getVar('TARGET_CPU', d, 1)
24         if re.match('powerpc', a):
25                 return 'ppc' + cpu + '-' + board
26         else:
27                 return 'system'
29 def uboot_machine(a, d):
30     import re
32     board = bb.data.getVar('XILINX_BOARD', d, 1)
33     if board in ['ml300', 'ml401', 'ml403', 'ml405', 'ml507', 'ml510']:
34         if re.match('powerpc', a):
35             if board == 'ml403':
36                 return 'ml401_config'
37             elif board == 'ml510':
38                 return 'ml507_config'
39             else:
40                 return board + '_config'
41         else:
42             return 'microblaze-generic_config'
44 def uboot_target(a, d):
45     import re
47     board = bb.data.getVar('XILINX_BOARD', d, 1)
48     target = bb.data.getVar('TARGET_CPU', d, 1) + '-generic'
49     if board in ['ml300', 'ml401', 'ml403', 'ml405', 'ml507', 'ml510']:
50         if re.match('powerpc', a):
51             if board == 'ml403':
52                 return 'ml401'
53             elif board == 'ml510':
54                 return 'ml507'
55             else:
56                 return board
57         else:
58             return target
60 do_configure_prepend() {
61 #first check that the XILINX_BSP_PATH and XILINX_BOARD have been defined in local.conf
62 #now depending on the board type and arch do what is nessesary
63 if [ -n "${XILINX_BSP_PATH}" ]; then
64         if [ -n "${XILINX_BOARD}" ]; then
65                 if [ -d "${S}/arch/${TARGET_ARCH}/boot" ]; then
66                         dts=`find "${XILINX_BSP_PATH}" -name *.dts -print`
67                         if [ -e "$dts" ]; then
68                                 oenote "Replacing device tree to match hardware model"
69                                 if [ "${TARGET_ARCH}" = "powerpc" ]; then
70                                         cp -pP ${dts} ${S}/arch/powerpc/boot/dts/virtex${TARGET_BOARD}.dts
71                                 else
72                                         cp -pP ${dts} ${S}/arch/microblaze/platform/generic/${TARGET_BOARD}.dts
73                                 fi
74                         else
75                                 oefatal "No device tree found, missing hardware ref design?"
76                                 exit 1
77                         fi
78                 elif [ -d "${S}/board/xilinx" ]; then
79                         oenote "Replacing xparameters header to match hardware model"
80                         if [ "${TARGET_ARCH}" = "powerpc" ]; then
81                                 xparam="${XILINX_BSP_PATH}/ppc${TARGET_CPU}_0/include/xparameters.h"
82                                 cpu="PPC`echo ${TARGET_CPU} | tr '[:lower:]' '[:upper:]'`"
83                         else
84                                 xparam="${XILINX_BSP_PATH}/${TARGET_CPU}_0/include/xparameters.h"
85                                 cpu=`echo ${TARGET_CPU} | tr '[:lower:]' '[:upper:]'`
86                         fi
87                         if [ -e "$xparam" ]; then
88                                 cp ${xparam} ${S}/board/xilinx/${UBOOT_TARGET}
89                                 echo "/*** Cannonical definitions ***/
90 #define XPAR_PLB_CLOCK_FREQ_HZ XPAR_PROC_BUS_0_FREQ_HZ
91 #define XPAR_CORE_CLOCK_FREQ_HZ XPAR_CPU_${cpu}_CORE_CLOCK_FREQ_HZ
92 #ifndef XPAR_DDR2_SDRAM_MEM_BASEADDR
93 # define XPAR_DDR2_SDRAM_MEM_BASEADDR XPAR_DDR_SDRAM_MPMC_BASEADDR
94 #endif
95 #define XPAR_PCI_0_CLOCK_FREQ_HZ    0" >> ${S}/board/xilinx/${UBOOT_TARGET}/xparameters.h
96                         else
97                                 oefatal "No xparameters header file found, missing hardware ref design?"
98                 exit 1
99                         fi
100                 fi
101         else
102                 oefatal "XILINX_BOARD not defined ! Exit"
103                 exit 1
104         fi
105 else
106         oefatal "XILINX_BSP_PATH not defined ! Exit"
107         exit 1
111 do_deploy_prepend() {
112 # Install u-boot elf image
113 if [ -d "${XILINX_BSP_PATH}" ]; then
114         if [ -e "${S}/u-boot" ]; then
115                 install ${S}/u-boot ${XILINX_BSP_PATH}
116         fi