forked from mirrors/linux
		
	i2c: convert i2c-isch to platform_device
Convert i2c-isch to platform_device for the lpc mfd core to add it at probe time. Signed-off-by: Denis Turischev <denis@compulab.co.il> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
		
							parent
							
								
									473fe73650
								
							
						
					
					
						commit
						fd46a0064a
					
				
					 2 changed files with 28 additions and 42 deletions
				
			
		|  | @ -105,7 +105,7 @@ config I2C_I801 | ||||||
| 
 | 
 | ||||||
| config I2C_ISCH | config I2C_ISCH | ||||||
| 	tristate "Intel SCH SMBus 1.0" | 	tristate "Intel SCH SMBus 1.0" | ||||||
| 	depends on PCI | 	select LPC_SCH | ||||||
| 	help | 	help | ||||||
| 	  Say Y here if you want to use SMBus controller on the Intel SCH | 	  Say Y here if you want to use SMBus controller on the Intel SCH | ||||||
| 	  based systems. | 	  based systems. | ||||||
|  |  | ||||||
|  | @ -27,7 +27,7 @@ | ||||||
| */ | */ | ||||||
| 
 | 
 | ||||||
| #include <linux/module.h> | #include <linux/module.h> | ||||||
| #include <linux/pci.h> | #include <linux/platform_device.h> | ||||||
| #include <linux/kernel.h> | #include <linux/kernel.h> | ||||||
| #include <linux/delay.h> | #include <linux/delay.h> | ||||||
| #include <linux/stddef.h> | #include <linux/stddef.h> | ||||||
|  | @ -46,12 +46,6 @@ | ||||||
| #define SMBHSTDAT1	(7 + sch_smba) | #define SMBHSTDAT1	(7 + sch_smba) | ||||||
| #define SMBBLKDAT	(0x20 + sch_smba) | #define SMBBLKDAT	(0x20 + sch_smba) | ||||||
| 
 | 
 | ||||||
| /* count for request_region */ |  | ||||||
| #define SMBIOSIZE	64 |  | ||||||
| 
 |  | ||||||
| /* PCI Address Constants */ |  | ||||||
| #define SMBBA_SCH	0x40 |  | ||||||
| 
 |  | ||||||
| /* Other settings */ | /* Other settings */ | ||||||
| #define MAX_TIMEOUT	500 | #define MAX_TIMEOUT	500 | ||||||
| 
 | 
 | ||||||
|  | @ -63,7 +57,6 @@ | ||||||
| #define SCH_BLOCK_DATA		0x05 | #define SCH_BLOCK_DATA		0x05 | ||||||
| 
 | 
 | ||||||
| static unsigned short sch_smba; | static unsigned short sch_smba; | ||||||
| static struct pci_driver sch_driver; |  | ||||||
| static struct i2c_adapter sch_adapter; | static struct i2c_adapter sch_adapter; | ||||||
| 
 | 
 | ||||||
