aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/rdc-2.6/files
diff options
context:
space:
mode:
Diffstat (limited to 'target/linux/rdc-2.6/files')
-rw-r--r--target/linux/rdc-2.6/files/arch/i386/mach-rdc/gpio.c81
-rw-r--r--target/linux/rdc-2.6/files/arch/i386/mach-rdc/platform.c73
-rw-r--r--target/linux/rdc-2.6/files/drivers/leds/leds-rdc3211.c87
-rw-r--r--target/linux/rdc-2.6/files/include/asm-i386/gpio.h6
-rw-r--r--target/linux/rdc-2.6/files/include/asm-i386/mach-generic/gpio.h15
-rw-r--r--target/linux/rdc-2.6/files/include/asm-i386/mach-rdc/gpio.h56
-rw-r--r--target/linux/rdc-2.6/files/include/asm-i386/mach-rdc/rdc321x_defs.h1
7 files changed, 259 insertions, 60 deletions
diff --git a/target/linux/rdc-2.6/files/arch/i386/mach-rdc/gpio.c b/target/linux/rdc-2.6/files/arch/i386/mach-rdc/gpio.c
new file mode 100644
index 0000000000..eadb15235e
--- /dev/null
+++ b/target/linux/rdc-2.6/files/arch/i386/mach-rdc/gpio.c
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2007, OpenWrt.org, Florian Fainelli <florian@openwrt.org>
+ * RDC321x architecture specific GPIO support
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ */
+
+#include <linux/autoconf.h>
+#include <linux/init.h>
+#include <linux/io.h>
+#include <linux/types.h>
+#include <linux/module.h>
+#include <linux/delay.h>
+
+#define RDC3210_CFGREG_ADDR 0x0CF8
+#define RDC3210_CFGREG_DATA 0x0CFC
+
+static unsigned int rdc_gpio_read(unsigned gpio)
+{
+ unsigned int val;
+
+ val = 0x80000000 | (7 << 11) | ((0x48));
+ outl(val, RDC3210_CFGREG_ADDR);
+ udelay(10);
+ val = inl(RDC3210_CFGREG_DATA);
+ val |= (0x1 << gpio);
+ outl(val, RDC3210_CFGREG_DATA);
+ udelay(10);
+ val = 0x80000000 | (7 << 11) | ((0x4C));
+ outl(val, RDC3210_CFGREG_ADDR);
+ udelay(10);
+ val = inl(RDC3210_CFGREG_DATA);
+
+ return val;
+}
+
+void rdc_gpio_write(unsigned int val)
+{
+ if (val) {
+ outl(val, RDC3210_CFGREG_DATA);
+ udelay(10);
+ }
+}
+
+int rdc_gpio_get_value(unsigned gpio)
+{
+ return ((int)rdc_gpio_read(gpio));
+}
+EXPORT_SYMBOL(rdc_gpio_get_value);
+
+void rdc_gpio_set_value(unsigned gpio, int value)
+{
+ unsigned int val;
+
+ val = rdc_gpio_read(gpio);
+
+ if (value)
+ val &= ~(0x1 << gpio);
+ else
+ val |= (0x1 << gpio);
+
+ rdc_gpio_write(val);
+}
+EXPORT_SYMBOL(rdc_gpio_set_value);
+
+int rdc_gpio_direction_input(unsigned gpio)
+{
+ return 0;
+}
+EXPORT_SYMBOL(rdc_gpio_direction_input);
+
+int rdc_gpio_direction_output(unsigned gpio, int value)
+{
+ return 0;
+}
+EXPORT_SYMBOL(rdc_gpio_direction_output);
+
+
diff --git a/target/linux/rdc-2.6/files/arch/i386/mach-rdc/platform.c b/target/linux/rdc-2.6/files/arch/i386/mach-rdc/platform.c
new file mode 100644
index 0000000000..aa245a052b
--- /dev/null
+++ b/target/linux/rdc-2.6/files/arch/i386/mach-rdc/platform.c
@@ -0,0 +1,73 @@
+/*
+ * $Id: platform.c 8331 2007-08-03 15:59:23Z florian $
+ *
+ * Generic RDC321x platform devices
+ *
+ * Copyright (C) 2007 OpenWrt.org
+ * Copyright (C) 2007 Florian Fainelli <florian@openwrt.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/list.h>
+#include <linux/device.h>
+#include <linux/platform_device.h>
+
+#include <asm/gpio.h>
+#include <asm/mach-rdc/rdc321x_defs.h>
+
+/* FIXME : Flash */
+static struct resource rdc_flash_resource[] = {
+ [0] = {
+ .start = RDC_FLASH_BASE,
+ .end = RDC_FLASH_BASE+CONFIG_MTD_RDC3210_SIZE-1,
+ .flags = IORESOURCE_MEM,
+ },
+};
+
+static struct platform_device rdc_flash_device = {
+ .name = "rdc321x-flash",
+ .id = -1,
+ .num_resources = ARRAY_SIZE(rdc_flash_resource),
+ .resource = rdc_flash_resource,
+};
+
+/* LEDS */
+static struct platform_device rdc321x_leds = {
+ .name = "rdc321x-leds",
+ .id = -1,
+ .num_resources = 0,
+};
+
+static int __init rdc_board_setup(void)
+{
+ int err;
+
+ err = platform_device_register(&rdc_flash_device);
+ if (err)
+ printk(KERN_ALERT "rdc321x: failed to register flash\n");
+
+ err = platform_device_register(&rdc321x_leds);
+ if (err)
+ printk(KERN_ALERT "rdc321x: failed to register LEDS\n");
+
+ return err;
+}
+
+arch_initcall(rdc_board_setup);
diff --git a/target/linux/rdc-2.6/files/drivers/leds/leds-rdc3211.c b/target/linux/rdc-2.6/files/drivers/leds/leds-rdc3211.c
index b98b43a5b5..b45a10e0a6 100644
--- a/target/linux/rdc-2.6/files/drivers/leds/leds-rdc3211.c
+++ b/target/linux/rdc-2.6/files/drivers/leds/leds-rdc3211.c
@@ -10,100 +10,67 @@
*/
#include <linux/kernel.h>
+#include <linux/module.h>
#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/leds.h>
#include <linux/err.h>
+#include <linux/delay.h>
#include <asm/io.h>
+#include <asm/gpio.h>
-#define LED_VAL 0x8000384C // the data ofset of gpio 0~30
+int gpio;
+module_param(gpio, int, 0444);
+MODULE_PARM_DESC(gpio, " GPIO line");
-static struct platform_device *pdev;
-
-static void rdc3211_led_set(struct led_classdev *led_cdev, enum led_brightness brightness)
+static void rdc321x_led_set(struct led_classdev *led_cdev, enum led_brightness brightness)
{
- unsigned long ul_ledstat = 0xffffffff;
- unsigned long led_bit = 1 << (led_cdev->flags);
-
- if (brightness)
- ul_ledstat &= ~led_bit;
- else
- ul_ledstat|= led_bit;
-
- outl(LED_VAL, 0xcf8);
- outl(ul_ledstat, 0xcfc);
+ gpio_set_value(gpio, brightness ? 1 : 0);
}
-static struct led_classdev rdc3211_power_led = {
- .name = "rdc3211:power",
- .flags = 15,
- .brightness_set = rdc3211_led_set,
+static struct led_classdev rdc321x_dmz_led = {
+ .name = "rdc321x:dmz",
+ .brightness_set = rdc321x_led_set,
};
-static struct led_classdev rdc3211_dmz_led = {
- .name = "rdc3211:dmz",
- .flags = 16,
- .brightness_set = rdc3211_led_set,
-};
-
-static int rdc3211_leds_probe(struct platform_device *pdev)
+static int rdc321x_leds_probe(struct platform_device *pdev)
{
- int ret;
-
- ret = led_classdev_register(&pdev->dev, &rdc3211_power_led);
- if (ret < 0)
- return ret;
-
- ret = led_classdev_register(&pdev->dev, &rdc3211_dmz_led);
- if (ret < 0)
- led_classdev_unregister(&rdc3211_power_led);
-
- return ret;
+ return led_classdev_register(&pdev->dev, &rdc321x_dmz_led);
}
-static int rdc3211_leds_remove(struct platform_device *pdev)
+static int rdc321x_leds_remove(struct platform_device *pdev)
{
- led_classdev_unregister(&rdc3211_power_led);
- led_classdev_unregister(&rdc3211_dmz_led);
+ led_classdev_unregister(&rdc321x_dmz_led);
return 0;
}
-static struct platform_driver rdc3211_leds_driver = {
- .probe = rdc3211_leds_probe,
- .remove = rdc3211_leds_remove,
+static struct platform_driver rdc321x_leds_driver = {
+ .probe = rdc321x_leds_probe,
+ .remove = rdc321x_leds_remove,
.driver = {
- .name = "rdc3211-leds",
+ .name = "rdc321x-leds",
+ .owner = THIS_MODULE,
}
};
-static int __init rdc3211_leds_init(void)
+static int __init rdc321x_leds_init(void)
{
int ret;
- ret = platform_driver_register(&rdc3211_leds_driver);
- if (ret < 0)
- goto out;
-
- pdev = platform_device_register_simple("rdc3211-leds", -1, NULL, 0);
- if (IS_ERR(pdev)) {
- ret = PTR_ERR(pdev);
- platform_driver_unregister(&rdc3211_leds_driver);
- goto out;
- }
+ ret = platform_driver_register(&rdc321x_leds_driver);
-out:
return ret;
}
-static void __exit rdc3211_leds_exit(void)
+static void __exit rdc321x_leds_exit(void)
{
- platform_driver_unregister(&rdc3211_leds_driver);
+ platform_driver_unregister(&rdc321x_leds_driver);
}
-module_init(rdc3211_leds_init);
-module_exit(rdc3211_leds_exit);
+module_init(rdc321x_leds_init);
+module_exit(rdc321x_leds_exit);
MODULE_AUTHOR("Florian Fainelli <florian@openwrt.org>");
-MODULE_DESCRIPTION("RDC3211 LED driver");
+MODULE_DESCRIPTION("RDC321x LED driver");
MODULE_LICENSE("GPL");
diff --git a/target/linux/rdc-2.6/files/include/asm-i386/gpio.h b/target/linux/rdc-2.6/files/include/asm-i386/gpio.h
new file mode 100644
index 0000000000..ff87fca0ca
--- /dev/null
+++ b/target/linux/rdc-2.6/files/include/asm-i386/gpio.h
@@ -0,0 +1,6 @@
+#ifndef _ASM_I386_GPIO_H
+#define _ASM_I386_GPIO_H
+
+#include <gpio.h>
+
+#endif /* _ASM_I386_GPIO_H */
diff --git a/target/linux/rdc-2.6/files/include/asm-i386/mach-generic/gpio.h b/target/linux/rdc-2.6/files/include/asm-i386/mach-generic/gpio.h
new file mode 100644
index 0000000000..5305dcb96d
--- /dev/null
+++ b/target/linux/rdc-2.6/files/include/asm-i386/mach-generic/gpio.h
@@ -0,0 +1,15 @@
+#ifndef __ASM_MACH_GENERIC_GPIO_H
+#define __ASM_MACH_GENERIC_GPIO_H
+
+int gpio_request(unsigned gpio, const char *label);
+void gpio_free(unsigned gpio);
+int gpio_direction_input(unsigned gpio);
+int gpio_direction_output(unsigned gpio, int value);
+int gpio_get_value(unsigned gpio);
+void gpio_set_value(unsigned gpio, int value);
+int gpio_to_irq(unsigned gpio);
+int irq_to_gpio(unsigned irq);
+
+#include <asm-generic/gpio.h> /* cansleep wrappers */
+
+#endif /* __ASM_MACH_GENERIC_GPIO_H */
diff --git a/target/linux/rdc-2.6/files/include/asm-i386/mach-rdc/gpio.h b/target/linux/rdc-2.6/files/include/asm-i386/mach-rdc/gpio.h
new file mode 100644
index 0000000000..2368bd7583
--- /dev/null
+++ b/target/linux/rdc-2.6/files/include/asm-i386/mach-rdc/gpio.h
@@ -0,0 +1,56 @@
+#ifndef _RDC_GPIO_H
+#define _RDC_GPIO_H
+
+extern int rdc_gpio_get_value(unsigned gpio);
+extern void rdc_gpio_set_value(unsigned gpio, int value);
+extern int rdc_gpio_direction_input(unsigned gpio);
+extern int rdc_gpio_direction_output(unsigned gpio, int value);
+
+
+/* Wrappers for the arch-neutral GPIO API */
+
+static inline int gpio_request(unsigned gpio, const char *label)
+{
+ /* Not yet implemented */
+ return 0;
+}
+
+static inline void gpio_free(unsigned gpio)
+{
+ /* Not yet implemented */
+}
+
+static inline int gpio_direction_input(unsigned gpio)
+{
+ return rdc_gpio_direction_input(gpio);
+}
+
+static inline int gpio_direction_output(unsigned gpio, int value)
+{
+ return rdc_gpio_direction_output(gpio, value);
+}
+
+static inline int gpio_get_value(unsigned gpio)
+{
+ return rdc_gpio_get_value(gpio);
+}
+
+static inline void gpio_set_value(unsigned gpio, int value)
+{
+ rdc_gpio_set_value(gpio, value);
+}
+
+static inline int gpio_to_irq(unsigned gpio)
+{
+ return gpio;
+}
+
+static inline int irq_to_gpio(unsigned irq)
+{
+ return irq;
+}
+
+/* For cansleep */
+#include <asm-generic/gpio.h>
+
+#endif /* _RDC_GPIO_H_ */
diff --git a/target/linux/rdc-2.6/files/include/asm-i386/mach-rdc/rdc321x_defs.h b/target/linux/rdc-2.6/files/include/asm-i386/mach-rdc/rdc321x_defs.h
new file mode 100644
index 0000000000..c8e6355bce
--- /dev/null
+++ b/target/linux/rdc-2.6/files/include/asm-i386/mach-rdc/rdc321x_defs.h
@@ -0,0 +1 @@
+#define RDC_FLASH_BASE 0xffc00000