1b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0
261a6976bSPaul Mundt #include <linux/serial_sci.h>
361a6976bSPaul Mundt #include <linux/serial_core.h>
461a6976bSPaul Mundt #include <linux/io.h>
561a6976bSPaul Mundt #include <cpu/serial.h>
661a6976bSPaul Mundt
761a6976bSPaul Mundt #define SCPCR 0xA4000116
861a6976bSPaul Mundt #define SCPDR 0xA4000136
961a6976bSPaul Mundt
sh770x_sci_init_pins(struct uart_port * port,unsigned int cflag)1061a6976bSPaul Mundt static void sh770x_sci_init_pins(struct uart_port *port, unsigned int cflag)
1161a6976bSPaul Mundt {
1261a6976bSPaul Mundt unsigned short data;
1361a6976bSPaul Mundt
1461a6976bSPaul Mundt /* We need to set SCPCR to enable RTS/CTS */
1561a6976bSPaul Mundt data = __raw_readw(SCPCR);
1661a6976bSPaul Mundt /* Clear out SCP7MD1,0, SCP6MD1,0, SCP4MD1,0*/
1761a6976bSPaul Mundt __raw_writew(data & 0x0fcf, SCPCR);
1861a6976bSPaul Mundt
1961a6976bSPaul Mundt if (!(cflag & CRTSCTS)) {
2061a6976bSPaul Mundt /* We need to set SCPCR to enable RTS/CTS */
2161a6976bSPaul Mundt data = __raw_readw(SCPCR);
2261a6976bSPaul Mundt /* Clear out SCP7MD1,0, SCP4MD1,0,
2361a6976bSPaul Mundt Set SCP6MD1,0 = {01} (output) */
2461a6976bSPaul Mundt __raw_writew((data & 0x0fcf) | 0x1000, SCPCR);
2561a6976bSPaul Mundt
2661a6976bSPaul Mundt data = __raw_readb(SCPDR);
2761a6976bSPaul Mundt /* Set /RTS2 (bit6) = 0 */
2861a6976bSPaul Mundt __raw_writeb(data & 0xbf, SCPDR);
2961a6976bSPaul Mundt }
3061a6976bSPaul Mundt }
3161a6976bSPaul Mundt
3261a6976bSPaul Mundt struct plat_sci_port_ops sh770x_sci_port_ops = {
3361a6976bSPaul Mundt .init_pins = sh770x_sci_init_pins,
3461a6976bSPaul Mundt };
35