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: 2858241 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id F16CDBF43F for ; Sun, 8 Sep 2013 08:52:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 60E1E20319 for ; Sun, 8 Sep 2013 08:52:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 777F120343 for ; Sun, 8 Sep 2013 08:51:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752566Ab3IHIvb (ORCPT ); Sun, 8 Sep 2013 04:51:31 -0400 Received: from mail-ee0-f54.google.com ([74.125.83.54]:49813 "EHLO mail-ee0-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752506Ab3IHIv3 (ORCPT ); Sun, 8 Sep 2013 04:51:29 -0400 Received: by mail-ee0-f54.google.com with SMTP id e53so2536062eek.27 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 Cc: Russell King , David Woodhouse , Felipe Balbi , Greg Kroah-Hartman , linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, freemangordon@abv.bg, aaro.koskinen@iki.fi, pavel@ucw.cz, =?UTF-8?q?Pali=20Roh=C3=A1r?= 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 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, 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