From patchwork Mon Dec 9 14:50:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hsin-Yi Wang X-Patchwork-Id: 11281687 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9A84814B7 for ; Tue, 10 Dec 2019 08:41:08 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 794D4206D5 for ; Tue, 10 Dec 2019 08:41:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="FoiOPgQc" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 794D4206D5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6FFDC6E841; Tue, 10 Dec 2019 08:40:43 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5C6BD6E48E for ; Mon, 9 Dec 2019 14:51:38 +0000 (UTC) Received: by mail-pg1-x542.google.com with SMTP id l24so7245028pgk.2 for ; Mon, 09 Dec 2019 06:51:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cGLkt56MhFh8o5EiPOGN5Gs/bQLSYtcgRKiESMUAAEg=; b=FoiOPgQcYmkXm/tZqxmuOTlheNX0AgdOI/2MZIVoyVaDZ2omAlNpvjC5J7UkXZjHkN w/FEIk9KLjFC9aKhMHaRz6mznpSflD0o8I0Gq9L9AKEzN5+Ft6j7taGzy5nEO8JDQzdE SXjPxv1lzNd1yp0r/THRyWzyCzs5KLo3RQEv8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cGLkt56MhFh8o5EiPOGN5Gs/bQLSYtcgRKiESMUAAEg=; b=ZCDG7WCZbL5EVJn/xad2lEgdZ6L1mwjmAfU4MK9pFHZHFufa41eM3B/mto9Xxjm7pg au3ZsxbDKub5dLyslYKz1F/L1C8JziQjtmrwRIcJVlQcChgjJheW7A3G7UkxbU0QUtXn fqk7SWvhagNMHte4uUJcntRNVQA+ryFVzjoFFWLaIO7Sdotpawz1xaVjB7HGtYPaxKOZ FFxy9OCCAU1RwGAY2o8PLpSBWrVCJcmSn05Qk33uA4ZHQs6MzUIQ65EuNnNvFh3xMmcl Cb8a65zzPpkvezpAZIoinJTCic8/Nq3Q/gqqRNE4SYNjI3ljnp69aJ9rjk1MrzuQpcQn j6wQ== X-Gm-Message-State: APjAAAXwABcrOXgrYQADt+IxdSeduhws8MTJ+HfzlPXT5pD1zthN/bhB j/LDNl2WsRkk29tnCOAnGptDtA/kVkZCiQ== X-Google-Smtp-Source: APXvYqwdFN4BDi6/3J9nybGN70nDZ2haqNMPr+4STLfU6yafWcXmeyYw7k9dIphwuYdoFrfoWNCktQ== X-Received: by 2002:a63:93:: with SMTP id 141mr18975594pga.411.1575903097523; Mon, 09 Dec 2019 06:51:37 -0800 (PST) Received: from hsinyi-z840.tpe.corp.google.com ([2401:fa00:1:10:b852:bd51:9305:4261]) by smtp.gmail.com with ESMTPSA id k16sm29143119pfh.97.2019.12.09.06.51.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Dec 2019 06:51:37 -0800 (PST) From: Hsin-Yi Wang To: dri-devel@lists.freedesktop.org Subject: [PATCH RESEND 1/4] dt-bindings: drm/bridge: analogix-anx7688: Add ANX7688 transmitter binding Date: Mon, 9 Dec 2019 22:50:13 +0800 Message-Id: <20191209145016.227784-2-hsinyi@chromium.org> X-Mailer: git-send-email 2.24.0.393.g34dc348eaf-goog In-Reply-To: <20191209145016.227784-1-hsinyi@chromium.org> References: <20191209145016.227784-1-hsinyi@chromium.org> MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 10 Dec 2019 08:40:04 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, Jernej Skrabec , Nicolas Boichat , Neil Armstrong , David Airlie , Jonas Karlman , linux-kernel@vger.kernel.org, Archit Taneja , Rob Herring , Laurent Pinchart , Matthias Brugger , Enric Balletbo i Serra , Russell King Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Nicolas Boichat Add support for analogix,anx7688 Signed-off-by: Nicolas Boichat Signed-off-by: Hsin-Yi Wang --- .../bindings/display/bridge/anx7688.txt | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Documentation/devicetree/bindings/display/bridge/anx7688.txt diff --git a/Documentation/devicetree/bindings/display/bridge/anx7688.txt b/Documentation/devicetree/bindings/display/bridge/anx7688.txt new file mode 100644 index 000000000000..78b55bdb18f7 --- /dev/null +++ b/Documentation/devicetree/bindings/display/bridge/anx7688.txt @@ -0,0 +1,32 @@ +Analogix ANX7688 SlimPort (Single-Chip Transmitter for DP over USB-C) +--------------------------------------------------------------------- + +The ANX7688 is a single-chip mobile transmitter to support 4K 60 frames per +second (4096x2160p60) or FHD 120 frames per second (1920x1080p120) video +resolution from a smartphone or tablet with full function USB-C. + +This binding only describes the HDMI to DP display bridge. + +Required properties: + + - compatible : "analogix,anx7688" + - reg : I2C address of the device (fixed at 0x2c) + +Optional properties: + + - Video port for HDMI input, using the DT bindings defined in [1]. + +[1]: Documentation/devicetree/bindings/media/video-interfaces.txt + +Example: + + anx7688: anx7688@2c { + compatible = "analogix,anx7688"; + reg = <0x2c>; + + port { + anx7688_in: endpoint { + remote-endpoint = <&hdmi0_out>; + }; + }; + }; From patchwork Mon Dec 9 14:50:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hsin-Yi Wang X-Patchwork-Id: 11281663 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 64F4A930 for ; Tue, 10 Dec 2019 08:40:36 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 43061206D5 for ; Tue, 10 Dec 2019 08:40:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="Kwn0aCF5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 43061206D5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1AC5F89D02; Tue, 10 Dec 2019 08:40:09 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by gabe.freedesktop.org (Postfix) with ESMTPS id CA9E16E48E for ; Mon, 9 Dec 2019 14:51:42 +0000 (UTC) Received: by mail-pl1-x644.google.com with SMTP id o9so5906557plk.6 for ; Mon, 09 Dec 2019 06:51:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Wkr31BcuGIKRbU/y5I32iuJXAa0HvWpiYxphQuZXBlE=; b=Kwn0aCF5ZAc/IReb3eYAE5BovnP2NQIg3KZttdyuQpFoRA6sttmjYM3JI3rX2oX4gt kHQT0Yro/Ir4VC3wWDlfs6qpZ2OTQPaEjyKN4SQDP40EXFG9QIxC0BnlMAT7oSwmSUYd BEIibXETEjLBycnz0mvhs1GtZE3jn9aCRr6eQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Wkr31BcuGIKRbU/y5I32iuJXAa0HvWpiYxphQuZXBlE=; b=gwKrqmIfq94sU6kBZqvLnWTmk/do2Cw5WSMg6EhC4qI+qHsy5yMBG9jGidE6QDBGS+ tjxspQkyAXmZpt+HFZkHWm3fb/Ll4mbJFtRAOqGXFG0txYOdWmH1YrqOXXSoUCijUWIu Pkq23Jakkvenl0jyaYVuiHsKPu0d3K+Ye37l6U64vn3yNQ4PAblWA/CAzW35pG094Htn wLaslTjDTePUT6R38nlfPeaD9DitpYp+NqAS1xKPNl9MyIvNzXTndvvKGjcNOmtVzXAz Q9gbz0lF39wFw800Fd4a54sSaadmKDZ3kokqyYvvDBuUYZSH4IUQD+myFm1cISXlEWXT L0TA== X-Gm-Message-State: APjAAAWdUdlEQ1htoT9t7aYOZYbuUrx6hx7UIJlx9c8aLsBMwAUXXqwn fdCibQzIfH8Ld0bxyy1Udtp5Q3mHI83hmQ== X-Google-Smtp-Source: APXvYqwsMOja5csTw+BFyRrAWrm09PKT+KRpdPz2sq8cN/9kiu2drYyM/M61zfXNEaSyKHkzxkF9Ag== X-Received: by 2002:a17:902:9a97:: with SMTP id w23mr30145463plp.79.1575903101988; Mon, 09 Dec 2019 06:51:41 -0800 (PST) Received: from hsinyi-z840.tpe.corp.google.com ([2401:fa00:1:10:b852:bd51:9305:4261]) by smtp.gmail.com with ESMTPSA id k16sm29143119pfh.97.2019.12.09.06.51.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Dec 2019 06:51:41 -0800 (PST) From: Hsin-Yi Wang To: dri-devel@lists.freedesktop.org Subject: [PATCH RESEND 2/4] drm: bridge: anx7688: Add anx7688 bridge driver support. Date: Mon, 9 Dec 2019 22:50:14 +0800 Message-Id: <20191209145016.227784-3-hsinyi@chromium.org> X-Mailer: git-send-email 2.24.0.393.g34dc348eaf-goog In-Reply-To: <20191209145016.227784-1-hsinyi@chromium.org> References: <20191209145016.227784-1-hsinyi@chromium.org> MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 10 Dec 2019 08:40:04 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, Jernej Skrabec , Nicolas Boichat , Neil Armstrong , David Airlie , Jonas Karlman , linux-kernel@vger.kernel.org, Archit Taneja , Rob Herring , Laurent Pinchart , Matthias Brugger , Enric Balletbo i Serra , Russell King Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Nicolas Boichat ANX7688 is a HDMI to DP converter (as well as USB-C port controller), that has an internal microcontroller. The only reason a Linux kernel driver is necessary is to reject resolutions that require more bandwidth than what is available on the DP side. DP bandwidth and lane count are reported by the bridge via 2 registers on I2C. Signed-off-by: Nicolas Boichat Signed-off-by: Hsin-Yi Wang --- drivers/gpu/drm/bridge/Kconfig | 9 + drivers/gpu/drm/bridge/Makefile | 1 + drivers/gpu/drm/bridge/analogix-anx7688.c | 203 ++++++++++++++++++++++ 3 files changed, 213 insertions(+) create mode 100644 drivers/gpu/drm/bridge/analogix-anx7688.c diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig index 34362976cd6f..1f3fc6bec842 100644 --- a/drivers/gpu/drm/bridge/Kconfig +++ b/drivers/gpu/drm/bridge/Kconfig @@ -16,6 +16,15 @@ config DRM_PANEL_BRIDGE menu "Display Interface Bridges" depends on DRM && DRM_BRIDGE +config DRM_ANALOGIX_ANX7688 + tristate "Analogix ANX7688 bridge" + select DRM_KMS_HELPER + select REGMAP_I2C + ---help--- + ANX7688 is a transmitter to support DisplayPort over USB-C for + smartphone and tablets. + This driver only supports the HDMI to DP component of the chip. + config DRM_ANALOGIX_ANX78XX tristate "Analogix ANX78XX bridge" select DRM_KMS_HELPER diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile index 4934fcf5a6f8..7a1e0ec032e6 100644 --- a/drivers/gpu/drm/bridge/Makefile +++ b/drivers/gpu/drm/bridge/Makefile @@ -1,4 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_DRM_ANALOGIX_ANX7688) += analogix-anx7688.o obj-$(CONFIG_DRM_ANALOGIX_ANX78XX) += analogix-anx78xx.o obj-$(CONFIG_DRM_CDNS_DSI) += cdns-dsi.o obj-$(CONFIG_DRM_DUMB_VGA_DAC) += dumb-vga-dac.o diff --git a/drivers/gpu/drm/bridge/analogix-anx7688.c b/drivers/gpu/drm/bridge/analogix-anx7688.c new file mode 100644 index 000000000000..5a3a2251c1c5 --- /dev/null +++ b/drivers/gpu/drm/bridge/analogix-anx7688.c @@ -0,0 +1,203 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * ANX7688 HDMI->DP bridge driver + * + * Copyright 2016 Google LLC + */ + +#include +#include +#include +#include +#include + +/* Register addresses */ +#define VENDOR_ID_REG 0x00 +#define DEVICE_ID_REG 0x02 + +#define FW_VERSION_REG 0x80 + +#define DP_BANDWIDTH_REG 0x85 +#define DP_LANE_COUNT_REG 0x86 + +#define VENDOR_ID 0x1f29 +#define DEVICE_ID 0x7688 + +/* First supported firmware version (0.85) */ +#define MINIMUM_FW_VERSION 0x0085 + +struct anx7688 { + struct drm_bridge bridge; + struct i2c_client *client; + struct regmap *regmap; + + bool filter; +}; + +static inline struct anx7688 *bridge_to_anx7688(struct drm_bridge *bridge) +{ + return container_of(bridge, struct anx7688, bridge); +} + +static bool anx7688_bridge_mode_fixup(struct drm_bridge *bridge, + const struct drm_display_mode *mode, + struct drm_display_mode *adjusted_mode) +{ + struct anx7688 *anx7688 = bridge_to_anx7688(bridge); + u8 regs[2]; + u8 dpbw, lanecount; + int totalbw, requiredbw; + int ret; + + if (!anx7688->filter) + return true; + + /* Read both regs 0x85 (bandwidth) and 0x86 (lane count). */ + ret = regmap_bulk_read(anx7688->regmap, DP_BANDWIDTH_REG, regs, 2); + if (ret < 0) { + dev_err(&anx7688->client->dev, + "Failed to read bandwidth/lane count\n"); + return false; + } + dpbw = regs[0]; + lanecount = regs[1]; + + /* Maximum 0x19 bandwidth (6.75 Gbps Turbo mode), 2 lanes */ + if (dpbw > 0x19 || lanecount > 2) { + dev_err(&anx7688->client->dev, + "Invalid bandwidth/lane count (%02x/%d)\n", + dpbw, lanecount); + return false; + } + + /* Compute available bandwidth (kHz) */ + totalbw = dpbw * lanecount * 270000 * 8 / 10; + + /* Required bandwidth (8 bpc, kHz) */ + requiredbw = mode->clock * 8 * 3; + + dev_dbg(&anx7688->client->dev, + "DP bandwidth: %d kHz (%02x/%d); mode requires %d Khz\n", + totalbw, dpbw, lanecount, requiredbw); + + if (totalbw == 0) { + dev_warn(&anx7688->client->dev, + "Bandwidth/lane count are 0, not rejecting modes\n"); + return true; + } + + return totalbw >= requiredbw; +} + +static const struct drm_bridge_funcs anx7688_bridge_funcs = { + .mode_fixup = anx7688_bridge_mode_fixup, +}; + +static const struct regmap_config anx7688_regmap_config = { + .reg_bits = 8, + .val_bits = 8, +}; + +static int anx7688_i2c_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct anx7688 *anx7688; + struct device *dev = &client->dev; + int ret; + u8 buffer[4]; + u16 vendor, device, fwversion; + + anx7688 = devm_kzalloc(dev, sizeof(*anx7688), GFP_KERNEL); + if (!anx7688) + return -ENOMEM; + +#if IS_ENABLED(CONFIG_OF) + anx7688->bridge.of_node = client->dev.of_node; +#endif + + anx7688->client = client; + i2c_set_clientdata(client, anx7688); + + anx7688->regmap = + devm_regmap_init_i2c(client, &anx7688_regmap_config); + + /* Read both vendor and device id (4 bytes). */ + ret = regmap_bulk_read(anx7688->regmap, VENDOR_ID_REG, buffer, 4); + if (ret) { + dev_err(dev, "Failed to read chip vendor/device id\n"); + return ret; + } + + vendor = (u16)buffer[1] << 8 | buffer[0]; + device = (u16)buffer[3] << 8 | buffer[2]; + if (vendor != VENDOR_ID || device != DEVICE_ID) { + dev_err(dev, "Invalid vendor/device id %04x/%04x\n", + vendor, device); + return -ENODEV; + } + + ret = regmap_bulk_read(anx7688->regmap, FW_VERSION_REG, buffer, 2); + if (ret) { + dev_err(&client->dev, "Failed to read firmware version\n"); + return ret; + } + + fwversion = (u16)buffer[0] << 8 | buffer[1]; + dev_info(dev, "ANX7688 firwmare version %02x.%02x\n", + buffer[0], buffer[1]); + + /* FW version >= 0.85 supports bandwidth/lane count registers */ + if (fwversion >= MINIMUM_FW_VERSION) { + anx7688->filter = true; + } else { + /* Warn, but not fail, for backwards compatibility. */ + dev_warn(dev, + "Old ANX7688 FW version (%02x.%02x), not filtering\n", + buffer[0], buffer[1]); + } + + anx7688->bridge.funcs = &anx7688_bridge_funcs; + drm_bridge_add(&anx7688->bridge); + + return 0; +} + +static int anx7688_i2c_remove(struct i2c_client *client) +{ + struct anx7688 *anx7688 = i2c_get_clientdata(client); + + drm_bridge_remove(&anx7688->bridge); + + return 0; +} + +static const struct i2c_device_id anx7688_id[] = { + { "anx7688", 0 }, + { /* sentinel */ } +}; + +MODULE_DEVICE_TABLE(i2c, anx7688_id); + +#if IS_ENABLED(CONFIG_OF) +static const struct of_device_id anx7688_match_table[] = { + { .compatible = "analogix,anx7688", }, + { /* sentinel */ }, +}; +MODULE_DEVICE_TABLE(of, anx7688_match_table); +#endif + +static struct i2c_driver anx7688_driver = { + .driver = { + .name = "anx7688", + .of_match_table = of_match_ptr(anx7688_match_table), + }, + .probe = anx7688_i2c_probe, + .remove = anx7688_i2c_remove, + .id_table = anx7688_id, +}; + +module_i2c_driver(anx7688_driver); + +MODULE_DESCRIPTION("ANX7688 SlimPort Transmitter driver"); +MODULE_AUTHOR("Nicolas Boichat "); +MODULE_LICENSE("GPL v2"); From patchwork Mon Dec 9 14:50:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hsin-Yi Wang X-Patchwork-Id: 11281679 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2150814B7 for ; Tue, 10 Dec 2019 08:40:53 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id F2993206D5 for ; Tue, 10 Dec 2019 08:40:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="XogCXVx2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org F2993206D5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 08BDC6E834; Tue, 10 Dec 2019 08:40:32 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by gabe.freedesktop.org (Postfix) with ESMTPS id B74486E48F for ; Mon, 9 Dec 2019 14:51:46 +0000 (UTC) Received: by mail-pl1-x642.google.com with SMTP id g6so5902707plp.7 for ; Mon, 09 Dec 2019 06:51:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=jJwCq9E5sHUES1apw52pvzBBVDCgoOmF9UzMrlF+I9Y=; b=XogCXVx2RXzDAutpzGtBCHE+T8kLmeCQvQsMdlbs1tDq7y1UrkAwc/k+g7CufIO+PA dpQKZ4iazoJSwFFuHkVnZErr6o6mC7eXyQQPeDi2oYU+ZfEdPXZgi7FkAEORJ/7BN9k1 evO2wVdIGUA1AbJjhA2vmOqgRcmVLhvVO95t0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=jJwCq9E5sHUES1apw52pvzBBVDCgoOmF9UzMrlF+I9Y=; b=UeN4a6A832F7ZE31c5QMKsCzxXTIIw9UHn0d0ct0Su6mfgcDl1mF5XnK2u74Nmrbx5 pIhN6fBK8uQU8k+xARMEpJN3GGX+AVRMlyU+af6EGQ/fcxYB1Dm+NbLeQFjE0W6tPvRg IbmCAU5LKw4xhfc1Mvto4cGU5ZJJ/ycJgjJJlv1nK/9v/zXCq3/Q7SM4+VcywwWYpzpx jU3NROY9Y7v3pWWK5rD21+kUoprogxguIPl/W4m9JZBAGJwe7yZIpQZlfggNHlGtHL2e fyF72wd/2CLKQIAH6m6zkHRB6Ur8x4bd8Tzu6jSkndIsqf2rx+oQowQYyKeUfPVhIcFk lPCA== X-Gm-Message-State: APjAAAWYrFbI4TXVIKMbMWG35MHSZf1rj8A+IjnyvWcdbrqqk+5USku4 T4Nbec4INct5S/7IFPqKgaksC5+l6TClFQ== X-Google-Smtp-Source: APXvYqxU02o6BtUzY2uYrPaZe5xjkP17fMbo/9XayXiUcb1MB3mIfbRhi9fLq+g8w3r6KCxzsaaOJw== X-Received: by 2002:a17:902:a503:: with SMTP id s3mr5631915plq.38.1575903106015; Mon, 09 Dec 2019 06:51:46 -0800 (PST) Received: from hsinyi-z840.tpe.corp.google.com ([2401:fa00:1:10:b852:bd51:9305:4261]) by smtp.gmail.com with ESMTPSA id k16sm29143119pfh.97.2019.12.09.06.51.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Dec 2019 06:51:45 -0800 (PST) From: Hsin-Yi Wang To: dri-devel@lists.freedesktop.org Subject: [PATCH RESEND 3/4] dt-bindings: drm/bridge: analogix-anx78xx: support bypass GPIO Date: Mon, 9 Dec 2019 22:50:15 +0800 Message-Id: <20191209145016.227784-4-hsinyi@chromium.org> X-Mailer: git-send-email 2.24.0.393.g34dc348eaf-goog In-Reply-To: <20191209145016.227784-1-hsinyi@chromium.org> References: <20191209145016.227784-1-hsinyi@chromium.org> MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 10 Dec 2019 08:40:04 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, Jernej Skrabec , Nicolas Boichat , Neil Armstrong , David Airlie , Jonas Karlman , linux-kernel@vger.kernel.org, Archit Taneja , Rob Herring , Laurent Pinchart , Matthias Brugger , Enric Balletbo i Serra , Russell King Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Support optional feature: bypass GPIO. Some SoC (eg. mt8173) have a hardware mux that connects to 2 ports: anx7688 and hdmi. When the GPIO is active, the bridge is bypassed. Signed-off-by: Hsin-Yi Wang --- .../bindings/display/bridge/anx7688.txt | 40 ++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/display/bridge/anx7688.txt b/Documentation/devicetree/bindings/display/bridge/anx7688.txt index 78b55bdb18f7..44185dcac839 100644 --- a/Documentation/devicetree/bindings/display/bridge/anx7688.txt +++ b/Documentation/devicetree/bindings/display/bridge/anx7688.txt @@ -15,10 +15,13 @@ Required properties: Optional properties: - Video port for HDMI input, using the DT bindings defined in [1]. + - bypass-gpios : External GPIO. If this GPIO is active, we assume + the bridge is bypassed (e.g. by a mux). + - pinctrl-0, pinctrl-names: the pincontrol settings to configure bypass GPIO. [1]: Documentation/devicetree/bindings/media/video-interfaces.txt -Example: +Example 1: anx7688: anx7688@2c { compatible = "analogix,anx7688"; @@ -30,3 +33,38 @@ Example: }; }; }; + +Example 2: + + anx7688: anx7688@2c { + compatible = "analogix,anx7688"; + status = "okay"; + reg = <0x2c>; + ddc-i2c-bus = <&hdmiddc0>; + + bypass-gpios = <&pio 36 GPIO_ACTIVE_HIGH>; + pinctrl-names = "default"; + pinctrl-0 = <&hdmi_mux_pins>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { /* input */ + reg = <0>; + + anx7688_in: endpoint { + remote-endpoint = <&hdmi_out_anx>; + }; + }; + + port@1 { /* output */ + reg = <1>; + + anx7688_out: endpoint { + remote-endpoint = <&hdmi_connector_in>; + }; + }; + }; + }; + From patchwork Mon Dec 9 14:50:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hsin-Yi Wang X-Patchwork-Id: 11281673 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9DFF5930 for ; Tue, 10 Dec 2019 08:40:47 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7B83E207FF for ; Tue, 10 Dec 2019 08:40:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="mgRkhidW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7B83E207FF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 62EB16E82E; Tue, 10 Dec 2019 08:40:28 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by gabe.freedesktop.org (Postfix) with ESMTPS id C445B6E48F for ; Mon, 9 Dec 2019 14:51:50 +0000 (UTC) Received: by mail-pf1-x444.google.com with SMTP id s18so7354872pfd.8 for ; Mon, 09 Dec 2019 06:51:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uaDYqsyc1Amfj+rSgV5LdqRPEszOSqeoO5bxQF6wI/8=; b=mgRkhidWIwQrXgZ+53Q3ES0onwYvT97F/zSJomcMLUsE3rX1QvgnpHcPZGSNwySnyL v4fWp3ofa4Ls1qwhijcJQIQeRtVEa7DifKsIRjyLmsfGNCv6gf6Ntb/rBTM1y39ufl4B lHTGSCi6gahnJsCCQeNaViCA8QJnrfYvVWwbE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uaDYqsyc1Amfj+rSgV5LdqRPEszOSqeoO5bxQF6wI/8=; b=T81F/S6Wx8PO8jdW8fk86ex8RO5jM3jSjUqYMY2j3CFO9walX3fMHsgr/MXBGtonEb v4iCoCBLQRO+CMPDWLRdoBg29+6Zb/r4pB5oElW8gvIaxnFPx33Qfk+ATtEDBDWQKpgm io9Vr7L/MCsReiSgLytNjOl5hqIT5jT5rMGGra5dAi0cr3InTxcYjl/WD1RyOeU0IFkl 6E87xia9+EPDmzq52oKiI/njF0m+HidnYKiAkRY+om7NLyGHgfU7FpZbu7HzfS+Ol0xS aZyeYrJCEYONFcmZeYHFP/8bsrQVvY69a/ZF6giY7vDKhTsP6W6C4FrIBhKyacGxAC3m Hafw== X-Gm-Message-State: APjAAAXDKlTXivDTZwhO3Eer/GXxM3to1QqZRNhpQfoqDFG0yCwfBbAq fg1b+R+HJ0nNT4nhzzkS5LPlX6R5bz4/9A== X-Google-Smtp-Source: APXvYqzAxcbhb9dq2bTBZndMkD6J3hhmRbSgWIiplaCgX/EMjF8TeQ17Ny2l9Uhse5276EJgApSiUA== X-Received: by 2002:a65:5c0a:: with SMTP id u10mr18950072pgr.258.1575903110084; Mon, 09 Dec 2019 06:51:50 -0800 (PST) Received: from hsinyi-z840.tpe.corp.google.com ([2401:fa00:1:10:b852:bd51:9305:4261]) by smtp.gmail.com with ESMTPSA id k16sm29143119pfh.97.2019.12.09.06.51.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Dec 2019 06:51:49 -0800 (PST) From: Hsin-Yi Wang To: dri-devel@lists.freedesktop.org Subject: [PATCH RESEND 4/4] drm: bridge: anx7688: Support bypass GPIO feature Date: Mon, 9 Dec 2019 22:50:16 +0800 Message-Id: <20191209145016.227784-5-hsinyi@chromium.org> X-Mailer: git-send-email 2.24.0.393.g34dc348eaf-goog In-Reply-To: <20191209145016.227784-1-hsinyi@chromium.org> References: <20191209145016.227784-1-hsinyi@chromium.org> MIME-Version: 1.0 X-Mailman-Approved-At: Tue, 10 Dec 2019 08:40:04 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, Jernej Skrabec , Nicolas Boichat , Neil Armstrong , David Airlie , Jonas Karlman , linux-kernel@vger.kernel.org, Archit Taneja , Rob Herring , Laurent Pinchart , Matthias Brugger , Enric Balletbo i Serra , Russell King Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Support optional feature: bypass GPIO. Get GPIO status in irq handler. If GPIO is active, mode_fixup would be bypassed. Signed-off-by: Hsin-Yi Wang --- drivers/gpu/drm/bridge/analogix-anx7688.c | 57 +++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/drivers/gpu/drm/bridge/analogix-anx7688.c b/drivers/gpu/drm/bridge/analogix-anx7688.c index 5a3a2251c1c5..1d09db2cf8e9 100644 --- a/drivers/gpu/drm/bridge/analogix-anx7688.c +++ b/drivers/gpu/drm/bridge/analogix-anx7688.c @@ -5,11 +5,16 @@ * Copyright 2016 Google LLC */ +#include #include +#include #include +#include #include #include #include +#include +#include /* Register addresses */ #define VENDOR_ID_REG 0x00 @@ -31,6 +36,9 @@ struct anx7688 { struct i2c_client *client; struct regmap *regmap; + struct gpio_desc *gpiod_bypass; + int bypass; + bool filter; }; @@ -49,6 +57,10 @@ static bool anx7688_bridge_mode_fixup(struct drm_bridge *bridge, int totalbw, requiredbw; int ret; + /* bypass anx mode fixup */ + if (anx7688->bypass) + return true; + if (!anx7688->filter) return true; @@ -93,6 +105,19 @@ static const struct drm_bridge_funcs anx7688_bridge_funcs = { .mode_fixup = anx7688_bridge_mode_fixup, }; +static irqreturn_t gpio_display_mux_det_threaded_handler(int unused, void *data) +{ + struct anx7688 *anx7688 = data; + + anx7688->bypass = gpiod_get_value(anx7688->gpiod_bypass); + dev_dbg(&anx7688->client->dev, "Interrupt %d!\n", anx7688->bypass); + + if (anx7688->bridge.dev) + drm_kms_helper_hotplug_event(anx7688->bridge.dev); + + return IRQ_HANDLED; +} + static const struct regmap_config anx7688_regmap_config = { .reg_bits = 8, .val_bits = 8, @@ -156,6 +181,38 @@ static int anx7688_i2c_probe(struct i2c_client *client, buffer[0], buffer[1]); } + /* Optional bypass-gpios */ + anx7688->gpiod_bypass = devm_gpiod_get_optional(dev, "bypass", + GPIOD_IN); + if (IS_ERR(anx7688->gpiod_bypass)) { + ret = PTR_ERR(anx7688->gpiod_bypass); + if (ret != -EPROBE_DEFER) + dev_err(dev, "bypass-gpios assigned failed\n"); + return ret; + } + if (anx7688->gpiod_bypass) { + int irq; + + irq = gpiod_to_irq(anx7688->gpiod_bypass); + if (irq < 0) { + dev_err(dev, "Failed to get output irq %d\n", irq); + return -ENODEV; + } + + anx7688->bypass = gpiod_get_value(anx7688->gpiod_bypass); + + ret = devm_request_threaded_irq(dev, irq, NULL, + gpio_display_mux_det_threaded_handler, + IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | + IRQF_ONESHOT, + "gpio-display-mux-det", anx7688); + if (ret) { + dev_err(dev, + "Failed to request MUX_DET threaded irq\n"); + return ret; + } + } + anx7688->bridge.funcs = &anx7688_bridge_funcs; drm_bridge_add(&anx7688->bridge);