1/* 2 * Copyright 2017, Data61 3 * Commonwealth Scientific and Industrial Research Organisation (CSIRO) 4 * ABN 41 687 119 230. 5 * 6 * This software may be distributed and modified according to the terms of 7 * the BSD 2-Clause license. Note that NO WARRANTY is provided. 8 * See "LICENSE_BSD2.txt" for details. 9 * 10 * @TAG(DATA61_BSD) 11 */ 12 13#pragma once 14 15#include <platsupport/chardev.h> 16#include <platsupport/plat/serial.h> 17 18/***************************** 19 **** Serial device flags **** 20 *****************************/ 21 22/* Auto-send CR(Carriage Return) after each "\n". 23 * NOTE: This flag should be set by default. */ 24#define SERIAL_AUTO_CR BIT(0) 25 26/*****************************/ 27 28enum serial_parity { 29 PARITY_NONE, 30 PARITY_EVEN, 31 PARITY_ODD 32}; 33 34/* 35 * Initialiase a device 36 * @param id: the id of the character device 37 * @param ops: a structure containing OS specific operations for memory access 38 * @param dev: a character device structure to populate 39 * @return : 0 on success 40 */ 41int serial_init(enum chardev_id id, 42 ps_io_ops_t* ops, 43 ps_chardevice_t* dev); 44 45/* 46 * Performs line configuration of a serial port 47 * @param dev: an initialised character device structure 48 * @param bps: The desired boad rate 49 * @param char_size: The desired character size 50 * @param stop_bits: The number of stop bits 51 */ 52int serial_configure(ps_chardevice_t* dev, 53 long bps, 54 int char_size, 55 enum serial_parity parity, 56 int stop_bits); 57 58