blob: 10dbe6374a89328b00da7014e4eccfa886906f2f [file] [log] [blame]
Florian Fainellie090d502010-03-21 01:06:05 +01001/*
2 * RDC321x MFD southbrige driver
3 *
4 * Copyright (C) 2007-2010 Florian Fainelli <florian@openwrt.org>
5 * Copyright (C) 2010 Bernhard Loos <bernhardloos@googlemail.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 *
21 */
22#include <linux/init.h>
23#include <linux/module.h>
24#include <linux/kernel.h>
25#include <linux/platform_device.h>
26#include <linux/pci.h>
27#include <linux/mfd/core.h>
28#include <linux/mfd/rdc321x.h>
29
30static struct rdc321x_wdt_pdata rdc321x_wdt_pdata;
31
32static struct resource rdc321x_wdt_resource[] = {
33 {
34 .name = "wdt-reg",
35 .start = RDC321X_WDT_CTRL,
36 .end = RDC321X_WDT_CTRL + 0x3,
Florian Fainelli8deca39e2010-05-15 22:58:27 +020037 .flags = IORESOURCE_IO,
Florian Fainellie090d502010-03-21 01:06:05 +010038 }
39};
40
41static struct rdc321x_gpio_pdata rdc321x_gpio_pdata = {
42 .max_gpios = RDC321X_MAX_GPIO,
43};
44
45static struct resource rdc321x_gpio_resources[] = {
46 {
47 .name = "gpio-reg1",
48 .start = RDC321X_GPIO_CTRL_REG1,
49 .end = RDC321X_GPIO_CTRL_REG1 + 0x7,
Florian Fainelli8deca39e2010-05-15 22:58:27 +020050 .flags = IORESOURCE_IO,
Florian Fainellie090d502010-03-21 01:06:05 +010051 }, {
52 .name = "gpio-reg2",
53 .start = RDC321X_GPIO_CTRL_REG2,
54 .end = RDC321X_GPIO_CTRL_REG2 + 0x7,
Florian Fainelli8deca39e2010-05-15 22:58:27 +020055 .flags = IORESOURCE_IO,
Florian Fainellie090d502010-03-21 01:06:05 +010056 }
57};
58
59static struct mfd_cell rdc321x_sb_cells[] = {
60 {
61 .name = "rdc321x-wdt",
62 .resources = rdc321x_wdt_resource,
63 .num_resources = ARRAY_SIZE(rdc321x_wdt_resource),
Andres Salomon46673ed2011-02-17 19:07:32 -080064 .mfd_data = &rdc321x_wdt_pdata,
Florian Fainellie090d502010-03-21 01:06:05 +010065 }, {
66 .name = "rdc321x-gpio",
67 .resources = rdc321x_gpio_resources,
68 .num_resources = ARRAY_SIZE(rdc321x_gpio_resources),
Andres Salomon46673ed2011-02-17 19:07:32 -080069 .mfd_data = &rdc321x_gpio_pdata,
Florian Fainellie090d502010-03-21 01:06:05 +010070 },
71};
72
73static int __devinit rdc321x_sb_probe(struct pci_dev *pdev,
74 const struct pci_device_id *ent)
75{
76 int err;
77
78 err = pci_enable_device(pdev);
79 if (err) {
80 dev_err(&pdev->dev, "failed to enable device\n");
81 return err;
82 }
83
84 rdc321x_gpio_pdata.sb_pdev = pdev;
85 rdc321x_wdt_pdata.sb_pdev = pdev;
86
87 return mfd_add_devices(&pdev->dev, -1,
88 rdc321x_sb_cells, ARRAY_SIZE(rdc321x_sb_cells), NULL, 0);
89}
90
91static void __devexit rdc321x_sb_remove(struct pci_dev *pdev)
92{
93 mfd_remove_devices(&pdev->dev);
94}
95
96static DEFINE_PCI_DEVICE_TABLE(rdc321x_sb_table) = {
97 { PCI_DEVICE(PCI_VENDOR_ID_RDC, PCI_DEVICE_ID_RDC_R6030) },
98 {}
99};
Axel Lin85375482011-03-24 15:04:53 +0800100MODULE_DEVICE_TABLE(pci, rdc321x_sb_table);
Florian Fainellie090d502010-03-21 01:06:05 +0100101
102static struct pci_driver rdc321x_sb_driver = {
103 .name = "RDC321x Southbridge",
104 .id_table = rdc321x_sb_table,
105 .probe = rdc321x_sb_probe,
106 .remove = __devexit_p(rdc321x_sb_remove),
107};
108
109static int __init rdc321x_sb_init(void)
110{
111 return pci_register_driver(&rdc321x_sb_driver);
112}
113
114static void __exit rdc321x_sb_exit(void)
115{
116 pci_unregister_driver(&rdc321x_sb_driver);
117}
118
119module_init(rdc321x_sb_init);
120module_exit(rdc321x_sb_exit);
121
122MODULE_AUTHOR("Florian Fainelli <florian@openwrt.org>");
123MODULE_LICENSE("GPL");
124MODULE_DESCRIPTION("RDC R-321x MFD southbridge driver");