Skip to content

Commit 8906ced

Browse files
committed
Merge tag 'ib-mfd-edac-i2c-leds-pinctrl-platform-watchdog-v5.20' into review-hans
Immutable branch between MFD, EDAC, I2C, LEDs, PinCtrl, Platform and Watchdog due for the v5.20 merge window
2 parents 6dd7125 + a6c80be commit 8906ced

File tree

19 files changed

+464
-243
lines changed

19 files changed

+464
-243
lines changed

drivers/edac/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ config EDAC_I10NM
263263
config EDAC_PND2
264264
tristate "Intel Pondicherry2"
265265
depends on PCI && X86_64 && X86_MCE_INTEL
266+
select P2SB if X86
266267
help
267268
Support for error detection and correction on the Intel
268269
Pondicherry2 Integrated Memory Controller. This SoC IP is

drivers/edac/pnd2_edac.c

Lines changed: 20 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
#include <linux/bitmap.h>
2929
#include <linux/math64.h>
3030
#include <linux/mod_devicetable.h>
31+
#include <linux/platform_data/x86/p2sb.h>
32+
3133
#include <asm/cpu_device_id.h>
3234
#include <asm/intel-family.h>
3335
#include <asm/processor.h>
@@ -232,42 +234,14 @@ static u64 get_mem_ctrl_hub_base_addr(void)
232234
return U64_LSHIFT(hi.base, 32) | U64_LSHIFT(lo.base, 15);
233235
}
234236

