blob: 2bd8c5b6d600a7824b8c9f437fb75b21f0f01b2e [file] [log] [blame]
Florian Fainellie090d502010-03-21 01:06:05 +01001/*
Masanari Iida5a4432b2012-08-13 21:00:25 +09002 * RDC321x MFD southbridge driver
Florian Fainellie090d502010-03-21 01:06:05 +01003 *
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 */
Florian Fainellie090d502010-03-21 01:06:05 +010022#include <linux/module.h>
23#include <linux/kernel.h>
24#include <linux/platform_device.h>
25#include <linux/pci.h>
26#include <linux/mfd/core.h>
27#include <linux/mfd/rdc321x.h>
28
29static struct rdc321x_wdt_pdata rdc321x_wdt_pdata;
30
31static struct resource rdc321x_wdt_resource[] = {
32 {
33 .name = "wdt-reg",
34 .start = RDC321X_WDT_CTRL,
35 .end = RDC321X_WDT_CTRL + 0x3,
Florian Fainelli8deca39e2010-05-15 22:58:27 +020036 .flags = IORESOURCE_IO,
Florian Fainellie090d502010-03-21 01:06:05 +010037 }
38};
39
40static struct rdc321x_gpio_pdata rdc321x_gpio_pdata = {
Axel Lin1ec93b92014-04-25 09:24:21 +080041 .max_gpios = RDC321X_NUM_GPIO,
Florian Fainellie090d502010-03-21 01:06:05 +010042};
43
44static struct resource rdc321x_gpio_resources[] = {
45 {
46 .name = "gpio-reg1",
47 .start = RDC321X_GPIO_CTRL_REG1,
48 .end = RDC321X_GPIO_CTRL_REG1 + 0x7,
Florian Fainelli8deca39e2010-05-15 22:58:27 +020049 .flags = IORESOURCE_IO,
Florian Fainellie090d502010-03-21 01:06:05 +010050 }, {
51 .name = "gpio-reg2",
52 .start = RDC321X_GPIO_CTRL_REG2,
53 .end = RDC321X_GPIO_CTRL_REG2 + 0x7,
Florian Fainelli8deca39e2010-05-15 22:58:27 +020054 .flags = IORESOURCE_IO,
Florian Fainellie090d502010-03-21 01:06:05 +010055 }
56};
57
Geert Uytterhoeven5ac98552013-11-18 14:33:06 +010058static const struct mfd_cell rdc321x_sb_cells[] = {
Florian Fainellie090d502010-03-21 01:06:05 +010059 {
60 .name = "rdc321x-wdt",
61 .resources = rdc321x_wdt_resource,
62 .num_resources = ARRAY_SIZE(rdc321x_wdt_resource),
Samuel Ortiz9abd7682011-04-06 13:21:01 +020063 .platform_data = &rdc321x_wdt_pdata,
64 .pdata_size = sizeof(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),
Samuel Ortiz9abd7682011-04-06 13:21:01 +020069 .platform_data = &rdc321x_gpio_pdata,
70 .pdata_size = sizeof(rdc321x_gpio_pdata),
Florian Fainellie090d502010-03-21 01:06:05 +010071 },
72};
73
Bill Pembertonf791be42012-11-19 13:23:04 -050074static int rdc321x_sb_probe(struct pci_dev *pdev,
Florian Fainellie090d502010-03-21 01:06:05 +010075 const struct pci_device_id *ent)
76{
77 int err;
78
79 err = pci_enable_device(pdev);
80 if (err) {
81 dev_err(&pdev->dev, "failed to enable device\n");
82 return err;
83 }
84
85 rdc321x_gpio_pdata.sb_pdev = pdev;
86 rdc321x_wdt_pdata.sb_pdev = pdev;
87
Laxman Dewangan73605442016-04-08 00:13:05 +053088 return devm_mfd_add_devices(&pdev->dev, -1,
89 rdc321x_sb_cells,
90 ARRAY_SIZE(rdc321x_sb_cells),
91 NULL, 0, NULL);
Florian Fainellie090d502010-03-21 01:06:05 +010092}
93
Jingoo Han36fcd062013-12-03 08:15:39 +090094static const struct pci_device_id rdc321x_sb_table[] = {
Florian Fainellie090d502010-03-21 01:06:05 +010095 { PCI_DEVICE(PCI_VENDOR_ID_RDC, PCI_DEVICE_ID_RDC_R6030) },
96 {}
97};
Axel Lin85375482011-03-24 15:04:53 +080098MODULE_DEVICE_TABLE(pci, rdc321x_sb_table);
Florian Fainellie090d502010-03-21 01:06:05 +010099
100static struct pci_driver rdc321x_sb_driver = {
101 .name = "RDC321x Southbridge",
102 .id_table = rdc321x_sb_table,
103 .probe = rdc321x_sb_probe,
Florian Fainellie090d502010-03-21 01:06:05 +0100104};
105
Axel Lin38a36f52012-04-03 09:09:19 +0800106module_pci_driver(rdc321x_sb_driver);
Florian Fainellie090d502010-03-21 01:06:05 +0100107
108MODULE_AUTHOR("Florian Fainelli <florian@openwrt.org>");
109MODULE_LICENSE("GPL");
110MODULE_DESCRIPTION("RDC R-321x MFD southbridge driver");