Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / arch / powerpc / boot / mpc52xx-psc.c
blobc2c08633ee356c33eee7dd5ebb0f4f52bdf023d5
1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * MPC5200 PSC serial console support.
5 * Author: Grant Likely <grant.likely@secretlab.ca>
7 * Copyright (c) 2007 Secret Lab Technologies Ltd.
8 * Copyright (c) 2007 Freescale Semiconductor, Inc.
10 * It is assumed that the firmware (or the platform file) has already set
11 * up the port.
14 #include "types.h"
15 #include "io.h"
16 #include "ops.h"
18 /* Programmable Serial Controller (PSC) status register bits */
19 #define MPC52xx_PSC_SR 0x04
20 #define MPC52xx_PSC_SR_RXRDY 0x0100
21 #define MPC52xx_PSC_SR_RXFULL 0x0200
22 #define MPC52xx_PSC_SR_TXRDY 0x0400
23 #define MPC52xx_PSC_SR_TXEMP 0x0800
25 #define MPC52xx_PSC_BUFFER 0x0C
27 static void *psc;
29 static int psc_open(void)
31 /* Assume the firmware has already configured the PSC into
32 * uart mode */
33 return 0;
36 static void psc_putc(unsigned char c)
38 while (!(in_be16(psc + MPC52xx_PSC_SR) & MPC52xx_PSC_SR_TXRDY)) ;
39 out_8(psc + MPC52xx_PSC_BUFFER, c);
42 static unsigned char psc_tstc(void)
44 return (in_be16(psc + MPC52xx_PSC_SR) & MPC52xx_PSC_SR_RXRDY) != 0;
47 static unsigned char psc_getc(void)
49 while (!(in_be16(psc + MPC52xx_PSC_SR) & MPC52xx_PSC_SR_RXRDY)) ;
50 return in_8(psc + MPC52xx_PSC_BUFFER);
53 int mpc5200_psc_console_init(void *devp, struct serial_console_data *scdp)
55 /* Get the base address of the psc registers */
56 if (dt_get_virtual_reg(devp, &psc, 1) < 1)
57 return -1;
59 scdp->open = psc_open;
60 scdp->putc = psc_putc;
61 scdp->getc = psc_getc;
62 scdp->tstc = psc_tstc;
64 return 0;