From patchwork Tue Mar 25 16: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: 876212 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 BCB4825D8F6 for ; Tue, 25 Mar 2025 16:14:13 +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=1742919255; cv=none; b=F3V3ZGYM0s1cr/UtlTLo2PtRJOD/E84Dcy4Mf9S151vuwsQOCkRh0mKC/EJx+jKvyShol5nb0ePvOd7fSWgvJEve68VWnCJuSI7hYIoqoJEcs2Ig9T6/5l/bWnu+6Pz1DsWD0dEOqrvIGlBpMiy1APz7MKF4+CsdvMveT4HprUs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742919255; c=relaxed/simple; bh=rGAP4/7Rj1ngR4z4FUB+TYWC07B16KOr9KuTwLpO4c8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XNFoHJ9whMgTuZhsx9Qt5THKlCghtp19yRzYcS9alyy7NgfTSgtt6qKsC6YO1jfAe9yz4QbrxVijv+/pl22AKiEs/BKkrFXZWT3ws/6kO47rKrHS0kwwMRMVljgoHJHujHOkpwqeeF/TMz6ihaavJoDepo7+1HSCbYXnNPwFc4E= 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=PsnjUSe4; 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="PsnjUSe4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742919252; 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=nO6ZT1U/Rf9ad4UQYPeMfniKVuwydHICTsImQSi1AhI=; b=PsnjUSe4xy+SFAP5OhEIVTDq47UnNnqxqM8vcqfT5G333JA7/4LURAg3iEZdavAcLIhuLg 73/J3FuZD28CH59uckVUZyHObwZ14wGaMIPxNuQZGDDWRGd73VYKnjwXLi+KNpvsAe1uR6 o28k9AU1boi+RTo/8FO9iM0cHoS03jY= 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-84-jPrqRlysNK2T3_fuDYJW1g-1; Tue, 25 Mar 2025 12:14:08 -0400 X-MC-Unique: jPrqRlysNK2T3_fuDYJW1g-1 X-Mimecast-MFC-AGG-ID: jPrqRlysNK2T3_fuDYJW1g_1742919247 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 20D3D188EA50; Tue, 25 Mar 2025 16:13:58 +0000 (UTC) Received: from localhost.localdomain (unknown [10.44.32.136]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C6AEE180A802; Tue, 25 Mar 2025 16:13:54 +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 , platform-driver-x86@vger.kernel.org, linux-media@vger.kernel.org Subject: [PATCH 2/8] platform/x86: int3472: Stop setting a supply-name for GPIO regulators Date: Tue, 25 Mar 2025 17:13:34 +0100 Message-ID: <20250325161340.342192-3-hdegoede@redhat.com> In-Reply-To: <20250325161340.342192-1-hdegoede@redhat.com> References: <20250325161340.342192-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. 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 Tue Mar 25 16: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: 876213 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 1E4B825D1FA for ; Tue, 25 Mar 2025 16: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=1742919252; cv=none; b=cDCmrrrKj5ToMyEXxl+H3GbS8X9+qRdYN5eUj55QOA1o90fh5Vgv4C1rMUwYTPxOU8jGx2Rf/+Putn1oXIE3hhzjcf8uIHhSfsuWAMSfNAWwLnbj5Bb5JymhIOb90e2JaPpV/CSJjBmH7qXt4PX/dSy7nedfexSQdCYyCFmy6l0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742919252; c=relaxed/simple; bh=yLj4z+jqDXv/XbwjnmtZJj42RpgP/iMihdjydmeZqjY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MvgIZ38Ny0gMcFJUiC1ddsBXT6JGBRI28hTjbUaH1uT9Yz8mSQy0f3037XEyQV9jnIvxhVewzWCzMLpDQ4UOIWa84pnDsPtufLMI+EKV3t1Iul1SUHA6ZqzSuDgAu6W2LHxAdumw0D/7DcSdJDYFxNWSii7/1F+IxbOsPjVDkUI= 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=i+X+vT1O; 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="i+X+vT1O" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742919250; 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=XgP8EzgSaGGRGVenkO80yzIIdLrjN4fqfxhFtuQOr48=; b=i+X+vT1O3vBY6wNJKD71qAYX4nECV4pPQBnWEGB2rUId+w8IaLqAsLbmajF1ovVOMqErVr yeAYv5Uir6ILpFsdLifUNwAX1KcHeMC6ER49QwZ/MeGSEDWPC79k4dViZkWl083I8+xn1m Egv8PVGoh8yWoynoVb7AcLGJ2/P3w0I= 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-669-4YoMZcLXNn2fd-GwOJZ7Qg-1; Tue, 25 Mar 2025 12:14:03 -0400 X-MC-Unique: 4YoMZcLXNn2fd-GwOJZ7Qg-1 X-Mimecast-MFC-AGG-ID: 4YoMZcLXNn2fd-GwOJZ7Qg_1742919242 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 0555D196E08E; Tue, 25 Mar 2025 16:14:02 +0000 (UTC) Received: from localhost.localdomain (unknown [10.44.32.136]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 9B95E1828A80; Tue, 25 Mar 2025 16:13:58 +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 , platform-driver-x86@vger.kernel.org, linux-media@vger.kernel.org Subject: [PATCH 3/8] platform/x86: int3472: Drop unused gpio field from struct int3472_gpio_regulator Date: Tue, 25 Mar 2025 17:13:35 +0100 Message-ID: <20250325161340.342192-4-hdegoede@redhat.com> In-Reply-To: <20250325161340.342192-1-hdegoede@redhat.com> References: <20250325161340.342192-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. 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 Tue Mar 25 16: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: 876211 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 CD5B91799F for ; Tue, 25 Mar 2025 16:14:30 +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=1742919272; cv=none; b=NAO/47H75uPlecP0Yfg58i3Vv9Eh+tbbPI+36NJ6jqyXiR/Zf76OijOqDvPxNJe/EQ4MG+oKo7B8Ewtkc6xA5avWmHwILOlMaXB/SSnBD0LVFC/X8G45DKup0oSXnAoN7pWLpD6h9ynB0hxBgvE+5xHohY24KrWmmWJw7DZlZIQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742919272; c=relaxed/simple; bh=EXNvGL9W3hlORRCLLqf5hUVaFECrdG9DfvPp4lc8QWQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=u5/SQmll7ayCiFUMRnMLAJkqChScoC+wHoa+L7E3I3Wf6sEVlRrnWuPfXMEiH0Z4us6UuxJmpwhoWjx5+ctOdPAXZo6ryNvyzbBFhn2p8TqJ1aTLpVogIB6PAbljwFFZdlOuw8OklSlw5GdKUqMe4d68XvSWyd0EO1cWnVF9p+Y= 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=VZf0ykbK; 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="VZf0ykbK" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742919269; 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=I+2Viq8mPpP05ayntw0T/qjHI1rdPcvXdZKMDnwEtCk=; b=VZf0ykbKidXhsWs7S7qK+ygRwMypzBRDWUEH5DWxIrz/lKdIWVqWUFReveF8/uOPBgXdt8 +ONDTo7AUhFnO7ZcL5rcLISqDnFshjhnjinJZOEc/3leH4QIT96KMOZoIf1j3OSi6XZaaH //y4RfgnOLBs7mDFDGTGCMaXn/W6CYg= 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-498-LIVamCC4P1unJidp0zmAKg-1; Tue, 25 Mar 2025 12:14:26 -0400 X-MC-Unique: LIVamCC4P1unJidp0zmAKg-1 X-Mimecast-MFC-AGG-ID: LIVamCC4P1unJidp0zmAKg_1742919265 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 ACE851828B7F; Tue, 25 Mar 2025 16:14:05 +0000 (UTC) Received: from localhost.localdomain (unknown [10.44.32.136]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 7C9E9180A803; Tue, 25 Mar 2025 16:14:02 +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 , platform-driver-x86@vger.kernel.org, linux-media@vger.kernel.org Subject: [PATCH 4/8] platform/x86: int3472: Rework AVDD second sensor quirk handling Date: Tue, 25 Mar 2025 17:13:36 +0100 Message-ID: <20250325161340.342192-5-hdegoede@redhat.com> In-Reply-To: <20250325161340.342192-1-hdegoede@redhat.com> References: <20250325161340.342192-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. 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 Tue Mar 25 16:13:38 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: 876210 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 E3C9C25C6E2 for ; Tue, 25 Mar 2025 16:14:38 +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=1742919280; cv=none; b=hkBbnk1tlwBTY7b6JXBuEi5QKNyd5DGIUYcefIzDZJsdX5OLkeZ0zkmn1cAWYIYl9zqEMzQQ3is7cAZKF3ziI9KCMM1eDKNZ4Nwhs/zLNW1G5vua92XWu5wHhtdizVDBQIO9M6I6C58VGac6qXhrBYJUZrk/Wt1cjQjtACY6gyI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1742919280; c=relaxed/simple; bh=gsMlnd38Psc3SaI9GEpL2QYV7gDlfVkONvSXqzgv8lU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RN1EYw3J5uqfqW6jbayuBdZf8s3sWA8lfPUmeN/RR7XoE/wPRsk3RLuaUeHNi2+uG8q3us9gmzG88eZMSFXTb4Wz0odBYAsaN+sxYFu+ttQfCwGQj4XAVCoAs4idbMnOGmS+NdjVTlaGFClccm75tAIJ/0HY/D8pFQD7nr2ofQI= 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=ePaCdZFp; 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="ePaCdZFp" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1742919277; 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=HnRLG9xVvPIADBKT198ZOyHaoYN/0FEtBZPtkKvLk5A=; b=ePaCdZFphdfnxHs5kfCAyeG4jj1y/i+rTVtPjlDCTk/ZANhSsSbhSJOd2Z7fRJLA84gqjl afInzCkj6ZEUvdvCCMszhq4q+mtOmd5e33iyyuYJe6DJiPIIiGM8XhkgAieTptU1zUxYrF DAgm6r23+V13vC8AweBNb6eK1psdSDU= 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-642-GlI1KpqfOAGeAHexR1Xpuw-1; Tue, 25 Mar 2025 12:14:32 -0400 X-MC-Unique: GlI1KpqfOAGeAHexR1Xpuw-1 X-Mimecast-MFC-AGG-ID: GlI1KpqfOAGeAHexR1Xpuw_1742919270 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 F1DC518BAF5D; Tue, 25 Mar 2025 16:14:12 +0000 (UTC) Received: from localhost.localdomain (unknown [10.44.32.136]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id CB2D7180B48D; Tue, 25 Mar 2025 16: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 , platform-driver-x86@vger.kernel.org, linux-media@vger.kernel.org Subject: [PATCH 6/8] platform/x86: int3472: Prepare for registering more then 1 GPIO regulator Date: Tue, 25 Mar 2025 17:13:38 +0100 Message-ID: <20250325161340.342192-7-hdegoede@redhat.com> In-Reply-To: <20250325161340.342192-1-hdegoede@redhat.com> References: <20250325161340.342192-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 then 1 GPIO regulator. Signed-off-by: Hans de Goede --- .../x86/intel/int3472/clk_and_regulator.c | 26 ++++++++++++------- drivers/platform/x86/intel/int3472/common.h | 20 ++++++++------ 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/drivers/platform/x86/intel/int3472/clk_and_regulator.c b/drivers/platform/x86/intel/int3472/clk_and_regulator.c index 459dbb2cd68a..93033ced8633 100644 --- a/drivers/platform/x86/intel/int3472/clk_and_regulator.c +++ b/drivers/platform/x86/intel/int3472/clk_and_regulator.c @@ -195,12 +195,17 @@ int skl_int3472_register_regulator(struct int3472_discrete_device *int3472, struct regulator_config cfg = { }; int i, j; + if (int3472->n_regulators >= 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 -EOVERFLOW; } - regulator = &int3472->regulator; + regulator = &int3472->regulators[int3472->n_regulators]; string_upper(regulator->supply_name_upper, supply_name); for (i = 0, j = 0; i < GPIO_REGULATOR_SUPPLY_MAP_COUNT; i++) { @@ -218,28 +223,29 @@ 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", 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); cfg.dev = &int3472->adev->dev; 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_regulators++; + return 0; } void skl_int3472_unregister_regulator(struct int3472_discrete_device *int3472) { - regulator_unregister(int3472->regulator.rdev); + for (int i = 0; i < int3472->n_regulators; 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 b0638c29d847..9f995028137b 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 #define GPIO_SUPPPLY_NAME_LENGTH 5 #define GPIO_REGULATOR_NAME_LENGTH (12 + GPIO_SUPPPLY_NAME_LENGTH) @@ -76,6 +77,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; @@ -84,14 +94,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; @@ -113,6 +116,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_regulators; /* how many have we mapped to a regulator */ struct gpiod_lookup_table gpios; };