Thomas Gleixner | 74ba920 | 2019-05-20 09:19:02 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Florian Fainelli | e090d50 | 2010-03-21 01:06:05 +0100 | [diff] [blame] | 2 | /* |
Masanari Iida | 5a4432b | 2012-08-13 21:00:25 +0900 | [diff] [blame] | 3 | * RDC321x MFD southbridge driver |
Florian Fainelli | e090d50 | 2010-03-21 01:06:05 +0100 | [diff] [blame] | 4 | * |
| 5 | * Copyright (C) 2007-2010 Florian Fainelli <florian@openwrt.org> |
| 6 | * Copyright (C) 2010 Bernhard Loos <bernhardloos@googlemail.com> |
Florian Fainelli | e090d50 | 2010-03-21 01:06:05 +0100 | [diff] [blame] | 7 | */ |
Florian Fainelli | e090d50 | 2010-03-21 01:06:05 +0100 | [diff] [blame] | 8 | #include <linux/module.h> |
| 9 | #include <linux/kernel.h> |
| 10 | #include <linux/platform_device.h> |
| 11 | #include <linux/pci.h> |
| 12 | #include <linux/mfd/core.h> |
| 13 | #include <linux/mfd/rdc321x.h> |
| 14 | |
| 15 | static struct rdc321x_wdt_pdata rdc321x_wdt_pdata; |
| 16 | |
| 17 | static struct resource rdc321x_wdt_resource[] = { |
| 18 | { |
| 19 | .name = "wdt-reg", |
| 20 | .start = RDC321X_WDT_CTRL, |
| 21 | .end = RDC321X_WDT_CTRL + 0x3, |
Florian Fainelli | 8deca39e | 2010-05-15 22:58:27 +0200 | [diff] [blame] | 22 | .flags = IORESOURCE_IO, |
Florian Fainelli | e090d50 | 2010-03-21 01:06:05 +0100 | [diff] [blame] | 23 | } |
| 24 | }; |
| 25 | |
| 26 | static struct rdc321x_gpio_pdata rdc321x_gpio_pdata = { |
Axel Lin | 1ec93b9 | 2014-04-25 09:24:21 +0800 | [diff] [blame] | 27 | .max_gpios = RDC321X_NUM_GPIO, |
Florian Fainelli | e090d50 | 2010-03-21 01:06:05 +0100 | [diff] [blame] | 28 | }; |
| 29 | |
| 30 | static struct resource rdc321x_gpio_resources[] = { |
| 31 | { |
| 32 | .name = "gpio-reg1", |
| 33 | .start = RDC321X_GPIO_CTRL_REG1, |
| 34 | .end = RDC321X_GPIO_CTRL_REG1 + 0x7, |
Florian Fainelli | 8deca39e | 2010-05-15 22:58:27 +0200 | [diff] [blame] | 35 | .flags = IORESOURCE_IO, |
Florian Fainelli | e090d50 | 2010-03-21 01:06:05 +0100 | [diff] [blame] | 36 | }, { |
| 37 | .name = "gpio-reg2", |
| 38 | .start = RDC321X_GPIO_CTRL_REG2, |
| 39 | .end = RDC321X_GPIO_CTRL_REG2 + 0x7, |
Florian Fainelli | 8deca39e | 2010-05-15 22:58:27 +0200 | [diff] [blame] | 40 | .flags = IORESOURCE_IO, |
Florian Fainelli | e090d50 | 2010-03-21 01:06:05 +0100 | [diff] [blame] | 41 | } |
| 42 | }; |
| 43 | |
Geert Uytterhoeven | 5ac9855 | 2013-11-18 14:33:06 +0100 | [diff] [blame] | 44 | static const struct mfd_cell rdc321x_sb_cells[] = { |
Florian Fainelli | e090d50 | 2010-03-21 01:06:05 +0100 | [diff] [blame] | 45 | { |
| 46 | .name = "rdc321x-wdt", |
| 47 | .resources = rdc321x_wdt_resource, |
| 48 | .num_resources = ARRAY_SIZE(rdc321x_wdt_resource), |
Samuel Ortiz | 9abd768 | 2011-04-06 13:21:01 +0200 | [diff] [blame] | 49 | .platform_data = &rdc321x_wdt_pdata, |
| 50 | .pdata_size = sizeof(rdc321x_wdt_pdata), |
Florian Fainelli | e090d50 | 2010-03-21 01:06:05 +0100 | [diff] [blame] | 51 | }, { |
| 52 | .name = "rdc321x-gpio", |
| 53 | .resources = rdc321x_gpio_resources, |
| 54 | .num_resources = ARRAY_SIZE(rdc321x_gpio_resources), |
Samuel Ortiz | 9abd768 | 2011-04-06 13:21:01 +0200 | [diff] [blame] | 55 | .platform_data = &rdc321x_gpio_pdata, |
| 56 | .pdata_size = sizeof(rdc321x_gpio_pdata), |
Florian Fainelli | e090d50 | 2010-03-21 01:06:05 +0100 | [diff] [blame] | 57 | }, |
| 58 | }; |
| 59 | |
Bill Pemberton | f791be4 | 2012-11-19 13:23:04 -0500 | [diff] [blame] | 60 | static int rdc321x_sb_probe(struct pci_dev *pdev, |
Florian Fainelli | e090d50 | 2010-03-21 01:06:05 +0100 | [diff] [blame] | 61 | const struct pci_device_id *ent) |
| 62 | { |
| 63 | int err; |
| 64 | |
| 65 | err = pci_enable_device(pdev); |
| 66 | if (err) { |
| 67 | dev_err(&pdev->dev, "failed to enable device\n"); |
| 68 | return err; |
| 69 | } |
| 70 | |
| 71 | rdc321x_gpio_pdata.sb_pdev = pdev; |
| 72 | rdc321x_wdt_pdata.sb_pdev = pdev; |
| 73 | |
Laxman Dewangan | 7360544 | 2016-04-08 00:13:05 +0530 | [diff] [blame] | 74 | return devm_mfd_add_devices(&pdev->dev, -1, |
| 75 | rdc321x_sb_cells, |
| 76 | ARRAY_SIZE(rdc321x_sb_cells), |
| 77 | NULL, 0, NULL); |
Florian Fainelli | e090d50 | 2010-03-21 01:06:05 +0100 | [diff] [blame] | 78 | } |
| 79 | |
Jingoo Han | 36fcd06 | 2013-12-03 08:15:39 +0900 | [diff] [blame] | 80 | static const struct pci_device_id rdc321x_sb_table[] = { |
Florian Fainelli | e090d50 | 2010-03-21 01:06:05 +0100 | [diff] [blame] | 81 | { PCI_DEVICE(PCI_VENDOR_ID_RDC, PCI_DEVICE_ID_RDC_R6030) }, |
| 82 | {} |
| 83 | }; |
Axel Lin | 8537548 | 2011-03-24 15:04:53 +0800 | [diff] [blame] | 84 | MODULE_DEVICE_TABLE(pci, rdc321x_sb_table); |
Florian Fainelli | e090d50 | 2010-03-21 01:06:05 +0100 | [diff] [blame] | 85 | |
| 86 | static struct pci_driver rdc321x_sb_driver = { |
| 87 | .name = "RDC321x Southbridge", |
| 88 | .id_table = rdc321x_sb_table, |
| 89 | .probe = rdc321x_sb_probe, |
Florian Fainelli | e090d50 | 2010-03-21 01:06:05 +0100 | [diff] [blame] | 90 | }; |
| 91 | |
Axel Lin | 38a36f5 | 2012-04-03 09:09:19 +0800 | [diff] [blame] | 92 | module_pci_driver(rdc321x_sb_driver); |
Florian Fainelli | e090d50 | 2010-03-21 01:06:05 +0100 | [diff] [blame] | 93 | |
| 94 | MODULE_AUTHOR("Florian Fainelli <florian@openwrt.org>"); |
| 95 | MODULE_LICENSE("GPL"); |
| 96 | MODULE_DESCRIPTION("RDC R-321x MFD southbridge driver"); |