From patchwork Fri Oct 5 08:16:31 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: 189434 X-Patchwork-Delegate: sbabic@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 634AF2C0327 for ; Fri, 5 Oct 2012 18:18:35 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 20A67280AC; Fri, 5 Oct 2012 10:18:32 +0200 (CEST) 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 RoCygjYXOM97; Fri, 5 Oct 2012 10:18:31 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 1D24B280B4; Fri, 5 Oct 2012 10:17:41 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id D1044280AA for ; Fri, 5 Oct 2012 10:17:35 +0200 (CEST) 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 UGPsxD4CTSuV for ; Fri, 5 Oct 2012 10:17:35 +0200 (CEST) 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 E06D6280B5 for ; Fri, 5 Oct 2012 10:17:21 +0200 (CEST) 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 <0MBE006R6V03SG20@mailout1.samsung.com> for u-boot@lists.denx.de; Fri, 05 Oct 2012 17:17:20 +0900 (KST) X-AuditID: cbfee61b-b7f2b6d000000f14-e1-506e979064db Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id 5A.A7.03860.0979E605; Fri, 05 Oct 2012 17:17:20 +0900 (KST) Received: from mcdsrvbld02.digital.local ([106.116.37.23]) by mmp2.samsung.com (Oracle Communications Messaging Server 7u4-24.01 (7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTPA id <0MBE0068VUZYNY10@mmp2.samsung.com> for u-boot@lists.denx.de; Fri, 05 Oct 2012 17:17:20 +0900 (KST) From: Lukasz Majewski To: u-boot@lists.denx.de Date: Fri, 05 Oct 2012 10:16:31 +0200 Message-id: <1349425003-32523-10-git-send-email-l.majewski@samsung.com> X-Mailer: git-send-email 1.7.10 In-reply-to: <1349425003-32523-1-git-send-email-l.majewski@samsung.com> References: <1349425003-32523-1-git-send-email-l.majewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrEJMWRmVeSWpSXmKPExsVy+t9jQd0J0/MCDNr/G1q83dvJ7sDocfbO DsYAxigum5TUnMyy1CJ9uwSujJn7V7AVXJOsOLm6mbGB8YFIFyMnh4SAicTuvjvsELaYxIV7 69m6GLk4hASmM0r8/3MQLCEksJhJ4vrTWhCbTUBP4vPdp0wgtoiAhMSv/quMIA3MAjsYJZpP nmUDSQgLpEmsejkJyObgYBFQlZh2kAMkzCvgLnFt9REWiGXyEk/v94GVcwLFt7//xgyxy01i 3oNLjBMYeRcwMqxiFE0tSC4oTkrPNdIrTswtLs1L10vOz93ECPb5M+kdjKsaLA4xCnAwKvHw CjzLDRBiTSwrrsw9xCjBwawkwns1KS9AiDclsbIqtSg/vqg0J7X4EKM0B4uSOG+zR0qAkEB6 YklqdmpqQWoRTJaJg1OqgTEmZsZFl0U7tyeZf7bcdlDZVeqYtYu/4vUIEbaUuUU3p3WEZL6Y 8dvR463SuX3XuIsf3FRM2Wze/XNK/5QwHTEZO2a5xvRzOlXH7QTvlCZNzW71lFGPmyHEu0Vs HzeHlb2C94Wr/+KMvUxSL1SsF645wSqcua1gcfcl88N6U6X/lWdPv7+JUYmlOCPRUIu5qDgR AApo8GP1AQAA Cc: Tom Rini , Kyungmin Park Subject: [U-Boot] [PATCH v2 09/21] 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 --- include/power/battery.h | 38 ++++++++++++++++++++++++++++++++++++++ include/power/pmic.h | 23 ++++++++++++++++++++++- 2 files changed, 60 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 3583342..5ec7bae 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_BYTE_ORDER_REVERSED, PMIC_BYTE_ORDER_NORMAL, }; @@ -48,6 +49,21 @@ struct p_spi { u32 (*prepare_tx)(u32 reg, u32 *val, u32 write); }; +struct pmic; +struct power_battery { + struct battery *bat; + + int (*fg_battery_check) (struct pmic *p, struct pmic *bat); + int (*fg_battery_update) (struct pmic *p, struct pmic *bat); + + int (*chrg_type) (struct pmic *p); + int (*chrg_bat_present) (struct pmic *p); + int (*chrg_state) (struct pmic *p, int state, int current); + + /* Keep info about power devices involved with battery operation */ + struct pmic *chrg, *fg, *muic; +}; + struct pmic { const char *name; unsigned char bus; @@ -59,6 +75,11 @@ struct pmic { struct p_spi spi; } hw; + struct power_battery *pwr_bat; + int (*battery_init) (struct pmic *p, struct pmic *bat); + int (*battery_charge) (struct pmic *bat); + void (*low_power_mode) (void); + struct list_head list; };