Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp541931ybl; Fri, 9 Aug 2019 09:45:40 -0700 (PDT) X-Google-Smtp-Source: APXvYqycMNyBB/gbicY1UhH27kFf7sM8LyOvAjYwcpT46WUKFtRbyjTY7tAJSX1qScIfVBumI+az X-Received: by 2002:a17:902:3181:: with SMTP id x1mr19522646plb.135.1565369140320; Fri, 09 Aug 2019 09:45:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565369140; cv=none; d=google.com; s=arc-20160816; b=vt+P9zKVBR6MdB2HrajJawFiFrvmKZZdGusQgpyGCBqBr1kaXXdtAzXRWWFrTziZoC Zc5jabRnSUplo80gs0jBAtEgFUFDjOnAPFGyQSjOp5+5lFv2o5M49tsc5PqtB1n8CdnF xS27uBvBQKUUFb8fEne/cwyjs4X6F5ermLlBgnLy2he9i6tDEg2bXQkVIs3NQ72vUcW3 bGjDJM0zzxUey658pOoRLXsDcX6hZkBxJYfKTuuMRrbG0DbMjbTxkTbyXlpc8YyCIqtm WPMQmn6ItTXfFtEMYLX0q6WcoTVjXc4Jpe8D9btCWqHSWx3jDfpkG0cDjJzW9kEWSoqM 10mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=9hXml4syP742FiWmF1L8/DoyzlhCvovuzObfJpyd8PY=; b=okPVz/fNnwN4Mf5lUb0MR2rjDKc8Ie8/LYwnjOAN+C5/XEHVUHOnrqMMSB9UsjtgAM tn5kC2IxIthqL8fVwCq5ipVAnr3A5RwAFaNKFGa6Lmn0W8R2wHB/9kh6x/XXSu51GsQK 8Ps71b6bIiifXkXtWMUk1I7Y0nfn5oHp46VZGkYevcQrmc/+GZVO2wZYIDVbBguGShfP 8qnrCBi4I5VM805vsoQuLIa0gh9zED5rpql0bgiH9u5m0bXKzxAm/Ifm8yzYLoanMcDZ 6NUdredNksqAFAFGFGBds1YAPaVSzVsAfjCkq4Uz7OZUe6swF3wj8rW1xTTcLQUHP7Ke uqFg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l14si53881020pgh.205.2019.08.09.09.45.24; Fri, 09 Aug 2019 09:45:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2407362AbfHIPZR (ORCPT + 99 others); Fri, 9 Aug 2019 11:25:17 -0400 Received: from asavdk4.altibox.net ([109.247.116.15]:39444 "EHLO asavdk4.altibox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726463AbfHIPZR (ORCPT ); Fri, 9 Aug 2019 11:25:17 -0400 Received: from ravnborg.org (unknown [158.248.194.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by asavdk4.altibox.net (Postfix) with ESMTPS id B1527803BE; Fri, 9 Aug 2019 17:25:11 +0200 (CEST) Date: Fri, 9 Aug 2019 17:25:10 +0200 From: Sam Ravnborg To: Bogdan Togorean Cc: dri-devel@lists.freedesktop.org, airlied@linux.ie, daniel@ffwll.ch, robh+dt@kernel.org, a.hajda@samsung.com, Laurent.pinchart@ideasonboard.com, gregkh@linuxfoundation.org, allison@lohutok.net, tglx@linutronix.de, matt.redfearn@thinci.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/2] drm: bridge: adv7511: Add support for ADV7535 Message-ID: <20190809152510.GA23265@ravnborg.org> References: <20190809141611.9927-1-bogdan.togorean@analog.com> <20190809141611.9927-3-bogdan.togorean@analog.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190809141611.9927-3-bogdan.togorean@analog.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-CMAE-Score: 0 X-CMAE-Analysis: v=2.3 cv=VcLZwmh9 c=1 sm=1 tr=0 a=UWs3HLbX/2nnQ3s7vZ42gw==:117 a=UWs3HLbX/2nnQ3s7vZ42gw==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=kj9zAlcOel0A:10 a=mACkeoi2Hy_AJo-pb_YA:9 a=CjuIK1q_8ugA:10 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Bogdan. This patch triggered a few general comments. > --- a/drivers/gpu/drm/bridge/adv7511/Makefile > +++ b/drivers/gpu/drm/bridge/adv7511/Makefile > @@ -2,5 +2,5 @@ > adv7511-y := adv7511_drv.o > adv7511-$(CONFIG_DRM_I2C_ADV7511_AUDIO) += adv7511_audio.o > adv7511-$(CONFIG_DRM_I2C_ADV7511_CEC) += adv7511_cec.o > -adv7511-$(CONFIG_DRM_I2C_ADV7533) += adv7533.o > +adv7511-$(CONFIG_DRM_I2C_ADV753x) += adv7533.o > obj-$(CONFIG_DRM_I2C_ADV7511) += adv7511.o > diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511.h b/drivers/gpu/drm/bridge/adv7511/adv7511.h > index 52b2adfdc877..38288c3c3c53 100644 > --- a/drivers/gpu/drm/bridge/adv7511/adv7511.h > +++ b/drivers/gpu/drm/bridge/adv7511/adv7511.h > @@ -91,6 +91,7 @@ > #define ADV7511_REG_ARC_CTRL 0xdf > #define ADV7511_REG_CEC_I2C_ADDR 0xe1 > #define ADV7511_REG_CEC_CTRL 0xe2 > +#define ADV7511_REG_SUPPLY_SELECT 0xe4 > #define ADV7511_REG_CHIP_ID_HIGH 0xf5 > #define ADV7511_REG_CHIP_ID_LOW 0xf6 > > @@ -320,6 +321,7 @@ struct adv7511_video_config { > enum adv7511_type { > ADV7511, > ADV7533, > + ADV7535, > }; > > #define ADV7511_MAX_ADDRS 3 > @@ -393,7 +395,7 @@ static inline int adv7511_cec_init(struct device *dev, struct adv7511 *adv7511) > } > #endif > > -#ifdef CONFIG_DRM_I2C_ADV7533 > +#ifdef CONFIG_DRM_I2C_ADV753x > void adv7533_dsi_power_on(struct adv7511 *adv); > void adv7533_dsi_power_off(struct adv7511 *adv); > void adv7533_mode_set(struct adv7511 *adv, const struct drm_display_mode *mode); The else part here define dummy functions. > diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c > index f6d2681f6927..b1501344df3e 100644 > --- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c > +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c > @@ -367,7 +367,7 @@ static void adv7511_power_on(struct adv7511 *adv7511) > */ > regcache_sync(adv7511->regmap); > > - if (adv7511->type == ADV7533) > + if (adv7511->type == ADV7533 || adv7511->type == ADV7535) > adv7533_dsi_power_on(adv7511); In the driver we check for adv7511->type - and call adv7533_dsi_power_on() only for the two types where we have this function defined. A simpler approach would be to always call adv7533_dsi_power_on(), and let the existing logic pick up the right version. The dummy version should then return 0 to say OK. Same goes for several places below. > adv7511->powered = true; > } > @@ -387,7 +387,7 @@ static void __adv7511_power_off(struct adv7511 *adv7511) > static void adv7511_power_off(struct adv7511 *adv7511) > { > __adv7511_power_off(adv7511); > - if (adv7511->type == ADV7533) > + if (adv7511->type == ADV7533 || adv7511->type == ADV7535) > adv7533_dsi_power_off(adv7511); > adv7511->powered = false; > } > @@ -761,7 +761,7 @@ static void adv7511_mode_set(struct adv7511 *adv7511, > regmap_update_bits(adv7511->regmap, 0x17, > 0x60, (vsync_polarity << 6) | (hsync_polarity << 5)); > > - if (adv7511->type == ADV7533) > + if (adv7511->type == ADV7533 || adv7511->type == ADV7535) > adv7533_mode_set(adv7511, adj_mode); > > drm_mode_copy(&adv7511->curr_mode, adj_mode); > @@ -874,7 +874,7 @@ static int adv7511_bridge_attach(struct drm_bridge *bridge) > &adv7511_connector_helper_funcs); > drm_connector_attach_encoder(&adv->connector, bridge->encoder); > > - if (adv->type == ADV7533) > + if (adv->type == ADV7533 || adv->type == ADV7535) > ret = adv7533_attach_dsi(adv); > > if (adv->i2c_main->irq) > @@ -903,6 +903,7 @@ static const char * const adv7511_supply_names[] = { > "dvdd-3v", > }; > > +/* The order of entries is important. If changed update hardcoded indices */ > static const char * const adv7533_supply_names[] = { > "avdd", > "dvdd", > @@ -952,7 +953,7 @@ static bool adv7511_cec_register_volatile(struct device *dev, unsigned int reg) > struct i2c_client *i2c = to_i2c_client(dev); > struct adv7511 *adv7511 = i2c_get_clientdata(i2c); > > - if (adv7511->type == ADV7533) > + if (adv7511->type == ADV7533 || adv7511->type == ADV7535) > reg -= ADV7533_REG_CEC_OFFSET; > > switch (reg) { > @@ -994,7 +995,7 @@ static int adv7511_init_cec_regmap(struct adv7511 *adv) > goto err; > } > > - if (adv->type == ADV7533) { > + if (adv->type == ADV7533 || adv->type == ADV7535) { > ret = adv7533_patch_cec_registers(adv); > if (ret) > goto err; > @@ -1094,8 +1095,9 @@ static int adv7511_probe(struct i2c_client *i2c, const struct i2c_device_id *id) > struct adv7511_link_config link_config; > struct adv7511 *adv7511; > struct device *dev = &i2c->dev; > + struct regulator *reg_v1p2; > unsigned int val; > - int ret; > + int ret, reg_v1p2_uV; > > if (!dev->of_node) > return -EINVAL; > @@ -1163,6 +1165,16 @@ static int adv7511_probe(struct i2c_client *i2c, const struct i2c_device_id *id) > if (ret) > goto uninit_regulators; > > + if (adv7511->type == ADV7533) { > + reg_v1p2 = adv7511->supplies[5].consumer; > + reg_v1p2_uV = regulator_get_voltage(reg_v1p2); > + > + if (reg_v1p2_uV == 1200000) { > + regmap_update_bits(adv7511->regmap, > + ADV7511_REG_SUPPLY_SELECT, 0x80, 0x80); > + } > + } > + > adv7511_packet_disable(adv7511, 0xffff); > > adv7511->i2c_edid = i2c_new_secondary_device(i2c, "edid", > @@ -1242,7 +1254,7 @@ static int adv7511_remove(struct i2c_client *i2c) > { > struct adv7511 *adv7511 = i2c_get_clientdata(i2c); > > - if (adv7511->type == ADV7533) > + if (adv7511->type == ADV7533 || adv7511->type == ADV7535) > adv7533_detach_dsi(adv7511); > i2c_unregister_device(adv7511->i2c_cec); > if (adv7511->cec_clk) > @@ -1266,8 +1278,9 @@ static const struct i2c_device_id adv7511_i2c_ids[] = { > { "adv7511", ADV7511 }, > { "adv7511w", ADV7511 }, > { "adv7513", ADV7511 }, > -#ifdef CONFIG_DRM_I2C_ADV7533 > +#ifdef CONFIG_DRM_I2C_ADV753x > { "adv7533", ADV7533 }, > + { "adv7535", ADV7535 }, > #endif This ifdef may not be needed?? If we did not get this type we will not look it up. > { } > }; > @@ -1277,8 +1290,9 @@ static const struct of_device_id adv7511_of_ids[] = { > { .compatible = "adi,adv7511", .data = (void *)ADV7511 }, > { .compatible = "adi,adv7511w", .data = (void *)ADV7511 }, > { .compatible = "adi,adv7513", .data = (void *)ADV7511 }, > -#ifdef CONFIG_DRM_I2C_ADV7533 > +#ifdef CONFIG_DRM_I2C_ADV753x > { .compatible = "adi,adv7533", .data = (void *)ADV7533 }, > + { .compatible = "adi,adv7535", .data = (void *)ADV7535 }, > #endif > { } > }; Sam