1/* 2 * Copyright 2019, 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/** 14 * Contains the definition for all character devices on this platform. 15 * Currently this is just a simple patch. 16 */ 17 18#include "../../chardev.h" 19#include "../../common.h" 20#include <utils/util.h> 21 22#include "../../chardev.h" 23 24static const int uart0_irqs[] = {UART0_IRQ, -1}; 25static const int uart1_irqs[] = {UART1_IRQ, -1}; 26static const int uart2_irqs[] = {UART2_IRQ, -1}; 27static const int uart0_AO_irqs[] = {UART0_AO_IRQ, -1}; 28static const int uart2_AO_irqs[] = {UART2_AO_IRQ, -1}; 29 30#define UART_DEFN(devid) { \ 31 .id = UART##devid, \ 32 .paddr = UART##devid##_PADDR, \ 33 .size = BIT(12), \ 34 .irqs = uart##devid##_irqs, \ 35 .init_fn = &uart_init \ 36} 37 38static const struct dev_defn dev_defn[] = { 39 UART_DEFN(0), 40 UART_DEFN(1), 41 UART_DEFN(2), 42 UART_DEFN(0_AO), 43 UART_DEFN(2_AO), 44}; 45 46struct ps_chardevice * 47ps_cdev_init(enum chardev_id id, const ps_io_ops_t *o, struct ps_chardevice *d) 48{ 49 unsigned int i; 50 for (i = 0; i < ARRAY_SIZE(dev_defn); i++) { 51 if (dev_defn[i].id == id) { 52 return (dev_defn[i].init_fn(dev_defn + i, o, d)) ? NULL : d; 53 } 54 } 55 return NULL; 56} 57