Trats battery is now treated in the same way as other power related
devices. This approach allows for more unified handling of all devices
responsible for power management.

Signed-off-by: Lukasz Majewski <l.majew...@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.p...@samsung.com>
Cc: Stefano Babic <sba...@denx.de>
---
Changes for v2:
- New patch at v2.
---
 drivers/power/Makefile            |    1 +
 drivers/power/battery/bat_trats.c |   79 +++++++++++++++++++++++++++++++++++++
 2 files changed, 80 insertions(+), 0 deletions(-)
 create mode 100644 drivers/power/battery/bat_trats.c

diff --git a/drivers/power/Makefile b/drivers/power/Makefile
index 7016d5b..74a0990 100644
--- a/drivers/power/Makefile
+++ b/drivers/power/Makefile
@@ -38,6 +38,7 @@ COBJS-$(CONFIG_PMIC_I2C) += pmic_i2c.o
 COBJS-$(CONFIG_PMIC_SPI) += pmic_spi.o
 COBJS-$(CONFIG_PMIC_MAX8998) += max8998/pmic_max8998.o
 COBJS-$(CONFIG_PMIC_MAX8997) += max8997/pmic_max8997.o
+COBJS-$(CONFIG_POWER_BATTERY_TRATS) += battery/bat_trats.o
 
 COBJS  := $(COBJS-y)
 SRCS   := $(COBJS:.o=.c)
diff --git a/drivers/power/battery/bat_trats.c 
b/drivers/power/battery/bat_trats.c
new file mode 100644
index 0000000..d6f01da
--- /dev/null
+++ b/drivers/power/battery/bat_trats.c
@@ -0,0 +1,79 @@
+/*
+ *  Copyright (C) 2012 Samsung Electronics
+ *  Lukasz Majewski <l.majew...@samsung.com>
+ *
+ * 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 <common.h>
+#include <power/pmic.h>
+#include <power/battery.h>
+#include <power/max8997_pmic.h>
+
+static struct battery battery_trats;
+
+static int power_battery_charge(struct pmic *bat)
+{
+       struct power_battery *p_bat = bat->pwr_bat;
+       struct battery *battery = p_bat->bat;
+       int k;
+
+       if (p_bat->chrg_state(p_bat->chrg, CHARGER_ENABLE, 450))
+               return -1;
+
+       for (k = 0; p_bat->chrg_bat_present(p_bat->chrg) &&
+                    p_bat->chrg_type(p_bat->muic) &&
+                    battery->state_of_chrg < 5; k++) {
+               udelay(10000000);
+               puts(".");
+               p_bat->fg_battery_update(p_bat->fg, bat);
+
+               if (k == 100) {
+                       debug(" %d [V]", battery->voltage_uV);
+                       puts("\n");
+                       k = 0;
+               }
+
+       }
+
+       p_bat->chrg_state(p_bat->chrg, CHARGER_DISABLE, 0);
+
+       return 0;
+}
+
+static struct power_battery trats_bat = {
+       .bat = &battery_trats,
+};
+
+int power_bat_init(unsigned char bus)
+{
+       struct pmic *p = pmic_alloc();
+       static const char name[] = "BAT_TRATS";
+
+       debug("Board BAT init\n");
+
+       p->interface = PMIC_NONE;
+       p->name = name;
+       p->bus = bus;
+
+       p->pwr_bat = &trats_bat;
+       p->battery_charge = power_battery_charge;
+
+       return 0;
+}
-- 
1.7.2.3

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to