linux-2.6.23: fix LEDs driver for mpc8313e-rdb
authorJeremy Laine <jeremy.laine@m4x.org>
Mon, 3 Dec 2007 10:28:10 +0000 (10:28 +0000)
committerJeremy Laine <jeremy.laine@m4x.org>
Mon, 3 Dec 2007 10:28:10 +0000 (10:28 +0000)
packages/linux/linux-2.6.23/mpc8313e-rdb/mpc8313e-rdb-leds.patch

index 0310746..56176c1 100644 (file)
@@ -1,6 +1,6 @@
 diff -urN linux-2.6.23.orig/drivers/leds/Kconfig linux-2.6.23/drivers/leds/Kconfig
 --- linux-2.6.23.orig/drivers/leds/Kconfig     2007-10-09 22:31:38.000000000 +0200
-+++ linux-2.6.23/drivers/leds/Kconfig  2007-11-29 09:02:42.000000000 +0100
++++ linux-2.6.23/drivers/leds/Kconfig  2007-12-03 11:08:06.000000000 +0100
 @@ -101,6 +101,12 @@
          outputs. To be useful the particular board must have LEDs
          and they must be connected to the GPIO lines.
@@ -16,8 +16,8 @@ diff -urN linux-2.6.23.orig/drivers/leds/Kconfig linux-2.6.23/drivers/leds/Kconf
  config LEDS_TRIGGERS
 diff -urN linux-2.6.23.orig/drivers/leds/leds-mpc8313e-rdb.c linux-2.6.23/drivers/leds/leds-mpc8313e-rdb.c
 --- linux-2.6.23.orig/drivers/leds/leds-mpc8313e-rdb.c 1970-01-01 01:00:00.000000000 +0100
-+++ linux-2.6.23/drivers/leds/leds-mpc8313e-rdb.c      2007-11-29 09:02:42.000000000 +0100
-@@ -0,0 +1,128 @@
++++ linux-2.6.23/drivers/leds/leds-mpc8313e-rdb.c      2007-12-03 11:08:36.000000000 +0100
+@@ -0,0 +1,127 @@
 +/*
 + * drivers/leds/leds-mpc8313e-rdb.c
 + * Copyright (C) 2007 Leon Woestenberg <leon@sidebranch.com>
@@ -38,18 +38,18 @@ diff -urN linux-2.6.23.orig/drivers/leds/leds-mpc8313e-rdb.c linux-2.6.23/driver
 +#include <linux/err.h>
 +#include <asm/io.h>
 +
-+int par_io_config_pin(u8 port, u8 pin, int dir, int open_drain,
-+                      int assignment, int has_irq);
-+int par_io_data_set(u8 port, u8 pin, u8 val);
++#define LEDS_BASE 0xfa000000
++#define LEDS_SIZE 0x2
 +
 +static struct platform_dev *leds_pdev = NULL;
 +static struct resource *led_mem = NULL;
-+static void *p = NULL;
++static void *led_io = NULL;
++static u8 led_state = 0;
 +
 +static void mpc8313leds_green_set(struct led_classdev *led_cdev, enum led_brightness value)
 +{
-+      int d = ioread16(p);
-+      iowrite16(value?d&~1:d|1, p);
++      led_state = value ? led_state&~32 : led_state|32;
++      iowrite8(led_state, led_io);
 +}
 +
 +static struct led_classdev mpc8313_green_led = {
@@ -59,8 +59,8 @@ diff -urN linux-2.6.23.orig/drivers/leds/leds-mpc8313e-rdb.c linux-2.6.23/driver
 +
 +static void mpc8313leds_yellow_set(struct led_classdev *led_cdev, enum led_brightness value)
 +{
-+      int d = ioread16(p);
-+      iowrite16(value?d&~2:d|2, p);
++      led_state = value ? led_state&~64 : led_state|64;
++      iowrite8(led_state, led_io);
 +}
 +
 +static struct led_classdev mpc8313_yellow_led = {
@@ -70,8 +70,8 @@ diff -urN linux-2.6.23.orig/drivers/leds/leds-mpc8313e-rdb.c linux-2.6.23/driver
 +
 +static void mpc8313leds_red_set(struct led_classdev *led_cdev, enum led_brightness value)
 +{
-+      int d = ioread16(p);
-+      iowrite16(value?d&~4:d|4, p);
++      led_state = value ? led_state&~128 : led_state|128;
++      iowrite8(led_state, led_io);
 +}
 +
 +static struct led_classdev mpc8313_red_led = {
@@ -117,12 +117,11 @@ diff -urN linux-2.6.23.orig/drivers/leds/leds-mpc8313e-rdb.c linux-2.6.23/driver
 +
 +static int __init mpc8313leds_init(void)
 +{
-+      led_mem = request_mem_region(0xfa000000, 0x100, "mpc8313-leds");
-+      if (led_mem == NULL) return -ENOMEM;
-+      p = ioremap(0xfa000000, 0x100);
-+      if (p == NULL)
++      if (!(led_mem = request_mem_region(LEDS_BASE, LEDS_SIZE, "mpc8313-leds")))
++              return -ENOMEM;
++      if (!(led_io = ioremap(LEDS_BASE, LEDS_SIZE)))
 +      {
-+              if (led_mem) release_mem_region(0xfa000000, 0x100);
++              release_mem_region(LEDS_BASE, LEDS_SIZE);
 +              led_mem = NULL;
 +              return -ENOMEM;
 +      }
@@ -133,7 +132,7 @@ diff -urN linux-2.6.23.orig/drivers/leds/leds-mpc8313e-rdb.c linux-2.6.23/driver
 +
 +static void __exit mpc8313leds_exit(void)
 +{
-+      if (led_mem) release_mem_region(0xfa000000, 0x100);
++      if (led_mem) release_mem_region(LEDS_BASE, LEDS_SIZE);
 +      led_mem = NULL;
 +      platform_driver_unregister(&mpc8313leds_driver);
 +
@@ -148,7 +147,7 @@ diff -urN linux-2.6.23.orig/drivers/leds/leds-mpc8313e-rdb.c linux-2.6.23/driver
 +MODULE_LICENSE("GPL");
 diff -urN linux-2.6.23.orig/drivers/leds/Makefile linux-2.6.23/drivers/leds/Makefile
 --- linux-2.6.23.orig/drivers/leds/Makefile    2007-10-09 22:31:38.000000000 +0200
-+++ linux-2.6.23/drivers/leds/Makefile 2007-11-29 09:03:09.000000000 +0100
++++ linux-2.6.23/drivers/leds/Makefile 2007-12-03 11:08:06.000000000 +0100
 @@ -17,6 +17,7 @@
  obj-$(CONFIG_LEDS_H1940)              += leds-h1940.o
  obj-$(CONFIG_LEDS_COBALT)             += leds-cobalt.o