Root/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
29static struct pci_dev *rdc321x_sb_pdev;
30
31/*
32 * Unlocked PCI configuration space accessors
33 */
34int 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}
44EXPORT_SYMBOL(rdc321x_pci_read);
45
46int 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}
56EXPORT_SYMBOL(rdc321x_pci_write);
57
58static struct platform_device rdc321x_wdt_device = {
59    .name = "rdc321x-wdt"
60};
61
62static struct platform_device rdc321x_gpio_device = {
63    .name = "rdc321x-gpio"
64};
65
66static 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    panic_on_unrecovered_nmi = 1;
85
86    err = platform_device_register(&rdc321x_gpio_device);
87    if (err) {
88        dev_err(&pdev->dev, "failed to register gpiochip\n");
89        return err;
90    }
91    dev_info(&rdc321x_sb_pdev->dev, "RDC321x southhridge registered\n");
92
93    return err;
94}
95
96static struct pci_device_id rdc321x_sb_table[] = {
97    { PCI_DEVICE(PCI_VENDOR_ID_RDC, PCI_DEVICE_ID_RDC_R6030) },
98    {}
99};
100
101static struct pci_driver rdc321x_sb_driver = {
102    .name = "RDC3210 Southbridge",
103    .id_table = rdc321x_sb_table,
104    .probe = rdc321x_sb_probe
105};
106
107static int __init rdc321x_sb_init(void)
108{
109    return pci_register_driver(&rdc321x_sb_driver);
110}
111
112device_initcall(rdc321x_sb_init);
113

Archive Download this file



interactive