From patchwork Tue Nov 13 13:22:00 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Majewski?= X-Patchwork-Id: 198652 X-Patchwork-Delegate: agust@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 451662C00C8 for ; Wed, 14 Nov 2012 00:24:27 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2A0434A160; Tue, 13 Nov 2012 14:24:21 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MAx1pCjCs+nI; Tue, 13 Nov 2012 14:24:20 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id ED0FE4A161; Tue, 13 Nov 2012 14:23:38 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C5D8D4A134 for ; Tue, 13 Nov 2012 14:23:21 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NaF0QKo6TZjW for ; Tue, 13 Nov 2012 14:23:20 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mailout1.samsung.com (mailout1.samsung.com [203.254.224.24]) by theia.denx.de (Postfix) with ESMTP id 044594A186 for ; Tue, 13 Nov 2012 14:23:02 +0100 (CET) Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MDF00IJDH5HT1C0@mailout1.samsung.com> for u-boot@lists.denx.de; Tue, 13 Nov 2012 22:23:01 +0900 (KST) X-AuditID: cbfee61b-b7f616d00000319b-16-50a249b5826d Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 11.46.12699.5B942A05; Tue, 13 Nov 2012 22:23:01 +0900 (KST) Received: from mcdsrvbld02.digital.local ([106.116.37.23]) by mmp1.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MDF00AK5H593U10@mmp1.samsung.com> for u-boot@lists.denx.de; Tue, 13 Nov 2012 22:23:01 +0900 (KST) From: Lukasz Majewski To: u-boot@lists.denx.de Date: Tue, 13 Nov 2012 14:22:00 +0100 Message-id: <1352812937-15998-10-git-send-email-l.majewski@samsung.com> X-Mailer: git-send-email 1.7.10 In-reply-to: <1352812937-15998-1-git-send-email-l.majewski@samsung.com> References: <1352812937-15998-1-git-send-email-l.majewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMJMWRmVeSWpSXmKPExsVy+t9jAd2tnosCDD58l7R4u7eT3YHR4+yd HYwBjFFcNimpOZllqUX6dglcGYe2HmUveCtTsejgEdYGxvniXYycHBICJhIHT11hh7DFJC7c W8/WxcjFISSwiFFi7Y8/zBDOYiaJe5cfsIJUsQnoSXy++5QJxBYRkJD41X+VEaSIWeAOo8T/ ay/AEsICaRKfvuxkA7FZBFQlni+fzgJi8wq4S3y7sY4ZYp28xNP7fUA1HBycQPE/58FahQTc JDbvPMo8gZF3ASPDKkbR1ILkguKk9FwjveLE3OLSvHS95PzcTYxgrz+T3sG4qsHiEKMAB6MS D6+i5cIAIdbEsuLK3EOMEhzMSiK8590WBQjxpiRWVqUW5ccXleakFh9ilOZgURLnbfZICRAS SE8sSc1OTS1ILYLJMnFwSjUwMibnhx1I5j0ec2KC3/qk9EfLxPNyZ+eXbVv5cGtQ+dyZZtuF Zn41UYz5HSohOX9aystfv79YaN/5ccNz4YS2FXV7MvZWfxPfW7R016qKfsG0vH+Ma0vcV05i lw+1D9lfkhJU9VNj/eQ+T5ZUhpW1Ks5Me61+fNroX3/e995zDgUDW9aDFi6CSizFGYmGWsxF xYkAu8yrmPYBAAA= Cc: Kyungmin Park , Tom Rini Subject: [U-Boot] [PATCH v7 09/26] pmic: Extend struct pmic to support battery and charger related operations X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de Now it is possible to provide specific function per PMIC/power device instance. Signed-off-by: Lukasz Majewski Signed-off-by: Kyungmin Park --- Changes for v2: - New at patch v2 Changes for v3: - separate power_{battery|chrg|fg} structures to provide battery ops - struct pmic *parent pointer added Changes for v4: - None Changes for v5: - None Changes for v6: - None Changes for v7: - None --- include/power/battery.h | 38 ++++++++++++++++++++++++++++++++++++++ include/power/pmic.h | 30 +++++++++++++++++++++++++++++- 2 files changed, 67 insertions(+), 1 deletions(-) create mode 100644 include/power/battery.h diff --git a/include/power/battery.h b/include/power/battery.h new file mode 100644 index 0000000..e2fec68 --- /dev/null +++ b/include/power/battery.h @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2012 Samsung Electronics + * Lukasz Majewski + * + * See file CREDITS for list of people who contributed to this + * project. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#ifndef __POWER_BATTERY_H_ +#define __POWER_BATTERY_H_ + +struct battery { + unsigned int version; + unsigned int state_of_chrg; + unsigned int time_to_empty; + unsigned int capacity; + unsigned int voltage_uV; + + unsigned int state; +}; + +int power_bat_init(unsigned char bus); +#endif /* __POWER_BATTERY_H_ */ diff --git a/include/power/pmic.h b/include/power/pmic.h index e9affc8..1ecfc05 100644 --- a/include/power/pmic.h +++ b/include/power/pmic.h @@ -27,8 +27,9 @@ #include #include #include +#include -enum { PMIC_I2C, PMIC_SPI, }; +enum { PMIC_I2C, PMIC_SPI, PMIC_NONE}; enum { I2C_PMIC, I2C_NUM, }; enum { PMIC_READ, PMIC_WRITE, }; enum { PMIC_SENSOR_BYTE_ORDER_LITTLE, PMIC_SENSOR_BYTE_ORDER_BIG, }; @@ -48,6 +49,27 @@ struct p_spi { u32 (*prepare_tx)(u32 reg, u32 *val, u32 write); }; +struct pmic; +struct power_fg { + int (*fg_battery_check) (struct pmic *p, struct pmic *bat); + int (*fg_battery_update) (struct pmic *p, struct pmic *bat); +}; + +struct power_chrg { + int (*chrg_type) (struct pmic *p); + int (*chrg_bat_present) (struct pmic *p); + int (*chrg_state) (struct pmic *p, int state, int current); +}; + +struct power_battery { + struct battery *bat; + int (*battery_init) (struct pmic *bat, struct pmic *p1, + struct pmic *p2, struct pmic *p3); + int (*battery_charge) (struct pmic *bat); + /* Keep info about power devices involved with battery operation */ + struct pmic *chrg, *fg, *muic; +}; + struct pmic { const char *name; unsigned char bus; @@ -59,6 +81,12 @@ struct pmic { struct p_spi spi; } hw; + void (*low_power_mode) (void); + struct power_battery *pbat; + struct power_chrg *chrg; + struct power_fg *fg; + + struct pmic *parent; struct list_head list; };