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 definitions for all character devices on this 15 * platform 16 */ 17 18#include "../../chardev.h" 19#include "../../common.h" 20 21#include <utils/arith.h> 22 23static const int uart1_irqs[] = {UART1_IRQ, -1}; 24static const int uart2_irqs[] = {UART2_IRQ, -1}; 25static const int uart3_irqs[] = {UART3_IRQ, -1}; 26static const int uart4_irqs[] = {UART4_IRQ, -1}; 27 28#define UART_DEFN(devid) { \ 29 .id = OMAP3_UART##devid, \ 30 .paddr = UART##devid##_PADDR, \ 31 .size = (1<<12), \ 32 .irqs = uart##devid##_irqs, \ 33 .init_fn = &uart_init \ 34 } 35 36static const struct dev_defn dev_defn[] = { 37 UART_DEFN(1), 38 UART_DEFN(2), 39 UART_DEFN(3), 40 UART_DEFN(4) 41}; 42 43/* It would be nice to reuse this, but it requires knowledge of the variable * 44 * sized 'dev_defn' */ 45struct ps_chardevice* 46ps_cdev_init(enum chardev_id id, const ps_io_ops_t* o, 47 struct ps_chardevice* d) { 48 int i; 49 for (i = 0; i < ARRAY_SIZE(dev_defn); i++) { 50 if (dev_defn[i].id == id) { 51 return (dev_defn[i].init_fn(dev_defn + i, o, d)) ? NULL : d; 52 } 53 } 54 return NULL; 55} 56