All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: "Opensource [Adam Thomson]" <Adam.Thomson.Opensource@diasemi.com>,
	Lee Jones <lee.jones@linaro.org>,
	Samuel Ortiz <sameo@linux.intel.com>,
	Hartmut Knaack <knaack.h@gmx.de>,
	"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
	Sebastian Reichel <sre@kernel.org>,
	Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>,
	David Woodhouse <dwmw2@infradead.org>,
	"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
	Rob Herring <robh+dt@kernel.org>, Pawel Moll <pawel.moll@arm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Ian Campbell <ijc+devicetree@hellion.org.uk>,
	Kumar Gala <galak@codeaurora.org>,
	Grant Likely <grant.likely@linaro.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Joe Perches <joe@perches.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Support Opensource <Support.Opensource@diasemi.com>
Subject: Re: [PATCH v5 3/7] iio: Add support for DA9150 GPADC
Date: Tue, 20 Jan 2015 20:49:28 +0000	[thread overview]
Message-ID: <54BEBF58.30308@kernel.org> (raw)
In-Reply-To: <2E89032DDAA8B9408CB92943514A0337AB527B9D@SW-EX-MBX01.diasemi.com>

On 14/01/15 11:30, Opensource [Adam Thomson] wrote:
> On January 10, 2015 22:19, Jonathan Cameron wrote:
> 
>> On 07/01/15 16:03, Opensource [Adam Thomson] wrote:
>>> On January 4, 2015 17:22, Jonathan Cameron wrote:
>>>
>>>> On 22/12/14 16:51, Adam Thomson wrote:
>>>>> This patch adds support for DA9150 Charger & Fuel-Gauge IC GPADC.
>>>>>
>>>>> Signed-off-by: Adam Thomson <Adam.Thomson.Opensource@diasemi.com>
>>>> One last query from me.
>>>>
>>>> Using the extended channel names in IIO is only really appropriate when
>>>> they don't correspond to simple pins on the side of the chip. For those
>>>> just drop the extname bit.  Some of the channels you have here, definitely
>>>> need them though.
>>>>
>>>> Drop those first 4 or convince me otherwise and add
>>>> Acked-by: Jonathan Cameron <jic23@kernel.org>
>>>
>>> Have added responses below. If the comments are accepted then I'll respin
>>> and add you're 'Acked-by'. Is that ok?
>>>
>> Not accepted as yet :)
> 
> Yeah, that's why I added the 'if'. :)
> 
>>>>> +#define DA9150_GPADC_CHANNEL_PROCESSED(_id, _hw_id, _type,
>> _ext_name)
>>>> 	\
>>>>> +	DA9150_GPADC_CHANNEL(_id, _hw_id, _type,			\
>>>>> +			     BIT(IIO_CHAN_INFO_PROCESSED), _ext_name)
>>>>> +
>>>>> +/* Supported channels */
>>>>> +static const struct iio_chan_spec da9150_gpadc_channels[] = {
>>>>> +	DA9150_GPADC_CHANNEL_PROCESSED(GPIOA, GPIOA_6V, IIO_VOLTAGE,
>>>> "GPIOA"),
>>>>> +	DA9150_GPADC_CHANNEL_PROCESSED(GPIOB, GPIOB_6V, IIO_VOLTAGE,
>>>> "GPIOB"),
>>>>> +	DA9150_GPADC_CHANNEL_PROCESSED(GPIOC, GPIOC_6V, IIO_VOLTAGE,
>>>> "GPIOC"),
>>>>> +	DA9150_GPADC_CHANNEL_PROCESSED(GPIOD, GPIOD_6V, IIO_VOLTAGE,
>>>> "GPIOD"),
>>>> I'm not sure some of these really deserve extended names.  Those are usually
>>>> reserved for naming strange internal adc channels etc.  These first 4 are
>>>> presumably just for input pins?  Those should just be channels 0..3
>>>> On another note, unless you want really weird sysfs attribute names, the
>>>> extended names want to be lowercase.
>>>>
>>>
>>> I'd prefer to keep the names because the input pins are muxed with GPIOs of the
>>> chip, so thought it sensible to show that this is the case. Am happy to change
>>> to lower-case to follow convention.
>> Hmm.  It's a bit of an oddity as the point of the naming
>> is about the uses, not which pins they are on.  If we exposed the
>> 'datasheet_name' parameter directly rather than just using it internally
>> I'd suggest relying on that - but clearly you want it to be apparent
>> in the interface.  Whether that is useful is the question I'd raise
>> here (and is the reason datasheet_name is not exposed.
>>
>> The obvious question is does userspace care?  Answer is probably not.
>>
>> It cares what is being measured but this is about what pins it is
>> on and doesn't provide any information on what is connected to them.
>>
> 
> Surely it helps when using sysfs to access whatever is connected to one of
> those pins if we label the pin with something meaningful? If say you have a
> device connected to GPIC of the charger IC, it's easier to work out which ADC
> channel you need to access through sysfs if the naming is as I have now, rather
> than some arbitrary number which doesn't necessarily tally to the channel in the
> datasheet. You'd then need to look at the code and work out which channel number
> GPIOC actually was. Or am I just missing something here? :)
Not really for the vast majority of users.  They tend not to have a detailed
board layout in front of them.  It's more interesting if you know 'what' they
are measuring (hence we do use these names when that is true - such as
internal voltage measurements).

The numbers almost never tally with the datasheet, but then datasheet numbering
has a habit of being inconsistent as well!
> 
>>
>>>
>>>>> +	DA9150_GPADC_CHANNEL_PROCESSED(IBUS, IBUS_SENSE, IIO_CURRENT,
>>>> "IBUS"),
>>>>> +	DA9150_GPADC_CHANNEL_PROCESSED(VBUS, VBUS_DIV_, IIO_VOLTAGE,
>>>> "VBUS"),
>>>>> +	DA9150_GPADC_CHANNEL_RAW(ID, ID, IIO_VOLTAGE, "ID"),
>>>> You hae an identifier voltage? That's certainly unusual but if so - fair enough
>>>> and it defintely needs the extname!
>>>
>>> Thanks for pointing that out. Having checked again, this is not needed and can
>>> be dispensed with.
>>>
>>>>> +	DA9150_GPADC_CHANNEL_PROCESSED(VSYS, VSYS, IIO_VOLTAGE, "VSYS"),
>>>>> +	DA9150_GPADC_CHANNEL_SCALED(VBAT, VBAT, IIO_VOLTAGE, "VBAT"),
>>>>> +	DA9150_GPADC_CHANNEL_RAW(TBAT, TBAT, IIO_VOLTAGE, "TBAT"),
>>>>> +	DA9150_GPADC_CHANNEL_SCALED(TJUNC_CORE, TJUNC_CORE,
>>>> IIO_TEMP,
>>>>> +				    "TJUNC_CORE"),
>>>> tjunc_core is a good use of extname ;)
>>>>> +	DA9150_GPADC_CHANNEL_SCALED(TJUNC_OVP, TJUNC_OVP, IIO_TEMP,
>>>>> +				    "TJUNC_OVP"),
>>>>> +};
>>>>> +
>>>>> +/* Default maps used by da9150-charger */
>>>>> +static struct iio_map da9150_gpadc_default_maps[] = {
>>>>> +	{
>>>>> +		.consumer_dev_name = "da9150-charger",
>>>>> +		.consumer_channel = "CHAN_IBUS",
>>>>> +		.adc_channel_label = "IBUS",
>>>>> +	},
>>>>> +	{
>>>>> +		.consumer_dev_name = "da9150-charger",
>>>>> +		.consumer_channel = "CHAN_VBUS",
>>>>> +		.adc_channel_label = "VBUS",
>>>>> +	},
>>>>> +	{
>>>>> +		.consumer_dev_name = "da9150-charger",
>>>>> +		.consumer_channel = "CHAN_TJUNC",
>>>>> +		.adc_channel_label = "TJUNC_CORE",
>>>>> +	},
>>>>> +	{
>>>>> +		.consumer_dev_name = "da9150-charger",
>>>>> +		.consumer_channel = "CHAN_VBAT",
>>>>> +		.adc_channel_label = "VBAT",
>>>>> +	},
>>>>> +	{},
>>>>> +};
>>>>> +
>>>>> +static int da9150_gpadc_probe(struct platform_device *pdev)
>>>>> +{
>>>>> +	struct device *dev = &pdev->dev;
>>>>> +	struct da9150 *da9150 = dev_get_drvdata(dev->parent);
>>>>> +	struct da9150_gpadc *gpadc;
>>>>> +	struct iio_dev *indio_dev;
>>>>> +	int irq, ret;
>>>>> +
>>>>> +	indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*gpadc));
>>>>> +	if (!indio_dev) {
>>>>> +		dev_err(&pdev->dev, "Failed to allocate IIO device\n");
>>>>> +		return -ENOMEM;
>>>>> +	}
>>>>> +	gpadc = iio_priv(indio_dev);
>>>>> +
>>>>> +	platform_set_drvdata(pdev, indio_dev);
>>>>> +	gpadc->da9150 = da9150;
>>>>> +	gpadc->dev = dev;
>>>>> +	mutex_init(&gpadc->lock);
>>>>> +	init_completion(&gpadc->complete);
>>>>> +
>>>>> +	irq = platform_get_irq_byname(pdev, "GPADC");
>>>>> +	if (irq < 0) {
>>>>> +		dev_err(dev, "Failed to get IRQ: %d\n", irq);
>>>>> +		return irq;
>>>>> +	}
>>>>> +
>>>>> +	ret = devm_request_threaded_irq(dev, irq, NULL, da9150_gpadc_irq,
>>>>> +					IRQF_ONESHOT, "GPADC", gpadc);
>>>>> +	if (ret) {
>>>>> +		dev_err(dev, "Failed to request IRQ %d: %d\n", irq, ret);
>>>>> +		return ret;
>>>>> +	}
>>>>> +
>>>>> +	ret = iio_map_array_register(indio_dev, da9150_gpadc_default_maps);
>>>>> +	if (ret) {
>>>>> +		dev_err(dev, "Failed to register IIO maps: %d\n", ret);
>>>>> +		return ret;
>>>>> +	}
>>>>> +
>>>>> +	indio_dev->name = dev_name(dev);
>>>>> +	indio_dev->dev.parent = dev;
>>>>> +	indio_dev->dev.of_node = pdev->dev.of_node;
>>>>> +	indio_dev->info = &da9150_gpadc_info;
>>>>> +	indio_dev->modes = INDIO_DIRECT_MODE;
>>>>> +	indio_dev->channels = da9150_gpadc_channels;
>>>>> +	indio_dev->num_channels = ARRAY_SIZE(da9150_gpadc_channels);
>>>>> +
>>>>> +	ret = iio_device_register(indio_dev);
>>>>> +	if (ret) {
>>>>> +		dev_err(dev, "Failed to register IIO device: %d\n", ret);
>>>>> +		goto iio_map_unreg;
>>>>> +	}
>>>>> +
>>>>> +	return 0;
>>>>> +
>>>>> +iio_map_unreg:
>>>>> +	iio_map_array_unregister(indio_dev);
>>>>> +
>>>>> +	return ret;
>>>>> +}
>>>>> +
>>>>> +static int da9150_gpadc_remove(struct platform_device *pdev)
>>>>> +{
>>>>> +	struct iio_dev *indio_dev = platform_get_drvdata(pdev);
>>>>> +
>>>>> +	iio_device_unregister(indio_dev);
>>>>> +	iio_map_array_unregister(indio_dev);
>>>>> +
>>>>> +	return 0;
>>>>> +}
>>>>> +
>>>>> +static struct platform_driver da9150_gpadc_driver = {
>>>>> +	.driver = {
>>>>> +		.name = "da9150-gpadc",
>>>>> +	},
>>>>> +	.probe = da9150_gpadc_probe,
>>>>> +	.remove = da9150_gpadc_remove,
>>>>> +};
>>>>> +
>>>>> +module_platform_driver(da9150_gpadc_driver);
>>>>> +
>>>>> +MODULE_DESCRIPTION("GPADC Driver for DA9150");
>>>>> +MODULE_AUTHOR("Adam Thomson
>>>> <Adam.Thomson.Opensource@diasemi.com>");
>>>>> +MODULE_LICENSE("GPL");
>>>>> --
>>>>> 1.9.3
>>>>>


  reply	other threads:[~2015-01-20 20:49 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-22 16:50 [PATCH v5 0/7] Add initial support for DA9150 Charger & Fuel-Gauge IC Adam Thomson
2014-12-22 16:50 ` Adam Thomson
2014-12-22 16:51 ` [PATCH v5 1/7] mfd: Add support for DA9150 combined charger & fuel-gauge device Adam Thomson
2014-12-22 16:51   ` Adam Thomson
2015-01-19 11:33   ` Lee Jones
2015-01-19 13:23     ` Opensource [Adam Thomson]
2015-01-19 13:23       ` Opensource [Adam Thomson]
2015-01-19 13:23       ` Opensource [Adam Thomson]
2015-01-20 10:50       ` Lee Jones
2014-12-22 16:51 ` [PATCH v5 2/7] mfd: da9150: Add DT binding documentation for core Adam Thomson
2014-12-22 16:51   ` Adam Thomson
2014-12-22 16:51 ` [PATCH v5 3/7] iio: Add support for DA9150 GPADC Adam Thomson
2014-12-22 16:51   ` Adam Thomson
2015-01-01 20:51   ` Hartmut Knaack
2015-01-01 20:51     ` Hartmut Knaack
2015-01-04 17:22   ` Jonathan Cameron
2015-01-04 17:22     ` Jonathan Cameron
2015-01-07 16:03     ` Opensource [Adam Thomson]
2015-01-07 16:03       ` Opensource [Adam Thomson]
2015-01-07 16:03       ` Opensource [Adam Thomson]
2015-01-10 22:19       ` Jonathan Cameron
2015-01-10 22:19         ` Jonathan Cameron
2015-01-14 11:30         ` Opensource [Adam Thomson]
2015-01-14 11:30           ` Opensource [Adam Thomson]
2015-01-14 11:30           ` Opensource [Adam Thomson]
2015-01-20 20:49           ` Jonathan Cameron [this message]
2015-01-21 11:02             ` Opensource [Adam Thomson]
2015-01-21 11:02               ` Opensource [Adam Thomson]
2015-01-21 11:02               ` Opensource [Adam Thomson]
2014-12-22 16:51 ` [PATCH v5 4/7] iio: da9150: Add DT binding documentation for GPADC Adam Thomson
2014-12-22 16:51   ` Adam Thomson
2014-12-22 16:51 ` [PATCH v5 5/7] power: Add support for DA9150 Charger Adam Thomson
2014-12-22 16:51   ` Adam Thomson
2015-01-04 17:26   ` Jonathan Cameron
2015-01-04 17:26     ` Jonathan Cameron
2015-01-07 16:04     ` Opensource [Adam Thomson]
2015-01-07 16:04       ` Opensource [Adam Thomson]
2015-01-07 16:04       ` Opensource [Adam Thomson]
2014-12-22 16:51 ` [PATCH v5 6/7] power: da9150: Add DT binding documentation for charger Adam Thomson
2014-12-22 16:51   ` Adam Thomson
2014-12-22 16:51 ` [PATCH v5 7/7] MAINTAINERS: Include DA9150 files in Dialog Semiconductor support list Adam Thomson
2014-12-22 16:51   ` Adam Thomson

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=54BEBF58.30308@kernel.org \
    --to=jic23@kernel.org \
    --cc=Adam.Thomson.Opensource@diasemi.com \
    --cc=Support.Opensource@diasemi.com \
    --cc=akpm@linux-foundation.org \
    --cc=dbaryshkov@gmail.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dwmw2@infradead.org \
    --cc=galak@codeaurora.org \
    --cc=grant.likely@linaro.org \
    --cc=ijc+devicetree@hellion.org.uk \
    --cc=joe@perches.com \
    --cc=knaack.h@gmx.de \
    --cc=lee.jones@linaro.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=pawel.moll@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=sameo@linux.intel.com \
    --cc=sre@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.