Skip to content

Commit

Permalink
add e907 rtos source tree
Browse files Browse the repository at this point in the history
  • Loading branch information
YuzukiTsuru committed Dec 26, 2022
1 parent f4adef9 commit 29bc60d
Show file tree
Hide file tree
Showing 2,047 changed files with 577,005 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Software/BSP/e907_rtos/rtos-hal/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
modules.builtin
modules.order
Module.symvers
.gitignore
.*
*.d
*.dis
*.sct
*.via
*.o.*
*.o
*.elf
*.map
*.log
!.gitignore
!.astylerc
filelist
*.swp
*.i
*.s
*.lst
tags
cscope.in.out
cscope.out
cscope.po.out
2 changes: 2 additions & 0 deletions Software/BSP/e907_rtos/rtos-hal/hal/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
obj-y += source/
obj-y += test/
1 change: 1 addition & 0 deletions Software/BSP/e907_rtos/rtos-hal/hal/include
236 changes: 236 additions & 0 deletions Software/BSP/e907_rtos/rtos-hal/hal/objects.mk

Large diffs are not rendered by default.

Empty file.
9 changes: 9 additions & 0 deletions Software/BSP/e907_rtos/rtos-hal/hal/source/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
obj-$(CONFIG_DRIVERS_CCMU) += ccmu/
obj-$(CONFIG_DRIVERS_UART) += uart/
obj-$(CONFIG_DRIVERS_RTC) += rtc/
obj-$(CONFIG_DRIVERS_GPIO) += gpio/
obj-$(CONFIG_DRIVERS_DMA) += dma/
obj-$(CONFIG_DRIVERS_TWI) += twi/
obj-$(CONFIG_DRIVERS_PWM) += pwm/
obj-$(CONFIG_DRIVERS_MSGBOX) += msgbox/
obj-y += common/
16 changes: 16 additions & 0 deletions Software/BSP/e907_rtos/rtos-hal/hal/source/ccmu/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
menu "CCMU Devices"

config DRIVERS_CCMU
bool "enable ccmu driver"
default y

config DRIVERS_SUNXI_CLK
bool "enable sunxi ccmu driver"
depends on DRIVERS_CCMU
default n

config HAL_TEST_CLK
bool "enable sunxi ccmu hal APIs test command"
depends on DRIVERS_SUNXI_CLK
default n
endmenu
6 changes: 6 additions & 0 deletions Software/BSP/e907_rtos/rtos-hal/hal/source/ccmu/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ccflags-y += -I$(obj)/ \
-I$(srctree)/include/melis/kernel/drivers

obj-y += hal_clk.o hal_reset.o