235-
static u64 get_sideband_reg_base_addr(void)
236-
{
237-
struct pci_dev *pdev;
238-
u32 hi, lo;
239-
u8 hidden;
240-
241-
pdev = pci_get_device(PCI_VENDOR_ID_INTEL, 0x19dd, NULL);
242-
if (pdev) {
243-
/* Unhide the P2SB device, if it's hidden */
244-
pci_read_config_byte(pdev, 0xe1, &hidden);
245-
if (hidden)
246-
pci_write_config_byte(pdev, 0xe1, 0);
247-
248-
pci_read_config_dword(pdev, 0x10, &lo);
249-
pci_read_config_dword(pdev, 0x14, &hi);
250-
lo &= 0xfffffff0;
251-
252-
/* Hide the P2SB device, if it was hidden before */
253-
if (hidden)
254-
pci_write_config_byte(pdev, 0xe1, hidden);
255-
256-
pci_dev_put(pdev);
257-
return (U64_LSHIFT(hi, 32) | U64_LSHIFT(lo, 0));
258-
} else {
259-
return 0xfd000000;
260-
}
261-
}
262-
263237
#define DNV_MCHBAR_SIZE 0x8000
264238
#define DNV_SB_PORT_SIZE 0x10000
265239
static int dnv_rd_reg(int port, int off, int op, void *data, size_t sz, char *name)
266240
{
267241
struct pci_dev *pdev;
268-
char *base;
269-
u64 addr;
270-
unsigned long size;
242+
void __iomem *base;
243+
struct resource r;
244+
int ret;
271245

272246
if (op == 4) {
273247
pdev = pci_get_device(PCI_VENDOR_ID_INTEL, 0x1980, NULL);
@@ -279,26 +253,30 @@ static int dnv_rd_reg(int port, int off, int op, void *data, size_t sz, char *na
279253
} else {
280254
/* MMIO via memory controller hub base address */
281255
if (op == 0 && port == 0x4c) {
282-
addr = get_mem_ctrl_hub_base_addr();
283-
if (!addr)
256+
memset(&r, 0, sizeof(r));
257+
258+
r.start = get_mem_ctrl_hub_base_addr();
259+
if (!r.start)
284260
return -ENODEV;
285-
size = DNV_MCHBAR_SIZE;
261+
r.end = r.start + DNV_MCHBAR_SIZE - 1;
286262
} else {
287263
/* MMIO via sideband register base address */
288-
addr = get_sideband_reg_base_addr();
289-
if (!addr)
290-
return -ENODEV;
291-
addr += (port << 16);
292-
size = DNV_SB_PORT_SIZE;
264+
ret = p2sb_bar(NULL, 0, &r);
265+
if (ret)
266+
return ret;
267+
268+
r.start += (port << 16);
269+
r.end = r.start + DNV_SB_PORT_SIZE - 1;
293270
}
294271

295-
base = ioremap((resource_size_t)addr, size);
272+
base = ioremap(r.start, resource_size(&r));
296273
if (!base)
297274
return -ENODEV;
298275

299276
if (sz == 8)
300-
*(u32 *)(data + 4) = *(u32 *)(base + off + 4);
301-
*(u32 *)data = *(u32 *)(base + off);
277+
*(u64 *)data = readq(base + off);
278+
else
279+
*(u32 *)data = readl(base + off);
302280

303281
iounmap(base);
304282
}

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/leds/simple/Kconfig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# SPDX-License-Identifier: GPL-2.0-only
22
config LEDS_SIEMENS_SIMATIC_IPC
33
tristate "LED driver for Siemens Simatic IPCs"
4-
depends on LEDS_CLASS
4+
depends on LEDS_GPIO
55
depends on SIEMENS_SIMATIC_IPC
66
help
77
This option enables support for the LEDs of several Industrial PCs
88
from Siemens.
99

10-
To compile this driver as a module, choose M here: the module
11-
will be called simatic-ipc-leds.
10+
To compile this driver as a module, choose M here: the modules
11+
will be called simatic-ipc-leds and simatic-ipc-leds-gpio.

drivers/leds/simple/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
# SPDX-License-Identifier: GPL-2.0
22
obj-$(CONFIG_LEDS_SIEMENS_SIMATIC_IPC) += simatic-ipc-leds.o
3+
obj-$(CONFIG_LEDS_SIEMENS_SIMATIC_IPC) += simatic-ipc-leds-gpio.o
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
/*
3+
* Siemens SIMATIC IPC driver for GPIO based LEDs
4+
*
5+
* Copyright (c) Siemens AG, 2022
6+
*
7+
* Authors:
8+
* Henning Schild <[email protected]>
9+
*/
10+
11+
#include <linux/gpio/machine.h>
12+
#include <linux/gpio/consumer.h>
13+
#include <linux/leds.h>
14+
#include <linux/module.h>
15+
#include <linux/platform_device.h>
16+
17+
static struct gpiod_lookup_table simatic_ipc_led_gpio_table = {
18+
.dev_id = "leds-gpio",
19+
.table = {
20+
GPIO_LOOKUP_IDX("apollolake-pinctrl.0", 51, NULL, 0, GPIO_ACTIVE_LOW),
21+
GPIO_LOOKUP_IDX("apollolake-pinctrl.0", 52, NULL, 1, GPIO_ACTIVE_LOW),
22+
GPIO_LOOKUP_IDX("apollolake-pinctrl.0", 53, NULL, 2, GPIO_ACTIVE_LOW),
23+
GPIO_LOOKUP_IDX("apollolake-pinctrl.0", 57, NULL, 3, GPIO_ACTIVE_LOW),
24+
GPIO_LOOKUP_IDX("apollolake-pinctrl.0", 58, NULL, 4, GPIO_ACTIVE_LOW),
25+
GPIO_LOOKUP_IDX("apollolake-pinctrl.0", 60, NULL, 5, GPIO_ACTIVE_LOW),
26+
GPIO_LOOKUP_IDX("apollolake-pinctrl.0", 56, NULL, 6, GPIO_ACTIVE_LOW),
27+
GPIO_LOOKUP_IDX("apollolake-pinctrl.0", 59, NULL, 7, GPIO_ACTIVE_HIGH),
28+
},
29+
};
30+
31+
static const struct gpio_led simatic_ipc_gpio_leds[] = {
32+
{ .name = "green:" LED_FUNCTION_STATUS "-3" },
33+
{ .name = "red:" LED_FUNCTION_STATUS "-1" },
34+
{ .name = "green:" LED_FUNCTION_STATUS "-1" },
35+
{ .name = "red:" LED_FUNCTION_STATUS "-2" },
36+
{ .name = "green:" LED_FUNCTION_STATUS "-2" },
37+
{ .name = "red:" LED_FUNCTION_STATUS "-3" },
38+
};
39+
40+
static const struct gpio_led_platform_data simatic_ipc_gpio_leds_pdata = {
41+
.num_leds = ARRAY_SIZE(simatic_ipc_gpio_leds),
42+
.leds = simatic_ipc_gpio_leds,
43+
};
44+
45+
static struct platform_device *simatic_leds_pdev;
46+
47+
static int simatic_ipc_leds_gpio_remove(struct platform_device *pdev)
48+
{
49+
gpiod_remove_lookup_table(&simatic_ipc_led_gpio_table);
50+
platform_device_unregister(simatic_leds_pdev);
51+
52+
return 0;
53+
}
54+
55+
static int simatic_ipc_leds_gpio_probe(struct platform_device *pdev)
56+
{
57+
struct gpio_desc *gpiod;
58+
int err;
59+
60+
gpiod_add_lookup_table(&simatic_ipc_led_gpio_table);
61+
simatic_leds_pdev = platform_device_register_resndata(NULL,
62+
"leds-gpio", PLATFORM_DEVID_NONE, NULL, 0,
63+
&simatic_ipc_gpio_leds_pdata,
64+
sizeof(simatic_ipc_gpio_leds_pdata));
65+
if (IS_ERR(simatic_leds_pdev)) {
66+
err = PTR_ERR(simatic_leds_pdev);
67+
goto out;
68+
}
69+
70+
/* PM_BIOS_BOOT_N */
71+
gpiod = gpiod_get_index(&simatic_leds_pdev->dev, NULL, 6, GPIOD_OUT_LOW);
72+
if (IS_ERR(gpiod)) {
73+
err = PTR_ERR(gpiod);
74+
goto out;
75+
}
76+
gpiod_put(gpiod);
77+
78+
/* PM_WDT_OUT */
79+
gpiod = gpiod_get_index(&simatic_leds_pdev->dev, NULL, 7, GPIOD_OUT_LOW);
80+
if (IS_ERR(gpiod)) {
81+
err = PTR_ERR(gpiod);
82+
goto out;
83+
}
84+
gpiod_put(gpiod);
85+
86+
return 0;
87+
out:
88+
simatic_ipc_leds_gpio_remove(pdev);
89+
90+
return err;
91+
}
92+
93+
static struct platform_driver simatic_ipc_led_gpio_driver = {
94+
.probe = simatic_ipc_leds_gpio_probe,
95+
.remove = simatic_ipc_leds_gpio_remove,
96+
.driver = {
97+
.name = KBUILD_MODNAME,
98+
}
99+
};
100+
module_platform_driver(simatic_ipc_led_gpio_driver);
101+
102+
MODULE_LICENSE("GPL v2");
103+
MODULE_ALIAS("platform:" KBUILD_MODNAME);
104+
MODULE_SOFTDEP("pre: platform:leds-gpio");
105+
MODULE_AUTHOR("Henning Schild <[email protected]>");

0 commit comments

Comments
 (0)