From patchwork Fri May 24 08:23:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Piotr Wilczek X-Patchwork-Id: 246104 X-Patchwork-Delegate: promsoft@gmail.com 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 4D3512C0098 for ; Fri, 24 May 2013 18:24:11 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 524D64A023; Fri, 24 May 2013 10:24:08 +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 T5F73FHCwagW; Fri, 24 May 2013 10:24:08 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id DB9FD4A037; Fri, 24 May 2013 10:23:49 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7E9894A02D for ; Fri, 24 May 2013 10:23:44 +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 YXeMAXT7IcS9 for ; Fri, 24 May 2013 10:23:39 +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 mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by theia.denx.de (Postfix) with ESMTP id F3DD74A021 for ; Fri, 24 May 2013 10:23:32 +0200 (CEST) Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout4.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0MNA00DIBNAWQSF0@mailout4.samsung.com> for u-boot@lists.denx.de; Fri, 24 May 2013 17:23:26 +0900 (KST) X-AuditID: cbfee61a-b7f3b6d000006edd-e6-519f237e7713 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id F6.B2.28381.E732F915; Fri, 24 May 2013 17:23:26 +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 <0MNA0053UNAQMW70@mmp2.samsung.com>; Fri, 24 May 2013 17:23:26 +0900 (KST) From: Piotr Wilczek To: u-boot@lists.denx.de Date: Fri, 24 May 2013 10:23:09 +0200 Message-id: <1369383791-21795-2-git-send-email-p.wilczek@samsung.com> X-Mailer: git-send-email 1.7.10 In-reply-to: <1369383791-21795-1-git-send-email-p.wilczek@samsung.com> References: <1369383791-21795-1-git-send-email-p.wilczek@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrNJMWRmVeSWpSXmKPExsVy+t9jQd065fmBBtt6jSzONr1ht3jzcDOj RceRFkaLdU/Wslq83dvJ7sDqcfbODkaPvi2rGAOYorhsUlJzMstSi/TtErgyFq9czl6wQbLi 5QWHBsabIl2MnBwSAiYS555fZoWwxSQu3FvPBmILCUxnlPi/M7aLkQvI7mKSePn0ISNIgk1A W2L5mzdgtoiAhMSv/quMIEXMAssYJRoafrODJIQFvCVmdj9iAbFZBFQlfhxcB9bAK+Aq0dM1 hxFim7zE0/t9YNs4Bdwk/m09wQqx2VXi4bnpTBMYeRcwMqxiFE0tSC4oTkrPNdQrTswtLs1L 10vOz93ECA6SZ1I7GFc2WBxiFOBgVOLhnaEzL1CINbGsuDL3EKMEB7OSCO8svvmBQrwpiZVV qUX58UWlOanFhxilOViUxHkPtFoHCgmkJ5akZqemFqQWwWSZODilGhg37tcqnb52nfipV4qu k6/a1bLaLa57117h/vdrF5PshJ+3ra9eCIq4WF9W0ns/SHB+dzXvTW6j4vvmB7Rb237rrnPp 8d0RujDU6yr7i2kFUX/sWCY/38p7/cq6e1NncZTvXbdZmmP+g7w97ldOCOo4zb0qdbtwy/2F 80y4ur/OORzAZfPoINM5JZbijERDLeai4kQAKx6EbA4CAAA= Cc: Piotr Wilczek , Kyungmin Park Subject: [U-Boot] [PATCH V3 1/3] power:battery: add battery support for Trats2 board 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 Signed-off-by: Piotr Wilczek Signed-off-by: Kyungmin Park --- Changes in v3: none Changes in v2: none --- drivers/power/battery/Makefile | 1 + drivers/power/battery/bat_trats2.c | 81 ++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 drivers/power/battery/bat_trats2.c diff --git a/drivers/power/battery/Makefile b/drivers/power/battery/Makefile index b176701..eeeaa27 100644 --- a/drivers/power/battery/Makefile +++ b/drivers/power/battery/Makefile @@ -26,6 +26,7 @@ include $(TOPDIR)/config.mk LIB := $(obj)libbattery.o COBJS-$(CONFIG_POWER_BATTERY_TRATS) += bat_trats.o +COBJS-$(CONFIG_POWER_BATTERY_TRATS2) += bat_trats2.o COBJS := $(COBJS-y) SRCS := $(COBJS:.o=.c) diff --git a/drivers/power/battery/bat_trats2.c b/drivers/power/battery/bat_trats2.c new file mode 100644 index 0000000..c1be64d --- /dev/null +++ b/drivers/power/battery/bat_trats2.c @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2013 Samsung Electronics + * Piotr Wilczek + * + * 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 + */ + +#include +#include +#include +#include +#include + +static struct battery battery_trats; + +static int power_battery_charge(struct pmic *bat) +{ + struct power_battery *p_bat = bat->pbat; + + if (bat->chrg->chrg_state(p_bat->chrg, CHARGER_ENABLE, 450)) + return -1; + + return 0; +} + +static int power_battery_init_trats2(struct pmic *bat_, + struct pmic *fg_, + struct pmic *chrg_, + struct pmic *muic_) +{ + bat_->pbat->fg = fg_; + bat_->pbat->chrg = chrg_; + bat_->pbat->muic = muic_; + + bat_->fg = fg_->fg; + bat_->chrg = chrg_->chrg; + bat_->chrg->chrg_type = muic_->chrg->chrg_type; + return 0; +} + +static struct power_battery power_bat_trats2 = { + .bat = &battery_trats, + .battery_init = power_battery_init_trats2, + .battery_charge = power_battery_charge, +}; + +int power_bat_init(unsigned char bus) +{ + static const char name[] = "BAT_TRATS2"; + struct pmic *p = pmic_alloc(); + + if (!p) { + printf("%s: POWER allocation error!\n", __func__); + return -ENOMEM; + } + + debug("Board BAT init\n"); + + p->interface = PMIC_NONE; + p->name = name; + p->bus = bus; + + p->pbat = &power_bat_trats2; + return 0; +}