From patchwork Sun Sep 8 08:50:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 2858291 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 2A8B79F2D6 for ; Sun, 8 Sep 2013 08:53:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 84D1B20319 for ; Sun, 8 Sep 2013 08:53:21 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 70AC02027D for ; Sun, 8 Sep 2013 08:53:20 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VIajB-0003tn-NL; Sun, 08 Sep 2013 08:52:19 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VIair-0000D4-NV; Sun, 08 Sep 2013 08:51:57 +0000 Received: from mail-ee0-x235.google.com ([2a00:1450:4013:c00::235]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VIaij-00008J-Nj for linux-arm-kernel@lists.infradead.org; Sun, 08 Sep 2013 08:51:51 +0000 Received: by mail-ee0-f53.google.com with SMTP id b15so2522738eek.12 for ; Sun, 08 Sep 2013 01:51:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=+O17gopseclg7gf7CVVQPQsxhfD4yyDddXIP9zZ9rRs=; b=NZLSr3dV/lYW2WaVP8AdBdkqAE/57tbVRX+aaoIWZmpqlG6uvlzm61Vw2i8DLxJpeF 3Ok2Mvvxo4L3/dr+SJxqebDiWM/vXmbSFAnCIMWMlK98iT8g0Eb5wzePDUlzi6OEUiFU QH96Uf6iXrietLwPB+15pj1CL5hZFV8dNCo7djAN9gVYVNUlN1z/5hohaACYw4jVOXzJ ET8b+biVGg8Qlb8ix4L7etxA695tP+mnE3aUZqI5ZUz3jcKuxUWKaKSUG0YZTGYiXuV1 wzppODw3cSER+nF3lGW4JYc650C5cH/eucoHOn4lKiVQIjdoo0T2eM4nM7IumA3/PhhN DLPw== X-Received: by 10.15.94.201 with SMTP id bb49mr20295228eeb.23.1378630287891; Sun, 08 Sep 2013 01:51:27 -0700 (PDT) Received: from Pali-EliteBook.kolej.mff.cuni.cz (pali.kolej.mff.cuni.cz. [78.128.193.202]) by mx.google.com with ESMTPSA id z12sm11627397eev.6.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 08 Sep 2013 01:51:27 -0700 (PDT) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: Tony Lindgren , Anton Vorontsov Subject: [PATCH 3/4] power: isp1704_charger: Add callback function set_current Date: Sun, 8 Sep 2013 10:50:38 +0200 Message-Id: <1378630239-10006-4-git-send-email-pali.rohar@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1378630239-10006-1-git-send-email-pali.rohar@gmail.com> References: <1378630239-10006-1-git-send-email-pali.rohar@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130908_045150_008372_9268505B X-CRM114-Status: GOOD ( 13.93 ) X-Spam-Score: -2.0 (--) Cc: Russell King , aaro.koskinen@iki.fi, Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Felipe Balbi , freemangordon@abv.bg, pavel@ucw.cz, =?UTF-8?q?Pali=20Roh=C3=A1r?= , linux-omap@vger.kernel.org, David Woodhouse , linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch add callback function set_current to platform data. Driver will call this function when isp1704 change current and board provided this callback funtion in platform data. This patch is needed for Nokia RX-51 to tell bq2415x charging chip about connected wallcharger events. Signed-off-by: Pali Rohár --- drivers/power/isp1704_charger.c | 16 ++++++++++++++++ include/linux/power/isp1704_charger.h | 1 + 2 files changed, 17 insertions(+) diff --git a/drivers/power/isp1704_charger.c b/drivers/power/isp1704_charger.c index f726cb6..4f20a1a 100644 --- a/drivers/power/isp1704_charger.c +++ b/drivers/power/isp1704_charger.c @@ -91,6 +91,18 @@ static void isp1704_charger_set_power(struct isp1704_charger *isp, bool on) } /* + * Set charger current from isp1704 if a function for it + * has been provided with platform data. + */ +static void isp1704_charger_set_current(struct isp1704_charger *isp, int mA) +{ + struct isp1704_charger_data *board = isp->dev->platform_data; + + if (board && board->set_current) + board->set_current(mA); +} + +/* * Determine is the charging port DCP (dedicated charger) or CDP (Host/HUB * chargers). * @@ -257,6 +269,7 @@ static void isp1704_charger_work(struct work_struct *data) if (isp1704_charger_detect_dcp(isp)) { isp->psy.type = POWER_SUPPLY_TYPE_USB_DCP; isp->current_max = 1800; + isp1704_charger_set_current(isp, 1800); } else { isp->psy.type = POWER_SUPPLY_TYPE_USB; isp->current_max = 500; @@ -277,6 +290,8 @@ static void isp1704_charger_work(struct work_struct *data) if (isp->current_max > 100) isp->psy.type = POWER_SUPPLY_TYPE_USB_CDP; + + isp1704_charger_set_current(isp, isp->current_max); } break; case USB_EVENT_NONE: @@ -297,6 +312,7 @@ static void isp1704_charger_work(struct work_struct *data) usb_gadget_disconnect(isp->phy->otg->gadget); isp1704_charger_set_power(isp, 0); + isp1704_charger_set_current(isp, 0); break; default: goto out; diff --git a/include/linux/power/isp1704_charger.h b/include/linux/power/isp1704_charger.h index 68096a6..d154b02 100644 --- a/include/linux/power/isp1704_charger.h +++ b/include/linux/power/isp1704_charger.h @@ -24,6 +24,7 @@ struct isp1704_charger_data { void (*set_power)(bool on); + void (*set_current)(int mA); }; #endif