mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lars-Peter Clausen <lars@metafoo.de>
To: Marc CAPDEVILLE <m.capdeville@no-log.org>,
	Kevin Tsai <ktsai@capellamicro.com>
Cc: Jonathan Cameron <jic23@kernel.org>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	Wolfram Sang <wsa@the-dreams.de>,
	Hartmut Knaack <knaack.h@gmx.de>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] iio : Add cm3218 smbus ara and acpi support
Date: Mon, 30 Oct 2017 13:53:06 +0100	[thread overview]
Message-ID: <2c52a855-2bf7-d682-e20e-c4fbd01341e6@metafoo.de> (raw)
In-Reply-To: <6ac0c8cf-3ee8-ccc0-75c6-ec87f127857a@metafoo.de>

On 10/30/2017 11:54 AM, Lars-Peter Clausen wrote:
> On 10/27/2017 03:20 PM, Marc CAPDEVILLE wrote:
>> On asus T100, Capella cm3218 chip is implemented as ambiant light
>> sensor. This chip expose an smbus ARA protocol device on standard
>> address 0x0c. The chip is not functional before all alerts are
>> acknowledged.
>> On asus T100, this device is enumerated on ACPI bus and the description
>> give tow I2C connection. The first is the connection to the ARA device
> 
> two
> 
>> and the second gives the real address of the device.
> 
> Is there a document somewhere describing what this ARA stuff is and how it
> works? Is this "Project ARA"?

Found it: "Address Response Alert". Given that the ARA address 0x0c is an
reserved address and should not be used for normal I2C devices I wonder if
the I2C core shouldn't ignore it and get the correct address on its own when
instantiating the I2C slave device? I'd assume that this issue is not
specific to this particular device.

> 
>>
>> So, on device probe,If the i2c address is the ARA address and the
>> device is enumerated via acpi, we lookup for the real address in
>> the ACPI resource list and change it in the client structure.
>> if an interrupt resource is given, and only for cm3218 chip,
>> we declare an smbus_alert device.
>>
>> Signed-off-by: Marc CAPDEVILLE <m.capdeville@no-log.org>
> [...]
>> +/* Get the real i2c address from acpi resources */
>> +static int cm3218_acpi_get_address(struct i2c_client *client)
>> +{
>> +	int ret;
>> +	struct acpi_device *adev;
>> +	LIST_HEAD(res_list);
>> +	struct resource_entry *res_entry;
>> +	struct acpi_resource *ares;
>> +	struct acpi_resource_i2c_serialbus *sb;
>> +
>> +	adev = ACPI_COMPANION(&client->dev);
>> +	if (!adev)
>> +		return -ENODEV;
>> +
>> +	ret = acpi_dev_get_resources(adev,
>> +				     &res_list,
>> +				     cm3218_filter_i2c_address,
>> +				     client);
>> +	if (ret < 0)
>> +		return ret;
>> +
>> +	/* get first resource */
>> +	res_entry = list_entry(&res_list, struct resource_entry, node);
>> +	ares = (struct acpi_resource *)res_entry->res;
>> +	sb = &ares->data.i2c_serial_bus;
>> +
>> +	/* set i2c address */
>> +	client->addr = sb->slave_address;
>> +	client->flags &= ~I2C_CLIENT_TEN;
> 
> I'm not convinced overwriting the address and flags is legal. Those are
> owned by the I2C core and should be read-only in the client driver. Maybe
> use i2c_new_dummy() to create a device for the new address?
> 
>> +	if (sb->access_mode == ACPI_I2C_10BIT_MODE)
>> +		client->flags |= I2C_CLIENT_TEN;
>> +
>> +	acpi_dev_free_resource_list(&res_list);
>> +
>> +	return 0;
>> +}
> [...]
> 

  reply	other threads:[~2017-10-30 12:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-27 13:20 Marc CAPDEVILLE
2017-10-30 10:54 ` Lars-Peter Clausen
2017-10-30 12:53   ` Lars-Peter Clausen [this message]
2017-10-30 13:25   ` Wolfram Sang
2017-10-31  8:39 ` kbuild test robot
2017-10-27 15:52 Marc CAPDEVILLE

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2c52a855-2bf7-d682-e20e-c4fbd01341e6@metafoo.de \
    --to=lars@metafoo.de \
    --cc=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=ktsai@capellamicro.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.capdeville@no-log.org \
    --cc=pmeerw@pmeerw.net \
    --cc=wsa@the-dreams.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®