Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp1488345ybb; Fri, 29 Mar 2019 05:38:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqyNJRvdeSEvg4PiO2CcCPdXrrelRQJ+qmFoWA8hYs/f1SbjXLtveZLgeshCVtmeVUAV7SLt X-Received: by 2002:a62:e213:: with SMTP id a19mr1425333pfi.85.1553863124297; Fri, 29 Mar 2019 05:38:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553863124; cv=none; d=google.com; s=arc-20160816; b=bq5jQDuDW4nXe6dqmXNrlTNAl6k/AomQLPRXeeloxekLZe4sl0LjMM6rwWDiX2u037 jXN/21y4l687rhMQS8pDhAJQeC0uYB8ZvTX+M7psDTB6ytAkXEAZu91EXJVW35p8H/J6 0f3iZ+VOzPw9pJcONnsjZ+CX7C+LZ4yNMDNDx1nGkw34tI7hNnUq+dND4CEJOxeVEaDr 8haqAyKcpp1+zezlnmJfKoAFaAvPVTxC+r1I+RuyqPC6/inx12AHhJXh9fmwnEItliiw yDvemkcLTAaS/MUzzrfjZ1XeRXZ+mH49sSR1CwQvN3oC++5Cc+MpB+mixUGo05CTF4nS 79dw== 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 :message-id:date:subject:cc:to:from; bh=4leFWXtt9WIQPxE2qLQjoU027boKrW8xAaLlZmY2fS8=; b=qegaIFsZX2bzPyk42E8IrPu8KT1K6QvMXd7CLFtt9TYlqCTbeM9J8UF2yfzQz25Oie zplpWzwAJ/GFfO3x84uCWLQGpwEVjlJO+Apz0uE9WfbSNDXpfW1tGA4XNE7+KvhSDvio Aq4qgTju5VnVMGaKbmwqJCwyraIMHpGNEpe6rw4Yhfuo7NgcwC8GTEMGebkrVcaZpy+X QUE465THjxu+Ed2p/21icfWbBalIojW64+Rv4YKw1raxAP3sftlZK9GJ+OPEEHt17EDJ iylZ6KMOjH1WzEEjQOYZScUiCAjZlFe02Orljn5IRzpRZW+uhWiw55fmyPi5qAXpEOCQ /gCQ== 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 g188si1820298pgc.88.2019.03.29.05.38.28; Fri, 29 Mar 2019 05:38:44 -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 S1729558AbfC2Mhg (ORCPT + 99 others); Fri, 29 Mar 2019 08:37:36 -0400 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:52706 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729384AbfC2Mhf (ORCPT ); Fri, 29 Mar 2019 08:37:35 -0400 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x2TCWl9A004462; Fri, 29 Mar 2019 13:36:24 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 2rddhc4x5u-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Fri, 29 Mar 2019 13:36:24 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id D297A31; Fri, 29 Mar 2019 12:36:21 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas22.st.com [10.75.90.92]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 8B7CB2A3F; Fri, 29 Mar 2019 12:36:21 +0000 (GMT) Received: from SAFEX1HUBCAS23.st.com (10.75.90.47) by Safex1hubcas22.st.com (10.75.90.92) with Microsoft SMTP Server (TLS) id 14.3.361.1; Fri, 29 Mar 2019 13:36:21 +0100 Received: from localhost (10.201.23.97) by webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.435.0; Fri, 29 Mar 2019 13:36:21 +0100 From: =?UTF-8?q?Yannick=20Fertr=C3=A9?= To: Andrzej Hajda , Laurent Pinchart , David Airlie , "Daniel Vetter" , , , CC: Benjamin Gaignard , Yannick Fertre , Philippe Cornu , "Alexandre Torgue" Subject: [PATCH] drm/bridge: sii902x: initialize CEC device Date: Fri, 29 Mar 2019 13:35:58 +0100 Message-ID: <1553862958-6454-1-git-send-email-yannick.fertre@st.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit X-Originating-IP: [10.201.23.97] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-03-29_07:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Initialize the CEC device embedded into sii902x bridge. By default, the CEC device must be disabled to allow other CEC devices to bypass the bridge. Signed-off-by: Yannick Fertré --- drivers/gpu/drm/bridge/sii902x.c | 64 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c index 08e12fe..d33c097 100644 --- a/drivers/gpu/drm/bridge/sii902x.c +++ b/drivers/gpu/drm/bridge/sii902x.c @@ -83,9 +83,15 @@ #define SII902X_I2C_BUS_ACQUISITION_TIMEOUT_MS 500 +#define SII902X_CEC_I2C_ADDR_DEFAULT 0x60 +#define SII902X_CEC_SETUP 0x8e +#define CEC_EN BIT(4) + struct sii902x { struct i2c_client *i2c; + struct i2c_client *i2c_cec; struct regmap *regmap; + struct regmap *regmap_cec; struct drm_bridge bridge; struct drm_connector connector; struct gpio_desc *reset_gpio; @@ -331,6 +337,22 @@ static const struct regmap_config sii902x_regmap_config = { .cache_type = REGCACHE_NONE, }; +static const struct regmap_range sii902x_cec_volatile_ranges[] = { + { .range_min = 0x84, .range_max = 0xe4 }, +}; + +static const struct regmap_access_table sii902x_cec_volatile_table = { + .yes_ranges = sii902x_cec_volatile_ranges, + .n_yes_ranges = ARRAY_SIZE(sii902x_cec_volatile_ranges), +}; + +static const struct regmap_config sii902x_cec_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + .volatile_table = &sii902x_cec_volatile_table, + .cache_type = REGCACHE_NONE, +}; + static irqreturn_t sii902x_interrupt(int irq, void *data) { struct sii902x *sii902x = data; @@ -460,6 +482,39 @@ static int sii902x_i2c_bypass_deselect(struct i2c_mux_core *mux, u32 chan_id) return 0; } +int sii902x_cec_init(struct device *dev, struct sii902x *sii902x) +{ + struct i2c_client *client; + int ret; + + client = i2c_new_secondary_device(sii902x->i2c, "cec", + SII902X_CEC_I2C_ADDR_DEFAULT); + if (!client) + return -EINVAL; + + sii902x->i2c_cec = client; + + i2c_set_clientdata(sii902x->i2c_cec, sii902x); + + sii902x->regmap_cec = devm_regmap_init_i2c(sii902x->i2c_cec, + &sii902x_cec_regmap_config); + if (IS_ERR(sii902x->regmap_cec)) { + ret = PTR_ERR(sii902x->regmap_cec); + goto err; + } + + /* + * By default, CEC must be disabled to allow other CEC devives + * to bypass the bridge. + */ + regmap_update_bits(sii902x->regmap_cec, SII902X_CEC_SETUP, CEC_EN, 0); + + return 0; +err: + i2c_unregister_device(sii902x->i2c_cec); + return ret; +} + static int sii902x_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -542,7 +597,16 @@ static int sii902x_probe(struct i2c_client *client, return -ENOMEM; sii902x->i2cmux->priv = sii902x; + + ret = sii902x_cec_init(dev, sii902x); + if (ret) + goto err; + return i2c_mux_add_adapter(sii902x->i2cmux, 0, 0, 0); +err: + drm_bridge_remove(&sii902x->bridge); + + return ret; } static int sii902x_remove(struct i2c_client *client) -- 2.7.4