From: Jagan Teki <jagan@amarulasolutions.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 12/34] spi: mpc8xxx: Use IO accessors
Date: Tue, 20 Nov 2018 18:17:52 +0530 [thread overview]
Message-ID: <20181120124814.23293-13-jagan@amarulasolutions.com> (raw)
In-Reply-To: <20181120124814.23293-1-jagan@amarulasolutions.com>
From: Mario Six <mario.six@gdsys.cc>
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 <mario.six@gdsys.cc>
---
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));
--
2.18.0.321.gffc6fa0e3
next prev parent reply other threads:[~2018-11-20 12:47 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-11-20 12:47 [U-Boot] [PATCH 00/34] spi: DM_SPI migration timeout! Jagan Teki
2018-11-20 12:47 ` [U-Boot] [PATCH 01/34] spi: Remove unused spi_init Jagan Teki
2018-11-20 12:47 ` [U-Boot] [PATCH 02/34] spi: Remove used spi_init Jagan Teki
2018-11-20 12:47 ` [U-Boot] [PATCH 03/34] spi: davinci: Full dm conversion Jagan Teki
2018-11-20 14:45 ` Adam Ford
2018-11-21 9:33 ` Chris Packham
2018-11-20 12:47 ` [U-Boot] [PATCH 04/34] spi: kirkwood: " Jagan Teki
2018-11-21 7:52 ` Chris Packham
2018-11-21 8:39 ` Jagan Teki
2018-11-21 8:59 ` Chris Packham
2018-11-21 9:04 ` Jagan Teki
2018-11-20 12:47 ` [U-Boot] [PATCH 05/34] spi: ti_qspi: " Jagan Teki
2018-11-20 12:47 ` [U-Boot] [PATCH 06/34] spi: mpc8xxx: Use short type names Jagan Teki
2018-11-20 12:47 ` [U-Boot] [PATCH 07/34] spi: mpc8xxx: Fix comments Jagan Teki
2018-11-20 12:47 ` [U-Boot] [PATCH 08/34] spi: mpc8xxx: Rename camel-case variables Jagan Teki
2018-11-20 12:47 ` [U-Boot] [PATCH 09/34] spi: mpc8xxx: Fix space after cast Jagan Teki
2018-11-20 12:47 ` [U-Boot] [PATCH 10/34] spi: mpc8xxx: Fix function names in strings Jagan Teki
2018-11-20 12:47 ` [U-Boot] [PATCH 11/34] spi: mpc8xxx: Replace defines with enums Jagan Teki
2018-11-20 12:47 ` Jagan Teki [this message]
2018-11-20 12:47 ` [U-Boot] [PATCH 13/34] spi: mpc8xxx: Simplify if Jagan Teki
2018-11-20 12:47 ` [U-Boot] [PATCH 14/34] spi: mpc8xxx: Get rid of is_read Jagan Teki
2018-11-20 12:47 ` [U-Boot] [PATCH 15/34] spi: mpc8xxx: Simplify logic a bit Jagan Teki
2018-11-20 12:47 ` [U-Boot] [PATCH 16/34] spi: mpc8xxx: Reduce scope of loop variables Jagan Teki
2018-11-20 12:47 ` [U-Boot] [PATCH 17/34] spi: mpc8xxx: Make code more readable Jagan Teki
2018-11-20 12:47 ` [U-Boot] [PATCH 18/34] spi: mpc8xxx: Rename variable Jagan Teki
2018-11-20 12:47 ` [U-Boot] [PATCH 19/34] spi: mpc8xxx: Document LEN setting better Jagan Teki
2018-11-20 12:48 ` [U-Boot] [PATCH 20/34] spi: mpc8xxx: Re-order transfer setup Jagan Teki
2018-11-20 12:48 ` [U-Boot] [PATCH 21/34] spi: mpc8xxx: Fix if check Jagan Teki
2018-11-20 12:48 ` [U-Boot] [PATCH 22/34] spi: mpc8xxx: Use get_timer Jagan Teki
2018-11-20 12:48 ` [U-Boot] [PATCH 23/34] spi: mpc8xxx: Convert to DM Jagan Teki
2018-11-20 12:48 ` [U-Boot] [PATCH 24/34] spi: Zap cf_spi driver-related code Jagan Teki
2018-11-20 12:48 ` [U-Boot] [PATCH 25/34] spi: Zap lpc32xx_ssp " Jagan Teki
2018-11-20 12:48 ` [U-Boot] [PATCH 26/34] spi: Zap mxs_spi " Jagan Teki
2018-11-20 12:48 ` [U-Boot] [PATCH 27/34] spi: Zap sh_spi " Jagan Teki
2018-11-20 12:48 ` [U-Boot] [PATCH 28/34] spi: Zap soft_spi_legacy " Jagan Teki
2018-11-20 12:48 ` [U-Boot] [PATCH 29/34] spi: Zap mpc8xx_spi " Jagan Teki
2018-11-20 12:48 ` [U-Boot] [PATCH 30/34] spi: Zap mxc_spi " Jagan Teki
2018-11-20 12:48 ` [U-Boot] [PATCH 31/34] spi: Zap omap3_spi " Jagan Teki
2018-11-20 12:48 ` [U-Boot] [PATCH 32/34] spi: Zap atmel_spi " Jagan Teki
2018-11-20 12:48 ` [U-Boot] [PATCH 33/34] spi: fsl_dspi: Drop non-dm code Jagan Teki
2018-11-20 12:48 ` [U-Boot] [PATCH 34/34] dm: MIGRATION: spi: Update SPI driver status Jagan Teki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181120124814.23293-13-jagan@amarulasolutions.com \
--to=jagan@amarulasolutions.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox