RK 方案u-boot阶段添加驱动

2024-08-30 02:36
文章标签 驱动 boot 阶段 方案 rk

本文主要是介绍RK 方案u-boot阶段添加驱动,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

驱动部分:
u-boot/drivers/video/drm/gpio_init.c

/** (C) Copyright 2008-2017 Fuzhou Rockchip Electronics Co., Ltd** SPDX-License-Identifier:	GPL-2.0+*/#include <config.h>
#include <common.h>
#include <errno.h>
#include <malloc.h>
#include <video.h>
#include <backlight.h>
#include <asm/gpio.h>
#include <dm/device.h>
#include <dm/read.h>
#include <dm/uclass.h>
#include <dm/uclass-id.h>
#include <linux/media-bus-format.h>
#include <power/regulator.h>
//DECLARE_GLOBAL_DATA_PTR;
struct customer_gpio_priv {struct udevice *reg;struct gpio_desc wifi_power_gpio;struct gpio_desc usb_switch_gpio;struct gpio_desc usb_switch_gpio2;struct gpio_desc wifi_power_gpio_01;struct gpio_desc power_led_ctrl;uint default_level;uint min_level;uint max_level;
};
static int customer_gpio_ofdata_to_platdata(struct udevice *dev)
{printf("##fan##%s\n",__func__);	return 0;
}static int customer_gpio_probe(struct udevice *dev)
{int ret;
//	struct gpio_desc reset_gpio;struct customer_gpio_priv *priv = dev_get_priv(dev);ret = gpio_request_by_name(dev, "usb-switch2", 0,&priv->usb_switch_gpio2, GPIOD_IS_OUT);if (ret && ret != -ENOENT) {printf("%s: Cannot get usb-switch2: %d\n", __func__, ret);return ret;}printf("####set gpio switch gpio2 low\n");dm_gpio_set_value(&priv->usb_switch_gpio2, 0);ret = gpio_request_by_name(dev, "wifi-gpios", 0,&priv->wifi_power_gpio, GPIOD_IS_OUT);if (ret && ret != -ENOENT) {printf("%s: Cannot get wifi GPIO: %d\n", __func__, ret);return ret;}ret = gpio_request_by_name(dev, "usb-switch", 0,&priv->usb_switch_gpio, GPIOD_IS_OUT);if (ret && ret != -ENOENT) {printf("%s: Cannot get usb-switch11: %d\n", __func__, ret);return ret;}ret = gpio_request_by_name(dev, "power-led-ctl", 0,&priv->power_led_ctrl, GPIOD_IS_OUT);if (ret && ret != -ENOENT) {printf("%s: Cannot get power led ctrl  GPIO: %d\n", __func__, ret);return ret;}dm_gpio_set_value(&priv->usb_switch_gpio, 0);printf("%s:  usb-switch---0h:\n", __func__);mdelay(50);dm_gpio_set_value(&priv->usb_switch_gpio, 1);printf("%s:  usb-switch---1h:\n", __func__);dm_gpio_set_value(&priv->wifi_power_gpio, 1);// dm_gpio_set_value(&priv->wifi_power_gpio_01, 1);mdelay(50);dm_gpio_set_value(&priv->wifi_power_gpio, 0);dm_gpio_set_value(&priv->power_led_ctrl, 1);return 0;
}static const struct udevice_id customer_gpio_ids[] = {//{ .compatible = "mmc-pwrseq-simple"},{ .compatible = "customer-gpio-init", },{}
};U_BOOT_DRIVER(customer_gpio) = {.name = "customer_gpio",.id = UCLASS_CUSTOMER_GPIO,  // 跟下面定义对应.of_match = customer_gpio_ids,.ofdata_to_platdata = customer_gpio_ofdata_to_platdata,.probe = customer_gpio_probe,.priv_auto_alloc_size = sizeof(struct customer_gpio_priv),
//	.platdata_auto_alloc_size = sizeof(struct customer_gpio_priv),
};

u-boot/drivers/video/drm/Makefile 让驱动编译进来

