1 /* SPDX-License-Identifier: BSD-2-Clause */ 2 /* 3 * Copyright (c) 2016, Linaro Limited 4 */ 5 #ifndef __DRIVERS_SERIAL_H 6 #define __DRIVERS_SERIAL_H 7 8 #include <assert.h> 9 #include <stdbool.h> 10 #include <types_ext.h> 11 #include <mm/core_memprot.h> 12 #include <mm/core_mmu.h> 13 14 struct serial_chip { 15 const struct serial_ops *ops; 16 }; 17 18 struct serial_ops { 19 void (*putc)(struct serial_chip *chip, int ch); 20 void (*flush)(struct serial_chip *chip); 21 bool (*have_rx_data)(struct serial_chip *chip); 22 int (*getchar)(struct serial_chip *chip); 23 }; 24 25 struct serial_driver { 26 /* Allocate device data and return the inner serial_chip */ 27 struct serial_chip *(*dev_alloc)(void); 28 /* 29 * Initialize device from FDT node. @parms is device-specific, 30 * its meaning is as defined by the DT bindings for the characters 31 * following the ":" in /chosen/stdout-path. Typically for UART 32 * devices this is <baud>{<parity>{<bits>{<flow>}}} where: 33 * baud - baud rate in decimal 34 * parity - 'n' (none), 'o', (odd) or 'e' (even) 35 * bits - number of data bits 36 * flow - 'r' (rts) 37 * For example: 115200n8r 38 */ 39 int (*dev_init)(struct serial_chip *dev, const void *fdt, 40 int offset, const char *parms); 41 void (*dev_free)(struct serial_chip *dev); 42 }; 43 44 #endif /*__DRIVERS_SERIASERIAL_H*/ 45