Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp878591img; Fri, 22 Mar 2019 10:27:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqxqBAYNsoHVYwkoiQuA8d+759gBdcDoEeqs3M8A6Bsg7HTrPVzQY9v8tTmzoxu1GdpO+MOS X-Received: by 2002:a17:902:7b94:: with SMTP id w20mr10782661pll.156.1553275674832; Fri, 22 Mar 2019 10:27:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553275674; cv=none; d=google.com; s=arc-20160816; b=Gp9tgKA5/PyyiJ/eIA4tiwHU214/FEgLn/IVPcNnWfauTByTIXMCGKqEl/9a3wbH6J NrBKFBoP+BnOlqwnlgEJh8SZ55+4+o1O7lBLOPWt5DCZ4p+yMSwJtpASTus9bxRl62wT M5acxt5W7AI5+dRKHStLBuDipnctvQSgB3x5CLN8iYkt62kGIBiQHbi4xYfP2cfYVBY6 vg4RQuOm2er/dIxQnS7JuEPwZqSwLx/rJFnNHcJDx6fQg/ElhbGVE8fRH4f1GFmk5X9w bUnQ2jWOnAJogV8UZDtLH1xIsx9NJ7zfJ3D8tVvcyhBK29/Hbw44sVlY9WP4Vqzde8Lt lxTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=worEQNaoJLYeD7mblzWWmpJ8BvsIgSttCy+a9olDJxw=; b=egtM8si1MEUYTa7oqySMJFqvc2R7Wfq3a3gxbFoNPyB9RE5d6AzdgwLcrZl6/y9ePp LCnqAQJu9j4j9/cyD0rmH4pr9QfSGsrhF9DuQ3KmxvnW/Dl+CCGMlmVbqMl6rc97IAaA rLTqJZHhJf3NMrrk0GhzkfTe17MehrnNLh5IQmwkOR6ruF82jUP6IxEjNNzrQHXM7uHA ENmXXEpwPoPcHJMb/O248r2fN/DEZn57ndrspG3lhiJli7dRsgEnY2A7fDmaSFfAJccc I51tENOO2cg1q2029ddnCqqaCzaKaHgp5mE87jN1Yyw3/8Tz0pMsB/Lwk0pLjMYj0+MR oPcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dUVK5Sia; 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 67si7498651plf.222.2019.03.22.10.27.39; Fri, 22 Mar 2019 10:27:54 -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=dUVK5Sia; 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 S1728913AbfCVRZh (ORCPT + 99 others); Fri, 22 Mar 2019 13:25:37 -0400 Received: from mail-wm1-f68.google.com ([209.85.128.68]:38086 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727741AbfCVRZg (ORCPT ); Fri, 22 Mar 2019 13:25:36 -0400 Received: by mail-wm1-f68.google.com with SMTP id a188so2929136wmf.3 for ; Fri, 22 Mar 2019 10:25:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=worEQNaoJLYeD7mblzWWmpJ8BvsIgSttCy+a9olDJxw=; b=dUVK5SiaSMke7aU5k6wJk+NOLiodivaeMMsV8g1Z/3w2CKHg8WNtCrQ25fQnXEXHgd kMAih97gsZbS+MXnMcEHFXeRkEfR9B88UBTRkPaIG+w8MQGYEFtu5oGr8F+WuYQFnihS DyoC0weVf94LbQDU9Kr4mCWkiz7ekQxkq25A2jDOjGRAXUJASzm5gnhjuEAnA1wCPYKu j8fHPwXkPco0WLzx0/3os854OLNoGvwrz7/skoz1srpXPwXEtfRz/TRkjinWqf3IKfXL VKv0rH7akZvymgzKO15Z6FZIIllzGO8H96N8wN7NrWgLeplN3193hXhfF2atNPI9Pgr+ mkKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=worEQNaoJLYeD7mblzWWmpJ8BvsIgSttCy+a9olDJxw=; b=E1GNurBjBvqukm2pttyrA3D74Ch/5Uqp39DkN5LZqGfQ9CNCdr8+jM21taw/DIEIwS f5nKPJS4opPfV77yFlS0pk7dJ/lV7gfzbo0oicxEK+LJhpNE4FAbw8NrDEd99J9xbUgR mFV8gJbQCrZnJZ3pVT9quXvpc/ve9zoq+IL6oyPzl/y7aFMzjLBIjLG8TEJghjxSdqIO 1stvAZ6j+i6VIChwmZ1Le1lPzNtZs0udYlKuMioSn14UgmjGf7+FT0zRYvJ3TUQpuqd0 CIORG14xaHh5l0UT++/hwQrq8CPN7MLPP8CnoV4aKurIxq78HEgDZmSt4JAARiO9f9iC LgRA== X-Gm-Message-State: APjAAAWu7qRRN3KzUavhW2/8vh54wy6I827wVgvm36Gl9zUa2jjtFUpN FB7BR6u1wPSNBjnJS5H1OI7JGq/DZ6s/YZM+tTM= X-Received: by 2002:a05:600c:218:: with SMTP id 24mr3838767wmi.144.1553275533864; Fri, 22 Mar 2019 10:25:33 -0700 (PDT) MIME-Version: 1.0 References: <20190322032901.12045-1-andrew.smirnov@gmail.com> <20190322032901.12045-8-andrew.smirnov@gmail.com> <25d95ed0-4dba-09d5-87ec-57c5e763beb4@ti.com> In-Reply-To: <25d95ed0-4dba-09d5-87ec-57c5e763beb4@ti.com> From: Andrey Smirnov Date: Fri, 22 Mar 2019 10:25:22 -0700 Message-ID: Subject: Re: [PATCH v2 07/15] drm/bridge: tc358767: Simplify AUX data write To: Tomi Valkeinen Cc: dri-devel@lists.freedesktop.org, Archit Taneja , Andrzej Hajda , Laurent Pinchart , Andrey Gusakov , Philipp Zabel , Chris Healy , Lucas Stach , linux-kernel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 22, 2019 at 3:51 AM Tomi Valkeinen wrote: > > On 22/03/2019 05:28, Andrey Smirnov wrote: > > Simplify AUX data write by dropping index arithmetic and shifting and > > replacing it with a call to a helper function that does three things: > > > > 1. Copies user-provided data into a write buffer > > 2. Optionally fixes the endianness of the write buffer (not needed > > on LE hosts) > > 3. Transfers contenst of the write buffer to up to 4 32-bit > > registers on the chip > > > > Note that separate data endianness fix: > > > > tmp = (tmp << 8) | buf[i]; > > > > that was reserved for DP_AUX_I2C_WRITE looks really strange, since it > > will place data differently depending on the passed user-data > > size. E.g. for a write of 1 byte, data transferred to the chip would > > look like: > > > > [byte0] [dummy1] [dummy2] [dummy3] > > > > whereas for a write of 4 bytes we'd get: > > > > [byte3] [byte2] [byte1] [byte0] > > > > Since there's no indication in the datasheet that I2C write buffer > > should be treated differently than AUX write buffer and no comment in > > the original code explaining why it was done this way, that special > > I2C write buffer transformation was dropped in this patch. > > > > Signed-off-by: Andrey Smirnov > > Cc: Archit Taneja > > Cc: Andrzej Hajda > > Cc: Laurent Pinchart > > Cc: Tomi Valkeinen > > Cc: Andrey Gusakov > > Cc: Philipp Zabel > > Cc: Chris Healy > > Cc: Lucas Stach > > Cc: dri-devel@lists.freedesktop.org > > Cc: linux-kernel@vger.kernel.org > > --- > > drivers/gpu/drm/bridge/tc358767.c | 58 +++++++++++++++++++------------ > > 1 file changed, 36 insertions(+), 22 deletions(-) > > > > diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c > > index 81c10a5d8106..21374565585d 100644 > > --- a/drivers/gpu/drm/bridge/tc358767.c > > +++ b/drivers/gpu/drm/bridge/tc358767.c > > @@ -307,6 +307,31 @@ static int tc_aux_get_status(struct tc_data *tc, u8 *reply) > > return 0; > > } > > > > +static int tc_aux_write_data(struct tc_data *tc, const void *data, > > + size_t size) > > +{ > > + u32 auxwdata[DP_AUX_MAX_PAYLOAD_BYTES / sizeof(u32)] = { 0 }; > > + int ret, i, count = DIV_ROUND_UP(size, 4); > > Should 4 there be sizeof(u32)? Yup, will replace. > > > + > > + memcpy(auxwdata, data, size); > > + > > + for (i = 0; i < count; i++) { > > + ret = regmap_write(tc->regmap, DP0_AUXWDATA(i), > > + /* > > + * Our regmap is configured as LE > > + * for register data, so we need > > + * undo any byte swapping that will > > + * happened to preserve original > > + * byte order. > > + */ > > + cpu_to_le32(auxwdata[i])); > > Can regmap_bulk_write or regmap_raw_write be used here? > Not sure, will give it a try. Thanks, Andrey Smirnov