[rdc] add a new southbridge driver which registers the gpio and watchdog platform...
[openwrt.git] / target / linux / rdc / files-2.6.30 / arch / x86 / mach-rdc321x / pci.c
1 /*
2 * RDC321x southbrige driver
3 *
4 * Copyright (C) 2007-2010 Florian Fainelli <florian@openwrt.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 */
21 #include <linux/init.h>
22 #include <linux/module.h>
23 #include <linux/kernel.h>
24 #include <linux/platform_device.h>
25 #include <linux/pci.h>
26
27 #include <asm/rdc321x_defs.h>
28
29 static struct pci_dev *rdc321x_sb_pdev;
30
31 /*
32 * Unlocked PCI configuration space accessors
33 */
34 int rdc321x_pci_read(int reg, u32 *val)
35 {
36 int err;
37
38 err = pci_read_config_dword(rdc321x_sb_pdev, reg, val);
39 if (err)
40 return err;
41
42 return err;
43 }
44 EXPORT_SYMBOL(rdc321x_pci_read);
45
46 int rdc321x_pci_write(int reg, u32 val)
47 {
48 int err;
49
50 err = pci_write_config_dword(rdc321x_sb_pdev, reg, val);
51 if (err)
52 return err;
53
54 return err;
55 }
56 EXPORT_SYMBOL(rdc321x_pci_write);
57
58 static struct platform_device rdc321x_wdt_device = {
59 .name = "rdc321x-wdt"
60 };
61
62 static struct platform_device rdc321x_gpio_device = {
63 .name = "rdc321x-gpio"
64 };
65
66 static int __devinit rdc321x_sb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
67 {
68 int err;
69
70 err = pci_enable_device(pdev);
71 if (err) {
72 printk(KERN_ERR "failed to enable device\n");
73 return err;
74 }
75
76 rdc321x_sb_pdev = pdev;
77
78 err = platform_device_register(&rdc321x_wdt_device);
79 if (err) {
80 dev_err(&pdev->dev, "failed to register watchdog\n");
81 return err;
82 }
83
84 err = platform_device_register(&rdc321x_gpio_device);
85 if (err) {
86 dev_err(&pdev->dev, "failed to register gpiochip\n");
87 return err;
88 }
89 dev_info(&rdc321x_sb_pdev->dev, "RDC321x southhridge registered\n");
90
91 return err;
92 }
93
94 static struct pci_device_id rdc321x_sb_table[] = {
95 { PCI_DEVICE(PCI_VENDOR_ID_RDC, PCI_DEVICE_ID_RDC_R6030) },
96 {}
97 };
98
99 static struct pci_driver rdc321x_sb_driver = {
100 .name = "RDC3210 Southbridge",
101 .id_table = rdc321x_sb_table,
102 .probe = rdc321x_sb_probe
103 };
104
105 static int __init rdc321x_sb_init(void)
106 {
107 return pci_register_driver(&rdc321x_sb_driver);
108 }
109
110 device_initcall(rdc321x_sb_init);
This page took 0.04499 seconds and 5 git commands to generate.