summaryrefslogtreecommitdiff
path: root/common/cmd_i2c.c
Commit message (Collapse)AuthorAgeLines
* cmd_usage(): simplify return code handlingWolfgang Denk2010-07-24-57/+30
| | | | | | | | | | | | | | | | Lots of code use this construct: cmd_usage(cmdtp); return 1; Change cmd_usage() let it return 1 - then we can replace all these ocurrances by return cmd_usage(cmdtp); This fixes a few places with incorrect return code handling, too. Signed-off-by: Wolfgang Denk <wd@denx.de>
* Make sure that argv[] argument pointers are not modified.Wolfgang Denk2010-07-04-15/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The hush shell dynamically allocates (and re-allocates) memory for the argument strings in the "char *argv[]" argument vector passed to commands. Any code that modifies these pointers will cause serious corruption of the malloc data structures and crash U-Boot, so make sure the compiler can check that no such modifications are being done by changing the code into "char * const argv[]". This modification is the result of debugging a strange crash caused after adding a new command, which used the following argument processing code which has been working perfectly fine in all Unix systems since version 6 - but not so in U-Boot: int main (int argc, char **argv) { while (--argc > 0 && **++argv == '-') { /* ====> */ while (*++*argv) { switch (**argv) { case 'd': debug++; break; ... default: usage (); } } } ... } The line marked "====>" will corrupt the malloc data structures and usually cause U-Boot to crash when the next command gets executed by the shell. With the modification, the compiler will prevent this with an error: increment of read-only location '*argv' N.B.: The code above can be trivially rewritten like this: while (--argc > 0 && **++argv == '-') { char *arg = *argv; while (*++arg) { switch (*arg) { ... Signed-off-by: Wolfgang Denk <wd@denx.de> Acked-by: Mike Frysinger <vapier@gentoo.org>
* i2c: made unused function i2c_mux_add_device staticFrans Meulenbroeks2010-03-29-1/+1
| | | | | | and removed it from the .h file Signed-off-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com>
* cmd_i2c: introduced get_alen helper functionFrans Meulenbroeks2010-03-29-72/+47
| | | | | | | The code to parse alen appeared 6 times in the function. Factored this out in a small helper function Signed-off-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com>
* cmd_i2c: moved a define to before the functionsFrans Meulenbroeks2010-03-29-2/+2
| | | | Signed-off-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com>
* cmd_i2c: moved mispositioned comment for i2c mdFrans Meulenbroeks2010-03-29-4/+4
| | | | Signed-off-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com>
* cmd_i2c.c: declared local functions as staticFrans Meulenbroeks2010-03-29-14/+14
| | | | | | Declared all functions that were not called outside the file as static Signed-off-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com>
* cmd_i2c.c: added i2c read to memory functionFrans Meulenbroeks2010-03-21-1/+59
| | | | Signed-off-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com>
* cmd_i2c.c: sorted commands alphabeticallyFrans Meulenbroeks2010-03-21-6/+5
| | | | Signed-off-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com>
* cmd_i2c.c: reworked subcommand handlingFrans Meulenbroeks2010-03-21-32/+45
| | | | Signed-off-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com>
* cmd_i2c.c: reduced subaddress length to 3 bytesFrans Meulenbroeks2010-03-21-5/+5
| | | | | | | | according to some of the comments the subaddress length is 1 or 2, but we are being prepared for the case it becomes 3. However the code also accepted 4. This repairs this by changing the constand 4 to 3. Signed-off-by: Frans Meulenbroeks <fransmeulenbroeks@gmail.com>
* i2c: fix dangling comment in do_i2c_mw()Heiko Schocher2009-12-07-4/+0
| | | | | | | | commit bd3784df94bfeca43fbf34094df9cb1bd3ecca3b deleted some unused code in do_i2c_mw(), but missed to also remove the respective commment. This patch fixes this. Signed-off-by: Heiko Schocher <hs@denx.de>
* Removes dead code in the file common/cmd_i2c.cPratap Chandu2009-12-02-8/+0
| | | | | | | | There is some dead code enclosed by #if 0 .... #endif in the file common/cmd_i2c.c This patch removes the dead code. Signed-off-by: Pratap Chandu <pratap.rrke@gmail.com>
* cmd_i2c: bugfix: add missing braceAlessandro Rubini2009-07-18-3/+3
| | | | | | | | | | | The sub-command parser missed a brace, so "return 0;" is always taken and no error message is diplayed if you say "i2c scan" instead of "i2c probe", for example. Proper brace is added. Also, a misleading and unneeded else is removed. Signed-off-by: Alessandro Rubini <rubini@gnudd.com.it>
* General help message cleanupWolfgang Denk2009-06-12-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Many of the help messages were not really helpful; for example, many commands that take no arguments would not print a correct synopsis line, but "No additional help available." which is not exactly wrong, but not helpful either. Commit ``Make "usage" messages more helpful.'' changed this partially. But it also became clear that lots of "Usage" and "Help" messages (fields "usage" and "help" in struct cmd_tbl_s respective) were actually redundant. This patch cleans this up - for example: Before: => help dtt dtt - Digital Thermometer and Thermostat Usage: dtt - Read temperature from digital thermometer and thermostat. After: => help dtt dtt - Read temperature from Digital Thermometer and Thermostat Usage: dtt Signed-off-by: Wolfgang Denk <wd@denx.de>
* cmd_i2c: Fix i2c help command output when CONFIG_I2C_MUXPeter Tyser2009-06-12-2/+2
| | | | | | | | | | | | | | | | | | | When CONFIG_I2C_MUX was defined the output of 'help i2c' was not correct, eg: => help i2c i2c bus [muxtype:muxaddr:muxchannel] - add a new bus reached over muxes. speed [speed] - show or set I2C bus speed i2c dev [dev] - show or set current I2C bus ... It has been changed to: i2c speed [speed] - show or set I2C bus speed i2c bus [muxtype:muxaddr:muxchannel] - add a new bus reached over muxes i2c dev [dev] - show or set current I2C bus ... Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
* cmd_i2c: Clean up trivial helper functionsPeter Tyser2009-06-12-21/+4
| | | | Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
* cmd_i2c: Clean up i2c command argument parsingPeter Tyser2009-06-12-24/+28
| | | | | | | argc and argv should only be modified once instead of once for every i2c sub-command Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
* i2c: Update references to individual i2c commandsPeter Tyser2009-06-12-16/+11
| | | | | | | | The individual i2c commands imd, imm, inm, imw, icrc32, iprobe, iloop, and isdram are no longer available so all references to them have been updated to the new form of "i2c <cmd>". Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
* i2c: Remove deprecated individual i2c commandsPeter Tyser2009-06-12-58/+0
| | | | | | | | | | | | | The following individual I2C commands have been removed: imd, imm, inm, imw, icrc32, iprobe, iloop, isdram. The functionality of the individual commands is still available via the 'i2c' command. This change only has an impact on those boards which did not have CONFIG_I2C_CMD_TREE defined. Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
* i2c: Create common default i2c_[set|get]_bus_speed() functionsPeter Tyser2009-06-12-0/+18
| | | | | | | | | | | | | New default, weak i2c_get_bus_speed() and i2c_set_bus_speed() functions replace a number of architecture-specific implementations. Also, providing default functions will allow all boards to enable CONFIG_I2C_CMD_TREE. This was previously not possible since the tree-form of the i2c command provides the ability to display and modify the i2c bus speed which requires i2c_[set|get]_bus_speed() to be present. Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
* Command usage cleanupPeter Tyser2009-01-28-9/+9
| | | | | | | | Remove command name from all command "usage" fields and update common/command.c to display "name - usage" instead of just "usage". Also remove newlines from command usage fields. Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
* Standardize command usage messages with cmd_usage()Peter Tyser2009-01-28-12/+12
| | | | Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
* Coding Style cleanup, update CHANGELOGWolfgang Denk2008-11-02-6/+0
| | | | Signed-off-by: Wolfgang Denk <wd@denx.de>
* rename CFG_ macros to CONFIG_SYSJean-Christophe PLAGNIOL-VILLARD2008-10-18-14/+14
| | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* I2C: adding new "i2c bus" Command to the I2C Subsystem.Heiko Schocher2008-10-18-0/+267
| | | | | | | With this Command it is possible to add new I2C Busses, which are behind 1 .. n I2C Muxes. Details see README. Signed-off-by: Heiko Schocher <hs@denx.de>
* I2C: add new command i2c reset.Heiko Schocher2008-10-18-0/+9
| | | | | | | | | | | If I2C Bus is blocked (see doc/I2C_Edge_Conditions), it is not possible to get out of this, until the complete Hardware gets a reset. This new commando calls again i2c_init (and that calls i2c_init_board if defined), which will deblock the I2C Bus. Signed-off-by: Heiko Schocher <hs@denx.de> Signed-off-by: Wolfgang Denk <wd@denx.de>
* cmd_i2c: Fix help for CONFIG_I2C_CMD_TREE && !CONFIG_I2C_MULTI_BUSPeter Tyser2008-10-14-4/+4
| | | | | | | | | | Original code displayed: => help i2c i2c i2c speed [speed] - show or set I2C bus speed i2c md chip address[.0, .1, .2] [# of objects] - read from I2C device ... Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
* move cmd_get_data_size to command.cJean-Christophe PLAGNIOL-VILLARD2008-09-10-1/+0
| | | | | | add CMD_DATA_SIZE macro to enable it Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* mod_i2c_mem() bugfixPeter Tyser2008-08-21-3/+3
| | | | | | | The last used chip, address, and address length were not being stored for the imm and imn commands. Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
* Big white-space cleanup.Wolfgang Denk2008-05-21-8/+8
| | | | | | | | | | | This commit gets rid of a huge amount of silly white-space issues. Especially, all sequences of SPACEs followed by TAB characters get removed (unless they appear in print statements). Also remove all embedded "vim:" and "vi:" statements which hide indentation problems. Signed-off-by: Wolfgang Denk <wd@denx.de>
* Refactor code for "i2c sdram" commandLarry Johnson2008-01-12-291/+220
| | | | Signed-off-by: Larry Johnson <lrj@acm.org>
* Fix "i2c sdram" command for DDR2 DIMMsLarry Johnson2008-01-12-119/+496
| | | | | | | | Many of the SPD bytes for DDR2 SDRAM are not interpreted correctly by the "i2c sdram" command. This patch provides correct alternative interpretations when DDR2 memory is detected. Signed-off-by: Larry Johnson <lrj@acm.org>
* [BUILD] conditionally compile common/cmd_*.c in common/MakefileGrant Likely2007-11-20-5/+0
| | | | | | | Modify common/Makefile to conditionally compile the cmd_*.c files based on the board config. Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
* common/: Remove lingering references to CFG_CMD_* symbols.Jon Loeliger2007-07-10-4/+4
| | | | | | | | Fixed some broken instances of "#ifdef CMD_CFG_IDE" too. Those always evaluated TRUE, and thus were always compiled even when IDE really wasn't defined/wanted. Signed-off-by: Jon Loeliger <jdl@freescale.com>
* common/cmd_[i-n]*: Remove obsolete references to CONFIG_COMMANDS.Jon Loeliger2007-07-08-5/+5
| | | | Signed-off-by: Jon Loeliger <jdl@freescale.com>
* common/cmd_[i-z]* : Augment CONFIG_COMMANDS tests with defined(CONFIG_CMD_*).Jon Loeliger2007-07-04-5/+5
| | | | | | | | | | | | | | This is a compatibility step that allows both the older form and the new form to co-exist for a while until the older can be removed entirely. All transformations are of the form: Before: #if (CONFIG_COMMANDS & CFG_CMD_AUTOSCRIPT) After: #if (CONFIG_COMMANDS & CFG_CMD_AUTOSCRIPT) || defined(CONFIG_CMD_AUTOSCRIPT) Signed-off-by: Jon Loeliger <jdl@freescale.com>
* i2c: Enable "old" i2c commands even when CONFIG_I2C_CMD_TREE is definedStefan Roese2007-03-28-2/+1
| | | | | | | | The "old" i2c commands (iprobe, imd...) are now compiled in again, even when the i2c command tree is enabled via the CONFIG_I2C_CMD_TREE config option. Signed-off-by: Stefan Roese <sr@denx.de>
* [PATCH] I2C: add some more SPD eeprom decoding for DDR2 modulesMatthias Fuchs2007-03-08-0/+2
| | | | Signed-off-by: Matthias Fuchs <matthias.fuchs@esd-electronics.com>
* [PATCH] I2C: disable flat i2c commands when CONFIG_I2C_CMD_TREE is definedMatthias Fuchs2007-03-08-20/+20
| | | | Signed-off-by: Matthias Fuchs <matthias.fuchs@esd-electronics.com>
* mpc83xx: Miscellaneous code style fixesTimur Tabi2006-11-28-130/+75
| | | | | | Implement various code style fixes and similar changes. Signed-off-by: Timur Tabi <timur@freescale.com>
* Add support for multiple I2C busesBen Warren2006-11-03-5/+154
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Hello, Attached is a patch providing support for multiple I2C buses at the command level. The second part of the patch includes an implementation for the MPC834x CPU and MPC8349EMDS board. /*** Note: This patch replaces ticket DNX#2006083042000018 ***/ Signed-off-by: Ben Warren <bwarren@qstreams.com> Overview: 1. Include new 'i2c' command (based on USB implementation) using CONFIG_I2C_CMD_TREE. 2. Allow multiple buses by defining CONFIG_I2C_MULTI_BUS. Note that the commands to change bus number and speed are only available under the new 'i2c' command mentioned in the first bullet. 3. The option CFG_I2C_NOPROBES has been expanded to work in multi-bus systems. When CONFIG_I2C_MULTI_BUS is used, this option takes the form of an array of bus-device pairs. Otherwise, it is an array of uchar. CHANGELOG: Added new 'i2c' master command for all I2C interaction. This is conditionally compiled with CONFIG_I2C_CMD_TREE. New commands added for setting I2C bus speed as well as changing the active bus if the board has more than one (conditionally compiled with CONFIG_I2C_MULTI_BUS). Updated NOPROBE logic to handle multiple buses. Updated README. regards, Ben
* Cleanup for GCC-4.xWolfgang Denk2005-10-13-2/+2
|
* FRAM memory access optimization.2005-08-12-0/+6
|
* * Patches by Thomas Viehweger, 16 Mar 2004:wdenk2004-03-23-114/+114
| | | | | | | | | - show PCI clock frequency on MPC8260 systems - add FCC_PSMR_RMII flag for HiP7 processors - in do_jffs2_fsload(), take load address from load_addr if not set explicit, update load_addr otherwise - replaced printf by putc/puts when no formatting is needed (smaller code size, faster execution)
* * Patch by Martin Krause, 17 Jul 2003:wdenk2003-07-17-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | add delay to get I2C working with "imm" command and s3c24x0_i2c.c * Patch by Richard Woodruff, 17 July 03: - Fixed bug in OMAP1510 baud rate divisor settings. * Patch by Nye Liu, 16 July 2003: MPC860FADS fixes: - add MPC86xADS support (uses MPC86xADS.h) - add 866P/T core support (also MPC859T/MPC859DSL/MPC852T) o PLPRCR changes o BRG changes (EXTAL/XTAL restricted to 10MHz) o don't trust gclk() software measurement by default, depend on CONFIG_8xx_GCLK_FREQ - add DRAM SIMM not installed detection - use more "correct" SDRAM initialization sequence - allow different SDRAM sizes (8xxADS has 8M) - default DER is 0 - remove unused MAMR defines from FADS860T.h (all done in fads.c) - rename MAMR/MBMR defines to be more consistent. Should eventually be merged into MxMR to better reflect the PowerQUICC datasheet. * Patch by Yuli Barcohen, 16 Jul 2003: support new Motorola PQ2FADS-ZU evaluation board which replaced MPC8260ADS and MPC8266ADS
* Patch by Kenneth Johansson, 30 Jun 2003:wdenk2003-07-01-16/+16
| | | | get rid of MK_CMD_ENTRY macro; update doc/README.command
* * Code cleanup:wdenk2003-06-27-1/+57
| | | | | | | | | - remove trailing white space, trailing empty lines, C++ comments, etc. - split cmd_boot.c (separate cmd_bdinfo.c and cmd_load.c) * Patches by Kenneth Johansson, 25 Jun 2003: - major rework of command structure (work done mostly by Michal Cendrowski and Joakim Kristiansen)
* Initial revisionwdenk2002-10-26-0/+868