serial-sh770x.c 874 B

12345678910111213141516171819202122232425262728293031323334
  1. // SPDX-License-Identifier: GPL-2.0
  2. #include <linux/serial_sci.h>
  3. #include <linux/serial_core.h>
  4. #include <linux/io.h>
  5. #include <cpu/serial.h>
  6. #define SCPCR 0xA4000116
  7. #define SCPDR 0xA4000136
  8. static void sh770x_sci_init_pins(struct uart_port *port, unsigned int cflag)
  9. {
  10. unsigned short data;
  11. /* We need to set SCPCR to enable RTS/CTS */
  12. data = __raw_readw(SCPCR);
  13. /* Clear out SCP7MD1,0, SCP6MD1,0, SCP4MD1,0*/
  14. __raw_writew(data & 0x0fcf, SCPCR);
  15. if (!(cflag & CRTSCTS)) {
  16. /* We need to set SCPCR to enable RTS/CTS */
  17. data = __raw_readw(SCPCR);
  18. /* Clear out SCP7MD1,0, SCP4MD1,0,
  19. Set SCP6MD1,0 = {01} (output) */
  20. __raw_writew((data & 0x0fcf) | 0x1000, SCPCR);
  21. data = __raw_readb(SCPDR);
  22. /* Set /RTS2 (bit6) = 0 */
  23. __raw_writeb(data & 0xbf, SCPDR);
  24. }
  25. }
  26. struct plat_sci_port_ops sh770x_sci_port_ops = {
  27. .init_pins = sh770x_sci_init_pins,
  28. };