Sat Jul 29 10:50:05 2023 UTC ()
Pull up the following revisions, via patch, requested by msaitoh in
ticket #253:

	sys/dev/pci/ichsmb.c				1.83-1.84

- Add support Intel 700 series chipset and Alder Lake-N devices.
- Use device_printf() instead of aprint_error_dev() in
  ichsmb_i2c_exec().


(martin)
diff -r1.81 -r1.81.4.1 src/sys/dev/pci/ichsmb.c

cvs diff -r1.81 -r1.81.4.1 src/sys/dev/pci/ichsmb.c (expand / switch to unified diff)

--- src/sys/dev/pci/ichsmb.c 2022/09/22 14:45:33 1.81
+++ src/sys/dev/pci/ichsmb.c 2023/07/29 10:50:05 1.81.4.1
@@ -1,38 +1,38 @@ @@ -1,38 +1,38 @@
1/* $NetBSD: ichsmb.c,v 1.81 2022/09/22 14:45:33 riastradh Exp $ */ 1/* $NetBSD: ichsmb.c,v 1.81.4.1 2023/07/29 10:50:05 martin Exp $ */
2/* $OpenBSD: ichiic.c,v 1.44 2020/10/07 11:23:05 jsg Exp $ */ 2/* $OpenBSD: ichiic.c,v 1.44 2020/10/07 11:23:05 jsg Exp $ */
3 3
4/* 4/*
5 * Copyright (c) 2005, 2006 Alexander Yurchenko <grange@openbsd.org> 5 * Copyright (c) 2005, 2006 Alexander Yurchenko <grange@openbsd.org>
6 * 6 *
7 * Permission to use, copy, modify, and distribute this software for any 7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above 8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies. 9 * copyright notice and this permission notice appear in all copies.
10 * 10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */ 18 */
19 19
20/* 20/*
21 * Intel ICH SMBus controller driver. 21 * Intel ICH SMBus controller driver.
22 */ 22 */
23 23
24#include <sys/cdefs.h> 24#include <sys/cdefs.h>
25__KERNEL_RCSID(0, "$NetBSD: ichsmb.c,v 1.81 2022/09/22 14:45:33 riastradh Exp $"); 25__KERNEL_RCSID(0, "$NetBSD: ichsmb.c,v 1.81.4.1 2023/07/29 10:50:05 martin Exp $");
26 26
27#include <sys/param.h> 27#include <sys/param.h>
28#include <sys/device.h> 28#include <sys/device.h>
29#include <sys/errno.h> 29#include <sys/errno.h>
30#include <sys/kernel.h> 30#include <sys/kernel.h>
31#include <sys/mutex.h> 31#include <sys/mutex.h>
32#include <sys/condvar.h> 32#include <sys/condvar.h>
33#include <sys/module.h> 33#include <sys/module.h>
34 34
35#include <sys/bus.h> 35#include <sys/bus.h>
36 36
37#include <dev/pci/pcidevs.h> 37#include <dev/pci/pcidevs.h>
38#include <dev/pci/pcireg.h> 38#include <dev/pci/pcireg.h>
@@ -128,43 +128,45 @@ ichsmb_match(device_t parent, cfdata_t m @@ -128,43 +128,45 @@ ichsmb_match(device_t parent, cfdata_t m
128 case PCI_PRODUCT_INTEL_3HS_SMB: 128 case PCI_PRODUCT_INTEL_3HS_SMB:
129 case PCI_PRODUCT_INTEL_3HS_U_SMB: 129 case PCI_PRODUCT_INTEL_3HS_U_SMB:
130 case PCI_PRODUCT_INTEL_4HS_H_SMB: 130 case PCI_PRODUCT_INTEL_4HS_H_SMB:
131 case PCI_PRODUCT_INTEL_4HS_V_SMB: 131 case PCI_PRODUCT_INTEL_4HS_V_SMB:
132 case PCI_PRODUCT_INTEL_CORE4G_M_SMB: 132 case PCI_PRODUCT_INTEL_CORE4G_M_SMB:
133 case PCI_PRODUCT_INTEL_CORE5G_M_SMB: 133 case PCI_PRODUCT_INTEL_CORE5G_M_SMB:
134 case PCI_PRODUCT_INTEL_CMTLK_SMB: 134 case PCI_PRODUCT_INTEL_CMTLK_SMB:
135 case PCI_PRODUCT_INTEL_BAYTRAIL_PCU_SMB: 135 case PCI_PRODUCT_INTEL_BAYTRAIL_PCU_SMB:
136 case PCI_PRODUCT_INTEL_BSW_PCU_SMB: 136 case PCI_PRODUCT_INTEL_BSW_PCU_SMB:
137 case PCI_PRODUCT_INTEL_APL_SMB: 137 case PCI_PRODUCT_INTEL_APL_SMB:
138 case PCI_PRODUCT_INTEL_GLK_SMB: 138 case PCI_PRODUCT_INTEL_GLK_SMB:
139 case PCI_PRODUCT_INTEL_EHL_SMB: 139 case PCI_PRODUCT_INTEL_EHL_SMB:
140 case PCI_PRODUCT_INTEL_JSL_SMB: 140 case PCI_PRODUCT_INTEL_JSL_SMB:
 141 case PCI_PRODUCT_INTEL_ADL_N_SMB:
141 case PCI_PRODUCT_INTEL_C600_SMBUS: 142 case PCI_PRODUCT_INTEL_C600_SMBUS:
142 case PCI_PRODUCT_INTEL_C600_SMB_0: 143 case PCI_PRODUCT_INTEL_C600_SMB_0:
143 case PCI_PRODUCT_INTEL_C600_SMB_1: 144 case PCI_PRODUCT_INTEL_C600_SMB_1:
144 case PCI_PRODUCT_INTEL_C600_SMB_2: 145 case PCI_PRODUCT_INTEL_C600_SMB_2:
145 case PCI_PRODUCT_INTEL_C610_SMB: 146 case PCI_PRODUCT_INTEL_C610_SMB:
146 case PCI_PRODUCT_INTEL_C620_SMB: 147 case PCI_PRODUCT_INTEL_C620_SMB:
147 case PCI_PRODUCT_INTEL_C620_SMB_S: 148 case PCI_PRODUCT_INTEL_C620_SMB_S:
148 case PCI_PRODUCT_INTEL_EP80579_SMB: 149 case PCI_PRODUCT_INTEL_EP80579_SMB:
149 case PCI_PRODUCT_INTEL_DH89XXCC_SMB: 150 case PCI_PRODUCT_INTEL_DH89XXCC_SMB:
150 case PCI_PRODUCT_INTEL_DH89XXCL_SMB: 151 case PCI_PRODUCT_INTEL_DH89XXCL_SMB:
151 case PCI_PRODUCT_INTEL_C2000_PCU_SMBUS: 152 case PCI_PRODUCT_INTEL_C2000_PCU_SMBUS:
152 case PCI_PRODUCT_INTEL_C3K_SMBUS_LEGACY: 153 case PCI_PRODUCT_INTEL_C3K_SMBUS_LEGACY:
153 case PCI_PRODUCT_INTEL_495_YU_SMB: 154 case PCI_PRODUCT_INTEL_495_YU_SMB:
154 case PCI_PRODUCT_INTEL_5HS_H_SMB: 155 case PCI_PRODUCT_INTEL_5HS_H_SMB:
155 case PCI_PRODUCT_INTEL_5HS_LP_SMB: 156 case PCI_PRODUCT_INTEL_5HS_LP_SMB:
156 case PCI_PRODUCT_INTEL_6HS_H_SMB: 157 case PCI_PRODUCT_INTEL_6HS_H_SMB:
157 case PCI_PRODUCT_INTEL_6HS_LP_SMB: 158 case PCI_PRODUCT_INTEL_6HS_LP_SMB:
 159 case PCI_PRODUCT_INTEL_7HS_SMB:
158 return 1; 160 return 1;
159 } 161 }
160 } 162 }
161 return 0; 163 return 0;
162} 164}
163 165
164static void 166static void
165ichsmb_attach(device_t parent, device_t self, void *aux) 167ichsmb_attach(device_t parent, device_t self, void *aux)
166{ 168{
167 struct ichsmb_softc *sc = device_private(self); 169 struct ichsmb_softc *sc = device_private(self);
168 struct pci_attach_args *pa = aux; 170 struct pci_attach_args *pa = aux;
169 pcireg_t conf; 171 pcireg_t conf;
170 const char *intrstr = NULL; 172 const char *intrstr = NULL;
@@ -413,27 +415,27 @@ ichsmb_i2c_exec(void *cookie, i2c_op_t o @@ -413,27 +415,27 @@ ichsmb_i2c_exec(void *cookie, i2c_op_t o
413 mutex_exit(&sc->sc_exec_lock); 415 mutex_exit(&sc->sc_exec_lock);
414 416
415 return (error); 417 return (error);
416 418
417timeout: 419timeout:
418 /* 420 /*
419 * Transfer timeout. Kill the transaction and clear status bits. 421 * Transfer timeout. Kill the transaction and clear status bits.
420 */ 422 */
421 bus_space_write_1(sc->sc_iot, sc->sc_ioh, SMB_HC, SMB_HC_KILL); 423 bus_space_write_1(sc->sc_iot, sc->sc_ioh, SMB_HC, SMB_HC_KILL);
422 DELAY(ICHIIC_DELAY); 424 DELAY(ICHIIC_DELAY);
423 st = bus_space_read_1(sc->sc_iot, sc->sc_ioh, SMB_HS); 425 st = bus_space_read_1(sc->sc_iot, sc->sc_ioh, SMB_HS);
424 if ((st & SMB_HS_FAILED) == 0) { 426 if ((st & SMB_HS_FAILED) == 0) {
425 snprintb(fbuf, sizeof(fbuf), SMB_HS_BITS, st); 427 snprintb(fbuf, sizeof(fbuf), SMB_HS_BITS, st);
426 aprint_error_dev(sc->sc_dev, "abort failed, status %s\n", 428 device_printf(sc->sc_dev, "abort failed, status %s\n",
427 fbuf); 429 fbuf);
428 } 430 }
429 bus_space_write_1(sc->sc_iot, sc->sc_ioh, SMB_HS, st); 431 bus_space_write_1(sc->sc_iot, sc->sc_ioh, SMB_HS, st);
430 mutex_exit(&sc->sc_exec_lock); 432 mutex_exit(&sc->sc_exec_lock);
431 return (ETIMEDOUT); 433 return (ETIMEDOUT);
432} 434}
433 435
434static int 436static int
435ichsmb_intr(void *arg) 437ichsmb_intr(void *arg)
436{ 438{
437 struct ichsmb_softc *sc = arg; 439 struct ichsmb_softc *sc = arg;
438 uint8_t st; 440 uint8_t st;
439 uint8_t *b; 441 uint8_t *b;