在这里插入图片描述

u-boot/include/dm/uclass-id.h 这个匹配驱动中的.id
在这里插入图片描述

这篇关于RK 方案u-boot阶段添加驱动的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1119560

相关文章

Java进行文件格式校验的方案详解

《Java进行文件格式校验的方案详解》这篇文章主要为大家详细介绍了Java中进行文件格式校验的相关方案,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录一、背景异常现象原因排查用户的无心之过二、解决方案Magandroidic Number判断主流检测库对比Tika的使用区分zip

Spring Boot 3.4.3 基于 Spring WebFlux 实现 SSE 功能(代码示例)

《SpringBoot3.4.3基于SpringWebFlux实现SSE功能(代码示例)》SpringBoot3.4.3结合SpringWebFlux实现SSE功能,为实时数据推送提供... 目录1. SSE 简介1.1 什么是 SSE?1.2 SSE 的优点1.3 适用场景2. Spring WebFlu

Spring Boot结成MyBatis-Plus最全配置指南

《SpringBoot结成MyBatis-Plus最全配置指南》本文主要介绍了SpringBoot结成MyBatis-Plus最全配置指南,包括依赖引入、配置数据源、Mapper扫描、基本CRUD操... 目录前言详细操作一.创建项目并引入相关依赖二.配置数据源信息三.编写相关代码查zsRArly询数据库数

一文详解如何从零构建Spring Boot Starter并实现整合

《一文详解如何从零构建SpringBootStarter并实现整合》SpringBoot是一个开源的Java基础框架,用于创建独立、生产级的基于Spring框架的应用程序,:本文主要介绍如何从... 目录一、Spring Boot Starter的核心价值二、Starter项目创建全流程2.1 项目初始化(

Spring Boot 整合 MyBatis 连接数据库及常见问题

《SpringBoot整合MyBatis连接数据库及常见问题》MyBatis是一个优秀的持久层框架,支持定制化SQL、存储过程以及高级映射,下面详细介绍如何在SpringBoot项目中整合My... 目录一、基本配置1. 添加依赖2. 配置数据库连接二、项目结构三、核心组件实现(示例)1. 实体类2. Ma

IDEA中Git版本回退的两种实现方案

《IDEA中Git版本回退的两种实现方案》作为开发者,代码版本回退是日常高频操作,IntelliJIDEA集成了强大的Git工具链,但面对reset和revert两种核心回退方案,许多开发者仍存在选择... 目录一、版本回退前置知识二、Reset方案:整体改写历史1、IDEA图形化操作(推荐)1.1、查看提

Spring Boot 集成 Quartz 使用Cron 表达式实现定时任务

《SpringBoot集成Quartz使用Cron表达式实现定时任务》本文介绍了如何在SpringBoot项目中集成Quartz并使用Cron表达式进行任务调度,通过添加Quartz依赖、创... 目录前言1. 添加 Quartz 依赖2. 创建 Quartz 任务3. 配置 Quartz 任务调度4. 启

Python实现html转png的完美方案介绍

《Python实现html转png的完美方案介绍》这篇文章主要为大家详细介绍了如何使用Python实现html转png功能,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 1.增强稳定性与错误处理建议使用三层异常捕获结构:try: with sync_playwright(

Java使用多线程处理未知任务数的方案介绍

《Java使用多线程处理未知任务数的方案介绍》这篇文章主要为大家详细介绍了Java如何使用多线程实现处理未知任务数,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 知道任务个数,你可以定义好线程数规则,生成线程数去跑代码说明:1.虚拟线程池:使用 Executors.newVir

MySQL中闪回功能的方案讨论及实现

《MySQL中闪回功能的方案讨论及实现》Oracle有一个闪回(flashback)功能,能够用户恢复误操作的数据,这篇文章主要来和大家讨论一下MySQL中支持闪回功能的方案,有需要的可以了解下... 目录1、 闪回的目标2、 无米无炊一3、 无米无炊二4、 演示5、小结oracle有一个闪回(flashb