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