代码拉取完成,页面将自动刷新
/*
* Copyright 2024 Hangzhou Yingyi Technology Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <rk3568/gpio.h>
#include <uk/assert.h>
#include <uk/ofw/fdt.h>
#include <libfdt.h>
static uint64_t grf_base_addr;
static uint8_t gpio_initialized;
/* Macros to access gpio Registers with base address 'grf_base_addr'*/
#define GPIO_REG(r) ((uint32_t *)(grf_base_addr + (r)))
#define GPIO_REG_READ(r) ioreg_read32(GPIO_REG(r))
#define GPIO_REG_WRITE(r, v) ioreg_write32(GPIO_REG(r), v)
/**
* @brief map uart4 to gpio39/40
*
* @return -1: gpio not initialized, mapping error
* 0: mapping success
*/
static int map_uart_to_gpio(void)
{
if (!gpio_initialized) {
UK_CRASH("GPIO not initialized!\n");
return -1;
}
GPIO_REG_WRITE(GRF_IOFUNC_SEL3, MODE_UART4_SEL);
GPIO_REG_WRITE(GRF_GPIO3B_IOMUX_L, UART4_ON);
return 0;
}
void _librk3568plat_init_gpio(void *fdtp)
{
int grf_offset, rc;
uint64_t addr, size;
grf_offset = fdt_node_offset_by_compatible(fdtp, -1,
"rockchip,rk3568-grf");
if (grf_offset < 0)
UK_CRASH("No General Register Files node found!\n");
rc = fdt_get_address(fdtp, grf_offset, 0, &addr, &size);
if (rc < 0)
UK_CRASH("Could not find grf address!\n");
grf_base_addr = addr;
gpio_initialized = 1;
map_uart_to_gpio();
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。