Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  * RDC321x MFD southbridge driver
0004  *
0005  * Copyright (C) 2007-2010 Florian Fainelli <florian@openwrt.org>
0006  * Copyright (C) 2010 Bernhard Loos <bernhardloos@googlemail.com>
0007  */
0008 #include <linux/module.h>
0009 #include <linux/kernel.h>
0010 #include <linux/platform_device.h>
0011 #include <linux/pci.h>
0012 #include <linux/mfd/core.h>
0013 #include <linux/mfd/rdc321x.h>
0014 
0015 static struct rdc321x_wdt_pdata rdc321x_wdt_pdata;
0016 
0017 static const struct resource rdc321x_wdt_resource[] = {
0018     {
0019         .name   = "wdt-reg",
0020         .start  = RDC321X_WDT_CTRL,
0021         .end    = RDC321X_WDT_CTRL + 0x3,
0022         .flags  = IORESOURCE_IO,
0023     }
0024 };
0025 
0026 static struct rdc321x_gpio_pdata rdc321x_gpio_pdata = {
0027     .max_gpios  = RDC321X_NUM_GPIO,
0028 };
0029 
0030 static const struct resource rdc321x_gpio_resources[] = {
0031     {
0032         .name   = "gpio-reg1",
0033         .start  = RDC321X_GPIO_CTRL_REG1,
0034         .end    = RDC321X_GPIO_CTRL_REG1 + 0x7,
0035         .flags  = IORESOURCE_IO,
0036     }, {
0037         .name   = "gpio-reg2",
0038         .start  = RDC321X_GPIO_CTRL_REG2,
0039         .end    = RDC321X_GPIO_CTRL_REG2 + 0x7,
0040         .flags  = IORESOURCE_IO,
0041     }
0042 };
0043 
0044 static const struct mfd_cell rdc321x_sb_cells[] = {
0045     {
0046         .name       = "rdc321x-wdt",
0047         .resources  = rdc321x_wdt_resource,
0048         .num_resources  = ARRAY_SIZE(rdc321x_wdt_resource),
0049         .platform_data  = &rdc321x_wdt_pdata,
0050         .pdata_size = sizeof(rdc321x_wdt_pdata),
0051     }, {
0052         .name       = "rdc321x-gpio",
0053         .resources  = rdc321x_gpio_resources,
0054         .num_resources  = ARRAY_SIZE(rdc321x_gpio_resources),
0055         .platform_data  = &rdc321x_gpio_pdata,
0056         .pdata_size = sizeof(rdc321x_gpio_pdata),
0057     },
0058 };
0059 
0060 static int rdc321x_sb_probe(struct pci_dev *pdev,
0061                     const struct pci_device_id *ent)
0062 {
0063     int err;
0064 
0065     err = pci_enable_device(pdev);
0066     if (err) {
0067         dev_err(&pdev->dev, "failed to enable device\n");
0068         return err;
0069     }
0070 
0071     rdc321x_gpio_pdata.sb_pdev = pdev;
0072     rdc321x_wdt_pdata.sb_pdev = pdev;
0073 
0074     return devm_mfd_add_devices(&pdev->dev, -1,
0075                     rdc321x_sb_cells,
0076                     ARRAY_SIZE(rdc321x_sb_cells),
0077                     NULL, 0, NULL);
0078 }
0079 
0080 static const struct pci_device_id rdc321x_sb_table[] = {
0081     { PCI_DEVICE(PCI_VENDOR_ID_RDC, PCI_DEVICE_ID_RDC_R6030) },
0082     {}
0083 };
0084 MODULE_DEVICE_TABLE(pci, rdc321x_sb_table);
0085 
0086 static struct pci_driver rdc321x_sb_driver = {
0087     .name       = "RDC321x Southbridge",
0088     .id_table   = rdc321x_sb_table,
0089     .probe      = rdc321x_sb_probe,
0090 };
0091 
0092 module_pci_driver(rdc321x_sb_driver);
0093 
0094 MODULE_AUTHOR("Florian Fainelli <florian@openwrt.org>");
0095 MODULE_LICENSE("GPL");
0096 MODULE_DESCRIPTION("RDC R-321x MFD southbridge driver");