summaryrefslogtreecommitdiffstats
path: root/commands/i2c.c
Commit message (Collapse)AuthorAgeFilesLines
* commands: i2c_read: default to reading one byteRoland Hieber2023-11-221-2/+2
| | | | | | | | | | | | | | | | | The help text for i2c_read specifies that -c is optional: Usage: i2c_read [-bacrwv] However, using i2c_read without -c falls through in do_i2c_read(): if ((addr < 0) || (count < 1) || (addr > 0x7F)) return COMMAND_ERROR_USAGE; Actually make -c optional by initialising the count to 1. Signed-off-by: Roland Hieber <rhi@pengutronix.de> Link: https://lore.barebox.org/20231122110641.3683555-1-rhi@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c_probe: Use "read_byte" command for probingAlexander Shiyan2020-11-091-2/+4
| | | | | | | | Some I2C adapters do not allow zero length data transfers, such as the AM335X. To use the i2c_probe command, let's use byte reading for this purpose. Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands/*: Replace license and copyright boilerplate by SPDX identfiersUwe Kleine-König2020-04-271-16/+4
| | | | | | | | | | | | | While at it also drop references to the non-existing CREDITS file and do some small rearrangements for some uniform formatting. (SPDX-License-Identifier first, then copyright texts and then an empty line.) The advantage is that these specifiers are machine-parseable which helps license conformance. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c_probe command: Use kstrtointSascha Hauer2020-02-141-5/+25
| | | | | | | Use kstrtoint rather than simple_strtoul to catch erroneous input like "i2c1" which previously was silently interpreted as "0". Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c_probe: Use a quick write transfer instead of writing a zeroUwe Kleine-König2019-01-281-8/+8
| | | | | | | | | | | | | | This matches the method implemented in i2cdetect(8) when using its -q option. With this change an rx8130 RTC is detectable using i2c_probe. This failed before because this chip acks the first byte (containing its address and the R/̅W bit) but nacks the following 0 (representing the target address to write nothing to) which makes i2c_write_reg() return with an error and so the chip is not listed as available. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c_probe: limit slave addresses to [0x04, 0x77]Uwe Kleine-König2019-01-281-4/+6
| | | | | | | | | | | | | | | Adresses below 0x04 and above 0x77 are reserved in the i2c bus specification, so don't probe these addresses unless requested explicitly. Also do more strict boundary checking: - ensure start address is greater or equal to zero; - don't decrease stopaddr after checking it being greater or equal to startaddr. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c_read: implement support for master receive modeAleksander Morgado2018-08-221-6/+15
| | | | | | | | If no start register is explicitly given, receive data in master receive mode. Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c_write: document master send modeAleksander Morgado2018-08-221-3/+7
| | | | | | | | When no explicit start register is given, the i2c message is emitted in master send mode. Signed-off-by: Aleksander Morgado <aleksander@aleksander.es> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands: i2c_write: enable reg == 0 tooAntony Pavlov2018-04-171-1/+1
| | | | | | | | | | | | | This commit fixes the mistake introduced in the commit 34fadb685905 ('commands: i2c_write: enable raw write to address'). The intended behaviour for i2c_write command is "use raw i2c write only if reg address is not defined". Before the commit 34fadb685905 reg address == 0 was acceptable. After the commit 34fadb685905 reg address == 0 became unacceptable ("undefined") and will lead to raw i2c write. Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands: i2c_write: enable raw write to addressAntony Pavlov2018-02-091-2/+6
| | | | | | | | | | | | | | | | | | | | Sometimes for communication with a simple I2C devices (e.g. PCF8574 or TM1650) it's necessary to send only one data byte into the I2C device. Current i2c_write command makes this impossible because you can't just pass 'device address' and 'register number' (or 'device address' and 'one data byte') to the command. You always have to pass all three parameters: 'device address', 'register number' and 'data'. This commit fixes the problem. Sample usage: barebox@barebox sandbox:/ i2c_write -a 0x24 0x01 Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands: i2c: do not restrict i2c_write's data to be hex-formattedUlrich Ölmann2017-10-231-1/+1
| | | | | | | | | | | Change the default base to 0 to be consistent with the "mw" command and particularly allow decimally formatted data. The price to pay is needing the usual prefix "0x" for each hex-formatted number. Signed-off-by: Ulrich Ölmann <u.oelmann@pengutronix.de> Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands: i2c: Listen for CTRL-C when probingAndrey Smirnov2017-01-101-1/+1
| | | | | | | | | Allow I2C bus probing to be interrupted early by sending CTRL-C. This is usefull when calling the tool without any arguments and one of the busses is misconfigured (waiting for 100+ failures is pretty inconvenient). Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* documentation: i2c_read() does not expect any "DATA".Andreas Geisenhainer2016-04-281-1/+1
| | | | | | | Remove information about DATA from help text. Signed-off-by: Andreas Geisenhainer <Andreas.Geisenhainer@atsonline.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c_probe: fix wrong start and stop addressesMiquel Raynal2016-04-151-1/+1
| | | | | | | | | | This patch fixes the wrong range of i2c addresses used by the i2c_probe command when a stop address is provided. In this case the start address (startaddr) was taking the value of the stop address and the stop address (stopaddr) was always set to its default value. Signed-off-by: Miquel Raynal <raynal.miquel@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c_probe: Make command easier to work withSascha Hauer2015-11-191-19/+37
| | | | | | | | Instead of insisting on multiple parameters just use sane defaults. This allows us to scan all addresses on all busses which is normally what one wants to get an overview over devices on i2c busses. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands: i2c: add message if write is not successfulSilvio Fricke2014-07-141-1/+5
| | | | | Signed-off-by: Silvio Fricke <silvio.fricke@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands: i2c: simplify i2c wide access logicSilvio Fricke2014-07-141-4/+4
| | | | | Signed-off-by: Silvio Fricke <silvio.fricke@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands: i2c: verbose option doesn't need argumentSilvio Fricke2014-07-141-2/+2
| | | | | Signed-off-by: Silvio Fricke <silvio.fricke@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands: harmonize in-barebox documentationHolger Schurig2014-05-141-21/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch does probably too much, but it's hard (and very cumbersome/time consuming) to break it out. What is does is this: * each command has one short description, e.g. "list MUX configuration" * made sure the short descriptions start lowercase * each command has one usage. That string contains just the options, e.g. "[-npn]". It's not part of the long help text. * that is, it doesn't say "[OPTIONS]" anymore, every usable option is listed by character in this (short) option string (the long description is in the long help text, as before) * help texts have been reworked, to make them - sometimes smaller - sometimes describe the options better - more often present themselves in a nicer format * all long help texts are now created with BUSYBOX_CMD_HELP_ macros, no more 'static const __maybe_unused char cmd_foobar_help[]' * made sure the long help texts starts uppercase * because cmdtp->name and cmdtp->opts together provide the new usage, all "Usage: foobar" texts have been removed from the long help texts * BUSYBOX_CMD_HELP_TEXT() provides the trailing newline by itself, this is nicer in the source code * BUSYBOX_CMD_HELP_OPT() provides the trailing newline by itself * made sure no line gets longer than 77 characters * delibertely renamed cmdtp->usage, so that we can get compile-time errors (e.g. in out-of-tree modules that use register_command() * the 'help' command can now always emit the usage, even without compiled long help texts * 'help -v' gives a list of commands with their short description, this is similar like the old "help" command before my patchset * 'help -a' gives out help of all commands Signed-off-by: Holger Schurig <holgerschurig@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands: group 'help' outputHolger Schurig2014-05-141-0/+3
| | | | | | | | | | | | | | | | | | | The old output of "help" was just producing a long list, that usually scrolled of the screen (even on a X11 terminal). This list is more compact, and also sorted by groups. The old output format (plus grouping) is now available with 'help -v'. Example: Information commands: ?, devinfo, help, iomem, meminfo, version Boot commands: boot, bootm, go, loadb, loads, loadx, loady, saves, uimage ... Signed-off-by: Holger Schurig <holgerschurig@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands: i2c: change 0X to 0xJan Luebbe2013-04-091-1/+1
| | | | | Signed-off-by: Jan Luebbe <jlu@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Treewide: remove address of the Free Software FoundationSascha Hauer2012-09-171-4/+0
| | | | | | | The FSF address has changed in the past. Instead of updating it each time the address changes, just drop it completely treewide. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'master' into nextSascha Hauer2012-05-161-1/+1
|\
| * i2c: Fix barebox crash when 'count' is not set for i2c_read commandAlexander Shiyan2012-05-111-1/+1
| | | | | | | | | | | | | | | | | | | | Running i2c_read without the 'count' setting causes an error and reboots. barebox@Phytec phyCORE-i.MX27:/ i2c_read -b 1 -a 0x4a -r 0x00 ERROR: out of memory no stack data available Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | i2c: Added switch for allowing usage 16bit register addressesAlexander Shiyan2012-05-131-9/+17
|/ | | | | Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands: remove struct command pointer from commandsSascha Hauer2012-02-271-3/+3
| | | | | | This is unused in all commands and thus can be removed. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands: add i2c commandsEric Bénard2010-05-261-0/+214
theses commands allow low level access to i2c bus and can be useful to setup an i2c device without having to add code, compile and flash barebox. Signed-off-by: Eric Bénard <eric@eukrea.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>