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/** 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 22static const int uartA_irqs[] = {UARTA_IRQ, -1}; 23static const int uartB_irqs[] = {UARTB_IRQ, -1}; 24static const int uartC_irqs[] = {UARTC_IRQ, -1}; 25static const int uartD_irqs[] = {UARTD_IRQ, -1}; 26static const int uartA_ASYNC_irqs[] = {UARTA_IRQ, -1}; 27static const int uartB_ASYNC_irqs[] = {UARTB_IRQ, -1}; 28static const int uartC_ASYNC_irqs[] = {UARTC_IRQ, -1}; 29static const int uartD_ASYNC_irqs[] = {UARTD_IRQ, -1}; 30 31#define UART_DEFN(devid) { \ 32 .id = NV_UART##devid, \ 33 .paddr = UART##devid##_PADDR, \ 34 .size = BIT(12), \ 35 .irqs = uart##devid##_irqs, \ 36 .init_fn = &uart_init \ 37} 38 39#define UART_ASYNC_DEFN(devid) { \ 40 .id = NV_UART##devid##_ASYNC, \ 41 .paddr = UART##devid##_PADDR, \ 42 .size = BIT(12), \ 43 .irqs = uart##devid##_ASYNC_irqs, \ 44 .init_fn = &uart_init \ 45} 46 47static const struct dev_defn dev_defn[] = { 48 UART_DEFN(A), 49 UART_DEFN(B), 50 UART_DEFN(C), 51 UART_DEFN(D), 52 UART_ASYNC_DEFN(A), 53 UART_ASYNC_DEFN(B), 54 UART_ASYNC_DEFN(C), 55 UART_ASYNC_DEFN(D) 56}; 57 58struct ps_chardevice* 59ps_cdev_init(enum chardev_id id, const ps_io_ops_t* o, struct ps_chardevice* d) { 60 unsigned int i; 61 for (i = 0; i < ARRAY_SIZE(dev_defn); i++) { 62 if (dev_defn[i].id == id) { 63 return (dev_defn[i].init_fn(dev_defn + i, o, d)) ? NULL : d; 64 } 65 } 66 return NULL; 67} 68