From patchwork Wed Aug 26 09:18:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ikjoon Jang X-Patchwork-Id: 11737635 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 46DE2913 for ; Wed, 26 Aug 2020 09:19:11 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 1E8FC207DF for ; Wed, 26 Aug 2020 09:19:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="L0N8s0cD"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="K+PUZGRM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1E8FC207DF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=avyvnIfLxMwRZs8x1axYv6upKPnTJAv7lqkBUFg6xOg=; b=L0N8s0cDCdVIC44/uIkeT8me2W N/4i0urT3G18D5aVqv6Ny7D1aZSIbv0teItUZTj6kIlm/RSK534dEguJIHauslyXbW6FlYqIP8cl/ gLbOL8KMeHcuK8I00GrKI29yCWaJJEZuyAkSgHWCZHPCVITf+niwj88Kqwx/jEoG1iWAijnNJJUoL c+F24i/m0xCxfB8l6tQAm8EFTzQbqkxmMOy6s4CNO0uZC4kVdwTvMyIuiE8LMUitkcEW49XY8vDrJ FPz2wVQlHaC0WWq/ZuNS64hBJYicrnKAOI3XpqdNf4VOmcEPvJ4mMGTi55AU4jSKG0BKiJ4WtS/Pq ziaUXipg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kAra9-0004Lm-LF; Wed, 26 Aug 2020 09:19:01 +0000 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kAra7-0004Ka-LX for linux-arm-kernel@lists.infradead.org; Wed, 26 Aug 2020 09:19:00 +0000 Received: by mail-pl1-x644.google.com with SMTP id j11so607618plk.9 for ; Wed, 26 Aug 2020 02:18:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=3zVbq7zEl/VylsOkImAEnSsEooCYxqv16B/0RWDkhJE=; b=K+PUZGRMtL+WeKb15tJBnfkVOHrBfTwHgTsG6Vhq5aOYQ9VzlMP8bC3D4H9s9Vmnwr T9UbSHeZLvi2f0631yma1BoIk5JYO0ZMUMnnNgxwstvJPuxz6OXM3Zei5mB9fjd+8QXu tOQbQiebKGt/CBAaRYhsoaC02PXAPOJ+6bDTE= 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:mime-version :content-transfer-encoding; bh=3zVbq7zEl/VylsOkImAEnSsEooCYxqv16B/0RWDkhJE=; b=RG6qMGn7zL6WiI/iTQ0ArMPB41jUZ7gc9OBaX6a6t4nfnQJ6NP6MP60orY9ywir+4L mbqOzXKjxBj9aQ/6ODtd3DJz1Y4WWS5X3ThLa01qlryFqnNO5UGSRi5VmHpKzVPuBWtn zXlEUhM8NfgczxXmhOp0Btq3dlGqvUxiM4pJFTG6lP6w2SNCMpQ/GNBslQ60dFSvDIXs frZijAECAHNTzQVJSGExBWTcuHnpfUhNJTdgoIGU+V9Al9CODp1hHU2mfhheZ9btLFUp qhLeNUWCIQKoEznzPA+kQ1nO0DzTVq+124KQ752k3nTDsFr1lDnGF0YigK/GL65E1711 oRCg== X-Gm-Message-State: AOAM530NeR3r2pDUxKxZmasi8NaEZT0FnZFhZCTuuceNtViNnTz69LZd ZB1IHgQF6ScYnSv+yF9kJoX3kQ== X-Google-Smtp-Source: ABdhPJwmlAUvfRKgb9uu3liuf+trZDCW7x2GR14ieJBTwinOvb3MMKRDTkVHVMx+HWNAbWEyyr44TA== X-Received: by 2002:a17:902:bb89:: with SMTP id m9mr7541350pls.108.1598433537693; Wed, 26 Aug 2020 02:18:57 -0700 (PDT) Received: from ikjn-p920.tpe.corp.google.com ([2401:fa00:1:10:f693:9fff:fef4:a8fc]) by smtp.gmail.com with ESMTPSA id t20sm1922270pgj.27.2020.08.26.02.18.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Aug 2020 02:18:57 -0700 (PDT) From: Ikjoon Jang To: Mark Brown , Matthias Brugger , linux-spi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] spi: spi-mtk-nor: support standard spi properties Date: Wed, 26 Aug 2020 17:18:52 +0800 Message-Id: <20200826091852.519138-1-ikjn@chromium.org> X-Mailer: git-send-email 2.28.0.297.g1956fa8f8d-goog MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200826_051859_738183_716CA681 X-CRM114-Status: GOOD ( 14.03 ) X-Spam-Score: -1.2 (-) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-1.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:644 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -1.0 DKIMWL_WL_HIGH DKIMwl.org - Whitelisted High sender X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Chuanhong Guo , Ikjoon Jang , Bayi Cheng Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Use default supports_op() to support spi-[rt]x-bus-width properties. And check dummy op's byte length instead of its bus width for output. Signed-off-by: Ikjoon Jang --- drivers/spi/spi-mtk-nor.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/drivers/spi/spi-mtk-nor.c b/drivers/spi/spi-mtk-nor.c index b08d8e9a8ee9..6e6ca2b8e6c8 100644 --- a/drivers/spi/spi-mtk-nor.c +++ b/drivers/spi/spi-mtk-nor.c @@ -211,25 +211,28 @@ static bool mtk_nor_supports_op(struct spi_mem *mem, if (op->cmd.buswidth != 1) return false; - /* DTR ops not supported. */ - if (op->cmd.dtr || op->addr.dtr || op->dummy.dtr || op->data.dtr) - return false; - if (op->cmd.nbytes != 1) - return false; - if ((op->addr.nbytes == 3) || (op->addr.nbytes == 4)) { - if ((op->data.dir == SPI_MEM_DATA_IN) && mtk_nor_match_read(op)) - return true; - else if (op->data.dir == SPI_MEM_DATA_OUT) - return (op->addr.buswidth == 1) && - (op->dummy.buswidth == 0) && - (op->data.buswidth == 1); + switch(op->data.dir) { + case SPI_MEM_DATA_IN: + if (!mtk_nor_match_read(op)) + return false; + break; + case SPI_MEM_DATA_OUT: + if ((op->addr.buswidth != 1) || + (op->dummy.nbytes != 0) || + (op->data.buswidth != 1)) + return false; + break; + default: + break; + } } len = op->cmd.nbytes + op->addr.nbytes + op->dummy.nbytes; if ((len > MTK_NOR_PRG_MAX_SIZE) || ((op->data.nbytes) && (len == MTK_NOR_PRG_MAX_SIZE))) return false; - return true; + + return spi_mem_default_supports_op(mem, op); } static void mtk_nor_setup_bus(struct mtk_nor *sp, const struct spi_mem_op *op)