Lines Matching +full:i2c +full:- +full:sda +full:- +full:hold +full:- +full:time +full:- +full:ns

1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * i2c.h - definitions for the Linux i2c bus interface
4 * Copyright (C) 1995-2000 Simon G. Vogl
5 * Copyright (C) 2013-2019 Wolfram Sang <wsa@kernel.org>
24 #include <uapi/linux/i2c.h>
30 /* --- General options ------------------------------------------------ */
44 /* I2C Frequency Modes */
62 * transmit one message at a time, a more complex version can be used to
70 * i2c_master_recv - issue a single I2C message in master receive mode
84 * i2c_master_recv_dmasafe - issue a single I2C message in master receive mode
100 * i2c_master_send - issue a single I2C message in master transmit mode
114 * i2c_master_send_dmasafe - issue a single I2C message in master transmit mode
192 #endif /* I2C */
195 * struct i2c_device_identity - i2c client device identification
196 * @manufacturer_id: 0 - 4095, database maintained by NXP
197 * @part_id: 0 - 511, according to manufacturer
198 * @die_revision: 0 - 7, according to manufacturer
227 * enum i2c_driver_flags - Flags for an I2C device driver
236 * struct i2c_driver - represent an I2C device driver
237 * @class: What kind of i2c device we instantiate (for detect)
238 * @probe: Callback for device binding - soon to be deprecated
243 * @command: Callback for bus-wide signaling (optional)
245 * @id_table: List of I2C devices supported by this driver
247 * @address_list: The I2C addresses to probe (for detect)
248 * @clients: List of detected clients we created (for i2c-core use only)
262 * for the many I2C/SMBus devices which can't be detected reliably, and
291 * 16-bit payload data reported by the slave device acting as master.
314 * struct i2c_client - represent an I2C slave device
316 * @addr: Address used on the I2C bus connected to the parent adapter.
318 * generic enough to hide second-sourcing and compatible revisions.
319 * @adapter: manages the bus segment hosting this I2C device
323 * @detected: member of an i2c_driver.clients list or i2c-core's
325 * @slave_cb: Callback when I2C slave mode of an adapter is used. The adapter
331 * i2c bus. The behaviour exposed to Linux is defined by the driver
340 #define I2C_CLIENT_HOST_NOTIFY 0x40 /* We want to use I2C host notify */
345 unsigned short addr; /* chip address - NOTE: 7bit */
373 return dev_get_drvdata(&client->dev); in i2c_get_clientdata()
378 dev_set_drvdata(&client->dev, data); in i2c_set_clientdata()
381 /* I2C slave support */
402 * struct i2c_board_info - template for device creation
406 * @dev_name: Overrides the default <busnr>-<addr> dev_name if set
415 * I2C doesn't actually support hardware probing, although controllers and
420 * i2c_board_info is used to build tables of information listing I2C devices
423 * bus numbers identify adapters that aren't yet available. For add-on boards,
441 * I2C_BOARD_INFO - macro used to list an i2c device and its address
447 * fields (such as associated irq, or device-specific platform_data)
456 * Add-on boards should register/unregister their devices; e.g. a board
457 * with integrated I2C, a config eeprom, sensors, and a codec that's
463 /* If you don't know the exact address of an I2C device, use this variant
497 #endif /* I2C */
499 /* Mainboard arch_initcall() code should register all its I2C devices.
500 * This is done at arch_initcall time, before declaring any i2c adapters.
501 * Modules for add-on boards must use other calls.
517 * struct i2c_algorithm - represent I2C transfer method
518 * @master_xfer: Issue a set of i2c transactions to the given I2C adapter
523 * @smbus_xfer: Issue smbus transactions to the given I2C adapter. If this
525 * into I2C transfers instead.
530 * @reg_slave: Register given client to I2C slave mode of this adapter
531 * @unreg_slave: Unregister given client from I2C slave mode of this adapter
535 * be addressed using the same bus algorithms - i.e. bit-banging or the PCF8584
540 * Kernel Documentation file Documentation/i2c/fault-codes.rst. Otherwise, the
545 * If an adapter algorithm can't do I2C-level access, set master_xfer
548 * using common I2C messages.
574 * struct i2c_lock_operations - represent I2C locking operations
575 * @lock_bus: Get exclusive access to an I2C bus segment
576 * @trylock_bus: Try to get exclusive access to an I2C bus segment
577 * @unlock_bus: Release exclusive access to an I2C bus segment
588 * struct i2c_timings - I2C timing information
590 * @scl_rise_ns: time SCL signal takes to rise in ns; t(r) in the I2C specification
591 * @scl_fall_ns: time SCL signal takes to fall in ns; t(f) in the I2C specification
592 * @scl_int_delay_ns: time IP core additionally needs to setup SCL in ns
593 * @sda_fall_ns: time SDA signal takes to fall in ns; t(f) in the I2C specification
594 * @sda_hold_ns: time IP core additionally needs to hold SDA in ns
595 * @digital_filter_width_ns: width in ns of spikes on i2c lines that the IP core
612 * struct i2c_bus_recovery_info - I2C bus recovery information
619 * @get_sda: This gets current value of SDA line. This or set_sda() is mandatory
622 * @set_sda: This sets/clears the SDA line. This or get_sda() is mandatory for
626 * has a more complex internal logic than just reading SDA. Optional.
628 * configure padmux here for SDA/SCL line or something else they want.
630 * may configure padmux here for SDA/SCL line or something else they want.
632 * @sda_gpiod: gpiod of the SDA line. Only required for GPIO recovery.
633 * @pinctrl: pinctrl used by GPIO recovery to change the state of the I2C pins.
635 * @pins_default: default pinctrl state of SCL/SDA lines, when they are assigned
636 * to the I2C bus. Optional. Populated internally for GPIO recovery, if
638 * @pins_gpio: recovery pinctrl state of SCL/SDA lines, when they are used as
668 * struct i2c_adapter_quirks - describe flaws of an i2c adapter
676 * Note about combined messages: Some I2C controllers can only send one message
677 * per transfer, plus something called combined message or write-then-read.
683 * write-then-anything or other variants. To support that, write-then-read has
684 * been broken out into smaller bits like write-first and read-second which can
705 /* convenience macro for typical write-then read case */
718 * i2c_adapter is the structure used to identify a physical i2c bus along
735 unsigned long locked_flags; /* owned by the I2C core */
756 return dev_get_drvdata(&adap->dev); in i2c_get_adapdata()
761 dev_set_drvdata(&adap->dev, data); in i2c_set_adapdata()
768 struct device *parent = adapter->dev.parent; in i2c_parent_is_i2c_adapter()
770 if (parent != NULL && parent->type == &i2c_adapter_type) in i2c_parent_is_i2c_adapter()
784 * i2c_lock_bus - Get exclusive access to an I2C bus segment
785 * @adapter: Target I2C bus segment
786 * @flags: I2C_LOCK_ROOT_ADAPTER locks the root i2c adapter, I2C_LOCK_SEGMENT
792 adapter->lock_ops->lock_bus(adapter, flags); in i2c_lock_bus()
796 * i2c_trylock_bus - Try to get exclusive access to an I2C bus segment
797 * @adapter: Target I2C bus segment
798 * @flags: I2C_LOCK_ROOT_ADAPTER tries to locks the root i2c adapter,
801 * Return: true if the I2C bus segment is locked, false otherwise
806 return adapter->lock_ops->trylock_bus(adapter, flags); in i2c_trylock_bus()
810 * i2c_unlock_bus - Release exclusive access to an I2C bus segment
811 * @adapter: Target I2C bus segment
812 * @flags: I2C_LOCK_ROOT_ADAPTER unlocks the root i2c adapter, I2C_LOCK_SEGMENT
818 adapter->lock_ops->unlock_bus(adapter, flags); in i2c_unlock_bus()
822 * i2c_mark_adapter_suspended - Report suspended state of the adapter to the core
834 set_bit(I2C_ALF_IS_SUSPENDED, &adap->locked_flags); in i2c_mark_adapter_suspended()
839 * i2c_mark_adapter_resumed - Report resumed state of the adapter to the core
849 clear_bit(I2C_ALF_IS_SUSPENDED, &adap->locked_flags); in i2c_mark_adapter_resumed()
853 /* i2c adapter classes (bitmask) */
863 /* Construct an I2C_CLIENT_END-terminated array of i2c addresses */
868 /* ----- functions exported by i2c.o */
887 return !IS_ERR_OR_NULL(client) && client->dev.driver; in i2c_client_has_driver()
890 /* call the i2c_client->command() of all attached clients with
904 return adap->algo->functionality(adap); in i2c_get_functionality()
914 * i2c_check_quirks() - Function for checking the quirk flags in an i2c adapter
915 * @adap: i2c adapter
922 if (!adap->quirks) in i2c_check_quirks()
924 return (adap->quirks->flags & quirks) == quirks; in i2c_check_quirks()
930 return adap->nr; in i2c_adapter_id()
935 return (msg->addr << 1) | (msg->flags & I2C_M_RD ? 1 : 0); in i2c_8bit_addr_from_msg()
943 * module_i2c_driver() - Helper macro for registering a modular I2C driver
946 * Helper macro for I2C drivers which do not do anything special in module
955 * builtin_i2c_driver() - Helper macro for registering a builtin I2C driver
958 * Helper macro for I2C drivers which do not do anything special in their
965 #endif /* I2C */
1012 return -ENOTSUPP; in of_i2c_get_board_info()
1022 struct acpi_resource_i2c_serialbus **i2c);
1032 struct acpi_resource_i2c_serialbus **i2c) in i2c_acpi_get_i2c_resource() argument
1048 return ERR_PTR(-ENODEV); in i2c_acpi_new_device_by_fwnode()