Skip to content

Commit

Permalink
Merge branch 'master' of github.com:buglabs/bug20-2.6.31-omap
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Isaacs committed Feb 8, 2011
2 parents 830910a + 95963da commit bade24e
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 15 deletions.
32 changes: 32 additions & 0 deletions Documentation/bmi/bmi_overview.txt
@@ -0,0 +1,32 @@
INTRODUCTION

BMI is the Bug Module Interface. This is a hardware standard for low
power plug and play devices. It's a bit like USB, but with lower power
requirements for mobile/embedded/battery-powered Devices.


DESIGN OVERVIEW

BMI is composed of slots and PIMs (Plug In Modules). Slots are the
abstraction for the physical slots on a machine (bug board for this
version) PIM's Slot drivers are platform specific, and some devices
are slot limited such that a high baud video device may have only a
few select slots that it will work in.

PIM's are intended to work on any platform supporting the BMI,
regardless of the underlying platform, as long as the slot provides
the required features of the PIM.

As a bare minimum a BMI slot needs to provide and I2C connection, as
well as 2 IRQ pins to register the insertion and removal of modules.

BMI BOOT PROCESS
The core BMI module is loaded as a bus driver as compiled-in kernel
module (see drivers/bmi/core/ ) During boot BMI is loaded and runs,
and slots are regiestered as bus items. Then modules are detected and
loaded individually depending on what module info was detected.

Modules can alternately be loaded at run-time when they are detected by
a change on a slots IRQ.


4 changes: 2 additions & 2 deletions arch/arm/configs/omap3_bug_defconfig
@@ -1,7 +1,7 @@
# #
# Automatically generated make config: don't edit # Automatically generated make config: don't edit
# Linux kernel version: 2.6.31-omap1 # Linux kernel version: 2.6.31-omap1
# Thu Dec 30 14:30:58 2010 # Fri Jan 28 14:51:18 2011
# #
CONFIG_ARM=y CONFIG_ARM=y
CONFIG_HAVE_PWM=y CONFIG_HAVE_PWM=y
Expand Down Expand Up @@ -760,7 +760,6 @@ CONFIG_MISC_DEVICES=y
# CONFIG_ENCLOSURE_SERVICES is not set # CONFIG_ENCLOSURE_SERVICES is not set
# CONFIG_ISL29003 is not set # CONFIG_ISL29003 is not set
CONFIG_BUG_DOCK=y CONFIG_BUG_DOCK=y
CONFIG_BUG_BQSIG=y
# CONFIG_C2PORT is not set # CONFIG_C2PORT is not set


# #
Expand Down Expand Up @@ -1771,6 +1770,7 @@ CONFIG_LEDS_TRIGGER_HEARTBEAT=y
CONFIG_LEDS_TRIGGER_BREATHE=y CONFIG_LEDS_TRIGGER_BREATHE=y
CONFIG_LEDS_TRIGGER_BACKLIGHT=m CONFIG_LEDS_TRIGGER_BACKLIGHT=m
# CONFIG_LEDS_TRIGGER_GPIO is not set # CONFIG_LEDS_TRIGGER_GPIO is not set
CONFIG_LEDS_TRIGGER_BQSIG=y
CONFIG_LEDS_TRIGGER_DEFAULT_ON=m CONFIG_LEDS_TRIGGER_DEFAULT_ON=m


