public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Roger Quadros <roger.quadros@nokia.com>
To: "Krogerus Heikki (EXT-Teleca/Helsinki)"  <ext-heikki.krogerus@nokia.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-omap@vger.kernel.org" <linux-omap@vger.kernel.org>,
	"dwmw2@infradead.org" <dwmw2@infradead.org>,
	"cbou@mail.ru" <cbou@mail.ru>,
	"Balbi Felipe (Nokia-MS/Helsinki)" <felipe.balbi@nokia.com>,
	"Palande Ameya (Nokia-MS/Helsinki)" <ameya.palande@nokia.com>,
	"Lehtonen Markus (Nokia-MS/Helsinki)" <markus.lehtonen@nokia.com>
Subject: Re: [PATCH] power_supply: add isp1704 charger detection driver
Date: Wed, 18 Aug 2010 17:55:28 +0300	[thread overview]
Message-ID: <4C6BF460.9090105@nokia.com> (raw)
In-Reply-To: <1282136465-1748-1-git-send-email-ext-heikki.krogerus@nokia.com>

Hi,

On 08/18/2010 04:01 PM, Krogerus Heikki (EXT-Teleca/Helsinki) wrote:
> From: Heikki Krogerus<ext-heikki.krogerus@nokia.com>
>
> NXP ISP1704 is Battery Charging Specification 1.0 compliant USB
> transceiver. This adds a power supply driver for ISP1704 and
> ISP1707 USB transceivers.
>
> Signed-off-by: Heikki Krogerus<ext-heikki.krogerus@nokia.com>
> ---
>   drivers/power/Kconfig           |    7 +
>   drivers/power/Makefile          |    1 +
>   drivers/power/isp1704_charger.c |  371 +++++++++++++++++++++++++++++++++++++++
>   3 files changed, 379 insertions(+), 0 deletions(-)
>   create mode 100644 drivers/power/isp1704_charger.c
>
> diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
> index 0734356..d55fc29 100644
> --- a/drivers/power/Kconfig
> +++ b/drivers/power/Kconfig
> @@ -166,4 +166,11 @@ config BATTERY_INTEL_MID
>   	  Say Y here to enable the battery driver on Intel MID
>   	  platforms.
>
> +config CHARGER_ISP1704
> +	tristate "ISP1704 USB Charger Detection"
> +	select NOP_USB_XCEIV if ! MACH_NOKIA_RX51

As Anton mentioned, this is wrong.

It is possible for platforms other than RX51 to use ISP1704 and this driver 
should be usable on them without modifications to kconfig or driver code.

> +	help
> +	  Say Y to enable support for USB Charger Detection with
> +	  ISP1707/ISP1704 USB transceivers.
> +


>   endif # POWER_SUPPLY
> diff --git a/drivers/power/Makefile b/drivers/power/Makefile
> index 10143aa..c73d381 100644
> --- a/drivers/power/Makefile
> +++ b/drivers/power/Makefile
> @@ -37,3 +37,4 @@ obj-$(CONFIG_BATTERY_S3C_ADC)	+= s3c_adc_battery.o
>   obj-$(CONFIG_CHARGER_PCF50633)	+= pcf50633-charger.o
>   obj-$(CONFIG_BATTERY_JZ4740)	+= jz4740-battery.o
>   obj-$(CONFIG_BATTERY_INTEL_MID)	+= intel_mid_battery.o
> +obj-$(CONFIG_CHARGER_ISP1704)	+= isp1704_charger.o
> diff --git a/drivers/power/isp1704_charger.c b/drivers/power/isp1704_charger.c
> new file mode 100644
> index 0000000..821ad29
> --- /dev/null
> +++ b/drivers/power/isp1704_charger.c
> @@ -0,0 +1,371 @@
> +/*
> + * isp1704_charger.c - ISP1704 USB Charger Detection driver
> + *
> + * Copyright (C) 2010 Nokia Corporation
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
> + */
> +

<snip>


