Received: by 10.223.185.116 with SMTP id b49csp3695853wrg; Tue, 13 Feb 2018 06:24:48 -0800 (PST) X-Google-Smtp-Source: AH8x227PaJhrwE4URHCQQ8JOxOYeUX6vWNEekUrl6FXtegZg75KMiXrpZtUn/CSG5ofHq0l4YV1V X-Received: by 2002:a17:902:f81:: with SMTP id 1-v6mr1232974plz.265.1518531887996; Tue, 13 Feb 2018 06:24:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518531887; cv=none; d=google.com; s=arc-20160816; b=zjVQeS3RHtvtOR12gS10JfTjbNDHOasw248taGrx/jU5NJKcuWCEg5Lj9D7Oz7b29t a7VrxsG31VpT2KywGHhSb5TWbwBTug7Vc12DvNJtWqZcJSTKBAMzamv3ms0/QY/IaZd6 JX7PaRm5mf1xFLPMTbYJbda+JJd/kqf29T7XjZOEsflRnpykExu2o8IrmCJd1wH/vgVC m8unby/qgA4okCIJZoR12HGePXfNmjmFZsDpqJGwe+JmmWs/HzulKHmaMVEVI88HaG2G za+I3rU9e43zdyqHzh5ZMlXLIUV8GSa1cfSTn11oVupVrDbdUkcHtt9HcAIPM+vsVtne 5D8Q== 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:organization:from:references:cc:to:subject :dkim-signature:arc-authentication-results; bh=uaqlPtOhTF+v9skjJVA7/PZ8xWo7Tym+9I5PeBRTTlI=; b=rFgyRJDFfjtzFDHkZA8WRpMtsYQ3wVyxlHdm828NXZse7wAIRSajyoJXXkOLISIkHo PHElCJYIuFFBdhXzKqZBQx8s7zy4L/qr+pEbT8OzuDtLkJ78x1KmyCVRNu4Gq/+IEvmQ OxKjgDpHRIrhswpteocc9/8LazK6UGYgoo5GhQVfvbah/TVdoldLM2AnbLTxrwkMPIxI 436A2FATfBwUQFK7Gt0A/86RmlryabSim9v6DgsDh4YkMuoGLa/Xia3ymJcalG28PMk/ hDNCqy4rs0C7ogTKjLZ29QmMC981Qtcns2PlYnZIqP/ryyQ1CSPg9FwmrhbF4bDQ4n6E blxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=X7K6iHeR; 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 e17si1169511pgo.189.2018.02.13.06.24.32; Tue, 13 Feb 2018 06:24:47 -0800 (PST) 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 (test mode) header.i=@ideasonboard.com header.s=mail header.b=X7K6iHeR; 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 S935246AbeBMOXs (ORCPT + 99 others); Tue, 13 Feb 2018 09:23:48 -0500 Received: from galahad.ideasonboard.com ([185.26.127.97]:43926 "EHLO galahad.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933555AbeBMOXr (ORCPT ); Tue, 13 Feb 2018 09:23:47 -0500 Received: from [192.168.0.20] (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by galahad.ideasonboard.com (Postfix) with ESMTPSA id 43FB12005E; Tue, 13 Feb 2018 15:22:14 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1518531735; bh=14CYAOlB5cSDqo4+nfosHEwAJVv8VmeE4tkAKjrDbDY=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=X7K6iHeR24Vyt8tW/REuhzS/rQNXvtP82Z6uqGGeLQIYeoOoCT3uPrrO3VDeJtxSF 05GAHqqBrA+1RnptC5yd6YqQBZDi8oxgsB9Fl0H/7lm8T3iPpfHNEHlLH/lGlUnbb6 3Y8VqVRZcw3fXunt+KsuG0HJqg69fnmsSC19Txic= Subject: Re: [PATCH v3 5/5] drm: adv7511: Add support for i2c_new_secondary_device To: Laurent Pinchart Cc: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Kieran Bingham , Jean-Michel Hautbois , Sergei Shtylyov , Lars-Peter Clausen , Kieran Bingham , Archit Taneja , Andrzej Hajda , David Airlie , Hans Verkuil , Neil Armstrong , Daniel Vetter , Bhumika Goyal , Inki Dae References: <1518473273-6333-1-git-send-email-kbingham@kernel.org> <1518473273-6333-6-git-send-email-kbingham@kernel.org> <3664373.zGkbJUDGbo@avalon> From: Kieran Bingham Organization: Ideas on Board Message-ID: <9db9aec6-5ab3-4a67-d705-19d91667d5dc@ideasonboard.com> Date: Tue, 13 Feb 2018 14:23:41 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: <3664373.zGkbJUDGbo@avalon> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Laurent, Thanks for the review, On 13/02/18 12:23, Laurent Pinchart wrote: > Hi Kieran, > > Thank you for the patch. > > On Tuesday, 13 February 2018 00:07:53 EET Kieran Bingham wrote: >> From: Kieran Bingham >> >> The ADV7511 has four 256-byte maps that can be accessed via the main I²C >> ports. Each map has it own I²C address and acts as a standard slave >> device on the I²C 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. >> >> Signed-off-by: Kieran Bingham >> --- >> v2: >> - Update missing edid-i2c address setting >> - Split out DT bindings >> - Rename and move the I2C default addresses to their own section >> >> 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..04e6759ee45b >> 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 */ > > s/i2c/I2C/ ? That's really because I had to find something :-) The I²C comes from JMH's original patch, but is much harder to grep for, so normalising to I2C throughout. > > Reviewed-by: Laurent Pinchart >> +#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) >> >> @@ -322,6 +327,7 @@ struct adv7511 { >> struct i2c_client *i2c_main; >> struct i2c_client *i2c_edid; >> struct i2c_client *i2c_cec; >> + struct i2c_client *i2c_packet; >> >> struct regmap *regmap; >> struct regmap *regmap_cec; >> diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c >> b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c index >> efa29db5fc2b..5e61b928c9c0 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,24 +1151,35 @@ 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); >> + >> ret = adv7511_init_cec_regmap(adv7511); >> if (ret) >> goto err_i2c_unregister_edid; >> >> + regmap_write(adv7511->regmap, ADV7511_REG_CEC_I2C_ADDR, >> + adv7511->i2c_cec->addr << 1); >> + >> + adv7511->i2c_packet = i2c_new_secondary_device(i2c, "packet", >> + ADV7511_PACKET_I2C_ADDR_DEFAULT); >> + if (!adv7511->i2c_packet) { >> + ret = -EINVAL; >> + goto err_unregister_cec; >> + } >> + >> + regmap_write(adv7511->regmap, ADV7511_REG_PACKET_I2C_ADDR, >> + adv7511->i2c_packet->addr << 1); >> + >> INIT_WORK(&adv7511->hpd_work, adv7511_hpd_work); >> >> if (i2c->irq) { >> @@ -1181,7 +1190,7 @@ static int adv7511_probe(struct i2c_client *i2c, const >> struct i2c_device_id *id) IRQF_ONESHOT, dev_name(dev), >> adv7511); >> if (ret) >> - goto err_unregister_cec; >> + goto err_unregister_packet; >> } >> >> adv7511_power_off(adv7511); >> @@ -1203,6 +1212,8 @@ static int adv7511_probe(struct i2c_client *i2c, const >> struct i2c_device_id *id) adv7511_audio_init(dev, adv7511); >> return 0; >> >> +err_unregister_packet: >> + i2c_unregister_device(adv7511->i2c_packet); >> err_unregister_cec: >> i2c_unregister_device(adv7511->i2c_cec); >> if (adv7511->cec_clk) >> @@ -1234,6 +1245,7 @@ static int adv7511_remove(struct i2c_client *i2c) >> cec_unregister_adapter(adv7511->cec_adap); >> >> i2c_unregister_device(adv7511->i2c_edid); >> + i2c_unregister_device(adv7511->i2c_packet); >> >> return 0; >> } >