From patchwork Thu Apr 17 11:13:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 882129 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 452DE237A3B for ; Thu, 17 Apr 2025 11:13:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744888445; cv=none; b=jmAv4qiEqcN8+DG9QJEg4uBkibBVQWTu8k1c7/g82DrkjC9WRK7yHFJw9qqTaI0I418YpX8b65Mq8iZu0LvXbdiurJqReMxj1pYEgyi9qluzBaPz/oAr0smoHbVNL13qgrQ56aADIm2Y7egHo7G1QwEy8nbQLufBjXwOkFk1lS8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744888445; c=relaxed/simple; bh=DF9uLVCmcppGaYrzAQ/097853xSxX5JBUgPcUUDVnAI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UTFSh1s9VJGQ9N3u16WTtJIz75Izij/v1l0uqcb2ZJO7jYPRZmOLiu0g/e6BSUIvwRHl3B9kRL/UgqH8KmtLrBl953GFAn/l+hnA1nJLG1va0606zmq+L5zJrN5W0UVkKMJNNsL/th3GmXCV1EOzJ6snsynYq1hmklma3TX6v+Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=DtCYbOpM; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="DtCYbOpM" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1744888439; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nqvRoUOS45eqYZyUu/oyin/hyEkH6Sk3qKL5WSi0Vdk=; b=DtCYbOpMy+RsSQXAs4vfSTr2/B2pwkYrWsBsXFugJs1x73vY4+k1wRFX186ZgjvHMlliC8 Z+twOEQxJBVtzs+FLxz86ZtqoQve0s6G2X46LuVE9lY9BxslRyrI8v4hmmjPIwDnZcdeba cX2nbZAO2rkuWqfbaFQFo3iDufiSA80= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-373-gzF-n1i9NBaE3o9G8QIshg-1; Thu, 17 Apr 2025 07:13:54 -0400 X-MC-Unique: gzF-n1i9NBaE3o9G8QIshg-1 X-Mimecast-MFC-AGG-ID: gzF-n1i9NBaE3o9G8QIshg_1744888432 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 315D319560AA; Thu, 17 Apr 2025 11:13:52 +0000 (UTC) Received: from localhost.localdomain (unknown [10.44.34.7]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9CFAA18002AD; Thu, 17 Apr 2025 11:13:48 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andy Shevchenko Cc: Hans de Goede , Dan Scally , Alan Stern , Sakari Ailus , Hao Yao , Bingbu Cao , Duane , platform-driver-x86@vger.kernel.org, linux-media@vger.kernel.org Subject: [PATCH v4 1/9] platform/x86: int3472: Add skl_int3472_register_clock() helper Date: Thu, 17 Apr 2025 13:13:29 +0200 Message-ID: <20250417111337.38142-2-hdegoede@redhat.com> In-Reply-To: <20250417111337.38142-1-hdegoede@redhat.com> References: <20250417111337.38142-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 skl_int3472_register_dsm_clock() and skl_int3472_register_gpio_clock() are 80% the same code. Factor out the common code into a new skl_int3472_register_clock() helper. Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede --- .../x86/intel/int3472/clk_and_regulator.c | 57 +++++-------------- 1 file changed, 13 insertions(+), 44 deletions(-) diff --git a/drivers/platform/x86/intel/int3472/clk_and_regulator.c b/drivers/platform/x86/intel/int3472/clk_and_regulator.c index 16e36ac0a7b4..837990af24fe 100644 --- a/drivers/platform/x86/intel/int3472/clk_and_regulator.c +++ b/drivers/platform/x86/intel/int3472/clk_and_regulator.c @@ -118,7 +118,7 @@ static const struct clk_ops skl_int3472_clock_ops = { .recalc_rate = skl_int3472_clk_recalc_rate, }; -int skl_int3472_register_dsm_clock(struct int3472_discrete_device *int3472) +static int skl_int3472_register_clock(struct int3472_discrete_device *int3472) { struct acpi_device *adev = int3472->adev; struct clk_init_data init = { @@ -127,12 +127,6 @@ int skl_int3472_register_dsm_clock(struct int3472_discrete_device *int3472) }; int ret; - if (int3472->clock.cl) - return 0; /* A GPIO controlled clk has already been registered */ - - if (!acpi_check_dsm(adev->handle, &img_clk_guid, 0, BIT(1))) - return 0; /* DSM clock control is not available */ - init.name = kasprintf(GFP_KERNEL, "%s-clk", acpi_dev_name(adev)); if (!init.name) return -ENOMEM; @@ -161,51 +155,26 @@ int skl_int3472_register_dsm_clock(struct int3472_discrete_device *int3472) return ret; } +int skl_int3472_register_dsm_clock(struct int3472_discrete_device *int3472) +{ + if (int3472->clock.cl) + return 0; /* A GPIO controlled clk has already been registered */ + + if (!acpi_check_dsm(int3472->adev->handle, &img_clk_guid, 0, BIT(1))) + return 0; /* DSM clock control is not available */ + + return skl_int3472_register_clock(int3472); +} + int skl_int3472_register_gpio_clock(struct int3472_discrete_device *int3472, struct gpio_desc *gpio) { - struct clk_init_data init = { - .ops = &skl_int3472_clock_ops, - .flags = CLK_GET_RATE_NOCACHE, - }; - int ret; - if (int3472->clock.cl) return -EBUSY; int3472->clock.ena_gpio = gpio; - init.name = kasprintf(GFP_KERNEL, "%s-clk", - acpi_dev_name(int3472->adev)); - if (!init.name) - return -ENOMEM; - - int3472->clock.frequency = skl_int3472_get_clk_frequency(int3472); - - int3472->clock.clk_hw.init = &init; - int3472->clock.clk = clk_register(&int3472->adev->dev, - &int3472->clock.clk_hw); - if (IS_ERR(int3472->clock.clk)) { - ret = PTR_ERR(int3472->clock.clk); - goto out_free_init_name; - } - - int3472->clock.cl = clkdev_create(int3472->clock.clk, NULL, - int3472->sensor_name); - if (!int3472->clock.cl) { - ret = -ENOMEM; - goto err_unregister_clk; - } - - kfree(init.name); - return 0; - -err_unregister_clk: - clk_unregister(int3472->clock.clk); -out_free_init_name: - kfree(init.name); - - return ret; + return skl_int3472_register_clock(int3472); } void skl_int3472_unregister_clock(struct int3472_discrete_device *int3472) From patchwork Thu Apr 17 11:13:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 882506 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7FBB8238147 for ; Thu, 17 Apr 2025 11:14:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744888447; cv=none; b=gdeNoiwE2e2k/KOX/5QEszU0hWH9n+b2vPw4ezyrM4rwHZxWuljt3gSQnxk/tkm1W3hN6ANnCDpMWSAlo/nRFUXdZWLsD6yqiDFv1cuGlfLqn31rywC4eeUNe+j+F/GBoMWXUykESNgz59c4UDmrF7W3Yzq55cClqHVASZhiDIU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744888447; c=relaxed/simple; bh=nVnBfmspl+DON/YD3BIcEG78H4IhwBM2t0pL72M0Zjc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QeBARs2ExiCLcvBZCOHD5uC0AuVdHMwDtXMQ/Jw4f0BbhzSw1HJTX7U0gGAfie0KuZvALCKihsDGo+ia9gC9Z99Py1Eji662ZYfdYfWGuOJjAnaMNSZEvNeWQAAjagVAZ8LV2rGfnhwczE46V/Y2Ixsd9agCWHRm7kIZM4MqM98= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=RlSNzVh/; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="RlSNzVh/" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1744888441; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XlHtPHUZ660q5i4ytAKPVW+2iA+L4bNpvIUVcx+G3mQ=; b=RlSNzVh/zeiHC2h+VNLkwOJGKiDsOo0Rf+eIdxu+neoaUkr5E4N4TGYu+oz9puP+5k4bh6 Ru9M30aK7qlRJNgn4+YKpqJe/k8Cl/FAq20uFlZZwc3ZS5BSXfeicYzc7fpLRUJ8Una6l5 +h4GToyMRn+DR2YklMPYzqQh9JeaGo8= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-21-fZEMoCZpMoK4P88a2LQL6g-1; Thu, 17 Apr 2025 07:13:58 -0400 X-MC-Unique: fZEMoCZpMoK4P88a2LQL6g-1 X-Mimecast-MFC-AGG-ID: fZEMoCZpMoK4P88a2LQL6g_1744888436 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 92541180087C; Thu, 17 Apr 2025 11:13:56 +0000 (UTC) Received: from localhost.localdomain (unknown [10.44.34.7]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id E202E18002AD; Thu, 17 Apr 2025 11:13:52 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andy Shevchenko Cc: Hans de Goede , Dan Scally , Alan Stern , Sakari Ailus , Hao Yao , Bingbu Cao , Duane , platform-driver-x86@vger.kernel.org, linux-media@vger.kernel.org Subject: [PATCH v4 2/9] platform/x86: int3472: Stop setting a supply-name for GPIO regulators Date: Thu, 17 Apr 2025 13:13:30 +0200 Message-ID: <20250417111337.38142-3-hdegoede@redhat.com> In-Reply-To: <20250417111337.38142-1-hdegoede@redhat.com> References: <20250417111337.38142-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 The supply_name field is not mandatory and is supposed to be set to the name of another regulator when it is known that the regulator being registered is supplied by that other regulator. Having a regulator supplying the regulator which is being registered does not apply to the INT3472 GPIO regulator, stop setting a supply_name. Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede --- drivers/platform/x86/intel/int3472/clk_and_regulator.c | 3 --- drivers/platform/x86/intel/int3472/common.h | 5 +---- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/platform/x86/intel/int3472/clk_and_regulator.c b/drivers/platform/x86/intel/int3472/clk_and_regulator.c index 837990af24fe..40434591dd0b 100644 --- a/drivers/platform/x86/intel/int3472/clk_and_regulator.c +++ b/drivers/platform/x86/intel/int3472/clk_and_regulator.c @@ -256,12 +256,9 @@ int skl_int3472_register_regulator(struct int3472_discrete_device *int3472, snprintf(int3472->regulator.regulator_name, sizeof(int3472->regulator.regulator_name), "%s-regulator", acpi_dev_name(int3472->adev)); - snprintf(int3472->regulator.supply_name, - GPIO_REGULATOR_SUPPLY_NAME_LENGTH, "supply-0"); int3472->regulator.rdesc = INT3472_REGULATOR( int3472->regulator.regulator_name, - int3472->regulator.supply_name, &int3472_gpio_regulator_ops); int3472->regulator.gpio = gpio; diff --git a/drivers/platform/x86/intel/int3472/common.h b/drivers/platform/x86/intel/int3472/common.h index 145dec66df64..72ef222629b6 100644 --- a/drivers/platform/x86/intel/int3472/common.h +++ b/drivers/platform/x86/intel/int3472/common.h @@ -27,17 +27,15 @@ #define INT3472_MAX_SENSOR_GPIOS 3 #define GPIO_REGULATOR_NAME_LENGTH 21 -#define GPIO_REGULATOR_SUPPLY_NAME_LENGTH 9 #define GPIO_REGULATOR_SUPPLY_MAP_COUNT 2 #define INT3472_LED_MAX_NAME_LEN 32 #define CIO2_SENSOR_SSDB_MCLKSPEED_OFFSET 86 -#define INT3472_REGULATOR(_name, _supply, _ops) \ +#define INT3472_REGULATOR(_name, _ops) \ (const struct regulator_desc) { \ .name = _name, \ - .supply_name = _supply, \ .type = REGULATOR_VOLTAGE, \ .ops = _ops, \ .owner = THIS_MODULE, \ @@ -82,7 +80,6 @@ struct int3472_discrete_device { /* SUPPLY_MAP_COUNT * 2 to make room for second sensor mappings */ struct regulator_consumer_supply supply_map[GPIO_REGULATOR_SUPPLY_MAP_COUNT * 2]; char regulator_name[GPIO_REGULATOR_NAME_LENGTH]; - char supply_name[GPIO_REGULATOR_SUPPLY_NAME_LENGTH]; struct gpio_desc *gpio; struct regulator_dev *rdev; struct regulator_desc rdesc; From patchwork Thu Apr 17 11:13:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 882128 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 815382376EA for ; Thu, 17 Apr 2025 11:14:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744888455; cv=none; b=tLoTN4zxb16J+J/9C3bpGJyqRtbZOqTDXF9vuQ1n5PE583T0rCOtOYMPaZhIKozZNevn1kDDaA6RY54aJJnYrMDm0kuqFImhwzASoAu2feRIribF6reFkWQOKLm2EOc0ciHHUdD957Ej0S9QuikY9j6Gl94ILRR08Zj09ziK56c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744888455; c=relaxed/simple; bh=vJOovRwT5oBTlJtE96qNm/0UqugHRiAShonypF+q16g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JGNXsz95UdZX2zBPceRJVsLGpr7LcH2x/TRBOwR6Jmz2MN9KFffqP7uLfCIG34W2vobMTanmN04sOhPVCYiQtYI1YkzcK3umXbDOZfk1pnpPcSAv4XfsZL5PIlfo+FTKrjNn4K10XZ3TkBHc0GjzYh4obgee2xrGmHsPfxfrJXU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=PrPPmpHP; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="PrPPmpHP" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1744888449; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CgikGdvC8j108bQE/mdQFjk6E8b6Q6tIt4AUZ/HzCuM=; b=PrPPmpHPeJUYgsYaQBXcEh82BZvvwny8qE0Cq0/SV2BuU57lpqAVYW6BQYh/NlXRBvHMW1 Q733xcoStbt0RMvndqAvPK5OQNYVWtTUxkNYwMLkLT38oXVuy/bbPBBM1mlyVFRnSvvQCi gsvLrEzIw79nViqOI97t04eTbusnIRY= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-155-VDb7nEs8O9yiVrH4ukBVGA-1; Thu, 17 Apr 2025 07:14:02 -0400 X-MC-Unique: VDb7nEs8O9yiVrH4ukBVGA-1 X-Mimecast-MFC-AGG-ID: VDb7nEs8O9yiVrH4ukBVGA_1744888441 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BD82618001EA; Thu, 17 Apr 2025 11:14:00 +0000 (UTC) Received: from localhost.localdomain (unknown [10.44.34.7]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4458C18002AD; Thu, 17 Apr 2025 11:13:56 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andy Shevchenko Cc: Hans de Goede , Dan Scally , Alan Stern , Sakari Ailus , Hao Yao , Bingbu Cao , Duane , platform-driver-x86@vger.kernel.org, linux-media@vger.kernel.org Subject: [PATCH v4 3/9] platform/x86: int3472: Drop unused gpio field from struct int3472_gpio_regulator Date: Thu, 17 Apr 2025 13:13:31 +0200 Message-ID: <20250417111337.38142-4-hdegoede@redhat.com> In-Reply-To: <20250417111337.38142-1-hdegoede@redhat.com> References: <20250417111337.38142-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 The gpio field in struct int3472_gpio_regulator is only briefly used to store the GPIO in skl_int3472_register_regulator(). Instead just store the GPIO directly into cfg.ena_gpiod an drop the gpio field. Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede --- drivers/platform/x86/intel/int3472/clk_and_regulator.c | 4 +--- drivers/platform/x86/intel/int3472/common.h | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/platform/x86/intel/int3472/clk_and_regulator.c b/drivers/platform/x86/intel/int3472/clk_and_regulator.c index 40434591dd0b..5f6c66215f63 100644 --- a/drivers/platform/x86/intel/int3472/clk_and_regulator.c +++ b/drivers/platform/x86/intel/int3472/clk_and_regulator.c @@ -261,11 +261,9 @@ int skl_int3472_register_regulator(struct int3472_discrete_device *int3472, int3472->regulator.regulator_name, &int3472_gpio_regulator_ops); - int3472->regulator.gpio = gpio; - cfg.dev = &int3472->adev->dev; cfg.init_data = &init_data; - cfg.ena_gpiod = int3472->regulator.gpio; + cfg.ena_gpiod = gpio; int3472->regulator.rdev = regulator_register(int3472->dev, &int3472->regulator.rdesc, diff --git a/drivers/platform/x86/intel/int3472/common.h b/drivers/platform/x86/intel/int3472/common.h index 72ef222629b6..e0fa34be8a07 100644 --- a/drivers/platform/x86/intel/int3472/common.h +++ b/drivers/platform/x86/intel/int3472/common.h @@ -80,7 +80,6 @@ struct int3472_discrete_device { /* SUPPLY_MAP_COUNT * 2 to make room for second sensor mappings */ struct regulator_consumer_supply supply_map[GPIO_REGULATOR_SUPPLY_MAP_COUNT * 2]; char regulator_name[GPIO_REGULATOR_NAME_LENGTH]; - struct gpio_desc *gpio; struct regulator_dev *rdev; struct regulator_desc rdesc; } regulator; From patchwork Thu Apr 17 11:13:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 882505 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B203E238159 for ; Thu, 17 Apr 2025 11:14:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744888455; cv=none; b=U4Y/6b6vkOB9InbiFDNDAJavnArD4CIp+37SE0JeDvx1QyfXCTT/TyNXlozntycUQtomZQy1HS5uc0ydAuor4FY+xDDtAUA9s92ojLdK9EyNMj3iZprB2zE10bOnl761dtRanpM2csSWGhAh//I5dCG8Kx2calV3NArkSu9MkHs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744888455; c=relaxed/simple; bh=gyPxyPG9ur8rw8wnpbKQbqdHB3sNV6+YQGwlOJT3JSs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jrxMKL7G8uai71e3AYo4UknwDZ2mVoR/aq0vauGyoLcudxzrs0yH1ArDV+Nsj8f1rnri28I++CacJTfxUsmmFTndyJ0LvssOf17yUJfJABisERVN21rUv05J/bN+SoEZO7pFvjUlScHvRzdGS/uHovF+wxO4hB51Flx7nK/CozM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=ZOsnKMQy; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ZOsnKMQy" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1744888449; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=215HgyjeVIU/Zl0fQFeBsUH+Vk1QJOIWpb4d7f4NOH0=; b=ZOsnKMQygwzuvNJv7jp0Luq9BbIlN6Qhx61cb8sL2Y7qgxarBFxzM5c1jiwPxQzpd8rq6H PpIqRJ0HmpqIzagcbAoacgNNt4qKDJTW6/Q6FBi1qoisum80DMuCOWBvE41+p3X/gbEark cI0LcHiAYJnaPwXQQf8QU0niQjIx0PQ= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-34-tgOqoFIjMLC091QnAMrVEQ-1; Thu, 17 Apr 2025 07:14:06 -0400 X-MC-Unique: tgOqoFIjMLC091QnAMrVEQ-1 X-Mimecast-MFC-AGG-ID: tgOqoFIjMLC091QnAMrVEQ_1744888445 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CAE3519560AA; Thu, 17 Apr 2025 11:14:04 +0000 (UTC) Received: from localhost.localdomain (unknown [10.44.34.7]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4509D180045C; Thu, 17 Apr 2025 11:14:01 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andy Shevchenko Cc: Hans de Goede , Dan Scally , Alan Stern , Sakari Ailus , Hao Yao , Bingbu Cao , Duane , platform-driver-x86@vger.kernel.org, linux-media@vger.kernel.org Subject: [PATCH v4 4/9] platform/x86: int3472: Rework AVDD second sensor quirk handling Date: Thu, 17 Apr 2025 13:13:32 +0200 Message-ID: <20250417111337.38142-5-hdegoede@redhat.com> In-Reply-To: <20250417111337.38142-1-hdegoede@redhat.com> References: <20250417111337.38142-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Rework the discrete quirk handling to use a quirks struct which is pointed to by a dmi_system_id table, rather then having a dmi_system_id table per type of quirk. This is a preparation patch for adding support for multiple regulators, where not all regulators might be shared between sensors. Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede --- drivers/platform/x86/intel/int3472/Makefile | 3 +- .../x86/intel/int3472/clk_and_regulator.c | 28 ++----------------- drivers/platform/x86/intel/int3472/common.h | 13 ++++++++- drivers/platform/x86/intel/int3472/discrete.c | 13 ++++++++- .../x86/intel/int3472/discrete_quirks.c | 22 +++++++++++++++ 5 files changed, 50 insertions(+), 29 deletions(-) create mode 100644 drivers/platform/x86/intel/int3472/discrete_quirks.c diff --git a/drivers/platform/x86/intel/int3472/Makefile b/drivers/platform/x86/intel/int3472/Makefile index a8aba07bf1dc..103661e6685d 100644 --- a/drivers/platform/x86/intel/int3472/Makefile +++ b/drivers/platform/x86/intel/int3472/Makefile @@ -1,7 +1,8 @@ obj-$(CONFIG_INTEL_SKL_INT3472) += intel_skl_int3472_discrete.o \ intel_skl_int3472_tps68470.o \ intel_skl_int3472_common.o -intel_skl_int3472_discrete-y := discrete.o clk_and_regulator.o led.o +intel_skl_int3472_discrete-y := discrete.o discrete_quirks.o \ + clk_and_regulator.o led.o intel_skl_int3472_tps68470-y := tps68470.o tps68470_board_data.o intel_skl_int3472_common-y += common.o diff --git a/drivers/platform/x86/intel/int3472/clk_and_regulator.c b/drivers/platform/x86/intel/int3472/clk_and_regulator.c index 5f6c66215f63..374a99dea7d1 100644 --- a/drivers/platform/x86/intel/int3472/clk_and_regulator.c +++ b/drivers/platform/x86/intel/int3472/clk_and_regulator.c @@ -5,7 +5,6 @@ #include #include #include -#include #include #include #include @@ -205,37 +204,14 @@ static const char * const skl_int3472_regulator_map_supplies[] = { static_assert(ARRAY_SIZE(skl_int3472_regulator_map_supplies) == GPIO_REGULATOR_SUPPLY_MAP_COUNT); -/* - * On some models there is a single GPIO regulator which is shared between - * sensors and only listed in the ACPI resources of one sensor. - * This DMI table contains the name of the second sensor. This is used to add - * entries for the second sensor to the supply_map. - */ -static const struct dmi_system_id skl_int3472_regulator_second_sensor[] = { - { - /* Lenovo Miix 510-12IKB */ - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), - DMI_MATCH(DMI_PRODUCT_VERSION, "MIIX 510-12IKB"), - }, - .driver_data = "i2c-OVTI2680:00", - }, - { } -}; - int skl_int3472_register_regulator(struct int3472_discrete_device *int3472, - struct gpio_desc *gpio) + struct gpio_desc *gpio, + const char *second_sensor) { struct regulator_init_data init_data = { }; struct regulator_config cfg = { }; - const char *second_sensor = NULL; - const struct dmi_system_id *id; int i, j; - id = dmi_first_match(skl_int3472_regulator_second_sensor); - if (id) - second_sensor = id->driver_data; - for (i = 0, j = 0; i < ARRAY_SIZE(skl_int3472_regulator_map_supplies); i++) { int3472->regulator.supply_map[j].supply = skl_int3472_regulator_map_supplies[i]; int3472->regulator.supply_map[j].dev_name = int3472->sensor_name; diff --git a/drivers/platform/x86/intel/int3472/common.h b/drivers/platform/x86/intel/int3472/common.h index e0fa34be8a07..3728f3864a84 100644 --- a/drivers/platform/x86/intel/int3472/common.h +++ b/drivers/platform/x86/intel/int3472/common.h @@ -48,6 +48,7 @@ container_of(clk, struct int3472_discrete_device, clock) struct acpi_device; +struct dmi_system_id; struct i2c_client; struct platform_device; @@ -68,6 +69,11 @@ struct int3472_cldb { u8 reserved2[17]; }; +struct int3472_discrete_quirks { + /* For models where AVDD GPIO is shared between sensors */ + const char *avdd_second_sensor; +}; + struct int3472_discrete_device { struct acpi_device *adev; struct device *dev; @@ -100,11 +106,15 @@ struct int3472_discrete_device { struct gpio_desc *gpio; } pled; + struct int3472_discrete_quirks quirks; + unsigned int ngpios; /* how many GPIOs have we seen */ unsigned int n_sensor_gpios; /* how many have we mapped to sensor */ struct gpiod_lookup_table gpios; }; +extern const struct dmi_system_id skl_int3472_discrete_quirks[]; + union acpi_object *skl_int3472_get_acpi_buffer(struct acpi_device *adev, char *id); int skl_int3472_fill_cldb(struct acpi_device *adev, struct int3472_cldb *cldb); @@ -118,7 +128,8 @@ int skl_int3472_register_dsm_clock(struct int3472_discrete_device *int3472); void skl_int3472_unregister_clock(struct int3472_discrete_device *int3472); int skl_int3472_register_regulator(struct int3472_discrete_device *int3472, - struct gpio_desc *gpio); + struct gpio_desc *gpio, + const char *second_sensor); void skl_int3472_unregister_regulator(struct int3472_discrete_device *int3472); int skl_int3472_register_pled(struct int3472_discrete_device *int3472, struct gpio_desc *gpio); diff --git a/drivers/platform/x86/intel/int3472/discrete.c b/drivers/platform/x86/intel/int3472/discrete.c index 30ff8f3ea1f5..cbf39459bdf0 100644 --- a/drivers/platform/x86/intel/int3472/discrete.c +++ b/drivers/platform/x86/intel/int3472/discrete.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -310,7 +311,8 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares, break; case INT3472_GPIO_TYPE_POWER_ENABLE: - ret = skl_int3472_register_regulator(int3472, gpio); + ret = skl_int3472_register_regulator(int3472, gpio, + int3472->quirks.avdd_second_sensor); if (ret) err_msg = "Failed to map regulator to sensor\n"; @@ -378,13 +380,19 @@ static void skl_int3472_discrete_remove(struct platform_device *pdev) static int skl_int3472_discrete_probe(struct platform_device *pdev) { struct acpi_device *adev = ACPI_COMPANION(&pdev->dev); + const struct int3472_discrete_quirks *quirks = NULL; struct int3472_discrete_device *int3472; + const struct dmi_system_id *id; struct int3472_cldb cldb; int ret; if (!adev) return -ENODEV; + id = dmi_first_match(skl_int3472_discrete_quirks); + if (id) + quirks = id->driver_data; + ret = skl_int3472_fill_cldb(adev, &cldb); if (ret) { dev_err(&pdev->dev, "Couldn't fill CLDB structure\n"); @@ -408,6 +416,9 @@ static int skl_int3472_discrete_probe(struct platform_device *pdev) platform_set_drvdata(pdev, int3472); int3472->clock.imgclk_index = cldb.clock_source; + if (quirks) + int3472->quirks = *quirks; + ret = skl_int3472_get_sensor_adev_and_name(&pdev->dev, &int3472->sensor, &int3472->sensor_name); if (ret) diff --git a/drivers/platform/x86/intel/int3472/discrete_quirks.c b/drivers/platform/x86/intel/int3472/discrete_quirks.c new file mode 100644 index 000000000000..bf88863803b2 --- /dev/null +++ b/drivers/platform/x86/intel/int3472/discrete_quirks.c @@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Author: Hans de Goede */ + +#include + +#include "common.h" + +static const struct int3472_discrete_quirks lenovo_miix_510_quirks = { + .avdd_second_sensor = "i2c-OVTI2680:00", +}; + +const struct dmi_system_id skl_int3472_discrete_quirks[] = { + { + /* Lenovo Miix 510-12IKB */ + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), + DMI_MATCH(DMI_PRODUCT_VERSION, "MIIX 510-12IKB"), + }, + .driver_data = (void *)&lenovo_miix_510_quirks, + }, + { } +}; From patchwork Thu Apr 17 11:13:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 882127 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD627238C09 for ; Thu, 17 Apr 2025 11:14:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744888460; cv=none; b=jxi7UDqLMHbMGOTaO7r/wp1mlVL5h/c17j5NBCZ6kS6GS2SrPl3dUAxFIH7U5L2SelKoT/OHHgvywEDOYsEAyU7qEZpTLKaSwX0K5TMh3tynM76IFgeGOtqywyOZwnog9npoMlYef2KQNIArgd7IPta7SSNBZwmPCbD7eWBhNPE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744888460; c=relaxed/simple; bh=vQUQ3xWitcQfclEhWE+eK4nKYNxFHrBz8fWexvOXmtY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hHJbuMiw36H58j/PHvNxwA/Dt9GqbaXgiMpmiwNXfKNG8b+xXfFtL2R/M/EJ2cV8Hko4tE6SQ3xve7afcpkTss/sJyRLWzGk9TJA6pDvBpGppM6BJVQlXSgLqEsb9MDjEc9pSd3fIkVKIGUGEBQVdqjiy4XiUcZs7FCviCleyGY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=f0i9yZYt; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="f0i9yZYt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1744888453; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r0Z80TVPQj2ImieAekdFiPa2qwodXN0cTReqBlA11yA=; b=f0i9yZYtD2bYrdGRYDtRr8O24WcebuolmjJEFHr/zJdd9RFRio2Q+1g8oXJUZIArj0/1Oj Gfmpn8M4arlep+4DMvlcH1vkveV7UYVOvwURVr0JTD1gECKC6CFo/j0FZO/sCa2N1AbMnR IMECSHJjSbr6SsogSirRT7xgg3j38eo= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-186-VEYHXz5kPQan_hNdSOP5dw-1; Thu, 17 Apr 2025 07:14:10 -0400 X-MC-Unique: VEYHXz5kPQan_hNdSOP5dw-1 X-Mimecast-MFC-AGG-ID: VEYHXz5kPQan_hNdSOP5dw_1744888448 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id CD6A618001CA; Thu, 17 Apr 2025 11:14:08 +0000 (UTC) Received: from localhost.localdomain (unknown [10.44.34.7]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 626CB18001EA; Thu, 17 Apr 2025 11:14:05 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andy Shevchenko Cc: Hans de Goede , Dan Scally , Alan Stern , Sakari Ailus , Hao Yao , Bingbu Cao , Duane , platform-driver-x86@vger.kernel.org, linux-media@vger.kernel.org Subject: [PATCH v4 5/9] platform/x86: int3472: Make regulator supply name configurable Date: Thu, 17 Apr 2025 13:13:33 +0200 Message-ID: <20250417111337.38142-6-hdegoede@redhat.com> In-Reply-To: <20250417111337.38142-1-hdegoede@redhat.com> References: <20250417111337.38142-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 This is a preparation patch for registering multiple regulators, which requires a different supply-name for each regulator. Make supply-name a parameter to skl_int3472_register_regulator() and use con-id to set it so that the existing int3472_gpio_map remapping can be used with it. Since supply-name is a parameter now, drop the fixed skl_int3472_regulator_map_supplies[] array and instead add lower- and upper-case mappings of the passed-in supply-name to the regulator. Signed-off-by: Hans de Goede --- Changes in v4: - At static_assert(GPIO_REGULATOR_SUPPLY_MAP_COUNT == 2) since the code assumes that Changes in v3: - Add comment explaining value of 12 in GPIO_REGULATOR_NAME_LENGTH - Some other comment / commitmsg tweaks Changes in v2: - Use E2BIG instead of EOVERFLOW for too long supply-names --- .../x86/intel/int3472/clk_and_regulator.c | 50 ++++++++----------- drivers/platform/x86/intel/int3472/common.h | 8 ++- drivers/platform/x86/intel/int3472/discrete.c | 4 +- 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/drivers/platform/x86/intel/int3472/clk_and_regulator.c b/drivers/platform/x86/intel/int3472/clk_and_regulator.c index 374a99dea7d1..b7a1abc2919c 100644 --- a/drivers/platform/x86/intel/int3472/clk_and_regulator.c +++ b/drivers/platform/x86/intel/int3472/clk_and_regulator.c @@ -185,42 +185,37 @@ void skl_int3472_unregister_clock(struct int3472_discrete_device *int3472) clk_unregister(int3472->clock.clk); } -/* - * The INT3472 device is going to be the only supplier of a regulator for - * the sensor device. But unlike the clk framework the regulator framework - * does not allow matching by consumer-device-name only. - * - * Ideally all sensor drivers would use "avdd" as supply-id. But for drivers - * where this cannot be changed because another supply-id is already used in - * e.g. DeviceTree files an alias for the other supply-id can be added here. - * - * Do not forget to update GPIO_REGULATOR_SUPPLY_MAP_COUNT when changing this. - */ -static const char * const skl_int3472_regulator_map_supplies[] = { - "avdd", - "AVDD", -}; - -static_assert(ARRAY_SIZE(skl_int3472_regulator_map_supplies) == - GPIO_REGULATOR_SUPPLY_MAP_COUNT); - int skl_int3472_register_regulator(struct int3472_discrete_device *int3472, struct gpio_desc *gpio, + const char *supply_name, const char *second_sensor) { struct regulator_init_data init_data = { }; + struct int3472_gpio_regulator *regulator; struct regulator_config cfg = { }; int i, j; - for (i = 0, j = 0; i < ARRAY_SIZE(skl_int3472_regulator_map_supplies); i++) { - int3472->regulator.supply_map[j].supply = skl_int3472_regulator_map_supplies[i]; - int3472->regulator.supply_map[j].dev_name = int3472->sensor_name; + if (strlen(supply_name) >= GPIO_SUPPPLY_NAME_LENGTH) { + dev_err(int3472->dev, "supply-name '%s' length too long\n", supply_name); + return -E2BIG; + } + + regulator = &int3472->regulator; + string_upper(regulator->supply_name_upper, supply_name); + + /* The below code assume that map-count is 2 (upper- and lower-case) */ + static_assert(GPIO_REGULATOR_SUPPLY_MAP_COUNT == 2); + + for (i = 0, j = 0; i < GPIO_REGULATOR_SUPPLY_MAP_COUNT; i++) { + const char *supply = i ? regulator->supply_name_upper : supply_name; + + regulator->supply_map[j].supply = supply; + regulator->supply_map[j].dev_name = int3472->sensor_name; j++; if (second_sensor) { - int3472->regulator.supply_map[j].supply = - skl_int3472_regulator_map_supplies[i]; - int3472->regulator.supply_map[j].dev_name = second_sensor; + regulator->supply_map[j].supply = supply; + regulator->supply_map[j].dev_name = second_sensor; j++; } } @@ -229,9 +224,8 @@ int skl_int3472_register_regulator(struct int3472_discrete_device *int3472, init_data.consumer_supplies = int3472->regulator.supply_map; init_data.num_consumer_supplies = j; - snprintf(int3472->regulator.regulator_name, - sizeof(int3472->regulator.regulator_name), "%s-regulator", - acpi_dev_name(int3472->adev)); + snprintf(regulator->regulator_name, sizeof(regulator->regulator_name), "%s-%s", + acpi_dev_name(int3472->adev), supply_name); int3472->regulator.rdesc = INT3472_REGULATOR( int3472->regulator.regulator_name, diff --git a/drivers/platform/x86/intel/int3472/common.h b/drivers/platform/x86/intel/int3472/common.h index 3728f3864a84..b750a309ee16 100644 --- a/drivers/platform/x86/intel/int3472/common.h +++ b/drivers/platform/x86/intel/int3472/common.h @@ -26,7 +26,11 @@ #define INT3472_PDEV_MAX_NAME_LEN 23 #define INT3472_MAX_SENSOR_GPIOS 3 -#define GPIO_REGULATOR_NAME_LENGTH 21 +/* E.g. "avdd\0" */ +#define GPIO_SUPPPLY_NAME_LENGTH 5 +/* 12 chars for acpi_dev_name() + "-", e.g. "ABCD1234:00-" */ +#define GPIO_REGULATOR_NAME_LENGTH (12 + GPIO_SUPPPLY_NAME_LENGTH) +/* lower- and upper-case mapping */ #define GPIO_REGULATOR_SUPPLY_MAP_COUNT 2 #define INT3472_LED_MAX_NAME_LEN 32 @@ -85,6 +89,7 @@ struct int3472_discrete_device { struct int3472_gpio_regulator { /* SUPPLY_MAP_COUNT * 2 to make room for second sensor mappings */ struct regulator_consumer_supply supply_map[GPIO_REGULATOR_SUPPLY_MAP_COUNT * 2]; + char supply_name_upper[GPIO_SUPPPLY_NAME_LENGTH]; char regulator_name[GPIO_REGULATOR_NAME_LENGTH]; struct regulator_dev *rdev; struct regulator_desc rdesc; @@ -129,6 +134,7 @@ void skl_int3472_unregister_clock(struct int3472_discrete_device *int3472); int skl_int3472_register_regulator(struct int3472_discrete_device *int3472, struct gpio_desc *gpio, + const char *supply_name, const char *second_sensor); void skl_int3472_unregister_regulator(struct int3472_discrete_device *int3472); diff --git a/drivers/platform/x86/intel/int3472/discrete.c b/drivers/platform/x86/intel/int3472/discrete.c index cbf39459bdf0..f6dae82739e5 100644 --- a/drivers/platform/x86/intel/int3472/discrete.c +++ b/drivers/platform/x86/intel/int3472/discrete.c @@ -188,7 +188,7 @@ static void int3472_get_con_id_and_polarity(struct acpi_device *adev, u8 *type, *gpio_flags = GPIO_ACTIVE_HIGH; break; case INT3472_GPIO_TYPE_POWER_ENABLE: - *con_id = "power-enable"; + *con_id = "avdd"; *gpio_flags = GPIO_ACTIVE_HIGH; break; default: @@ -311,7 +311,7 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares, break; case INT3472_GPIO_TYPE_POWER_ENABLE: - ret = skl_int3472_register_regulator(int3472, gpio, + ret = skl_int3472_register_regulator(int3472, gpio, con_id, int3472->quirks.avdd_second_sensor); if (ret) err_msg = "Failed to map regulator to sensor\n"; From patchwork Thu Apr 17 11:13:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 882504 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9DEE223816B for ; Thu, 17 Apr 2025 11:14:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744888463; cv=none; b=oxc9ZdlNwwxAx7hfLdqCKVjGNT6XSv5kohA8Az/Xgx54LDxIr+PdX4cp8E5gwI3YRHZeM+rwN+8Tk9Ze7cL7/m2zBhaohRtTXm+dSoycV8g+ON/Kd/7w1qvJX50WbTrvlXGmuP2lMSrGSp+ymGXULRT8lnjn/VgtbvafoeIukxQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744888463; c=relaxed/simple; bh=9Pqv4lsCcy8j31avKT95eOF7DOAcHJpEGFfVfIDE2fA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KxOkE2Q5W4++VM64Lhj9RKesfyKkmlEOBehj2r1G5Q8iDVs8+nZ9hfRuhLHZfbCArIx8tcFGak1ATgp+ekTkRQTis1qaeQtnVZp51peza9McSnRtt6b2AGWLYqLWpeTxxhfMOCgkJxcE2TdVWB0zhzxDnc23Mz82xw0uIPbYKm4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=E4FpFE1N; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="E4FpFE1N" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1744888457; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Isioa2l6nxUeLsHPfGnYDLBRr0Pg9PTO8XS3qjgGg7U=; b=E4FpFE1NOmUKFSpi1oYKMAD6LAzxQk4vSqQNeY2tRpHnKQiCz+SgvSGN5qFH55OfHD7Mqo I4RibgGjd2rKh4h4XrHT3wEPiwQZ9YVvWFB0oWvRPyA7GTuaFCv6DNtIAGHH4eUXG2spci MW8F/Tx3AZOQJ9s/l4TaPABnzjFaA5s= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-313-WB1W9JqHNFCZAMbQvWL5Xg-1; Thu, 17 Apr 2025 07:14:14 -0400 X-MC-Unique: WB1W9JqHNFCZAMbQvWL5Xg-1 X-Mimecast-MFC-AGG-ID: WB1W9JqHNFCZAMbQvWL5Xg_1744888453 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C349A18001D5; Thu, 17 Apr 2025 11:14:12 +0000 (UTC) Received: from localhost.localdomain (unknown [10.44.34.7]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 54AD4180045C; Thu, 17 Apr 2025 11:14:09 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andy Shevchenko Cc: Hans de Goede , Dan Scally , Alan Stern , Sakari Ailus , Hao Yao , Bingbu Cao , Duane , platform-driver-x86@vger.kernel.org, linux-media@vger.kernel.org Subject: [PATCH v4 6/9] platform/x86: int3472: Avoid GPIO regulator spikes Date: Thu, 17 Apr 2025 13:13:34 +0200 Message-ID: <20250417111337.38142-7-hdegoede@redhat.com> In-Reply-To: <20250417111337.38142-1-hdegoede@redhat.com> References: <20250417111337.38142-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Avoid the GPIO controlling the avdd regulator being driven low or high for a very short time leading to spikes by adding an enable delay of 2 ms and a minimum off to on delay of also 2 ms. Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede --- Changes in v3: - Add a comment to the defines int3472/common.h explaining where the 2 ms comes from --- .../platform/x86/intel/int3472/clk_and_regulator.c | 7 ++++--- drivers/platform/x86/intel/int3472/common.h | 13 ++++++++++++- drivers/platform/x86/intel/int3472/discrete.c | 4 +++- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/drivers/platform/x86/intel/int3472/clk_and_regulator.c b/drivers/platform/x86/intel/int3472/clk_and_regulator.c index b7a1abc2919c..9f9f2c52e026 100644 --- a/drivers/platform/x86/intel/int3472/clk_and_regulator.c +++ b/drivers/platform/x86/intel/int3472/clk_and_regulator.c @@ -187,6 +187,7 @@ void skl_int3472_unregister_clock(struct int3472_discrete_device *int3472) int skl_int3472_register_regulator(struct int3472_discrete_device *int3472, struct gpio_desc *gpio, + unsigned int enable_time, const char *supply_name, const char *second_sensor) { @@ -227,9 +228,9 @@ int skl_int3472_register_regulator(struct int3472_discrete_device *int3472, snprintf(regulator->regulator_name, sizeof(regulator->regulator_name), "%s-%s", acpi_dev_name(int3472->adev), supply_name); - int3472->regulator.rdesc = INT3472_REGULATOR( - int3472->regulator.regulator_name, - &int3472_gpio_regulator_ops); + regulator->rdesc = INT3472_REGULATOR(regulator->regulator_name, + &int3472_gpio_regulator_ops, + enable_time, GPIO_REGULATOR_OFF_ON_DELAY); cfg.dev = &int3472->adev->dev; cfg.init_data = &init_data; diff --git a/drivers/platform/x86/intel/int3472/common.h b/drivers/platform/x86/intel/int3472/common.h index b750a309ee16..c3b28424af6e 100644 --- a/drivers/platform/x86/intel/int3472/common.h +++ b/drivers/platform/x86/intel/int3472/common.h @@ -32,17 +32,27 @@ #define GPIO_REGULATOR_NAME_LENGTH (12 + GPIO_SUPPPLY_NAME_LENGTH) /* lower- and upper-case mapping */ #define GPIO_REGULATOR_SUPPLY_MAP_COUNT 2 +/* + * Ensure the GPIO is driven low/high for at least 2 ms before changing. + * + * 2 ms has been chosen because it is the minimum time ovXXXX sensors need to + * have their reset line driven logical high to properly register a reset. + */ +#define GPIO_REGULATOR_ENABLE_TIME (2 * USEC_PER_MSEC) +#define GPIO_REGULATOR_OFF_ON_DELAY (2 * USEC_PER_MSEC) #define INT3472_LED_MAX_NAME_LEN 32 #define CIO2_SENSOR_SSDB_MCLKSPEED_OFFSET 86 -#define INT3472_REGULATOR(_name, _ops) \ +#define INT3472_REGULATOR(_name, _ops, _enable_time, _off_on_delay) \ (const struct regulator_desc) { \ .name = _name, \ .type = REGULATOR_VOLTAGE, \ .ops = _ops, \ .owner = THIS_MODULE, \ + .enable_time = _enable_time, \ + .off_on_delay = _off_on_delay, \ } #define to_int3472_clk(hw) \ @@ -134,6 +144,7 @@ void skl_int3472_unregister_clock(struct int3472_discrete_device *int3472); int skl_int3472_register_regulator(struct int3472_discrete_device *int3472, struct gpio_desc *gpio, + unsigned int enable_time, const char *supply_name, const char *second_sensor); void skl_int3472_unregister_regulator(struct int3472_discrete_device *int3472); diff --git a/drivers/platform/x86/intel/int3472/discrete.c b/drivers/platform/x86/intel/int3472/discrete.c index f6dae82739e5..a2db4fae0e6d 100644 --- a/drivers/platform/x86/intel/int3472/discrete.c +++ b/drivers/platform/x86/intel/int3472/discrete.c @@ -311,7 +311,9 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares, break; case INT3472_GPIO_TYPE_POWER_ENABLE: - ret = skl_int3472_register_regulator(int3472, gpio, con_id, + ret = skl_int3472_register_regulator(int3472, gpio, + GPIO_REGULATOR_ENABLE_TIME, + con_id, int3472->quirks.avdd_second_sensor); if (ret) err_msg = "Failed to map regulator to sensor\n"; From patchwork Thu Apr 17 11:13:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 882126 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 272BA2356D3 for ; Thu, 17 Apr 2025 11:14:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744888469; cv=none; b=aWqtRmNeZGX0FIf7vphA2oQt/dPb3NkNPrubcT8NLHejTCv0R9lI5ADsGi6xzq/jvO1o0Y0S1VUtECTH3POS0bhC9LifIQtmfRAWKSa2VPWvwQdC3wDuOsmWmUuSKssZPfxwXvnHpVeHL9K5B6XuLsgNuDAI/0IlHIfT4h2ZIqo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744888469; c=relaxed/simple; bh=w/Mt7SlvyV3QchjI7CrSK4cbdrSwtJE1ru3BETF5cdM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=C8EKmFaXaUBQJQlH9kZigdaMQZZyMnYrB6XHyzm8En/FfWibhbq9VJxIaLyRdbRfnAhm79ThNdOrTF1Z5IGbmEBUR9dhInTVQnDvQ4lX+1ltVzk+O7iMut8hE6RofKBOA/uaeAuXQtIB/IFlP8M83janaLGW4zUvEXw8QlCIelc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=SozNbEwB; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="SozNbEwB" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1744888463; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aWcTrlTsyHs4yeQjujJcs6sZtOp6mXv0zqpJY40ampc=; b=SozNbEwB6KQ/F0PsNd91Py5BbPVna/Z1gYC1kpItucJComQs1AGnsBmFkNcXsUs0xvat08 ZD/1ILKyUFh0HPNE5RZ/mZx9P5aK1bY66JYVWeHo8qLTxIfwJY/jrgldmMK/po+6Cqqz62 zdiqtaCWOh5myLaTYL/btfZRqk32650= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-249-Q1lbvebFNcKePRL2Bf0EBw-1; Thu, 17 Apr 2025 07:14:18 -0400 X-MC-Unique: Q1lbvebFNcKePRL2Bf0EBw-1 X-Mimecast-MFC-AGG-ID: Q1lbvebFNcKePRL2Bf0EBw_1744888457 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id BD670195608E; Thu, 17 Apr 2025 11:14:16 +0000 (UTC) Received: from localhost.localdomain (unknown [10.44.34.7]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 499EB180045C; Thu, 17 Apr 2025 11:14:13 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andy Shevchenko Cc: Hans de Goede , Dan Scally , Alan Stern , Sakari Ailus , Hao Yao , Bingbu Cao , Duane , platform-driver-x86@vger.kernel.org, linux-media@vger.kernel.org Subject: [PATCH v4 7/9] platform/x86: int3472: Prepare for registering more than 1 GPIO regulator Date: Thu, 17 Apr 2025 13:13:35 +0200 Message-ID: <20250417111337.38142-8-hdegoede@redhat.com> In-Reply-To: <20250417111337.38142-1-hdegoede@redhat.com> References: <20250417111337.38142-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Prepare the discrete code for registering more than 1 GPIO regulator. Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede --- Changes in v3: - s/n_regulators/n_regulator_gpios/ --- .../x86/intel/int3472/clk_and_regulator.c | 21 ++++++++++++------- drivers/platform/x86/intel/int3472/common.h | 20 +++++++++++------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/drivers/platform/x86/intel/int3472/clk_and_regulator.c b/drivers/platform/x86/intel/int3472/clk_and_regulator.c index 9f9f2c52e026..33319404f266 100644 --- a/drivers/platform/x86/intel/int3472/clk_and_regulator.c +++ b/drivers/platform/x86/intel/int3472/clk_and_regulator.c @@ -196,12 +196,17 @@ int skl_int3472_register_regulator(struct int3472_discrete_device *int3472, struct regulator_config cfg = { }; int i, j; + if (int3472->n_regulator_gpios >= INT3472_MAX_REGULATORS) { + dev_err(int3472->dev, "Too many regulators mapped\n"); + return -EINVAL; + } + if (strlen(supply_name) >= GPIO_SUPPPLY_NAME_LENGTH) { dev_err(int3472->dev, "supply-name '%s' length too long\n", supply_name); return -E2BIG; } - regulator = &int3472->regulator; + regulator = &int3472->regulators[int3472->n_regulator_gpios]; string_upper(regulator->supply_name_upper, supply_name); /* The below code assume that map-count is 2 (upper- and lower-case) */ @@ -222,7 +227,7 @@ int skl_int3472_register_regulator(struct int3472_discrete_device *int3472, } init_data.constraints.valid_ops_mask = REGULATOR_CHANGE_STATUS; - init_data.consumer_supplies = int3472->regulator.supply_map; + init_data.consumer_supplies = regulator->supply_map; init_data.num_consumer_supplies = j; snprintf(regulator->regulator_name, sizeof(regulator->regulator_name), "%s-%s", @@ -236,14 +241,16 @@ int skl_int3472_register_regulator(struct int3472_discrete_device *int3472, cfg.init_data = &init_data; cfg.ena_gpiod = gpio; - int3472->regulator.rdev = regulator_register(int3472->dev, - &int3472->regulator.rdesc, - &cfg); + regulator->rdev = regulator_register(int3472->dev, ®ulator->rdesc, &cfg); + if (IS_ERR(regulator->rdev)) + return PTR_ERR(regulator->rdev); - return PTR_ERR_OR_ZERO(int3472->regulator.rdev); + int3472->n_regulator_gpios++; + return 0; } void skl_int3472_unregister_regulator(struct int3472_discrete_device *int3472) { - regulator_unregister(int3472->regulator.rdev); + for (int i = 0; i < int3472->n_regulator_gpios; i++) + regulator_unregister(int3472->regulators[i].rdev); } diff --git a/drivers/platform/x86/intel/int3472/common.h b/drivers/platform/x86/intel/int3472/common.h index c3b28424af6e..e88a22a6f81b 100644 --- a/drivers/platform/x86/intel/int3472/common.h +++ b/drivers/platform/x86/intel/int3472/common.h @@ -25,6 +25,7 @@ #define INT3472_PDEV_MAX_NAME_LEN 23 #define INT3472_MAX_SENSOR_GPIOS 3 +#define INT3472_MAX_REGULATORS 3 /* E.g. "avdd\0" */ #define GPIO_SUPPPLY_NAME_LENGTH 5 @@ -88,6 +89,15 @@ struct int3472_discrete_quirks { const char *avdd_second_sensor; }; +struct int3472_gpio_regulator { + /* SUPPLY_MAP_COUNT * 2 to make room for second sensor mappings */ + struct regulator_consumer_supply supply_map[GPIO_REGULATOR_SUPPLY_MAP_COUNT * 2]; + char supply_name_upper[GPIO_SUPPPLY_NAME_LENGTH]; + char regulator_name[GPIO_REGULATOR_NAME_LENGTH]; + struct regulator_dev *rdev; + struct regulator_desc rdesc; +}; + struct int3472_discrete_device { struct acpi_device *adev; struct device *dev; @@ -96,14 +106,7 @@ struct int3472_discrete_device { const struct int3472_sensor_config *sensor_config; - struct int3472_gpio_regulator { - /* SUPPLY_MAP_COUNT * 2 to make room for second sensor mappings */ - struct regulator_consumer_supply supply_map[GPIO_REGULATOR_SUPPLY_MAP_COUNT * 2]; - char supply_name_upper[GPIO_SUPPPLY_NAME_LENGTH]; - char regulator_name[GPIO_REGULATOR_NAME_LENGTH]; - struct regulator_dev *rdev; - struct regulator_desc rdesc; - } regulator; + struct int3472_gpio_regulator regulators[INT3472_MAX_REGULATORS]; struct int3472_clock { struct clk *clk; @@ -125,6 +128,7 @@ struct int3472_discrete_device { unsigned int ngpios; /* how many GPIOs have we seen */ unsigned int n_sensor_gpios; /* how many have we mapped to sensor */ + unsigned int n_regulator_gpios; /* how many have we mapped to a regulator */ struct gpiod_lookup_table gpios; }; From patchwork Thu Apr 17 11:13:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 882503 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9E63A237A3C for ; Thu, 17 Apr 2025 11:14:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744888473; cv=none; b=C47+/qgUMpr2DLnPzgeuSsUYOEOGPEyZgHm7MXG7wahsDc5s3KYEUFhUAJ0jOjGRo3/NI6vgHE0cYdU9fgchgth/pclwauX2CqgQGUM7gj/SzuhxpwquvchFlYVK4XBkrORJ79JDhK6w7kw4q2ceJV/FES5bGZ3MuYyudo6YsYw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744888473; c=relaxed/simple; bh=69wn8HkIVTYm+j/kCuRtrse0u6eNczG36e/pbY8h/NA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MNUmwLYlq2siPlj4VdPqJe7LXlilroDhEzEhaLW4H51jDI/osf9gPI5zybdKr4e08qpuLixMcXFlLNPwU+C9UedqA6qX3HGoZIa3GaOTlqoxvfrFC76UiVWkz+A0Mukr6jof98BpAcAPUU6ywBILxqbO5vz/oVT9jEMJP6kyPcE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=HsYaSJFI; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="HsYaSJFI" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1744888467; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5Y4lc9+AomjcJoxuaSDmHbVB6ytTYBYkEPBKNmLGtF8=; b=HsYaSJFISflZCbtSBkVuc7ssXh+TSPzGk6nLn2MEZUGzZ9vCDpHho8BfN1IbF++n0LJzZC zKzhxo/OmL6pQHtOssE7bOZq1AFRu2lFIRRh8LNwCo62fCWL894SNJLLJJXuk+o9kYsYdx 5E+vcSR4PQRyA1mgYoMnAiN+vRbdZk8= Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-280-5tu5eUJbOSuEhxHeV2Jhdw-1; Thu, 17 Apr 2025 07:14:22 -0400 X-MC-Unique: 5tu5eUJbOSuEhxHeV2Jhdw-1 X-Mimecast-MFC-AGG-ID: 5tu5eUJbOSuEhxHeV2Jhdw_1744888461 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id F3ECF19560B1; Thu, 17 Apr 2025 11:14:20 +0000 (UTC) Received: from localhost.localdomain (unknown [10.44.34.7]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4489818002AD; Thu, 17 Apr 2025 11:14:17 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andy Shevchenko Cc: Hans de Goede , Dan Scally , Alan Stern , Sakari Ailus , Hao Yao , Bingbu Cao , Duane , platform-driver-x86@vger.kernel.org, linux-media@vger.kernel.org Subject: [PATCH v4 8/9] platform/x86: int3472: Add handshake pin support Date: Thu, 17 Apr 2025 13:13:36 +0200 Message-ID: <20250417111337.38142-9-hdegoede@redhat.com> In-Reply-To: <20250417111337.38142-1-hdegoede@redhat.com> References: <20250417111337.38142-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 New Intel Meteor Lake based laptops with IPU6 cameras have a new type 0x12 pin defined in the INT3472 sensor companion device which describes the sensor's GPIOs. This pin is primarily used on designs with a Lattice FPGA chip which is capable of running the sensor independently of the main CPU for features like presence detection. This pin needs to be driven high to make the FPGA run the power-on sequence of the sensor. After driving the pin high, the FPGA "firmware" needs 25ms to complete the power-on sequence. Add support for this modelling the handshake pin as a GPIO driven "dvdd" regulator with a 25 ms enable time. This model was chosen because: 1. Sensor chips don't have a handshake pin, so we need to abstract this in some way which does not require modification to the sensor drivers, sensor drivers using the bulk-regulator API to get avdd + vddio + dvdd is normal. So this will work to get the right value set to the handshake pin without requiring sensor driver modifications. 2. Sensors typically wait only a small time for the sensor to power-on after de-asserting reset. Not the 25ms the Lattice chip requires. Using the regulator framework's enable_time allows hiding the need for this delay from the sensor drivers. Link: https://lore.kernel.org/platform-driver-x86/59f672c3-6d87-4ec7-9b7f-f44fe2cce934@redhat.com/ Link: https://bugzilla.redhat.com/show_bug.cgi?id=2341731 Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede --- Changes in v4: - Use unique error messages for power-enable vs handshake skl_int3472_register_regulator() failures - Drop setting of constraints.enable_time. enable_time already gets set in struct regulator_desc (missed left-over from an older patch version) Changes in v3: - Small commitmsg improvements --- drivers/platform/x86/intel/int3472/common.h | 1 + drivers/platform/x86/intel/int3472/discrete.c | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/platform/x86/intel/int3472/common.h b/drivers/platform/x86/intel/int3472/common.h index e88a22a6f81b..56fb91dcc130 100644 --- a/drivers/platform/x86/intel/int3472/common.h +++ b/drivers/platform/x86/intel/int3472/common.h @@ -22,6 +22,7 @@ #define INT3472_GPIO_TYPE_POWER_ENABLE 0x0b #define INT3472_GPIO_TYPE_CLK_ENABLE 0x0c #define INT3472_GPIO_TYPE_PRIVACY_LED 0x0d +#define INT3472_GPIO_TYPE_HANDSHAKE 0x12 #define INT3472_PDEV_MAX_NAME_LEN 23 #define INT3472_MAX_SENSOR_GPIOS 3 diff --git a/drivers/platform/x86/intel/int3472/discrete.c b/drivers/platform/x86/intel/int3472/discrete.c index a2db4fae0e6d..bcc7bb122a56 100644 --- a/drivers/platform/x86/intel/int3472/discrete.c +++ b/drivers/platform/x86/intel/int3472/discrete.c @@ -191,6 +191,10 @@ static void int3472_get_con_id_and_polarity(struct acpi_device *adev, u8 *type, *con_id = "avdd"; *gpio_flags = GPIO_ACTIVE_HIGH; break; + case INT3472_GPIO_TYPE_HANDSHAKE: + *con_id = "dvdd"; + *gpio_flags = GPIO_ACTIVE_HIGH; + break; default: *con_id = "unknown"; *gpio_flags = GPIO_ACTIVE_HIGH; @@ -290,6 +294,7 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares, case INT3472_GPIO_TYPE_CLK_ENABLE: case INT3472_GPIO_TYPE_PRIVACY_LED: case INT3472_GPIO_TYPE_POWER_ENABLE: + case INT3472_GPIO_TYPE_HANDSHAKE: gpio = skl_int3472_gpiod_get_from_temp_lookup(int3472, agpio, con_id, gpio_flags); if (IS_ERR(gpio)) { ret = PTR_ERR(gpio); @@ -316,7 +321,16 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares, con_id, int3472->quirks.avdd_second_sensor); if (ret) - err_msg = "Failed to map regulator to sensor\n"; + err_msg = "Failed to map power-enable to sensor\n"; + + break; + case INT3472_GPIO_TYPE_HANDSHAKE: + /* Setups using a handshake pin need 25 ms enable delay */ + ret = skl_int3472_register_regulator(int3472, gpio, + 25 * USEC_PER_MSEC, + con_id, NULL); + if (ret) + err_msg = "Failed to map handshake to sensor\n"; break; default: /* Never reached */ From patchwork Thu Apr 17 11:13:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 882125 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5A99B238C18 for ; Thu, 17 Apr 2025 11:14:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744888475; cv=none; b=Q3eeqFZUZcjEyHisGyXHf0vARW7Cj8z6KB3N8bnf0nJfOQI5LHrnsSrGhdChPJXWnZ6rpMJQ0f5OISjhGlwq52KaXzyScwvG/cBLzFaxPohtmuPzQt+K4F0mMsqWksPjZoMWDxm1ZWl0+3siqX4p8JjF4wyaKQ6AY7EqEKyexGU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744888475; c=relaxed/simple; bh=4A1gHcjAmIV5ZH+g5WDpCt9GGv1Z7fyOyQagXYu8U8E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TG6TAj7nBovzKf2t/xTWeiLPhDjpbBVtTfexNe2sf8at5p6/32mCm173srXe3fFyXUEm5vV/qWTKmNGI+36cQiax/3dqPAcrWVgYSIM5q0fPe0+1DI2ggbTULH0BwZJgXrapgVSi/RmFivoCqXOfrP831c+Spqc1AILRx1VpDK0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=LOUnWDIr; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="LOUnWDIr" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1744888470; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FKgWBrGNN4/2FyqMIQl+z4/Z9VFWr/dDKLcwoAB3Sow=; b=LOUnWDIr5A/nVAkYjc/yFLnOexe/dHTRrCWFf0W1ax+a3WjtRoTWpN1jiDTPyV7kNqqeNz 9QpkcUe71/L5KQRtxEoiBXIQ3sa4ZZehAdCtNHrtwJMXHRE45U4VX4n0ZGRO4QYiq3n5LC kOi1eUOg9+SwJ16ADFsKldSd9XBBw9s= Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-665-ksIidirGM9m4K5Gmu6_3iQ-1; Thu, 17 Apr 2025 07:14:26 -0400 X-MC-Unique: ksIidirGM9m4K5Gmu6_3iQ-1 X-Mimecast-MFC-AGG-ID: ksIidirGM9m4K5Gmu6_3iQ_1744888464 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C87CE1956094; Thu, 17 Apr 2025 11:14:24 +0000 (UTC) Received: from localhost.localdomain (unknown [10.44.34.7]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5A962180045C; Thu, 17 Apr 2025 11:14:21 +0000 (UTC) From: Hans de Goede To: =?utf-8?q?Ilpo_J=C3=A4rvinen?= , Andy Shevchenko Cc: Hans de Goede , Dan Scally , Alan Stern , Sakari Ailus , Hao Yao , Bingbu Cao , Duane , platform-driver-x86@vger.kernel.org, linux-media@vger.kernel.org Subject: [PATCH v4 9/9] platform/x86: int3472: Debug log when remapping pins Date: Thu, 17 Apr 2025 13:13:37 +0200 Message-ID: <20250417111337.38142-10-hdegoede@redhat.com> In-Reply-To: <20250417111337.38142-1-hdegoede@redhat.com> References: <20250417111337.38142-1-hdegoede@redhat.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Debug log when remapping a pin/function because of a int3472_gpio_map[] match. Reviewed-by: Andy Shevchenko Signed-off-by: Hans de Goede --- drivers/platform/x86/intel/int3472/discrete.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/intel/int3472/discrete.c b/drivers/platform/x86/intel/int3472/discrete.c index bcc7bb122a56..394975f55d64 100644 --- a/drivers/platform/x86/intel/int3472/discrete.c +++ b/drivers/platform/x86/intel/int3472/discrete.c @@ -146,9 +146,10 @@ static const struct int3472_gpio_map int3472_gpio_map[] = { { "INT347E", INT3472_GPIO_TYPE_RESET, INT3472_GPIO_TYPE_RESET, false, "enable" }, }; -static void int3472_get_con_id_and_polarity(struct acpi_device *adev, u8 *type, +static void int3472_get_con_id_and_polarity(struct int3472_discrete_device *int3472, u8 *type, const char **con_id, unsigned long *gpio_flags) { + struct acpi_device *adev = int3472->sensor; unsigned int i; for (i = 0; i < ARRAY_SIZE(int3472_gpio_map); i++) { @@ -163,6 +164,9 @@ static void int3472_get_con_id_and_polarity(struct acpi_device *adev, u8 *type, if (!acpi_dev_hid_uid_match(adev, int3472_gpio_map[i].hid, NULL)) continue; + dev_dbg(int3472->dev, "mapping type 0x%02x pin to 0x%02x %s\n", + *type, int3472_gpio_map[i].type_to, int3472_gpio_map[i].con_id); + *type = int3472_gpio_map[i].type_to; *gpio_flags = int3472_gpio_map[i].polarity_low ? GPIO_ACTIVE_LOW : GPIO_ACTIVE_HIGH; @@ -267,7 +271,7 @@ static int skl_int3472_handle_gpio_resources(struct acpi_resource *ares, type = FIELD_GET(INT3472_GPIO_DSM_TYPE, obj->integer.value); - int3472_get_con_id_and_polarity(int3472->sensor, &type, &con_id, &gpio_flags); + int3472_get_con_id_and_polarity(int3472, &type, &con_id, &gpio_flags); pin = FIELD_GET(INT3472_GPIO_DSM_PIN, obj->integer.value); /* Pin field is not really used under Windows and wraps around at 8 bits */