1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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,
37 .flags = IORESOURCE_IO,
38 }
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,
50 .flags = IORESOURCE_IO,
51 }, {
52 .name = "gpio-reg2",
53 .start = RDC321X_GPIO_CTRL_REG2,
54 .end = RDC321X_GPIO_CTRL_REG2 + 0x7,
55 .flags = IORESOURCE_IO,
56 }
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),
64 .platform_data = &rdc321x_wdt_pdata,
65 .pdata_size = sizeof(rdc321x_wdt_pdata),
66 }, {
67 .name = "rdc321x-gpio",
68 .resources = rdc321x_gpio_resources,
69 .num_resources = ARRAY_SIZE(rdc321x_gpio_resources),
70 .platform_data = &rdc321x_gpio_pdata,
71 .pdata_size = sizeof(rdc321x_gpio_pdata),
72 },
73};
74
75static int rdc321x_sb_probe(struct pci_dev *pdev,
76 const struct pci_device_id *ent)
77{
78 int err;
79
80 err = pci_enable_device(pdev);
81 if (err) {
82 dev_err(&pdev->dev, "failed to enable device\n");
83 return err;
84 }
85
86 rdc321x_gpio_pdata.sb_pdev = pdev;
87 rdc321x_wdt_pdata.sb_pdev = pdev;
88
89 return mfd_add_devices(&pdev->dev, -1,
90 rdc321x_sb_cells, ARRAY_SIZE(rdc321x_sb_cells),
91 NULL, 0, NULL);
92}
93
94static void rdc321x_sb_remove(struct pci_dev *pdev)
95{
96 mfd_remove_devices(&pdev->dev);
97}
98
99static DEFINE_PCI_DEVICE_TABLE(rdc321x_sb_table) = {
100 { PCI_DEVICE(PCI_VENDOR_ID_RDC, PCI_DEVICE_ID_RDC_R6030) },
101 {}
102};
103MODULE_DEVICE_TABLE(pci, rdc321x_sb_table);
104
105static struct pci_driver rdc321x_sb_driver = {
106 .name = "RDC321x Southbridge",
107 .id_table = rdc321x_sb_table,
108 .probe = rdc321x_sb_probe,
109 .remove = rdc321x_sb_remove,
110};
111
112module_pci_driver(rdc321x_sb_driver);
113
114MODULE_AUTHOR("Florian Fainelli <florian@openwrt.org>");
115MODULE_LICENSE("GPL");
116MODULE_DESCRIPTION("RDC R-321x MFD southbridge driver");
117