Skip to content

Commit 5c7b916

Browse files
andy-shevlag-linaro
authored andcommitted
i2c: i801: convert to use common P2SB accessor
Since we have a common P2SB accessor in tree we may use it instead of open coded variants. Replace custom code by p2sb_bar() call. Signed-off-by: Andy Shevchenko <[email protected]> Tested-by: Henning Schild <[email protected]> Acked-by: Hans de Goede <[email protected]> Acked-by: Linus Walleij <[email protected]> Reviewed-by: Jean Delvare <[email protected]> Acked-by: Wolfram Sang <[email protected]> Signed-off-by: Lee Jones <[email protected]>
1 parent 7064d7d commit 5c7b916

File tree

3 files changed

+16
-30
lines changed

3 files changed

+16
-30
lines changed

drivers/i2c/busses/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ config I2C_HIX5HD2
108108
config I2C_I801
109109
tristate "Intel 82801 (ICH/PCH)"
110110
depends on PCI
111+
select P2SB if X86
111112
select CHECK_SIGNATURE if X86 && DMI
112113
select I2C_SMBUS
113114
help

drivers/i2c/busses/i2c-i801.c

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@
111111
#include <linux/err.h>
112112
#include <linux/platform_device.h>
113113
#include <linux/platform_data/itco_wdt.h>
114+
#include <linux/platform_data/x86/p2sb.h>
114115
#include <linux/pm_runtime.h>
115116
#include <linux/mutex.h>
116117

@@ -140,7 +141,6 @@
140141
#define TCOBASE 0x050
141142
#define TCOCTL 0x054
142143

143-
#define SBREG_BAR 0x10
144144
#define SBREG_SMBCTRL 0xc6000c
145145
#define SBREG_SMBCTRL_DNV 0xcf000c
146146

@@ -1482,45 +1482,24 @@ i801_add_tco_spt(struct i801_priv *priv, struct pci_dev *pci_dev,
14821482
.version = 4,
14831483
};
14841484
struct resource *res;
1485-
unsigned int devfn;
1486-
u64 base64_addr;
1487-
u32 base_addr;
1488-
u8 hidden;
1485+
int ret;
14891486

14901487
/*
14911488
* We must access the NO_REBOOT bit over the Primary to Sideband
1492-
* bridge (P2SB). The BIOS prevents the P2SB device from being
1493-
* enumerated by the PCI subsystem, so we need to unhide/hide it
1494-
* to lookup the P2SB BAR.
1489+
* (P2SB) bridge.
14951490
*/
1496-
pci_lock_rescan_remove();
1497-
1498-
devfn = PCI_DEVFN(PCI_SLOT(pci_dev->devfn), 1);
1499-
1500-
/* Unhide the P2SB device, if it is hidden */
1501-
pci_bus_read_config_byte(pci_dev->bus, devfn, 0xe1, &hidden);
1502-
if (hidden)
1503-
pci_bus_write_config_byte(pci_dev->bus, devfn, 0xe1, 0x0);
1504-
1505-
pci_bus_read_config_dword(pci_dev->bus, devfn, SBREG_BAR, &base_addr);
1506-
base64_addr = base_addr & 0xfffffff0;
1507-
1508-
pci_bus_read_config_dword(pci_dev->bus, devfn, SBREG_BAR + 0x4, &base_addr);
1509-
base64_addr |= (u64)base_addr << 32;
1510-
1511-
/* Hide the P2SB device, if it was hidden before */
1512-
if (hidden)
1513-
pci_bus_write_config_byte(pci_dev->bus, devfn, 0xe1, hidden);
1514-
pci_unlock_rescan_remove();
15151491

15161492
res = &tco_res[1];
1493+
ret = p2sb_bar(pci_dev->bus, 0, res);
1494+
if (ret)
1495+
return ERR_PTR(ret);
1496+
15171497
if (pci_dev->device == PCI_DEVICE_ID_INTEL_DNV_SMBUS)
1518-
res->start = (resource_size_t)base64_addr + SBREG_SMBCTRL_DNV;
1498+
res->start += SBREG_SMBCTRL_DNV;
15191499
else
1520-
res->start = (resource_size_t)base64_addr + SBREG_SMBCTRL;
1500+
res->start += SBREG_SMBCTRL;
15211501

15221502
res->end = res->start + 3;
1523-
res->flags = IORESOURCE_MEM;
15241503

15251504
return platform_device_register_resndata(&pci_dev->dev, "iTCO_wdt", -1,
15261505
tco_res, 2, &pldata, sizeof(pldata));

drivers/platform/x86/intel/p2sb.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@
2121

2222
static const struct x86_cpu_id p2sb_cpu_ids[] = {
2323
X86_MATCH_INTEL_FAM6_MODEL(ATOM_GOLDMONT, PCI_DEVFN(13, 0)),
24+
X86_MATCH_INTEL_FAM6_MODEL(ATOM_GOLDMONT_D, PCI_DEVFN(31, 1)),
25+
X86_MATCH_INTEL_FAM6_MODEL(ATOM_SILVERMONT_D, PCI_DEVFN(31, 1)),
26+
X86_MATCH_INTEL_FAM6_MODEL(KABYLAKE, PCI_DEVFN(31, 1)),
27+
X86_MATCH_INTEL_FAM6_MODEL(KABYLAKE_L, PCI_DEVFN(31, 1)),
28+
X86_MATCH_INTEL_FAM6_MODEL(SKYLAKE, PCI_DEVFN(31, 1)),
29+
X86_MATCH_INTEL_FAM6_MODEL(SKYLAKE_L, PCI_DEVFN(31, 1)),
2430
{}
2531
};
2632

0 commit comments

Comments
 (0)