lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 18 Aug 2010 17:55:28 +0300
From:	Roger Quadros <roger.quadros@...ia.com>
To:	"Krogerus Heikki (EXT-Teleca/Helsinki)" 
	<ext-heikki.krogerus@...ia.com>
CC:	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"linux-omap@...r.kernel.org" <linux-omap@...r.kernel.org>,
	"dwmw2@...radead.org" <dwmw2@...radead.org>,
	"cbou@...l.ru" <cbou@...l.ru>,
	"Balbi Felipe (Nokia-MS/Helsinki)" <felipe.balbi@...ia.com>,
	"Palande Ameya (Nokia-MS/Helsinki)" <ameya.palande@...ia.com>,
	"Lehtonen Markus (Nokia-MS/Helsinki)" <markus.lehtonen@...ia.com>
Subject: Re: [PATCH] power_supply: add isp1704 charger detection driver

Hi,

On 08/18/2010 04:01 PM, Krogerus Heikki (EXT-Teleca/Helsinki) wrote:
> From: Heikki Krogerus<ext-heikki.krogerus@...ia.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@...ia.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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