> +
> +static inline int isp1704_test_ulpi(struct isp1704_charger *isp)
> +{
> +	int			vendor, product, i;
> +	int			ret = -ENODEV;
> +
> +	/* Test ULPI interface */
> +	ret = otg_io_write(isp->otg, ULPI_SCRATCH, 0xaa);
> +	if (ret<  0)
> +		return ret;
> +	ret = otg_io_read(isp->otg, ULPI_SCRATCH);
> +	if (ret<  0)
> +		return ret;
> +	if (ret != 0xaa)
> +		return -ENODEV;
> +	/* Verify the product and vendor id matches */
> +	vendor = otg_io_read(isp->otg, ULPI_VENDOR_ID_LOW);
> +	vendor |= otg_io_read(isp->otg, ULPI_VENDOR_ID_HIGH)<<  8;
> +	if (vendor != NXP_VENDOR_ID)
> +		return -ENODEV;
> +	for (i = 0; i<  ARRAY_SIZE(isp170x_id); i++) {
> +		product = otg_io_read(isp->otg, ULPI_PRODUCT_ID_LOW);
> +		product |= otg_io_read(isp->otg, ULPI_PRODUCT_ID_HIGH)<<  8;

product id should be read outside the for loop. This way you will save 
unnecessary otg_io_reads. product id won't change anyways.

> +		if (product == isp170x_id[i]) {
> +			sprintf(isp->model, "isp%x", product);
> +			return product;
> +		}
> +	}
> +
> +	dev_err(isp->dev, "product id %x not matching known ids", product);
> +
> +	return -ENODEV;
> +}

<snip>

> +static struct platform_driver isp1704_charger_driver = {
> +	.driver = {
> +		.name = "isp1704_charger",
> +	},
> +	.probe = isp1704_charger_probe,
> +	.remove = __devexit_p(isp1704_charger_remove),
> +};
> +
> +static struct platform_device *isp1704_device;
> +
> +static int __init isp1704_charger_init(void)
> +{
> +	int ret = 0;
> +
> +	ret = platform_driver_register(&isp1704_charger_driver);
> +	if (ret)
> +		return ret;
> +
> +	isp1704_device = platform_device_register_simple("isp1704_charger",
> +							0, NULL, 0);

This platform_device_register should be done in the rx51 board file. i.e. 
board-rx51-peripherals.c

> +	if (IS_ERR(isp1704_device)) {
> +		platform_driver_unregister(&isp1704_charger_driver);
> +		ret = PTR_ERR(isp1704_device);
> +	}
> +
> +	return ret;
> +}
> +module_init(isp1704_charger_init);
> +
> +static void __exit isp1704_charger_exit(void)
> +{
> +	platform_device_unregister(isp1704_device);
don't do platform_device_unregister here.

> +	platform_driver_unregister(&isp1704_charger_driver);
> +}
> +module_exit(isp1704_charger_exit);
> +
> +MODULE_ALIAS("platform:isp1704-charger");
> +MODULE_AUTHOR("Nokia Corporation");
> +MODULE_DESCRIPTION("ISP170x USB Charger driver");
> +MODULE_LICENSE("GPL");


-- 
regards,
-roger

  parent reply	other threads:[~2010-08-18 14:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-18 13:01 [PATCH] power_supply: add isp1704 charger detection driver Krogerus Heikki (EXT-Teleca/Helsinki)
2010-08-18 13:42 ` Anton Vorontsov
2010-08-19  7:03   ` Heikki Krogerus
2010-08-18 14:55 ` Roger Quadros [this message]
2010-08-19  7:17   ` Heikki Krogerus
2010-08-19 10:59 ` Gadiyar, Anand

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=4C6BF460.9090105@nokia.com \
    --to=roger.quadros@nokia.com \
    --cc=ameya.palande@nokia.com \
    --cc=cbou@mail.ru \
    --cc=dwmw2@infradead.org \
    --cc=ext-heikki.krogerus@nokia.com \
    --cc=felipe.balbi@nokia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=markus.lehtonen@nokia.com \
    /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