| 1 | /* |
|---|
| 2 | * hal_drivers.c - Driver initializers for TSAR |
|---|
| 3 | * |
|---|
| 4 | * Copyright (c) 2017 Maxime Villard |
|---|
| 5 | * |
|---|
| 6 | * This file is part of ALMOS-MKH. |
|---|
| 7 | * |
|---|
| 8 | * ALMOS-MKH is free software; you can redistribute it and/or modify it |
|---|
| 9 | * under the terms of the GNU General Public License as published by |
|---|
| 10 | * the Free Software Foundation; version 2.0 of the License. |
|---|
| 11 | * |
|---|
| 12 | * ALMOS-MKH is distributed in the hope that it will be useful, but |
|---|
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|---|
| 15 | * General Public License for more details. |
|---|
| 16 | * |
|---|
| 17 | * You should have received a copy of the GNU General Public License |
|---|
| 18 | * along with ALMOS-MKH; if not, write to the Free Software Foundation, |
|---|
| 19 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|---|
| 20 | */ |
|---|
| 21 | |
|---|
| 22 | #include <hal_types.h> |
|---|
| 23 | #include <chdev.h> |
|---|
| 24 | #include <hal_drivers.h> |
|---|
| 25 | #include <printk.h> |
|---|
| 26 | |
|---|
| 27 | #include <soclib_tty.h> |
|---|
| 28 | #include <soclib_pic.h> |
|---|
| 29 | #include <soclib_bdv.h> |
|---|
| 30 | #include <soclib_hba.h> |
|---|
| 31 | #include <soclib_mmc.h> |
|---|
| 32 | #include <soclib_nic.h> |
|---|
| 33 | #include <soclib_dma.h> |
|---|
| 34 | |
|---|
| 35 | #include <dev_txt.h> |
|---|
| 36 | #include <dev_pic.h> |
|---|
| 37 | #include <dev_ioc.h> |
|---|
| 38 | #include <dev_mmc.h> |
|---|
| 39 | #include <dev_nic.h> |
|---|
| 40 | #include <dev_dma.h> |
|---|
| 41 | |
|---|
| 42 | /////////////////////////////////////////////////////////////////////////////// |
|---|
| 43 | // TXT |
|---|
| 44 | /////////////////////////////////////////////////////////////////////////////// |
|---|
| 45 | |
|---|
| 46 | ////////////////////////////////////////// |
|---|
| 47 | void hal_drivers_txt_init( chdev_t * txt, |
|---|
| 48 | uint32_t impl ) |
|---|
| 49 | { |
|---|
| 50 | if( impl == IMPL_TXT_TTY ) |
|---|
| 51 | { |
|---|
| 52 | soclib_tty_init( txt ); |
|---|
| 53 | } |
|---|
| 54 | else |
|---|
| 55 | { |
|---|
| 56 | assert( false , __FUNCTION__ , "undefined TXT device implementation" ); |
|---|
| 57 | } |
|---|
| 58 | } |
|---|
| 59 | |
|---|
| 60 | /////////////////////////////////////////////////////////////////////////////// |
|---|
| 61 | // PIC |
|---|
| 62 | /////////////////////////////////////////////////////////////////////////////// |
|---|
| 63 | |
|---|
| 64 | ////////////////////////////////////////// |
|---|
| 65 | void hal_drivers_pic_init( chdev_t * pic, |
|---|
| 66 | uint32_t impl ) |
|---|
| 67 | { |
|---|
| 68 | if( impl != IMPL_PIC_SCL ) |
|---|
| 69 | { |
|---|
| 70 | assert( false , __FUNCTION__ , "undefined PIC device implementation" ); |
|---|
| 71 | } |
|---|
| 72 | |
|---|
| 73 | soclib_pic_init( pic ); |
|---|
| 74 | |
|---|
| 75 | /* update the PIC chdev extension */ |
|---|
| 76 | pic->ext.pic.enable_timer = &soclib_pic_enable_timer; |
|---|
| 77 | pic->ext.pic.enable_irq = &soclib_pic_enable_irq; |
|---|
| 78 | pic->ext.pic.disable_irq = &soclib_pic_disable_irq; |
|---|
| 79 | pic->ext.pic.bind_irq = &soclib_pic_bind_irq; |
|---|
| 80 | pic->ext.pic.send_ipi = &soclib_pic_send_ipi; |
|---|
| 81 | pic->ext.pic.extend_init = &soclib_pic_extend_init; |
|---|
| 82 | } |
|---|
| 83 | |
|---|
| 84 | /////////////////////////////////////////////////////////////////////////////// |
|---|
| 85 | // IOC |
|---|
| 86 | /////////////////////////////////////////////////////////////////////////////// |
|---|
| 87 | |
|---|
| 88 | ////////////////////////////////////////// |
|---|
| 89 | void hal_drivers_ioc_init( chdev_t * ioc, |
|---|
| 90 | uint32_t impl ) |
|---|
| 91 | { |
|---|
| 92 | if (impl == IMPL_IOC_BDV) |
|---|
| 93 | { |
|---|
| 94 | soclib_bdv_init( ioc ); |
|---|
| 95 | } |
|---|
| 96 | else if (impl == IMPL_IOC_HBA) |
|---|
| 97 | { |
|---|
| 98 | soclib_hba_init( ioc ); |
|---|
| 99 | } |
|---|
| 100 | else |
|---|
| 101 | { |
|---|
| 102 | assert( false , __FUNCTION__ , "undefined IOC device implementation" ); |
|---|
| 103 | } |
|---|
| 104 | } |
|---|
| 105 | |
|---|
| 106 | /////////////////////////////////////////////////////////////////////////////// |
|---|
| 107 | // MMC |
|---|
| 108 | /////////////////////////////////////////////////////////////////////////////// |
|---|
| 109 | |
|---|
| 110 | ////////////////////////////////////////// |
|---|
| 111 | void hal_drivers_mmc_init( chdev_t * mmc, |
|---|
| 112 | uint32_t impl ) |
|---|
| 113 | { |
|---|
| 114 | if( impl == IMPL_MMC_TSR ) |
|---|
| 115 | { |
|---|
| 116 | soclib_mmc_init( mmc ); |
|---|
| 117 | } |
|---|
| 118 | else |
|---|
| 119 | { |
|---|
| 120 | assert( false , __FUNCTION__ , "undefined MMC device implementation" ); |
|---|
| 121 | } |
|---|
| 122 | } |
|---|
| 123 | |
|---|
| 124 | /////////////////////////////////////////////////////////////////////////////// |
|---|
| 125 | // NIC |
|---|
| 126 | /////////////////////////////////////////////////////////////////////////////// |
|---|
| 127 | |
|---|
| 128 | ////////////////////////////////////////// |
|---|
| 129 | void hal_drivers_nic_init( chdev_t * nic, |
|---|
| 130 | uint32_t impl ) |
|---|
| 131 | { |
|---|
| 132 | if( impl == IMPL_NIC_SOC ) |
|---|
| 133 | { |
|---|
| 134 | soclib_nic_init( nic ); |
|---|
| 135 | } |
|---|
| 136 | else |
|---|
| 137 | { |
|---|
| 138 | assert( false , __FUNCTION__ , "undefined NIC device implementation" ); |
|---|
| 139 | } |
|---|
| 140 | } |
|---|
| 141 | |
|---|
| 142 | /////////////////////////////////////////////////////////////////////////////// |
|---|
| 143 | // DMA |
|---|
| 144 | /////////////////////////////////////////////////////////////////////////////// |
|---|
| 145 | |
|---|
| 146 | ////////////////////////////////////////// |
|---|
| 147 | void hal_drivers_dma_init( chdev_t * dma, |
|---|
| 148 | uint32_t impl ) |
|---|
| 149 | { |
|---|
| 150 | if( impl == IMPL_DMA_SCL ) |
|---|
| 151 | { |
|---|
| 152 | soclib_dma_init( dma ); |
|---|
| 153 | } |
|---|
| 154 | else |
|---|
| 155 | { |
|---|
| 156 | assert( false , __FUNCTION__ , "undefined DMA implementation" ); |
|---|
| 157 | } |
|---|
| 158 | } |
|---|
| 159 | |
|---|