x86: Add sp5100_tco AMD patches
[openwrt/openwrt.git] / target / linux / x86 / patches-4.4 / 097-0004-watchdog-sp5100_tco-properly-check-for-new-register-.patch
1 From 46856fabe40cc80f92134683cdec7dc0fc8f4000 Mon Sep 17 00:00:00 2001
2 From: Lucas Stach <dev@lynxeye.de>
3 Date: Tue, 3 May 2016 19:15:58 +0200
4 Subject: [PATCH] watchdog: sp5100_tco: properly check for new register layouts
5
6 Commits 190aa4304de6 (Add AMD Mullins platform support) and
7 cca118fa2a0a94 (Add AMD Carrizo platform support) enabled the
8 driver on a lot more devices, but the following commit missed
9 a single location in the code when checking if the SB800 register
10 offsets should be used. This leads to the wrong register being
11 written which in turn causes ACPI to go haywire.
12
13 Fix this by introducing a helper function to check for the new
14 register layout and use this consistently.
15
16 https://bugzilla.kernel.org/show_bug.cgi?id=114201
17 https://bugzilla.redhat.com/show_bug.cgi?id=1329910
18 Fixes: bdecfcdb5461 (sp5100_tco: fix the device check for SB800
19 and later chipsets)
20 Cc: stable@vger.kernel.org (4.5+)
21 Signed-off-by: Lucas Stach <dev@lynxeye.de>
22 Signed-off-by: Guenter Roeck <linux@roeck-us.net>
23 Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
24 ---
25 drivers/watchdog/sp5100_tco.c | 15 ++++++++++-----
26 1 file changed, 10 insertions(+), 5 deletions(-)
27
28 diff --git a/drivers/watchdog/sp5100_tco.c b/drivers/watchdog/sp5100_tco.c
29 index 6467b91..028618c 100644
30 --- a/drivers/watchdog/sp5100_tco.c
31 +++ b/drivers/watchdog/sp5100_tco.c
32 @@ -73,6 +73,13 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started."
33 /*
34 * Some TCO specific functions
35 */
36 +
37 +static bool tco_has_sp5100_reg_layout(struct pci_dev *dev)
38 +{
39 + return dev->device == PCI_DEVICE_ID_ATI_SBX00_SMBUS &&
40 + dev->revision < 0x40;
41 +}
42 +
43 static void tco_timer_start(void)
44 {
45 u32 val;
46 @@ -129,7 +136,7 @@ static void tco_timer_enable(void)
47 {
48 int val;
49
50 - if (sp5100_tco_pci->revision >= 0x40) {
51 + if (!tco_has_sp5100_reg_layout(sp5100_tco_pci)) {
52 /* For SB800 or later */
53 /* Set the Watchdog timer resolution to 1 sec */
54 outb(SB800_PM_WATCHDOG_CONFIG, SB800_IO_PM_INDEX_REG);
55 @@ -342,8 +349,7 @@ static unsigned char sp5100_tco_setupdevice(void)
56 /*
57 * Determine type of southbridge chipset.
58 */
59 - if (sp5100_tco_pci->device == PCI_DEVICE_ID_ATI_SBX00_SMBUS &&
60 - sp5100_tco_pci->revision < 0x40) {
61 + if (tco_has_sp5100_reg_layout(sp5100_tco_pci)) {
62 dev_name = SP5100_DEVNAME;
63 index_reg = SP5100_IO_PM_INDEX_REG;
64 data_reg = SP5100_IO_PM_DATA_REG;
65 @@ -388,8 +394,7 @@ static unsigned char sp5100_tco_setupdevice(void)
66 * Secondly, Find the watchdog timer MMIO address
67 * from SBResource_MMIO register.
68 */
69 - if (sp5100_tco_pci->device == PCI_DEVICE_ID_ATI_SBX00_SMBUS &&
70 - sp5100_tco_pci->revision < 0x40) {
71 + if (tco_has_sp5100_reg_layout(sp5100_tco_pci)) {
72 /* Read SBResource_MMIO from PCI config(PCI_Reg: 9Ch) */
73 pci_read_config_dword(sp5100_tco_pci,
74 SP5100_SB_RESOURCE_MMIO_BASE, &val);
75 --
76 2.7.4