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

相关文章

在 Spring Boot 中使用 @Autowired和 @Bean注解的示例详解

《在SpringBoot中使用@Autowired和@Bean注解的示例详解》本文通过一个示例演示了如何在SpringBoot中使用@Autowired和@Bean注解进行依赖注入和Bean... 目录在 Spring Boot 中使用 @Autowired 和 @Bean 注解示例背景1. 定义 Stud

Spring Boot整合log4j2日志配置的详细教程

《SpringBoot整合log4j2日志配置的详细教程》:本文主要介绍SpringBoot项目中整合Log4j2日志框架的步骤和配置,包括常用日志框架的比较、配置参数介绍、Log4j2配置详解... 目录前言一、常用日志框架二、配置参数介绍1. 日志级别2. 输出形式3. 日志格式3.1 PatternL

如何使用Spring boot的@Transactional进行事务管理

《如何使用Springboot的@Transactional进行事务管理》这篇文章介绍了SpringBoot中使用@Transactional注解进行声明式事务管理的详细信息,包括基本用法、核心配置... 目录一、前置条件二、基本用法1. 在方法上添加注解2. 在类上添加注解三、核心配置参数1. 传播行为(

Spring Boot Actuator使用说明

《SpringBootActuator使用说明》SpringBootActuator是一个用于监控和管理SpringBoot应用程序的强大工具,通过引入依赖并配置,可以启用默认的监控接口,... 目录项目里引入下面这个依赖使用场景总结说明:本文介绍Spring Boot Actuator的使用,关于Spri

Redis 多规则限流和防重复提交方案实现小结

《Redis多规则限流和防重复提交方案实现小结》本文主要介绍了Redis多规则限流和防重复提交方案实现小结,包括使用String结构和Zset结构来记录用户IP的访问次数,具有一定的参考价值,感兴趣... 目录一:使用 String 结构记录固定时间段内某用户 IP 访问某接口的次数二:使用 Zset 进行

Spring Boot 整合 ShedLock 处理定时任务重复执行的问题小结

《SpringBoot整合ShedLock处理定时任务重复执行的问题小结》ShedLock是解决分布式系统中定时任务重复执行问题的Java库,通过在数据库中加锁,确保只有一个节点在指定时间执行... 目录前言什么是 ShedLock?ShedLock 的工作原理:定时任务重复执行China编程的问题使用 Shed

解读Redis秒杀优化方案(阻塞队列+基于Stream流的消息队列)

《解读Redis秒杀优化方案(阻塞队列+基于Stream流的消息队列)》该文章介绍了使用Redis的阻塞队列和Stream流的消息队列来优化秒杀系统的方案,通过将秒杀流程拆分为两条流水线,使用Redi... 目录Redis秒杀优化方案(阻塞队列+Stream流的消息队列)什么是消息队列?消费者组的工作方式每

Spring Boot统一异常拦截实践指南(最新推荐)

《SpringBoot统一异常拦截实践指南(最新推荐)》本文介绍了SpringBoot中统一异常处理的重要性及实现方案,包括使用`@ControllerAdvice`和`@ExceptionHand... 目录Spring Boot统一异常拦截实践指南一、为什么需要统一异常处理二、核心实现方案1. 基础组件

MySQL分表自动化创建的实现方案

《MySQL分表自动化创建的实现方案》在数据库应用场景中,随着数据量的不断增长,单表存储数据可能会面临性能瓶颈,例如查询、插入、更新等操作的效率会逐渐降低,分表是一种有效的优化策略,它将数据分散存储在... 目录一、项目目的二、实现过程(一)mysql 事件调度器结合存储过程方式1. 开启事件调度器2. 创

JAVA系统中Spring Boot应用程序的配置文件application.yml使用详解

《JAVA系统中SpringBoot应用程序的配置文件application.yml使用详解》:本文主要介绍JAVA系统中SpringBoot应用程序的配置文件application.yml的... 目录文件路径文件内容解释1. Server 配置2. Spring 配置3. Logging 配置4. Ma