From patchwork Fri Nov 9 07:42:14 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: 197971 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 364A32C00C8 for ; Fri, 9 Nov 2012 18:44:43 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id F38AF4A895; Fri, 9 Nov 2012 08:44:25 +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 1Cioi0EW+4Wl; Fri, 9 Nov 2012 08:44:25 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 025164A89F; Fri, 9 Nov 2012 08:43:51 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id EDF384A61D for ; Fri, 9 Nov 2012 08:43:46 +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 5NBFYs9WMq7h for ; Fri, 9 Nov 2012 08:43:45 +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 mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by theia.denx.de (Postfix) with ESMTP id E51A74A72A for ; Fri, 9 Nov 2012 08:43:09 +0100 (CET) Received: from epcpsbgm2.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout2.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MD7007UUMR20BV0@mailout2.samsung.com> for u-boot@lists.denx.de; Fri, 09 Nov 2012 16:43:08 +0900 (KST) X-AuditID: cbfee61b-b7f616d00000319b-5a-509cb40c0844 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2.samsung.com (EPCPMTA) with SMTP id C4.DF.12699.C04BC905; Fri, 09 Nov 2012 16:43:08 +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 <0MD700H3CMQZYP10@mmp1.samsung.com> for u-boot@lists.denx.de; Fri, 09 Nov 2012 16:43:08 +0900 (KST) From: Lukasz Majewski To: u-boot@lists.denx.de Date: Fri, 09 Nov 2012 08:42:14 +0100 Message-id: <1352446951-12558-10-git-send-email-l.majewski@samsung.com> X-Mailer: git-send-email 1.7.10 In-reply-to: <1352446951-12558-1-git-send-email-l.majewski@samsung.com> References: <1352446951-12558-1-git-send-email-l.majewski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrMJMWRmVeSWpSXmKPExsVy+t9jAV2eLXMCDJZc5bF4u7eT3YHR4+yd HYwBjFFcNimpOZllqUX6dglcGe8aJjIXXJGp6D+xiLGBsVe8i5GDQ0LAROLnEsYuRk4gU0zi wr31bF2MXBxCAosYJZrvrmeBcBYzSextuMAOUsUmoCfx+e5TJhBbREBC4lf/VUaQImaBHUAd J8+ygSSEBdIkDm9YDGazCKhKnHj4CszmFXCX2L3kJhPEOnmJp/f7wOKcQPGdFxeB2UICbhK9 8x8zTWDkXcDIsIpRNLUguaA4KT3XSK84Mbe4NC9dLzk/dxMj2OvPpHcwrmqwOMQowMGoxMOb +GB2gBBrYllxZe4hRgkOZiUR3rmZcwKEeFMSK6tSi/Lji0pzUosPMUpzsCiJ8zZ7pAQICaQn lqRmp6YWpBbBZJk4OKUaGG13V37fKjTtr/3ff/mtPyY1h5248kthS9/z/24Ft/l2LauqFrx0 NdJxeqzb14Lbz2cfD1VdbDbdVMhr4eoUP9Vqtvi2xTFOfI3Kni9e8b/TYdLMux6w5fK1aVst m1ctVt++Y8HXt4I+uYx+e81sJ0mvfTPh4dXwSTrBB3kcZNc4nFr4+Dn/j4tKLMUZiYZazEXF iQCItPS89gEAAA== Cc: Tom Rini , Kyungmin Park Subject: [U-Boot] [PATCH v6 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 --- 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; };