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: 273426 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Received: from casper.infradead.org (unknown [IPv6:2001:770:15f::2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 4149A2C00EC for ; Sun, 8 Sep 2013 18:53:42 +1000 (EST) 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 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (pali.rohar[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 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-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org 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