From patchwork Sun Apr 28 20:28:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 323 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 81F423F08F for ; Sun, 28 Apr 2019 22:29:24 +0200 (CEST) Received: by mail-pf1-f200.google.com with SMTP id p8sf6142728pfd.4 for ; Sun, 28 Apr 2019 13:29:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1556483363; cv=pass; d=google.com; s=arc-20160816; b=r+2GG/DMK3JgToXbCRM1Di86yda0yg91fFjJ5EBBxOlyFDHETgpttT1zxYlSSwzCxb Ni9BALS8v9DBEZuLamrQzevDFKkiAH/4OJEYn2i3k4zUHfiqbR4me7IPWlql31/xIDbf Lc+2g32Fky2gB1fcmavVmseced8tV7PuiVtTtPq5VM/3WmU+pK47YpuZZRQTraKC69hR Fj/DbXWSXdQGILxzpz5lhSytfMIhaict5QX2tN+uZJKFlXGWA/tN+MVpswPe8psmsAGO wMe1dTecpJaEYAwClj04lCi/GRUNk6LQt+VwIxFZm096Qo5xeAZ4Q5K8gOzzxBQ+m9nR Z8xA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=v4HRyKFrbVB2dt37tWqd2iVntqv9jaJKC4id3NI9dpU=; b=i+1Bcmos1OeOAPrVUm8syT3Fk97fc7G0WZv4EX5Dzk++BlDU0Ge9a89ZQDzxkjwQpM pY0pv2t4n5OIk1gyjoree0lR6FKKli2pfxHb7TJrKsmkzOykaKeNi1BeGOR8YJxhpWsh v+58wFYxp1gWNFQyxopr1NDggy42q90F5VTmMB9/YbaGNqMylWk27fARzdN9OdB6pL89 hC5P71w2k2DGtCgofTD06Erzt0IlR72tLVfp89YvmvWfhM2pPWd35ztfeTFifRjuKRsi 1n5ILULq07aBylZgGluq2qBr9e89h7Bti+Pno8lwGs8osqUrQ03sAYOXYrXT4kmBpRJM 3bsg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=fplu6g99; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=v4HRyKFrbVB2dt37tWqd2iVntqv9jaJKC4id3NI9dpU=; b=fIrxc/NQ3smm0Kx/KEkeULezLteFQa07UwyZg4M6QeiBiDGyybrqXKrdJmZNpnb622 j+sYVYZUWTsKV1HZk4GxSlZpanbR/8ARGSzC7sBYJSRUTD9ca19/tf4l1U72tvUzrDiR qR/6DxedYznGaBhXumjksOcMof44+vAN1cqhg= 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:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=v4HRyKFrbVB2dt37tWqd2iVntqv9jaJKC4id3NI9dpU=; b=QMiA0IUa+JGgxBz4hf48QhlkW+uSdYI9Sfl5qhD+KL8NFos58LB1CrLMk8zVjVRXvD iSS82rYYOvL2dUtZERCkV2PinNZt2DJwz0G+GYp+yro/QY4fFHpPRDTJcXkgEIOy8pSB 2KBmy40DDKVkaglmSYqL9Xpp1W26IlNPZrVJW4IU5S118MAkJnPIjvG9xwGVCCW6OjIh bLNeUKb2hYazoZp+7fWnQuuQ9vYOoP+xgw8J9MuGBmtTjYTD1JPd9IHsX3CWnlvW+dUf ekbOiyhsTHJHevdP/qryiq6jz17qWmE26lZ7dYpEvYi2IBU3tB8T6zrr2wgeEdCnkzAK QYNw== X-Gm-Message-State: APjAAAXx3De229jVgsD0bb9og8JQS9eaTH8pLZoOfzto+480xC+PQUWZ Cksdc7CkK+p+36pHnj6u8szGpD1X X-Google-Smtp-Source: APXvYqxe/yBjUAafjHaKOaYxZUzKoNDT9133kc/uoOCuoAXrUe9XqrzbY8NT8sDsgpFLtNz3qYtQnQ== X-Received: by 2002:a65:4302:: with SMTP id j2mr54868859pgq.291.1556483363348; Sun, 28 Apr 2019 13:29:23 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a62:120a:: with SMTP id a10ls883125pfj.10.gmail; Sun, 28 Apr 2019 13:29:23 -0700 (PDT) X-Received: by 2002:aa7:8c84:: with SMTP id p4mr40899355pfd.164.1556483363001; Sun, 28 Apr 2019 13:29:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556483362; cv=none; d=google.com; s=arc-20160816; b=pey5bFtXgHIiK4WTHqhONt4JtdoGHkEzE6uZJm36A5DftXIF53SODHb8m2spOo75YD CB8tnhWstFbr7BK/MDmFY4RnZXm5VAZB/B0cQhkzyT7WkHiWsOM/1m/i3h1Lj3CiqihG pe8nZIUUZnlyEfQJyTP6A+8pTvLWNrljdGbxFErk6v/3FmTHNVZWzuuJ8RhY0Z0b+8ol MepV0wfj/kFDX+hQTnfSdjpXClx+XjN9GTBhqkuZ+79qmf8iBd/CgitP4vDV7Jo6TL+n pEd1s4CpgjA89M7TNzobahUKy6Jnpd6Iczc9bB8PiLZEH0Eq5SUe9Pxwkkic8V+czb9M bJNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=pQRuhVVoE0yWd3mKjSZGAd435raNgPLT517CJjGksNc=; b=stCH7IcWWAcNXaCIVsqv2kjid6XUA9EDrfjssdfh3jgeuoAlO9a2JEx1ZE8Af1yZ8D O7DxT2Akm6C18FeZZjF5YAhTWZlvhvvp+arPOTMN5yEedZlaAxPPTrFf+DS8WwVyfrxh KrMzu9hxmjsKNDsse7YLYFNouP6a9kgvfcWt2C16Uv3sf0V9HK34XVN9UyUp4jaT3LNB RKmftHzgl/1IIVenWRirgVIIPb5q+ZN2TE6JBhm9+2BaGJvW76qEHgC17uIapusmO4XS pvaPjlRf/XcMLsr5sGDFw7cKRzBZCHCnd1tPzIhgEmygxculkkdUJdyKz4PgXxbAtqzx DFBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=fplu6g99; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id v6sor30838729plp.3.2019.04.28.13.29.22 for (Google Transport Security); Sun, 28 Apr 2019 13:29:22 -0700 (PDT) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; X-Received: by 2002:a17:902:2b89:: with SMTP id l9mr3789693plb.331.1556483362700; Sun, 28 Apr 2019 13:29:22 -0700 (PDT) Received: from localhost.localdomain ([115.97.185.144]) by smtp.gmail.com with ESMTPSA id x66sm68841439pfb.78.2019.04.28.13.29.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 28 Apr 2019 13:29:22 -0700 (PDT) From: Jagan Teki To: Heiko Schocher , Tom Rini Cc: u-boot@lists.denx.de, linux-amarula@amarulasolutions.com, Mario Six Subject: [PATCH v2 07/19] spi: mpc8xxx: Use IO accessors Date: Mon, 29 Apr 2019 01:58:42 +0530 Message-Id: <20190428202854.8590-8-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20190428202854.8590-1-jagan@amarulasolutions.com> References: <20190428202854.8590-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=fplu6g99; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Mario Six Accesses to the register map are currently done by directly reading and writing the structure. Switch to the appropriate IO accessors instead. Signed-off-by: Mario Six --- drivers/spi/mpc8xxx_spi.c | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/drivers/spi/mpc8xxx_spi.c b/drivers/spi/mpc8xxx_spi.c index 7b2ab1e4af..da9e1e3f98 100644 --- a/drivers/spi/mpc8xxx_spi.c +++ b/drivers/spi/mpc8xxx_spi.c @@ -58,21 +58,21 @@ void spi_free_slave(struct spi_slave *slave) void spi_init(void) { - volatile spi8xxx_t *spi = &((immap_t *) (CONFIG_SYS_IMMR))->spi; + spi8xxx_t *spi = &((immap_t *)(CONFIG_SYS_IMMR))->spi; /* * SPI pins on the MPC83xx are not muxed, so all we do is initialize * some registers */ - spi->mode = SPI_MODE_REV | SPI_MODE_MS | SPI_MODE_EN; + out_be32(&spi->mode, SPI_MODE_REV | SPI_MODE_MS | SPI_MODE_EN); /* Use SYSCLK / 8 (16.67MHz typ.) */ - spi->mode = (spi->mode & 0xfff0ffff) | BIT(16); + clrsetbits_be32(&spi->mode, 0x000f0000, BIT(16)); /* Clear all SPI events */ - spi->event = 0xffffffff; + setbits_be32(&spi->event, 0xffffffff); /* Mask all SPI interrupts */ - spi->mask = 0x00000000; + clrbits_be32(&spi->mask, 0xffffffff); /* LST bit doesn't do anything, so disregard */ - spi->com = 0; + out_be32(&spi->com, 0); } int spi_claim_bus(struct spi_slave *slave) @@ -87,7 +87,7 @@ void spi_release_bus(struct spi_slave *slave) int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din, ulong flags) { - volatile spi8xxx_t *spi = &((immap_t *) (CONFIG_SYS_IMMR))->spi; + spi8xxx_t *spi = &((immap_t *)(CONFIG_SYS_IMMR))->spi; uint tmpdout, tmpdin, event; int num_blks = DIV_ROUND_UP(bitlen, 32); int tm, is_read = 0; @@ -100,7 +100,7 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din, spi_cs_activate(slave); /* Clear all SPI events */ - spi->event = 0xffffffff; + setbits_be32(&spi->event, 0xffffffff); /* Handle data in 32-bit chunks */ while (num_blks--) { @@ -118,26 +118,26 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din, * len > 16 0 */ - spi->mode &= ~SPI_MODE_EN; + clrbits_be32(&spi->mode, SPI_MODE_EN); if (bitlen <= 16) { if (bitlen <= 4) - spi->mode = (spi->mode & 0xff0fffff) | - (3 << 20); + clrsetbits_be32(&spi->mode, 0x00f00000, + (3 << 20)); else - spi->mode = (spi->mode & 0xff0fffff) | - ((bitlen - 1) << 20); + clrsetbits_be32(&spi->mode, 0x00f00000, + ((bitlen - 1) << 20)); } else { - spi->mode = (spi->mode & 0xff0fffff); + clrbits_be32(&spi->mode, 0x00f00000); /* Set up the next iteration if sending > 32 bits */ bitlen -= 32; dout += 4; } - spi->mode |= SPI_MODE_EN; + setbits_be32(&spi->mode, SPI_MODE_EN); /* Write the data out */ - spi->tx = tmpdout; + out_be32(&spi->tx, tmpdout); debug("*** %s: ... %08x written\n", __func__, tmpdout); @@ -147,10 +147,10 @@ int spi_xfer(struct spi_slave *slave, uint bitlen, const void *dout, void *din, * The NE event must be read and cleared first */ for (tm = 0, is_read = 0; tm < SPI_TIMEOUT; ++tm) { - event = spi->event; + event = in_be32(&spi->event); if (event & SPI_EV_NE) { - tmpdin = spi->rx; - spi->event |= SPI_EV_NE; + tmpdin = in_be32(&spi->rx); + setbits_be32(&spi->event, SPI_EV_NE); is_read = 1; *(u32 *)din = (tmpdin << (32 - char_size));