Received: by 10.223.176.46 with SMTP id f43csp2867376wra; Mon, 22 Jan 2018 04:53:16 -0800 (PST) X-Google-Smtp-Source: AH8x226nQfYFauLnM6+qnw1EJFul/+k4ZuEi81DZZ4/yLgbkJFzkwly+FCKCcR5dFVpk5kcWRUb5 X-Received: by 10.99.95.20 with SMTP id t20mr7234646pgb.79.1516625596375; Mon, 22 Jan 2018 04:53:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516625596; cv=none; d=google.com; s=arc-20160816; b=XOSnZqHiq0zmbKP/ii1/xVejjhOUNpsa7OUJOWP/20tSWijF+fdBz/MdNCgHONqQUS T/DasYfc/sEa1EHzw0vjH4+O48msDDPDhzCZ9WidgAzUbkQLq5IVYaehIeIJS1eTahY8 FUIZ69m+a2VJ6OvukvXBz/RYeVBRl2VBCGS4alMsxBg+QUDox/Cz6GyLisDqgpcwbi0s rkA6LPP+3RU6vQsev6Iq8lZTWnsOhwu+NcYyziXjSu8hJc+9LxaKF4E3W9khJKFpC5Cw fphk/6Pv0SpCEb6gceDCCZFU9tmx1nDsOZ7uk0Zw32B95JZw/yF1gNAqLVcBr9cS9cPh rITw== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=yvDo9HqssDBCtrKFfnZMKntPRwc/Ggxjla6OJbYrLRI=; b=wZSvM6cleRidGbnJTRqNslw96uJ/BE377YjwRr4Z/kxEUAmOnXfIOA2+Rf2R9GnfKV eD0AlPyerTouk6TIcvHKCwlnng9xc+IQ+B6jTsL1d0WYJa7fhF9XsaWPgDRy229YC9Di aDaJJjgdpJ0lITpwn+Mt4JD9fCHwv9K+WHgXtDmt3lpjneRUKnzBgGKadumQGxesvxG3 imM/vGuk2O32N3QcPmJ/MLPu7AU4XAXYUjaXzMcc8XE4kr2+RSl2FkcIr7NmM6HwlMiW vvaHmOp/ttN8ShMkrzLZdLfRf8+e79plxNXrxz8XIwDxgUCd0KpMdqFOrpEXa1PBueCE 98lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sendgrid.me header.s=smtpapi header.b=B3V5bR4c; 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 124si13816970pgi.649.2018.01.22.04.53.02; Mon, 22 Jan 2018 04:53:16 -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 header.i=@sendgrid.me header.s=smtpapi header.b=B3V5bR4c; 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 S1751178AbeAVMwj (ORCPT + 99 others); Mon, 22 Jan 2018 07:52:39 -0500 Received: from o1682455182.outbound-mail.sendgrid.net ([168.245.5.182]:23543 "EHLO o1682455182.outbound-mail.sendgrid.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750970AbeAVMwi (ORCPT ); Mon, 22 Jan 2018 07:52:38 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=sendgrid.me; h=from:to:cc:subject:in-reply-to:references:mime-version:content-type:content-transfer-encoding; s=smtpapi; bh=TFJrw6sps6pamwrhOnlBVykGNUs=; b=B3V5bR4cAWm9jH/zC4 piRYjcb14WYJ9fO6y1RfoG011vOZGvfrB32ABNbYOFIWQEB4du+s3/QNV9/YmDzI 2BfHQ9SCfjlySWuICSXfA2yrMrGr6MWnmbf+AuTkKOMzzUp9oKYtFuj7RAxST1cd RwSF1nArvUDxD6gV4rn3NMb4k= Received: by filter0017p3iad2.sendgrid.net with SMTP id filter0017p3iad2-18204-5A65DDF1-66 2018-01-22 12:49:54.71119606 +0000 UTC Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by ismtpd0003p1lon1.sendgrid.net (SG) with ESMTP id ZIVYYB19SmiCnCd5XReyrw Mon, 22 Jan 2018 12:49:53.841 +0000 (UTC) From: Kieran Bingham To: linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org Cc: Jean-Michel Hautbois , Kieran Bingham , Mauro Carvalho Chehab , Rob Herring , Mark Rutland , Hans Verkuil , devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS) Subject: [PATCH 1/2] media: adv7604: Add support for i2c_new_secondary_device Date: Mon, 22 Jan 2018 12:49:55 +0000 (UTC) Message-Id: <1516625389-6362-2-git-send-email-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516625389-6362-1-git-send-email-kieran.bingham@ideasonboard.com> References: <1516625389-6362-1-git-send-email-kieran.bingham@ideasonboard.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 content-transfer-encoding: quoted-printable X-SG-EID: UsLXQ589HNP4HLBydmD9pgHURQozLYm9XliudupI8YsPEFWoT3EKYhetjJF0cbfqAp0g30r+vuvqLL 9lHRyiAumjnU6mZvUOYD51kP3x4xlSk4apmE2j7mHKDSuCuzRyfKHV7f5fQikQtq1VIHOjhx/Eg2I7 DTtgVtBuiYMwimEGvxZx9dzk4BQvb5z/NjghiqeJPHW5CXbAadNtGD2ihOQB3rMmSUVVQLnpWny0NJ bgcDmySvkzJXldeVMgXRBo Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jean-Michel Hautbois =0D =0D The ADV7604 has thirteen 256-byte maps that can be accessed via the main=0D I=C2=B2C ports. Each map has it own I=C2=B2C address and acts as a standard= slave=0D device on the I=C2=B2C bus.=0D =0D Allow a device tree node to override the default addresses so that=0D address conflicts with other devices on the same bus may be resolved at=0D the board description level.=0D =0D Signed-off-by: Jean-Michel Hautbois =0D [Kieran: Re-adapted for mainline]=0D Signed-off-by: Kieran Bingham =0D ---=0D Based upon the original posting :=0D https://lkml.org/lkml/2014/10/22/469=0D ---=0D .../devicetree/bindings/media/i2c/adv7604.txt | 18 ++++++-=0D drivers/media/i2c/adv7604.c | 60 ++++++++++++++----= ----=0D 2 files changed, 55 insertions(+), 23 deletions(-)=0D =0D diff --git a/Documentation/devicetree/bindings/media/i2c/adv7604.txt b/Docu= mentation/devicetree/bindings/media/i2c/adv7604.txt=0D index 9cbd92eb5d05..b64e313dcc66 100644=0D --- a/Documentation/devicetree/bindings/media/i2c/adv7604.txt=0D +++ b/Documentation/devicetree/bindings/media/i2c/adv7604.txt=0D @@ -13,7 +13,11 @@ Required Properties:=0D - "adi,adv7611" for the ADV7611=0D - "adi,adv7612" for the ADV7612=0D =0D - - reg: I2C slave address=0D + - reg: I2C slave addresses=0D + The ADV76xx has up to thirteen 256-byte maps that can be accessed via = the=0D + main I=C2=B2C ports. Each map has it own I=C2=B2C address and acts as = a standard=0D + slave device on the I=C2=B2C bus. The main address is mandatory, other= s are=0D + optional and revert to defaults if not specified.=0D =0D - hpd-gpios: References to the GPIOs that control the HDMI hot-plug=0D detection pins, one per HDMI input. The active flag indicates the GPIO= =0D @@ -35,6 +39,11 @@ Optional Properties:=0D =0D - reset-gpios: Reference to the GPIO connected to the device's reset pin= .=0D - default-input: Select which input is selected after reset.=0D + - reg-names : Names of maps with programmable addresses.=0D + It can contain any map needing a non-default address.=0D + Possible maps names are :=0D + "main", "avlink", "cec", "infoframe", "esdp", "dpp", "afe",=0D + "rep", "edid", "hdmi", "test", "cp", "vdp"=0D =0D Optional Endpoint Properties:=0D =0D @@ -52,7 +61,12 @@ Example:=0D =0D hdmi_receiver@4c {=0D compatible =3D "adi,adv7611";=0D - reg =3D <0x4c>;=0D + /*=0D + * The edid page will be accessible @ 0x66 on the i2c bus. All=0D + * other maps will retain their default addresses.=0D + */=0D + reg =3D <0x4c 0x66>;=0D + reg-names "main", "edid";=0D =0D reset-gpios =3D <&ioexp 0 GPIO_ACTIVE_LOW>;=0D hpd-gpios =3D <&ioexp 2 GPIO_ACTIVE_HIGH>;=0D diff --git a/drivers/media/i2c/adv7604.c b/drivers/media/i2c/adv7604.c=0D index 1544920ec52d..c346b9a8fb57 100644=0D --- a/drivers/media/i2c/adv7604.c=0D +++ b/drivers/media/i2c/adv7604.c=0D @@ -2734,6 +2734,27 @@ static const struct v4l2_ctrl_config adv76xx_ctrl_fr= ee_run_color =3D {=0D =0D /* -----------------------------------------------------------------------= */=0D =0D +struct adv76xx_register {=0D + const char *name;=0D + u8 default_addr;=0D +};=0D +=0D +static const struct adv76xx_register adv76xx_secondary_names[] =3D {=0D + [ADV76XX_PAGE_IO] =3D { "main", 0x4c },=0D + [ADV7604_PAGE_AVLINK] =3D { "avlink", 0x42 },=0D + [ADV76XX_PAGE_CEC] =3D { "cec", 0x40 },=0D + [ADV76XX_PAGE_INFOFRAME] =3D { "infoframe", 0x3e },=0D + [ADV7604_PAGE_ESDP] =3D { "esdp", 0x38 },=0D + [ADV7604_PAGE_DPP] =3D { "dpp", 0x3c },=0D + [ADV76XX_PAGE_AFE] =3D { "afe", 0x26 },=0D + [ADV76XX_PAGE_REP] =3D { "rep", 0x32 },=0D + [ADV76XX_PAGE_EDID] =3D { "edid", 0x36 },=0D + [ADV76XX_PAGE_HDMI] =3D { "hdmi", 0x34 },=0D + [ADV76XX_PAGE_TEST] =3D { "test", 0x30 },=0D + [ADV76XX_PAGE_CP] =3D { "cp", 0x22 },=0D + [ADV7604_PAGE_VDP] =3D { "vdp", 0x24 },=0D +};=0D +=0D static int adv76xx_core_init(struct v4l2_subdev *sd)=0D {=0D struct adv76xx_state *state =3D to_state(sd);=0D @@ -2834,13 +2855,26 @@ static void adv76xx_unregister_clients(struct adv76= xx_state *state)=0D }=0D =0D static struct i2c_client *adv76xx_dummy_client(struct v4l2_subdev *sd,=0D - u8 addr, u8 io_reg)=0D + unsigned int i)=0D {=0D struct i2c_client *client =3D v4l2_get_subdevdata(sd);=0D + struct adv76xx_state *state =3D to_state(sd);=0D + struct adv76xx_platform_data *pdata =3D &state->pdata;=0D + unsigned int io_reg =3D 0xf2 + i;=0D + struct i2c_client *new_client;=0D +=0D + if (pdata && pdata->i2c_addresses[i])=0D + new_client =3D i2c_new_dummy(client->adapter,=0D + pdata->i2c_addresses[i]);=0D + else=0D + new_client =3D i2c_new_secondary_device(client,=0D + adv76xx_secondary_names[i].name,=0D + adv76xx_secondary_names[i].default_addr);=0D =0D - if (addr)=0D - io_write(sd, io_reg, addr << 1);=0D - return i2c_new_dummy(client->adapter, io_read(sd, io_reg) >> 1);=0D + if (new_client)=0D + io_write(sd, io_reg, new_client->addr << 1);=0D +=0D + return new_client;=0D }=0D =0D static const struct adv76xx_reg_seq adv7604_recommended_settings_afe[] =3D= {=0D @@ -3115,20 +3149,6 @@ static int adv76xx_parse_dt(struct adv76xx_state *st= ate)=0D /* Disable the interrupt for now as no DT-based board uses it. */=0D state->pdata.int1_config =3D ADV76XX_INT1_CONFIG_DISABLED;=0D =0D - /* Use the default I2C addresses. */=0D - state->pdata.i2c_addresses[ADV7604_PAGE_AVLINK] =3D 0x42;=0D - state->pdata.i2c_addresses[ADV76XX_PAGE_CEC] =3D 0x40;=0D - state->pdata.i2c_addresses[ADV76XX_PAGE_INFOFRAME] =3D 0x3e;=0D - state->pdata.i2c_addresses[ADV7604_PAGE_ESDP] =3D 0x38;=0D - state->pdata.i2c_addresses[ADV7604_PAGE_DPP] =3D 0x3c;=0D - state->pdata.i2c_addresses[ADV76XX_PAGE_AFE] =3D 0x26;=0D - state->pdata.i2c_addresses[ADV76XX_PAGE_REP] =3D 0x32;=0D - state->pdata.i2c_addresses[ADV76XX_PAGE_EDID] =3D 0x36;=0D - state->pdata.i2c_addresses[ADV76XX_PAGE_HDMI] =3D 0x34;=0D - state->pdata.i2c_addresses[ADV76XX_PAGE_TEST] =3D 0x30;=0D - state->pdata.i2c_addresses[ADV76XX_PAGE_CP] =3D 0x22;=0D - state->pdata.i2c_addresses[ADV7604_PAGE_VDP] =3D 0x24;=0D -=0D /* Hardcode the remaining platform data fields. */=0D state->pdata.disable_pwrdnb =3D 0;=0D state->pdata.disable_cable_det_rst =3D 0;=0D @@ -3478,9 +3498,7 @@ static int adv76xx_probe(struct i2c_client *client,= =0D if (!(BIT(i) & state->info->page_mask))=0D continue;=0D =0D - state->i2c_clients[i] =3D=0D - adv76xx_dummy_client(sd, state->pdata.i2c_addresses[i],=0D - 0xf2 + i);=0D + state->i2c_clients[i] =3D adv76xx_dummy_client(sd, i);=0D if (!state->i2c_clients[i]) {=0D err =3D -ENOMEM;=0D v4l2_err(sd, "failed to create i2c client %u\n", i);=0D -- =0D 2.7.4=0D