obj-$(CONFIG_DRIVERS_SUNXI_CLK) += sunxi/
111 changes: 111 additions & 0 deletions Software/BSP/e907_rtos/rtos-hal/hal/source/ccmu/common_ccmu.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/*
* Copyright (c) 2019-2025 Allwinner Technology Co., Ltd. ALL rights reserved.
*
* Allwinner is a trademark of Allwinner Technology Co.,Ltd., registered in
* the the People's Republic of China and other countries.
* All Allwinner Technology Co.,Ltd. trademarks are used with permission.
*
* DISCLAIMER
* THIRD PARTY LICENCES MAY BE REQUIRED TO IMPLEMENT THE SOLUTION/PRODUCT.
* IF YOU NEED TO INTEGRATE THIRD PARTY’S TECHNOLOGY (SONY, DTS, DOLBY, AVS OR MPEGLA, ETC.)
* IN ALLWINNERS’SDK OR PRODUCTS, YOU SHALL BE SOLELY RESPONSIBLE TO OBTAIN
* ALL APPROPRIATELY REQUIRED THIRD PARTY LICENCES.
* ALLWINNER SHALL HAVE NO WARRANTY, INDEMNITY OR OTHER OBLIGATIONS WITH RESPECT TO MATTERS
* COVERED UNDER ANY REQUIRED THIRD PARTY LICENSE.
* YOU ARE SOLELY RESPONSIBLE FOR YOUR USAGE OF THIRD PARTY’S TECHNOLOGY.
*
*
* THIS SOFTWARE IS PROVIDED BY ALLWINNER"AS IS" AND TO THE MAXIMUM EXTENT
* PERMITTED BY LAW, ALLWINNER EXPRESSLY DISCLAIMS ALL WARRANTIES OF ANY KIND,
* WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING WITHOUT LIMITATION REGARDING
* THE TITLE, NON-INFRINGEMENT, ACCURACY, CONDITION, COMPLETENESS, PERFORMANCE
* OR MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
* IN NO EVENT SHALL ALLWINNER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS, OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef __COMMON_CCMU_H__
#define __COMMON_CCMU_H__

#if defined(CCMU_DBG_LEAVE_TINY) || defined(CCMU_DBG_LEAVE_HIGH)
#define CCMU_DBG(fmt,args...) printf("[CCMU:dbg..] %-*s:%d "fmt ,30, __func__, __LINE__, ##args)
#define CCMU_ERR(fmt,args...) printf("[CCMU:err**] %-*s:%d "fmt ,30, __func__, __LINE__, ##args)
#else
#define CCMU_DBG(fmt,args...) do{} while(0)
#define CCMU_ERR(fmt,args...) do{} while(0)
#endif

#if defined(CCMU_DBG_LEAVE_HIGH)
#define CCMU_TRACE() printf("[CCMU:trace] %-*s:%d \n",30, __func__, __LINE__)
#define CCMU_TRACE_CLK(tpye, clk) printf("CCMU:trace %s:%d CLK "#tpye" id %d\n",__func__, __LINE__, clk)
#else
#define CCMU_TRACE() do{} while(0)
#define CCMU_TRACE_CLK(clk, rate) do{} while(0)
#endif

typedef unsigned int hal_clk_id_t;

#if !defined(CONFIG_DRIVERS_SUNXI_CLK) && !defined(CONFIG_DRIVERS_SUNXI_CCU)
typedef hal_clk_id_t hal_clk_t;
#endif

/************************************************************************************************
* Enum hal_clk_status_t
* @Description: This enum defines the return status of Clock APIs. User should check the return value after calling the APIs
*************************************************************************************************/
typedef enum
{

HAL_CLK_STATUS_DISABLED = -1,
HAL_CLK_STATUS_ENABLED = 0,
HAL_CLK_STATUS_ERROR_CLK_FACTOR_REFUSED = -11,
HAL_CLK_STATUS_ERROR_CLK_NEED_DISABLED = -10,
HAL_CLK_STATUS_ERROR_CLK_PARENT_DISABLED = -9,
HAL_CLK_STATUS_ERROR_CLK_ENABLED_FAILED = -8,
HAL_CLK_STATUS_ERROR_CLK_ROUND_FAILED = -7,
HAL_CLK_STATUS_ERROR_CLK_SET_RATE_REFUSED = -6,
HAL_CLK_STATUS_ERROR_CLK_NOT_FOUND = -5,
HAL_CLK_STATUS_ERROT_CLK_UNDEFINED = -4,
HAL_CLK_STATUS_UNINITIALIZED = -3, /**< Uninitialized clock driver. */
HAL_CLK_STATUS_INVALID_PARAMETER = -2, /**< Invalid parameter. */
HAL_CLK_STATUS_ERROR = -1, /**< Unknown error. */
HAL_CLK_STATUS_OK = 0, /**< Successful. */
} hal_clk_status_t;

#if defined(CONFIG_DRIVERS_SUNXI_CLK)

#define HAL_SUNXI_CCU (0)

#include "sunxi/clk.h"
typedef hal_clk_id_t hal_clk_t;

#endif

#if defined(CONFIG_DRIVERS_SUNXI_CCU)
/************************************************************************************************
* Enum hal_clk_type_t
* @Description: This enum defines the type of Clock
*************************************************************************************************/
typedef enum
{
HAL_SUNXI_FIXED_CCU = 0,
HAL_SUNXI_RTC_CCU,
HAL_SUNXI_CCU,
HAL_SUNXI_AON_CCU,
HAL_SUNXI_R_CCU,
HAL_SUNXI_CCU_NUMBER,
} hal_clk_type_t;

#include "sunxi-ng/clk.h"
typedef struct clk* hal_clk_t;

