From patchwork Sun Sep 8 08:50:39 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: 2858231 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 009D8BF43F for ; Sun, 8 Sep 2013 08:52:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 48D5320335 for ; Sun, 8 Sep 2013 08:51:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9654F20319 for ; Sun, 8 Sep 2013 08:51:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752740Ab3IHIvl (ORCPT ); Sun, 8 Sep 2013 04:51:41 -0400 Received: from mail-ea0-f176.google.com ([209.85.215.176]:51550 "EHLO mail-ea0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752009Ab3IHIvj (ORCPT ); Sun, 8 Sep 2013 04:51:39 -0400 Received: by mail-ea0-f176.google.com with SMTP id q16so2478581ead.21 for ; Sun, 08 Sep 2013 01:51:37 -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=B7h6LBmWbYPolcmuo+CbD45RbLaBJ9PuJsId8jp5tIw=; b=JV698lDCMJ9RWMngmTwsaz6QwNMNKfNDr7rgj27EexgiPHKqiv/g/mIsnI2EFHxfgJ gvVhpqafzK1C2Kg2PgOke/jsX41dzJujyraDxKVYU1JTtToEatFKi/+s8OPzMyqeYvu4 58SVlYQ81sVgpuL31Kjfhtl9VC8qtUeBScjj/oDkmRdvC7y4Yf7jSBVIywzIR5mXH7tt LQLWLdXVv3Wb3z6sAJeN465tEHGggLp/kIdL5V1/qs3UIhzZE8qCDhRq+rYVhWuuQosL d9MpIOobjDMqgQwwTLUYWaca3Ab8s5solbqnJGy40oFZNM+afKN5fTU9cZqK2/xU43hb D9AA== X-Received: by 10.14.183.2 with SMTP id p2mr1994976eem.44.1378630297525; Sun, 08 Sep 2013 01:51:37 -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:37 -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 4/4] RX-51: Add platform function and data for bq24150a charger Date: Sun, 8 Sep 2013 10:50:39 +0200 Message-Id: <1378630239-10006-5-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 will register bq24150a charger in RX-51 board data. Patch also adding platform function between isp1704 and bq2415x drivers for detecting charger type. So finally charging battery on Nokia N900 (RX-51) working automatically without any proprietary Nokia bits in userspace. Signed-off-by: Pali Rohár --- arch/arm/mach-omap2/board-rx51-peripherals.c | 56 +++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-omap2/board-rx51-peripherals.c b/arch/arm/mach-omap2/board-rx51-peripherals.c index 9c2dd10..a993ffe 100644 --- a/arch/arm/mach-omap2/board-rx51-peripherals.c +++ b/arch/arm/mach-omap2/board-rx51-peripherals.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -270,6 +271,44 @@ static struct platform_device rx51_battery_device = { .id = -1, }; +static enum bq2415x_mode rx51_charger_mode = BQ2415X_MODE_OFF; +static void *rx51_charger_hook_data; +static void (*rx51_charger_hook)(enum bq2415x_mode mode, void *data); + +static int rx51_charger_set_hook( + void (*hook)(enum bq2415x_mode mode, void *data), void *data) +{ + rx51_charger_hook = hook; + rx51_charger_hook_data = data; + if (rx51_charger_hook) + rx51_charger_hook(rx51_charger_mode, rx51_charger_hook_data); + return 1; +} + +static void rx51_charger_set_current(int mA) +{ + enum bq2415x_mode mode; + + pr_info("RX-51: Charger current limit is %d mA\n", mA); + + if (mA == 0) + mode = BQ2415X_MODE_OFF; + else if (mA < 500) + mode = BQ2415X_MODE_NONE; + else if (mA < 1800) + mode = BQ2415X_MODE_HOST_CHARGER; + else + mode = BQ2415X_MODE_DEDICATED_CHARGER; + + if (rx51_charger_mode == mode) + return; + + rx51_charger_mode = mode; + + if (rx51_charger_hook) + rx51_charger_hook(rx51_charger_mode, rx51_charger_hook_data); +} + static void rx51_charger_set_power(bool on) { gpio_set_value(RX51_USB_TRANSCEIVER_RST_GPIO, on); @@ -277,6 +316,7 @@ static void rx51_charger_set_power(bool on) static struct isp1704_charger_data rx51_charger_data = { .set_power = rx51_charger_set_power, + .set_current = rx51_charger_set_current, }; static struct platform_device rx51_charger_device = { @@ -1017,6 +1057,16 @@ static struct aic3x_pdata rx51_aic3x_data2 = { .gpio_reset = 60, }; +static struct bq2415x_platform_data rx51_bq24150a_platform_data = { + .current_limit = 100, /* mA */ + .weak_battery_voltage = 3400, /* mV */ + .battery_regulation_voltage = 4200, /* mV */ + .charge_current = 650, /* mA */ + .termination_current = 100, /* mA */ + .resistor_sense = 68, /* m ohm */ + .set_mode_hook = &rx51_charger_set_hook, +}; + static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_2[] = { { I2C_BOARD_INFO("tlv320aic3x", 0x18), @@ -1044,7 +1094,11 @@ static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_2[] = { { I2C_BOARD_INFO("tpa6130a2", 0x60), .platform_data = &rx51_tpa6130a2_data, - } + }, + { + I2C_BOARD_INFO("bq24150a", 0x6b), + .platform_data = &rx51_bq24150a_platform_data, + }, }; static struct i2c_board_info __initdata rx51_peripherals_i2c_board_info_3[] = {