git: 3416f5cde7a7 - main - asmc: Add support for MacBookPro6,2

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Mon, 25 Jul 2022 16:04:35 UTC
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=3416f5cde7a7e01b25b5f5fd240ae8aa12fd70bf

commit 3416f5cde7a7e01b25b5f5fd240ae8aa12fd70bf
Author:     ed crowe <fbsdbug@edcrowe.com>
AuthorDate: 2022-07-25 15:35:46 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2022-07-25 15:43:56 +0000

    asmc: Add support for MacBookPro6,2
    
    Modify asmc_sms_printintr() to be silent when the ambient light sensor
    interrupt fires on this model, since the messages can otherwise fill up
    the dmesg.
    
    PR:             265005
    Reviewed by:    markj
    MFC after:      2 weeks
---
 sys/dev/asmc/asmc.c    | 18 +++++++++++++++++-
 sys/dev/asmc/asmcvar.h | 32 ++++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/sys/dev/asmc/asmc.c b/sys/dev/asmc/asmc.c
index 37949b52afda..cd35c35cd9ce 100644
--- a/sys/dev/asmc/asmc.c
+++ b/sys/dev/asmc/asmc.c
@@ -226,6 +226,12 @@ static const struct asmc_model asmc_models[] = {
 	  ASMC_MBP5_TEMPS, ASMC_MBP5_TEMPNAMES, ASMC_MBP5_TEMPDESCS
 	},
 
+	{
+	  "MacBookPro6,2", "Apple SMC MacBook Pro (Mid 2010, 15-inch)",
+	  ASMC_SMS_FUNCS, ASMC_FAN_FUNCS, ASMC_LIGHT_FUNCS,
+	  ASMC_MBP62_TEMPS, ASMC_MBP62_TEMPNAMES, ASMC_MBP62_TEMPDESCS
+	},
+
 	{
 	  "MacBookPro8,1", "Apple SMC MacBook Pro (early 2011, 13-inch)",
 	  ASMC_SMS_FUNCS_DISABLED, ASMC_FAN_FUNCS2, ASMC_LIGHT_FUNCS,
@@ -1376,6 +1382,7 @@ asmc_sms_intrfast(void *arg)
 static void
 asmc_sms_printintr(device_t dev, uint8_t type)
 {
+	struct asmc_softc *sc = device_get_softc(dev);
 
 	switch (type) {
 	case ASMC_SMS_INTFF:
@@ -1387,8 +1394,17 @@ asmc_sms_printintr(device_t dev, uint8_t type)
 	case ASMC_SMS_INTSH:
 		device_printf(dev, "WARNING: possible shock!\n");
 		break;
+	case ASMC_ALSL_INT2A:
+		/*
+		 * This suppresses console and log messages for the ambient
+		 * light sensor for the only model known to generate this
+		 * interrupt.
+		 */
+		if (strcmp(sc->sc_model->smc_model, "MacBookPro6,2") == 0)
+			break;
+		/* FALLTHROUGH */
 	default:
-		device_printf(dev, "%s unknown interrupt\n", __func__);
+		device_printf(dev, "unknown interrupt: 0x%x\n", type);
 	}
 }
 
diff --git a/sys/dev/asmc/asmcvar.h b/sys/dev/asmc/asmcvar.h
index 533686d0c56b..769903701a99 100644
--- a/sys/dev/asmc/asmcvar.h
+++ b/sys/dev/asmc/asmcvar.h
@@ -109,6 +109,11 @@ struct asmc_softc {
 #define ASMC_SMS_INTHA		0x6f	/* High Acceleration Interrupt */
 #define ASMC_SMS_INTSH		0x80	/* Shock Interrupt */
 
+/*
+ * Light Sensor.
+ */
+#define ASMC_ALSL_INT2A		0x2a	/* Ambient Light related Interrupt */
+
 /*
  * Keyboard backlight.
  */
@@ -232,6 +237,33 @@ struct asmc_softc {
 				  "Heatsink 2", "Memory Controller", \
 				  "PCI Express Slot Pin", "PCI Express Slot (unk)" }
 
+#define ASMC_MBP62_TEMPS	{ "TB0T", "TB1T", "TB2T", \
+				  "TC0C", "TC0D", "TC0P", \
+				  "TC1C", "TG0D", "TG0P", \
+				  "TG0T", "TMCD", "TP0P", \
+				  "TPCD", "Th1H", "Th2H", \
+				  "Tm0P", "Ts0P", "Ts0S" }
+
+#define ASMC_MBP62_TEMPNAMES	{ "enclosure_bottom_0", "enclosure_bottom_1", \
+				  "enclosure_bottom_2", "cpu0", \
+				  "cpu_diode", "cpu_proximity", \
+				  "cpu1", "gpu_diode", \
+				  "gpu_pin", "gpu_transistor", \
+				  "TMCD", "pch_controller_proximity", \
+				  "pch_die", "heatsink1", \
+				  "heatsink2", "memory-controller", \
+				  "palmrest", "memoryproximity" }
+
+#define ASMC_MBP62_TEMPDESCS	{ "Enclosure Bottom 0", "Enclosure Bottom 1", \
+				  "Enclosure Bottom 2", "CPU 0", \
+				  "CPU Diode", "CPU Proximity", \
+				  "CPU 1", "GPU Diode", \
+				  "GPU Pin", "GPU Transistor", \
+				  "TMCD", "PCH Controller Proximity", \
+				  "PCH Die", "Heat Sink 1", \
+				  "Heat Sink 2", "Memory Controller", \
+				  "Palm Rest", "Memory Proximity" }
+
 #define ASMC_MBP81_TEMPS	{ "TB0T", "TB1T", "TB2T", "TC0C", "TC0D", \
 				  "TC0E", "TC0F", "TC0P", "TC1C", "TC2C", \
 				  "TCFC", "TCGC", "TCSA", "TM0S", "TMBS", \