Skip to content

Commit c509ebd

Browse files
Shyam Sundar S KAndi Shyti
authored andcommitted
i2c: amd-asf: Add ACPI support for AMD ASF Controller
The AMD ASF controller is presented to the operating system as an ACPI device. The AMD ASF driver can use ACPI to obtain information about the ASF controller's attributes, such as the ASF address space and interrupt number, and to handle ASF interrupts. Currently, the piix4 driver assumes that a specific port address is designated for AUX operations. However, with the introduction of ASF, the same port address may also be used by the ASF controller. Therefore, a check needs to be added to ensure that if ASF is advertised and enabled in ACPI, the AUX port should not be configured. Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Co-developed-by: Sanket Goswami <Sanket.Goswami@amd.com> Signed-off-by: Sanket Goswami <Sanket.Goswami@amd.com> Signed-off-by: Shyam Sundar S K <Shyam-sundar.S-k@amd.com> Signed-off-by: Andi Shyti <andi.shyti@kernel.org>
1 parent 05d9800 commit c509ebd

4 files changed

Lines changed: 98 additions & 1 deletion

File tree

drivers/i2c/busses/Kconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,22 @@ config I2C_AMD_MP2
9595
This driver can also be built as modules. If so, the modules will
9696
be called i2c-amd-mp2-pci and i2c-amd-mp2-plat.
9797

98+
config I2C_AMD_ASF
99+
tristate "AMD ASF I2C Controller Support"
100+
depends on I2C_PIIX4
101+
help
102+
This option enables support for the AMD ASF (Alert Standard Format)
103+
I2C controller. The AMD ASF controller is an SMBus controller with
104+
built-in ASF functionality, allowing it to issue generic SMBus
105+
packets and communicate with the DASH controller using MCTP over
106+
ASF.
107+
108+
If you have an AMD system with ASF support and want to enable this
109+
functionality, say Y or M here. If unsure, say N.
110+
111+
To compile this driver as a module, choose M here: the module will
112+
be called i2c_amd_asf_plat.
113+
98114
config I2C_HIX5HD2
99115
tristate "Hix5hd2 high-speed I2C driver"
100116
depends on ARCH_HISI || ARCH_HIX5HD2 || COMPILE_TEST

