Path: blob/master/drivers/mfd/rdc321x-southbridge.c
15109 views
/*1* RDC321x MFD southbrige driver2*3* Copyright (C) 2007-2010 Florian Fainelli <[email protected]>4* Copyright (C) 2010 Bernhard Loos <[email protected]>5*6* This program is free software; you can redistribute it and/or modify7* it under the terms of the GNU General Public License as published by8* the Free Software Foundation; either version 2 of the License, or9* (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 of13* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the14* GNU General Public License for more details.15*16* You should have received a copy of the GNU General Public License17* along with this program; if not, write to the Free Software18* 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#include <linux/mfd/core.h>27#include <linux/mfd/rdc321x.h>2829static struct rdc321x_wdt_pdata rdc321x_wdt_pdata;3031static struct resource rdc321x_wdt_resource[] = {32{33.name = "wdt-reg",34.start = RDC321X_WDT_CTRL,35.end = RDC321X_WDT_CTRL + 0x3,36.flags = IORESOURCE_IO,37}38};3940static struct rdc321x_gpio_pdata rdc321x_gpio_pdata = {41.max_gpios = RDC321X_MAX_GPIO,42};4344static struct resource rdc321x_gpio_resources[] = {45{46.name = "gpio-reg1",47.start = RDC321X_GPIO_CTRL_REG1,48.end = RDC321X_GPIO_CTRL_REG1 + 0x7,49.flags = IORESOURCE_IO,50}, {51.name = "gpio-reg2",52.start = RDC321X_GPIO_CTRL_REG2,53.end = RDC321X_GPIO_CTRL_REG2 + 0x7,54.flags = IORESOURCE_IO,55}56};5758static struct mfd_cell rdc321x_sb_cells[] = {59{60.name = "rdc321x-wdt",61.resources = rdc321x_wdt_resource,62.num_resources = ARRAY_SIZE(rdc321x_wdt_resource),63.platform_data = &rdc321x_wdt_pdata,64.pdata_size = sizeof(rdc321x_wdt_pdata),65}, {66.name = "rdc321x-gpio",67.resources = rdc321x_gpio_resources,68.num_resources = ARRAY_SIZE(rdc321x_gpio_resources),69.platform_data = &rdc321x_gpio_pdata,70.pdata_size = sizeof(rdc321x_gpio_pdata),71},72};7374static int __devinit rdc321x_sb_probe(struct pci_dev *pdev,75const struct pci_device_id *ent)76{77int err;7879err = pci_enable_device(pdev);80if (err) {81dev_err(&pdev->dev, "failed to enable device\n");82return err;83}8485rdc321x_gpio_pdata.sb_pdev = pdev;86rdc321x_wdt_pdata.sb_pdev = pdev;8788return mfd_add_devices(&pdev->dev, -1,89rdc321x_sb_cells, ARRAY_SIZE(rdc321x_sb_cells), NULL, 0);90}9192static void __devexit rdc321x_sb_remove(struct pci_dev *pdev)93{94mfd_remove_devices(&pdev->dev);95}9697static DEFINE_PCI_DEVICE_TABLE(rdc321x_sb_table) = {98{ PCI_DEVICE(PCI_VENDOR_ID_RDC, PCI_DEVICE_ID_RDC_R6030) },99{}100};101MODULE_DEVICE_TABLE(pci, rdc321x_sb_table);102103static struct pci_driver rdc321x_sb_driver = {104.name = "RDC321x Southbridge",105.id_table = rdc321x_sb_table,106.probe = rdc321x_sb_probe,107.remove = __devexit_p(rdc321x_sb_remove),108};109110static int __init rdc321x_sb_init(void)111{112return pci_register_driver(&rdc321x_sb_driver);113}114115static void __exit rdc321x_sb_exit(void)116{117pci_unregister_driver(&rdc321x_sb_driver);118}119120module_init(rdc321x_sb_init);121module_exit(rdc321x_sb_exit);122123MODULE_AUTHOR("Florian Fainelli <[email protected]>");124MODULE_LICENSE("GPL");125MODULE_DESCRIPTION("RDC R-321x MFD southbridge driver");126127128