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
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

baidu_37552881

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值