Skip to content
Snippets Groups Projects
Commit ece412ae authored by Gabriel Fernandez's avatar Gabriel Fernandez Committed by Sebastien Pasdeloup
Browse files

clk: add clk interface with clk_ops register


Introduce a minimal clock framework.

Change-Id: I5119a2aeaf103ceaae7a60d9e423caf0c148d794
Signed-off-by: default avatarLudovic Barre <ludovic.barre@st.com>
Signed-off-by: default avatarGabriel Fernandez <gabriel.fernandez@st.com>
Reviewed-on: https://gerrit.st.com/c/mpu/oe/st/tf-a/+/182345


Reviewed-by: default avatarCITOOLS <smet-aci-reviews@lists.codex.cro.st.com>
Reviewed-by: default avatarYann GAUTIER <yann.gautier@st.com>
Tested-by: default avatarYann GAUTIER <yann.gautier@st.com>
parent 775cf635
No related branches found
No related tags found
No related merge requests found
/*
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
* Author(s): Ludovic Barre, <ludovic.barre@st.com> for STMicroelectronics.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <assert.h>
#include <errno.h>
#include <stdbool.h>
#include <drivers/clk.h>
static const clk_ops_t *ops;
int clk_enable(unsigned long id)
{
assert((ops != NULL) && (ops->enable != NULL));
return ops->enable(id);
}
void clk_disable(unsigned long id)
{
assert((ops != NULL) && (ops->disable != NULL));
ops->disable(id);
}
unsigned long clk_get_rate(unsigned long id)
{
assert((ops != NULL) && (ops->get_rate != NULL));
return ops->get_rate(id);
}
int clk_get_parent(unsigned long id)
{
assert((ops != NULL) && (ops->get_parent != NULL));
return ops->get_parent(id);
}
bool clk_is_enabled(unsigned long id)
{
assert((ops != NULL) && (ops->is_enabled != NULL));
return ops->is_enabled(id);
}
/*
* Initialize the clk. The fields in the provided clk
* ops pointer must be valid.
*/
void clk_register(const clk_ops_t *ops_ptr)
{
assert((ops_ptr != NULL) && (ops_ptr->enable != NULL) &&
(ops_ptr->disable != NULL) &&
(ops_ptr->get_rate != NULL) &&
(ops_ptr->get_parent != NULL) &&
(ops_ptr->is_enabled != NULL));
ops = ops_ptr;
}
/*
* Copyright (c) 2020, STMicroelectronics - All Rights Reserved
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef CLK_H
#define CLK_H
#include <stdbool.h>
typedef struct clk_ops {
int (*enable)(unsigned long id);
void (*disable)(unsigned long id);
unsigned long (*get_rate)(unsigned long id);
int (*get_parent)(unsigned long id);
bool (*is_enabled)(unsigned long id);
} clk_ops_t;
int clk_enable(unsigned long id);
void clk_disable(unsigned long id);
unsigned long clk_get_rate(unsigned long id);
bool clk_is_enabled(unsigned long id);
int clk_get_parent(unsigned long id);
void clk_register(const clk_ops_t *ops);
#endif /* CLK_H */
......@@ -200,6 +200,7 @@ PLAT_BL_COMMON_SOURCES += ${XLAT_TABLES_LIB_SRCS}
PLAT_BL_COMMON_SOURCES += lib/cpus/aarch32/cortex_a7.S
PLAT_BL_COMMON_SOURCES += drivers/arm/tzc/tzc400.c \
drivers/clk/clk.c \
drivers/delay_timer/delay_timer.c \
drivers/delay_timer/generic_delay_timer.c \
drivers/st/bsec/bsec2.c \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment