Author: cmjones
Date: 2012-08-16 13:05:13 +0100 (Thu, 16 Aug 2012)
New Revision: 1952
Modified:
balloon/branches/menuconfig2/package/kernel/patches/2.6.39.4/balloon3-powerfail.patch
Log:
Powerfail patch converted to 2.6.39.4
Modified: balloon/branches/menuconfig2/package/kernel/patches/2.6.39.4/balloon3-powerfail.patch
===================================================================
--- balloon/branches/menuconfig2/package/kernel/patches/2.6.39.4/balloon3-powerfail.patch 2012-08-16 11:56:43 UTC (rev 1951)
+++ balloon/branches/menuconfig2/package/kernel/patches/2.6.39.4/balloon3-powerfail.patch 2012-08-16 12:05:13 UTC (rev 1952)
@@ -1,322 +1,28 @@
-Index: linux-2.6.29.1/drivers/char/Kconfig
+Index: linux-2.6.39.4/drivers/char/Kconfig
===================================================================
---- linux-2.6.29.1.orig/drivers/char/Kconfig 2009-09-21 01:17:07.000000000 +0100
-+++ linux-2.6.29.1/drivers/char/Kconfig 2009-09-21 01:17:07.000000000 +0100
-@@ -680,6 +680,13 @@
- help
- TSL2560 light sensor driven down Samosa bus (for Balloonboard).
+--- linux-2.6.39.4.orig/drivers/char/Kconfig 2012-08-16 13:00:58.000000000 +0100
++++ linux-2.6.39.4/drivers/char/Kconfig 2012-08-16 13:01:45.000000000 +0100
+@@ -212,6 +212,13 @@
+ help
+ TSL2560 light sensor driven down Samosa bus (for Balloonboard).
+config BALLOON3_POWERFAIL
-+ tristate "Balloon 3 powerfail"
-+ depends on MACH_BALLOON3
-+ default m
-+ help
-+ Balloon 3 power failure detection device.
++ tristate "Balloon 3 powerfail"
++ depends on MACH_BALLOON3
++ default m
++ help
++ Balloon 3 power failure detection device.
+
- config HVCS
- tristate "IBM Hypervisor Virtual Console Server support"
- depends on PPC_PSERIES
-Index: linux-2.6.29.1/drivers/char/Makefile
+ config DS1620
+ tristate "NetWinder thermometer support"
+ depends on ARCH_NETWINDER
+Index: linux-2.6.39.4/drivers/char/Makefile
===================================================================
---- linux-2.6.29.1.orig/drivers/char/Makefile 2009-09-21 01:17:07.000000000 +0100
-+++ linux-2.6.29.1/drivers/char/Makefile 2009-09-21 01:17:07.000000000 +0100
-@@ -114,6 +114,7 @@
+--- linux-2.6.39.4.orig/drivers/char/Makefile 2012-08-16 13:01:53.000000000 +0100
++++ linux-2.6.39.4/drivers/char/Makefile 2012-08-16 13:02:09.000000000 +0100
+@@ -67,3 +67,5 @@
obj-$(CONFIG_SAMOSA) += samosa.o
obj-$(CONFIG_LMR5428) += lmr5428.o
obj-$(CONFIG_TSL2560) += tsl2560.o
-+obj-$(CONFIG_BALLOON3_POWERFAIL) += balloon3-powerfail.o
-
- # Files generated that shall be removed upon make clean
- clean-files := consolemap_deftbl.c defkeymap.c
-Index: linux-2.6.29.1/drivers/char/balloon3-powerfail.c
-===================================================================
---- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ linux-2.6.29.1/drivers/char/balloon3-powerfail.c 2009-09-21 01:22:45.000000000 +0100
-@@ -0,0 +1,287 @@
-+/*
-+ * linux/drivers/char/balloon3-powerfail.c
-+ *
-+ * file interface balloon 3 power failure
-+ * Copyright (c) Chris Jones, Martin-Jones Technology Ltd 2009
-+ *
-+*/
++obj-$(CONFIG_BALLOON3_POWERFAIL) += balloon3-powerfail.o
+
-+#include <linux/module.h>
-+#include <linux/init.h>
-+#include <linux/fs.h>
-+#include <linux/uaccess.h>
-+
-+#include <mach/balloon3.h>
-+#include <asm/cacheflush.h>
-+
-+#include <linux/delay.h>
-+#include <linux/device.h>
-+#include <linux/proc_fs.h>
-+#include <linux/vmalloc.h>
-+#include <linux/platform_device.h>
-+#include <linux/spinlock.h>
-+#include <linux/cdev.h>
-+#include <linux/interrupt.h>
-+
-+#include <mach/pxa-regs.h>
-+#include <mach/pxa2xx-regs.h>
-+
-+#define PMCR_INTRS (1<<5)
-+#define PMCR_IAS (1<<4)
-+#define PMCR_VIDAS (1<<3)
-+#define PMCR_VIDAE (1<<2)
-+#define PMCR_BIDAS (1<<1)
-+#define PMCR_BIDAE (1<<0)
-+
-+/* character device start number */
-+static dev_t dev;
-+
-+static int powerstate;
-+
-+static spinlock_t powerfail_lock;
-+
-+#define POWERSTATE_OK 0
-+#define POWERSTATE_BATT_FAULT (1<<0)
-+#define POWERSTATE_VDD_FAULT (1<<1)
-+
-+/* per device data */
-+static struct powerfail_dev {
-+ struct cdev cdev;
-+} powerfail;
-+
-+static irqreturn_t powerfail_interrupt(int irq, struct irq_desc *desc);
-+
-+irqreturn_t powerfail_interrupt(int irq, struct irq_desc *desc) {
-+ pr_info("%s\n",__func__);
-+
-+ /* look at PXA registers to see what's happened */
-+ if(!(PMCR&PMCR_INTRS)) {
-+ /* INTRS wasn't set, so this wasn't ours */
-+ return IRQ_NONE;
-+ }
-+ PMCR|=PMCR_INTRS;
-+
-+ if(PMCR&PMCR_VIDAS) {
-+ pr_info("VDD fault\n");
-+ powerstate|=POWERSTATE_VDD_FAULT;
-+ PMCR|=PMCR_VIDAS;
-+ } else {
-+ powerstate&=~POWERSTATE_VDD_FAULT;
-+ }
-+
-+ if(PMCR&PMCR_BIDAS) {
-+ pr_info("Batt fault\n");
-+ powerstate|=POWERSTATE_BATT_FAULT;
-+ PMCR|=PMCR_BIDAS;
-+ } else {
-+ powerstate&=~POWERSTATE_BATT_FAULT;
-+ }
-+
-+ return IRQ_HANDLED;
-+}
-+
-+static ssize_t powerfail_read(struct file *, char *, size_t, loff_t *);
-+static ssize_t powerfail_write(struct file *, const char *, size_t, loff_t *);
-+static int powerfail_open(struct inode *, struct file *);
-+static int powerfail_release(struct inode *, struct file *);
-+static int powerfail_ioctl(struct inode *, struct file *, unsigned int, unsigned long);
-+static int powerfail_mmap(struct file *, struct vm_area_struct *vm);
-+
-+static struct file_operations powerfail_fops = {
-+ read: powerfail_read,
-+ write: powerfail_write,
-+ open: powerfail_open,
-+ release: powerfail_release,
-+ ioctl: powerfail_ioctl,
-+ mmap: powerfail_mmap,
-+};
-+
-+/* proc interface */
-+static ssize_t proc_read_powerfail(struct file *file, char *buf,
-+ size_t nbytes, loff_t *ppos);
-+static ssize_t proc_write_powerfail(struct file *file, const char *buffer,
-+ size_t count, loff_t *ppos);
-+
-+static struct file_operations proc_powerfail_operations = {
-+ read: proc_read_powerfail,
-+ write: proc_write_powerfail
-+};
-+static struct proc_dir_entry *proc_powerfail;
-+#define PROC_POWERFAIL "powerfail"
-+
-+static int powerfail_open(struct inode *inode, struct file *filp)
-+{
-+ struct powerfail_dev *powerfail_devp;
-+
-+ powerfail_devp = container_of(inode->i_cdev, struct powerfail_dev, cdev);
-+ filp->private_data = powerfail_devp;
-+
-+ return 0;
-+}
-+
-+static int powerfail_release(struct inode *inode, struct file *filp)
-+{
-+ return 0;
-+}
-+
-+static ssize_t powerfail_read(struct file *filp, char *buf,
-+ size_t size, loff_t *offp)
-+{
-+ char outputbuf[80];
-+ int count = 0;
-+
-+ /* all done in a single read */
-+ if (*offp > 0)
-+ return 0;
-+
-+ /* quick and dirty, this: just read the value of PMCR and munge it a bit */
-+ if(PMCR&PMCR_VIDAS) powerstate |= POWERSTATE_VDD_FAULT;
-+ if(PMCR&PMCR_BIDAS) powerstate |= POWERSTATE_BATT_FAULT;
-+
-+ count += sprintf(&outputbuf[count], "0x%02x\n", powerstate);
-+
-+ if (count > size) /* Assume output can be read at one time */
-+ return -EINVAL;
-+ if (copy_to_user(buf, outputbuf, count))
-+ return -EFAULT;
-+ *offp += count;
-+ return count;
-+}
-+
-+static ssize_t powerfail_write(struct file *filp, const char *buf,
-+ size_t size, loff_t *offp)
-+{
-+ /* we don't support writing at the moment */
-+ return -EINVAL;
-+}
-+
-+/* maybe this will be handy in due course */
-+static int powerfail_ioctl(struct inode *inode, struct file *flip,
-+ unsigned int command, unsigned long arg)
-+{
-+ int err;
-+ err = -EINVAL;
-+ return err;
-+}
-+
-+static int powerfail_mmap(struct file *filp, struct vm_area_struct *vma)
-+{
-+ /*struct powerfail_dev *mp = (struct powerfail_dev *)filp->private_data;*/
-+
-+ return -EINVAL;
-+}
-+
-+
-+static int proc_read_powerfail(struct file *filp, char *buf,
-+ size_t nbytes, loff_t *ppos)
-+{
-+ char outputbuf[512];
-+ int count = 0;
-+
-+ /* all done in a single read */
-+ if (*ppos > 0)
-+ return 0;
-+
-+ count += sprintf(&outputbuf[count], "powerfail: major dev = %d\n", MAJOR(dev));
-+
-+ if (count > nbytes) /* Assume output can be read at one time */
-+ return -EINVAL;
-+ if (copy_to_user(buf, outputbuf, count))
-+ return -EFAULT;
-+ *ppos += count;
-+ return count;
-+}
-+
-+static ssize_t proc_write_powerfail(struct file *filp, const char *buffer,
-+ size_t count, loff_t *ppos)
-+{
-+ /* struct powerfail_dev *mp= (struct powerfail_dev *)filp->private_data;
-+ * if (strncmp(buff,"reset:",6)==0)
-+ * newRegValue = simple_strtoul(buffer,&endp,0);
-+ * a bold but simple claim is to have read it all
-+ */
-+ return count;
-+}
-+
-+/* class object */
-+static struct class *powerfail_class;
-+
-+static int __init powerfail_init(void)
-+{
-+ int ret;
-+
-+ /* general initialisation */
-+ spin_lock_init(&powerfail_lock);
-+
-+ /* register a range of device nodes */
-+ ret = alloc_chrdev_region(&dev, 0, 1, "powerfail");
-+ if (ret)
-+ goto error;
-+
-+ /* create the powerfail character devices */
-+ /* initialise character device */
-+ cdev_init(&powerfail.cdev, &powerfail_fops);
-+ /* claim ownership */
-+ powerfail.cdev.owner = THIS_MODULE;
-+ /* add character device */
-+ ret = cdev_add(&powerfail.cdev, dev, 1);
-+ if (ret) {
-+ goto error_region;
-+ }
-+
-+ /* create the class and devices */
-+ powerfail_class = class_create(THIS_MODULE, "powerfail");
-+
-+ if (!device_create(powerfail_class, NULL, (dev), NULL, "powerfail"))
-+ goto error_class_device;
-+
-+ /* create proc access */
-+ proc_powerfail = create_proc_entry(PROC_POWERFAIL, S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH, NULL);
-+ if (proc_powerfail)
-+ proc_powerfail->proc_fops = &proc_powerfail_operations;
-+
-+ /* set up interrupt handler */
-+ /* no, actually, don't: it's too hard */
-+
-+ powerstate =0;
-+
-+ /* clear any pending interrupts and put the power manager in the right state */
-+ PMCR=PMCR_INTRS+PMCR_IAS+PMCR_VIDAS+PMCR_VIDAE+PMCR_BIDAS+PMCR_BIDAE;
-+
-+ return 0;
-+
-+error_class_device:
-+ device_destroy(powerfail_class, dev);
-+error_region:
-+ unregister_chrdev_region(dev, 1);
-+error:
-+ return ret;
-+}
-+
-+static void __exit powerfail_exit(void)
-+{
-+ /* remove interrupt handler */
-+ /* we never registered it */
-+
-+ /* remove proc entry */
-+ remove_proc_entry(PROC_POWERFAIL, NULL);
-+
-+ /* remove class device */
-+ device_destroy(powerfail_class, (dev));
-+
-+ /* remove character device */
-+ cdev_del(&powerfail.cdev);
-+
-+ /* unregister region */
-+ unregister_chrdev_region(dev, 1);
-+
-+ /* remove class */
-+ class_destroy(powerfail_class);
-+}
-+
-+module_init(powerfail_init);
-+module_exit(powerfail_exit);
-+
-+MODULE_AUTHOR("Chris Jones <chris@martin-jones.com>");
-+MODULE_DESCRIPTION("Balloon 3 power failure device");
-+MODULE_LICENSE("GPL");