mirror of
https://gitee.com/Vancouver2017/luban-lite.git
synced 2025-12-16 09:08:56 +00:00
V1.0.6
This commit is contained in:
@@ -6,7 +6,8 @@ cwd = GetCurrentDir()
|
||||
src = Glob('*.c')
|
||||
src += Glob('partition/*.c')
|
||||
src += Glob('private_param/*.c')
|
||||
src += Glob('crc32/*.c')
|
||||
if not GetDepend('LPKG_USING_ZLIB'):
|
||||
src += Glob('crc32/*.c')
|
||||
src += Glob('utils/*.c')
|
||||
CPPPATH = [cwd + '/include', ]
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Artinchip Technology Co., Ltd
|
||||
* Copyright (c) 2022-2024, ArtInChip Technology Co., Ltd
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -19,7 +19,7 @@ extern "C" {
|
||||
/* Luban-Lite version information */
|
||||
#define LL_VERSION 1 /**< major version number */
|
||||
#define LL_SUBVERSION 0 /**< minor version number */
|
||||
#define LL_REVISION 5 /**< revise version number */
|
||||
#define LL_REVISION 6 /**< revise version number */
|
||||
|
||||
typedef __signed__ char s8;
|
||||
typedef unsigned char u8;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023, ArtInChip Technology Co., Ltd
|
||||
* Copyright (c) 2023-2024, ArtInChip Technology Co., Ltd
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -72,7 +72,6 @@ enum aic_reboot_reason {
|
||||
|
||||
void aic_set_reboot_reason(enum aic_reboot_reason reason);
|
||||
enum aic_reboot_reason aic_get_reboot_reason(void);
|
||||
void aic_clr_reboot_reason_rtc(void);
|
||||
void aic_clr_reboot_reason(void);
|
||||
void aic_show_gtc_time(char *tag, u32 val);
|
||||
void aic_show_startup_time(void);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Artinchip Technology Co., Ltd
|
||||
* Copyright (c) 2023-2024, ArtInChip Technology Co., Ltd
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@@ -12,8 +12,12 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
void hexdump(unsigned char *buf, unsigned long len, int groupsize);
|
||||
void hexdump_msg(char *msg, unsigned char *buf, unsigned long len, int groupsize);
|
||||
|
||||
void show_speed(char *msg, unsigned long len, unsigned long us);
|
||||
#ifdef LPKG_USING_FDTLIB
|
||||
int pinmux_fdt_parse(void);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
@@ -342,7 +342,7 @@ struct aic_partition *aic_disk_get_mbr_parts(struct blk_desc *dev_desc)
|
||||
}
|
||||
memset(n, 0, sizeof(*n));
|
||||
n->start = pp->start_sect * dev_desc->blksz;
|
||||
n->size = pp->nr_sects * dev_desc->blksz;
|
||||
n->size = (u64)pp->nr_sects * dev_desc->blksz;
|
||||
|
||||
if (parts == NULL) {
|
||||
parts = n;
|
||||
|
||||
@@ -112,3 +112,20 @@ void hexdump(unsigned char *buf, unsigned long len, int groupsize)
|
||||
hex_dump_1(buf, len);
|
||||
}
|
||||
}
|
||||
|
||||
void hexdump_msg(char *msg, unsigned char *buf, unsigned long len, int groupsize)
|
||||
{
|
||||
printf("%s\n", msg);
|
||||
|
||||
if (groupsize <= 1) {
|
||||
hex_dump_1(buf, len);
|
||||
} else if (groupsize <= 2) {
|
||||
hex_dump_2(buf, len);
|
||||
} else if (groupsize <= 4) {
|
||||
hex_dump_4(buf, len);
|
||||
} else if (groupsize <= 8) {
|
||||
hex_dump_8(buf, len);
|
||||
} else {
|
||||
hex_dump_1(buf, len);
|
||||
}
|
||||
}
|
||||
|
||||
164
bsp/common/utils/pinmux_fdt.c
Normal file
164
bsp/common/utils/pinmux_fdt.c
Normal file
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
* Copyright (c) 2023-2024, ArtInChip Technology Co., Ltd
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Authors: weijie.ding <weijie.ding@artinchip.com>
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <aic_utils.h>
|
||||
#include <aic_common.h>
|
||||
#include <aic_hal_gpio.h>
|
||||
#if defined(KERNEL_RTTHREAD)
|
||||
#include <rtthread.h>
|
||||
#elif defined(KERNEL_BAREMETAL)
|
||||
#include <console.h>
|
||||
#endif
|
||||
#ifdef LPKG_USING_FDTLIB
|
||||
#include <libfdt.h>
|
||||
#include <of.h>
|
||||
#endif
|
||||
|
||||
int list_pinmux(int argc, char *argv[])
|
||||
{
|
||||
unsigned int group, pin, func, i;
|
||||
pin_name_t pin_name, pin_name_max;
|
||||
|
||||
for (i = 0; i < GPIO_GROUP_MAX; i++)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case PA_GROUP:
|
||||
case PB_GROUP:
|
||||
case PC_GROUP:
|
||||
case PD_GROUP:
|
||||
case PE_GROUP:
|
||||
#ifndef AIC_CHIP_D12X
|
||||
case PF_GROUP:
|
||||
case PG_GROUP:
|
||||
case PO_GROUP:
|
||||
#endif
|
||||
pin_name = PA_BASE + i * GPIO_GROUP_SIZE;
|
||||
pin_name_max = pin_name + GPIO_GROUP_SIZE;
|
||||
|
||||
while (pin_name < pin_name_max)
|
||||
{
|
||||
group = GPIO_GROUP(pin_name);
|
||||
pin = GPIO_GROUP_PIN(pin_name);
|
||||
func = 0;
|
||||
|
||||
hal_gpio_get_func(group, pin, &func);
|
||||
if (func)
|
||||
{
|
||||
printf("P%c%d: function: %d\n", group + 'A', pin, func);
|
||||
}
|
||||
|
||||
pin_name++;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(KERNEL_RTTHREAD)
|
||||
MSH_CMD_EXPORT_ALIAS(list_pinmux, list_pinmux, list pin function config);
|
||||
#elif defined(KERNEL_BAREMETAL)
|
||||
CONSOLE_CMD(list_pinmux, list_pinmux, "list pin function config");
|
||||
#endif
|
||||
|
||||
#ifdef LPKG_USING_FDTLIB
|
||||
/*
|
||||
* DTS uses 32bit data to define the properties of a pin.
|
||||
*
|
||||
* |---------------------32bit---------------------|
|
||||
* |<----8---->|<----8---->|<----8---->|<-4->|<-4->|
|
||||
* | group | pin | func |pull | STR |
|
||||
*
|
||||
*/
|
||||
#define AIC_GROUP_OFFSET (24)
|
||||
#define AIC_PIN_OFFSET (16)
|
||||
#define AIC_FUNC_OFFSET (8)
|
||||
#define AIC_PULL_OFFSET (4)
|
||||
#define AIC_STR_OFFSET (0)
|
||||
|
||||
#define AIC_DTS_PINMUX(group, pin, func, pull, strength) \
|
||||
(((group - 'A') << AIC_GROUP_OFFSET) | \
|
||||
(pin << AIC_PIN_OFFSET) | \
|
||||
(func << AIC_FUNC_OFFSET) | \
|
||||
(pull << AIC_PULL_OFFSET) | \
|
||||
(strength << AIC_STR_OFFSET))
|
||||
|
||||
#define AIC_PINCTRL_GET_GROUP(pinmux) ((pinmux >> AIC_GROUP_OFFSET) & 0xFF)
|
||||
#define AIC_PINCTRL_GET_PIN(pinmux) ((pinmux >> AIC_PIN_OFFSET) & 0xFF)
|
||||
#define AIC_PINCTRL_GET_FUNC(pinmux) ((pinmux >> AIC_FUNC_OFFSET) & 0xFF)
|
||||
#define AIC_PINCTRL_GET_PULL(pinmux) ((pinmux >> AIC_PULL_OFFSET) & 0xF)
|
||||
#define AIC_PINCTRL_GET_STR(pinmux) ((pinmux >> AIC_STR_OFFSET) & 0xF)
|
||||
|
||||
int pinmux_fdt_parse(void)
|
||||
{
|
||||
u8 group, pin, func, pull, strength;
|
||||
ofnode pinctrl, node;
|
||||
int i, cell_cnt;
|
||||
u32 pinmux;
|
||||
|
||||
of_find_node_by_path("/soc/pinctrl", &pinctrl);
|
||||
if (pinctrl.offset < 0)
|
||||
{
|
||||
pr_err("/soc/pinctrl node not found!\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!of_fdt_device_is_available(pinctrl))
|
||||
{
|
||||
pr_info("/soc/pinctrl is disabled\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* find pin_deinit node, then deinit pin in this subnode */
|
||||
of_find_subnode(pinctrl, "pin_deinit", &node);
|
||||
if (node.offset > 0)
|
||||
{
|
||||
of_property_get_u32_array_number(node, "pinmux", &cell_cnt);
|
||||
|
||||
for (i = 0; i < cell_cnt; i++)
|
||||
{
|
||||
of_property_read_u32_by_index(node, "pinmux", i, &pinmux);
|
||||
group = AIC_PINCTRL_GET_GROUP(pinmux);
|
||||
pin = AIC_PINCTRL_GET_PIN(pinmux);
|
||||
|
||||
/* Deinit pin function*/
|
||||
hal_gpio_set_func(group, pin, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* find pin_init node, then init pin in this subnode */
|
||||
of_find_subnode(pinctrl, "pin_init", &node);
|
||||
if (node.offset > 0)
|
||||
{
|
||||
of_property_get_u32_array_number(node, "pinmux", &cell_cnt);
|
||||
|
||||
for (i = 0; i < cell_cnt; i++)
|
||||
{
|
||||
of_property_read_u32_by_index(node, "pinmux", i, &pinmux);
|
||||
group = AIC_PINCTRL_GET_GROUP(pinmux);
|
||||
pin = AIC_PINCTRL_GET_PIN(pinmux);
|
||||
func = AIC_PINCTRL_GET_FUNC(pinmux);
|
||||
pull = AIC_PINCTRL_GET_PULL(pinmux);
|
||||
strength = AIC_PINCTRL_GET_STR(pinmux);
|
||||
|
||||
/* Init pin */
|
||||
hal_gpio_set_func(group, pin, func);
|
||||
hal_gpio_set_bias_pull(group, pin, pull);
|
||||
hal_gpio_set_drive_strength(group, pin, strength);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user