keymile-common.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  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. #define CONFIG_KM_DEF_ENV_IOMUX \
  118. "stderr=serial \0" \
  119. "stdin=serial \0" \
  120. "stdout=serial \0"
  121. /* common powerpc specific env settings */
  122. #ifndef CONFIG_KM_DEF_ENV_BOOTPARAMS
  123. #define CONFIG_KM_DEF_ENV_BOOTPARAMS \
  124. "bootparams=empty\0" \
  125. "initial_boot_bank=0\0"
  126. #endif
  127. #ifndef CONFIG_KM_DEF_NETDEV
  128. #define CONFIG_KM_DEF_NETDEV \
  129. "netdev=eth0\0"
  130. #endif
  131. #ifndef CONFIG_KM_UBI_PARTITION_NAME
  132. #define CONFIG_KM_UBI_PARTITION_NAME "ubi0"
  133. #endif
  134. #ifndef CONFIG_KM_UBI_LINUX_MTD_NAME
  135. #define CONFIG_KM_UBI_LINUX_MTD_NAME "ubi0"
  136. #endif
  137. #define xstr(s) str(s)
  138. #define str(s) #s
  139. /*
  140. * bootrunner
  141. * - run all commands in 'subbootcmds'
  142. * - on error, stop running the remaing commands
  143. */
  144. #define CONFIG_KM_DEF_ENV_BOOTRUNNER \
  145. "bootrunner=" \
  146. "break=0; " \
  147. "for subbootcmd in ${subbootcmds}; do " \
  148. "if test ${break} -eq 0; then; " \
  149. "echo \"[INFO] running \\c\"; " \
  150. "print ${subbootcmd}; " \
  151. "run ${subbootcmd} || break=1; " \
  152. "if test ${break} -eq 1; then; " \
  153. "echo \"[ERR] failed \\c\"; " \
  154. "print ${subbootcmd}; " \
  155. "fi; " \
  156. "fi; " \
  157. "done\0" \
  158. ""
  159. /*
  160. * boottargets
  161. * - set 'subbootcmds' for the bootrunner
  162. * - set 'bootcmd' and 'altbootcmd'
  163. * available targets:
  164. * - 'release': for a standalone system kernel/rootfs from flash
  165. * - 'develop': for development kernel(tftp)/rootfs(NFS)
  166. * - 'ramfs': rootfilesystem in RAM kernel(tftp)/rootfs(RAM)
  167. *
  168. * - 'commonargs': bootargs common to all targets
  169. */
  170. #define CONFIG_KM_DEF_ENV_BOOTTARGETS \
  171. "commonargs=" \
  172. "addip " \
  173. "addtty " \
  174. "addmem " \
  175. "addinit " \
  176. "addvar " \
  177. "addmtdparts " \
  178. "addbootcount " \
  179. "\0" \
  180. "develop=" \
  181. "setenv subbootcmds \"" \
  182. "tftpfdt tftpkernel " \
  183. "nfsargs ${commonargs} " \
  184. "printbootargs boot " \
  185. "\" && " \
  186. "setenv bootcmd \'" \
  187. "run bootrunner" \
  188. "\' && " \
  189. "setenv altbootcmd \'" \
  190. "run bootcmd" \
  191. "\' && " \
  192. "run setboardid && " \
  193. "saveenv && " \
  194. "reset\0" \
  195. "ramfs=" \
  196. "setenv actual_bank -1 && " \
  197. "setenv subbootcmds \"" \
  198. "tftpfdt tftpkernel " \
  199. "setrootfsaddr tftpramfs " \
  200. "flashargs ${commonargs} " \
  201. "addpanic addramfs " \
  202. "printbootargs boot " \
  203. "\" && " \
  204. "setenv bootcmd \'" \
  205. "run bootrunner" \
  206. "\' && " \
  207. "setenv altbootcmd \'" \
  208. "run bootcmd" \
  209. "\' && " \
  210. "run setboardid && " \
  211. "run setramfspram && " \
  212. "saveenv && " \
  213. "reset\0" \
  214. "release=" \
  215. "setenv actual_bank ${initial_boot_bank} && " \
  216. "setenv subbootcmds \"" \
  217. "checkboardid " \
  218. "ubiattach ubicopy " \
  219. "cramfsloadfdt cramfsloadkernel " \
  220. "flashargs ${commonargs} " \
  221. "addpanic " \
  222. "printbootargs boot " \
  223. "\" && " \
  224. "setenv bootcmd \'" \
  225. "run bootrunner; reset" \
  226. "\' && " \
  227. "setenv altbootcmd \'" \
  228. "run actual0 bootcmd; reset" \
  229. "\' && " \
  230. "saveenv && " \
  231. "reset\0" \
  232. ""
  233. /*
  234. * bootargs
  235. * - modify 'bootargs'
  236. *
  237. * - 'addip': add ip configuration
  238. * - 'addmem': limit kernel memory mem=
  239. * - 'addpanic': add kernel panic options
  240. * - 'addramfs': add phram device for the rootfilesysten in ram
  241. * - 'addtty': add console=...
  242. * - 'addvar': add phram device for /var
  243. * - 'nfsargs': default arguments for nfs boot
  244. * - 'flashargs': defaults arguments for flash base boot
  245. *
  246. * processor specific settings
  247. * - 'addbootcount': add boot counter
  248. * - 'addmtdparts': add mtd partition information
  249. */
  250. #define CONFIG_KM_DEF_ENV_BOOTARGS \
  251. "addinit=" \
  252. "setenv bootargs ${bootargs} init=${init}\0" \
  253. "addip=" \
  254. "setenv bootargs ${bootargs} " \
  255. "ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}" \
  256. ":${hostname}:${netdev}:off\0" \
  257. "addmem=" \
  258. "setenv bootargs ${bootargs} mem=0x${pnvramaddr}\0" \
  259. "addpanic=" \
  260. "setenv bootargs ${bootargs} " \
  261. "panic=1 panic_on_oops=1\0" \
  262. "addramfs=" \
  263. "setenv bootargs \"" \
  264. "${bootargs} phram.phram=" \
  265. "rootfs${actual_bank},${rootfsaddr},${rootfssize}\"\0" \
  266. "addtty=" \
  267. "setenv bootargs ${bootargs}" \
  268. " console=" CONFIG_KM_CONSOLE_TTY ",${baudrate}\0" \
  269. "addvar=" \
  270. "setenv bootargs ${bootargs} phram.phram=phvar," \
  271. "${varaddr},0x" xstr(CONFIG_KM_PHRAM) "\0" \
  272. "nfsargs=" \
  273. "setenv bootargs " \
  274. "ubi.mtd=" CONFIG_KM_UBI_LINUX_MTD_NAME " " \
  275. "root=/dev/nfs rw " \
  276. "nfsroot=${serverip}:${rootpath}\0" \
  277. "flashargs=" \
  278. "setenv bootargs " \
  279. "ubi.mtd=" CONFIG_KM_UBI_LINUX_MTD_NAME " " \
  280. "root=mtdblock:rootfs${actual_bank} " \
  281. "rootfstype=squashfs ro\0" \
  282. ""
  283. /*
  284. * compute_addr
  285. * - compute addresses and sizes
  286. * - addresses are calculated form the end of memory 'memsize'
  287. *
  288. * - 'setramfspram': compute PRAM size for ramfs target
  289. * - 'setrootfsaddr': compute rootfilesystem address for phram
  290. */
  291. #define CONFIG_KM_DEF_ENV_COMPUTE_ADDR \
  292. "setboardid=" \
  293. "if test \"x${boardId}\" = \"x\"; then; " \
  294. "setenv boardId ${IVM_BoardId} && " \
  295. "setenv hwKey ${IVM_HWKey}; " \
  296. "else; " \
  297. "echo \\\\c; " \
  298. "fi\0" \
  299. "setramfspram=" \
  300. "setexpr value ${rootfssize} / 0x400 && " \
  301. "setexpr value 0x${value} + ${pram} && " \
  302. "setenv pram 0x${value}\0" \
  303. "setrootfsaddr=" \
  304. "setexpr value ${pnvramaddr} - ${rootfssize} && " \
  305. "setenv rootfsaddr 0x${value}\0" \
  306. ""
  307. /*
  308. * flash_boot
  309. * - commands for booting from flash
  310. *
  311. * - 'cramfsaddr': address to the cramfs (in ram)
  312. * - 'cramfsloadkernel': copy kernel from a cramfs to ram
  313. * - 'ubiattach': attach ubi partition
  314. * - 'ubicopy': copy ubi volume to ram
  315. * - volume names: bootfs0, bootfs1, bootfs2, ...
  316. * - 'ubiparition': mtd parition name for ubi
  317. *
  318. * processor specific settings
  319. * - 'cramfsloadfdt': copy fdt from a cramfs to ram
  320. */
  321. #define CONFIG_KM_DEF_ENV_FLASH_BOOT \
  322. "cramfsaddr="xstr(CONFIG_KM_CRAMFS_ADDR) "\0" \
  323. "cramfsloadkernel=" \
  324. "cramfsload ${kernel_addr_r} uImage && " \
  325. "setenv actual_kernel_addr ${kernel_addr_r}\0" \
  326. "ubiattach=ubi part ${ubipartition}\0" \
  327. "ubicopy=ubi read ${cramfsaddr} bootfs${actual_bank}\0" \
  328. "ubipartition=" CONFIG_KM_UBI_PARTITION_NAME "\0" \
  329. ""
  330. /*
  331. * net_boot
  332. * - commands for booting over the network
  333. *
  334. * - 'tftpkernel': load a kernel with tftp into ram
  335. * - 'tftpramfs': load rootfs with tftp into ram
  336. *
  337. * processor specific settings
  338. * - 'tftpfdt': load fdt with tftp into ram
  339. */
  340. #define CONFIG_KM_DEF_ENV_NET_BOOT \
  341. "tftpkernel=" \
  342. "tftpboot ${kernel_addr_r} ${kernel_file} && " \
  343. "setenv actual_kernel_addr ${kernel_addr_r}\0" \
  344. "tftpramfs=" \
  345. "tftpboot ${rootfsaddr} \"\\\"${rootfsfile}\\\"\" && " \
  346. "setenv loadaddr\0" \
  347. ""
  348. /*
  349. * constants
  350. * - KM specific constants and commands
  351. *
  352. * - 'default': setup default environment
  353. */
  354. #define CONFIG_KM_DEF_ENV_CONSTANTS \
  355. "actual=setenv actual_bank ${initial_boot_bank}\0" \
  356. "actual0=setenv actual_bank 0\0" \
  357. "actual_bank=${initial_boot_bank}\0" \
  358. "default=" \
  359. "setenv default 'run newenv; reset' && " \
  360. "run release && saveenv; reset\0" \
  361. "checkboardid=" \
  362. "test \"x${boardId}\" = \"x${IVM_BoardId}\"\0" \
  363. "printbootargs=print bootargs\0" \
  364. "rootfsfile="xstr(CONFIG_HOSTNAME) "/rootfsImage\0" \
  365. ""
  366. #ifndef CONFIG_KM_DEF_ENV
  367. #define CONFIG_KM_DEF_ENV \
  368. CONFIG_KM_DEF_ENV_BOOTPARAMS \
  369. CONFIG_KM_DEF_ENV_IOMUX \
  370. CONFIG_KM_DEF_NETDEV \
  371. CONFIG_KM_DEF_ENV_CPU \
  372. CONFIG_KM_DEF_ENV_BOOTRUNNER \
  373. CONFIG_KM_DEF_ENV_BOOTTARGETS \
  374. CONFIG_KM_DEF_ENV_BOOTARGS \
  375. CONFIG_KM_DEF_ENV_COMPUTE_ADDR \
  376. CONFIG_KM_DEF_ENV_FLASH_BOOT \
  377. CONFIG_KM_DEF_ENV_NET_BOOT \
  378. CONFIG_KM_DEF_ENV_CONSTANTS \
  379. "altbootcmd=run bootcmd\0" \
  380. "bootcmd=run default\0" \
  381. "bootlimit=2\0" \
  382. "init=/sbin/init-overlay.sh\0" \
  383. "kernel_addr_r="xstr(CONFIG_KM_KERNEL_ADDR) "\0" \
  384. "kernel_file="xstr(CONFIG_HOSTNAME) "/uImage\0" \
  385. "kernel_name=uImage\0" \
  386. "load=tftpboot ${u-boot_addr_r} ${u-boot}\0" \
  387. "mtdids=" MTDIDS_DEFAULT "\0" \
  388. "mtdparts=" MTDPARTS_DEFAULT "\0" \
  389. "u-boot="xstr(CONFIG_HOSTNAME) "/u-boot.bin\0" \
  390. "u-boot_addr_r="xstr(CONFIG_KM_KERNEL_ADDR) "\0" \
  391. ""
  392. #endif /* CONFIG_KM_DEF_ENV */
  393. #define CONFIG_VERSION_VARIABLE /* include version env variable */
  394. #endif /* __CONFIG_KEYMILE_H */