Skip to content

Commit

Permalink
Merge pull request #157 from YuzukiHD/dev
Browse files Browse the repository at this point in the history
v0.4.0.2
  • Loading branch information
SamulKyull authored Jan 10, 2025
2 parents 645a113 + 8609e1d commit d31a5ed
Show file tree
Hide file tree
Showing 61 changed files with 1,812 additions and 84 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ include_directories(
include/drivers/chips
include/drivers/reg
include/drivers/usb
include/drivers/ufs
include/drivers/mtd
include/drivers/intc
include/lib/fatfs
Expand Down
4 changes: 2 additions & 2 deletions board/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ if(CONFIG_BOARD_AVAOTA-A1)
add_subdirectory(avaota-a1)
endif()

if(CONFIG_BOARD_AVAOTA-CAM)
add_subdirectory(avaota-cam)
if(CONFIG_BOARD_AVAOTA-F1)
add_subdirectory(avaota-f1)
endif()

if(CONFIG_BOARD_AVAOTA-NAS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ set(APP_COMMON_SOURCE
${CMAKE_CURRENT_SOURCE_DIR}/head.c
)

add_subdirectory(hello_world)
add_subdirectory(app)
2 changes: 1 addition & 1 deletion board/avaota-cam/README.md → board/avaota-f1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

| Name | Function | Path |
| ----------- | ------------------------------------------------------------ | ----------------- |
| hello world | Minimal program example, prints Hello World | `app/hello_world` |
| hello world | Minimal program example, prints Hello World | `app/app` |
| init dram | Initializes the serial port and DRAM | `app/init_dram` |
| load hifi4 | Start and initialize the tf card through the C906 CPU, read the hifi4 dsp firmware from it, and load it for execution | `app/load_hifi4` |
| syter boot | Bootstrapping function that replaces U-Boot, enabling fast system startup for Linux | `app/syter_boot` |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# SPDX-License-Identifier: GPL-2.0+

add_syterkit_app(helloworld
add_syterkit_app(app
main.c
)
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <cli_termesc.h>

extern sunxi_serial_t uart_dbg;
extern sunxi_serial_t uart_cpu_dbg;
extern sunxi_serial_t uart_card;
extern dram_para_t dram_para;
extern sunxi_dma_t sunxi_dma;
Expand Down Expand Up @@ -125,6 +126,8 @@ int main(void) {

sunxi_serial_init(&uart_dbg);

sunxi_serial_init(&uart_cpu_dbg);

sunxi_serial_init(&uart_card);

show_banner();
Expand Down
20 changes: 20 additions & 0 deletions board/avaota-cam/board.c → board/avaota-f1/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,26 @@ sunxi_serial_t uart_dbg = {
},
};

sunxi_serial_t uart_cpu_dbg = {
.base = SUNXI_UART0_BASE,
.id = 0,
.baud_rate = UART_BAUDRATE_115200,
.dlen = UART_DLEN_8,
.stop = UART_STOP_BIT_0,
.parity = UART_PARITY_NO,
.gpio_pin = {
.gpio_tx = {GPIO_PIN(GPIO_PORTD, 22), GPIO_PERIPH_MUX3},
.gpio_rx = {GPIO_PIN(GPIO_PORTD, 23), GPIO_PERIPH_MUX3},
},
.uart_clk = {
.gate_reg_base = SUNXI_CCU_APP_BASE + BUS_CLK_GATING0_REG,
.gate_reg_offset = BUS_CLK_GATING0_REG_UART0_PCLK_EN_OFFSET,
.rst_reg_base = SUNXI_CCU_APP_BASE + BUS_Reset0_REG,
.rst_reg_offset = BUS_Reset0_REG_PRESETN_UART0_SW_OFFSET,
.parent_clk = 192000000,
},
};

sunxi_serial_t uart_card = {
.base = SUNXI_UART0_BASE,
.id = 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
Lst/
Obj/
cdkws.mk
avaota_cam.modify.bat
avaota_cam.mk
avaota_f1.modify.bat
avaota_f1.mk
.cache
.cdk
377 changes: 377 additions & 0 deletions board/avaota-f1/cdk/avaota_cam.mk

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions board/avaota-f1/cdk/avaota_cam.modify.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off
SET PATH=%Systemroot%\System32;%PATH%
forfiles.exe -P "%1" -M %2 -C "cmd /c echo %1/%2 is modified at: @fdate @ftime" | findstr modified
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<Project Name="avaota_cam" Version="1" Language="C" Type="Solution Package">
<Project Name="avaota_f1" Version="1" Language="C" Type="Solution Package">
<Description/>
<Dependencies Name="Debug"/>
<MergedToYaml>yes</MergedToYaml>
<Dependencies Name="BuildSet"/>
<VendorInfo>
<VendorName>new_soc_project_c_solution_e907f</VendorName>
<VendorName>Avaota SBC Avaota F1</VendorName>
</VendorInfo>
<ToolsConfig>
<Compiler>
Expand Down Expand Up @@ -524,7 +524,7 @@
</VirtualDirectory>
</VirtualDirectory>
<VirtualDirectory Name="app">
<File Name="../hello_world/main.c">
<File Name="../app/main.c">
<FileOption/>
</File>
</VirtualDirectory>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<CDK_Workspace Name="Avaota CAM" Database="LanguageSever" DoubleClick="Yes">
<CDK_Workspace Name="Avaota F1" Database="LanguageSever" DoubleClick="Yes">
<DefaultPackPath>$(CDKWS)\__workspace_pack__</DefaultPackPath>
<Project Name="avaota_cam" Path="avaota_cam.cdkproj" RootPath="" Active="Yes"/>
<Project Name="avaota_f1" Path="avaota_f1.cdkproj" RootPath="" Active="Yes"/>
<BuildMatrix>
<WorkspaceConfiguration Name="Debug" Selected="yes">
<Environment/>
<Project Name="avaota_cam" ConfigName="BuildSet"/>
<Project Name="avaota_f1" ConfigName="BuildSet"/>
</WorkspaceConfiguration>
</BuildMatrix>
</CDK_Workspace>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion cmake/board/avaota-cam.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ set(CONFIG_ARCH_RISCV32 True)
set(CONFIG_ARCH_RISCV32_CORE_E907 True)
set(CONFIG_CHIP_SUN300IW1 True)
set(CONFIG_CHIP_MMC_V2 True)
set(CONFIG_BOARD_AVAOTA-CAM True)
set(CONFIG_BOARD_AVAOTA-F1 True)

add_definitions(-DCONFIG_CHIP_SUN300IW1)
add_definitions(-DCONFIG_CHIP_MMC_V2)
Expand Down
1 change: 1 addition & 0 deletions cmake/board/avaota-nas.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ set(CONFIG_CHIP_DCACHE True)
set(CONFIG_CHIP_MMC_V2 True)
set(CONFIG_CHIP_GPIO_V3 True)
set(CONFIG_BOARD_AVAOTA-NAS True)
set(CONFIG_CHIP_UFS True)

add_definitions(-DCONFIG_CHIP_SUN60IW2)
add_definitions(-DCONFIG_CHIP_DCACHE)
Expand Down
80 changes: 80 additions & 0 deletions include/arch/arm32/byteorder.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/* SPDX-License-Identifier: GPL-2.0+ */

#ifndef __BYTEORDER_H__
#define __BYTEORDER_H__

#ifdef __cplusplus
extern "C" {
#endif

#include <types.h>

static inline u16_t __swab16(u16_t x) {
return ((x << 8) | (x >> 8));
}

static inline u32_t __swab32(u32_t x) {
return ((x << 24) | (x >> 24) |
((x & (u32_t) 0x0000ff00UL) << 8) |
((x & (u32_t) 0x00ff0000UL) >> 8));
}

static inline u64_t __swab64(u64_t x) {
return ((x << 56) | (x >> 56) |
((x & (u64_t) 0x000000000000ff00ULL) << 40) |
((x & (u64_t) 0x0000000000ff0000ULL) << 24) |
((x & (u64_t) 0x00000000ff000000ULL) << 8) |
((x & (u64_t) 0x000000ff00000000ULL) >> 8) |
((x & (u64_t) 0x0000ff0000000000ULL) >> 24) |
((x & (u64_t) 0x00ff000000000000ULL) >> 40));
}

/*
* swap bytes bizarrely.
* swahw32 - swap 16-bit half-words in a 32-bit word
*/
static inline u32_t __swahw32(u32_t x) {
return (((x & (u32_t) 0x0000ffffUL) << 16) | ((x & (u32_t) 0xffff0000UL) >> 16));
}

/*
* swap bytes bizarrely.
* swahb32 - swap 8-bit halves of each 16-bit half-word in a 32-bit word
*/
static inline u32_t __swahb32(u32_t x) {
return (((x & (u32_t) 0x00ff00ffUL) << 8) | ((x & (u32_t) 0xff00ff00UL) >> 8));
}

#if (BYTE_ORDER == BIG_ENDIAN)
#define cpu_to_le64(x) (__swab64((u64_t) (x)))
#define le64_to_cpu(x) (__swab64((u64_t) (x)))
#define cpu_to_le32(x) (__swab32((u32_t) (x)))
#define le32_to_cpu(x) (__swab32((u32_t) (x)))
#define cpu_to_le16(x) (__swab16((u16_t) (x)))
#define le16_to_cpu(x) (__swab16((u16_t) (x)))
#define cpu_to_be64(x) ((u64_t) (x))
#define be64_to_cpu(x) ((u64_t) (x))
#define cpu_to_be32(x) ((u32_t) (x))
#define be32_to_cpu(x) ((u32_t) (x))
#define cpu_to_be16(x) ((u16_t) (x))
#define be16_to_cpu(x) ((u16_t) (x))
#else
#define cpu_to_le64(x) ((u64_t) (x))
#define le64_to_cpu(x) ((u64_t) (x))
#define cpu_to_le32(x) ((u32_t) (x))
#define le32_to_cpu(x) ((u32_t) (x))
#define cpu_to_le16(x) ((u16_t) (x))
#define le16_to_cpu(x) ((u16_t) (x))
#define cpu_to_be64(x) (__swab64((u64_t) (x)))
#define be64_to_cpu(x) (__swab64((u64_t) (x)))
#define cpu_to_be32(x) (__swab32((u32_t) (x)))
#define be32_to_cpu(x) (__swab32((u32_t) (x)))
#define cpu_to_be16(x) (__swab16((u16_t) (x)))
#define be16_to_cpu(x) (__swab16((u16_t) (x)))
#endif

#ifdef __cplusplus
}
#endif

#endif /* __BYTEORDER_H__ */
29 changes: 29 additions & 0 deletions include/arch/arm32/endian.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* SPDX-License-Identifier: GPL-2.0+ */

#ifndef __ENDIAN_H__
#define __ENDIAN_H__

#ifdef __cplusplus
extern "C" {
#endif

#define LITTLE_ENDIAN (0x1234)
#define BIG_ENDIAN (0x4321)

#if (!defined(__LITTLE_ENDIAN) && !defined(__BIG_ENDIAN))
#define __LITTLE_ENDIAN
#endif

#if defined(__LITTLE_ENDIAN)
#define BYTE_ORDER LITTLE_ENDIAN
#elif defined(__BIG_ENDIAN)
#define BYTE_ORDER BIG_ENDIAN
#else
#error "Unknown byte order!"
#endif

#ifdef __cplusplus
}
#endif

#endif /* __ENDIAN_H__ */
103 changes: 34 additions & 69 deletions include/drivers/pmu/axp.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,36 +69,45 @@ int axp_set_vol(sunxi_i2c_t *i2c_dev, char *name, int set_vol, int onoff, axp_co
*/
int axp_get_vol(sunxi_i2c_t *i2c_dev, char *name, axp_contrl_info *axp_ctrl_tbl, uint8_t axp_ctrl_tbl_size, uint8_t axp_addr);

/* AXP1530 */
/* define AXP pmu */

/**
* Initialize the AXP1530 PMU.
* @brief Macro to define PMU functions for a specific AXP PMU chip.
*
* @param i2c_dev Pointer to the I2C device structure.
* @return 0 if successful, -1 if an error occurred.
*/
int pmu_axp1530_init(sunxi_i2c_t *i2c_dev);

/**
* Get the voltage value of a specific power domain from the AXP1530 PMU.
*
* @param i2c_dev Pointer to the I2C device structure.
* @param name Name of the power domain.
* @return The voltage value of the power domain, or -1 if an error occurred.
*/
int pmu_axp1530_get_vol(sunxi_i2c_t *i2c_dev, char *name);

/**
* Set the voltage value of a specific power domain on the AXP1530 PMU.
* This macro generates a set of function prototypes for controlling and
* interacting with a specified AXP Power Management Unit (PMU) chip.
*
* The generated functions are:
* - `pmu_<name>_init`: Initializes the PMU for the specified device.
* - `pmu_<name>_get_vol`: Retrieves the voltage of a specified power rail.
* - `pmu_<name>_set_vol`: Sets the voltage of a specified power rail.
* - `pmu_<name>_dump`: Dumps the internal registers and status of the PMU.
*
* @param i2c_dev Pointer to the I2C device structure.
* @param name Name of the power domain.
* @param set_vol Voltage value to set.
* @param onoff On/Off switch for the power domain (1 - On, 0 - Off).
* @return 0 if successful, -1 if an error occurred.
* Example usage:
* ```c
* DEFINE_AXP_PMU(axp2202);
* ```
* This will generate the following function prototypes:
* - `int pmu_axp2202_init(sunxi_i2c_t *i2c_dev);`
* - `int pmu_axp2202_get_vol(sunxi_i2c_t *i2c_dev, char *name);`
* - `int pmu_axp2202_set_vol(sunxi_i2c_t *i2c_dev, char *name, int set_vol, int onoff);`
* - `void pmu_axp2202_dump(sunxi_i2c_t *i2c_dev);`
*
* @param name The name of the PMU chip (e.g., axp2202, axp221, etc.).
*/
int pmu_axp1530_set_vol(sunxi_i2c_t *i2c_dev, char *name, int set_vol, int onoff);

#define DEFINE_AXP_PMU(name) \
int pmu_##name##_init(sunxi_i2c_t *i2c_dev); \
int pmu_##name##_get_vol(sunxi_i2c_t *i2c_dev, char *name); \
int pmu_##name##_set_vol(sunxi_i2c_t *i2c_dev, char *name, int set_vol, int onoff); \
void pmu_##name##_dump(sunxi_i2c_t *i2c_dev);

/* AXP PMU defines */
DEFINE_AXP_PMU(axp1530);
DEFINE_AXP_PMU(axp2202);
DEFINE_AXP_PMU(axp2101);
DEFINE_AXP_PMU(axp8191);

/* Extra */
/**
* Set the dual phase function on the AXP1530 PMU.
*
Expand All @@ -107,50 +116,6 @@ int pmu_axp1530_set_vol(sunxi_i2c_t *i2c_dev, char *name, int set_vol, int onoff
*/
int pmu_axp1530_set_dual_phase(sunxi_i2c_t *i2c_dev);

/**
* Dump the register values of the AXP1530 PMU.
*
* @param i2c_dev Pointer to the I2C device structure.
*/
void pmu_axp1530_dump(sunxi_i2c_t *i2c_dev);

/* AXP2202 */

/**
* Initialize the AXP2202 PMU.
*
* @param i2c_dev Pointer to the I2C device structure.
* @return 0 if successful, -1 if an error occurred.
*/
int pmu_axp2202_init(sunxi_i2c_t *i2c_dev);

/**
* Get the voltage value of a specific power domain from the AXP2202 PMU.
*
* @param i2c_dev Pointer to the I2C device structure.
* @param name Name of the power domain.
* @return The voltage value of the power domain, or -1 if an error occurred.
*/
int pmu_axp2202_get_vol(sunxi_i2c_t *i2c_dev, char *name);

/**
* Set the voltage value of a specific power domain on the AXP2202 PMU.
*
* @param i2c_dev Pointer to the I2C device structure.
* @param name Name of the power domain.
* @param set_vol Voltage value to set.
* @param onoff On/Off switch for the power domain (1 - On, 0 - Off).
* @return 0 if successful, -1 if an error occurred.
*/
int pmu_axp2202_set_vol(sunxi_i2c_t *i2c_dev, char *name, int set_vol, int onoff);

/**
* Dump the register values of the AXP2202 PMU.
*
* @param i2c_dev Pointer to the I2C device structure.
*/
void pmu_axp2202_dump(sunxi_i2c_t *i2c_dev);

#ifdef __cplusplus
}
#endif// __cplusplus
Expand Down
Loading

0 comments on commit d31a5ed

Please sign in to comment.