From: Juergen Borleis <jbe@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 10/19] MPC5xxx/serial: use dedicated I/O functions instead of memory access
Date: Tue, 7 Oct 2014 16:22:09 +0200 [thread overview]
Message-ID: <1412691738-11145-11-git-send-email-jbe@pengutronix.de> (raw)
In-Reply-To: <1412691738-11145-1-git-send-email-jbe@pengutronix.de>
This forces the driver to use the hardware synchronized commands.
Signed-off-by: Juergen Borleis <jbe@pengutronix.de>
---
drivers/serial/serial_mpc5xxx.c | 37 +++++++++++++++++++------------------
1 file changed, 19 insertions(+), 18 deletions(-)
diff --git a/drivers/serial/serial_mpc5xxx.c b/drivers/serial/serial_mpc5xxx.c
index 18aca87..9d92fed 100644
--- a/drivers/serial/serial_mpc5xxx.c
+++ b/drivers/serial/serial_mpc5xxx.c
@@ -32,6 +32,7 @@
#include <common.h>
#include <mach/mpc5xxx.h>
#include <driver.h>
+#include <io.h>
#include <init.h>
#include <console.h>
#include <xfuncs.h>
@@ -50,8 +51,8 @@ static int __mpc5xxx_serial_setbaudrate(struct mpc5xxx_psc *psc, int baudrate)
/* set up UART divisor */
div = (baseclk + (baudrate/2)) / baudrate;
- psc->ctur = (div >> 8) & 0xFF;
- psc->ctlr = div & 0xff;
+ out_8(&psc->ctur, (div >> 8) & 0xFF);
+ out_8(&psc->ctlr, div & 0xff);
return 0;
}
@@ -69,33 +70,33 @@ static int mpc5xxx_serial_setbaudrate(struct console_device *cdev, int baudrate)
static int __mpc5xxx_serial_init(struct mpc5xxx_psc *psc)
{
/* reset PSC */
- psc->command = PSC_SEL_MODE_REG_1;
+ out_8(&psc->command, PSC_SEL_MODE_REG_1);
/* select clock sources */
#if defined(CONFIG_MGT5100)
- psc->psc_clock_select = 0xdd00;
+ out_be16(&psc->psc_clock_select, 0xdd00);
#elif defined(CONFIG_MPC5200)
- psc->psc_clock_select = 0;
+ out_be16(&psc->psc_clock_select, 0);
#endif
/* switch to UART mode */
- psc->sicr = 0;
+ out_be32(&psc->sicr, 0);
/* configure parity, bit length and so on */
#if defined(CONFIG_MGT5100)
- psc->mode = PSC_MODE_ERR | PSC_MODE_8_BITS | PSC_MODE_PARNONE;
+ out_8(&psc->mode, PSC_MODE_ERR | PSC_MODE_8_BITS | PSC_MODE_PARNONE);
#elif defined(CONFIG_MPC5200)
- psc->mode = PSC_MODE_8_BITS | PSC_MODE_PARNONE;
+ out_8(&psc->mode, PSC_MODE_8_BITS | PSC_MODE_PARNONE);
#endif
- psc->mode = PSC_MODE_ONE_STOP;
+ out_8(&psc->mode, PSC_MODE_ONE_STOP);
/* disable all interrupts */
- psc->psc_imr = 0;
+ out_be16(&psc->psc_imr, 0);
/* reset and enable Rx/Tx */
-// psc->command = PSC_RST_RX;
-// psc->command = PSC_RST_TX;
- psc->command = PSC_RX_ENABLE | PSC_TX_ENABLE;
+// out_8(&psc->command, PSC_RST_RX);
+// out_8(&psc->command, PSC_RST_TX);
+ out_8(&psc->command, PSC_RX_ENABLE | PSC_TX_ENABLE);
return 0;
}
@@ -116,10 +117,10 @@ static void mpc5xxx_serial_putc (struct console_device *cdev, const char c)
struct mpc5xxx_psc *psc = dev->priv;
/* Wait for last character to go. */
- while (!(psc->psc_status & PSC_SR_TXEMP))
+ while (!(in_be16(&psc->psc_status) & PSC_SR_TXEMP))
;
- psc->psc_buffer_8 = c;
+ out_8(&psc->psc_buffer_8, c);
}
static int mpc5xxx_serial_getc (struct console_device *cdev)
@@ -128,10 +129,10 @@ static int mpc5xxx_serial_getc (struct console_device *cdev)
struct mpc5xxx_psc *psc = dev->priv;
/* Wait for a character to arrive. */
- while (!(psc->psc_status & PSC_SR_RXRDY))
+ while (!(in_be16(&psc->psc_status) & PSC_SR_RXRDY))
;
- return psc->psc_buffer_8;
+ return in_8(&psc->psc_buffer_8);
}
static int mpc5xxx_serial_tstc (struct console_device *cdev)
@@ -139,7 +140,7 @@ static int mpc5xxx_serial_tstc (struct console_device *cdev)
struct device_d *dev = cdev->dev;
struct mpc5xxx_psc *psc = dev->priv;
- return (psc->psc_status & PSC_SR_RXRDY);
+ return in_be16(&psc->psc_status) & PSC_SR_RXRDY;
}
static int mpc5xxx_serial_probe(struct device_d *dev)
--
2.1.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2014-10-07 14:22 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-07 14:21 [RFC] Add PowerPC MPC5125 support Juergen Borleis
2014-10-07 14:22 ` [PATCH 01/19] arch/MPC5xxx: fix linker script for MPC5200 Juergen Borleis
2014-10-07 14:22 ` [PATCH 02/19] arch/MPC5xxx: use a mach specific linker script instead of a board specific one Juergen Borleis
2014-10-07 14:22 ` [PATCH 03/19] arch/MPC5xxx: replace 'depends on' by 'select' Juergen Borleis
2014-10-07 14:22 ` [PATCH 04/19] arch/MPC5xxx: Simplify the calculation Juergen Borleis
2014-10-07 14:22 ` [PATCH 05/19] arch/MPC5xxx: just a format clean up Juergen Borleis
2014-10-07 14:22 ` [PATCH 06/19] arch/MPC5xxx: move away existing files to be able to add a new SoC type Juergen Borleis
2014-10-07 14:22 ` [PATCH 07/19] arch/MPC5xxx: separate architecture's main SoC header file Juergen Borleis
2014-10-07 14:22 ` [PATCH 08/19] arch/MPC5xxx: separate clock functions Juergen Borleis
2014-10-07 14:22 ` [PATCH 09/19] arch/MPC5xxx: just use macros instead of anonymous digits Juergen Borleis
2014-10-07 14:22 ` Juergen Borleis [this message]
2014-10-07 14:22 ` [PATCH 11/19] MPC5xxx/serial: provide an easier way to share register description Juergen Borleis
2014-10-07 14:22 ` [PATCH 12/19] MPC5xxx/serial: use new shared " Juergen Borleis
2014-10-07 14:22 ` [PATCH 13/19] MPC5xxx/serial: re-factor the code to share it between MPC5200/MPC5125 Juergen Borleis
2014-10-07 14:22 ` [PATCH 14/19] arch/MPC5xxx: add MPC5125 SoC support Juergen Borleis
2014-10-07 14:22 ` [PATCH 15/19] arch/MPC5xxx: add MPC5125 to the build-system Juergen Borleis
2014-10-07 14:22 ` [PATCH 16/19] MPC5xxx/serial: add support for the MPC5125 SoC Juergen Borleis
2014-10-07 14:22 ` [PATCH 17/19] MPC5125/FEC: add another FEC driver " Juergen Borleis
2014-10-07 14:22 ` [PATCH 18/19] MPC5125/WDG: add a watchdog driver Juergen Borleis
2014-10-07 14:22 ` [PATCH 19/19] MPC5125/GPIO: add a generic GPIO driver Juergen Borleis
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=1412691738-11145-11-git-send-email-jbe@pengutronix.de \
--to=jbe@pengutronix.de \
--cc=barebox@lists.infradead.org \
/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