Skip to content

Commit

Permalink
[board] update longanpi 4b
Browse files Browse the repository at this point in the history
  • Loading branch information
YuzukiTsuru committed Feb 4, 2024
1 parent 2a40c15 commit ad0c214
Show file tree
Hide file tree
Showing 8 changed files with 473 additions and 345 deletions.
31 changes: 12 additions & 19 deletions board/longanpi-4b/README.md
Original file line number Diff line number Diff line change
@@ -1,29 +1,22 @@
# SyterKit Common
# MYC-LT527核心板及开发板

## start.S
![image](https://github.com/YuzukiHD/SyterKit/assets/12003087/823c85ba-3f7a-4e8d-82ec-4c875b6e28a4)

This code snippet is an ARM assembly language program that includes initialization settings and exception handlers. Here's a breakdown of its functionalities:
Myir debuts the whole T527, octa-core A55 enabled edge computing
Full digital T527 processor, octa-core A55, efficient edge computing;

1. Initialization Settings: It sets registers and writes specific values to configure the processor's working mode, interrupt enable, etc.
Powerful multimedia functions: G57 GPU, 4K codec VPU, HiFi4 DSP, support 4~6 cameras;

2. Set Vector Table: It writes the address of the vector table to the Vector Base Address Register, which is used for handling exceptions and interrupts.
Support a variety of display interfaces: HDMI, DP, LVDS, MIPI-DSI and RGB parallel port, support 4K+1080P dual display;

3. Enable NEON/VFP Unit: It configures the processor to enable the NEON (Advanced SIMD) and VFP (Floating-Point) units.
Rich communication interface: 2*GE, 2*CAN, PCIE/USB3.0, 2*USB2.0, 10*UART, 30*PWM, 4*SPI, 9*I2C, etc.

4. Clear BSS Section: It zeroes out variables in the BSS section.
T527 is the real industrial grade -40℃~+85℃;

5. Disable Interrupts: It disables FIQ and IRQ interrupts and switches the processor to SVC32 mode.
Ultra-compact LGA 381pin package.

6. Set Timer Frequency: It sets the timer frequency to 24M.
Applications: high-performance industrial robots, display and control machines, vehicle terminals, edge smart boxes

7. Call the main Function: It jumps to the main function to execute the main logic.
## T527 Brief

## eabi_compat.c

This code snippet appears to be providing implementations for the functions `abort`, `raise`, and `__aeabi_unwind_cpp_pr0`. Here's a breakdown of their functionalities:

1. `void abort(void)`: This function creates an infinite loop, causing the program to hang indefinitely. It is typically used to indicate a critical error or unrecoverable condition in a program.

2. `int raise(int signum)`: This function is a placeholder and always returns 0. In standard C, this function is used to raise a signal and initiate the corresponding signal handler. However, in this implementation, it does nothing and simply returns 0.

3. `void __aeabi_unwind_cpp_pr0(void)`: This is a dummy function that serves as a placeholder to avoid linker complaints. Its purpose is to satisfy the linker when using C++ exceptions and unwinding, but it does not contain any actual functionality.
![image](https://github.com/YuzukiHD/SyterKit/assets/12003087/131a2982-c605-46f6-91cf-57d117b9a614)
74 changes: 73 additions & 1 deletion board/longanpi-4b/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ sdhci_t sdhci0 = {
.reg = (sdhci_reg_t *) SUNXI_SMHC0_BASE,
.voltage = MMC_VDD_27_36,
.width = MMC_BUS_WIDTH_4,
.clock = MMC_CLK_50M,
.clock = MMC_CLK_100M,
.removable = 0,
.isspi = FALSE,
.gpio_clk = {GPIO_PIN(GPIO_PORTF, 2), GPIO_PERIPH_MUX2},
Expand Down Expand Up @@ -122,4 +122,76 @@ void set_rpio_power_mode(void) {
} else {
printk(LOG_LEVEL_DEBUG, "PL gpio voltage : 3.3V \n");
}
}

int sunxi_nsi_init(void) {
/* IOMMU prio 3 */
writel(0x1, 0x02021418);
writel(0xf, 0x02021414);
/* DE prio 2 */
writel(0x1, 0x02021a18);
writel(0xa, 0x02021a14);
/* VE R prio 2 */
writel(0x1, 0x02021618);
writel(0xa, 0x02021614);
/* VE RW prio 2 */
writel(0x1, 0x02021818);
writel(0xa, 0x02021814);
/* ISP prio 2 */
writel(0x1, 0x02020c18);
writel(0xa, 0x02020c14);
/* CSI prio 2 */
writel(0x1, 0x02021c18);
writel(0xa, 0x02021c14);
/* NPU prio 2 */
writel(0x1, 0x02020a18);
writel(0xa, 0x02020a14);

/* close ra0 autogating */
writel(0x0, 0x02023c00);
/* close ta autogating */
writel(0x0, 0x02023e00);
/* close pcie autogating */
writel(0x0, 0x02020600);
return 0;
}

void enable_sram_a3() {
uint32_t reg_val;

/* De-assert PUBSRAM Clock and Gating */
reg_val = readl(RISCV_PUBSRAM_CFG_REG);
reg_val |= RISCV_PUBSRAM_RST;
reg_val |= RISCV_PUBSRAM_GATING;
writel(reg_val, RISCV_PUBSRAM_CFG_REG);

/* assert */
writel(0, RISCV_CFG_BGR_REG);
}

void show_chip() {
uint32_t chip_sid[4];
chip_sid[0] = read32(SUNXI_SID_SRAM_BASE + 0x0);
chip_sid[1] = read32(SUNXI_SID_SRAM_BASE + 0x4);
chip_sid[2] = read32(SUNXI_SID_SRAM_BASE + 0x8);
chip_sid[3] = read32(SUNXI_SID_SRAM_BASE + 0xc);

printk(LOG_LEVEL_INFO, "Chip SID = %08x%08x%08x%08x\n", chip_sid[0], chip_sid[1], chip_sid[2], chip_sid[3]);

uint32_t chip_markid_sid = chip_sid[0] & 0xffff;

switch (chip_markid_sid) {
case 0x5f30:
printk(LOG_LEVEL_INFO, "Chip type = T527M00X0DCH");
break;
case 0x5500:
printk(LOG_LEVEL_INFO, "Chip type = MR527M02X0D00");
break;
default:
printk(LOG_LEVEL_INFO, "Chip type = UNKNOW");
break;
}

uint32_t version = read32(SUNXI_SYSCTRL_BASE + 0x24) & 0x7;
printk(LOG_LEVEL_MUTE, "\tChip Version = %x \n", version);
}
35 changes: 34 additions & 1 deletion board/longanpi-4b/init_dram/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <types.h>
#include <stdint.h>

#include <log.h>

Expand All @@ -20,11 +20,44 @@ extern sunxi_i2c_t i2c_pmu;
extern void set_rpio_power_mode(void);
extern void rtc_set_vccio_det_spare(void);

static void set_axp323_pmu_fin_voltage(char* power_name, uint32_t voltage){
int set_vol = voltage;
int temp_vol, src_vol = pmu_axp1530_get_vol(&i2c_pmu, power_name);
if (src_vol > voltage) {
for (temp_vol = src_vol; temp_vol >= voltage; temp_vol -= 50) {
pmu_axp1530_set_vol(&i2c_pmu, power_name, temp_vol, 1);
}
} else if (src_vol < voltage) {
for (temp_vol = src_vol; temp_vol <= voltage; temp_vol += 50) {
pmu_axp1530_set_vol(&i2c_pmu, power_name, temp_vol, 1);
}
}
mdelay(30); /* Delay 300ms for pmu bootup */
}

static void set_axp717_pmu_fin_voltage(char* power_name, uint32_t voltage){
int set_vol = voltage;
int temp_vol, src_vol = pmu_axp2202_get_vol(&i2c_pmu, power_name);
if (src_vol > voltage) {
for (temp_vol = src_vol; temp_vol >= voltage; temp_vol -= 50) {
pmu_axp2202_set_vol(&i2c_pmu, power_name, temp_vol, 1);
}
} else if (src_vol < voltage) {
for (temp_vol = src_vol; temp_vol <= voltage; temp_vol += 50) {
pmu_axp2202_set_vol(&i2c_pmu, power_name, temp_vol, 1);
}
}
mdelay(30); /* Delay 300ms for pmu bootup */
}

int main(void) {
sunxi_serial_init(&uart_dbg);

show_banner();

printk(LOG_LEVEL_INFO, "Board: Myir Tech LT527X-E, Chip: Allwinner T527\n");
printk(LOG_LEVEL_INFO, "SoC: Arm Octa-Core Cortex-A55 v65 r2p0\n");

sunxi_clk_init();

sunxi_clk_dump();
Expand Down
Loading

0 comments on commit ad0c214

Please sign in to comment.