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

Last change on this file was 686, checked in by alain, 3 years ago

cosmetic

File size: 5.5 KB
RevLine 
[77]1/*
2 * hal_drivers.c - Driver initializers for TSAR
3 *
[686]4 * Author        Maxime Villard (2017)
[77]5 *
[686]6 * Copyright (c) UPMC Sorbonne Universites
7 *
[77]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
[245]20 * along with ALMOS-MKH; if not, write to the Free Software Foundation,
[77]21 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23
[457]24#include <hal_kernel_types.h>
[77]25#include <chdev.h>
26#include <hal_drivers.h>
[238]27#include <printk.h>
[77]28
[130]29#include <soclib_tty.h>
[570]30#include <soclib_mty.h>
[196]31#include <soclib_pic.h>
[346]32#include <soclib_iob.h>
[238]33#include <soclib_bdv.h>
34#include <soclib_hba.h>
[266]35#include <soclib_mmc.h>
36#include <soclib_nic.h>
37#include <soclib_dma.h>
[647]38#include <soclib_fbf.h>
[130]39
[266]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
[238]47///////////////////////////////////////////////////////////////////////////////
48//    TXT
49///////////////////////////////////////////////////////////////////////////////
[77]50
[647]51///////////////////////////////////////////
52void hal_drivers_txt_init( chdev_t  * txt )
[130]53{
[647]54    uint32_t   impl = txt->impl;
55
[570]56    if( impl ==  IMPL_TXT_TTY )
57    {
[534]58        soclib_tty_init( txt );
59    }
[570]60    else if (impl == IMPL_TXT_MTY )
61    {
62        soclib_mty_init( txt );
[534]63    }
[570]64    else
65    {
[679]66        assert( __FUNCTION__, false, "undefined implementation" );
[534]67    }
[130]68}
69
[238]70///////////////////////////////////////////////////////////////////////////////
71//    PIC
72///////////////////////////////////////////////////////////////////////////////
[136]73
[647]74///////////////////////////////////////////
75void hal_drivers_pic_init( chdev_t  * pic )
[136]76{
[647]77    uint32_t   impl = pic->impl;
78
[679]79    assert( __FUNCTION__, (impl == IMPL_PIC_SCL), "undefined implementation" );
[252]80
[238]81        soclib_pic_init( pic );
[136]82
[190]83        /* update the PIC chdev extension */
[238]84        pic->ext.pic.enable_timer = &soclib_pic_enable_timer;
[279]85        pic->ext.pic.enable_ipi   = &soclib_pic_enable_ipi;
[238]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;
[407]90        pic->ext.pic.ack_ipi      = &soclib_pic_ack_ipi;
[238]91        pic->ext.pic.extend_init  = &soclib_pic_extend_init;
[190]92}
[213]93
[238]94///////////////////////////////////////////////////////////////////////////////
[346]95//    IOB
96///////////////////////////////////////////////////////////////////////////////
97
[647]98///////////////////////////////////////////
99void hal_drivers_iob_init( chdev_t  * iob )
[346]100{
[647]101    uint32_t   impl = iob->impl;
102
[679]103        assert( __FUNCTION__, (impl == IMPL_IOB_TSR), "undefined implementation" );
[346]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///////////////////////////////////////////////////////////////////////////////
[238]117//    IOC
118///////////////////////////////////////////////////////////////////////////////
[213]119
[647]120///////////////////////////////////////////
121void hal_drivers_ioc_init( chdev_t  * ioc )
[213]122{
[647]123    uint32_t   impl = ioc->impl;
124
[238]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        }
[570]133//      else if (impl == IMPL_IOC_SPI)
134//  {
135//              soclib_sdc_init( ioc );
136//      }
[238]137    else 
138    {
[679]139                assert( __FUNCTION__, false , "undefined IOC device implementation" );
[216]140        }
[213]141}
142
[257]143///////////////////////////////////////////////////////////////////////////////
144//    MMC
145///////////////////////////////////////////////////////////////////////////////
146
[647]147///////////////////////////////////////////
148void hal_drivers_mmc_init( chdev_t  * mmc )
[257]149{
[647]150    uint32_t   impl = mmc->impl;
151
[679]152        assert( __FUNCTION__, (impl == IMPL_MMC_TSR), "undefined implementation" );
[407]153 
154    soclib_mmc_init( mmc );
[257]155}
156
[259]157///////////////////////////////////////////////////////////////////////////////
158//    NIC
159///////////////////////////////////////////////////////////////////////////////
160
[647]161///////////////////////////////////////////
162void hal_drivers_nic_init( chdev_t  * nic )
[259]163{
[647]164    uint32_t   impl = nic->impl;
165
[679]166        assert( __FUNCTION__, (impl == IMPL_NIC_CBF), "undefined implementation" );
[407]167 
168    soclib_nic_init( nic );
[259]169}
170
[261]171///////////////////////////////////////////////////////////////////////////////
172//    DMA
173///////////////////////////////////////////////////////////////////////////////
174
[647]175///////////////////////////////////////////
176void hal_drivers_dma_init( chdev_t  * dma )
[261]177{
[647]178    uint32_t   impl = dma->impl;
179
[679]180        assert( __FUNCTION__, (impl == IMPL_DMA_SCL), "undefined implementation" );
[407]181 
182    soclib_dma_init( dma );
[261]183}
184
[647]185///////////////////////////////////////////////////////////////////////////////
186//    FBF
187///////////////////////////////////////////////////////////////////////////////
188
189///////////////////////////////////////////
190void hal_drivers_fbf_init( chdev_t  * fbf )
191{
192    uint32_t   impl = fbf->impl;
193
[679]194        assert( __FUNCTION__, (impl == IMPL_FBF_SCL), "undefined implementation" );
[647]195 
196    soclib_fbf_init( fbf );
197}
198
Note: See TracBrowser for help on using the repository browser.