Commit b37c7e5e5c3c80c68f49a31c4308b159bb5bda1a
1 parent
b0fce99bfc
Exists in
master
and in
54 other branches
* Patch by Seb James, 30 Jun 2003:
Improve documentation of I2C configuration in README * Fix problems with previous log buffer "fixes" * Fix minor help text issues * "log append" did not append a newline
Showing 5 changed files with 75 additions and 23 deletions Side-by-side Diff
CHANGELOG
1 | 1 | ====================================================================== |
2 | +Changes for U-Boot 0.4.2: | |
3 | +====================================================================== | |
4 | + | |
5 | +* Patch by Seb James, 30 Jun 2003: | |
6 | + Improve documentation of I2C configuration in README | |
7 | + | |
8 | +* Fix problems with previous log buffer "fixes" | |
9 | + | |
10 | +* Fix minor help text issues | |
11 | + | |
12 | +* "log append" did not append a newline | |
13 | + | |
14 | +====================================================================== | |
2 | 15 | Changes for U-Boot 0.4.1: |
3 | 16 | ====================================================================== |
4 | 17 |
README
... | ... | @@ -653,6 +653,9 @@ |
653 | 653 | CONFIG_RTC_DS1338 - use Maxim, Inc. DS1338 RTC |
654 | 654 | CONFIG_RTC_DS164x - use Dallas DS164x RTC |
655 | 655 | |
656 | + Note that if the RTC uses I2C, then the I2C interface | |
657 | + must also be configured. See I2C Support, below. | |
658 | + | |
656 | 659 | - Timestamp Support: |
657 | 660 | |
658 | 661 | When CONFIG_TIMESTAMP is selected, the timestamp |
659 | 662 | |
660 | 663 | |
661 | 664 | |
662 | 665 | |
663 | 666 | |
664 | 667 | |
665 | 668 | |
666 | 669 | |
667 | 670 | |
... | ... | @@ -904,29 +907,48 @@ |
904 | 907 | |
905 | 908 | - I2C Support: CONFIG_HARD_I2C | CONFIG_SOFT_I2C |
906 | 909 | |
907 | - Enables I2C serial bus commands. If this is selected, | |
908 | - either CONFIG_HARD_I2C or CONFIG_SOFT_I2C must be defined | |
909 | - to include the appropriate I2C driver. | |
910 | + These enable I2C serial bus commands. Defining either of | |
911 | + (but not both of) CONFIG_HARD_I2C or CONFIG_SOFT_I2C will | |
912 | + include the appropriate I2C driver for the selected cpu. | |
910 | 913 | |
911 | - See also: common/cmd_i2c.c for a description of the | |
914 | + This will allow you to use i2c commands at the u-boot | |
915 | + command line (as long as you set CFG_CMD_I2C in | |
916 | + CONFIG_COMMANDS) and communicate with i2c based realtime | |
917 | + clock chips. See common/cmd_i2c.c for a description of the | |
912 | 918 | command line interface. |
913 | 919 | |
920 | + CONFIG_HARD_I2C selects the CPM hardware driver for I2C. | |
914 | 921 | |
915 | - CONFIG_HARD_I2C | |
922 | + CONFIG_SOFT_I2C configures u-boot to use a software (aka | |
923 | + bit-banging) driver instead of CPM or similar hardware | |
924 | + support for I2C. | |
916 | 925 | |
917 | - Selects the CPM hardware driver for I2C. | |
926 | + There are several other quantities that must also be | |
927 | + defined when you define CONFIG_HARD_I2C or CONFIG_SOFT_I2C. | |
918 | 928 | |
919 | - CONFIG_SOFT_I2C | |
929 | + In both cases you will need to define CFG_I2C_SPEED | |
930 | + to be the frequency (in Hz) at which you wish your i2c bus | |
931 | + to run and CFG_I2C_SLAVE to be the address of this node (ie | |
932 | + the cpu's i2c node address). | |
933 | + | |
934 | + Now, the u-boot i2c code for the mpc8xx (cpu/mpc8xx/i2c.c) | |
935 | + sets the cpu up as a master node and so its address should | |
936 | + therefore be cleared to 0 (See, eg, MPC823e User's Manual | |
937 | + p.16-473). So, set CFG_I2C_SLAVE to 0. | |
920 | 938 | |
921 | - Use software (aka bit-banging) driver instead of CPM | |
922 | - or similar hardware support for I2C. This is configured | |
923 | - via the following defines. | |
939 | + That's all that's required for CONFIG_HARD_I2C. | |
924 | 940 | |
941 | + If you use the software i2c interface (CONFIG_SOFT_I2C) | |
942 | + then the following macros need to be defined (examples are | |
943 | + from include/configs/lwmon.h): | |
944 | + | |
925 | 945 | I2C_INIT |
926 | 946 | |
927 | - (Optional). Any commands necessary to enable I2C | |
947 | + (Optional). Any commands necessary to enable the I2C | |
928 | 948 | controller or configure ports. |
929 | 949 | |
950 | + eg: #define I2C_INIT (immr->im_cpm.cp_pbdir |= PB_SCL) | |
951 | + | |
930 | 952 | I2C_PORT |
931 | 953 | |
932 | 954 | (Only for MPC8260 CPU). The I/O port to use (the code |
933 | 955 | |
934 | 956 | |
935 | 957 | |
936 | 958 | |
937 | 959 | |
... | ... | @@ -939,32 +961,49 @@ |
939 | 961 | (driven). If the data line is open collector, this |
940 | 962 | define can be null. |
941 | 963 | |
964 | + eg: #define I2C_ACTIVE (immr->im_cpm.cp_pbdir |= PB_SDA) | |
965 | + | |
942 | 966 | I2C_TRISTATE |
943 | 967 | |
944 | 968 | The code necessary to make the I2C data line tri-stated |
945 | 969 | (inactive). If the data line is open collector, this |
946 | 970 | define can be null. |
947 | 971 | |
972 | + eg: #define I2C_TRISTATE (immr->im_cpm.cp_pbdir &= ~PB_SDA) | |
973 | + | |
948 | 974 | I2C_READ |
949 | 975 | |
950 | 976 | Code that returns TRUE if the I2C data line is high, |
951 | 977 | FALSE if it is low. |
952 | 978 | |
979 | + eg: #define I2C_READ ((immr->im_cpm.cp_pbdat & PB_SDA) != 0) | |
980 | + | |
953 | 981 | I2C_SDA(bit) |
954 | 982 | |
955 | 983 | If <bit> is TRUE, sets the I2C data line high. If it |
956 | 984 | is FALSE, it clears it (low). |
957 | 985 | |
986 | + eg: #define I2C_SDA(bit) \ | |
987 | + if(bit) immr->im_cpm.cp_pbdat |= PB_SDA; \ | |
988 | + else immr->im_cpm.cp_pbdat &= ~PB_SDA | |
989 | + | |
958 | 990 | I2C_SCL(bit) |
959 | 991 | |
960 | 992 | If <bit> is TRUE, sets the I2C clock line high. If it |
961 | 993 | is FALSE, it clears it (low). |
962 | 994 | |
995 | + eg: #define I2C_SCL(bit) \ | |
996 | + if(bit) immr->im_cpm.cp_pbdat |= PB_SCL; \ | |
997 | + else immr->im_cpm.cp_pbdat &= ~PB_SCL | |
998 | + | |
963 | 999 | I2C_DELAY |
964 | 1000 | |
965 | 1001 | This delay is invoked four times per clock cycle so this |
966 | 1002 | controls the rate of data transfer. The data rate thus |
967 | - is 1 / (I2C_DELAY * 4). | |
1003 | + is 1 / (I2C_DELAY * 4). Often defined to be something | |
1004 | + like: | |
1005 | + | |
1006 | + #define I2C_DELAY udelay(2) | |
968 | 1007 | |
969 | 1008 | CFG_I2C_INIT_BOARD |
970 | 1009 |
common/cmd_bmp.c
common/cmd_log.c
... | ... | @@ -74,22 +74,26 @@ |
74 | 74 | void logbuff_init_ptrs (void) |
75 | 75 | { |
76 | 76 | DECLARE_GLOBAL_DATA_PTR; |
77 | + unsigned long *ext_tag; | |
77 | 78 | char *s; |
78 | 79 | |
79 | 80 | log_buf = (unsigned char *)(gd->bd->bi_memsize-LOGBUFF_LEN); |
80 | - ext_log_start = (unsigned long *)(log_buf)-3; | |
81 | + ext_tag = (unsigned long *)(log_buf)-4; | |
82 | + ext_log_start = (unsigned long *)(log_buf)-3; | |
81 | 83 | ext_log_size = (unsigned long *)(log_buf)-2; |
82 | 84 | ext_logged_chars = (unsigned long *)(log_buf)-1; |
83 | 85 | #ifdef CONFIG_POST |
84 | 86 | /* The post routines have setup the word so we can simply test it */ |
85 | - if (post_word_load () & POST_POWERON) { | |
87 | + if ((post_word_load () & 0xffff) == POST_POWERON) { | |
86 | 88 | logged_chars = log_size = log_start = 0; |
89 | + *ext_tag = LOGBUFF_MAGIC; | |
87 | 90 | } |
88 | 91 | #else |
89 | 92 | /* No post routines, so we do our own checking */ |
90 | 93 | if (post_word_load () != LOGBUFF_MAGIC) { |
91 | 94 | logged_chars = log_size = log_start = 0; |
92 | 95 | post_word_store (LOGBUFF_MAGIC); |
96 | + *ext_tag = LOGBUFF_MAGIC; | |
93 | 97 | } |
94 | 98 | #endif |
95 | 99 | /* Initialize default loglevel if present */ |
... | ... | @@ -162,12 +166,8 @@ |
162 | 166 | if (strcmp(argv[1],"append") == 0) { |
163 | 167 | /* Log concatenation of all arguments separated by spaces */ |
164 | 168 | for (i=2; i<argc; i++) { |
165 | - if (i<argc-1) { | |
166 | - logbuff_printk (argv[i]); | |
167 | - logbuff_putc (' '); | |
168 | - } else { | |
169 | - logbuff_puts (argv[i]); | |
170 | - } | |
169 | + logbuff_printk (argv[i]); | |
170 | + logbuff_putc ((i<argc-1) ? ' ' : '\n'); | |
171 | 171 | } |
172 | 172 | return 0; |
173 | 173 | } |
... | ... | @@ -205,7 +205,7 @@ |
205 | 205 | cmd_tbl_t U_BOOT_CMD(LOG) = MK_CMD_ENTRY( |
206 | 206 | "log", 255, 1, do_log, |
207 | 207 | "log - manipulate logbuffer\n", |
208 | - "log info - show pointer details\n" | |
208 | + "info - show pointer details\n" | |
209 | 209 | "log reset - clear contents\n" |
210 | 210 | "log show - show contents\n" |
211 | 211 | "log append <msg> - append <msg> to the logbuffer\n" |