Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp4718931pxu; Wed, 21 Oct 2020 03:42:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRPudBJjE6Tgvtf5olNuFsIAuU1RGUjFpuV8L9o6YSURtpIVe5HrXXz9B2n4Cd+TAUU2Ar X-Received: by 2002:a05:6402:396:: with SMTP id o22mr2348349edv.361.1603276924358; Wed, 21 Oct 2020 03:42:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603276924; cv=none; d=google.com; s=arc-20160816; b=Go24Oc+WPqR4Ek+S1jMsQts7qnFxYC4grr+JyTcFSAgd4is5u8c4YoXUKp50cz8zyH 6FqlL/VNoB681O9DHaw1cpOGbDhwzmO2UGeJPWB/4wcLbkwlOJXMRBiBSOpLJ7uJuRl2 8SqtjJ85C7Q8fWbd4BWxRgUxAo96InaE8cPT/4vHxyrX5TZqe5ZSRUY8QQ/kmDumCmsi q+QxvMjvcmM5FgmNkjG7CRrXLMWqC2QvTzm2Fr2q043pw/gLHnpxDSd/YjcK75gvjA8p x1EEzT/1A1qtD2bFMTKahWnQ0HqbIishWjE5Z8b53h9cbBdo8K3EvAAS+aL8/FK0BQ88 u7vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qgb/6FQ5Y+5ks3gJUSbI0OvSC559NlxqqVqZk7W8uig=; b=agsVVYsQDVDY0xKpxRWH1SUnE+MbQX8z5RfjlaaEqqqK1TPHfLygp58B4njyDZyyi5 nOPk5qKjEAw6/dTfA8zFNODqj4oKuNQWB7TiLK2JwqeXHdnnToUkzeHspR4lazmeU12H ifn69HNP0g97EZqZLr+6r3L3QwNxwgovwrxUkht+MZD0MCnLCkvjmZ4pQ5B70b3w0bNY Kaj+Q3JpBvzoJWYNbFR6N+q0gDLjDjYRdzsyVdFMCm95xq2Kq3io8DQ244g+dfftpIuq ClOphYk7mD1gmAy9MTofnYQI6SG2Cpu1BdubqjY6SpCVHtB4v0MyC1LaR4rnlS6CklzU CRtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=uNfpqwWZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gz8si1099844ejb.135.2020.10.21.03.41.42; Wed, 21 Oct 2020 03:42:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=uNfpqwWZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2438972AbgJTWPN (ORCPT + 99 others); Tue, 20 Oct 2020 18:15:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56000 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438925AbgJTWPM (ORCPT ); Tue, 20 Oct 2020 18:15:12 -0400 Received: from mail-ot1-x341.google.com (mail-ot1-x341.google.com [IPv6:2607:f8b0:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCFAAC0613CE; Tue, 20 Oct 2020 15:15:12 -0700 (PDT) Received: by mail-ot1-x341.google.com with SMTP id f10so78998otb.6; Tue, 20 Oct 2020 15:15:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qgb/6FQ5Y+5ks3gJUSbI0OvSC559NlxqqVqZk7W8uig=; b=uNfpqwWZTEG9jrnDv2yMwFvts2SeACpm4RaAGrMNM27LXCj16ykn3WxaPn/YyuJ1jl UKWNwa/WOMeMkK/PiT0CesDhjV8GryPrl+vMpvcqDWctvZ89EA7xNlvBrOb0WphNGtZ1 JR6YIpnujy0WRYKxi/zSsai1kJdGJ5HHmGuk7H/dWwdj0gNJFmLJKveYdoYoQa8F6JrL iUvp8jzDDDZ0NGBZ3gKmNRM9G60zxOGYLocpLuuK8KUBKnjmZXwleNYKvB3Phr/vtpkm ypHTaZzSumnz8IC4ap3RywWe4SYkhKbs7iZHvO51xkkno0wHcYU7m0DtLjh8ORc47WNn gb6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qgb/6FQ5Y+5ks3gJUSbI0OvSC559NlxqqVqZk7W8uig=; b=Yj1SY1fdMOMdSRpkEc+KEXBPnZMBcg4NogWT4x9DRjp8Y575sNS2yr2M2QLYncCO6B QMI33fcKo4F4UsvR+shrYYPyVzbv/DybvR1j0d860wPvfi8neGZCS2BFvtgmFHrzW8nI HRFnVcokTjXScOk5oiinCjvyjubE5oTFgJbHqZD9D9BGVes9tHfwXQt/0PvQEWFscMFt v7hwRWCbUi5lcrgpPchUTQQV72SKglXlvBTWBGE4ZWRDpe46CcRFaUWpwi6Pd17TyMJH hvS0jG1sZSm0pH91Ifz5zij4BD8KZqJPLVlrcDBmIDfh4nv2pPszaHwwFpU2XzonuJyB Idiw== X-Gm-Message-State: AOAM532TzrEcyoph9lD+3Neyn1GHKL9SPPguczzQ/fwMu3Wds/W/a0pz a1Ygy3F6OAmqdz+rbNqBCRso6r47uvjzNw== X-Received: by 2002:a05:6830:2434:: with SMTP id k20mr358136ots.205.1603232112128; Tue, 20 Oct 2020 15:15:12 -0700 (PDT) Received: from nuclearis2-1.lan (c-98-195-139-126.hsd1.tx.comcast.net. [98.195.139.126]) by smtp.gmail.com with ESMTPSA id 81sm57005oti.79.2020.10.20.15.15.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Oct 2020 15:15:11 -0700 (PDT) From: Alexandru Gagniuc To: dri-devel@lists.freedesktop.org, devicetree@vger.kernel.org Cc: sam@ravnborg.org, Alexandru Gagniuc , David Airlie , Daniel Vetter , Rob Herring , Andrzej Hajda , Neil Armstrong , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Mauro Carvalho Chehab , Mark Brown , Thomas Bogendoerfer , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 2/3] drm/bridge: sii902x: Enable I/O and core VCC supplies if present Date: Tue, 20 Oct 2020 17:14:58 -0500 Message-Id: <20201020221501.260025-2-mr.nuke.me@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200928173056.1674274-1-mr.nuke.me@gmail.com> References: <20200928173056.1674274-1-mr.nuke.me@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On the SII9022, the IOVCC and CVCC12 supplies must reach the correct voltage before the reset sequence is initiated. On most boards, this assumption is true at boot-up, so initialization succeeds. However, when we try to initialize the chip with incorrect supply voltages, it will not respond to I2C requests. sii902x_probe() fails with -ENXIO. To resolve this, look for the "iovcc" and "cvcc12" regulators, and make sure they are enabled before starting the reset sequence. If these supplies are not available in devicetree, then they will default to dummy-regulator. In that case everything will work like before. This was observed on a STM32MP157C-DK2 booting in u-boot falcon mode. On this board, the supplies would be set by the second stage bootloader, which does not run in falcon mode. Signed-off-by: Alexandru Gagniuc --- Changes since v1: * Fix return code after regulator_enable(sii902x->iovcc) fails (Fabio Estevam) * Use dev_err_probe() instead of dev_err() where appropriate (Sam Ravnborg) Changes since v2: * Eliminate prototype for static functionn sii902x_init (Sam Ravnborg) * Bundled supplies under regulator_bulk_get/enable/disable() drivers/gpu/drm/bridge/sii902x.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c index f78c17f49887..5bab51a6b55c 100644 --- a/drivers/gpu/drm/bridge/sii902x.c +++ b/drivers/gpu/drm/bridge/sii902x.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -168,6 +169,7 @@ struct sii902x { struct drm_connector connector; struct gpio_desc *reset_gpio; struct i2c_mux_core *i2cmux; + struct regulator_bulk_data supplies[2]; /* * Mutex protects audio and video functions from interfering * each other, by keeping their i2c command sequences atomic. @@ -1049,7 +1051,26 @@ static int sii902x_probe(struct i2c_client *client, mutex_init(&sii902x->mutex); + sii902x->supplies[0].supply = "iovcc"; + sii902x->supplies[1].supply = "cvcc12"; + ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(sii902x->supplies), + sii902x->supplies); + if (ret < 0) + return ret; + + ret = regulator_bulk_enable(ARRAY_SIZE(sii902x->supplies), + sii902x->supplies); + if (ret < 0) { + dev_err_probe(dev, ret, "Failed to enable supplies"); + return ret; + } + ret = sii902x_init(sii902x); + if (ret < 0) { + regulator_bulk_disable(ARRAY_SIZE(sii902x->supplies), + sii902x->supplies); + } + return ret; } @@ -1060,6 +1081,8 @@ static int sii902x_remove(struct i2c_client *client) i2c_mux_del_adapters(sii902x->i2cmux); drm_bridge_remove(&sii902x->bridge); + regulator_bulk_disable(ARRAY_SIZE(sii902x->supplies), + sii902x->supplies); return 0; } -- 2.26.2