drivers/i2c/busses/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ obj-$(CONFIG_I2C_POWERMAC) += i2c-powermac.o
3838
# Embedded system I2C/SMBus host controller drivers
3939
obj-$(CONFIG_I2C_ALTERA) += i2c-altera.o
4040
obj-$(CONFIG_I2C_AMD_MP2) += i2c-amd-mp2-pci.o i2c-amd-mp2-plat.o
41+
obj-$(CONFIG_I2C_AMD_ASF) += i2c-amd-asf-plat.o
4142
obj-$(CONFIG_I2C_ASPEED) += i2c-aspeed.o
4243
obj-$(CONFIG_I2C_AT91) += i2c-at91.o
4344
i2c-at91-objs := i2c-at91-core.o i2c-at91-master.o
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
// SPDX-License-Identifier: GPL-2.0-or-later
2+
/*
3+
* AMD Alert Standard Format Platform Driver
4+
*
5+
* Copyright (c) 2024, Advanced Micro Devices, Inc.
6+
* All Rights Reserved.
7+
*
8+
* Authors: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
9+
* Sanket Goswami <Sanket.Goswami@amd.com>
10+
*/
11+
12+
#include <linux/device.h>
13+
#include <linux/errno.h>
14+
#include <linux/gfp_types.h>
15+
#include <linux/i2c.h>
16+
#include <linux/io.h>
17+
#include <linux/ioport.h>
18+
#include <linux/module.h>
19+
#include <linux/mod_devicetable.h>
20+
#include <linux/platform_device.h>
21+
#include <linux/sprintf.h>
22+
23+
#include "i2c-piix4.h"
24+
25+
struct amd_asf_dev {
26+
struct i2c_adapter adap;
27+
struct sb800_mmio_cfg mmio_cfg;
28+
struct resource *port_addr;
29+
};
30+
31+
static int amd_asf_probe(struct platform_device *pdev)
32+
{
33+
struct device *dev = &pdev->dev;
34+
struct amd_asf_dev *asf_dev;
35+
36+
asf_dev = devm_kzalloc(dev, sizeof(*asf_dev), GFP_KERNEL);
37+
if (!asf_dev)
38+
return dev_err_probe(dev, -ENOMEM, "Failed to allocate memory\n");
39+
40+
asf_dev->mmio_cfg.use_mmio = true;
41+
asf_dev->port_addr = platform_get_resource(pdev, IORESOURCE_IO, 0);
42+
if (!asf_dev->port_addr)
43+
return dev_err_probe(dev, -EINVAL, "missing IO resources\n");
44+
45+
asf_dev->adap.owner = THIS_MODULE;
46+
asf_dev->adap.dev.parent = dev;
47+
48+
i2c_set_adapdata(&asf_dev->adap, asf_dev);
49+
snprintf(asf_dev->adap.name, sizeof(asf_dev->adap.name), "AMD ASF adapter");
50+
51+
return devm_i2c_add_adapter(dev, &asf_dev->adap);
52+
}
53+
54+
static const struct acpi_device_id amd_asf_acpi_ids[] = {
55+
{ "AMDI001A" },
56+
{ }
57+
};
58+
MODULE_DEVICE_TABLE(acpi, amd_asf_acpi_ids);
59+
60+
static struct platform_driver amd_asf_driver = {
61+
.driver = {
62+
.name = "i2c-amd-asf",
63+
.acpi_match_table = amd_asf_acpi_ids,
64+
},
65+
.probe = amd_asf_probe,
66+
};
67+
module_platform_driver(amd_asf_driver);
68+
69+
MODULE_LICENSE("GPL");
70+
MODULE_DESCRIPTION("AMD Alert Standard Format Driver");

drivers/i2c/busses/i2c-piix4.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@
8787

8888
#define SB800_PIIX4_FCH_PM_ADDR 0xFED80300
8989
#define SB800_PIIX4_FCH_PM_SIZE 8
90+
#define SB800_ASF_ACPI_PATH "\\_SB.ASFC"
9091

9192
/* insmod parameters */
9293

@@ -1024,6 +1025,9 @@ static int piix4_probe(struct pci_dev *dev, const struct pci_device_id *id)
10241025
{
10251026
int retval;
10261027
bool is_sb800 = false;
1028+
bool is_asf = false;
1029+
acpi_status status;
1030+
acpi_handle handle;
10271031

10281032
if ((dev->vendor == PCI_VENDOR_ID_ATI &&
10291033
dev->device == PCI_DEVICE_ID_ATI_SBX00_SMBUS &&
@@ -1086,10 +1090,16 @@ static int piix4_probe(struct pci_dev *dev, const struct pci_device_id *id)
10861090
}
10871091
}
10881092

1093+
status = acpi_get_handle(NULL, (acpi_string)SB800_ASF_ACPI_PATH, &handle);
1094+
if (ACPI_SUCCESS(status))
1095+
is_asf = true;
1096+
10891097
if (dev->vendor == PCI_VENDOR_ID_AMD &&
10901098
(dev->device == PCI_DEVICE_ID_AMD_HUDSON2_SMBUS ||
10911099
dev->device == PCI_DEVICE_ID_AMD_KERNCZ_SMBUS)) {
1092-
retval = piix4_setup_sb800(dev, id, 1);
1100+
/* Do not setup AUX port if ASF is enabled */
1101+
if (!is_asf)
1102+
retval = piix4_setup_sb800(dev, id, 1);
10931103
}
10941104

10951105
if (retval > 0) {

0 commit comments

Comments
 (0)