#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