/[linux-patches]/genpatches-2.6/tags/2.6.20-9/2300_i2c-i801-resume.patch
Gentoo

Contents of /genpatches-2.6/tags/2.6.20-9/2300_i2c-i801-resume.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 927 - (show annotations) (download)
Thu Apr 26 15:33:43 2007 UTC (7 years, 4 months ago) by phreak
File size: 2732 byte(s)
2.6.20-9 release
1 From: Jean Delvare <khali@linux-fr.org>
2 Date: Thu, 22 Mar 2007 18:49:01 +0000 (+0100)
3 Subject: i2c-i801: Restore the device state before leaving
4 X-Git-Tag: v2.6.21-rc5~44^2~1
5 X-Git-Url: http://git.kernel.org/?p=linux%2Fkernel%2Fgit%2Ftorvalds%2Flinux-2.6.git;a=commitdiff_plain;h=a5aaea37858fb56d624227408d1dde4cb78c9a6c
6
7 i2c-i801: Restore the device state before leaving
8
9 Restore the original host configuration on driver unload and on
10 suspend. In particular this returns the SMBus master in I2C mode if it
11 was originally in I2C mode, which should help with suspend/resume if
12 the BIOS expects to find the SMBus master in I2C mode.
13
14 This fixes bug #6449 (for real this time.)
15 http://bugzilla.kernel.org/show_bug.cgi?id=6449
16
17 Signed-off-by: Jean Delvare <khali@linux-fr.org>
18 Tested-by: Tommi Kyntola <tommi.kyntola@ray.fi>
19 ---
20
21 diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
22 index 6569a36..a320e7d 100644
23 --- a/drivers/i2c/busses/i2c-i801.c
24 +++ b/drivers/i2c/busses/i2c-i801.c
25 @@ -97,6 +97,7 @@ static int i801_block_transaction(union i2c_smbus_data *data, char read_write,
26 int command, int hwpec);
27
28 static unsigned long i801_smba;
29 +static unsigned char i801_original_hstcfg;
30 static struct pci_driver i801_driver;
31 static struct pci_dev *I801_dev;
32 static int isich4;
33 @@ -510,6 +511,7 @@ static int __devinit i801_probe(struct pci_dev *dev, const struct pci_device_id
34 }
35
36 pci_read_config_byte(I801_dev, SMBHSTCFG, &temp);
37 + i801_original_hstcfg = temp;
38 temp &= ~SMBHSTCFG_I2C_EN; /* SMBus timing */
39 if (!(temp & SMBHSTCFG_HST_EN)) {
40 dev_info(&dev->dev, "Enabling SMBus device\n");
41 @@ -543,6 +545,7 @@ exit:
42 static void __devexit i801_remove(struct pci_dev *dev)
43 {
44 i2c_del_adapter(&i801_adapter);
45 + pci_write_config_byte(I801_dev, SMBHSTCFG, i801_original_hstcfg);
46 pci_release_region(dev, SMBBAR);
47 /*
48 * do not call pci_disable_device(dev) since it can cause hard hangs on
49 @@ -550,11 +553,33 @@ static void __devexit i801_remove(struct pci_dev *dev)
50 */
51 }
52
53 +#ifdef CONFIG_PM
54 +static int i801_suspend(struct pci_dev *dev, pm_message_t mesg)
55 +{
56 + pci_save_state(dev);
57 + pci_write_config_byte(dev, SMBHSTCFG, i801_original_hstcfg);
58 + pci_set_power_state(dev, pci_choose_state(dev, mesg));
59 + return 0;
60 +}
61 +
62 +static int i801_resume(struct pci_dev *dev)
63 +{
64 + pci_set_power_state(dev, PCI_D0);
65 + pci_restore_state(dev);
66 + return pci_enable_device(dev);
67 +}
68 +#else
69 +#define i801_suspend NULL
70 +#define i801_resume NULL
71 +#endif
72 +
73 static struct pci_driver i801_driver = {
74 .name = "i801_smbus",
75 .id_table = i801_ids,
76 .probe = i801_probe,
77 .remove = __devexit_p(i801_remove),
78 + .suspend = i801_suspend,
79 + .resume = i801_resume,
80 };
81
82 static int __init i2c_i801_init(void)

  ViewVC Help
Powered by ViewVC 1.1.20