Received: by 10.192.165.148 with SMTP id m20csp363779imm; Wed, 25 Apr 2018 00:17:48 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/wxu1AEOfIXLFZqAuRcBbm2K5Ttjhz/pBFTrgBUHi86agItfronTIzSvF6WqlkVhk/AhVR X-Received: by 10.99.115.81 with SMTP id d17mr22180027pgn.297.1524640668724; Wed, 25 Apr 2018 00:17:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524640668; cv=none; d=google.com; s=arc-20160816; b=RgCXaC5zWJ+cItR14J2I6B4HkcPBrVGpmkN9UoPZ160XfAbOaj9+NN11QeYuQ2HBSY gk+3D3uMj3DuXTjNqOw8Weeh/ss/aRQOZ2raZuf+dlK4q/YXDUKPMSjYauKKI48Jft9r pKRfpJwIEnfAP0qwq6w1qCxX8yh7uvWp5jnYArZZL5d4JDLkEkD8UHQShP35VBuDpe1K mKhWIo5gInpV3dQXrYAUkQEo/ubyAUxnCW78/AA2YsgwcttZYLkYCEU4CdnWRyOn3ggF emiG1w5FVRZ7f59AGlKke2zxiqxLPVJzrMsy8oba6njKVByCAOGVP247vbprC56U7OTH 2zog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dmarc-filter :dkim-signature:dkim-signature:arc-authentication-results; bh=FZTc/nG25HWBBbIEpNaBlMIvPkhftV0tGo67IabAaNw=; b=KtFPK5h/UrTGxmtjXwH2mL3YyrUsqlKWXsCmPMbcQ4hM7hZ8QY4sBbKA+h7c0REY2A 1EqrqKVGwfkrjRdi6+1BSlJWslDW9jEUZ2QZl9aeqTg1cJNTlpuCqYikDyNAXQxoaLfl o3svBb47SJCztuau1AYzos09JSoNwFLPA60gg2JGCRFFnmuLZbSUFrlKGnWCygVZLnVs x/yTTitQJxi4wy4L/Rei3ajmfoDXgIUVuhTWE12Y7Gu6ofdQXF4h8oBdhDEkjkUs7KIQ Jz4NQQiThX5QaDcwUSlOtrjyfUTs43pA/mlFMqpk0JOmrqo/yYv1s7XHrznPKmgmtemi C5kQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=pG39Pplz; dkim=pass header.i=@codeaurora.org header.s=default header.b=DltKhtlx; 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 e12si12728034pgv.507.2018.04.25.00.17.34; Wed, 25 Apr 2018 00:17:48 -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; dkim=pass header.i=@codeaurora.org header.s=default header.b=pG39Pplz; dkim=pass header.i=@codeaurora.org header.s=default header.b=DltKhtlx; 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 S1751435AbeDYHQa (ORCPT + 99 others); Wed, 25 Apr 2018 03:16:30 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:43652 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750949AbeDYHQY (ORCPT ); Wed, 25 Apr 2018 03:16:24 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 1E0CA60C5F; Wed, 25 Apr 2018 07:16:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1524640584; bh=rH9KiqRUBVYd4r7D0+AP/r7I1ZSBb/ZbXrW6RcAgSJE=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=pG39PplzutLw91UJG0nurSMgX3tW3ge3FWA5M33bYdVZxrxDnpVIyqbod2s1d2bMc k3+7w9koJZ0q1woiSqQL8FyaKsFrHGMMhfeTUvTRoxNHIUZW8ppDvVQ0010KADR6D2 dbrQ6xFolgtmGcDJlCF+UrfySuazvJTRe5VTGgxc= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from [192.168.1.50] (unknown [182.71.117.114]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: architt@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id A033060863; Wed, 25 Apr 2018 07:16:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1524640583; bh=rH9KiqRUBVYd4r7D0+AP/r7I1ZSBb/ZbXrW6RcAgSJE=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=DltKhtlxv9Oxto0GXBG2PD6cnT03O2X+F83uMxueazYViI9gZUbrv+1iOZtELDLiz ep7vLoKeRoRxoqz6ZQCpt6BuhRDUJCYICMUYoN4mhQtt8zkH5NXJ5wAj/14H9Lnuv9 L1W+7ydWZ14Bix3EgkUV1WmIwAwFb28Nqh7QAFqg= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org A033060863 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=architt@codeaurora.org Subject: Re: [PATCH v4 5/5] drm: adv7511: Add support for i2c_new_secondary_device To: Kieran Bingham , linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-renesas-soc@vger.kernel.org Cc: Kieran Bingham , Jean-Michel Hautbois , Sergei Shtylyov , Lars-Peter Clausen , Kieran Bingham References: <1518544137-2742-1-git-send-email-kbingham@kernel.org> <1518544137-2742-6-git-send-email-kbingham@kernel.org> From: Archit Taneja Message-ID: <9d9acfa8-aa5d-c60f-3858-4847b80f1690@codeaurora.org> Date: Wed, 25 Apr 2018 12:46:17 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <1518544137-2742-6-git-send-email-kbingham@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tuesday 13 February 2018 11:18 PM, Kieran Bingham wrote: > From: Kieran Bingham > > The ADV7511 has four 256-byte maps that can be accessed via the main I2C > ports. Each map has it own I2C address and acts as a standard slave > device on the I2C bus. > > Allow a device tree node to override the default addresses so that > address conflicts with other devices on the same bus may be resolved at > the board description level. Queued to drm-misc-next > > Signed-off-by: Kieran Bingham > Reviewed-by: Laurent Pinchart > --- > v2: > - Update missing edid-i2c address setting > - Split out DT bindings > - Rename and move the I2C default addresses to their own section > > v3: > - No change > > v4: > - Change registration order of packet/cec to fix error path and > simplify code change. > - Collect Laurent's RB tag > > drivers/gpu/drm/bridge/adv7511/adv7511.h | 6 ++++ > drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 42 ++++++++++++++++++---------- > 2 files changed, 33 insertions(+), 15 deletions(-) > > diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511.h b/drivers/gpu/drm/bridge/adv7511/adv7511.h > index d034b2cb5eee..73d8ccb97742 100644 > --- a/drivers/gpu/drm/bridge/adv7511/adv7511.h > +++ b/drivers/gpu/drm/bridge/adv7511/adv7511.h > @@ -93,6 +93,11 @@ > #define ADV7511_REG_CHIP_ID_HIGH 0xf5 > #define ADV7511_REG_CHIP_ID_LOW 0xf6 > > +/* Hardware defined default addresses for I2C register maps */ > +#define ADV7511_CEC_I2C_ADDR_DEFAULT 0x3c > +#define ADV7511_EDID_I2C_ADDR_DEFAULT 0x3f > +#define ADV7511_PACKET_I2C_ADDR_DEFAULT 0x38 > + > #define ADV7511_CSC_ENABLE BIT(7) > #define ADV7511_CSC_UPDATE_MODE BIT(5) > > @@ -321,6 +326,7 @@ enum adv7511_type { > struct adv7511 { > struct i2c_client *i2c_main; > struct i2c_client *i2c_edid; > + struct i2c_client *i2c_packet; > struct i2c_client *i2c_cec; > > struct regmap *regmap; > diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c > index efa29db5fc2b..802bc433f54a 100644 > --- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c > +++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c > @@ -586,7 +586,7 @@ static int adv7511_get_modes(struct adv7511 *adv7511, > /* Reading the EDID only works if the device is powered */ > if (!adv7511->powered) { > unsigned int edid_i2c_addr = > - (adv7511->i2c_main->addr << 1) + 4; > + (adv7511->i2c_edid->addr << 1); > > __adv7511_power_on(adv7511); > > @@ -969,10 +969,10 @@ static int adv7511_init_cec_regmap(struct adv7511 *adv) > { > int ret; > > - adv->i2c_cec = i2c_new_dummy(adv->i2c_main->adapter, > - adv->i2c_main->addr - 1); > + adv->i2c_cec = i2c_new_secondary_device(adv->i2c_main, "cec", > + ADV7511_CEC_I2C_ADDR_DEFAULT); > if (!adv->i2c_cec) > - return -ENOMEM; > + return -EINVAL; > i2c_set_clientdata(adv->i2c_cec, adv); > > adv->regmap_cec = devm_regmap_init_i2c(adv->i2c_cec, > @@ -1082,8 +1082,6 @@ 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; > - unsigned int main_i2c_addr = i2c->addr << 1; > - unsigned int edid_i2c_addr = main_i2c_addr + 4; > unsigned int val; > int ret; > > @@ -1153,23 +1151,34 @@ static int adv7511_probe(struct i2c_client *i2c, const struct i2c_device_id *id) > if (ret) > goto uninit_regulators; > > - regmap_write(adv7511->regmap, ADV7511_REG_EDID_I2C_ADDR, edid_i2c_addr); > - regmap_write(adv7511->regmap, ADV7511_REG_PACKET_I2C_ADDR, > - main_i2c_addr - 0xa); > - regmap_write(adv7511->regmap, ADV7511_REG_CEC_I2C_ADDR, > - main_i2c_addr - 2); > - > adv7511_packet_disable(adv7511, 0xffff); > > - adv7511->i2c_edid = i2c_new_dummy(i2c->adapter, edid_i2c_addr >> 1); > + adv7511->i2c_edid = i2c_new_secondary_device(i2c, "edid", > + ADV7511_EDID_I2C_ADDR_DEFAULT); > if (!adv7511->i2c_edid) { > - ret = -ENOMEM; > + ret = -EINVAL; > goto uninit_regulators; > } > > + regmap_write(adv7511->regmap, ADV7511_REG_EDID_I2C_ADDR, > + adv7511->i2c_edid->addr << 1); > + > + adv7511->i2c_packet = i2c_new_secondary_device(i2c, "packet", > + ADV7511_PACKET_I2C_ADDR_DEFAULT); > + if (!adv7511->i2c_packet) { > + ret = -EINVAL; > + goto err_i2c_unregister_edid; > + } > + > + regmap_write(adv7511->regmap, ADV7511_REG_PACKET_I2C_ADDR, > + adv7511->i2c_packet->addr << 1); > + > ret = adv7511_init_cec_regmap(adv7511); > if (ret) > - goto err_i2c_unregister_edid; > + 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); > > @@ -1207,6 +1216,8 @@ static int adv7511_probe(struct i2c_client *i2c, const struct i2c_device_id *id) > i2c_unregister_device(adv7511->i2c_cec); > if (adv7511->cec_clk) > clk_disable_unprepare(adv7511->cec_clk); > +err_i2c_unregister_packet: > + i2c_unregister_device(adv7511->i2c_packet); > err_i2c_unregister_edid: > i2c_unregister_device(adv7511->i2c_edid); > uninit_regulators: > @@ -1233,6 +1244,7 @@ static int adv7511_remove(struct i2c_client *i2c) > > cec_unregister_adapter(adv7511->cec_adap); > > + i2c_unregister_device(adv7511->i2c_packet); > i2c_unregister_device(adv7511->i2c_edid); > > return 0; >