Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'github' into myfork

  • Loading branch information...
commit a95de46dd6ebb00102a63ceac45b6994f4d9bb37 2 parents 1daf47b + 1542103
@dirjud dirjud authored
View
3  arch/arm/configs/omap3_bug_defconfig
@@ -1,7 +1,7 @@
#
# Automatically generated make config: don't edit
# Linux kernel version: 2.6.31-omap1
-# Wed Oct 13 18:16:23 2010
+# Fri Oct 29 19:43:03 2010
#
CONFIG_ARM=y
CONFIG_HAVE_PWM=y
@@ -760,6 +760,7 @@ CONFIG_MISC_DEVICES=y
# CONFIG_ENCLOSURE_SERVICES is not set
# CONFIG_ISL29003 is not set
CONFIG_BUG_DOCK=y
+CONFIG_BUG_BQSIG=y
# CONFIG_C2PORT is not set
#
View
2  arch/arm/mach-omap2/mux.c
@@ -475,6 +475,8 @@ MUX_CFG_34XX("T8_34XX_GPIO55_OUT", 0x0b6,
///
MUX_CFG_34XX("L8_34XX_GPIO63", 0x0ce,
OMAP34XX_MUX_MODE4 | OMAP34XX_PIN_INPUT)
+MUX_CFG_34XX("K8_34XX_GPIO64", 0x0d0,
+ OMAP34XX_MUX_MODE4 | OMAP34XX_PIN_INPUT)
MUX_CFG_34XX("G25_34XX_GPIO86_OUT", 0x0fc,
OMAP34XX_MUX_MODE4 | OMAP34XX_PIN_OUTPUT)
MUX_CFG_34XX("AH19_34XX_GPIO113", 0x136,
View
1  arch/arm/plat-omap/include/mach/mux.h
@@ -848,6 +848,7 @@ enum omap34xx_index {
T8_34XX_GPIO55_OUT,
///
L8_34XX_GPIO63,
+ K8_34XX_GPIO64,
G25_34XX_GPIO86_OUT,
AH19_34XX_GPIO113,
AG4_34XX_GPIO134_OUT,
View
7 drivers/misc/Kconfig
@@ -254,6 +254,13 @@ config BUG_DOCK
Say yes to enable omap3 bug to shut down and start up it's USB hub
as it is needed by modules/dock. This should probably be built in.
+config BUG_BQSIG
+ tristate "Bug Low Battery Signal Handler"
+ depends on I2C
+ help
+ Say yes to enable omap3 bug to respond to low battery signals issued
+ by the bq27500 fuel gauge.
+
source "drivers/misc/c2port/Kconfig"
source "drivers/misc/eeprom/Kconfig"
source "drivers/misc/cb710/Kconfig"
View
1  drivers/misc/Makefile
@@ -21,5 +21,6 @@ obj-$(CONFIG_HP_ILO) += hpilo.o
obj-$(CONFIG_ISL29003) += isl29003.o
obj-$(CONFIG_C2PORT) += c2port/
obj-$(CONFIG_BUG_DOCK) += bug_dock.o
+obj-$(CONFIG_BUG_BQSIG) += bug_bqsig.o
obj-y += eeprom/
obj-y += cb710/
View
168 drivers/misc/bug_bqsig.c
@@ -0,0 +1,168 @@
+/*
+ * drivers/misc/bug_batt_low.c
+ *
+ * Dock driver for OMAP3 BUGBASE
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind,
+ * whether express or implied; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ */
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <mach/hardware.h>
+#include <mach/gpio.h>
+#include <linux/irq.h>
+#include <linux/interrupt.h>
+#include <mach/mux.h>
+#include <linux/bmi.h>
+
+#define BATT_LOW_GPIO 64
+
+struct bqsig_device {
+ struct platform_device *pdev;
+ struct work_struct irq_handler_work;
+};
+
+static struct platform_device *bug_bqsig_dev;
+
+/*
+ * work queuing
+ */
+
+static inline struct bqsig_device *irq_handler_work_to_bqsig_device(struct work_struct *work)
+{
+ return container_of(work, struct bqsig_device, irq_handler_work);
+}
+
+static void irq_handler_work(struct work_struct *work)
+{
+ bool value;
+ //struct bqsig_device *bq_signal = irq_handler_work_to_bqsig_device(work);
+
+ value = gpio_get_value(BATT_LOW_GPIO);
+
+ //asserted
+ if (value) {
+ printk(KERN_INFO "WARNING: Low Battery!\n");
+ }
+ else {
+ printk(KERN_INFO "WARNING: Battery Level Safe\n");
+ }
+}
+
+/*
+ * interrupt handler
+ */
+
+static irqreturn_t bqsig_irq_handler(int irq, void *dev_id)
+{
+ struct bqsig_device *bq_signal = dev_id;
+ schedule_work(&bq_signal->irq_handler_work);
+ return IRQ_HANDLED;
+}
+
+/*
+ * probe/remove
+ */
+
+static int bug_bqsig_probe(struct platform_device *pdev)
+{
+ int err;
+ //bool value;
+ struct bqsig_device *bq_signal;
+
+ bq_signal = kzalloc(sizeof(struct bqsig_device), GFP_KERNEL);
+ bq_signal->pdev = pdev;
+
+ // init work struct
+ INIT_WORK(&bq_signal->irq_handler_work, irq_handler_work);
+
+ // request dock presence pin
+ err = gpio_request(BATT_LOW_GPIO, "bq_batt_low");
+ err |= gpio_direction_input(BATT_LOW_GPIO);
+ omap_set_gpio_debounce(BATT_LOW_GPIO, 1);
+ omap_set_gpio_debounce_time(BATT_LOW_GPIO, 0xff);
+
+ omap_cfg_reg(K8_34XX_GPIO64);
+
+ // request BATT_LOW irq
+ err = request_irq(gpio_to_irq(BATT_LOW_GPIO), bqsig_irq_handler,
+ IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING, "bq-battlow-signal", bq_signal);
+
+ platform_set_drvdata(pdev, bq_signal);
+
+ // check for batt_low assertion on probe
+
+ if (err < 0) {
+ printk(KERN_ERR "bq_signal: error during probe...\n");
+ return -EINVAL;
+ }
+
+ printk(KERN_INFO "bug_bqsig: bug_bqsig_probe...\n");
+ return 0;
+}
+
+static int bug_bqsig_remove(struct platform_device *pdev)
+{
+ struct bqsig_device *bq_signal;
+ bq_signal = platform_get_drvdata(pdev);
+
+ free_irq(gpio_to_irq(BATT_LOW_GPIO), bq_signal);
+ gpio_free(BATT_LOW_GPIO);
+
+ printk(KERN_INFO "bug_bqsig: bug_bqsig_remove...\n");
+ return 0;
+}
+
+static int bug_bqsig_suspend(struct platform_device *pdev, pm_message_t state)
+{
+ return 0;
+}
+
+static int bug_bqsig_resume(struct platform_device *pdev)
+{
+ return 0;
+}
+
+static struct platform_driver bug_bqsig_drv = {
+ .probe = bug_bqsig_probe,
+ .remove = bug_bqsig_remove,
+ .suspend = bug_bqsig_suspend,
+ .resume = bug_bqsig_resume,
+ .driver = {
+ .name = "bq-battlow-signal",
+ },
+};
+
+static int __init bug_bqsig_init(void)
+{
+ int ret;
+
+ bug_bqsig_dev = platform_device_alloc("bq-battlow-signal", -1);
+ ret = platform_device_add(bug_bqsig_dev);
+
+ ret = platform_driver_register(&bug_bqsig_drv);
+ return ret;
+}
+
+static void __exit bug_bqsig_exit(void)
+{
+ platform_driver_unregister(&bug_bqsig_drv);
+ platform_device_unregister(bug_bqsig_dev);
+}
+
+module_init(bug_bqsig_init);
+module_exit(bug_bqsig_exit);
+
+MODULE_AUTHOR("Dave R");
+MODULE_DESCRIPTION("OMAP3 Bug BATT_LOW Signal Handler");
+MODULE_LICENSE("GPL");
Please sign in to comment.
Something went wrong with that request. Please try again.