lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1354002423-24587-2-git-send-email-ramakrishna.pallala@intel.com>
Date:	Tue, 27 Nov 2012 13:17:02 +0530
From:	Ramakrishna Pallala <ramakrishna.pallala@...el.com>
To:	linux-kernel@...r.kernel.org
Cc:	Anton Vorontsov <cbouatmailru@...il.com>,
	Anton Vorontsov <anton.vorontsov@...aro.org>,
	Ramakrishna Pallala <ramakrishna.pallala@...el.com>,
	Jenny TC <jenny.tc@...el.com>,
	Myungjoo Ham <myungjoo.ham@...sung.com>
Subject: [PATCH 1/2] power_supply: Add charge control struct in power supply class

This patch adds power supply charge control structure to power_supply struct
and add a Kconfig flag to use these controls by charger frameworks.

This patch also adds a helper function/API to return the charge control
struct to the charger frameworks.

Signed-off-by: Ramakrishna Pallala <ramakrishna.pallala@...el.com>
---
 drivers/power/Kconfig             |    6 ++++++
 drivers/power/power_supply_core.c |   18 ++++++++++++++++++
 include/linux/power_supply.h      |   26 ++++++++++++++++++++++++++
 3 files changed, 50 insertions(+), 0 deletions(-)

diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig
index 263499f..782067b 100644
--- a/drivers/power/Kconfig
+++ b/drivers/power/Kconfig
@@ -346,6 +346,12 @@ config AB8500_BM
 	help
 	  Say Y to include support for AB8500 battery management.
 
+config PSY_CM_LOW_LEVEL_SUPPORT
+	bool "Low level driver support for charger managers"
+	help
+	  Say Y here to enable low level power supply class drivers
+	  support for charger manager or framework.
+
 endif # POWER_SUPPLY
 
 source "drivers/power/avs/Kconfig"
diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
index f984da1..0f393c6 100644
--- a/drivers/power/power_supply_core.c
+++ b/drivers/power/power_supply_core.c
@@ -158,6 +158,24 @@ struct power_supply *power_supply_get_by_name(char *name)
 }
 EXPORT_SYMBOL_GPL(power_supply_get_by_name);
 
+#ifdef CONFIG_PSY_CM_LOW_LEVEL_SUPPORT
+struct power_supply_charger_control
+		*power_supply_get_chrg_cntl_by_name(const char *name)
+{
+	struct device *dev = class_find_device(power_supply_class, NULL,
+			(char *)name, power_supply_match_device_by_name);
+
+	return dev ? ((struct power_supply *)dev_get_drvdata(dev))->chrg_cntl : NULL;
+}
+#else
+struct power_supply_charger_control
+		*power_supply_get_chrg_cntl_by_name(const char *name)
+{
+	return NULL;
+}
+#endif
+EXPORT_SYMBOL_GPL(power_supply_get_chrg_cntl_by_name);
+
 int power_supply_powers(struct power_supply *psy, struct device *dev)
 {
 	return sysfs_create_link(&psy->dev->kobj, &dev->kobj, "powers");
diff --git a/include/linux/power_supply.h b/include/linux/power_supply.h
index 1f0ab90..35cdf2c 100644
--- a/include/linux/power_supply.h
+++ b/include/linux/power_supply.h
@@ -191,6 +191,10 @@ struct power_supply {
 	struct thermal_cooling_device *tcd;
 #endif
 
+#ifdef CONFIG_PSY_CM_LOW_LEVEL_SUPPORT
+	struct power_supply_charger_control *chrg_cntl;
+#endif
+
 #ifdef CONFIG_LEDS_TRIGGERS
 	struct led_trigger *charging_full_trig;
 	char *charging_full_trig_name;
@@ -224,7 +228,29 @@ struct power_supply_info {
 	int use_for_apm;
 };
 
+struct power_supply_charger_control {
+	const char *name;
+	/* get charging status */
+	int (*is_charging_enabled)(void);
+	int (*is_charger_enabled)(void);
+
+	/* set charging parameters */
+	int (*set_in_current_limit)(int uA);
+	int (*set_charge_current)(int uA);
+	int (*set_charge_voltage)(int uV);
+
+	/* control battery charging */
+	int (*enable_charging)(void);
+	int (*disable_charging)(void);
+
+	/* control VSYS or system supply */
+	int (*turnon_charger)(void);
+	int (*turnoff_charger)(void);
+};
+
 extern struct power_supply *power_supply_get_by_name(char *name);
+extern struct power_supply_charger_control
+		*power_supply_get_chrg_cntl_by_name(const char *name);
 extern void power_supply_changed(struct power_supply *psy);
 extern int power_supply_am_i_supplied(struct power_supply *psy);
 extern int power_supply_set_battery_charged(struct power_supply *psy);
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