[PATCH v5 16/16] iio: adc: xilinx-xadc: Add I2C interface support

Andy Shevchenko andriy.shevchenko at intel.com
Tue Nov 10 08:34:35 PST 2026


On Tue, Nov 10, 2026 at 10:32:01AM +0530, Dileep Kumar Nagavarapu wrote:
> Add I2C interface support for Xilinx System Management Wizard IP along
> with the existing AXI memory-mapped interface. This support enables
> monitoring the voltage and temperature on UltraScale+ devices where the
> System Management Wizard is connected via I2C.
> 
> Key changes:
> - Implement 32-bit DRP (Dynamic Reconfiguration Port) packet format
>   as per Xilinx PG185 specification.
> - Add separate I2C probe with xadc_i2c_of_match_table to handle same
>   compatible string ("xlnx,system-management-wiz-1.3") on I2C bus.
> - Add NULL checks for get_dclk_rate callback function in sampling rate
>   functions to support interfaces without clock control
> - Create separate iio_info structure(xadc_i2c_info) without event
>   callbacks for I2C devices
> - Add xadc_i2c_transaction() function to handle I2C read/write operations
> - Add XADC_TYPE_US_I2C type to distinguish I2C interface from AXI
> - Defer XADC hardware initialization until first device access, since the
>   I2C path reaches the PL SysMon indirectly through a platform controller
>   DRP bridge that may not yet be operational at probe() time. Initializing
>   on first read/write instead avoids probe failures caused by transient
>   unavailability of that downstream path.

...

> +struct xadc_i2c {
> +	struct xadc xadc;
> +	struct i2c_client *client;
> +	bool hw_initialized;
> +	unsigned int conf0;
> +	unsigned int bipolar_mask;
> +};

Have you run `pahole`?

...

> +static int xadc_i2c_probe(struct i2c_client *client)
> +{
> +	struct device *dev = &client->dev;
> +	unsigned int conf0, bipolar_mask;
> +	const struct xadc_ops *ops;
> +	struct iio_dev *indio_dev;
> +	struct xadc_i2c *xadc_i2c;
> +	struct xadc *xadc;
> +	int ret;
> +
> +	ops = device_get_match_data(dev);
> +	if (!ops)
> +		return -ENODEV;

-ENODATA

> +	indio_dev = xadc_device_setup(dev, sizeof(*xadc_i2c), ops);
> +	if (IS_ERR(indio_dev))
> +		return PTR_ERR(indio_dev);
> +
> +	xadc_i2c = iio_priv(indio_dev);
> +	xadc_i2c->client = client;
> +	xadc = &xadc_i2c->xadc;
> +
> +	ret = xadc_common_init(dev, xadc, ops);
> +	if (ret)
> +		return ret;
> +
> +	ret = xadc_device_configure(indio_dev, 0, &conf0, &bipolar_mask);
> +	if (ret)
> +		return dev_err_probe(dev, ret, "Failed to setup the device\n");
> +
> +	xadc_i2c->conf0 = conf0;
> +	xadc_i2c->bipolar_mask = bipolar_mask;
> +	xadc_i2c->hw_initialized = false;
> +
> +	return devm_iio_device_register(dev, indio_dev);
> +}

...

> +MODULE_IMPORT_NS("IIO_XADC");

> +

Unneeded blank line.

> +MODULE_LICENSE("GPL");
> +MODULE_AUTHOR("Sai Krishna Potthuri <sai.krishna.potthuri at amd.com>");
> +MODULE_AUTHOR("Dileep Kumar Nagavarapu <dileepkumar.nagavarapu at amd.com>");
> +MODULE_DESCRIPTION("Xilinx XADC I2C Interface Driver");



More information about the linux-arm-kernel mailing list