Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp6721366ybl; Wed, 15 Jan 2020 09:09:51 -0800 (PST) X-Google-Smtp-Source: APXvYqxLNOHLNGlW7w5JGDVOjNeMdtGKLXE9ZdHdh2lHoePLd4rZE8Y59Wt6x63T/eraIz+5Lq9h X-Received: by 2002:a54:4396:: with SMTP id u22mr673403oiv.128.1579108191201; Wed, 15 Jan 2020 09:09:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579108191; cv=none; d=google.com; s=arc-20160816; b=ewKsWEK6xvhuFwE9H7ozp0Tg/fkd1D0CdpPmkTVQYJ6LydFXxdK4bAoN3k/Qj4Vu+x Kh0Z3cZP9cZUkjn76J5uowVk8OlOABJB045c93mX5kPbFlIltcNM9E2Stc0QsVbbheNu 3Xn3sUZ7GlbLCFS5RKWJ8t4LiOZTjNL8LIvtFv42iNAcxH8pL3kmE1xFhgW1uNYafMag b/8cdRscahV/mgOSrnW42HaSrBaPS9ctqgznjsJAz8OwDZJBUfsLyFKxcCYt8nv6LRa9 ABgYULkjJg6a7SnE42HikHLuVwowRNDf90UKiu/mNxwXdO34KeMr4LN+bLZ8p74/Jflk m3aA== 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; bh=Ua0mONas3TvZv8vzYjZc2DMfivYEuCjcCuDzByhsM+I=; b=LZScF3iJUsnCX9eYgBy+4f8Vb8HryB1m2FtuSVSXJ26YFbiwqtvykMgkKueDNpLSat unskr9zkcVQpRFkdE8ACdBbnpcxxztGQ7vP6us0Arjnwy5ynJYLf9Sk9OcRTikteZ897 Djx1+eU4RSRoVI6Ud068KKrMxENX0oEg4QgeQWYY6mpb2eBkTWRUVMpiTp+dRZXTmJwC aiJ2lckUUC087lJi98QE5iuXLOkggxAHUkvQgzCjQcMZMFVHtqk/c6np1wzEDgJljY9e 8P5n49u0oU6Pabc6xkmOnkt2aW3XBeKLwvT5PmonbgW9a6AG4LjlJ8WGZ8HPOgOKrDRw FCzQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (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 2si9777190ois.221.2020.01.15.09.09.38; Wed, 15 Jan 2020 09:09:51 -0800 (PST) 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; 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729122AbgAORH7 (ORCPT + 99 others); Wed, 15 Jan 2020 12:07:59 -0500 Received: from 212.199.177.27.static.012.net.il ([212.199.177.27]:38836 "EHLO herzl.nuvoton.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728963AbgAORH7 (ORCPT ); Wed, 15 Jan 2020 12:07:59 -0500 Received: from taln60.nuvoton.co.il (ntil-fw [212.199.177.25]) by herzl.nuvoton.co.il (8.13.8/8.13.8) with ESMTP id 00FGN3ZW021573; Wed, 15 Jan 2020 18:23:03 +0200 Received: by taln60.nuvoton.co.il (Postfix, from userid 10070) id 5EDF16032E; Wed, 15 Jan 2020 18:23:03 +0200 (IST) From: Tomer Maimon To: broonie@kernel.org, robh+dt@kernel.org, mark.rutland@arm.com, avifishman70@gmail.com, tali.perry1@gmail.com, venture@google.com, yuenn@google.com, benjaminfair@google.com Cc: linux-spi@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, openbmc@lists.ozlabs.org, Tomer Maimon Subject: [PATCH v1 1/4] spi: npcm-pspi: fix 16 bit send and receive support Date: Wed, 15 Jan 2020 18:22:58 +0200 Message-Id: <20200115162301.235926-2-tmaimon77@gmail.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20200115162301.235926-1-tmaimon77@gmail.com> References: <20200115162301.235926-1-tmaimon77@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 Fixing NPCM BMC Peripheral SPI controller 16 bit send and receive support by writing and reading the SPI data in the right order. Signed-off-by: Tomer Maimon --- drivers/spi/spi-npcm-pspi.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/spi/spi-npcm-pspi.c b/drivers/spi/spi-npcm-pspi.c index fe624731c74c..c74611abe2a9 100644 --- a/drivers/spi/spi-npcm-pspi.c +++ b/drivers/spi/spi-npcm-pspi.c @@ -195,6 +195,7 @@ static void npcm_pspi_setup_transfer(struct spi_device *spi, static void npcm_pspi_send(struct npcm_pspi *priv) { int wsize; + u16 val; wsize = min(bytes_per_word(priv->bits_per_word), priv->tx_bytes); priv->tx_bytes -= wsize; @@ -204,17 +205,18 @@ static void npcm_pspi_send(struct npcm_pspi *priv) switch (wsize) { case 1: - iowrite8(*priv->tx_buf, NPCM_PSPI_DATA + priv->base); + val = *priv->tx_buf++; + iowrite8(val, NPCM_PSPI_DATA + priv->base); break; case 2: - iowrite16(*priv->tx_buf, NPCM_PSPI_DATA + priv->base); + val = *priv->tx_buf++; + val = *priv->tx_buf++ | (val << 8); + iowrite16(val, NPCM_PSPI_DATA + priv->base); break; default: WARN_ON_ONCE(1); return; } - - priv->tx_buf += wsize; } static void npcm_pspi_recv(struct npcm_pspi *priv) @@ -230,18 +232,17 @@ static void npcm_pspi_recv(struct npcm_pspi *priv) switch (rsize) { case 1: - val = ioread8(priv->base + NPCM_PSPI_DATA); + *priv->rx_buf++ = ioread8(priv->base + NPCM_PSPI_DATA); break; case 2: val = ioread16(priv->base + NPCM_PSPI_DATA); + *priv->rx_buf++ = (val >> 8); + *priv->rx_buf++ = val & 0xff; break; default: WARN_ON_ONCE(1); return; } - - *priv->rx_buf = val; - priv->rx_buf += rsize; } static int npcm_pspi_transfer_one(struct spi_master *master, -- 2.22.0