| 
									
										
										
										
											2010-03-21 01:06:05 +01:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2012-08-13 21:00:25 +09:00
										 |  |  |  * RDC321x MFD southbridge driver | 
					
						
							| 
									
										
										
										
											2010-03-21 01:06:05 +01:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Copyright (C) 2007-2010 Florian Fainelli <florian@openwrt.org> | 
					
						
							|  |  |  |  * Copyright (C) 2010 Bernhard Loos <bernhardloos@googlemail.com> | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is free software; you can redistribute it and/or modify | 
					
						
							|  |  |  |  * it under the terms of the GNU General Public License as published by | 
					
						
							|  |  |  |  * the Free Software Foundation; either version 2 of the License, or | 
					
						
							|  |  |  |  * (at your option) any later version. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |  * GNU General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU General Public License | 
					
						
							|  |  |  |  * along with this program; if not, write to the Free Software | 
					
						
							|  |  |  |  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | #include <linux/module.h>
 | 
					
						
							|  |  |  | #include <linux/kernel.h>
 | 
					
						
							|  |  |  | #include <linux/platform_device.h>
 | 
					
						
							|  |  |  | #include <linux/pci.h>
 | 
					
						
							|  |  |  | #include <linux/mfd/core.h>
 | 
					
						
							|  |  |  | #include <linux/mfd/rdc321x.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static struct rdc321x_wdt_pdata rdc321x_wdt_pdata; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static struct resource rdc321x_wdt_resource[] = { | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		.name	= "wdt-reg", | 
					
						
							|  |  |  | 		.start	= RDC321X_WDT_CTRL, | 
					
						
							|  |  |  | 		.end	= RDC321X_WDT_CTRL + 0x3, | 
					
						
							| 
									
										
										
										
											2010-05-15 22:58:27 +02:00
										 |  |  | 		.flags	= IORESOURCE_IO, | 
					
						
							| 
									
										
										
										
											2010-03-21 01:06:05 +01:00
										 |  |  | 	} | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static struct rdc321x_gpio_pdata rdc321x_gpio_pdata = { | 
					
						
							| 
									
										
										
										
											2014-04-25 09:24:21 +08:00
										 |  |  | 	.max_gpios	= RDC321X_NUM_GPIO, | 
					
						
							| 
									
										
										
										
											2010-03-21 01:06:05 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static struct resource rdc321x_gpio_resources[] = { | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		.name	= "gpio-reg1", | 
					
						
							|  |  |  | 		.start	= RDC321X_GPIO_CTRL_REG1, | 
					
						
							|  |  |  | 		.end	= RDC321X_GPIO_CTRL_REG1 + 0x7, | 
					
						
							| 
									
										
										
										
											2010-05-15 22:58:27 +02:00
										 |  |  | 		.flags	= IORESOURCE_IO, | 
					
						
							| 
									
										
										
										
											2010-03-21 01:06:05 +01:00
										 |  |  | 	}, { | 
					
						
							|  |  |  | 		.name	= "gpio-reg2", | 
					
						
							|  |  |  | 		.start	= RDC321X_GPIO_CTRL_REG2, | 
					
						
							|  |  |  | 		.end	= RDC321X_GPIO_CTRL_REG2 + 0x7, | 
					
						
							| 
									
										
										
										
											2010-05-15 22:58:27 +02:00
										 |  |  | 		.flags	= IORESOURCE_IO, | 
					
						
							| 
									
										
										
										
											2010-03-21 01:06:05 +01:00
										 |  |  | 	} | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-11-18 14:33:06 +01:00
										 |  |  | static const struct mfd_cell rdc321x_sb_cells[] = { | 
					
						
							| 
									
										
										
										
											2010-03-21 01:06:05 +01:00
										 |  |  | 	{ | 
					
						
							|  |  |  | 		.name		= "rdc321x-wdt", | 
					
						
							|  |  |  | 		.resources	= rdc321x_wdt_resource, | 
					
						
							|  |  |  | 		.num_resources	= ARRAY_SIZE(rdc321x_wdt_resource), | 
					
						
							| 
									
										
										
										
											2011-04-06 13:21:01 +02:00
										 |  |  | 		.platform_data	= &rdc321x_wdt_pdata, | 
					
						
							|  |  |  | 		.pdata_size	= sizeof(rdc321x_wdt_pdata), | 
					
						
							| 
									
										
										
										
											2010-03-21 01:06:05 +01:00
										 |  |  | 	}, { | 
					
						
							|  |  |  | 		.name		= "rdc321x-gpio", | 
					
						
							|  |  |  | 		.resources	= rdc321x_gpio_resources, | 
					
						
							|  |  |  | 		.num_resources	= ARRAY_SIZE(rdc321x_gpio_resources), | 
					
						
							| 
									
										
										
										
											2011-04-06 13:21:01 +02:00
										 |  |  | 		.platform_data	= &rdc321x_gpio_pdata, | 
					
						
							|  |  |  | 		.pdata_size	= sizeof(rdc321x_gpio_pdata), | 
					
						
							| 
									
										
										
										
											2010-03-21 01:06:05 +01:00
										 |  |  | 	}, | 
					
						
							|  |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-19 13:23:04 -05:00
										 |  |  | static int rdc321x_sb_probe(struct pci_dev *pdev, | 
					
						
							| 
									
										
										
										
											2010-03-21 01:06:05 +01:00
										 |  |  | 					const struct pci_device_id *ent) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int err; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	err = pci_enable_device(pdev); | 
					
						
							|  |  |  | 	if (err) { | 
					
						
							|  |  |  | 		dev_err(&pdev->dev, "failed to enable device\n"); | 
					
						
							|  |  |  | 		return err; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	rdc321x_gpio_pdata.sb_pdev = pdev; | 
					
						
							|  |  |  | 	rdc321x_wdt_pdata.sb_pdev = pdev; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return mfd_add_devices(&pdev->dev, -1, | 
					
						
							| 
									
										
										
										
											2012-09-11 15:16:36 +08:00
										 |  |  | 			       rdc321x_sb_cells, ARRAY_SIZE(rdc321x_sb_cells), | 
					
						
							|  |  |  | 			       NULL, 0, NULL); | 
					
						
							| 
									
										
										
										
											2010-03-21 01:06:05 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-19 13:26:01 -05:00
										 |  |  | static void rdc321x_sb_remove(struct pci_dev *pdev) | 
					
						
							| 
									
										
										
										
											2010-03-21 01:06:05 +01:00
										 |  |  | { | 
					
						
							|  |  |  | 	mfd_remove_devices(&pdev->dev); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-12-03 08:15:39 +09:00
										 |  |  | static const struct pci_device_id rdc321x_sb_table[] = { | 
					
						
							| 
									
										
										
										
											2010-03-21 01:06:05 +01:00
										 |  |  | 	{ PCI_DEVICE(PCI_VENDOR_ID_RDC, PCI_DEVICE_ID_RDC_R6030) }, | 
					
						
							|  |  |  | 	{} | 
					
						
							|  |  |  | }; | 
					
						
							| 
									
										
										
										
											2011-03-24 15:04:53 +08:00
										 |  |  | MODULE_DEVICE_TABLE(pci, rdc321x_sb_table); | 
					
						
							| 
									
										
										
										
											2010-03-21 01:06:05 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | static struct pci_driver rdc321x_sb_driver = { | 
					
						
							|  |  |  | 	.name		= "RDC321x Southbridge", | 
					
						
							|  |  |  | 	.id_table	= rdc321x_sb_table, | 
					
						
							|  |  |  | 	.probe		= rdc321x_sb_probe, | 
					
						
							| 
									
										
										
										
											2012-11-19 13:20:24 -05:00
										 |  |  | 	.remove		= rdc321x_sb_remove, | 
					
						
							| 
									
										
										
										
											2010-03-21 01:06:05 +01:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-04-03 09:09:19 +08:00
										 |  |  | module_pci_driver(rdc321x_sb_driver); | 
					
						
							| 
									
										
										
										
											2010-03-21 01:06:05 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | MODULE_AUTHOR("Florian Fainelli <florian@openwrt.org>"); | 
					
						
							|  |  |  | MODULE_LICENSE("GPL"); | 
					
						
							|  |  |  | MODULE_DESCRIPTION("RDC R-321x MFD southbridge driver"); |