# #
Expand Down
4 changes: 2 additions & 2 deletions arch/arm/mach-omap2/board-omap3bug.c
Expand Up @@ -605,14 +605,14 @@ static void __init omap3_bug_init_irq(void)
static struct gpio_led gpio_leds[] = { static struct gpio_led gpio_leds[] = {
{ {
.name = "omap3bug:green:battery", .name = "omap3bug:green:battery",
.default_trigger = "none", .default_trigger = "batt-normal",
.gpio = 53, .gpio = 53,
.active_low = true, .active_low = true,
.default_state = LEDS_GPIO_DEFSTATE_OFF, .default_state = LEDS_GPIO_DEFSTATE_OFF,
}, },
{ {
.name = "omap3bug:red:battery", .name = "omap3bug:red:battery",
.default_trigger = "none", .default_trigger = "batt-low",
.gpio = 54, .gpio = 54,
.active_low = true, .active_low = true,
.default_state = LEDS_GPIO_DEFSTATE_OFF, .default_state = LEDS_GPIO_DEFSTATE_OFF,
Expand Down
8 changes: 8 additions & 0 deletions drivers/leds/Kconfig
Expand Up @@ -317,6 +317,14 @@ config LEDS_TRIGGER_GPIO


If unsure, say N. If unsure, say N.


config LEDS_TRIGGER_BQSIG
tristate "Bug Low Battery Signal Handler"
depends on LEDS_TRIGGERS
depends on I2C
help
Say yes to enable omap3 bug to respond to low battery signals issued
by the bq27500 fuel gauge.

config LEDS_TRIGGER_DEFAULT_ON config LEDS_TRIGGER_DEFAULT_ON
tristate "LED Default ON Trigger" tristate "LED Default ON Trigger"
depends on LEDS_TRIGGERS depends on LEDS_TRIGGERS
Expand Down
1 change: 1 addition & 0 deletions drivers/leds/Makefile
Expand Up @@ -42,3 +42,4 @@ obj-$(CONFIG_LEDS_TRIGGER_BREATHE) += ledtrig-breathe.o
obj-$(CONFIG_LEDS_TRIGGER_BACKLIGHT) += ledtrig-backlight.o obj-$(CONFIG_LEDS_TRIGGER_BACKLIGHT) += ledtrig-backlight.o
obj-$(CONFIG_LEDS_TRIGGER_GPIO) += ledtrig-gpio.o obj-$(CONFIG_LEDS_TRIGGER_GPIO) += ledtrig-gpio.o
obj-$(CONFIG_LEDS_TRIGGER_DEFAULT_ON) += ledtrig-default-on.o obj-$(CONFIG_LEDS_TRIGGER_DEFAULT_ON) += ledtrig-default-on.o
obj-$(CONFIG_LEDS_TRIGGER_BQSIG) += ledtrig-bqsig.o
67 changes: 63 additions & 4 deletions drivers/misc/bug_bqsig.c → drivers/leds/ledtrig-bqsig.c
Expand Up @@ -24,12 +24,16 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <mach/mux.h> #include <mach/mux.h>
#include <linux/bmi.h> #include <linux/bmi.h>
#include <linux/leds.h>
#include "leds.h"


#define BATT_LOW_GPIO 64 #define BATT_LOW_GPIO 64


struct bqsig_device { struct bqsig_device {
struct platform_device *pdev; struct platform_device *pdev;
struct work_struct irq_handler_work; struct work_struct irq_handler_work;
struct led_trigger *batt_low_trig;
struct led_trigger *batt_normal_trig;
}; };


static struct platform_device *bug_bqsig_dev; static struct platform_device *bug_bqsig_dev;
Expand All @@ -46,16 +50,20 @@ static inline struct bqsig_device *irq_handler_work_to_bqsig_device(struct work_
static void irq_handler_work(struct work_struct *work) static void irq_handler_work(struct work_struct *work)
{ {
bool value; bool value;
//struct bqsig_device *bq_signal = irq_handler_work_to_bqsig_device(work); struct bqsig_device *bqsig = container_of(work, struct bqsig_device, irq_handler_work);


value = gpio_get_value(BATT_LOW_GPIO); value = gpio_get_value(BATT_LOW_GPIO);


//asserted //asserted
if (value) { if (value) {
printk(KERN_INFO "WARNING: Low Battery!\n"); led_trigger_event(bqsig->batt_normal_trig, LED_OFF);
led_trigger_event(bqsig->batt_low_trig, LED_FULL);
printk(KERN_INFO "WARNING: Low Battery!\n");
} }
else { else {
printk(KERN_INFO "WARNING: Battery Level Safe\n"); led_trigger_event(bqsig->batt_normal_trig, LED_FULL);
led_trigger_event(bqsig->batt_low_trig, LED_OFF);
printk(KERN_INFO "WARNING: Battery Level Safe\n");
} }
} }


Expand All @@ -70,6 +78,45 @@ static irqreturn_t bqsig_irq_handler(int irq, void *dev_id)
return IRQ_HANDLED; return IRQ_HANDLED;
} }


static void bqsig_low_trig_activate(struct led_classdev *led)
{
bool value;

value = gpio_get_value(BATT_LOW_GPIO);

if (value)
led_set_brightness(led, LED_FULL);
else
led_set_brightness(led, LED_OFF);

return;
}

static void bqsig_low_trig_deactivate(struct led_classdev *led)
{
led_set_brightness(led, LED_OFF);
return;
}

static void bqsig_normal_trig_activate(struct led_classdev *led)
{
bool value;

value = gpio_get_value(BATT_LOW_GPIO);

if (value)
led_set_brightness(led, LED_OFF);
else
led_set_brightness(led, LED_FULL);
return;
}

static void bqsig_normal_trig_deactivate(struct led_classdev *led)
{
led_set_brightness(led, LED_OFF);
return;
}

/* /*
* probe/remove * probe/remove
*/ */
Expand Down Expand Up @@ -107,6 +154,18 @@ static int bug_bqsig_probe(struct platform_device *pdev)
return -EINVAL; return -EINVAL;
} }


led_trigger_register_simple("batt-low", &bq_signal->batt_low_trig);
led_trigger_register_simple("batt-normal", &bq_signal->batt_normal_trig);

if (bq_signal->batt_low_trig && bq_signal->batt_normal_trig) {
bq_signal->batt_low_trig->activate = bqsig_low_trig_activate;
bq_signal->batt_low_trig->deactivate = bqsig_low_trig_deactivate;
bq_signal->batt_normal_trig->activate = bqsig_normal_trig_activate;
bq_signal->batt_normal_trig->deactivate = bqsig_normal_trig_deactivate;
}
else
printk(KERN_ERR "%s led triggers failed to register...\n", __FUNCTION__);

printk(KERN_INFO "bug_bqsig: bug_bqsig_probe...\n"); printk(KERN_INFO "bug_bqsig: bug_bqsig_probe...\n");
return 0; return 0;
} }
Expand Down Expand Up @@ -160,7 +219,7 @@ static void __exit bug_bqsig_exit(void)
platform_device_unregister(bug_bqsig_dev); platform_device_unregister(bug_bqsig_dev);
} }


