Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6400651ybi; Wed, 5 Jun 2019 00:07:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqwAKFi9TK9O7PlbjOqWkhe1mbpSkJ2t3PMMaalxsga5C289MwawS2QYPz2T1V/JU5gMVxo0 X-Received: by 2002:a17:90a:2446:: with SMTP id h64mr15359387pje.0.1559718445738; Wed, 05 Jun 2019 00:07:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559718445; cv=none; d=google.com; s=arc-20160816; b=NU4y9sBKA0cp9z6a3aU94iHWlC70TgZJugeTOFTBiTbthUEJadEHZsb2Nm7qsmktNz RbbFblqy5+IXWOgTJbr8rrnHfXeWpqHVhIVzl5XlNcyDr8Vsvdc0q6IDNNzwlNaPkiZT ys1TKVtUpC+Q/2JjDQS58QJbfiXvxuqAyWOlU0QMsTCcQ0YndCVoqIUk7xVTKbmp5iqX yjJ+j1ehZ/j2YYpCPBOKLM1sNqPHNqI6XkPYkzYQHsxUr4GUhqNz/I99j7bwNe4Sn2Nu yv0NOAYz/jziCuOJq9JsllgbAyLheiGKD80beTzJO+4oZ005SdGHm+wZnMrkXezxcr+S 5w8Q== 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; bh=lnLLdVOlusYEYXI+itkoU5Jat5K5TT8w7N1F2rwe390=; b=GXaX6TBpVJGtCx3HnwqGCHoJjFRJZyqxDZ5gEflZ58u6c/AGmFC4cCdLUSESQH3+Pj IdfFYftGmbtEgH3tdGL2HnTf+9DBL5wGwyniJ7cOy44pe+rv2WqU3sqnKsGiOWeKtMx/ hYQqDWGJFc5S5ZsE37S6s+OsQzhvVxqjWUEzO7+TTH4bCTFZUWz1vzGczF1B3yeXl5Ck u0X5eifUzHV301+CevMAJRIL2coUKLHqrMFjMPOM1fnKlHLGlS64p5Px7z7stCroKWXD VPEjFOXMSQiyspgWOE1rzzrEOU8KnJpMBhqX0DWjW8fbBXE+Xw9dIL4x94WxxnS2IWtk nddQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="XUdmC/bv"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h13si10771849pgj.204.2019.06.05.00.07.07; Wed, 05 Jun 2019 00:07:25 -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=@gmail.com header.s=20161025 header.b="XUdmC/bv"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726835AbfFEHFm (ORCPT + 99 others); Wed, 5 Jun 2019 03:05:42 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:46621 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726809AbfFEHFj (ORCPT ); Wed, 5 Jun 2019 03:05:39 -0400 Received: by mail-pl1-f193.google.com with SMTP id e5so7608257pls.13 for ; Wed, 05 Jun 2019 00:05:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lnLLdVOlusYEYXI+itkoU5Jat5K5TT8w7N1F2rwe390=; b=XUdmC/bvWolT7eI9YQ2cUFGxT2x+UR40fKEvKzQytbCtCbLnVXn60ri7ZaGHoMx0GJ gHZMwaJ6ULtsNFeV3IRzhIAMLH9gi897sX3lZoyKqf1NqL389JgUcjcA938NcnXuyQxg zyy2gu9IBni0w5Y1sX4HSUvJxt+UaZK+svntZSnv0eWIgJyzhbx0Om8SL83kUCQ4dQlM Up5MZamVlHETacU8vcyB6GOrmyLuxwUD4XYMv1fgLBVVM04j8B1RDH1WDRYwyAhFuFo/ SWhV8WXS23ZWu4J6clcwGKBzcCm7bZxM8l3G94IId7hQL6GyPWPH7tOkpvtmA06S5xok yZ4A== 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=lnLLdVOlusYEYXI+itkoU5Jat5K5TT8w7N1F2rwe390=; b=s3XfI9oiNNQewZFWgkjZjNYbAvF6h/zcX/5I+Na64FO7FGdQjLKS/TMGRBaeqklyPe Zl39YUBWgg9iUL3hHhUZbxt3hQkJ1Hv39KyA/9zysqBimDAR/xxQ4WBayrnwOL/y7hQ6 U0JWRSEHJGtndEaspdCAsFQeCIe7Au7kL2CU3ocYL7JxQ+ZZTmc07zG9yjuXXlAtbOmq 0kCq5UhV46pY2dodWYNDMqrCUIRYngQWkmXhdrB4pjJMjxx9tatyPrFcUdAtt7dG0Gze tJcEWk6w960LWlJmFLH4bHksq73JBWTtGVNIaErp1n4u+tIz7HWLbE6sih0qUtT98oop sT4Q== X-Gm-Message-State: APjAAAVQb+/KyyAP4e4INcy9ybLuY3Hjty9eRRzRriuaICBbF/P5iPJC 2RipCUXolTXXRG8csitVgHQ= X-Received: by 2002:a17:902:988b:: with SMTP id s11mr14564567plp.216.1559718337640; Wed, 05 Jun 2019 00:05:37 -0700 (PDT) Received: from localhost.lan (c-24-22-235-96.hsd1.wa.comcast.net. [24.22.235.96]) by smtp.gmail.com with ESMTPSA id d132sm6527348pfd.61.2019.06.05.00.05.35 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Jun 2019 00:05:37 -0700 (PDT) From: Andrey Smirnov To: dri-devel@lists.freedesktop.org Cc: Andrey Smirnov , Archit Taneja , Andrzej Hajda , Laurent Pinchart , Tomi Valkeinen , Andrey Gusakov , Philipp Zabel , Cory Tusar , Chris Healy , Lucas Stach , linux-kernel@vger.kernel.org Subject: [PATCH v3 10/15] drm/bridge: tc358767: Add support for address-only I2C transfers Date: Wed, 5 Jun 2019 00:05:02 -0700 Message-Id: <20190605070507.11417-11-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190605070507.11417-1-andrew.smirnov@gmail.com> References: <20190605070507.11417-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Transfer size of zero means a request to do an address-only transfer. Since the HW support this, we probably shouldn't be just ignoring such requests. While at it allow DP_AUX_I2C_MOT flag to pass through, since it is supported by the HW as well. Signed-off-by: Andrey Smirnov Cc: Archit Taneja Cc: Andrzej Hajda Cc: Laurent Pinchart Cc: Tomi Valkeinen Cc: Andrey Gusakov Cc: Philipp Zabel Cc: Cory Tusar Cc: Chris Healy Cc: Lucas Stach Cc: dri-devel@lists.freedesktop.org Cc: linux-kernel@vger.kernel.org --- drivers/gpu/drm/bridge/tc358767.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c index 90ec33caacbc..7b84fbb72973 100644 --- a/drivers/gpu/drm/bridge/tc358767.c +++ b/drivers/gpu/drm/bridge/tc358767.c @@ -145,6 +145,8 @@ /* AUX channel */ #define DP0_AUXCFG0 0x0660 +#define DP0_AUXCFG0_BSIZE GENMASK(11, 8) +#define DP0_AUXCFG0_ADDR_ONLY BIT(4) #define DP0_AUXCFG1 0x0664 #define AUX_RX_FILTER_EN BIT(16) @@ -347,6 +349,18 @@ static int tc_aux_read_data(struct tc_data *tc, void *data, size_t size) return size; } +static u32 tc_auxcfg0(struct drm_dp_aux_msg *msg, size_t size) +{ + u32 auxcfg0 = msg->request; + + if (size) + auxcfg0 |= FIELD_PREP(DP0_AUXCFG0_BSIZE, size - 1); + else + auxcfg0 |= DP0_AUXCFG0_ADDR_ONLY; + + return auxcfg0; +} + static ssize_t tc_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg) { @@ -356,9 +370,6 @@ static ssize_t tc_aux_transfer(struct drm_dp_aux *aux, u32 auxstatus; int ret; - if (size == 0) - return 0; - ret = tc_aux_wait_busy(tc, 100); if (ret) return ret; @@ -382,8 +393,7 @@ static ssize_t tc_aux_transfer(struct drm_dp_aux *aux, if (ret) return ret; /* Start transfer */ - ret = regmap_write(tc->regmap, DP0_AUXCFG0, - ((size - 1) << 8) | request); + ret = regmap_write(tc->regmap, DP0_AUXCFG0, tc_auxcfg0(msg, size)); if (ret) return ret; @@ -397,8 +407,14 @@ static ssize_t tc_aux_transfer(struct drm_dp_aux *aux, if (auxstatus & AUX_TIMEOUT) return -ETIMEDOUT; - - size = FIELD_GET(AUX_BYTES, auxstatus); + /* + * For some reason address-only DP_AUX_I2C_WRITE (MOT), still + * reports 1 byte transferred in its status. To deal we that + * we ignore aux_bytes field if we know that this was an + * address-only transfer + */ + if (size) + size = FIELD_GET(AUX_BYTES, auxstatus); msg->reply = FIELD_GET(AUX_STATUS, auxstatus); switch (request) { -- 2.21.0