Help answer threads with 0 replies.
Go Back > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.


Closed Thread
  Search this Thread
Old 09-10-2018, 04:19 PM   #1
Shreeya Patel
LQ Newbie
Registered: Sep 2018
Posts: 2

Rep: Reputation: Disabled
Device Tree Bindings for ADT7516 sensor

I have a BeagleBone green and ADT7516's evaluation board connected with SDA and SCL pins.

When I do i2cdetect -y -r 2, I can see the i2c address as 0x4b and I am able to probe the adt7316 driver present in IIO subsystem.

adt7316 driver uses platform data to get the hardware description. But my goal is to remove platform data and use DT bindings.

I understand some basic things about the DT bindings like..

1. Compatible
2. reg

But when I have a close look at the driver, I can see that there are certain
things which are taken from the platform data and are used in the whole driver.

So my question is that how do I replace those things in the driver if I remove platform data and use DT bindings.

I am putting probe function's code here.

    int adt7316_probe(struct device *dev, struct adt7316_bus *bus,
		const char *name)
	struct adt7316_chip_info *chip;
	struct iio_dev *indio_dev;
	unsigned short *adt7316_platform_data = dev->platform_data;
	int ret = 0;

	indio_dev = devm_iio_device_alloc(dev, sizeof(*chip));
	if (!indio_dev)
		return -ENOMEM;
	chip = iio_priv(indio_dev);
	/* this is only used for device removal purposes */
	dev_set_drvdata(dev, indio_dev);

	chip->bus = *bus;

	if (name[4] == '3')
		chip->id = ID_ADT7316 + (name[6] - '6');
	else if (name[4] == '5')
		chip->id = ID_ADT7516 + (name[6] - '6');
		return -ENODEV;

	chip->ldac_pin = adt7316_platform_data[1];
	if (chip->ldac_pin) {
		chip->config3 |= ADT7316_DA_EN_VIA_DAC_LDCA;
		if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX)
			chip->config1 |= ADT7516_SEL_AIN3;
	chip->int_mask = ADT7316_TEMP_INT_MASK | ADT7316_VDD_INT_MASK;
	if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX)
		chip->int_mask |= ADT7516_AIN_INT_MASK;

	indio_dev->dev.parent = dev;
	if ((chip->id & ID_FAMILY_MASK) == ID_ADT75XX)
		indio_dev->info = &adt7516_info;
		indio_dev->info = &adt7316_info;
	indio_dev->name = name;
	indio_dev->modes = INDIO_DIRECT_MODE;

	if (chip->bus.irq > 0) {
		if (adt7316_platform_data[0])
			chip->bus.irq_flags = adt7316_platform_data[0];

		ret = devm_request_threaded_irq(dev, chip->bus.irq,
						chip->bus.irq_flags |
		if (ret)
			return ret;

		if (chip->bus.irq_flags & IRQF_TRIGGER_HIGH)
			chip->config1 |= ADT7316_INT_POLARITY;

	ret = chip->bus.write(chip->bus.client, ADT7316_CONFIG1, chip->config1);
	if (ret)
		return -EIO;

	ret = chip->bus.write(chip->bus.client, ADT7316_CONFIG3, chip->config3);
	if (ret)
		return -EIO;

	ret = devm_iio_device_register(dev, indio_dev);
	if (ret)
		return ret;

	dev_info(dev, "%s temperature sensor, ADC and DAC registered.\n",

	return 0;

So in the code we can see that chip->ldac_pin and chip->bus.irq_flags uses
platform data.
If I use DT bindings then platform data will have NULL value in it.

So how do I design my DT bindings here and how can I fetch that data in the driver?

I have seen many examples of DT bindings but I need specific help with adt7516 sensor.

Datasheet of adt7516 sensor

Last edited by onebuck; 09-10-2018 at 04:39 PM.
Old 09-10-2018, 04:36 PM   #2
Registered: Jan 2005
Location: Central Florida 20 minutes from Disney World
Distribution: SlackwareŽ
Posts: 13,905
Blog Entries: 43

Rep: Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142Reputation: 3142
Moderator response

Please post your thread in only one forum. Posting a single thread in the most relevant forum will make it easier for members to help you and will keep the discussion in one place. This thread is being closed because it is a duplicate of

Plus when posting long code snippets you should use code tags. You can high light the entry and press the # sign upper right of edit window.

Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Device Tree Bindings for ADT7516 sensor Shreeya Patel Linux - Embedded & Single-board computer 3 06-26-2019 09:39 AM
i need code for generate tree structure on sensor nodes ? kunal0807 Linux - Wireless Networking 1 05-11-2014 12:01 PM
[SOLVED] TOSHIBA Hard Drive Impact Sensor (3D sensor) and Linux josephj Linux - Laptop and Netbook 4 11-06-2010 07:39 PM
LXer: Qyoto C#/Mono Bindings for Qt4, New QtRuby release and PHP Bindings Coming Soon LXer Syndicated Linux News 0 07-03-2007 10:01 PM
Generating Interrupts to the USB sensor device lucky6969b Programming 1 03-31-2006 02:18 AM > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 01:43 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration