Fedora kernel-2.6.17-1.2142_FC4 patched with stable patch-2.6.17.4-vs2.0.2-rc26.diff
[linux-2.6.git] / drivers / char / tb0219.c
index 5413f29..a80c832 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  Driver for TANBAC TB0219 base board.
  *
- *  Copyright (C) 2005  Yoichi Yuasa <yuasa@hh.iij4u.or.jp>
+ *  Copyright (C) 2005  Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>
  *
  *  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
  *  along with this program; if not, write to the Free Software
  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
-#include <linux/device.h>
+#include <linux/platform_device.h>
 #include <linux/fs.h>
 #include <linux/init.h>
 #include <linux/module.h>
 
 #include <asm/io.h>
 #include <asm/reboot.h>
+#include <asm/vr41xx/giu.h>
+#include <asm/vr41xx/tb0219.h>
 
-MODULE_AUTHOR("Yoichi Yuasa <yuasa@hh.iij4u.or.jp>");
+MODULE_AUTHOR("Yoichi Yuasa <yoichi_yuasa@tripeaks.co.jp>");
 MODULE_DESCRIPTION("TANBAC TB0219 base board driver");
 MODULE_LICENSE("GPL");
 
@@ -266,7 +268,22 @@ static void tb0219_restart(char *command)
        tb0219_write(TB0219_RESET, 0);
 }
 
-static int tb0219_probe(struct device *dev)
+static void tb0219_pci_irq_init(void)
+{
+       /* PCI Slot 1 */
+       vr41xx_set_irq_trigger(TB0219_PCI_SLOT1_PIN, IRQ_TRIGGER_LEVEL, IRQ_SIGNAL_THROUGH);
+       vr41xx_set_irq_level(TB0219_PCI_SLOT1_PIN, IRQ_LEVEL_LOW);
+
+       /* PCI Slot 2 */
+       vr41xx_set_irq_trigger(TB0219_PCI_SLOT2_PIN, IRQ_TRIGGER_LEVEL, IRQ_SIGNAL_THROUGH);
+       vr41xx_set_irq_level(TB0219_PCI_SLOT2_PIN, IRQ_LEVEL_LOW);
+
+       /* PCI Slot 3 */
+       vr41xx_set_irq_trigger(TB0219_PCI_SLOT3_PIN, IRQ_TRIGGER_LEVEL, IRQ_SIGNAL_THROUGH);
+       vr41xx_set_irq_level(TB0219_PCI_SLOT3_PIN, IRQ_LEVEL_LOW);
+}
+
+static int __devinit tb0219_probe(struct platform_device *dev)
 {
        int retval;
 
@@ -292,6 +309,8 @@ static int tb0219_probe(struct device *dev)
        old_machine_restart = _machine_restart;
        _machine_restart = tb0219_restart;
 
+       tb0219_pci_irq_init();
+
        if (major == 0) {
                major = retval;
                printk(KERN_INFO "TB0219: major number %d\n", major);
@@ -300,7 +319,7 @@ static int tb0219_probe(struct device *dev)
        return 0;
 }
 
-static int tb0219_remove(struct device *dev)
+static int __devexit tb0219_remove(struct platform_device *dev)
 {
        _machine_restart = old_machine_restart;
 
@@ -314,32 +333,39 @@ static int tb0219_remove(struct device *dev)
 
 static struct platform_device *tb0219_platform_device;
 
-static struct device_driver tb0219_device_driver = {
-       .name           = "TB0219",
-       .bus            = &platform_bus_type,
+static struct platform_driver tb0219_device_driver = {
        .probe          = tb0219_probe,
-       .remove         = tb0219_remove,
+       .remove         = __devexit_p(tb0219_remove),
+       .driver         = {
+               .name   = "TB0219",
+               .owner  = THIS_MODULE,
+       },
 };
 
-static int __devinit tanbac_tb0219_init(void)
+static int __init tanbac_tb0219_init(void)
 {
        int retval;
 
-       tb0219_platform_device = platform_device_register_simple("TB0219", -1, NULL, 0);
-       if (IS_ERR(tb0219_platform_device))
-               return PTR_ERR(tb0219_platform_device);
+       tb0219_platform_device = platform_device_alloc("TB0219", -1);
+       if (!tb0219_platform_device)
+               return -ENOMEM;
+
+       retval = platform_device_add(tb0219_platform_device);
+       if (retval < 0) {
+               platform_device_put(tb0219_platform_device);
+               return retval;
+       }
 
-       retval = driver_register(&tb0219_device_driver);
+       retval = platform_driver_register(&tb0219_device_driver);
        if (retval < 0)
                platform_device_unregister(tb0219_platform_device);
 
        return retval;
 }
 
-static void __devexit tanbac_tb0219_exit(void)
+static void __exit tanbac_tb0219_exit(void)
 {
-       driver_unregister(&tb0219_device_driver);
-
+       platform_driver_unregister(&tb0219_device_driver);
        platform_device_unregister(tb0219_platform_device);
 }