Skip to contentSkip to conversation

External power framework

RFC PATCH In review Anton Vorontsov 2 participants 4 messages Apr 11, 2007 – Apr 15, 2007

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/7 External power framework

External power framework - power supplies and power supplicants.

Supplicants (batteries so far) may ask to notify they when power supply arrive/gone. This framework used by battery class (next patches).

It's permitted for supply to be bound to several supplicants (think main and backup batteries).

It's also permitted for supplicants to consume power from several external supplies (say AC and USB).

Here is how it look like from userspace:

	# pwd
	/sys/class/power_supply
	# ls
	ac  usb
	# cat ac/online usb/online
	1
	0
---
 drivers/Kconfig                |    2 +
 drivers/Makefile               |    1 +
 drivers/power/Kconfig          |   13 ++
 drivers/power/Makefile         |    1 +
 drivers/power/external_power.c |  318 ++++++++++++++++++++++++++++++++++++++++
 include/linux/external_power.h |   54 +++++++
 6 files changed, 389 insertions(+), 0 deletions(-)
 create mode 100644 drivers/power/Kconfig
 create mode 100644 drivers/power/Makefile
 create mode 100644 drivers/power/external_power.c
 create mode 100644 include/linux/external_power.h
drivers/Kconfig +2 -0
index 050323f..c546de3 100644
@@ -54,6 +54,8 @@ source "drivers/spi/Kconfig"
 
 source "drivers/w1/Kconfig"
 
+source "drivers/power/Kconfig"
+
 source "drivers/hwmon/Kconfig"
 
 source "drivers/mfd/Kconfig"
drivers/Makefile +1 -0
index 3a718f5..2bdaae7 100644
@@ -60,6 +60,7 @@ obj-$(CONFIG_I2O)		+= message/
 obj-$(CONFIG_RTC_LIB)		+= rtc/
 obj-$(CONFIG_I2C)		+= i2c/
 obj-$(CONFIG_W1)		+= w1/
+obj-$(CONFIG_EXTERNAL_POWER)	+= power/
 obj-$(CONFIG_HWMON)		+= hwmon/
 obj-$(CONFIG_PHONE)		+= telephony/
 obj-$(CONFIG_MD)		+= md/
drivers/power/Kconfig new file +13 -0
new file mode 100644
index 0000000..17349c1
@@ -0,0 +1,13 @@
+
+menu "External power support"
+
+config EXTERNAL_POWER
+	tristate "External power kernel interface"
+	help
+	  Say Y here to enable kernel external power detection interface,
+	  like AC or USB. Information also will exported to userspace via
+	  /sys/class/external_power/ directory.
+
+	  This interface is mandatory for battery class support.
+
+endmenu
drivers/power/Makefile new file +1 -0
new file mode 100644
index 0000000..c303b45
@@ -0,0 +1 @@
+obj-$(CONFIG_EXTERNAL_POWER)  += external_power.o
drivers/power/external_power.c new file +318 -0

318 lines not on this page · raw message

include/linux/external_power.h new file +54 -0

54 lines not on this page · raw message

Signature · 1 line
1.5.0.5-dirty
#2 lore raw
In reply to Anton Vorontsov
Quoted 13 lines · Anton Vorontsov

External power framework - power supplies and power supplicants.

Supplicants (batteries so far) may ask to notify they when power supply arrive/gone. This framework used by battery class (next patches).

It's permitted for supply to be bound to several supplicants (think main and backup batteries).

It's also permitted for supplicants to consume power from several external supplies (say AC and USB).

Here is how it look like from userspace:

Quoted 7 lines
	# pwd
	/sys/class/power_supply
	# ls
	ac  usb
	# cat ac/online usb/online
	1
	0

Cleaned up version based on comments from Randy Dunlap.

Subject: [PATCH] [take2] External power framework

---
 drivers/Kconfig                |    2 +
 drivers/Makefile               |    1 +
 drivers/power/Kconfig          |   13 ++
 drivers/power/Makefile         |    1 +
 drivers/power/external_power.c |  326 ++++++++++++++++++++++++++++++++++++++++
 include/linux/external_power.h |   54 +++++++
 6 files changed, 397 insertions(+), 0 deletions(-)
 create mode 100644 drivers/power/Kconfig
 create mode 100644 drivers/power/Makefile
 create mode 100644 drivers/power/external_power.c
 create mode 100644 include/linux/external_power.h
drivers/Kconfig +2 -0
index 050323f..c546de3 100644
@@ -54,6 +54,8 @@ source "drivers/spi/Kconfig"
 
 source "drivers/w1/Kconfig"
 
+source "drivers/power/Kconfig"
+
 source "drivers/hwmon/Kconfig"
 
 source "drivers/mfd/Kconfig"
drivers/Makefile +1 -0
index 3a718f5..2bdaae7 100644
@@ -60,6 +60,7 @@ obj-$(CONFIG_I2O)		+= message/
 obj-$(CONFIG_RTC_LIB)		+= rtc/
 obj-$(CONFIG_I2C)		+= i2c/
 obj-$(CONFIG_W1)		+= w1/
+obj-$(CONFIG_EXTERNAL_POWER)	+= power/
 obj-$(CONFIG_HWMON)		+= hwmon/
 obj-$(CONFIG_PHONE)		+= telephony/
 obj-$(CONFIG_MD)		+= md/
drivers/power/Kconfig new file +13 -0
new file mode 100644
index 0000000..17349c1
@@ -0,0 +1,13 @@
+
+menu "External power support"
+
+config EXTERNAL_POWER
+	tristate "External power kernel interface"
+	help
+	  Say Y here to enable kernel external power detection interface,
+	  like AC or USB. Information also will exported to userspace via
+	  /sys/class/external_power/ directory.
+
+	  This interface is mandatory for battery class support.
+
+endmenu
drivers/power/Makefile new file +1 -0
new file mode 100644
index 0000000..c303b45
@@ -0,0 +1 @@
+obj-$(CONFIG_EXTERNAL_POWER)  += external_power.o
drivers/power/external_power.c new file +326 -0

326 lines not on this page · raw message

include/linux/external_power.h new file +54 -0

54 lines not on this page · raw message

Signature · 1 line
1.5.0.5-dirty
#3 lore raw
In reply to Anton Vorontsov

Hi!

Quoted 13 lines

External power framework - power supplies and power supplicants.

Supplicants (batteries so far) may ask to notify they when power supply arrive/gone. This framework used by battery class (next patches).

It's permitted for supply to be bound to several supplicants (think main and backup batteries).

It's also permitted for supplicants to consume power from several external supplies (say AC and USB).

Here is how it look like from userspace:

Quoted 7 lines
	# pwd
	/sys/class/power_supply
	# ls
	ac  usb
	# cat ac/online usb/online
	1
	0

Looks nice to me.
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html