Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5407331ybi; Wed, 12 Jun 2019 01:55:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqx8AjB/2Jt+QFviMhHRscQ9bKa9rRCl5nO8w12tNgPS7kc+7BjPKJJd9f9XHyMsgIX7iRYA X-Received: by 2002:a17:902:148:: with SMTP id 66mr75618397plb.143.1560329716047; Wed, 12 Jun 2019 01:55:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560329716; cv=none; d=google.com; s=arc-20160816; b=zsxyFK7ME6EOexOSUZ0B7zbPSjXJ/AuXDbP6CAWOYTX6WvS2K+RRhs+PDZlbGkJ8nU 3UcrjwqqQQs0tU1xiBL0JPoLxdMoG2t64SSs0CzfP1PCGJegv2twGkX8cmWhSjHoK9Vz +MKlT5Qfije5ZNEmizImYrYtpcltM3BnNhy5Ht0XNr17A/oiMEkyTMDnXebfC9+6ax8T 2KJNBDduLqgTtAxorMxMCmsmUooLltV1DDPTEnzqUcgjJASFoPkmzlnDKwOcoN6tNjaN xU4vRY5aJE2sWT4ddWgFhWSURwLywZhC71OaLQl3plcn+iJtMieuaHA+juVP2qrxzy/I vbFA== 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=YtcIT0Jg32O6R6ayXabHjP4bybCS1tEkrHIRDEcAfKg=; b=ezOKa0Nwh1VhhGw1fpOjJ6ge/x0gxVEfW+6Yk+kjKiRgtrroUjLXkvTG6WdxZYAuAM DnfMkCpZorxIz5BkMamkX9FBHzjiGvOC/qpXzzDy2G7JJBTBJrS5/JfmV2QyPSUYjb+2 nPxNaMeqbYCNEgqKSj7GH6Nelv6LKyeajYaWo0PZai8CzGWbszsdZLcFYu/HOwGiF5wf Y9Y1tHpb06MfnG6mdobfAhKOHM2KT30iqQYxB/qpzRJhl9V4X/YST7CxAnXV424ugQwk DFVUe6Z9UgP0AQe5Ll6Z+BX8x9gfoRVTkHSld0SCnVv+wPg+zz3mk90Dpoli9/HPG7w2 CSCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=gLfQOiMJ; 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 q204si14646696pgq.470.2019.06.12.01.55.01; Wed, 12 Jun 2019 01:55:16 -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=gLfQOiMJ; 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 S2408640AbfFLIdZ (ORCPT + 99 others); Wed, 12 Jun 2019 04:33:25 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:43358 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2408624AbfFLIdW (ORCPT ); Wed, 12 Jun 2019 04:33:22 -0400 Received: by mail-pl1-f193.google.com with SMTP id cl9so6319172plb.10 for ; Wed, 12 Jun 2019 01:33:22 -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=YtcIT0Jg32O6R6ayXabHjP4bybCS1tEkrHIRDEcAfKg=; b=gLfQOiMJREwfLUGXRDG7KOpR/5wG1izZ1Nif5YzwPV5Hj7i4bwIH2Mh2vYpcyc5nB6 UvGNDCNyfSxrvL79GEHgWUCd6+NkBhjyPsGE0PntsfIRSQwaGylm1UPm/uSTSRIN43D9 BDFn9H3lCoHIniq3aDXMFn2+LD4wha1P1UzvjwxwDtCGNl8a4h9Gubgd1PT71pe9sX7i TtpX3QXehQ4H60y2rKeMGHF3A0t+PsEQLqux0C0uEtcN3hsS1W8WTXCkPxRGNiN4H1tP YZpZf+jRWTkOqpmqqjoDKUMn8+vQVDb3cB1b5HSJEcwGeEkMQ+a+sq+a0ubdo8SwNI1F GxuQ== 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=YtcIT0Jg32O6R6ayXabHjP4bybCS1tEkrHIRDEcAfKg=; b=m17wtya5z+ic/IUerrlx6RvQd2NHYd1EAk/giphHTv9tozKAuFogczrBZBiSLVbTzZ 4h8wMuN3VDUlZ0rwl/V+7fQnh0WozPrb3Q8DaUdyiO7S1hmJa/EJP1aQRTZ2iqIeuEVd 2yDmXsXSXoqQeE3Dbt7l+zeNhRceflmtQ/AmHBcsOwTXJjCebI/lCmBm41gM4o4CbJDr ivWB1SzE2uR8FOev79KcPfTBjWp1IAqJ/3RC0LMfaIT6XKMzEk3+Kq8irwabxGXkYakP KU0mNKRoRHSyjiR1wcMJWmtz+60Q0CNUYAX+O2kE/8Nf5yfjRDTkOIBsWCqgqeyr5Q1a fw4w== X-Gm-Message-State: APjAAAUEhCF9xaA4Rvp+pAdjYgKew9UwROIaCSBySmsdAnqaWBsht1uQ IVWst92mBC+kU0Jx2LmSAGE= X-Received: by 2002:a17:902:7246:: with SMTP id c6mr20639549pll.248.1560328401708; Wed, 12 Jun 2019 01:33:21 -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 d21sm18845991pfr.162.2019.06.12.01.33.19 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 12 Jun 2019 01:33:20 -0700 (PDT) From: Andrey Smirnov To: dri-devel@lists.freedesktop.org Cc: Andrey Smirnov , Andrzej Hajda , Laurent Pinchart , Tomi Valkeinen , Andrey Gusakov , Philipp Zabel , Cory Tusar , Chris Healy , Lucas Stach , linux-kernel@vger.kernel.org Subject: [PATCH v5 10/15] drm/bridge: tc358767: Add support for address-only I2C transfers Date: Wed, 12 Jun 2019 01:32:47 -0700 Message-Id: <20190612083252.15321-11-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190612083252.15321-1-andrew.smirnov@gmail.com> References: <20190612083252.15321-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 Reviewed-by: Andrzej Hajda 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 7d0fbb12195b..4bb9b15e1324 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) @@ -327,6 +329,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) { @@ -336,9 +350,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; @@ -362,8 +373,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; @@ -377,8 +387,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