From patchwork Tue Nov 10 23:46:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 11895841 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2FD8EC56202 for ; Tue, 10 Nov 2020 23:47: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 B24D8207E8 for ; Tue, 10 Nov 2020 23:47:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Ois9Ru3J" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B24D8207E8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.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 02C6089D5C; Tue, 10 Nov 2020 23:47:04 +0000 (UTC) Received: from mail-lf1-x142.google.com (mail-lf1-x142.google.com [IPv6:2a00:1450:4864:20::142]) by gabe.freedesktop.org (Postfix) with ESMTPS id 34CC189D5C for ; Tue, 10 Nov 2020 23:47:03 +0000 (UTC) Received: by mail-lf1-x142.google.com with SMTP id l2so689308lfk.0 for ; Tue, 10 Nov 2020 15:47:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BZwpBjCKFkPFg4D+5kgmDyInAjRNL4hw/D5g9alUegs=; b=Ois9Ru3JLPsyJ899x+z10htmSkwf6Ku6x2+jtneNn/D8cLDHx5Uz2jl1BNQ/M/HKXU T3fAd+t0cE8Ao1I73wOHHT/x/mpk0A93IPjf7mCcsyGHdKZRpBWFUf2GMLvA+RYJMBx0 IKXzMXbrzOpC8GSyLxccCbgjeAnTmWGED935igkBFuP2wYNadB2/rHpc/2yAN1mLIH2Q hjnB3khYHaEXeayRKJWwtaaY4fmsHU2Ae4lDGm5+OnxYii7AEsCcRO5JW+/L3+ZH1UQF w9BaWuhLYMrsQ4h2VnQddNVs130Nbpd/ywjqEJOxH5p8dMoJQMTO2IHXUYxFaTrXYNBe Z32g== 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=BZwpBjCKFkPFg4D+5kgmDyInAjRNL4hw/D5g9alUegs=; b=AB4WV+oDDhzgH4h8BCrNWvAfVpWbhO5eDYW0O+j4Z2gIG/GCQePlmf8Ovm9otwMEkb nanilejOUrJHoVS2u/C8yex1D2ohs7L6HTwTIcppjkZP44sZQUL0oJqfUHXik6EVHxfH f4+Gjjmht4c+7QuFl3fgVFaHLEusdvRz9Pqf/vnP/nQvetdlc0I6eT0/DbSVRH+4iw2B b7jjy8oxsnX1zld61iK03K702zl5vE1aQ5OD+ymDi6nyDjAS+wjALprxFMc3lroJH8+O /PcERLBJGxGHdpiYp2mXWqKSmfABKJCyZ24JnITBVbW5NMXqYAO32Q2PFXTNG6E+3Yu+ wvig== X-Gm-Message-State: AOAM532z/XlRi2WD8EVED++xQHnI1ibYey2eFPVz75pypw5L0uB+RK8O QusJXChFO19RU3xuolqxSUf0mA== X-Google-Smtp-Source: ABdhPJxrIf45hk096T37XeKGU/4ge9gAffDTeWkM91ls8F9VWtneZ3CE1oS00zLtaQ8ivc3Z/JmB/A== X-Received: by 2002:a19:5052:: with SMTP id z18mr8104346lfj.574.1605052021569; Tue, 10 Nov 2020 15:47:01 -0800 (PST) Received: from localhost.bredbandsbolaget (c-92d7225c.014-348-6c756e10.bbcust.telenor.se. [92.34.215.146]) by smtp.gmail.com with ESMTPSA id y65sm39883lff.73.2020.11.10.15.47.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Nov 2020 15:47:00 -0800 (PST) From: Linus Walleij To: Thierry Reding , Sam Ravnborg , Stephan Gerhold , =?utf-8?q?Pawe=C5=82_Chmiel?= Subject: [PATCH 2/5] drm/panel: s6e63m0: Implement reading from panel Date: Wed, 11 Nov 2020 00:46:50 +0100 Message-Id: <20201110234653.2248594-3-linus.walleij@linaro.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201110234653.2248594-1-linus.walleij@linaro.org> References: <20201110234653.2248594-1-linus.walleij@linaro.org> MIME-Version: 1.0 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: dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" This code was found in the Samsung vendor tree for the Samsung GT-I9070 mobile phone. Let's support reading before we implement the 3WIRE protocol for both reading and writing. Cc: Stephan Gerhold Cc: Paweł Chmiel Signed-off-by: Linus Walleij --- .../gpu/drm/panel/panel-samsung-s6e63m0-spi.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-samsung-s6e63m0-spi.c b/drivers/gpu/drm/panel/panel-samsung-s6e63m0-spi.c index 75f00ed4810b..9e1552a7ccc7 100644 --- a/drivers/gpu/drm/panel/panel-samsung-s6e63m0-spi.c +++ b/drivers/gpu/drm/panel/panel-samsung-s6e63m0-spi.c @@ -13,13 +13,20 @@ static int s6e63m0_spi_dcs_read(struct device *dev, const u8 cmd, u8 *data) { - /* - * FIXME: implement reading DCS commands over SPI so we can - * properly identify which physical panel is connected. - */ - *data = 0; + struct spi_device *spi = to_spi_device(dev); + u16 buf[1]; + u16 rbuf[1]; + int ret; - return 0; + /* SPI buffers are always in CPU order */ + buf[0] = (u16) cmd; + ret = spi_write_then_read(spi, buf, 2, rbuf, 2); + dev_dbg(dev, "READ CMD: %04x RET: %04x\n", buf[0], rbuf[0]); + if (!ret) + /* These high 8 bits of the 9 contains the readout */ + *data = (rbuf[0] & 0x1ff) >> 1; + + return ret; } static int s6e63m0_spi_write_word(struct device *dev, u16 data)