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 gsbi3_uart_irqs[] = {GSBI3_UART_IRQ, -1}; 23static const int gsbi4_uart_irqs[] = {GSBI4_UART_IRQ, -1}; 24static const int gsbi5_uart_irqs[] = {GSBI5_UART_IRQ, -1}; 25static const int gsbi6_uart_irqs[] = {GSBI6_UART_IRQ, -1}; 26static const int gsbi7_uart_irqs[] = {GSBI7_UART_IRQ, -1}; 27 28#define GSBI_UART_DEFN(devid) { \ 29 .id = GSBI##devid##_UART, \ 30 .paddr = GSBI##devid##_UART_PADDR, \ 31 .size = BIT(12), \ 32 .irqs = gsbi##devid##_uart_irqs, \ 33 .init_fn = &uart_init \ 34} 35 36static const struct dev_defn dev_defn[] = { 37 GSBI_UART_DEFN(3), 38 GSBI_UART_DEFN(4), 39 GSBI_UART_DEFN(5), 40 GSBI_UART_DEFN(6), 41 GSBI_UART_DEFN(7) 42}; 43 44struct ps_chardevice* 45ps_cdev_init(enum chardev_id id, const ps_io_ops_t* o, struct ps_chardevice* d) { 46 unsigned int i; 47 for (i = 0; i < ARRAY_SIZE(dev_defn); i++) { 48 if (dev_defn[i].id == id) { 49 return (dev_defn[i].init_fn(dev_defn + i, o, d)) ? NULL : d; 50 } 51 } 52 return NULL; 53} 54