[77] | 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 |
---|
[245] | 18 | * along with ALMOS-MKH; if not, write to the Free Software Foundation, |
---|
[77] | 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> |
---|
[238] | 25 | #include <printk.h> |
---|
[77] | 26 | |
---|
[130] | 27 | #include <soclib_tty.h> |
---|
[196] | 28 | #include <soclib_pic.h> |
---|
[346] | 29 | #include <soclib_iob.h> |
---|
[238] | 30 | #include <soclib_bdv.h> |
---|
| 31 | #include <soclib_hba.h> |
---|
[266] | 32 | #include <soclib_mmc.h> |
---|
| 33 | #include <soclib_nic.h> |
---|
| 34 | #include <soclib_dma.h> |
---|
[130] | 35 | |
---|
[266] | 36 | #include <dev_txt.h> |
---|
| 37 | #include <dev_pic.h> |
---|
| 38 | #include <dev_ioc.h> |
---|
| 39 | #include <dev_mmc.h> |
---|
| 40 | #include <dev_nic.h> |
---|
| 41 | #include <dev_dma.h> |
---|
| 42 | |
---|
[238] | 43 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 44 | // TXT |
---|
| 45 | /////////////////////////////////////////////////////////////////////////////// |
---|
[77] | 46 | |
---|
[238] | 47 | ////////////////////////////////////////// |
---|
[245] | 48 | void hal_drivers_txt_init( chdev_t * txt, |
---|
| 49 | uint32_t impl ) |
---|
[130] | 50 | { |
---|
[245] | 51 | if( impl == IMPL_TXT_TTY ) |
---|
| 52 | { |
---|
| 53 | soclib_tty_init( txt ); |
---|
| 54 | } |
---|
| 55 | else |
---|
| 56 | { |
---|
| 57 | assert( false , __FUNCTION__ , "undefined TXT device implementation" ); |
---|
| 58 | } |
---|
[130] | 59 | } |
---|
| 60 | |
---|
[238] | 61 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 62 | // PIC |
---|
| 63 | /////////////////////////////////////////////////////////////////////////////// |
---|
[136] | 64 | |
---|
[238] | 65 | ////////////////////////////////////////// |
---|
[252] | 66 | void hal_drivers_pic_init( chdev_t * pic, |
---|
| 67 | uint32_t impl ) |
---|
[136] | 68 | { |
---|
[252] | 69 | if( impl != IMPL_PIC_SCL ) |
---|
| 70 | { |
---|
| 71 | assert( false , __FUNCTION__ , "undefined PIC device implementation" ); |
---|
| 72 | } |
---|
| 73 | |
---|
[238] | 74 | soclib_pic_init( pic ); |
---|
[136] | 75 | |
---|
[190] | 76 | /* update the PIC chdev extension */ |
---|
[238] | 77 | pic->ext.pic.enable_timer = &soclib_pic_enable_timer; |
---|
[279] | 78 | pic->ext.pic.enable_ipi = &soclib_pic_enable_ipi; |
---|
[238] | 79 | pic->ext.pic.enable_irq = &soclib_pic_enable_irq; |
---|
| 80 | pic->ext.pic.disable_irq = &soclib_pic_disable_irq; |
---|
| 81 | pic->ext.pic.bind_irq = &soclib_pic_bind_irq; |
---|
| 82 | pic->ext.pic.send_ipi = &soclib_pic_send_ipi; |
---|
| 83 | pic->ext.pic.extend_init = &soclib_pic_extend_init; |
---|
[190] | 84 | } |
---|
[213] | 85 | |
---|
[238] | 86 | /////////////////////////////////////////////////////////////////////////////// |
---|
[346] | 87 | // IOB |
---|
| 88 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 89 | |
---|
| 90 | ////////////////////////////////////////// |
---|
| 91 | void hal_drivers_iob_init( chdev_t * iob, |
---|
| 92 | uint32_t impl ) |
---|
| 93 | { |
---|
| 94 | if (impl != IMPL_IOB_TSR) |
---|
| 95 | { |
---|
| 96 | assert( false , __FUNCTION__ , "undefined IOB device implementation" ); |
---|
| 97 | } |
---|
| 98 | |
---|
| 99 | soclib_iob_init( iob ); |
---|
| 100 | |
---|
| 101 | /* update the IOB chdev extension */ |
---|
| 102 | iob->ext.iob.set_active = &soclib_iob_set_active; |
---|
| 103 | iob->ext.iob.set_ptpr = &soclib_iob_set_ptpr; |
---|
| 104 | iob->ext.iob.inval_page = &soclib_iob_inval_page; |
---|
| 105 | iob->ext.iob.get_bvar = &soclib_iob_get_bvar; |
---|
| 106 | iob->ext.iob.get_srcid = &soclib_iob_get_srcid; |
---|
| 107 | iob->ext.iob.get_error = &soclib_iob_get_error; |
---|
| 108 | } |
---|
| 109 | |
---|
| 110 | /////////////////////////////////////////////////////////////////////////////// |
---|
[238] | 111 | // IOC |
---|
| 112 | /////////////////////////////////////////////////////////////////////////////// |
---|
[213] | 113 | |
---|
[238] | 114 | ////////////////////////////////////////// |
---|
| 115 | void hal_drivers_ioc_init( chdev_t * ioc, |
---|
| 116 | uint32_t impl ) |
---|
[213] | 117 | { |
---|
[238] | 118 | if (impl == IMPL_IOC_BDV) |
---|
| 119 | { |
---|
| 120 | soclib_bdv_init( ioc ); |
---|
| 121 | } |
---|
| 122 | else if (impl == IMPL_IOC_HBA) |
---|
| 123 | { |
---|
| 124 | soclib_hba_init( ioc ); |
---|
| 125 | } |
---|
| 126 | else |
---|
| 127 | { |
---|
[216] | 128 | assert( false , __FUNCTION__ , "undefined IOC device implementation" ); |
---|
| 129 | } |
---|
[213] | 130 | } |
---|
| 131 | |
---|
[257] | 132 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 133 | // MMC |
---|
| 134 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 135 | |
---|
| 136 | ////////////////////////////////////////// |
---|
| 137 | void hal_drivers_mmc_init( chdev_t * mmc, |
---|
| 138 | uint32_t impl ) |
---|
| 139 | { |
---|
| 140 | if( impl == IMPL_MMC_TSR ) |
---|
| 141 | { |
---|
| 142 | soclib_mmc_init( mmc ); |
---|
| 143 | } |
---|
| 144 | else |
---|
| 145 | { |
---|
| 146 | assert( false , __FUNCTION__ , "undefined MMC device implementation" ); |
---|
| 147 | } |
---|
| 148 | } |
---|
| 149 | |
---|
[259] | 150 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 151 | // NIC |
---|
| 152 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 153 | |
---|
| 154 | ////////////////////////////////////////// |
---|
| 155 | void hal_drivers_nic_init( chdev_t * nic, |
---|
| 156 | uint32_t impl ) |
---|
| 157 | { |
---|
| 158 | if( impl == IMPL_NIC_SOC ) |
---|
| 159 | { |
---|
| 160 | soclib_nic_init( nic ); |
---|
| 161 | } |
---|
| 162 | else |
---|
| 163 | { |
---|
| 164 | assert( false , __FUNCTION__ , "undefined NIC device implementation" ); |
---|
| 165 | } |
---|
| 166 | } |
---|
| 167 | |
---|
[261] | 168 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 169 | // DMA |
---|
| 170 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 171 | |
---|
| 172 | ////////////////////////////////////////// |
---|
| 173 | void hal_drivers_dma_init( chdev_t * dma, |
---|
| 174 | uint32_t impl ) |
---|
| 175 | { |
---|
| 176 | if( impl == IMPL_DMA_SCL ) |
---|
| 177 | { |
---|
| 178 | soclib_dma_init( dma ); |
---|
| 179 | } |
---|
| 180 | else |
---|
| 181 | { |
---|
| 182 | assert( false , __FUNCTION__ , "undefined DMA implementation" ); |
---|
| 183 | } |
---|
| 184 | } |
---|
| 185 | |
---|