source: trunk/tools/bootloader_tsar/boot_mmc_driver.c @ 337

Last change on this file since 337 was 1, checked in by alain, 7 years ago

First import

File size: 2.3 KB
Line 
1///////////////////////////////////////////////////////////////////////////////////
2// File     : boot_mmc_driver.c
3// Date     : 18/01/2017
4// Author   : alain greiner
5// Copyright (c) UPMC-LIP6
6///////////////////////////////////////////////////////////////////////////////////
7
8#include <boot_mmc_driver.h>
9#include <boot_config.h>
10#include <boot_utils.h>
11
12#if !defined(SEG_MMC_BASE)
13# error: You must define SEG_MMC_BASE in the boot_config.h file
14#endif
15
16/****************************************************************************
17 * This static function set a new value to a MMC register.                  *
18 * @ cxy    : target cluster identifier.                                    *
19 * @ func   : accessed function in MMC (should be 0 for config).            *
20 * @ index  : target register index.                                        *
21 * @ val    : new value to be written.                                      *
22 ****************************************************************************/
23static void boot_mmc_set_register( uint32_t cxy, 
24                                   uint32_t func, 
25                                   uint32_t index, 
26                                   uint32_t value )
27{
28    uint32_t * ptr = (uint32_t *)SEG_MMC_BASE + MMC_REG( func , index );
29
30    boot_remote_sw( XPTR( cxy , ptr ) , value ); 
31
32} // end boot_mmc_set_register()
33
34
35///////////////////////////////////////
36int boot_mmc_inval( uint64_t buf_paddr,
37                    uint32_t buf_length )
38{
39    if ( buf_paddr & 0x3F )
40    {
41        boot_printf("\n[BOOT ERROR] in boot_mmc_inval() : paddr not 64 bytes aligned\n");
42        return -1;
43    }
44
45    // get cxy from paddr
46    uint32_t cxy = (uint32_t)(buf_paddr>>32);
47
48    // write MMC registers 
49    boot_mmc_set_register(cxy, MEMC_CONFIG, MEMC_ADDR_LO   , (uint32_t)buf_paddr );
50    boot_mmc_set_register(cxy, MEMC_CONFIG, MEMC_ADDR_HI   , (uint32_t)(buf_paddr>>32) );
51    boot_mmc_set_register(cxy, MEMC_CONFIG, MEMC_BUF_LENGTH, buf_length );
52    boot_mmc_set_register(cxy, MEMC_CONFIG, MEMC_CMD_TYPE  , MEMC_CMD_INVAL );
53
54    return 0;
55}
56
57// Local Variables:
58// tab-width: 4
59// c-basic-offset: 4
60// c-file-offsets:((innamespace . 0)(inline-open . 0))
61// indent-tabs-mode: nil
62// End:
63// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
64
Note: See TracBrowser for help on using the repository browser.