Documentation/driver-api/extcon.rst

Source file repositories/reference/linux-study-clean/Documentation/driver-api/extcon.rst

File Facts

System
Linux kernel
Corpus path
Documentation/driver-api/extcon.rst
Extension
.rst
Size
8014 bytes
Lines
256
Domain
Support Tooling And Documentation
Bucket
Documentation
Inferred role
Support Tooling And Documentation: documentation
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

struct extcon_dev {
        const char *name;
        const unsigned int *supported_cable;
        const u32 *mutually_exclusive;

        /* Internal data */
        struct device dev;
        unsigned int id;
        struct raw_notifier_head nh_all;
        struct raw_notifier_head *nh;
        struct list_head entry;
        int max_supported;
        spinlock_t lock;
        u32 state;

        /* Sysfs related */
        struct device_type extcon_dev_type;
        struct extcon_cable *cables;
        struct attribute_group attr_g_muex;
        struct attribute **attrs_muex;
        struct device_attribute *d_attrs_muex;
    };

Key fields:

- ``name``: Name of the Extcon device
- ``supported_cable``: Array of supported cable types
- ``mutually_exclusive``: Array defining mutually exclusive cable types
  This field is crucial for enforcing hardware constraints. It's an array of
  32-bit unsigned integers, where each element represents a set of mutually
  exclusive cable types. The array should be terminated with a 0.

  For example:

  ::

      static const u32 mutually_exclusive[] = {
          BIT(0) | BIT(1),  /* Cable 0 and 1 are mutually exclusive */
          BIT(2) | BIT(3) | BIT(4),  /* Cables 2, 3, and 4 are mutually exclusive */
          0  /* Terminator */
      };

  In this example, cables 0 and 1 cannot be connected simultaneously, and
  cables 2, 3, and 4 are also mutually exclusive. This is useful for
  scenarios like a single port that can either be USB or HDMI, but not both
  at the same time.

  The Extcon core uses this information to prevent invalid combinations of
  cable states, ensuring that the reported states are always consistent
  with the hardware capabilities.

- ``state``: Current state of the device (bitmap of connected cables)


extcon_cable
------------

Represents an individual cable managed by an Extcon device::

    struct extcon_cable {
        struct extcon_dev *edev;
        int cable_index;
        struct attribute_group attr_g;
        struct device_attribute attr_name;
        struct device_attribute attr_state;
        struct attribute *attrs[3];
        union extcon_property_value usb_propval[EXTCON_PROP_USB_CNT];
        union extcon_property_value chg_propval[EXTCON_PROP_CHG_CNT];
        union extcon_property_value jack_propval[EXTCON_PROP_JACK_CNT];
        union extcon_property_value disp_propval[EXTCON_PROP_DISP_CNT];

Annotation

Implementation Notes