From patchwork Sun Jan 16 21:51:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 532763 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 305BEC433FE for ; Sun, 16 Jan 2022 21:52:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233807AbiAPVwP (ORCPT ); Sun, 16 Jan 2022 16:52:15 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:55195 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233782AbiAPVwO (ORCPT ); Sun, 16 Jan 2022 16:52:14 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642369933; 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=FBFnWvgcrYpJ9MThj/22dUVsFhYmMpemjqGRrijtr88=; b=KAYHk8KMOFUI3vH1egNijt4/PAZbpaA0Nz6Bn+3aOB9kjxulUMbYo96pNVzyjOTSS+tTFN hL+HqFRne1aFFDSdyR+ytFMmvOB4DUbiaR+w34O7iHQyrdz6UcDYVZkJLSUmg/hX+NbNqR z+Cj+zqX3aR2CguQ4pb/Bt0hikRFLM4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-213-HHL40vT-Otyb7CP3EOLTgg-1; Sun, 16 Jan 2022 16:52:12 -0500 X-MC-Unique: HHL40vT-Otyb7CP3EOLTgg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BA37A802924; Sun, 16 Jan 2022 21:52:10 +0000 (UTC) Received: from shalem.redhat.com (unknown [10.40.192.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3D04D12E37; Sun, 16 Jan 2022 21:52:08 +0000 (UTC) From: Hans de Goede To: Mauro Carvalho Chehab , Sakari Ailus Cc: Hans de Goede , Tsuchiya Yuto , Andy Shevchenko , Yury Luneff , Nable , andrey.i.trufanov@gmail.com, Fabio Aiuto , linux-media@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH 1/9] media: atomisp: Don't use ifdef on IS_ISP2401 Date: Sun, 16 Jan 2022 22:51:56 +0100 Message-Id: <20220116215204.307649-2-hdegoede@redhat.com> In-Reply-To: <20220116215204.307649-1-hdegoede@redhat.com> References: <20220116215204.307649-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org IS_ISP2401 is a function like macro which is always defined, so it must not be used together with #ifdef. #ifdef checks should check for "ISP2401", not "IS_ISP2401". Signed-off-by: Hans de Goede --- drivers/staging/media/atomisp/pci/atomisp_compat_css20.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c b/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c index 7edee293b132..49f235f9c365 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c +++ b/drivers/staging/media/atomisp/pci/atomisp_compat_css20.c @@ -972,7 +972,7 @@ int atomisp_css_irq_translate(struct atomisp_device *isp, void atomisp_css_rx_get_irq_info(enum mipi_port_id port, unsigned int *infos) { -#ifndef IS_ISP2401 +#ifndef ISP2401 ia_css_isys_rx_get_irq_info(port, infos); #else *infos = 0; @@ -982,7 +982,7 @@ void atomisp_css_rx_get_irq_info(enum mipi_port_id port, void atomisp_css_rx_clear_irq_info(enum mipi_port_id port, unsigned int infos) { -#ifndef IS_ISP2401 +#ifndef ISP2401 ia_css_isys_rx_clear_irq_info(port, infos); #endif } From patchwork Sun Jan 16 21:51:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 532530 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0717EC433F5 for ; Sun, 16 Jan 2022 21:52:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236271AbiAPVwT (ORCPT ); Sun, 16 Jan 2022 16:52:19 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:57102 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233782AbiAPVwT (ORCPT ); Sun, 16 Jan 2022 16:52:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642369938; 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=ZFdB7jwYQUHSXecJcxmujN77bcWVZz3CxOp+viiBVaM=; b=fq/NU92Z+Nh+zqNw6PBpTTdDwkoVCK3V/tkXT2aLUue2/qr22X6E0W2HA8HvbLCASNoA/5 BO8a01hT2MKFbfL4mKTmtqh51Afqp9cYL3rQXOBmpvrFG+ICE2RGRltnFMc32Qp5T9S5Hc MrpvZD6AwaUpGPtDRLZDDHdVZ65Qrm4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-205-pmX-fAClNvew1iIR29rqyw-1; Sun, 16 Jan 2022 16:52:15 -0500 X-MC-Unique: pmX-fAClNvew1iIR29rqyw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A77D71083F60; Sun, 16 Jan 2022 21:52:13 +0000 (UTC) Received: from shalem.redhat.com (unknown [10.40.192.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1CE6361F20; Sun, 16 Jan 2022 21:52:10 +0000 (UTC) From: Hans de Goede To: Mauro Carvalho Chehab , Sakari Ailus Cc: Hans de Goede , Tsuchiya Yuto , Andy Shevchenko , Yury Luneff , Nable , andrey.i.trufanov@gmail.com, Fabio Aiuto , linux-media@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH 2/9] media: atomisp: Don't use ifdef ISP2400 Date: Sun, 16 Jan 2022 22:51:57 +0100 Message-Id: <20220116215204.307649-3-hdegoede@redhat.com> In-Reply-To: <20220116215204.307649-1-hdegoede@redhat.com> References: <20220116215204.307649-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org IPS2400 is never defined, for ISP2401 builds ISP2401 gets defined and for ISP2400 nothing gets defined, so any #ifdef ISP2400 checks should be #ifndef ISP2401 checks instead. Signed-off-by: Hans de Goede --- drivers/staging/media/atomisp/pci/atomisp_v4l2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c index 1b240891a6e2..52a367feaeee 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_v4l2.c +++ b/drivers/staging/media/atomisp/pci/atomisp_v4l2.c @@ -1467,7 +1467,7 @@ static bool is_valid_device(struct pci_dev *pdev, const struct pci_device_id *id * remove the if once the driver become generic */ -#if defined(ISP2400) +#ifndef ISP2401 if (IS_ISP2401) { dev_err(&pdev->dev, "Support for %s (ISP2401) was disabled at compile time\n", name); From patchwork Sun Jan 16 21:51:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 532762 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1EC8C433EF for ; Sun, 16 Jan 2022 21:52:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236281AbiAPVwV (ORCPT ); Sun, 16 Jan 2022 16:52:21 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:22881 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236275AbiAPVwU (ORCPT ); Sun, 16 Jan 2022 16:52:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642369940; 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=6GkPcX6WL4buAzlb3rvJP7uOMUndloDC4nSNGhGS+Z0=; b=gmlKtmHhWBLymYMJFzTAs0IXQANiouaJ2C68AbH7nn4+Zp6NXK5gxTzdipnHLU9h/fVIpi do295HUuHGpa1kFHcflk7xECctiZFCQYeAJkw3/U/bumDb5xCrG/51WxbKglZd74FrZk76 OWTalka72/WB5FrOHNe6aGfm6jNr3J8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-544-CK_GYErHO8y5tyGduLrODw-1; Sun, 16 Jan 2022 16:52:18 -0500 X-MC-Unique: CK_GYErHO8y5tyGduLrODw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 99DFB1083F60; Sun, 16 Jan 2022 21:52:16 +0000 (UTC) Received: from shalem.redhat.com (unknown [10.40.192.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A52712E37; Sun, 16 Jan 2022 21:52:13 +0000 (UTC) From: Hans de Goede To: Mauro Carvalho Chehab , Sakari Ailus Cc: Hans de Goede , Tsuchiya Yuto , Andy Shevchenko , Yury Luneff , Nable , andrey.i.trufanov@gmail.com, Fabio Aiuto , linux-media@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH 3/9] media: atomisp: Use irci_stable_candrpv_0415_20150423_1753 fw for byt Date: Sun, 16 Jan 2022 22:51:58 +0100 Message-Id: <20220116215204.307649-4-hdegoede@redhat.com> In-Reply-To: <20220116215204.307649-1-hdegoede@redhat.com> References: <20220116215204.307649-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org There is no irci_stable_candrpv_0415_20150521_0458 build for the isp2400/byt version of the atomisp2. There is however an irci_stable_candrpv_0415_20150423_1753 version which according to: https://github.com/intel/ProductionKernelQuilts/blob/master/uefi/cht-m1stable/patches/cam-041 Has the exact same fw ABI, so use that on the isp2400. Signed-off-by: Hans de Goede --- drivers/staging/media/atomisp/pci/sh_css_firmware.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/staging/media/atomisp/pci/sh_css_firmware.c b/drivers/staging/media/atomisp/pci/sh_css_firmware.c index 94149647b98b..dd688f8ab649 100644 --- a/drivers/staging/media/atomisp/pci/sh_css_firmware.c +++ b/drivers/staging/media/atomisp/pci/sh_css_firmware.c @@ -56,7 +56,11 @@ static struct firmware_header *firmware_header; * which will be replaced with the actual RELEASE_VERSION * during package generation. Please do not modify */ +#ifdef ISP2401 static const char *release_version = STR(irci_stable_candrpv_0415_20150521_0458); +#else +static const char *release_version = STR(irci_stable_candrpv_0415_20150423_1753); +#endif #define MAX_FW_REL_VER_NAME 300 static char FW_rel_ver_name[MAX_FW_REL_VER_NAME] = "---"; From patchwork Sun Jan 16 21:51:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 532761 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97DEDC433F5 for ; Sun, 16 Jan 2022 21:52:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236287AbiAPVw3 (ORCPT ); Sun, 16 Jan 2022 16:52:29 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:52066 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236275AbiAPVw2 (ORCPT ); Sun, 16 Jan 2022 16:52:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642369946; 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=hkoQd7gjxr71vUNWnR7XIGrbM4DTr+/zCdydsU3Qc/8=; b=Bpw0fpzN4hVDOqsT7g0rUIz8FiwGU9aTpZ4mZ85zcxZT5Nm4bsiZNVBJAKApKUQrk5fpSz IsucenxjxOIkzUrpLvzkjhhO1jrKFc9DbW3HZLmXhxLR8Cz2CvtxQbLCZvt0MtUa0HR2Zc uJRcrAuwZgznAom7zRAz5vA3deIPNdI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-247-lxTBumPvP82OVLxsuF1raw-1; Sun, 16 Jan 2022 16:52:21 -0500 X-MC-Unique: lxTBumPvP82OVLxsuF1raw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 737CB2F24; Sun, 16 Jan 2022 21:52:19 +0000 (UTC) Received: from shalem.redhat.com (unknown [10.40.192.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id EF83361F20; Sun, 16 Jan 2022 21:52:16 +0000 (UTC) From: Hans de Goede To: Mauro Carvalho Chehab , Sakari Ailus Cc: Hans de Goede , Tsuchiya Yuto , Andy Shevchenko , Yury Luneff , Nable , andrey.i.trufanov@gmail.com, Fabio Aiuto , linux-media@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH 4/9] media: atomisp_gmin_platform: Fix axp_regulator_set() writing to the wrong register Date: Sun, 16 Jan 2022 22:51:59 +0100 Message-Id: <20220116215204.307649-5-hdegoede@redhat.com> In-Reply-To: <20220116215204.307649-1-hdegoede@redhat.com> References: <20220116215204.307649-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The second write done in axp_regulator_set() must go to the ctrl_reg which turns the various regulators on/off. This replaces the second write writing the sel_reg, which sets the voltage for the regulator, for a second time with a wrong value. Signed-off-by: Hans de Goede --- drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c index 1cc581074ba7..a29e5086ffe1 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +++ b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c @@ -741,7 +741,7 @@ static int axp_regulator_set(struct device *dev, struct gmin_subdev *gs, val = on ? 1 << shift : 0; - ret = gmin_i2c_write(dev, gs->pwm_i2c_addr, sel_reg, val, 1 << shift); + ret = gmin_i2c_write(dev, gs->pwm_i2c_addr, ctrl_reg, val, 1 << shift); if (ret) return ret; From patchwork Sun Jan 16 21:52:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 532529 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5FCF4C433EF for ; Sun, 16 Jan 2022 21:52:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236284AbiAPVw2 (ORCPT ); Sun, 16 Jan 2022 16:52:28 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:44333 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236282AbiAPVw1 (ORCPT ); Sun, 16 Jan 2022 16:52:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642369946; 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=tdlz402qiFuS6gEvp9z+mWyjyKqkZaVDzlGuYidzGVo=; b=RtJK38KA4NrNkWtgvzkK7oTkNhRwtN3OMBx9J5jj6yE0nRkCD2q5E7LgjhIXXRHu8LN1/m wtccG7XuHBRvAq2xkUaBtfilonr0+xYwsH48ODaJQ7qVbf/yNHSWZfu7ymY1YE3BVFtKkQ 5R4/yqba7K00kTafdtd9q8VktkBL82M= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-562-azjLsH5iMQG44VRtAQFCBQ-1; Sun, 16 Jan 2022 16:52:23 -0500 X-MC-Unique: azjLsH5iMQG44VRtAQFCBQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2C0BA1006AA3; Sun, 16 Jan 2022 21:52:22 +0000 (UTC) Received: from shalem.redhat.com (unknown [10.40.192.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id B6B4312E37; Sun, 16 Jan 2022 21:52:19 +0000 (UTC) From: Hans de Goede To: Mauro Carvalho Chehab , Sakari Ailus Cc: Hans de Goede , Tsuchiya Yuto , Andy Shevchenko , Yury Luneff , Nable , andrey.i.trufanov@gmail.com, Fabio Aiuto , linux-media@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH 5/9] media: atomisp_gmin_platform: Add enable-count to gmin_[v1p8|v2p8]_ctrl() Date: Sun, 16 Jan 2022 22:52:00 +0100 Message-Id: <20220116215204.307649-6-hdegoede@redhat.com> In-Reply-To: <20220116215204.307649-1-hdegoede@redhat.com> References: <20220116215204.307649-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org On devices with 2 sensors the 2 sensors may get probed simultaneously and the v1p8 and v2p8 regulators are ususally shared between the 2 sensors. This means that the probe() function of sensor 1 may end up calling gmin_v1p8_ctrl(..., false) turning the regulator off while sensor 2's probe() function still needs it to be on, causing the probe() of sensor 2 to sometimes fail. Fix this by adding an enable-count for both regulators and only disabling them again when that goes to 0. Note all this really should be converted to use the standard kernel regulator framework, I have doing this on my long term TODO list, this fix is only meant as a temporary workaround for the issue. Signed-off-by: Hans de Goede --- .../media/atomisp/pci/atomisp_gmin_platform.c | 86 ++++++++++++++----- 1 file changed, 65 insertions(+), 21 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c index a29e5086ffe1..960c64ecdfe4 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +++ b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c @@ -118,6 +118,10 @@ static const char *pmic_name[] = { [PMIC_CRYSTALCOVE] = "Crystal Cove PMIC", }; +static DEFINE_MUTEX(gmin_regulator_mutex); +static int gmin_v1p8_enable_count; +static int gmin_v2p8_enable_count; + /* The atomisp uses type==0 for the end-of-list marker, so leave space. */ static struct intel_v4l2_subdev_table pdata_subdevs[MAX_SUBDEVS + 1]; @@ -851,38 +855,58 @@ static int gmin_v1p8_ctrl(struct v4l2_subdev *subdev, int on) gs->v1p8_on = on; + ret = 0; + mutex_lock(&gmin_regulator_mutex); + if (on) { + gmin_v1p8_enable_count++; + if (gmin_v1p8_enable_count > 1) + goto out; /* Already on */ + } else { + gmin_v1p8_enable_count--; + if (gmin_v1p8_enable_count > 0) + goto out; /* Still needed */ + } + if (gs->v1p8_gpio >= 0) gpio_set_value(gs->v1p8_gpio, on); if (gs->v1p8_reg) { regulator_set_voltage(gs->v1p8_reg, 1800000, 1800000); if (on) - return regulator_enable(gs->v1p8_reg); + ret = regulator_enable(gs->v1p8_reg); else - return regulator_disable(gs->v1p8_reg); + ret = regulator_disable(gs->v1p8_reg); + + goto out; } switch (pmic_id) { case PMIC_AXP: if (on) - return axp_v1p8_on(subdev->dev, gs); + ret = axp_v1p8_on(subdev->dev, gs); else - return axp_v1p8_off(subdev->dev, gs); + ret = axp_v1p8_off(subdev->dev, gs); + break; case PMIC_TI: value = on ? LDO_1P8V_ON : LDO_1P8V_OFF; - return gmin_i2c_write(subdev->dev, gs->pwm_i2c_addr, - LDO10_REG, value, 0xff); + ret = gmin_i2c_write(subdev->dev, gs->pwm_i2c_addr, + LDO10_REG, value, 0xff); + break; case PMIC_CRYSTALCOVE: value = on ? CRYSTAL_ON : CRYSTAL_OFF; - return gmin_i2c_write(subdev->dev, gs->pwm_i2c_addr, - CRYSTAL_1P8V_REG, value, 0xff); + ret = gmin_i2c_write(subdev->dev, gs->pwm_i2c_addr, + CRYSTAL_1P8V_REG, value, 0xff); + break; default: - dev_err(subdev->dev, "Couldn't set power mode for v1p2\n"); + dev_err(subdev->dev, "Couldn't set power mode for v1p8\n"); + ret = -EINVAL; } - return -EINVAL; +out: + mutex_unlock(&gmin_regulator_mutex); + return ret; } static int gmin_v2p8_ctrl(struct v4l2_subdev *subdev, int on) @@ -908,37 +932,57 @@ static int gmin_v2p8_ctrl(struct v4l2_subdev *subdev, int on) return 0; gs->v2p8_on = on; + ret = 0; + mutex_lock(&gmin_regulator_mutex); + if (on) { + gmin_v2p8_enable_count++; + if (gmin_v2p8_enable_count > 1) + goto out; /* Already on */ + } else { + gmin_v2p8_enable_count--; + if (gmin_v2p8_enable_count > 0) + goto out; /* Still needed */ + } + if (gs->v2p8_gpio >= 0) gpio_set_value(gs->v2p8_gpio, on); if (gs->v2p8_reg) { regulator_set_voltage(gs->v2p8_reg, 2900000, 2900000); if (on) - return regulator_enable(gs->v2p8_reg); + ret = regulator_enable(gs->v2p8_reg); else - return regulator_disable(gs->v2p8_reg); + ret = regulator_disable(gs->v2p8_reg); + + goto out; } switch (pmic_id) { case PMIC_AXP: - return axp_regulator_set(subdev->dev, gs, ALDO1_SEL_REG, - ALDO1_2P8V, ALDO1_CTRL3_REG, - ALDO1_CTRL3_SHIFT, on); + ret = axp_regulator_set(subdev->dev, gs, ALDO1_SEL_REG, + ALDO1_2P8V, ALDO1_CTRL3_REG, + ALDO1_CTRL3_SHIFT, on); + break; case PMIC_TI: value = on ? LDO_2P8V_ON : LDO_2P8V_OFF; - return gmin_i2c_write(subdev->dev, gs->pwm_i2c_addr, - LDO9_REG, value, 0xff); + ret = gmin_i2c_write(subdev->dev, gs->pwm_i2c_addr, + LDO9_REG, value, 0xff); + break; case PMIC_CRYSTALCOVE: value = on ? CRYSTAL_ON : CRYSTAL_OFF; - return gmin_i2c_write(subdev->dev, gs->pwm_i2c_addr, - CRYSTAL_2P8V_REG, value, 0xff); + ret = gmin_i2c_write(subdev->dev, gs->pwm_i2c_addr, + CRYSTAL_2P8V_REG, value, 0xff); + break; default: - dev_err(subdev->dev, "Couldn't set power mode for v1p2\n"); + dev_err(subdev->dev, "Couldn't set power mode for v2p8\n"); + ret = -EINVAL; } - return -EINVAL; +out: + mutex_unlock(&gmin_regulator_mutex); + return ret; } static int gmin_acpi_pm_ctrl(struct v4l2_subdev *subdev, int on) From patchwork Sun Jan 16 21:52:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 532528 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D176C433EF for ; Sun, 16 Jan 2022 21:52:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236288AbiAPVwb (ORCPT ); Sun, 16 Jan 2022 16:52:31 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:38751 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236275AbiAPVwa (ORCPT ); Sun, 16 Jan 2022 16:52:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642369950; 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=VErd/7wGyW/ygvfSf6FWyylvOBgyJgZoVFRzih2Btow=; b=UUqJoqm+uGdEqiAgl1xCJssmp2DWj2JPFiaTd30HGUMwmVGN+slF7urQ9qvEjlsoJqoAb0 /G3ITfh++PPXbKxu7G8VN07BDVse66R5MSVPsHp9pbxkmOmYcFLDOj38UdI9MdHPEepwf6 /f3tZTYY0obSbuZvkWODum/5u7LMeO0= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-517-BLtioM7-Oe2woZnRUs3BKA-1; Sun, 16 Jan 2022 16:52:27 -0500 X-MC-Unique: BLtioM7-Oe2woZnRUs3BKA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4ED95802924; Sun, 16 Jan 2022 21:52:25 +0000 (UTC) Received: from shalem.redhat.com (unknown [10.40.192.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8226D12E37; Sun, 16 Jan 2022 21:52:22 +0000 (UTC) From: Hans de Goede To: Mauro Carvalho Chehab , Sakari Ailus Cc: Hans de Goede , Tsuchiya Yuto , Andy Shevchenko , Yury Luneff , Nable , andrey.i.trufanov@gmail.com, Fabio Aiuto , linux-media@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH 6/9] media: atomisp_gmin_platform: Set ELDO1 to 1.6V on devices with an AXP288 PMIC Date: Sun, 16 Jan 2022 22:52:01 +0100 Message-Id: <20220116215204.307649-7-hdegoede@redhat.com> In-Reply-To: <20220116215204.307649-1-hdegoede@redhat.com> References: <20220116215204.307649-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Testing on multiple tablet models has shown that Android always uses 1.6V for ELDO1, adjust our code to match. This also matches with how ELDO1 is used in the DSDTs on these devices, where for Cherry Trail (ISP2401) based devices ELDO1 is used for an ACPI power-resource which is named "P16P". Note on Bay Trail (ISP2400) based devices the power-resource is called "P15P", which suggests that 1.5V might be a better value there. Signed-off-by: Hans de Goede --- .../media/atomisp/pci/atomisp_gmin_platform.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c index 960c64ecdfe4..1c3fd72895ec 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +++ b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c @@ -38,7 +38,7 @@ enum clock_rate { #define ELDO_CTRL_REG 0x12 #define ELDO1_SEL_REG 0x19 -#define ELDO1_1P8V 0x16 +#define ELDO1_1P6V 0x12 #define ELDO1_CTRL_SHIFT 0x00 #define ELDO2_SEL_REG 0x1a @@ -89,7 +89,7 @@ struct gmin_subdev { u8 pwm_i2c_addr; /* For PMIC AXP */ - int eldo1_sel_reg, eldo1_1p8v, eldo1_ctrl_shift; + int eldo1_sel_reg, eldo1_1p6v, eldo1_ctrl_shift; int eldo2_sel_reg, eldo2_1p8v, eldo2_ctrl_shift; }; @@ -685,9 +685,9 @@ static int gmin_subdev_add(struct gmin_subdev *gs) break; case PMIC_AXP: - gs->eldo1_1p8v = gmin_get_var_int(dev, false, + gs->eldo1_1p6v = gmin_get_var_int(dev, false, "eldo1_1p8v", - ELDO1_1P8V); + ELDO1_1P6V); gs->eldo1_sel_reg = gmin_get_var_int(dev, false, "eldo1_sel_reg", ELDO1_SEL_REG); @@ -767,8 +767,8 @@ static int axp_v1p8_on(struct device *dev, struct gmin_subdev *gs) */ usleep_range(110, 150); - ret = axp_regulator_set(dev, gs, gs->eldo1_sel_reg, gs->eldo1_1p8v, - ELDO_CTRL_REG, gs->eldo1_ctrl_shift, true); + ret = axp_regulator_set(dev, gs, gs->eldo1_sel_reg, gs->eldo1_1p6v, + ELDO_CTRL_REG, gs->eldo1_ctrl_shift, true); if (ret) return ret; @@ -781,7 +781,7 @@ static int axp_v1p8_off(struct device *dev, struct gmin_subdev *gs) { int ret; - ret = axp_regulator_set(dev, gs, gs->eldo1_sel_reg, gs->eldo1_1p8v, + ret = axp_regulator_set(dev, gs, gs->eldo1_sel_reg, gs->eldo1_1p6v, ELDO_CTRL_REG, gs->eldo1_ctrl_shift, false); if (ret) return ret; From patchwork Sun Jan 16 21:52:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 532760 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7036DC433F5 for ; Sun, 16 Jan 2022 21:52:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236290AbiAPVwe (ORCPT ); Sun, 16 Jan 2022 16:52:34 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:46208 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236275AbiAPVwd (ORCPT ); Sun, 16 Jan 2022 16:52:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642369953; 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=UA1A5VBn8thqziATr7SPyPEjX68UKG5mRdsuDL5RLlk=; b=ZbwikX5woWqrtv+TCBgw8Cc4pibN8TSZiL1SCyLdCeZP4NRR93WfZlJYiwoLBeAqk7SXDB CxWH7V6U+F2/D9wWh5s7wOso4xFNfSllLT3M/nAcSOC1eJzkPcvQb1YmIZ728WOrpAmGo/ z9iSPJdzAJ79oPFtCYzM5DTFyNeDfxA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-526-LuapLLWGOrSpOnCDdLGE3g-1; Sun, 16 Jan 2022 16:52:29 -0500 X-MC-Unique: LuapLLWGOrSpOnCDdLGE3g-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 33237802924; Sun, 16 Jan 2022 21:52:28 +0000 (UTC) Received: from shalem.redhat.com (unknown [10.40.192.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 954B761F20; Sun, 16 Jan 2022 21:52:25 +0000 (UTC) From: Hans de Goede To: Mauro Carvalho Chehab , Sakari Ailus Cc: Hans de Goede , Tsuchiya Yuto , Andy Shevchenko , Yury Luneff , Nable , andrey.i.trufanov@gmail.com, Fabio Aiuto , linux-media@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH 7/9] media: atomisp_gmin_platform: Do not turn ELDO2 off from axp_v1p8_on() Date: Sun, 16 Jan 2022 22:52:02 +0100 Message-Id: <20220116215204.307649-8-hdegoede@redhat.com> In-Reply-To: <20220116215204.307649-1-hdegoede@redhat.com> References: <20220116215204.307649-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Fix axp_v1p8_on() turning ELDO2 off at the end again by removing the bogus code which turns it off again after just having turned it on. Signed-off-by: Hans de Goede --- drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c index 1c3fd72895ec..84a453118bd9 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +++ b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c @@ -769,11 +769,6 @@ static int axp_v1p8_on(struct device *dev, struct gmin_subdev *gs) ret = axp_regulator_set(dev, gs, gs->eldo1_sel_reg, gs->eldo1_1p6v, ELDO_CTRL_REG, gs->eldo1_ctrl_shift, true); - if (ret) - return ret; - - ret = axp_regulator_set(dev, gs, gs->eldo2_sel_reg, gs->eldo2_1p8v, - ELDO_CTRL_REG, gs->eldo2_ctrl_shift, false); return ret; } From patchwork Sun Jan 16 21:52:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 532527 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A41B0C433EF for ; Sun, 16 Jan 2022 21:52:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236293AbiAPVwh (ORCPT ); Sun, 16 Jan 2022 16:52:37 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:26306 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236291AbiAPVwg (ORCPT ); Sun, 16 Jan 2022 16:52:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642369955; 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=o5VWUts0cwvuR1rVTDe6M//qtsGHWNBoNqzmU7SeN0k=; b=ZEnO0ZL3q9WxH6y42Oq0RCKiahe+f1FmWjFgW6EeBF+UJEIeajJeKAu+7etlSu4DDRk6UD F6cHoxOtfqM2IPY89Jpv59yVIIfy4At9Rv7ETZNxPylVRyLNHsz5ED36KYkeKFxj4ol096 vxvl3QYqnSV2l6O3bRdNQCylVhzp9R8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-557-wtknSVZgMj2JNkeNV-tqwg-1; Sun, 16 Jan 2022 16:52:32 -0500 X-MC-Unique: wtknSVZgMj2JNkeNV-tqwg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id ECD332F24; Sun, 16 Jan 2022 21:52:30 +0000 (UTC) Received: from shalem.redhat.com (unknown [10.40.192.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8A13512E37; Sun, 16 Jan 2022 21:52:28 +0000 (UTC) From: Hans de Goede To: Mauro Carvalho Chehab , Sakari Ailus Cc: Hans de Goede , Tsuchiya Yuto , Andy Shevchenko , Yury Luneff , Nable , andrey.i.trufanov@gmail.com, Fabio Aiuto , linux-media@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH 8/9] media: atomisp_gmin_platform: Base CsiPort default on detected CLK Date: Sun, 16 Jan 2022 22:52:03 +0100 Message-Id: <20220116215204.307649-9-hdegoede@redhat.com> In-Reply-To: <20220116215204.307649-1-hdegoede@redhat.com> References: <20220116215204.307649-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org On devices with 2 cameras and no _DSM / EFI-vars providing CsiPort clock info, defaulting to CsiPort 0 obviously is wrong for 1 of the 2 cameras. The Intel Cherry Trail (ISP2401) reference design combines: pmc_plt_clk_2 with CsiPort 0 pmc_plt_clk_4 with CsiPort 1 The Intel Bay Trail (ISP2400) reference design combines: pmc_plt_clk_1 with CsiPort 0 pmc_plt_clk_0 with CsiPort 1 Use this knowledge to set the default CsiPort value based on the detected CLK for the sensor. Signed-off-by: Hans de Goede --- .../media/atomisp/pci/atomisp_gmin_platform.c | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c index 84a453118bd9..544e3e7b3aaf 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +++ b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c @@ -540,7 +540,7 @@ static int gmin_subdev_add(struct gmin_subdev *gs) struct i2c_client *client = v4l2_get_subdevdata(gs->subdev); struct device *dev = &client->dev; struct acpi_device *adev = ACPI_COMPANION(dev); - int ret, clock_num = -1; + int ret, default_val, clock_num = -1; dev_info(dev, "%s: ACPI path is %pfw\n", __func__, dev_fwnode(dev)); @@ -548,7 +548,20 @@ static int gmin_subdev_add(struct gmin_subdev *gs) gs->clock_src = gmin_get_var_int(dev, false, "ClkSrc", VLV2_CLK_PLL_19P2MHZ); - gs->csi_port = gmin_get_var_int(dev, false, "CsiPort", 0); + /* + * Get ACPI _PR0 derived clock here already because it is used + * to determine the csi_port default. + */ + if (acpi_device_power_manageable(adev)) + clock_num = atomisp_get_acpi_power(dev); + + /* Compare clock to CsiPort 1 pmc-clock used in the CHT/BYT reference designs */ + if (IS_ISP2401) + default_val = clock_num == 4 ? 1 : 0; + else + default_val = clock_num == 0 ? 1 : 0; + + gs->csi_port = gmin_get_var_int(dev, false, "CsiPort", default_val); gs->csi_lanes = gmin_get_var_int(dev, false, "CsiLanes", 1); gs->gpio0 = gpiod_get_index(dev, NULL, 0, GPIOD_OUT_LOW); @@ -629,11 +642,7 @@ static int gmin_subdev_add(struct gmin_subdev *gs) * otherwise. */ - /* Try first to use ACPI to get the clock resource */ - if (acpi_device_power_manageable(adev)) - clock_num = atomisp_get_acpi_power(dev); - - /* Fall-back use EFI and/or DMI match */ + /* If getting the clock from _PR0 above failed, fall-back to EFI and/or DMI match */ if (clock_num < 0) clock_num = gmin_get_var_int(dev, false, "CamClk", 0); From patchwork Sun Jan 16 21:52:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 532759 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C41FC433EF for ; Sun, 16 Jan 2022 21:52:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236294AbiAPVwj (ORCPT ); Sun, 16 Jan 2022 16:52:39 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:51765 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236291AbiAPVwj (ORCPT ); Sun, 16 Jan 2022 16:52:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642369958; 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=xpUv2jXHv8dIaAEODjQNp9LH37nzXHyaaDslGDnwyR0=; b=FmkqHNAK95D8TWrmrGY77Hsk5XweDH0qPenYSKTH0BCnN58Y3nlZEBnwY9z0EYzmb1pRmd 7MnZD6N23uK+KaFYHhT9EYCqF2Skv+vo4/GUShR83G5lYkpJS0WLkVEQ7xfKMJhBy1MTwf xREmf1UFY6rQ44DAKPMDJ9vXXuUR5S8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-654-0r_aBLE6MiCBmTgW-DyvCQ-1; Sun, 16 Jan 2022 16:52:35 -0500 X-MC-Unique: 0r_aBLE6MiCBmTgW-DyvCQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B522A1006AA3; Sun, 16 Jan 2022 21:52:33 +0000 (UTC) Received: from shalem.redhat.com (unknown [10.40.192.3]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5104C61F20; Sun, 16 Jan 2022 21:52:31 +0000 (UTC) From: Hans de Goede To: Mauro Carvalho Chehab , Sakari Ailus Cc: Hans de Goede , Tsuchiya Yuto , Andy Shevchenko , Yury Luneff , Nable , andrey.i.trufanov@gmail.com, Fabio Aiuto , linux-media@vger.kernel.org, linux-staging@lists.linux.dev Subject: [PATCH 9/9] media: atomisp_gmin_platform: Add DMI quirk to not turn AXP ELDO2 regulator off on some boards Date: Sun, 16 Jan 2022 22:52:04 +0100 Message-Id: <20220116215204.307649-10-hdegoede@redhat.com> In-Reply-To: <20220116215204.307649-1-hdegoede@redhat.com> References: <20220116215204.307649-1-hdegoede@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org The TrekStor SurfTab duo W1 10.1 has a hw bug where turning eldo2 back on after having turned it off causes the CPLM3218 ambient-light-sensor on the front camera sensor's I2C bus to crash, hanging the bus. Add a DMI quirk table for systems on which to leave eldo2 on. Note an alternative fix is to turn off the CPLM3218 ambient-light-sensor as long as the camera sensor is being used, this is what Windows seems to do as a workaround (based on analyzing the DSDT). But that is not easy to do cleanly under Linux. Signed-off-by: Hans de Goede --- .../media/atomisp/pci/atomisp_gmin_platform.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c index 544e3e7b3aaf..7e47db82de07 100644 --- a/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c +++ b/drivers/staging/media/atomisp/pci/atomisp_gmin_platform.c @@ -761,6 +761,21 @@ static int axp_regulator_set(struct device *dev, struct gmin_subdev *gs, return 0; } +/* + * Some boards contain a hw-bug where turning eldo2 back on after having turned + * it off causes the CPLM3218 ambient-light-sensor on the image-sensor's I2C bus + * to crash, hanging the bus. Do not turn eldo2 off on these systems. + */ +static const struct dmi_system_id axp_leave_eldo2_on_ids[] = { + { + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "TrekStor"), + DMI_MATCH(DMI_PRODUCT_NAME, "SurfTab duo W1 10.1 (VT4)"), + }, + }, + { } +}; + static int axp_v1p8_on(struct device *dev, struct gmin_subdev *gs) { int ret; @@ -790,6 +805,9 @@ static int axp_v1p8_off(struct device *dev, struct gmin_subdev *gs) if (ret) return ret; + if (dmi_check_system(axp_leave_eldo2_on_ids)) + return 0; + ret = axp_regulator_set(dev, gs, gs->eldo2_sel_reg, gs->eldo2_1p8v, ELDO_CTRL_REG, gs->eldo2_ctrl_shift, false); return ret;