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