Florian Fainelli | e090d50 | 2010-03-21 01:06:05 +0100 | [diff] [blame] | 1 | /* |
Masanari Iida | 5a4432b | 2012-08-13 21:00:25 +0900 | [diff] [blame] | 2 | * RDC321x MFD southbridge driver |
Florian Fainelli | e090d50 | 2010-03-21 01:06:05 +0100 | [diff] [blame] | 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 | |
| 30 | static struct rdc321x_wdt_pdata rdc321x_wdt_pdata; |
| 31 | |
| 32 | static struct resource rdc321x_wdt_resource[] = { |
| 33 | { |
| 34 | .name = "wdt-reg", |
| 35 | .start = RDC321X_WDT_CTRL, |
| 36 | .end = RDC321X_WDT_CTRL + 0x3, |
Florian Fainelli | 8deca39e | 2010-05-15 22:58:27 +0200 | [diff] [blame] | 37 | .flags = IORESOURCE_IO, |
Florian Fainelli | e090d50 | 2010-03-21 01:06:05 +0100 | [diff] [blame] | 38 | } |
| 39 | }; |
| 40 | |
| 41 | static struct rdc321x_gpio_pdata rdc321x_gpio_pdata = { |
| 42 | .max_gpios = RDC321X_MAX_GPIO, |
| 43 | }; |
| 44 | |
| 45 | static struct resource rdc321x_gpio_resources[] = { |
| 46 | { |
| 47 | .name = "gpio-reg1", |
| 48 | .start = RDC321X_GPIO_CTRL_REG1, |
| 49 | .end = RDC321X_GPIO_CTRL_REG1 + 0x7, |
Florian Fainelli | 8deca39e | 2010-05-15 22:58:27 +0200 | [diff] [blame] | 50 | .flags = IORESOURCE_IO, |
Florian Fainelli | e090d50 | 2010-03-21 01:06:05 +0100 | [diff] [blame] | 51 | }, { |
| 52 | .name = "gpio-reg2", |
| 53 | .start = RDC321X_GPIO_CTRL_REG2, |
| 54 | .end = RDC321X_GPIO_CTRL_REG2 + 0x7, |
Florian Fainelli | 8deca39e | 2010-05-15 22:58:27 +0200 | [diff] [blame] | 55 | .flags = IORESOURCE_IO, |
Florian Fainelli | e090d50 | 2010-03-21 01:06:05 +0100 | [diff] [blame] | 56 | } |
| 57 | }; |
| 58 | |
| 59 | static struct mfd_cell rdc321x_sb_cells[] = { |
| 60 | { |
| 61 | .name = "rdc321x-wdt", |
| 62 | .resources = rdc321x_wdt_resource, |
| 63 | .num_resources = ARRAY_SIZE(rdc321x_wdt_resource), |
Samuel Ortiz | 9abd768 | 2011-04-06 13:21:01 +0200 | [diff] [blame] | 64 | .platform_data = &rdc321x_wdt_pdata, |
| 65 | .pdata_size = sizeof(rdc321x_wdt_pdata), |
Florian Fainelli | e090d50 | 2010-03-21 01:06:05 +0100 | [diff] [blame] | 66 | }, { |
| 67 | .name = "rdc321x-gpio", |
| 68 | .resources = rdc321x_gpio_resources, |
| 69 | .num_resources = ARRAY_SIZE(rdc321x_gpio_resources), |
Samuel Ortiz | 9abd768 | 2011-04-06 13:21:01 +0200 | [diff] [blame] | 70 | .platform_data = &rdc321x_gpio_pdata, |
| 71 | .pdata_size = sizeof(rdc321x_gpio_pdata), |
Florian Fainelli | e090d50 | 2010-03-21 01:06:05 +0100 | [diff] [blame] | 72 | }, |
| 73 | }; |
| 74 | |
Bill Pemberton | f791be4 | 2012-11-19 13:23:04 -0500 | [diff] [blame^] | 75 | static int rdc321x_sb_probe(struct pci_dev *pdev, |
Florian Fainelli | e090d50 | 2010-03-21 01:06:05 +0100 | [diff] [blame] | 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, |
Mark Brown | 0848c94 | 2012-09-11 15:16:36 +0800 | [diff] [blame] | 90 | rdc321x_sb_cells, ARRAY_SIZE(rdc321x_sb_cells), |
| 91 | NULL, 0, NULL); |
Florian Fainelli | e090d50 | 2010-03-21 01:06:05 +0100 | [diff] [blame] | 92 | } |
| 93 | |
| 94 | static void __devexit rdc321x_sb_remove(struct pci_dev *pdev) |
| 95 | { |
| 96 | mfd_remove_devices(&pdev->dev); |
| 97 | } |
| 98 | |
| 99 | static DEFINE_PCI_DEVICE_TABLE(rdc321x_sb_table) = { |
| 100 | { PCI_DEVICE(PCI_VENDOR_ID_RDC, PCI_DEVICE_ID_RDC_R6030) }, |
| 101 | {} |
| 102 | }; |
Axel Lin | 8537548 | 2011-03-24 15:04:53 +0800 | [diff] [blame] | 103 | MODULE_DEVICE_TABLE(pci, rdc321x_sb_table); |
Florian Fainelli | e090d50 | 2010-03-21 01:06:05 +0100 | [diff] [blame] | 104 | |
| 105 | static struct pci_driver rdc321x_sb_driver = { |
| 106 | .name = "RDC321x Southbridge", |
| 107 | .id_table = rdc321x_sb_table, |
| 108 | .probe = rdc321x_sb_probe, |
Bill Pemberton | 8444921 | 2012-11-19 13:20:24 -0500 | [diff] [blame] | 109 | .remove = rdc321x_sb_remove, |
Florian Fainelli | e090d50 | 2010-03-21 01:06:05 +0100 | [diff] [blame] | 110 | }; |
| 111 | |
Axel Lin | 38a36f5 | 2012-04-03 09:09:19 +0800 | [diff] [blame] | 112 | module_pci_driver(rdc321x_sb_driver); |
Florian Fainelli | e090d50 | 2010-03-21 01:06:05 +0100 | [diff] [blame] | 113 | |
| 114 | MODULE_AUTHOR("Florian Fainelli <florian@openwrt.org>"); |
| 115 | MODULE_LICENSE("GPL"); |
| 116 | MODULE_DESCRIPTION("RDC R-321x MFD southbridge driver"); |