#endif

#endif /* __COMMON_CCMU_H__ */

129 changes: 129 additions & 0 deletions Software/BSP/e907_rtos/rtos-hal/hal/source/ccmu/hal_clk.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/* Copyright (c) 2019-2025 Allwinner Technology Co., Ltd. ALL rights reserved.
*
* Allwinner is a trademark of Allwinner Technology Co.,Ltd., registered in
*the the People's Republic of China and other countries.
* All Allwinner Technology Co.,Ltd. trademarks are used with permission.
*
* DISCLAIMER
* THIRD PARTY LICENCES MAY BE REQUIRED TO IMPLEMENT THE SOLUTION/PRODUCT.
* IF YOU NEED TO INTEGRATE THIRD PARTY’S TECHNOLOGY (SONY, DTS, DOLBY, AVS OR MPEGLA, ETC.)
* IN ALLWINNERS’SDK OR PRODUCTS, YOU SHALL BE SOLELY RESPONSIBLE TO OBTAIN
* ALL APPROPRIATELY REQUIRED THIRD PARTY LICENCES.
* ALLWINNER SHALL HAVE NO WARRANTY, INDEMNITY OR OTHER OBLIGATIONS WITH RESPECT TO MATTERS
* COVERED UNDER ANY REQUIRED THIRD PARTY LICENSE.
* YOU ARE SOLELY RESPONSIBLE FOR YOUR USAGE OF THIRD PARTY’S TECHNOLOGY.
*
*
* THIS SOFTWARE IS PROVIDED BY ALLWINNER"AS IS" AND TO THE MAXIMUM EXTENT
* PERMITTED BY LAW, ALLWINNER EXPRESSLY DISCLAIMS ALL WARRANTIES OF ANY KIND,
* WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING WITHOUT LIMITATION REGARDING
* THE TITLE, NON-INFRINGEMENT, ACCURACY, CONDITION, COMPLETENESS, PERFORMANCE
* OR MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
* IN NO EVENT SHALL ALLWINNER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS, OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include <hal_clk.h>

void hal_clock_init(void)
{
CCMU_TRACE();
clk_init();
}

hal_clk_t hal_clock_get(hal_clk_type_t type, hal_clk_id_t id)
{
CCMU_TRACE();
return clk_get(type, id);
}

hal_clk_status_t hal_clock_put(hal_clk_t clk)
{
CCMU_TRACE();
return clk_put(clk);
}

hal_clk_status_t hal_clk_set_parent(hal_clk_t clk, hal_clk_t parent)
{
CCMU_TRACE();
return clk_set_parent(clk, parent);
}

hal_clk_t hal_clk_get_parent(hal_clk_t clk)
{
CCMU_TRACE();
return clk_get_parent(clk);
}

u32 hal_clk_recalc_rate(hal_clk_t clk)
{
u32 rate = 0;

CCMU_TRACE();
clk_recalc_rate(clk, &rate);

return rate;
}

u32 hal_clk_round_rate(hal_clk_t clk, u32 rate)
{
u32 round_rate = 0;

CCMU_TRACE();
clk_round_rate(clk, rate, &round_rate);

return round_rate;
}

u32 hal_clk_get_rate(hal_clk_t clk)
{
u32 rate;

CCMU_TRACE();
clk_get_rate(clk, &rate);

return rate;
}

hal_clk_status_t hal_clk_set_rate(hal_clk_t clk, u32 rate)
{
hal_clk_status_t ret;

CCMU_TRACE();
ret = clk_set_rate(clk, rate);

return ret;
}

hal_clk_status_t hal_clock_is_enabled(hal_clk_t clk)
{
CCMU_TRACE();
return clk_is_enabled(clk);
}

hal_clk_status_t hal_clock_enable(hal_clk_t clk)
{
hal_clk_status_t ret;

CCMU_TRACE();
ret = clk_prepare_enable(clk);

return ret;
}


hal_clk_status_t hal_clock_disable(hal_clk_t clk)
{
hal_clk_status_t ret;

CCMU_TRACE();
ret = clk_disable_unprepare(clk);

return ret;
}
Loading

0 comments on commit 29bc60d

Please sign in to comment.