pinebuds/platform/hal/hal_memsc.c

43 lines
1.1 KiB
C
Raw Permalink Normal View History

2022-08-15 04:20:27 -05:00
/***************************************************************************
*
* Copyright 2015-2019 BES.
* All rights reserved. All unpublished rights reserved.
*
* No part of this work may be used or reproduced in any form or by any
* means, or stored in a database or retrieval system, without prior written
* permission of BES.
*
* Use of this work is governed by a license granted by BES.
* This work contains confidential and proprietary information of
* BES. which is protected by copyright, trade secret,
* trademark and other intellectual property rights.
*
****************************************************************************/
#include "hal_memsc.h"
#include "hal_cmu.h"
#include "plat_addr_map.h"
2022-08-15 04:20:27 -05:00
int hal_memsc_lock(enum HAL_MEMSC_ID_T id) {
if (id >= HAL_MEMSC_ID_QTY) {
return 0;
}
2022-08-15 04:20:27 -05:00
return (hal_cmu_get_memsc_addr())[id];
2022-08-15 04:20:27 -05:00
}
void hal_memsc_unlock(enum HAL_MEMSC_ID_T id) {
if (id >= HAL_MEMSC_ID_QTY) {
return;
}
2022-08-15 04:20:27 -05:00
(hal_cmu_get_memsc_addr())[id] = 1;
2022-08-15 04:20:27 -05:00
}
bool hal_memsc_avail(enum HAL_MEMSC_ID_T id) {
if (id >= HAL_MEMSC_ID_QTY) {
return false;
}
2022-08-15 04:20:27 -05:00
return !!((hal_cmu_get_memsc_addr())[4] & (1 << id));
2022-08-15 04:20:27 -05:00
}