Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

i2c: piix4: Add ACPI support

Enable the i2c-piix4 SMBus controller driver to enumerate I2C slave
devices using ACPI. It builds on the related I2C mux device work
in commit 8eb5c87a92c0 ("i2c: add ACPI support for I2C mux ports")

In the i2c-piix4 driver the adapters are enumerated as:
Main SMBus adapter Port 0, Port 2, ..., aux port (i.e., ASF adapter)

However, in the AMD BKDG documentation[1], the implied order of ports is:
Main SMBus adapter Port 0, ASF adapter, Port 2, Port 3, ...

This ordering difference is unfortunate. We assume that ACPI
developers will use the AMD documentation ordering, so we have to
pass an extra parameter to piix4_add_adapter().

[1] 52740 BIOS and Kernel Developer's Guide (BKDG) for AMD Family 16h
Models 30h-3Fh Processors

Based on earlier work by Andrew Cooks.

Reported-by: Andrew Cooks <andrew.cooks@opengear.com>
Signed-off-by: Jean Delvare <jdelvare@suse.de>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>

authored by

Jean Delvare and committed by
Wolfram Sang
0183eb8b 528d53a1

+14 -4
+14 -4
drivers/i2c/busses/i2c-piix4.c
··· 813 813 814 814 static int piix4_add_adapter(struct pci_dev *dev, unsigned short smba, 815 815 bool sb800_main, u8 port, bool notify_imc, 816 - const char *name, struct i2c_adapter **padap) 816 + u8 hw_port_nr, const char *name, 817 + struct i2c_adapter **padap) 817 818 { 818 819 struct i2c_adapter *adap; 819 820 struct i2c_piix4_adapdata *adapdata; ··· 845 844 846 845 /* set up the sysfs linkage to our parent device */ 847 846 adap->dev.parent = &dev->dev; 847 + 848 + if (has_acpi_companion(&dev->dev)) { 849 + acpi_preset_companion(&adap->dev, 850 + ACPI_COMPANION(&dev->dev), 851 + hw_port_nr); 852 + } 848 853 849 854 snprintf(adap->name, sizeof(adap->name), 850 855 "SMBus PIIX4 adapter%s at %04x", name, smba); ··· 885 878 } 886 879 887 880 for (port = 0; port < piix4_adapter_count; port++) { 881 + u8 hw_port_nr = port == 0 ? 0 : port + 1; 882 + 888 883 retval = piix4_add_adapter(dev, smba, true, port, notify_imc, 884 + hw_port_nr, 889 885 piix4_main_port_names_sb800[port], 890 886 &piix4_main_adapters[port]); 891 887 if (retval < 0) ··· 959 949 return retval; 960 950 961 951 /* Try to register main SMBus adapter, give up if we can't */ 962 - retval = piix4_add_adapter(dev, retval, false, 0, false, "", 963 - &piix4_main_adapters[0]); 952 + retval = piix4_add_adapter(dev, retval, false, 0, false, 0, 953 + "", &piix4_main_adapters[0]); 964 954 if (retval < 0) 965 955 return retval; 966 956 } ··· 986 976 if (retval > 0) { 987 977 /* Try to add the aux adapter if it exists, 988 978 * piix4_add_adapter will clean up if this fails */ 989 - piix4_add_adapter(dev, retval, false, 0, false, 979 + piix4_add_adapter(dev, retval, false, 0, false, 1, 990 980 is_sb800 ? piix4_aux_port_name_sb800 : "", 991 981 &piix4_aux_adapter); 992 982 }