source: trunk/hal/tsar_mips32/core/hal_drivers.c @ 647

Last change on this file since 647 was 647, checked in by alain, 5 years ago

...miscelaneous...

File size: 5.4 KB
RevLine 
[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>
[570]28#include <soclib_mty.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>
[647]36#include <soclib_fbf.h>
[130]37
[266]38#include <dev_txt.h>
39#include <dev_pic.h>
40#include <dev_ioc.h>
41#include <dev_mmc.h>
42#include <dev_nic.h>
43#include <dev_dma.h>
44
[238]45///////////////////////////////////////////////////////////////////////////////
46//    TXT
47///////////////////////////////////////////////////////////////////////////////
[77]48
[647]49///////////////////////////////////////////
50void hal_drivers_txt_init( chdev_t  * txt )
[130]51{
[647]52    uint32_t   impl = txt->impl;
53
[570]54    if( impl ==  IMPL_TXT_TTY )
55    {
[534]56        soclib_tty_init( txt );
57    }
[570]58    else if (impl == IMPL_TXT_MTY )
59    {
60        soclib_mty_init( txt );
[534]61    }
[570]62    else
63    {
64        assert( false, "undefined implementation" );
[534]65    }
[130]66}
67
[238]68///////////////////////////////////////////////////////////////////////////////
69//    PIC
70///////////////////////////////////////////////////////////////////////////////
[136]71
[647]72///////////////////////////////////////////
73void hal_drivers_pic_init( chdev_t  * pic )
[136]74{
[647]75    uint32_t   impl = pic->impl;
76
[570]77    assert( (impl == IMPL_PIC_SCL), "undefined implementation" );
[252]78
[238]79        soclib_pic_init( pic );
[136]80
[190]81        /* update the PIC chdev extension */
[238]82        pic->ext.pic.enable_timer = &soclib_pic_enable_timer;
[279]83        pic->ext.pic.enable_ipi   = &soclib_pic_enable_ipi;
[238]84        pic->ext.pic.enable_irq   = &soclib_pic_enable_irq;
85        pic->ext.pic.disable_irq  = &soclib_pic_disable_irq;
86        pic->ext.pic.bind_irq     = &soclib_pic_bind_irq;
87        pic->ext.pic.send_ipi     = &soclib_pic_send_ipi;
[407]88        pic->ext.pic.ack_ipi      = &soclib_pic_ack_ipi;
[238]89        pic->ext.pic.extend_init  = &soclib_pic_extend_init;
[190]90}
[213]91
[238]92///////////////////////////////////////////////////////////////////////////////
[346]93//    IOB
94///////////////////////////////////////////////////////////////////////////////
95
[647]96///////////////////////////////////////////
97void hal_drivers_iob_init( chdev_t  * iob )
[346]98{
[647]99    uint32_t   impl = iob->impl;
100
[570]101        assert( (impl == IMPL_IOB_TSR), "undefined implementation" );
[346]102
103        soclib_iob_init( iob );
104
105        /* update the IOB chdev extension */
106        iob->ext.iob.set_active = &soclib_iob_set_active;
107        iob->ext.iob.set_ptpr   = &soclib_iob_set_ptpr;
108        iob->ext.iob.inval_page = &soclib_iob_inval_page;
109        iob->ext.iob.get_bvar   = &soclib_iob_get_bvar;
110        iob->ext.iob.get_srcid  = &soclib_iob_get_srcid;
111        iob->ext.iob.get_error  = &soclib_iob_get_error;
112}
113
114///////////////////////////////////////////////////////////////////////////////
[238]115//    IOC
116///////////////////////////////////////////////////////////////////////////////
[213]117
[647]118///////////////////////////////////////////
119void hal_drivers_ioc_init( chdev_t  * ioc )
[213]120{
[647]121    uint32_t   impl = ioc->impl;
122
[238]123        if (impl == IMPL_IOC_BDV) 
124    {
125                soclib_bdv_init( ioc );
126        } 
127    else if (impl == IMPL_IOC_HBA)
128    {
129                soclib_hba_init( ioc );
130        }
[570]131//      else if (impl == IMPL_IOC_SPI)
132//  {
133//              soclib_sdc_init( ioc );
134//      }
[238]135    else 
136    {
[492]137                assert( false , "undefined IOC device implementation" );
[216]138        }
[213]139}
140
[257]141///////////////////////////////////////////////////////////////////////////////
142//    MMC
143///////////////////////////////////////////////////////////////////////////////
144
[647]145///////////////////////////////////////////
146void hal_drivers_mmc_init( chdev_t  * mmc )
[257]147{
[647]148    uint32_t   impl = mmc->impl;
149
[570]150        assert( (impl == IMPL_MMC_TSR), "undefined implementation" );
[407]151 
152    soclib_mmc_init( mmc );
[257]153}
154
[259]155///////////////////////////////////////////////////////////////////////////////
156//    NIC
157///////////////////////////////////////////////////////////////////////////////
158
[647]159///////////////////////////////////////////
160void hal_drivers_nic_init( chdev_t  * nic )
[259]161{
[647]162    uint32_t   impl = nic->impl;
163
[570]164        assert( (impl == IMPL_NIC_CBF), "undefined implementation" );
[407]165 
166    soclib_nic_init( nic );
[259]167}
168
[261]169///////////////////////////////////////////////////////////////////////////////
170//    DMA
171///////////////////////////////////////////////////////////////////////////////
172
[647]173///////////////////////////////////////////
174void hal_drivers_dma_init( chdev_t  * dma )
[261]175{
[647]176    uint32_t   impl = dma->impl;
177
[570]178        assert( (impl == IMPL_DMA_SCL), "undefined implementation" );
[407]179 
180    soclib_dma_init( dma );
[261]181}
182
[647]183///////////////////////////////////////////////////////////////////////////////
184//    FBF
185///////////////////////////////////////////////////////////////////////////////
186
187///////////////////////////////////////////
188void hal_drivers_fbf_init( chdev_t  * fbf )
189{
190    uint32_t   impl = fbf->impl;
191
192        assert( (impl == IMPL_FBF_SCL), "undefined implementation" );
193 
194    soclib_fbf_init( fbf );
195}
196
Note: See TracBrowser for help on using the repository browser.