keymile-common.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  1. /*
  2. * (C) Copyright 2008-2011
  3. * Heiko Schocher, DENX Software Engineering, hs@denx.de.
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #ifndef __CONFIG_KEYMILE_H
  24. #define __CONFIG_KEYMILE_H
  25. /* Do boardspecific init for all boards */
  26. #define CONFIG_BOARD_EARLY_INIT_R
  27. #define CONFIG_LAST_STAGE_INIT
  28. #define CONFIG_BOOTCOUNT_LIMIT
  29. /*
  30. * By default kwbimage.cfg from board specific folder is used
  31. * If for some board, different configuration file need to be used,
  32. * CONFIG_SYS_KWD_CONFIG should be defined in board specific header file
  33. */
  34. #ifndef CONFIG_SYS_KWD_CONFIG
  35. #define CONFIG_SYS_KWD_CONFIG $(SRCTREE)/$(CONFIG_BOARDDIR)/kwbimage.cfg
  36. #endif /* CONFIG_SYS_KWD_CONFIG */
  37. /*
  38. * Command line configuration.
  39. */
  40. #include <config_cmd_default.h>
  41. #define CONFIG_CMD_ASKENV
  42. #define CONFIG_CMD_DHCP
  43. #define CONFIG_CMD_ECHO
  44. #define CONFIG_CMD_IMMAP
  45. #define CONFIG_CMD_MII
  46. #define CONFIG_CMD_PING
  47. #define CONFIG_CMD_EEPROM
  48. #define CONFIG_CMD_I2C
  49. #define CONFIG_CMD_JFFS2
  50. #define CONFIG_CMD_MTDPARTS
  51. #define CONFIG_CMD_SETEXPR
  52. #undef CONFIG_WATCHDOG /* disable platform specific watchdog */
  53. #define CONFIG_BOOTDELAY 2 /* autoboot after 2 seconds */
  54. #undef CONFIG_BOOTARGS /* the boot command will set bootargs */
  55. /*
  56. * Miscellaneous configurable options
  57. */
  58. #define CONFIG_SYS_HUSH_PARSER
  59. #define CONFIG_SYS_PROMPT_HUSH_PS2 "> "
  60. #define CONFIG_SYS_LONGHELP /* undef to save memory */
  61. #define CONFIG_SYS_PROMPT "=> " /* Monitor Command Prompt */
  62. #if defined(CONFIG_CMD_KGDB)
  63. #define CONFIG_SYS_CBSIZE 1024 /* Console I/O Buffer Size */
  64. #else
  65. #define CONFIG_SYS_CBSIZE 512 /* Console I/O Buffer Size */
  66. #endif
  67. #define CONFIG_SYS_PBSIZE (CONFIG_SYS_CBSIZE+sizeof(CONFIG_SYS_PROMPT)+16)
  68. #define CONFIG_SYS_MAXARGS 32 /* max number of command args */
  69. #define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE
  70. #define CONFIG_CMDLINE_EDITING
  71. #define CONFIG_AUTO_COMPLETE
  72. #define CONFIG_HUSH_INIT_VAR
  73. #define CONFIG_SYS_ALT_MEMTEST /* memory test, takes time */
  74. #define CONFIG_SYS_HZ 1000 /* decr. freq: 1 ms ticks */
  75. #define CONFIG_BAUDRATE 115200
  76. #define CONFIG_SYS_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200, 230400 }
  77. #define CONFIG_LOADS_ECHO
  78. #define CONFIG_SYS_LOADS_BAUD_CHANGE
  79. #define CONFIG_SYS_BOARD_DRAM_INIT /* Used board specific dram_init */
  80. /*
  81. * How to get access to the slot ID. Put this here to make it easy
  82. * to modify in a centralized location. This is used in the HDLC
  83. * driver to set the MAC.
  84. */
  85. #define CONFIG_CHECK_ETHERNET_PRESENT
  86. #define CONFIG_SYS_SLOT_ID_BASE CONFIG_SYS_KMBEC_FPGA_BASE
  87. #define CONFIG_SYS_SLOT_ID_OFF (0x07) /* register offset */
  88. #define CONFIG_SYS_SLOT_ID_MASK (0x3f) /* mask for slot ID bits */
  89. #define CONFIG_I2C_MULTI_BUS
  90. #define CONFIG_SYS_MAX_I2C_BUS 1
  91. #define CONFIG_SYS_I2C_INIT_BOARD
  92. #define CONFIG_I2C_MUX
  93. /* EEprom support */
  94. #define CONFIG_SYS_I2C_MULTI_EEPROMS
  95. #define CONFIG_SYS_EEPROM_PAGE_WRITE_ENABLE
  96. #define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS 3
  97. #define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS 10
  98. /* Support the IVM EEprom */
  99. #define CONFIG_SYS_IVM_EEPROM_ADR 0x50
  100. #define CONFIG_SYS_IVM_EEPROM_MAX_LEN 0x400
  101. #define CONFIG_SYS_IVM_EEPROM_PAGE_LEN 0x100
  102. #define CONFIG_SYS_FLASH_PROTECTION
  103. /*
  104. * BOOTP options
  105. */
  106. #define CONFIG_BOOTP_BOOTFILESIZE
  107. #define CONFIG_BOOTP_BOOTPATH
  108. #define CONFIG_BOOTP_GATEWAY
  109. #define CONFIG_BOOTP_HOSTNAME
  110. #define CONFIG_SYS_MALLOC_LEN (4 * 1024 * 1024)
  111. /* UBI Support for all Keymile boards */
  112. #define CONFIG_CMD_UBI
  113. #define CONFIG_RBTREE
  114. #define CONFIG_MTD_PARTITIONS
  115. #define CONFIG_MTD_DEVICE
  116. #define CONFIG_MTD_CONCAT
  117. /* common powerpc specific env settings */
  118. #ifndef CONFIG_KM_DEF_ENV_BOOTPARAMS
  119. #define CONFIG_KM_DEF_ENV_BOOTPARAMS \
  120. "bootparams=empty\0" \
  121. "initial_boot_bank=0\0"
  122. #endif
  123. #ifndef CONFIG_KM_DEF_NETDEV
  124. #define CONFIG_KM_DEF_NETDEV \
  125. "netdev=eth0\0"
  126. #endif
  127. #ifndef CONFIG_KM_UBI_PARTITION_NAME
  128. #define CONFIG_KM_UBI_PARTITION_NAME "ubi0"
  129. #endif
  130. #ifndef CONFIG_KM_UBI_LINUX_MTD_NAME
  131. #define CONFIG_KM_UBI_LINUX_MTD_NAME "ubi0"
  132. #endif
  133. #define xstr(s) str(s)
  134. #define str(s) #s
  135. /*
  136. * bootrunner
  137. * - run all commands in 'subbootcmds'
  138. * - on error, stop running the remaing commands
  139. */
  140. #define CONFIG_KM_DEF_ENV_BOOTRUNNER \
  141. "bootrunner=" \
  142. "break=0; " \
  143. "for subbootcmd in ${subbootcmds}; do " \
  144. "if test ${break} -eq 0; then; " \
  145. "echo \"[INFO] running \\c\"; " \
  146. "print ${subbootcmd}; " \
  147. "run ${subbootcmd} || break=1; " \
  148. "if test ${break} -eq 1; then; " \
  149. "echo \"[ERR] failed \\c\"; " \
  150. "print ${subbootcmd}; " \
  151. "fi; " \
  152. "fi; " \
  153. "done\0" \
  154. ""
  155. /*
  156. * boottargets
  157. * - set 'subbootcmds' for the bootrunner
  158. * - set 'bootcmd' and 'altbootcmd'
  159. * available targets:
  160. * - 'release': for a standalone system kernel/rootfs from flash
  161. * - 'develop': for development kernel(tftp)/rootfs(NFS)
  162. * - 'ramfs': rootfilesystem in RAM kernel(tftp)/rootfs(RAM)
  163. *
  164. * - 'commonargs': bootargs common to all targets
  165. */
  166. #define CONFIG_KM_DEF_ENV_BOOTTARGETS \
  167. "commonargs=" \
  168. "addip " \
  169. "addtty " \
  170. "addmem " \
  171. "addinit " \
  172. "addvar " \
  173. "addmtdparts " \
  174. "addbootcount " \
  175. "\0" \
  176. "develop=" \
  177. "setenv subbootcmds \"" \
  178. "tftpfdt tftpkernel " \
  179. "nfsargs ${commonargs} " \
  180. "printbootargs boot " \
  181. "\" && " \
  182. "setenv bootcmd \'" \
  183. "run bootrunner" \
  184. "\' && " \
  185. "setenv altbootcmd \'" \
  186. "run bootcmd" \
  187. "\' && " \
  188. "run setboardid && " \
  189. "saveenv && " \
  190. "reset\0" \
  191. "ramfs=" \
  192. "setenv actual_bank -1 && " \
  193. "setenv subbootcmds \"" \
  194. "tftpfdt tftpkernel " \
  195. "setrootfsaddr tftpramfs " \
  196. "flashargs ${commonargs} " \
  197. "addpanic addramfs " \
  198. "printbootargs boot " \
  199. "\" && " \
  200. "setenv bootcmd \'" \
  201. "run bootrunner" \
  202. "\' && " \
  203. "setenv altbootcmd \'" \
  204. "run bootcmd" \
  205. "\' && " \
  206. "run setboardid && " \
  207. "run setramfspram && " \
  208. "saveenv && " \
  209. "reset\0" \
  210. "release=" \
  211. "setenv actual_bank ${initial_boot_bank} && " \
  212. "setenv subbootcmds \"" \
  213. "checkboardidlist " \
  214. "checkboardid " \
  215. "ubiattach ubicopy " \
  216. "cramfsloadfdt cramfsloadkernel " \
  217. "flashargs ${commonargs} " \
  218. "addpanic " \
  219. "printbootargs boot " \
  220. "\" && " \
  221. "setenv bootcmd \'" \
  222. "run actual bootrunner; reset" \
  223. "\' && " \
  224. "setenv altbootcmd \'" \
  225. "run backup bootrunner; reset" \
  226. "\' && " \
  227. "saveenv && " \
  228. "reset\0" \
  229. ""
  230. /*
  231. * bootargs
  232. * - modify 'bootargs'
  233. *
  234. * - 'addip': add ip configuration
  235. * - 'addmem': limit kernel memory mem=
  236. * - 'addpanic': add kernel panic options
  237. * - 'addramfs': add phram device for the rootfilesysten in ram
  238. * - 'addtty': add console=...
  239. * - 'addvar': add phram device for /var
  240. * - 'nfsargs': default arguments for nfs boot
  241. * - 'flashargs': defaults arguments for flash base boot
  242. *
  243. * processor specific settings
  244. * - 'addbootcount': add boot counter
  245. * - 'addmtdparts': add mtd partition information
  246. */
  247. #define CONFIG_KM_DEF_ENV_BOOTARGS \
  248. "addinit=" \
  249. "setenv bootargs ${bootargs} init=${init}\0" \
  250. "addip=" \
  251. "setenv bootargs ${bootargs} " \
  252. "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}" \
  253. ":${hostname}:${netdev}:off\0" \
  254. "addmem=" \
  255. "setenv bootargs ${bootargs} mem=0x${pnvramaddr}\0" \
  256. "addpanic=" \
  257. "setenv bootargs ${bootargs} " \
  258. "panic=1 panic_on_oops=1\0" \
  259. "addramfs=" \
  260. "setenv bootargs \"" \
  261. "${bootargs} phram.phram=" \
  262. "rootfs${boot_bank},${rootfsaddr},${rootfssize}\"\0" \
  263. "addtty=" \
  264. "setenv bootargs ${bootargs}" \
  265. " console=" CONFIG_KM_CONSOLE_TTY ",${baudrate}\0" \
  266. "addvar=" \
  267. "setenv bootargs ${bootargs} phram.phram=phvar," \
  268. "${varaddr},0x" xstr(CONFIG_KM_PHRAM) "\0" \
  269. "nfsargs=" \
  270. "setenv bootargs " \
  271. "ubi.mtd=" CONFIG_KM_UBI_LINUX_MTD_NAME " " \
  272. "root=/dev/nfs rw " \
  273. "nfsroot=${serverip}:${rootpath}\0" \
  274. "flashargs=" \
  275. "setenv bootargs " \
  276. "ubi.mtd=" CONFIG_KM_UBI_LINUX_MTD_NAME " " \
  277. "root=mtdblock:rootfs${boot_bank} " \
  278. "rootfstype=squashfs ro\0" \
  279. ""
  280. /*
  281. * compute_addr
  282. * - compute addresses and sizes
  283. * - addresses are calculated form the end of memory 'memsize'
  284. *
  285. * - 'setramfspram': compute PRAM size for ramfs target
  286. * - 'setrootfsaddr': compute rootfilesystem address for phram
  287. */
  288. #define CONFIG_KM_DEF_ENV_COMPUTE_ADDR \
  289. "setboardid=" \
  290. "if test \"x${boardId}\" = \"x\"; then; " \
  291. "setenv boardId ${IVM_BoardId} && " \
  292. "setenv hwKey ${IVM_HWKey}; " \
  293. "else; " \
  294. "echo \\\\c; " \
  295. "fi\0" \
  296. "setramfspram=" \
  297. "setexpr value ${rootfssize} / 0x400 && " \
  298. "setexpr value 0x${value} + ${pram} && " \
  299. "setenv pram 0x${value}\0" \
  300. "setrootfsaddr=" \
  301. "setexpr value ${pnvramaddr} - ${rootfssize} && " \
  302. "setenv rootfsaddr 0x${value}\0" \
  303. ""
  304. /*
  305. * flash_boot
  306. * - commands for booting from flash
  307. *
  308. * - 'cramfsaddr': address to the cramfs (in ram)
  309. * - 'cramfsloadkernel': copy kernel from a cramfs to ram
  310. * - 'ubiattach': attach ubi partition
  311. * - 'ubicopy': copy ubi volume to ram
  312. * - volume names: bootfs0, bootfs1, bootfs2, ...
  313. * - 'ubiparition': mtd parition name for ubi
  314. *
  315. * processor specific settings
  316. * - 'cramfsloadfdt': copy fdt from a cramfs to ram
  317. */
  318. #define CONFIG_KM_DEF_ENV_FLASH_BOOT \
  319. "cramfsaddr="xstr(CONFIG_KM_CRAMFS_ADDR) "\0" \
  320. "cramfsloadkernel=" \
  321. "cramfsload ${kernel_addr_r} uImage && " \
  322. "setenv actual_kernel_addr ${kernel_addr_r}\0" \
  323. "ubiattach=ubi part ${ubipartition}\0" \
  324. "ubicopy=ubi read ${cramfsaddr} bootfs${boot_bank}\0" \
  325. "ubipartition=" CONFIG_KM_UBI_PARTITION_NAME "\0" \
  326. ""
  327. /*
  328. * net_boot
  329. * - commands for booting over the network
  330. *
  331. * - 'tftpkernel': load a kernel with tftp into ram
  332. * - 'tftpramfs': load rootfs with tftp into ram
  333. *
  334. * processor specific settings
  335. * - 'tftpfdt': load fdt with tftp into ram
  336. */
  337. #define CONFIG_KM_DEF_ENV_NET_BOOT \
  338. "tftpkernel=" \
  339. "tftpboot ${kernel_addr_r} ${kernel_file} && " \
  340. "setenv actual_kernel_addr ${kernel_addr_r}\0" \
  341. "tftpramfs=" \
  342. "tftpboot ${rootfsaddr} \"\\\"${rootfsfile}\\\"\" && " \
  343. "setenv loadaddr\0" \
  344. ""
  345. /*
  346. * constants
  347. * - KM specific constants and commands
  348. *
  349. * - 'default': setup default environment
  350. */
  351. #define CONFIG_KM_DEF_ENV_CONSTANTS \
  352. "actual=setenv boot_bank ${actual_bank}\0" \
  353. "backup=setenv boot_bank ${backup_bank}\0" \
  354. "actual_bank=${initial_boot_bank}\0" \
  355. "backup_bank=0\0" \
  356. "default=" \
  357. "setenv default 'run newenv; reset' && " \
  358. "run release && saveenv; reset\0" \
  359. "checkboardidlist=" \
  360. "if test \"x${boardIdListHex}\" != \"x\"; then " \
  361. "IVMbidhwk=${IVM_BoardId}_${IVM_HWKey}; " \
  362. "found=0; " \
  363. "for bidhwk in \"${boardIdListHex}\"; do " \
  364. "echo trying $bidhwk ...; " \
  365. "if test \"x$bidhwk\" = \"x$IVMbidhwk\"; then " \
  366. "found=1; " \
  367. "echo match found for $bidhwk; " \
  368. "if test \"x$bidhwk\" != \"x${boardId}_${hwKey}\";then "\
  369. "setenv boardid ${IVM_BoardId}; " \
  370. "setenv boardId ${IVM_BoardId}; " \
  371. "setenv hwkey ${IVM_HWKey}; " \
  372. "setenv hwKey ${IVM_HWKey}; " \
  373. "echo \"boardId set to ${boardId}\"; " \
  374. "echo \"hwKey set to ${hwKey}\"; " \
  375. "saveenv; " \
  376. "fi; " \
  377. "fi; " \
  378. "done; " \
  379. "else " \
  380. "echo \"boardIdListHex not set, not checked\"; "\
  381. "found=1; " \
  382. "fi; " \
  383. "test \"$found\" = 1 \0" \
  384. "checkboardid=" \
  385. "test \"x${boardId}\" = \"x${IVM_BoardId}\" && " \
  386. "test \"x${hwKey}\" = \"x${IVM_HWKey}\"\0" \
  387. "printbootargs=print bootargs\0" \
  388. "rootfsfile="xstr(CONFIG_HOSTNAME) "/rootfsImage\0" \
  389. ""
  390. #ifndef CONFIG_KM_DEF_ENV
  391. #define CONFIG_KM_DEF_ENV \
  392. CONFIG_KM_DEF_ENV_BOOTPARAMS \
  393. CONFIG_KM_DEF_NETDEV \
  394. CONFIG_KM_DEF_ENV_CPU \
  395. CONFIG_KM_DEF_ENV_BOOTRUNNER \
  396. CONFIG_KM_DEF_ENV_BOOTTARGETS \
  397. CONFIG_KM_DEF_ENV_BOOTARGS \
  398. CONFIG_KM_DEF_ENV_COMPUTE_ADDR \
  399. CONFIG_KM_DEF_ENV_FLASH_BOOT \
  400. CONFIG_KM_DEF_ENV_NET_BOOT \
  401. CONFIG_KM_DEF_ENV_CONSTANTS \
  402. "altbootcmd=run bootcmd\0" \
  403. "bootcmd=run default\0" \
  404. "bootlimit=2\0" \
  405. "init=/sbin/init-overlay.sh\0" \
  406. "kernel_addr_r="xstr(CONFIG_KM_KERNEL_ADDR) "\0" \
  407. "kernel_file="xstr(CONFIG_HOSTNAME) "/uImage\0" \
  408. "kernel_name=uImage\0" \
  409. "load=tftpboot ${u-boot_addr_r} ${u-boot}\0" \
  410. "mtdids=" MTDIDS_DEFAULT "\0" \
  411. "mtdparts=" MTDPARTS_DEFAULT "\0" \
  412. "stderr=serial\0" \
  413. "stdin=serial\0" \
  414. "stdout=serial\0" \
  415. "u-boot="xstr(CONFIG_HOSTNAME) "/u-boot.bin\0" \
  416. "u-boot_addr_r="xstr(CONFIG_KM_KERNEL_ADDR) "\0" \
  417. ""
  418. #endif /* CONFIG_KM_DEF_ENV */
  419. #define CONFIG_VERSION_VARIABLE /* include version env variable */
  420. #endif /* __CONFIG_KEYMILE_H */