RK3568平台(网络篇)添加网络交换芯片RTL8306M_rtl8309 demo

#include <linux/slab.h>
#include <linux/uaccess.h>
#include <linux/compat.h>
#include <linux/printk.h>
#include <linux/kobject.h>
#include <linux/version.h>
#include <linux/kthread.h>
#include <linux/gpio.h>
#include <linux/of_gpio.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/platform_device.h>

#include “rtk_api.h”
#include “rtl8309_main.h”

#include <linux/delay.h>

#define DRIVER_NAME “RTL8309”

#define RTL8309_DEBUG 1
#if RTL8309_DEBUG
#define DBG(format, args…)
printk(KERN_DEBUG "%s: " format, DRIVER_NAME, ##args)
#define ERR(format, args…)
printk(KERN_ERR "%s: " format, DRIVER_NAME, ##args)
#define WARNING(format, args…)
printk(KERN_WARN "%s: " format, DRIVER_NAME, ##args)
#define INFO(format, args…)
printk(KERN_INFO "%s: " format, DRIVER_NAME, ##args)
#else
#define DBG(format, args…)
#define ERR(format, args…)
#define WARNING(format, args…)
#define INFO(format, args…)
#endif

#define LINK_UP 1
#define LINK_DOWN 2
#define LINK_UNKNOW 3

int PRE_PORT_STATUS[5]={0,0,0,0,0};

struct rtl8309_dev {
struct device *dev;
struct device sys_dev;
struct gpio_desc *rtl8309_mdio;
struct gpio_desc *rtl8309_mdc;
struct delayed_work check_status_work;
struct mutex status_lock;
u32 link_status;
};

struct rtl8309_dev *g_rtl8309;
struct rtl8309_dev *rtl8309;

void setGpioDirection(int gpio, uint32_t dir)
{
if(gpio == IST_GPIO_RTL8309_MDIO){
if(dir){
gpiod_direction_output(g_rtl8309->rtl8309_mdio,1);
}else{
gpiod_direction_input(g_rtl8309->rtl8309_mdio);
}
}else if(gpio == IST_GPIO_RTL8309_MDC){
if(dir){
gpiod_dir

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值