| /*
 | /*
 | ||||||
|  | @ -256,37 +249,23 @@ static struct i2c_adapter sch_adapter = { | ||||||
| 	.algo		= &smbus_algorithm, | 	.algo		= &smbus_algorithm, | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| static const struct pci_device_id sch_ids[] = { | static int __devinit smbus_sch_probe(struct platform_device *dev) | ||||||
| 	{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_SCH_LPC) }, |  | ||||||
| 	{ 0, } |  | ||||||
| }; |  | ||||||
| 
 |  | ||||||
| MODULE_DEVICE_TABLE(pci, sch_ids); |  | ||||||
| 
 |  | ||||||
| static int __devinit sch_probe(struct pci_dev *dev, |  | ||||||
| 				const struct pci_device_id *id) |  | ||||||
| { | { | ||||||
|  | 	struct resource *res; | ||||||
| 	int retval; | 	int retval; | ||||||
| 	unsigned int smba; |  | ||||||
| 
 | 
 | ||||||
| 	pci_read_config_dword(dev, SMBBA_SCH, &smba); | 	res = platform_get_resource(dev, IORESOURCE_IO, 0); | ||||||
| 	if (!(smba & (1 << 31))) { | 	if (!res) | ||||||
| 		dev_err(&dev->dev, "SMBus I/O space disabled!\n"); | 		return -EBUSY; | ||||||
| 		return -ENODEV; |  | ||||||
| 	} |  | ||||||
| 
 | 
 | ||||||
| 	sch_smba = (unsigned short)smba; | 	if (!request_region(res->start, resource_size(res), dev->name)) { | ||||||
| 	if (sch_smba == 0) { |  | ||||||
| 		dev_err(&dev->dev, "SMBus base address uninitialized!\n"); |  | ||||||
| 		return -ENODEV; |  | ||||||
| 	} |  | ||||||
| 	if (acpi_check_region(sch_smba, SMBIOSIZE, sch_driver.name)) |  | ||||||
| 		return -ENODEV; |  | ||||||
| 	if (!request_region(sch_smba, SMBIOSIZE, sch_driver.name)) { |  | ||||||
| 		dev_err(&dev->dev, "SMBus region 0x%x already in use!\n", | 		dev_err(&dev->dev, "SMBus region 0x%x already in use!\n", | ||||||
| 			sch_smba); | 			sch_smba); | ||||||
| 		return -EBUSY; | 		return -EBUSY; | ||||||
| 	} | 	} | ||||||
|  | 
 | ||||||
|  | 	sch_smba = res->start; | ||||||
|  | 
 | ||||||
| 	dev_dbg(&dev->dev, "SMBA = 0x%X\n", sch_smba); | 	dev_dbg(&dev->dev, "SMBA = 0x%X\n", sch_smba); | ||||||
| 
 | 
 | ||||||
| 	/* set up the sysfs linkage to our parent device */ | 	/* set up the sysfs linkage to our parent device */ | ||||||
|  | @ -298,37 +277,43 @@ static int __devinit sch_probe(struct pci_dev *dev, | ||||||
| 	retval = i2c_add_adapter(&sch_adapter); | 	retval = i2c_add_adapter(&sch_adapter); | ||||||
| 	if (retval) { | 	if (retval) { | ||||||
| 		dev_err(&dev->dev, "Couldn't register adapter!\n"); | 		dev_err(&dev->dev, "Couldn't register adapter!\n"); | ||||||
| 		release_region(sch_smba, SMBIOSIZE); | 		release_region(res->start, resource_size(res)); | ||||||
| 		sch_smba = 0; | 		sch_smba = 0; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	return retval; | 	return retval; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static void __devexit sch_remove(struct pci_dev *dev) | static int __devexit smbus_sch_remove(struct platform_device *pdev) | ||||||
| { | { | ||||||
|  | 	struct resource *res; | ||||||
| 	if (sch_smba) { | 	if (sch_smba) { | ||||||
| 		i2c_del_adapter(&sch_adapter); | 		i2c_del_adapter(&sch_adapter); | ||||||
| 		release_region(sch_smba, SMBIOSIZE); | 		res = platform_get_resource(pdev, IORESOURCE_IO, 0); | ||||||
|  | 		release_region(res->start, resource_size(res)); | ||||||
| 		sch_smba = 0; | 		sch_smba = 0; | ||||||
| 	} | 	} | ||||||
|  | 
 | ||||||
|  | 	return 0; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static struct pci_driver sch_driver = { | static struct platform_driver smbus_sch_driver = { | ||||||
| 	.name		= "isch_smbus", | 	.driver = { | ||||||
| 	.id_table	= sch_ids, | 		.name = "isch_smbus", | ||||||
| 	.probe		= sch_probe, | 		.owner = THIS_MODULE, | ||||||
| 	.remove		= __devexit_p(sch_remove), | 	}, | ||||||
|  | 	.probe		= smbus_sch_probe, | ||||||
|  | 	.remove		= __devexit_p(smbus_sch_remove), | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| static int __init i2c_sch_init(void) | static int __init i2c_sch_init(void) | ||||||
| { | { | ||||||
| 	return pci_register_driver(&sch_driver); | 	return platform_driver_register(&smbus_sch_driver); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static void __exit i2c_sch_exit(void) | static void __exit i2c_sch_exit(void) | ||||||
| { | { | ||||||
| 	pci_unregister_driver(&sch_driver); | 	platform_driver_unregister(&smbus_sch_driver); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| MODULE_AUTHOR("Jacob Pan <jacob.jun.pan@intel.com>"); | MODULE_AUTHOR("Jacob Pan <jacob.jun.pan@intel.com>"); | ||||||
|  | @ -337,3 +322,4 @@ MODULE_LICENSE("GPL"); | ||||||
| 
 | 
 | ||||||
| module_init(i2c_sch_init); | module_init(i2c_sch_init); | ||||||
| module_exit(i2c_sch_exit); | module_exit(i2c_sch_exit); | ||||||
|  | MODULE_ALIAS("platform:isch_smbus"); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Denis Turischev
						Denis Turischev