[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> |
---|
[238] | 29 | #include <soclib_bdv.h> |
---|
| 30 | #include <soclib_hba.h> |
---|
[130] | 31 | |
---|
[238] | 32 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 33 | // TXT |
---|
| 34 | /////////////////////////////////////////////////////////////////////////////// |
---|
[77] | 35 | |
---|
[238] | 36 | ////////////////////////////////////////// |
---|
[245] | 37 | void hal_drivers_txt_init( chdev_t * txt, |
---|
| 38 | uint32_t impl ) |
---|
[130] | 39 | { |
---|
[245] | 40 | if( impl == IMPL_TXT_TTY ) |
---|
| 41 | { |
---|
| 42 | soclib_tty_init( txt ); |
---|
| 43 | } |
---|
| 44 | else |
---|
| 45 | { |
---|
| 46 | assert( false , __FUNCTION__ , "undefined TXT device implementation" ); |
---|
| 47 | } |
---|
[130] | 48 | } |
---|
| 49 | |
---|
[238] | 50 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 51 | // PIC |
---|
| 52 | /////////////////////////////////////////////////////////////////////////////// |
---|
[136] | 53 | |
---|
[238] | 54 | ////////////////////////////////////////// |
---|
[252] | 55 | void hal_drivers_pic_init( chdev_t * pic, |
---|
| 56 | uint32_t impl ) |
---|
[136] | 57 | { |
---|
[252] | 58 | if( impl != IMPL_PIC_SCL ) |
---|
| 59 | { |
---|
| 60 | assert( false , __FUNCTION__ , "undefined PIC device implementation" ); |
---|
| 61 | } |
---|
| 62 | |
---|
[238] | 63 | soclib_pic_init( pic ); |
---|
[136] | 64 | |
---|
[190] | 65 | /* update the PIC chdev extension */ |
---|
[238] | 66 | pic->ext.pic.enable_timer = &soclib_pic_enable_timer; |
---|
| 67 | pic->ext.pic.enable_irq = &soclib_pic_enable_irq; |
---|
| 68 | pic->ext.pic.disable_irq = &soclib_pic_disable_irq; |
---|
| 69 | pic->ext.pic.bind_irq = &soclib_pic_bind_irq; |
---|
| 70 | pic->ext.pic.send_ipi = &soclib_pic_send_ipi; |
---|
| 71 | pic->ext.pic.extend_init = &soclib_pic_extend_init; |
---|
[190] | 72 | } |
---|
[213] | 73 | |
---|
[238] | 74 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 75 | // IOC |
---|
| 76 | /////////////////////////////////////////////////////////////////////////////// |
---|
[213] | 77 | |
---|
[238] | 78 | ////////////////////////////////////////// |
---|
| 79 | void hal_drivers_ioc_init( chdev_t * ioc, |
---|
| 80 | uint32_t impl ) |
---|
[213] | 81 | { |
---|
[238] | 82 | if (impl == IMPL_IOC_BDV) |
---|
| 83 | { |
---|
| 84 | soclib_bdv_init( ioc ); |
---|
| 85 | } |
---|
| 86 | else if (impl == IMPL_IOC_HBA) |
---|
| 87 | { |
---|
| 88 | soclib_hba_init( ioc ); |
---|
| 89 | } |
---|
| 90 | else |
---|
| 91 | { |
---|
[216] | 92 | assert( false , __FUNCTION__ , "undefined IOC device implementation" ); |
---|
| 93 | } |
---|
[213] | 94 | } |
---|
| 95 | |
---|
[257] | 96 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 97 | // MMC |
---|
| 98 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 99 | |
---|
| 100 | ////////////////////////////////////////// |
---|
| 101 | void hal_drivers_mmc_init( chdev_t * mmc, |
---|
| 102 | uint32_t impl ) |
---|
| 103 | { |
---|
| 104 | if( impl == IMPL_MMC_TSR ) |
---|
| 105 | { |
---|
| 106 | soclib_mmc_init( mmc ); |
---|
| 107 | } |
---|
| 108 | else |
---|
| 109 | { |
---|
| 110 | assert( false , __FUNCTION__ , "undefined MMC device implementation" ); |
---|
| 111 | } |
---|
| 112 | } |
---|
| 113 | |
---|
[259] | 114 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 115 | // NIC |
---|
| 116 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 117 | |
---|
| 118 | ////////////////////////////////////////// |
---|
| 119 | void hal_drivers_nic_init( chdev_t * nic, |
---|
| 120 | uint32_t impl ) |
---|
| 121 | { |
---|
| 122 | if( impl == IMPL_NIC_SOC ) |
---|
| 123 | { |
---|
| 124 | soclib_nic_init( nic ); |
---|
| 125 | } |
---|
| 126 | else |
---|
| 127 | { |
---|
| 128 | assert( false , __FUNCTION__ , "undefined NIC device implementation" ); |
---|
| 129 | } |
---|
| 130 | } |
---|
| 131 | |
---|
[261] | 132 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 133 | // DMA |
---|
| 134 | /////////////////////////////////////////////////////////////////////////////// |
---|
| 135 | |
---|
| 136 | ////////////////////////////////////////// |
---|
| 137 | void hal_drivers_dma_init( chdev_t * dma, |
---|
| 138 | uint32_t impl ) |
---|
| 139 | { |
---|
| 140 | if( impl == IMPL_DMA_SCL ) |
---|
| 141 | { |
---|
| 142 | soclib_dma_init( dma ); |
---|
| 143 | } |
---|
| 144 | else |
---|
| 145 | { |
---|
| 146 | assert( false , __FUNCTION__ , "undefined DMA implementation" ); |
---|
| 147 | } |
---|
| 148 | } |
---|
| 149 | |
---|