LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
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.

Notices


Closed Thread
  Search this Thread
Old 09-10-2018, 03: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.


Code:
    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');
	else
		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;
	else
		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,
						NULL,
						adt7316_event_handler,
						chip->bus.irq_flags |
						IRQF_ONESHOT,
						indio_dev->name,
						indio_dev);
		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",
			indio_dev->name);

	return 0;
    }
    EXPORT_SYMBOL(adt7316_probe);

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

http://www.analog.com/media/en/techn..._7517_7519.pdf

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

Rep: Reputation: 3202Reputation: 3202Reputation: 3202Reputation: 3202Reputation: 3202Reputation: 3202Reputation: 3202Reputation: 3202Reputation: 3202Reputation: 3202Reputation: 3202
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 https://www.linuxquestions.org/quest...or-4175638125/


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 08:39 AM
i need code for generate tree structure on sensor nodes ? kunal0807 Linux - Wireless Networking 1 05-11-2014 11:01 AM
[SOLVED] TOSHIBA Hard Drive Impact Sensor (3D sensor) and Linux josephj Linux - Laptop and Netbook 4 11-06-2010 06: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 09:01 PM
Generating Interrupts to the USB sensor device lucky6969b Programming 1 03-31-2006 01:18 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer

All times are GMT -5. The time now is 09:35 AM.

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