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 /* Mandatory handler */ 20 void (*putc)(struct serial_chip *chip, int ch); 21 /* Optional handlers */ 22 void (*flush)(struct serial_chip *chip); 23 bool (*have_rx_data)(struct serial_chip *chip); 24 int (*getchar)(struct serial_chip *chip); 25 }; 26 27 struct serial_driver { 28 /* Allocate device data and return the inner serial_chip */ 29 struct serial_chip *(*dev_alloc)(void); 30 /* 31 * Initialize device from FDT node. @parms is device-specific, 32 * its meaning is as defined by the DT bindings for the characters 33 * following the ":" in /chosen/stdout-path. Typically for UART 34 * devices this is <baud>{<parity>{<bits>{<flow>}}} where: 35 * baud - baud rate in decimal 36 * parity - 'n' (none), 'o', (odd) or 'e' (even) 37 * bits - number of data bits 38 * flow - 'r' (rts) 39 * For example: 115200n8r 40 */ 41 int (*dev_init)(struct serial_chip *dev, const void *fdt, 42 int offset, const char *parms); 43 void (*dev_free)(struct serial_chip *dev); 44 }; 45 46 #endif /*__DRIVERS_SERIASERIAL_H*/ 47