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: 273427 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 AD1A92C010E for ; Sun, 8 Sep 2013 18:53:59 +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 1VIajM-00040N-CZ; Sun, 08 Sep 2013 08:52:29 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VIaiy-0000EN-Lx; Sun, 08 Sep 2013 08:52:04 +0000 Received: from mail-ee0-x22b.google.com ([2a00:1450:4013:c00::22b]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1VIait-00009R-Nz for linux-arm-kernel@lists.infradead.org; Sun, 08 Sep 2013 08:52:01 +0000 Received: by mail-ee0-f43.google.com with SMTP id e52so2495170eek.16 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130908_045200_005212_E16885FB X-CRM114-Status: GOOD ( 16.97 ) 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 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[] = {