module_init(bug_bqsig_init); subsys_initcall(bug_bqsig_init);
module_exit(bug_bqsig_exit); module_exit(bug_bqsig_exit);


MODULE_AUTHOR("Dave R"); MODULE_AUTHOR("Dave R");
Expand Down
6 changes: 0 additions & 6 deletions drivers/misc/Kconfig
Expand Up @@ -254,12 +254,6 @@ config BUG_DOCK
Say yes to enable omap3 bug to shut down and start up it's USB hub 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. 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/c2port/Kconfig"
source "drivers/misc/eeprom/Kconfig" source "drivers/misc/eeprom/Kconfig"
Expand Down
1 change: 0 additions & 1 deletion drivers/misc/Makefile
Expand Up @@ -21,6 +21,5 @@ obj-$(CONFIG_HP_ILO) += hpilo.o
obj-$(CONFIG_ISL29003) += isl29003.o obj-$(CONFIG_ISL29003) += isl29003.o
obj-$(CONFIG_C2PORT) += c2port/ obj-$(CONFIG_C2PORT) += c2port/
obj-$(CONFIG_BUG_DOCK) += bug_dock.o obj-$(CONFIG_BUG_DOCK) += bug_dock.o
obj-$(CONFIG_BUG_BQSIG) += bug_bqsig.o
obj-y += eeprom/ obj-y += eeprom/
obj-y += cb710/ obj-y += cb710/

0 comments on commit bade24e

Please sign in to comment.