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 73E0BC433F5 for ; Mon, 20 Dec 2021 15:53:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237341AbhLTPxm (ORCPT ); Mon, 20 Dec 2021 10:53:42 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:56780 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231790AbhLTPxl (ORCPT ); Mon, 20 Dec 2021 10:53:41 -0500 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.1.2/8.16.1.2) with ESMTP id 1BKB4Q9e022873; Mon, 20 Dec 2021 16:53:20 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=message-id : subject : from : to : cc : date : in-reply-to : references : content-type : mime-version : content-transfer-encoding; s=selector1; bh=Jgsa623SaViueGDOZhOSg8j75LYCq3JkOD9aq+r/VfQ=; b=Ldd5V86MOT/fE2WF4Lg2DS8jBjbIvCL4my+RuOlmH9NHg5Jz0/O/lZqlhOtJ4SKESwV+ 2wo+st4yxIOSOzjHtynk+FNnuMp5Ua1/1mJox/Co0VfeEHcBbTK5pT+04gvAuHQKTGGj odrpRrq+Zo4LPAhJTO00OjEErxPppMMtd+Yr5Y6MomCgCPOQ2tNskW43nFX7khUYIZCt iFTIRLEEfH9lrB3KgyHY9LzdErs2ZCs7ubnTmg+sowEQ4Cj4A3/BE7rjVYz0JCSzcRdA YCJRnM/Z5HOkW3T6eHaIKRVqV+EpBLodW1+iitopQBxJBNJlqrOhG1p3MfrrTLklEEgg zw== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com (PPS) with ESMTPS id 3d2kjnkbee-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 20 Dec 2021 16:53:20 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id B828C10002A; Mon, 20 Dec 2021 16:53:18 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node2.st.com [10.75.127.5]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id AEF9D207546; Mon, 20 Dec 2021 16:53:18 +0100 (CET) Received: from [192.168.8.15] (10.75.127.46) by SFHDAG2NODE2.st.com (10.75.127.5) with Microsoft SMTP Server (TLS) id 15.0.1497.26; Mon, 20 Dec 2021 16:53:17 +0100 Message-ID: <210c1e7c333b42702ac0c3ba0da639e82327d035.camel@foss.st.com> Subject: Re: [PATCH] drm: adv7511: override i2c address of cec before accessing it From: Antonio Borneo To: Kieran Bingham , Andrzej Hajda , Daniel Vetter , David Airlie , Jernej Skrabec , "Jonas Karlman" , Laurent Pinchart , Neil Armstrong , Robert Foss , CC: , Date: Mon, 20 Dec 2021 16:53:12 +0100 In-Reply-To: <164001209406.2512616.469307346369770543@Monstersaurus> References: <20211218182804.208906-1-antonio.borneo@foss.st.com> <164001209406.2512616.469307346369770543@Monstersaurus> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Originating-IP: [10.75.127.46] X-ClientProxiedBy: SFHDAG2NODE2.st.com (10.75.127.5) To SFHDAG2NODE2.st.com (10.75.127.5) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.790,Hydra:6.0.425,FMLib:17.11.62.513 definitions=2021-12-20_07,2021-12-20_01,2021-12-02_01 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2021-12-20 at 14:54 +0000, Kieran Bingham wrote: > Hi Antonio, > > Quoting Antonio Borneo (2021-12-18 18:28:04) > > Commit 680532c50bca ("drm: adv7511: Add support for > > i2c_new_secondary_device") allows a device tree node to override > > the default addresses of the secondary i2c devices. This is useful > > for solving address conflicts on the i2c bus. > > > > In adv7511_init_cec_regmap() the new i2c address of cec device is > > read from device tree and immediately accessed, well before it is > > written in the proper register to override the default address. > > This can cause an i2c error during probe and a consequent probe > > failure. > > Ouch, it does seem that way. I guess no one has used the CEC for > quite > some time, as it must have been like this for a while? Using the default i2c address for cec works without problem; apparently everyone is happy with such default. The issue appears only when you have to override the default cec address. The commit 680532c50bca landed in v4.18. > > Once the new i2c address is read from the device tree, override > > the default address before any attempt to access the cec. > > Reviewed-by: Kieran Bingham Thanks! Antonio > > Tested with adv7533 and stm32mp157f. > > > > Signed-off-by: Antonio Borneo > > Fixes: 680532c50bca ("drm: adv7511: Add support for > > i2c_new_secondary_device") > > --- > > To: Andrzej Hajda > > To: Neil Armstrong > > To: Robert Foss > > To: Laurent Pinchart > > To: Jonas Karlman > > To: Jernej Skrabec > > To: David Airlie > > To: Daniel Vetter > > To: Kieran Bingham > > To: dri-devel@lists.freedesktop.org > > Cc: linux-kernel@vger.kernel.org > > Cc: linux-stm32@st-md-mailman.stormreply.com > > --- > >  drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 7 ++++--- > >  1 file changed, 4 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c > > b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c > > index 76555ae64e9c..629e05286fd9 100644 > > --- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c > > +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c > > @@ -1048,6 +1048,10 @@ static int adv7511_init_cec_regmap(struct > > adv7511 *adv) > >                                                 > > ADV7511_CEC_I2C_ADDR_DEFAULT); > >         if (IS_ERR(adv->i2c_cec)) > >                 return PTR_ERR(adv->i2c_cec); > > + > > +       regmap_write(adv->regmap, ADV7511_REG_CEC_I2C_ADDR, > > +                    adv->i2c_cec->addr << 1); > > + > >         i2c_set_clientdata(adv->i2c_cec, adv); > >   > >         adv->regmap_cec = devm_regmap_init_i2c(adv->i2c_cec, > > @@ -1252,9 +1256,6 @@ static int adv7511_probe(struct i2c_client > > *i2c, const struct i2c_device_id *id) > >         if (ret) > >                 goto err_i2c_unregister_packet; > >   > > -       regmap_write(adv7511->regmap, ADV7511_REG_CEC_I2C_ADDR, > > -                    adv7511->i2c_cec->addr << 1); > > - > >         INIT_WORK(&adv7511->hpd_work, adv7511_hpd_work); > >   > >         if (i2c->irq) { > > > > base-commit: fc74881c28d314b10efac016ef49df4ff40b8b97 > > -- > > 2.34.1 > >