summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorJiaojinxing <jiaojinxing1987@gmail.com>2016-12-09 11:55:31 (GMT)
committer Jiaojinxing <jiaojinxing1987@gmail.com>2016-12-09 11:55:31 (GMT)
commit025c275fc190972106a606403a8a229f8be1004c (patch)
tree92ada05b4430a11c5bbb0213aedc0168065c5f60
parentb973b55505ef7604699f1854f734f81d733a1779 (diff)
downloadbspam335x-025c275fc190972106a606403a8a229f8be1004c.zip
bspam335x-025c275fc190972106a606403a8a229f8be1004c.tar.gz
bspam335x-025c275fc190972106a606403a8a229f8be1004c.tar.bz2
Updated net card driver.
-rw-r--r--.cproject19
-rw-r--r--.gitignore7
-rw-r--r--.reproject1
-rw-r--r--Makefile32
-rw-r--r--README.txt20
-rw-r--r--SylixOS/bsp/beaglebone/bspBeaglebone.c38
-rw-r--r--SylixOS/bsp/bspInit.c92
-rw-r--r--SylixOS/bsp/forlinx/bspForlinx.c76
-rw-r--r--SylixOS/driver/adc/am335x_adc.c4
-rw-r--r--SylixOS/driver/audio/dsp/dspDrv.c4
-rw-r--r--SylixOS/driver/audio/mixer/mixerDrv.c2
-rw-r--r--SylixOS/driver/ds1337/rx8010.c448
-rw-r--r--SylixOS/driver/ds1337/rx8010.h37
-rw-r--r--SylixOS/driver/ecap/am335x_ecap.c4
-rw-r--r--SylixOS/driver/ft5x06/ft5x06.c4
-rw-r--r--SylixOS/driver/i2c/am335x_i2c.c350
-rw-r--r--SylixOS/driver/netif/am335x_cpsw.c308
-rw-r--r--SylixOS/driver/netif/am335x_cpsw.h7
-rw-r--r--SylixOS/driver/netif/cpswif.c245
-rw-r--r--SylixOS/driver/netif/cpswif.h58
-rw-r--r--SylixOS/driver/netif/debug.h39
-rw-r--r--SylixOS/driver/netif/lwiplib.h18
-rw-r--r--SylixOS/driver/pwm/am335x_pwm.c4
-rw-r--r--SylixOS/driver/touch/am335x_adc_touch.c4
-rw-r--r--SylixOS/driver/tps65217/tps65217.c4
-rw-r--r--SylixOS/driver/tps65217/tps65217.h2
-rw-r--r--SylixOS/driver/watchdog/am335x_watchdog.c4
-rw-r--r--bspok335xs.mk1
-rw-r--r--config.lds6
-rw-r--r--config.mk8
30 files changed, 1116 insertions, 730 deletions
diff --git a/.cproject b/.cproject
index 592ba28..58e6e4d 100644
--- a/.cproject
+++ b/.cproject
@@ -16,22 +16,11 @@
<pathentry kind="mac" name="__GNUC__" path="" value="4"/>
<pathentry kind="mac" name="SYLIXOS" path="" value=""/>
<pathentry kind="mac" name="__arm__" path="" value=""/>
- <pathentry kind="mac" name="__BOOT_INRAM" path="" value="1"/>
- <pathentry kind="mac" name="am335x" path="" value=""/>
- <pathentry kind="mac" name="gcc" path="" value=""/>
- <pathentry kind="mac" name="DMA_MODE" path="" value=""/>
- <pathentry kind="mac" name="ok335xs" path="" value=""/>
+ <pathentry base-ref="bspam335x" include="D:/SylixOSDev/workspace/sylixos-base-a9/libsylixos/SylixOS" kind="inc" path="" system="true"/>
+ <pathentry base-ref="bspam335x" include="D:/SylixOSDev/workspace/sylixos-base-a9/libsylixos/SylixOS/include" kind="inc" path="" system="true"/>
+ <pathentry base-ref="bspam335x" include="D:/SylixOSDev/workspace/sylixos-base-a9/libsylixos/SylixOS/include/network" kind="inc" path="" system="true"/>
+ <pathentry base-ref="bspam335x" include="D:/SylixOSDev/workspace/sylixos-base-a9/libcextern/libcextern/include" kind="inc" path="" system="true"/>
<pathentry base-ref="bspam335x" include="C:/ACOINFO/RealEvo/compiler/arm-sylixos-toolchain/arm-sylixos-eabi/include" kind="inc" path="" system="true"/>
<pathentry base-ref="bspam335x" include="C:/ACOINFO/RealEvo/compiler/arm-sylixos-toolchain/lib/gcc/arm-sylixos-eabi/4.9.3/include" kind="inc" path="" system="true"/>
- <pathentry base-ref="bspam335x" include="D:/RealEvo-Simulator/src/workspace/sylixos-base-a8/libsylixos/SylixOS" kind="inc" path="" system="true"/>
- <pathentry base-ref="bspam335x" include="D:/RealEvo-Simulator/src/workspace/sylixos-base-a8/libsylixos/SylixOS/include" kind="inc" path="" system="true"/>
- <pathentry base-ref="bspam335x" include="D:/RealEvo-Simulator/src/workspace/sylixos-base-a8/libsylixos/SylixOS/include/inet" kind="inc" path="" system="true"/>
- <pathentry base-ref="bspam335x" include="SylixOS" kind="inc" path="" system="true"/>
- <pathentry base-ref="bspam335x" include="SylixOS/bsp" kind="inc" path="" system="true"/>
- <pathentry base-ref="bspam335x" include="SylixOS/StarterWare/include" kind="inc" path="" system="true"/>
- <pathentry base-ref="bspam335x" include="SylixOS/StarterWare/include/hw" kind="inc" path="" system="true"/>
- <pathentry base-ref="bspam335x" include="SylixOS/StarterWare/include/armv7a" kind="inc" path="" system="true"/>
- <pathentry base-ref="bspam335x" include="SylixOS/StarterWare/include/armv7a/am335x" kind="inc" path="" system="true"/>
- <pathentry base-ref="bspam335x" include="SylixOS/StarterWare/usblib/include" kind="inc" path="" system="true"/>
</storageModule>
</cproject>
diff --git a/.gitignore b/.gitignore
index 1fcac3a..8627b55 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
-/SylixOS/bsp/symbol.h
-/SylixOS/bsp/symbol.c
/Debug
/Release
-/.rcsetting
/.settings
+/.rcsetting
+/SylixOS/bsp/symbol.c
+/SylixOS/bsp/symbol.h
+/config.lds
diff --git a/.reproject b/.reproject
index b714e9f..1482404 100644
--- a/.reproject
+++ b/.reproject
@@ -10,4 +10,5 @@
<FileFilter>
<PairItem key="SylixOS/driver/netif/netio/getopt.c" value=""/>
</FileFilter>
+<BuildSetting CoustomCfgMakefile="true" NeedReBuild="false" NotScanSourceFile="false"/>
</SylixOSSetting>
diff --git a/Makefile b/Makefile
index 0195b42..a064c47 100644
--- a/Makefile
+++ b/Makefile
@@ -35,10 +35,38 @@ endif
endif
#*********************************************************************************************************
+# Include sylixos base config.mk
+#*********************************************************************************************************
+EMPTY =
+SPACE = $(EMPTY) $(EMPTY)
+
+SYLIXOS_BASE_PATH_BAK := $(SYLIXOS_BASE_PATH)
+TOOLCHAIN_PREFIX_BAK := $(TOOLCHAIN_PREFIX)
+DEBUG_LEVEL_BAK := $(DEBUG_LEVEL)
+CPU_TYPE_BAK := $(CPU_TYPE)
+FPU_TYPE_BAK := $(FPU_TYPE)
+
+SYLIXOS_BASE_CONFIGMK = $(subst $(SPACE),\ ,$(SYLIXOS_BASE_PATH))/config.mk
+include $(SYLIXOS_BASE_CONFIGMK)
+
+SYLIXOS_BASE_PATH := $(SYLIXOS_BASE_PATH_BAK)
+DEBUG_LEVEL := $(DEBUG_LEVEL_BAK)
+
+ifneq ($(TOOLCHAIN_PREFIX_BAK),)
+TOOLCHAIN_PREFIX := $(TOOLCHAIN_PREFIX_BAK)
+endif
+
+ifneq ($(CPU_TYPE_BAK),)
+CPU_TYPE := $(CPU_TYPE_BAK)
+endif
+
+ifneq ($(FPU_TYPE_BAK),)
+FPU_TYPE := $(FPU_TYPE_BAK)
+endif
+
+#*********************************************************************************************************
# Include header.mk
#*********************************************************************************************************
-EMPTY =
-SPACE = $(EMPTY) $(EMPTY)
MKTEMP = $(subst $(SPACE),\ ,$(SYLIXOS_BASE_PATH))/libsylixos/SylixOS/mktemp
include $(MKTEMP)/header.mk
diff --git a/README.txt b/README.txt
deleted file mode 100644
index 0185485..0000000
--- a/README.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-
-bspam335x 是 SylixOS 支持 Ti AM335x 系列处理器的 BSP 包,
-
-目前该 BSP 支持飞凌嵌入式公司的 Ok335xS 和 OK335xD 及 BeagleBone 开发板,
-
-如果您需要移植该 BSP 到您的 AM335x 处理器工控板上,请联系我们的销售人员,我们将提供有偿定制服务。
-
-使用 RealCoder 或 Eclipse 打开 bspam335x 工程;
-
-如果您使用 Eclipse,需要修改 config.mk 文件,设置正确的 SylixOS Base 工程路径和工具链前缀及调试级别;
-
-如果您使用 RealEvo-IDE,则需要对工程进行通用设置,方法请参考 《RealEvo-IDE 使用手册》。
-
-根据您使用的开发板,需要修改 Makefile 的 PLATFORM 变量。
-
-下载、运行和烧写内核镜像的方法请参考 U-Boot.txt 文件,我们建议使用 U-Boot 作为 Bootloader。
-
-项目发布时,建议将 libsylixos 的 LW_CFG_SMP_EN 配置为 0,将 LW_CFG_MONITOR_EN 配置为 0,这样性能会更好。
-
-一些实时以太网应用为了获得更好的网络性能,建议将 LW_CFG_LWIP_MSG_SIZE 配置为 2048,将 LW_CFG_LWIP_NUM_PBUFS 配置为 1024。 \ No newline at end of file
diff --git a/SylixOS/bsp/beaglebone/bspBeaglebone.c b/SylixOS/bsp/beaglebone/bspBeaglebone.c
index 8b564bb..60aaed0 100644
--- a/SylixOS/bsp/beaglebone/bspBeaglebone.c
+++ b/SylixOS/bsp/beaglebone/bspBeaglebone.c
@@ -29,9 +29,9 @@
#include "stdlib.h" /* for system() function */
#include "gdbserver.h" /* GDB 调试器 */
#include "sys/compiler.h" /* 编译器相关 */
-#include "lwip/tcpip.h" /* 网络系统 */
-#include "netif/etharp.h" /* 以太网网络接口 */
-#include "netif/aodvif.h" /* aodv 多跳自组网网络接口 */
+#include "network/lwip/tcpip.h" /* 网络系统 */
+#include "network/netif/etharp.h" /* 以太网网络接口 */
+#include "network/netif/aodvif.h" /* aodv 多跳自组网网络接口 */
#include <linux/mtd/mtd.h>
#include "sys/ioccom.h"
#include "net/if_param.h" /* 网络接口参数获取 */
@@ -212,10 +212,6 @@ VOID bspDevInit (VOID)
VOID bspNetifAttch (VOID)
{
AM335X_NETIF_CFG netIfCfg;
- ip_addr_t ip, submask, gateway;
- void *ifparam;
- int enable = 1;
- int def = 1;
arm335xCpswInit();
@@ -231,28 +227,12 @@ VOID bspNetifAttch (VOID)
netIfCfg.NETIFCFG_uiInstNum = 0;
netIfCfg.NETIFCFG_uiSlavePortNum = 1;
- ifparam = if_param_load("cpsw0");
- if (ifparam) {
- if_param_getenable(ifparam, &enable);
- if_param_getdefault(ifparam, &def);
- if_param_getipaddr(ifparam, &ip);
- if_param_getnetmask(ifparam, &submask);
- if_param_getgw(ifparam, &gateway);
- if_param_syncdns();
- if_param_unload(ifparam);
-
- netIfCfg.NETIFCFG_ipAddr = ip;
- netIfCfg.NETIFCFG_netMask = submask;
- netIfCfg.NETIFCFG_gwAddr = gateway;
- netIfCfg.NETIFCFG_bIsDefault = def;
- netIfCfg.NETIFCFG_bIsEnable = enable;
- } else {
- netIfCfg.NETIFCFG_ipAddr.addr = ipaddr_addr(BSP_CFG_EN1_IPADDR);
- netIfCfg.NETIFCFG_netMask.addr = ipaddr_addr(BSP_CFG_EN1_NETMASK);
- netIfCfg.NETIFCFG_gwAddr.addr = ipaddr_addr(BSP_CFG_EN1_GATEWAY);
- netIfCfg.NETIFCFG_bIsDefault = LW_TRUE;
- netIfCfg.NETIFCFG_bIsEnable = LW_TRUE;
- }
+
+ lib_strcpy(netIfCfg.NETIFCFG_ipAddr, BSP_CFG_EN1_IPADDR);
+ lib_strcpy(netIfCfg.NETIFCFG_netMask, BSP_CFG_EN1_NETMASK);
+ lib_strcpy(netIfCfg.NETIFCFG_gwAddr, BSP_CFG_EN1_GATEWAY);
+
+ netIfCfg.NETIFCFG_bIsEnable = LW_TRUE;
netIfCfg.NETIFCFG_uiInterfaceMode = NETIF_GMII_MII_MODE;
netIfCfg.NETIFCFG_bInternalDelay = LW_TRUE;
diff --git a/SylixOS/bsp/bspInit.c b/SylixOS/bsp/bspInit.c
index 859e9e1..e8b59bb 100644
--- a/SylixOS/bsp/bspInit.c
+++ b/SylixOS/bsp/bspInit.c
@@ -788,96 +788,6 @@ static VOID usrStartup (VOID)
LW_NULL); /* Create boot thread */
}
/*********************************************************************************************************
- openocd 相关参数
-*********************************************************************************************************/
-#if LW_CFG_MODULELOADER_EN > 0
-#include "loader/include/loader_lib.h"
-#endif /* LW_CFG_MODULELOADER_EN > 0 */
-
-LW_CFG_STRUCT_PACK_BEGIN
-struct LW_OPENOCD_PARAM {
- LW_CFG_STRUCT_PACK_FIELD(UINT32 uiFlags);
- LW_CFG_STRUCT_PACK_FIELD(UINT32 uiUlongSize);
- LW_CFG_STRUCT_PACK_FIELD(UINT32 uiPointerSize);
- LW_CFG_STRUCT_PACK_FIELD(UINT32 uiPidSize);
-
- LW_CFG_STRUCT_PACK_FIELD(UINT32 uiObjectNameSize);
- LW_CFG_STRUCT_PACK_FIELD(UINT32 uiMaxThreads);
- LW_CFG_STRUCT_PACK_FIELD(UINT32 uiMaxProcessors);
-
- LW_CFG_STRUCT_PACK_FIELD(UINT32 CPU_ptcbTCBCur);
- LW_CFG_STRUCT_PACK_FIELD(UINT32 CPU_ptcbTCBHigh);
- LW_CFG_STRUCT_PACK_FIELD(UINT32 CPU_ulInterNesting);
- LW_CFG_STRUCT_PACK_FIELD(UINT32 CPU_ulStatus);
-
- LW_CFG_STRUCT_PACK_FIELD(UINT32 TCB_cThreadName);
- LW_CFG_STRUCT_PACK_FIELD(UINT32 TCB_ulId);
- LW_CFG_STRUCT_PACK_FIELD(UINT32 TCB_ucPriority);
- LW_CFG_STRUCT_PACK_FIELD(UINT32 TCB_ulLastError);
- LW_CFG_STRUCT_PACK_FIELD(UINT32 TCB_i64PageFailCounter);
- LW_CFG_STRUCT_PACK_FIELD(UINT32 TCB_ulCPUId);
- LW_CFG_STRUCT_PACK_FIELD(UINT32 TCB_pstkStackNow);
- LW_CFG_STRUCT_PACK_FIELD(UINT32 TCB_usStatus);
- LW_CFG_STRUCT_PACK_FIELD(UINT32 TCB_ulOption);
- LW_CFG_STRUCT_PACK_FIELD(UINT32 TCB_pvVProcessContext);
-
- LW_CFG_STRUCT_PACK_FIELD(UINT32 VP_pid);
-} LW_CFG_STRUCT_PACK_STRUCT;
-LW_CFG_STRUCT_PACK_END
-typedef struct LW_OPENOCD_PARAM *PLW_OPENOCD_PARAM;
-
-struct LW_OPENOCD_PARAM _G_sylixosOpenocdParam = { 0 };
-/*********************************************************************************************************
-** 函数名称: bspOpenocdInit
-** 功能描述: 初始化 openocd
-** 输 入 : NONE
-** 输 出 : NONE
-** 全局变量:
-** 调用模块:
-** 注 意 : 必须要在 pOpenocdParam->uiFlags = htole32(1); 语句处下一个断点,
-** 并且单步执行 pOpenocdParam->uiFlags = htole32(1); 语句.
-** 建议关闭 D-Cache, 屏蔽 API_CacheEnable(DATA_CACHE); 语句.
-*********************************************************************************************************/
-static VOID bspOpenocdInit (VOID)
-{
- PLW_OPENOCD_PARAM pOpenocdParam = &_G_sylixosOpenocdParam;
-
- pOpenocdParam->uiFlags = htole32(0);
-
- pOpenocdParam->uiUlongSize = htole32(sizeof(ULONG));
- pOpenocdParam->uiPointerSize = htole32(sizeof(PVOID));
- pOpenocdParam->uiPidSize = htole32(sizeof(pid_t));
-
- pOpenocdParam->uiObjectNameSize = htole32(LW_CFG_OBJECT_NAME_SIZE);
- pOpenocdParam->uiMaxThreads = htole32(LW_CFG_MAX_THREADS);
- pOpenocdParam->uiMaxProcessors = htole32(LW_CFG_MAX_PROCESSORS);
-
- pOpenocdParam->CPU_ptcbTCBCur = htole32(offsetof(LW_CLASS_CPU, CPU_ptcbTCBCur));
- pOpenocdParam->CPU_ptcbTCBHigh = htole32(offsetof(LW_CLASS_CPU, CPU_ptcbTCBHigh));
- pOpenocdParam->CPU_ulInterNesting = htole32(offsetof(LW_CLASS_CPU, CPU_ulInterNesting));
- pOpenocdParam->CPU_ulStatus = htole32(offsetof(LW_CLASS_CPU, CPU_ulStatus));
-
- pOpenocdParam->TCB_cThreadName = htole32(offsetof(LW_CLASS_TCB, TCB_cThreadName));
- pOpenocdParam->TCB_ulId = htole32(offsetof(LW_CLASS_TCB, TCB_ulId));
- pOpenocdParam->TCB_ucPriority = htole32(offsetof(LW_CLASS_TCB, TCB_ucPriority));
- pOpenocdParam->TCB_ulLastError = htole32(offsetof(LW_CLASS_TCB, TCB_ulLastError));
- pOpenocdParam->TCB_i64PageFailCounter = htole32(offsetof(LW_CLASS_TCB, TCB_i64PageFailCounter));
- pOpenocdParam->TCB_ulCPUId = htole32(offsetof(LW_CLASS_TCB, TCB_ulCPUId));
- pOpenocdParam->TCB_pstkStackNow = htole32(offsetof(LW_CLASS_TCB, TCB_pstkStackNow));
- pOpenocdParam->TCB_usStatus = htole32(offsetof(LW_CLASS_TCB, TCB_usStatus));
- pOpenocdParam->TCB_ulOption = htole32(offsetof(LW_CLASS_TCB, TCB_ulOption));
- pOpenocdParam->TCB_pvVProcessContext = htole32(offsetof(LW_CLASS_TCB, TCB_pvVProcessContext));
-
-#if LW_CFG_MODULELOADER_EN > 0
- pOpenocdParam->VP_pid = htole32(offsetof(LW_LD_VPROC, VP_pid));
-#else
- pOpenocdParam->VP_pid = 0;
-#endif /* LW_CFG_MODULELOADER_EN > 0 */
-
- pOpenocdParam->uiFlags = htole32(1);
- pOpenocdParam->uiFlags = htole32(0);
-}
-/*********************************************************************************************************
** 函数名称: main
** 功能描述: C 入口
** 输 入 : NONE
@@ -898,8 +808,6 @@ INT bspInit (VOID)
WatchdogTimerDisable(SOC_WDT_1_REGS); /* Disable the Watchdog timer */
- bspOpenocdInit(); /* 初始化 openocd */
-
halModeInit(); /* 初始化硬件 */
/*
diff --git a/SylixOS/bsp/forlinx/bspForlinx.c b/SylixOS/bsp/forlinx/bspForlinx.c
index e9406d5..17fb5d6 100644
--- a/SylixOS/bsp/forlinx/bspForlinx.c
+++ b/SylixOS/bsp/forlinx/bspForlinx.c
@@ -29,9 +29,9 @@
#include "stdlib.h" /* for system() function */
#include "gdbserver.h" /* GDB 调试器 */
#include "sys/compiler.h" /* 编译器相关 */
-#include "lwip/tcpip.h" /* 网络系统 */
-#include "netif/etharp.h" /* 以太网网络接口 */
-#include "netif/aodvif.h" /* aodv 多跳自组网网络接口 */
+#include "network/lwip/tcpip.h" /* 网络系统 */
+#include "network/netif/etharp.h" /* 以太网网络接口 */
+#include "network/netif/aodvif.h" /* aodv 多跳自组网网络接口 */
#include <linux/mtd/mtd.h>
#include "sys/ioccom.h"
#include "net/if_param.h" /* 网络接口参数获取 */
@@ -72,6 +72,7 @@
#include "driver/beep/beep.h"
#include "driver/ft5x06/ft5x06.h"
#include "driver/ds1337/ds1337.h"
+#include "driver/ds1337/rx8010.h"
#include "driver/sdi/am335x_sdi.h"
@@ -666,7 +667,11 @@ VOID bspTimeInit (VOID)
#if defined(ok335xd)
pRtcFuncs = ds1337RtcGetFuncs("/bus/i2c/0");
#else
- pRtcFuncs = ds1337RtcGetFuncs("/bus/i2c/1");
+#if (BSP_CFG_RTC_RX8010 > 0)
+ pRtcFuncs = rx8010RtcGetFuncs("/bus/i2c/1");
+#else
+ pRtcFuncs = ds1337RtcGetFuncs("/bus/i2c/0");
+#endif
#endif
rtcDrv();
@@ -978,10 +983,6 @@ INT mtdDevCreateEx (CHAR *pcDevName)
VOID bspNetifAttch (VOID)
{
AM335X_NETIF_CFG netIfCfg;
- ip_addr_t ip, submask, gateway;
- void *ifparam;
- int enable = 1;
- int def = 1;
arm335xCpswInit();
@@ -998,28 +999,11 @@ VOID bspNetifAttch (VOID)
netIfCfg.NETIFCFG_uiInstNum = 0;
netIfCfg.NETIFCFG_uiSlavePortNum = 1;
- ifparam = if_param_load("cpsw0");
- if (ifparam) {
- if_param_getenable(ifparam, &enable);
- if_param_getdefault(ifparam, &def);
- if_param_getipaddr(ifparam, &ip);
- if_param_getnetmask(ifparam, &submask);
- if_param_getgw(ifparam, &gateway);
- if_param_syncdns();
- if_param_unload(ifparam);
-
- netIfCfg.NETIFCFG_ipAddr = ip;
- netIfCfg.NETIFCFG_netMask = submask;
- netIfCfg.NETIFCFG_gwAddr = gateway;
- netIfCfg.NETIFCFG_bIsDefault = def;
- netIfCfg.NETIFCFG_bIsEnable = enable;
- } else {
- netIfCfg.NETIFCFG_ipAddr.addr = ipaddr_addr(BSP_CFG_EN1_IPADDR);
- netIfCfg.NETIFCFG_netMask.addr = ipaddr_addr(BSP_CFG_EN1_NETMASK);
- netIfCfg.NETIFCFG_gwAddr.addr = ipaddr_addr(BSP_CFG_EN1_GATEWAY);
- netIfCfg.NETIFCFG_bIsDefault = LW_TRUE;
- netIfCfg.NETIFCFG_bIsEnable = LW_TRUE;
- }
+ lib_strcpy(netIfCfg.NETIFCFG_ipAddr, BSP_CFG_EN1_IPADDR);
+ lib_strcpy(netIfCfg.NETIFCFG_netMask, BSP_CFG_EN1_NETMASK);
+ lib_strcpy(netIfCfg.NETIFCFG_gwAddr, BSP_CFG_EN1_GATEWAY);
+
+ netIfCfg.NETIFCFG_bIsEnable = LW_TRUE;
#if defined(ok335xd) || defined(ok335xs)
netIfCfg.NETIFCFG_uiInterfaceMode = NETIF_RGMII_MODE;
@@ -1038,35 +1022,15 @@ VOID bspNetifAttch (VOID)
*/
arm335xCpswMacAddrGet(1, netIfCfg.NETIFCFG_ucMacArray);
-
netIfCfg.NETIFCFG_uiInstNum = 0;
netIfCfg.NETIFCFG_uiSlavePortNum = 2;
+ lib_strcpy(netIfCfg.NETIFCFG_ipAddr, BSP_CFG_EN2_IPADDR);
+ lib_strcpy(netIfCfg.NETIFCFG_netMask, BSP_CFG_EN2_NETMASK);
+ lib_strcpy(netIfCfg.NETIFCFG_gwAddr, BSP_CFG_EN2_GATEWAY);
+ netIfCfg.NETIFCFG_bIsEnable = LW_TRUE;
- ifparam = if_param_load("cpsw1");
- if (ifparam) {
- if_param_getenable(ifparam, &enable);
- if_param_getdefault(ifparam, &def);
- if_param_getipaddr(ifparam, &ip);
- if_param_getnetmask(ifparam, &submask);
- if_param_getgw(ifparam, &gateway);
- if_param_syncdns();
- if_param_unload(ifparam);
-
- netIfCfg.NETIFCFG_ipAddr = ip;
- netIfCfg.NETIFCFG_netMask = submask;
- netIfCfg.NETIFCFG_gwAddr = gateway;
- netIfCfg.NETIFCFG_bIsDefault = def;
- netIfCfg.NETIFCFG_bIsEnable = enable;
- } else {
- netIfCfg.NETIFCFG_ipAddr.addr = ipaddr_addr(BSP_CFG_EN2_IPADDR);
- netIfCfg.NETIFCFG_netMask.addr = ipaddr_addr(BSP_CFG_EN2_NETMASK);
- netIfCfg.NETIFCFG_gwAddr.addr = ipaddr_addr(BSP_CFG_EN2_GATEWAY);
- netIfCfg.NETIFCFG_bIsDefault = LW_FALSE;
- netIfCfg.NETIFCFG_bIsEnable = LW_TRUE;
- }
-
- netIfCfg.NETIFCFG_bInternalDelay = LW_FALSE;
- netIfCfg.NETIFCFG_uiInterfaceMode = NETIF_RGMII_MODE;
+ netIfCfg.NETIFCFG_bInternalDelay = LW_FALSE;
+ netIfCfg.NETIFCFG_uiInterfaceMode = NETIF_RGMII_MODE;
arm335xCpswNetIfAdd(&netIfCfg, rgmii2_pin_mux);
#elif defined(CPSW_SWITCH_CONFIG)
diff --git a/SylixOS/driver/adc/am335x_adc.c b/SylixOS/driver/adc/am335x_adc.c
index 9455e3d..cc37c4a 100644
--- a/SylixOS/driver/adc/am335x_adc.c
+++ b/SylixOS/driver/adc/am335x_adc.c
@@ -306,7 +306,7 @@ static LONG __am335xAdcOpen (PLW_DEV_HDR pDev,
}
if (pFdNode) {
- API_IosFdNodeDec(&pAdcChannel->ADCCHAN_fdNodeHeader, pFdNode);
+ API_IosFdNodeDec(&pAdcChannel->ADCCHAN_fdNodeHeader, pFdNode, LW_NULL);
pFdNode = LW_NULL;
}
@@ -329,7 +329,7 @@ static INT __am335xAdcClose (PLW_FD_ENTRY pFdEntry)
PLW_FD_NODE pFdNode = (PLW_FD_NODE)pFdEntry->FDENTRY_pfdnode;
if (pFdEntry && pFdNode) {
- API_IosFdNodeDec(&pAdcChannel->ADCCHAN_fdNodeHeader, pFdNode);
+ API_IosFdNodeDec(&pAdcChannel->ADCCHAN_fdNodeHeader, pFdNode, LW_NULL);
if (LW_DEV_DEC_USE_COUNT(&pAdcChannel->ADCCHAN_devHdr) == 0) {
diff --git a/SylixOS/driver/audio/dsp/dspDrv.c b/SylixOS/driver/audio/dsp/dspDrv.c
index 6b623a4..71df277 100644
--- a/SylixOS/driver/audio/dsp/dspDrv.c
+++ b/SylixOS/driver/audio/dsp/dspDrv.c
@@ -295,7 +295,7 @@ static LONG __dspOpen (PLW_DEV_HDR pDev,
* 删除 FD 文件节点
*/
if (pFdNode) {
- API_IosFdNodeDec(&pDspDev->DSP_fdNodeHeader, pFdNode);
+ API_IosFdNodeDec(&pDspDev->DSP_fdNodeHeader, pFdNode, LW_NULL);
pFdNode = LW_NULL;
}
@@ -320,7 +320,7 @@ static INT __dspClose (PLW_FD_ENTRY pFdEntry)
INTREG intReg;
if (pFdEntry && pFdNode) {
- API_IosFdNodeDec(&pDspDev->DSP_fdNodeHeader, pFdNode); /* 删除 FD 文件节点 */
+ API_IosFdNodeDec(&pDspDev->DSP_fdNodeHeader, pFdNode, LW_NULL); /* 删除 FD 文件节点 */
iFlags = pFdEntry->FDENTRY_iFlag & O_ACCMODE; /* 获得访问模式 */
diff --git a/SylixOS/driver/audio/mixer/mixerDrv.c b/SylixOS/driver/audio/mixer/mixerDrv.c
index ddf751b..bba2b69 100644
--- a/SylixOS/driver/audio/mixer/mixerDrv.c
+++ b/SylixOS/driver/audio/mixer/mixerDrv.c
@@ -88,7 +88,7 @@ static INT __mixerClose (PLW_FD_ENTRY pFdEntry)
PLW_FD_NODE pFdNode = (PLW_FD_NODE)pFdEntry->FDENTRY_pfdnode;
if (pFdEntry && pFdNode) {
- API_IosFdNodeDec(&pMixerDev->MIXER_fdNodeHeader, pFdNode);
+ API_IosFdNodeDec(&pMixerDev->MIXER_fdNodeHeader, pFdNode, LW_NULL);
LW_DEV_DEC_USE_COUNT(&pMixerDev->MIXER_devHdr);
diff --git a/SylixOS/driver/ds1337/rx8010.c b/SylixOS/driver/ds1337/rx8010.c
new file mode 100644
index 0000000..7cad1bf
--- /dev/null
+++ b/SylixOS/driver/ds1337/rx8010.c
@@ -0,0 +1,448 @@
+/*********************************************************************************************************
+**
+** 中国软件开源组织
+**
+** 嵌入式实时操作系统
+**
+** SylixOS(TM)
+**
+** Copyright All Rights Reserved
+**
+**--------------文件信息--------------------------------------------------------------------------------
+**
+** 文 件 名: rx8010.c
+**
+** 创 建 人: zhang.pengcheng
+**
+** 文件创建日期: 2016 年 12 月 5 日
+**
+** 描 述: RX8010 RTC 驱动
+*********************************************************************************************************/
+#define __SYLIXOS_KERNEL
+#include "SylixOS.h"
+#include "time.h"
+#include "rtc.h"
+/*********************************************************************************************************
+ 定义
+*********************************************************************************************************/
+#define __RTC_CONTROLER_NR (1)
+
+#define CONFIG_RTC_RX8010 (1)
+
+#define RX8010_SLAVE_ADDR 0x32
+/*********************************************************************************************************
+ RX8010 寄存器定义
+*********************************************************************************************************/
+/*
+ * RX8010 Register definitions
+ */
+#define RX8010_REG_SEC 0x10
+#define RX8010_REG_MIN 0x11
+#define RX8010_REG_HOUR 0x12
+#define RX8010_REG_WDAY 0x13
+#define RX8010_REG_MDAY 0x14
+#define RX8010_REG_MONTH 0x15
+#define RX8010_REG_YEAR 0x16
+ /* 0x17 is reserved */
+#define RX8010_REG_ALMIN 0x18
+#define RX8010_REG_ALHOUR 0x19
+#define RX8010_REG_ALWDAY 0x1A
+#define RX8010_REG_TCOUNT0 0x1B
+#define RX8010_REG_TCOUNT1 0x1C
+#define RX8010_REG_EXT 0x1D
+#define RX8010_REG_FLAG 0x1E
+#define RX8010_REG_CTRL 0x1F
+#define RX8010_REG_USER0 0x20
+#define RX8010_REG_USER1 0x21
+#define RX8010_REG_USER2 0x22
+#define RX8010_REG_USER3 0x23
+#define RX8010_REG_USER4 0x24
+#define RX8010_REG_USER5 0x25
+#define RX8010_REG_USER6 0x26
+#define RX8010_REG_USER7 0x27
+#define RX8010_REG_USER8 0x28
+#define RX8010_REG_USER9 0x29
+#define RX8010_REG_USERA 0x2A
+#define RX8010_REG_USERB 0x2B
+#define RX8010_REG_USERC 0x2C
+#define RX8010_REG_USERD 0x2D
+#define RX8010_REG_USERE 0x2E
+#define RX8010_REG_USERF 0x2F
+ /* 0x30 is reserved */
+ /* 0x31 is reserved */
+#define RX8010_REG_IRQ 0x32
+
+/*
+ * Extension Register (1Dh) bit positions
+ */
+#define RX8010_BIT_EXT_TSEL (7 << 0)
+#define RX8010_BIT_EXT_WADA (1 << 3)
+#define RX8010_BIT_EXT_TE (1 << 4)
+#define RX8010_BIT_EXT_USEL (1 << 5)
+#define RX8010_BIT_EXT_FSEL (3 << 6)
+
+/*
+ * Flag Register (1Eh) bit positions
+ */
+#define RX8010_BIT_FLAG_VLF (1 << 1)
+#define RX8010_BIT_FLAG_AF (1 << 3)
+#define RX8010_BIT_FLAG_TF (1 << 4)
+#define RX8010_BIT_FLAG_UF (1 << 5)
+
+/*
+ * Control Register (1Fh) bit positions
+ */
+#define RX8010_BIT_CTRL_TSTP (1 << 2)
+#define RX8010_BIT_CTRL_AIE (1 << 3)
+#define RX8010_BIT_CTRL_TIE (1 << 4)
+#define RX8010_BIT_CTRL_UIE (1 << 5)
+#define RX8010_BIT_CTRL_STOP (1 << 6)
+#define RX8010_BIT_CTRL_TEST (1 << 7)
+
+/*********************************************************************************************************
+ RTC 控制器类型定义
+*********************************************************************************************************/
+typedef struct {
+ PLW_I2C_DEVICE RTCC_pI2cDevice;
+ CPCHAR RTCC_pcI2cBusName;
+} __RX8010_RTC_CONTROLER, *__PRX8010_RTC_CONTROLER;
+/*********************************************************************************************************
+ 全局变量
+*********************************************************************************************************/
+static __RX8010_RTC_CONTROLER _G_rx8010RtcControlers[__RTC_CONTROLER_NR];
+/*********************************************************************************************************
+** 函数名称: __rx8010BinToBcd
+** 功能描述: BIN 码转 BCD 码
+** 输 入 : ucBin BIN 码
+** 输 出 : BCD 码
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+static UINT8 __rx8010BinToBcd (UINT8 ucBin)
+{
+ UINT8 ucBcd;
+
+ if (ucBin >= 100) {
+ return (0);
+ }
+
+ ucBcd = ucBin % 10;
+ ucBcd |= (ucBin / 10) << 4;
+
+ return (ucBcd);
+}
+/*********************************************************************************************************
+** 函数名称: __rx8010BcdToBin
+** 功能描述: BCD 码转 BIN 码
+** 输 入 : ucBcd BCD 码
+** 输 出 : BIN 码
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+static UINT8 __rx8010BcdToBin (UINT8 ucBcd)
+{
+ UINT8 ucBin;
+
+ ucBin = ((ucBcd & 0xF0) >> 4) * 10 + (ucBcd & 0x0F);
+
+ return (ucBin);
+}
+/*********************************************************************************************************
+** 函数名称: __rx8010RegReadS
+** 功能描述: 读 ds1337 寄存器
+** 输 入 : pI2cDev i2c 设备
+** ucRegAddr 寄存器地址
+** 输 出 : 寄存器值
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+static UINT8 __rx8010RegReadS (PLW_I2C_DEVICE pI2cDev,
+ UINT8 ucRegAddr,
+ INT iLen,
+ UINT8 *ucBuf)
+{
+ INT iError;
+ LW_I2C_MESSAGE i2cMsgs[] = {
+ {
+ .I2CMSG_usAddr = pI2cDev->I2CDEV_usAddr,
+ .I2CMSG_usFlag = 0,
+ .I2CMSG_usLen = 1,
+ .I2CMSG_pucBuffer = &ucRegAddr,
+ },
+ {
+ .I2CMSG_usAddr = pI2cDev->I2CDEV_usAddr,
+ .I2CMSG_usFlag = LW_I2C_M_RD,
+ .I2CMSG_usLen = iLen,
+ .I2CMSG_pucBuffer = ucBuf,
+ },
+ };
+
+ iError = API_I2cDeviceTransfer(pI2cDev, i2cMsgs, 2);
+ if (iError != 2) {
+ printk(KERN_ERR "__rx8010RegRead(): i2c transfer failed!\n");
+ return (PX_ERROR);
+ }
+
+ return (ERROR_NONE);
+}
+/*********************************************************************************************************
+** 函数名称: __ds1337RegWrite
+** 功能描述: 写 ds1337 寄存器
+** 输 入 : pI2cDev i2c 设备
+** ucRegAddr 寄存器地址
+** ucValue 值
+** 输 出 : NONE
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+static INT __rx8010RegWrite (PLW_I2C_DEVICE pI2cDev,
+ UINT8 ucRegAddr,
+ UINT8 ucValue)
+{
+ CHAR acBuffer[2];
+ INT iError;
+
+ acBuffer[0] = ucRegAddr;
+ acBuffer[1] = ucValue;
+ iError = API_I2cDeviceMasterSend(pI2cDev, acBuffer, 2);
+
+ return (iError == 2 ? ERROR_NONE : PX_ERROR);
+}
+/*********************************************************************************************************
+** 函数名称: __rx8010TimeGet
+** 功能描述: 获得 rx8010 时间
+** 输 入 : pI2cDev i2c 设备
+** aucValue 值
+** 输 出 : ERROR_CODE
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+static INT __rx8010TimeGet (PLW_I2C_DEVICE pI2cDev,
+ UINT8 aucValue[7])
+{
+ UINT8 ucRegAddr = RX8010_REG_SEC;
+ INT iError;
+ LW_I2C_MESSAGE i2cMsgs[] = {
+ {
+ .I2CMSG_usAddr = pI2cDev->I2CDEV_usAddr,
+ .I2CMSG_usFlag = 0,
+ .I2CMSG_usLen = 1,
+ .I2CMSG_pucBuffer = &ucRegAddr,
+ },
+ {
+ .I2CMSG_usAddr = pI2cDev->I2CDEV_usAddr,
+ .I2CMSG_usFlag = LW_I2C_M_RD,
+ .I2CMSG_usLen = 7,
+ .I2CMSG_pucBuffer = aucValue,
+ },
+ };
+
+ iError = API_I2cDeviceTransfer(pI2cDev, i2cMsgs, 2);
+ if (iError != 2) {
+ printk(KERN_ERR "__rx8010TimeGet(): i2c transfer failed!\n");
+ return (PX_ERROR);
+ }
+
+ return (ERROR_NONE);
+}
+/*********************************************************************************************************
+** 函数名称: __rx8010TimeSet
+** 功能描述: 设置 ds1337 时间
+** 输 入 : pI2cDev i2c 设备
+** aucValue 值
+** 输 出 : ERROR_CODE
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+static INT __rx8010TimeSet (PLW_I2C_DEVICE pI2cDev,
+ UINT8 aucValue[7])
+{
+ CHAR acBuffer[8];
+ INT iError;
+
+ acBuffer[0] = RX8010_REG_SEC;
+
+ lib_memcpy(acBuffer + 1, aucValue, 7);
+ iError = API_I2cDeviceMasterSend(pI2cDev, acBuffer, 8);
+
+ return (iError == 8 ? ERROR_NONE : PX_ERROR);
+}
+/*********************************************************************************************************
+** 函数名称: __rx8010RtcSetTime
+** 功能描述: 设置 RTC 时间
+** 输 入 : pRtcFuncs RTC 驱动程序
+** pTimeNow 当前时间
+** 输 出 : ERROR_CODE
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+static INT __rx8010RtcSetTime (PLW_RTC_FUNCS pRtcFuncs, time_t *pTimeNow)
+{
+ __PRX8010_RTC_CONTROLER pRtcControler = &_G_rx8010RtcControlers[0];
+ struct tm tmNow;
+ UINT8 aucBuffer[7];
+ UINT8 ucCtrl;
+
+ gmtime_r(pTimeNow, &tmNow); /* 转换成 tm 时间格式 */
+
+ /*
+ * set STOP bit before changing clock/calendar
+ */
+ __rx8010RegReadS(pRtcControler->RTCC_pI2cDevice, RX8010_REG_CTRL, 1, &ucCtrl);
+ ucCtrl |= RX8010_BIT_CTRL_STOP;
+ __rx8010RegWrite(pRtcControler->RTCC_pI2cDevice, RX8010_REG_CTRL, ucCtrl);
+
+
+ aucBuffer[RX8010_REG_SEC - 0x10] = __rx8010BinToBcd(tmNow.tm_sec);
+ aucBuffer[RX8010_REG_MIN - 0x10] = __rx8010BinToBcd(tmNow.tm_min);
+ aucBuffer[RX8010_REG_HOUR - 0x10] = __rx8010BinToBcd(tmNow.tm_hour);
+ /* only 24hr time */
+ aucBuffer[RX8010_REG_MDAY - 0x10] = __rx8010BinToBcd(tmNow.tm_mday);
+ aucBuffer[RX8010_REG_MONTH -0x10] = __rx8010BinToBcd(tmNow.tm_mon + 1);
+ aucBuffer[RX8010_REG_YEAR - 0x10] = __rx8010BinToBcd(tmNow.tm_year % 100);
+ aucBuffer[RX8010_REG_WDAY - 0x10] = __rx8010BinToBcd(tmNow.tm_wday + 1);
+
+ __rx8010TimeSet(pRtcControler->RTCC_pI2cDevice, aucBuffer);
+
+ /*
+ * clear STOP bit after changing clock/calendar
+ */
+ __rx8010RegReadS(pRtcControler->RTCC_pI2cDevice, RX8010_REG_CTRL, 1, &ucCtrl);
+ ucCtrl &= ~RX8010_BIT_CTRL_STOP;
+ __rx8010RegWrite(pRtcControler->RTCC_pI2cDevice, RX8010_REG_CTRL, ucCtrl);
+
+ return (ERROR_NONE);
+}
+/*********************************************************************************************************
+** 函数名称: __rx8010RtcGetTime
+** 功能描述: 获取 RTC 时间
+** 输 入 : pRtcFuncs RTC 驱动程序
+** pTimeNow 当前时间
+** 输 出 : ERROR_CODE
+** 全局变量:
+** 调用模块:
+**
+*********************************************************************************************************/
+static INT __rx8010RtcGetTime (PLW_RTC_FUNCS pRtcFuncs, time_t *pTimeNow)
+{
+ __PRX8010_RTC_CONTROLER pRtcControler = &_G_rx8010RtcControlers[0];
+ struct tm tmNow;
+ UINT8 ucValue;
+ UINT8 ucMonth;
+ UINT8 aucBuffer[7];
+
+ __rx8010TimeGet(pRtcControler->RTCC_pI2cDevice, aucBuffer);
+
+ ucValue = aucBuffer[RX8010_REG_SEC - 0x10];
+ tmNow.tm_sec = __rx8010BcdToBin(ucValue & 0x7F);
+
+ ucValue = aucBuffer[RX8010_REG_MIN - 0x10];
+ tmNow.tm_min = __rx8010BcdToBin(ucValue & 0x7F);
+
+ ucValue = aucBuffer[RX8010_REG_HOUR - 0x10];
+ tmNow.tm_hour = __rx8010BcdToBin(ucValue & 0x3F);
+
+ ucValue = aucBuffer[RX8010_REG_WDAY - 0x10];
+ tmNow.tm_wday = __rx8010BcdToBin(ucValue & 0x7) - 1;
+
+ ucValue = aucBuffer[RX8010_REG_MDAY - 0x10];
+ tmNow.tm_mday = __rx8010BcdToBin(ucValue & 0x3F);
+
+ ucMonth = aucBuffer[RX8010_REG_MONTH - 0x10];
+ tmNow.tm_mon = __rx8010BcdToBin(ucMonth & 0x1F) - 1;
+
+ ucValue = aucBuffer[RX8010_REG_YEAR - 0x10];
+ tmNow.tm_year = __rx8010BcdToBin(ucValue) + 100;
+
+ tmNow.tm_yday = 0;
+ tmNow.tm_isdst = 0;
+
+ if (pTimeNow) {
+ *pTimeNow = timegm(&tmNow);
+ }
+
+ return (ERROR_NONE);
+}
+/*********************************************************************************************************
+** 函数名称: __rx8010Init
+** 功能描述: 初始化 RTC 设备
+** 输 入 : PLW_I2C_DEVICE I2C 控制器
+** 输 出 : NONE
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+static INT __rx8010Init (PLW_I2C_DEVICE pI2cDev)
+{
+ /*
+ * set reserved register 0x17 with specified value of 0xD8
+ */
+ __rx8010RegWrite(pI2cDev, 0x17, 0xD8);
+
+ /*
+ * set reserved register 0x30 with specified value of 0x00
+ */
+ __rx8010RegWrite(pI2cDev, 0x30, 0x00);
+
+ /*
+ * set reserved register 0x31 with specified value of 0x08
+ */
+ __rx8010RegWrite(pI2cDev, 0x30, 0x08);
+ __rx8010RegWrite(pI2cDev, 0x1D, 0x04);
+ __rx8010RegWrite(pI2cDev, 0x1E, 0x00);
+ __rx8010RegWrite(pI2cDev, 0x1F, 0x40);
+
+ /*
+ * set present time
+ */
+ __rx8010RegWrite(pI2cDev, 0x1F, 0x00);
+
+ return (ERROR_NONE);
+}
+/*********************************************************************************************************
+** 函数名称: __rx8010RtcInit
+** 功能描述: 初始化 RTC 设备
+** 输 入 : NONE
+** 输 出 : NONE
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+static VOID __rx8010RtcInit (VOID)
+{
+ __PRX8010_RTC_CONTROLER pRtcControler = &_G_rx8010RtcControlers[0];
+
+ if (!pRtcControler->RTCC_pI2cDevice) {
+ pRtcControler->RTCC_pI2cDevice = API_I2cDeviceCreate(pRtcControler->RTCC_pcI2cBusName,
+ "/dev/rtc",
+ RX8010_SLAVE_ADDR,
+ 0);
+ if (pRtcControler->RTCC_pI2cDevice) {
+ __rx8010Init(pRtcControler->RTCC_pI2cDevice);
+ }
+ }
+}
+/*********************************************************************************************************
+ DS1337 RTC 驱动程序
+*********************************************************************************************************/
+static LW_RTC_FUNCS _G_rx8010tcFuncs = {
+ __rx8010RtcInit,
+ __rx8010RtcSetTime,
+ __rx8010RtcGetTime,
+ LW_NULL
+};
+/*********************************************************************************************************
+** 函数名称: rx8010RtcGetFuncs
+** 功能描述: 获取 RTC 驱动程序
+** 输 入 : NONE
+** 输 出 : RTC 驱动程序
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+PLW_RTC_FUNCS rx8010RtcGetFuncs (CPCHAR pcI2cBusName)
+{
+ _G_rx8010RtcControlers[0].RTCC_pcI2cBusName = pcI2cBusName;
+
+ return (&_G_rx8010tcFuncs);
+}
+/*********************************************************************************************************
+ END
+*********************************************************************************************************/
diff --git a/SylixOS/driver/ds1337/rx8010.h b/SylixOS/driver/ds1337/rx8010.h
new file mode 100644
index 0000000..6349f73
--- /dev/null
+++ b/SylixOS/driver/ds1337/rx8010.h
@@ -0,0 +1,37 @@
+/*********************************************************************************************************
+**
+** 中国软件开源组织
+**
+** 嵌入式实时操作系统
+**
+** SylixOS(TM)
+**
+** Copyright All Rights Reserved
+**
+**--------------文件信息--------------------------------------------------------------------------------
+**
+** 文 件 名: ds1337.h
+**
+** 创 建 人: Jiao.JinXing (焦进星)
+**
+** 文件创建日期: 2016 年 12 月 5 日
+**
+** 描 述: RX8010 RTC 驱动
+*********************************************************************************************************/
+#ifndef RX8010_H_
+#define RX8010_H_
+
+/*********************************************************************************************************
+** 函数名称: rx8010RtcGetFuncs
+** 功能描述: 获取 RTC 驱动程序
+** 输 入 : NONE
+** 输 出 : RTC 驱动程序
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+PLW_RTC_FUNCS rx8010RtcGetFuncs(CPCHAR pcI2cBusName);
+
+#endif /* DSRX8010_H_ */
+/*********************************************************************************************************
+ END
+*********************************************************************************************************/
diff --git a/SylixOS/driver/ecap/am335x_ecap.c b/SylixOS/driver/ecap/am335x_ecap.c
index 1e33ba4..83ab96f 100644
--- a/SylixOS/driver/ecap/am335x_ecap.c
+++ b/SylixOS/driver/ecap/am335x_ecap.c
@@ -197,7 +197,7 @@ static LONG __am335xECapOpen (PLW_DEV_HDR pDev,
}
if (pFdNode) {
- API_IosFdNodeDec(&pECapChannel->ECAPCHAN_fdNodeHeader, pFdNode);
+ API_IosFdNodeDec(&pECapChannel->ECAPCHAN_fdNodeHeader, pFdNode, LW_NULL);
pFdNode = LW_NULL;
}
@@ -220,7 +220,7 @@ static INT __am335xECapClose (PLW_FD_ENTRY pFdEntry)
PLW_FD_NODE pFdNode = (PLW_FD_NODE)pFdEntry->FDENTRY_pfdnode;
if (pFdEntry && pFdNode) {
- API_IosFdNodeDec(&pECapChannel->ECAPCHAN_fdNodeHeader, pFdNode);
+ API_IosFdNodeDec(&pECapChannel->ECAPCHAN_fdNodeHeader, pFdNode, LW_NULL);
if (LW_DEV_DEC_USE_COUNT(&pECapChannel->ECAPCHAN_devHdr) == 0) {
diff --git a/SylixOS/driver/ft5x06/ft5x06.c b/SylixOS/driver/ft5x06/ft5x06.c
index 0681314..0897905 100644
--- a/SylixOS/driver/ft5x06/ft5x06.c
+++ b/SylixOS/driver/ft5x06/ft5x06.c
@@ -440,7 +440,7 @@ static LONG __ft5x06Open (PLW_DEV_HDR pDev,
__ft5x06DeInit(pFt5x06TouchDev);
if (pFdNode) {
- API_IosFdNodeDec(&pFt5x06TouchDev->FT5X06_fdNodeHeader, pFdNode);
+ API_IosFdNodeDec(&pFt5x06TouchDev->FT5X06_fdNodeHeader, pFdNode, LW_NULL);
pFdNode = LW_NULL;
}
@@ -462,7 +462,7 @@ static INT __ft5x06Close (PLW_FD_ENTRY pFdEntry)
PLW_FD_NODE pFdNode = (PLW_FD_NODE)pFdEntry->FDENTRY_pfdnode;
if (pFdEntry && pFdNode) {
- API_IosFdNodeDec(&pFt5x06TouchDev->FT5X06_fdNodeHeader, pFdNode);
+ API_IosFdNodeDec(&pFt5x06TouchDev->FT5X06_fdNodeHeader, pFdNode, LW_NULL);
API_InterVectorDisable(pFt5x06TouchDev->FT5X06_ulVector);
API_InterVectorDisconnect((ULONG)pFt5x06TouchDev->FT5X06_ulVector,
diff --git a/SylixOS/driver/i2c/am335x_i2c.c b/SylixOS/driver/i2c/am335x_i2c.c
index d979089..f8b6f39 100644
--- a/SylixOS/driver/i2c/am335x_i2c.c
+++ b/SylixOS/driver/i2c/am335x_i2c.c
@@ -35,15 +35,70 @@
#define __I2C_INTERNAL_CLK_12MHZ (12000000)
#define __I2C_BUS_FREQ_MAX (400)
#define __I2C_BUS_FREQ_MIN (100)
+
+/*
+ * I2C Status Register (I2C_STAT):
+ */
+#define I2C_STAT_BB (1 << 12) /* Bus busy */
+#define I2C_STAT_ROVR (1 << 11) /* Receive overrun */
+#define I2C_STAT_XUDF (1 << 10) /* Transmit underflow */
+#define I2C_STAT_AAS (1 << 9) /* Address as slave */
+#define I2C_STAT_BF (1 << 8)
+#define I2C_STAT_GC (1 << 5)
+#define I2C_STAT_XRDY (1 << 4) /* Transmit data ready */
+#define I2C_STAT_RRDY (1 << 3) /* Receive data ready */
+#define I2C_STAT_ARDY (1 << 2) /* Register access ready */
+#define I2C_STAT_NACK (1 << 1) /* No acknowledgment interrupt enable */
+#define I2C_STAT_AL (1 << 0) /* Arbitration lost interrupt enable */
+
+/*
+ * I2C Interrupt Enable Register (I2C_IE):
+ */
+#define I2C_IE_BF_IE (1 << 8)
+#define I2C_IE_GC_IE (1 << 5)
+#define I2C_IE_XRDY_IE (1 << 4) /* Transmit data ready interrupt enable */
+#define I2C_IE_RRDY_IE (1 << 3) /* Receive data ready interrupt enable */
+#define I2C_IE_ARDY_IE (1 << 2) /* Register access ready interrupt enable */
+#define I2C_IE_NACK_IE (1 << 1) /* No acknowledgment interrupt enable */
+#define I2C_IE_AL_IE (1 << 0) /* Arbitration lost interrupt enable */
+
+#define I2C_TIMEOUT (1<<16)
+
+#define I2C_WAIT_TICK 3000
+
+#define CHECK_NACK(iStat) \
+ do { \
+ if (iStat & I2C_STAT_NACK) { \
+ I2CMasterStop(pI2cChannel->I2CCHAN_ulVirtAddrBase); \
+ printk(KERN_ERR "checked I2C_STA_NACK \n"); \
+ return (PX_ERROR); \
+ } \
+ } while(0)
+
+#define I2C_INTERRUPT_WAIT_STAT() \
+ do { \
+ uiError = API_SemaphoreBPend(pI2cChannel->I2CCHAN_hSignal, I2C_WAIT_TICK); \
+ if (uiError != ERROR_NONE) { \
+ printk(KERN_ERR " I2C_INTERRUPT_WAIT_STAT API_SemaphoreBPend error\n"); \
+ return (PX_ERROR); \
+ } \
+ } while(0)
+
+#define I2C_INTERRUPT_SET(X) \
+ I2CMasterIntEnableEx(pI2cChannel->I2CCHAN_ulVirtAddrBase, \
+ I2C_IE_AL_IE | I2C_IE_NACK_IE | \
+ I2C_IE_GC_IE | X)
/*********************************************************************************************************
i2c 通道类型定义
*********************************************************************************************************/
typedef struct {
addr_t I2CCHAN_ulPhyAddrBase; /* 物理地址基地址 */
size_t I2CCHAN_stPhyAddrSize; /* 物理地址空间大小 */
- UINT I2CCHAN_uiTxDmaChannel;
- UINT I2CCHAN_uiRxDmaChannel;
+ ULONG I2CCHAN_ulVector; /* 中断向量 */
+ UINT I2CCHAN_uiIntPriority; /* 中断优先级 */
UINT I2CCHAN_uiBusFreq;
+ UINT I2CCHAN_uiIntStat; /* 中断状态 */
+ UINT I2CCHAN_uiMask;
addr_t I2CCHAN_ulVirtAddrBase; /* 虚拟地址基地址 */
LW_HANDLE I2CCHAN_hSignal; /* 同步信号量 */
@@ -58,87 +113,73 @@ static __AM335X_I2C_CHANNEL _G_am335xI2cChannels[__I2C_CHANNEL_NR] = {
{
SOC_I2C_0_REGS,
LW_CFG_VMM_PAGE_SIZE,
- EDMA3_CHA_I2C0_TX,
- EDMA3_CHA_I2C0_RX,
+ SYS_INT_I2C0INT,
+ BSP_CFG_I2C0_INT_PRIO,
__I2C_BUS_FREQ_MIN,
},
{
SOC_I2C_1_REGS,
LW_CFG_VMM_PAGE_SIZE,
- EDMA3_CHA_I2C1_TX,
- EDMA3_CHA_I2C1_RX,
+ SYS_INT_I2C1INT,
+ BSP_CFG_I2C1_INT_PRIO,
__I2C_BUS_FREQ_MIN,
},
{
SOC_I2C_2_REGS,
LW_CFG_VMM_PAGE_SIZE,
- EDMA3_CHA_I2C2_TX,
- EDMA3_CHA_I2C2_RX,
+ SYS_INT_I2C2INT,
+ BSP_CFG_I2C2_INT_PRIO,
__I2C_BUS_FREQ_MIN,
}
};
/*********************************************************************************************************
-** 函数名称: __am335xI2cAllocBuffer
-** 功能描述: 分配 i2c 缓冲区
-** 输 入 : pI2cChannel i2c 通道
-** uiLen 缓冲区长度
-** 输 出 : ERROR_CODE
+** 函数名称: __am335xI2cIrqPoll
+** 功能描述: i2c 状态查询函数
+** 输 入 : uiBaseAddr 寄存器基地址
+** iMask 检查状态位
+** 输 出 : NONE
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-static INT __am335xI2cAllocBuffer (__PAM335X_I2C_CHANNEL pI2cChannel,
- UINT uiLen)
+static UINT __am335xI2cIrqPoll (UINT uiBaseAddr, UINT iMask)
{
- ULONG ulPageNum;
- size_t stExcess;
-
- if (pI2cChannel->I2CCHAN_uiBufferLen < uiLen) {
- if (pI2cChannel->I2CCHAN_pucBuffer) {
- API_VmmDmaFree(pI2cChannel->I2CCHAN_pucBuffer);
- pI2cChannel->I2CCHAN_pucBuffer = LW_NULL;
- pI2cChannel->I2CCHAN_uiBufferLen = 0;
- }
-
- ulPageNum = (ULONG) (uiLen >> LW_CFG_VMM_PAGE_SHIFT);
- stExcess = (size_t)(uiLen & ~LW_CFG_VMM_PAGE_MASK);
+ UINT iStat = 0, iTimeout;
- if (stExcess) {
- ulPageNum++;
+ for (iTimeout = 0; iTimeout < 10; iTimeout++) {
+ iStat = I2CMasterIntStatus(uiBaseAddr);
+ if (iStat & iMask) {
+ return (iStat);
}
+ bspDelayUs(1000);
+ }
- uiLen = ulPageNum * LW_CFG_VMM_PAGE_SIZE;
+ I2CMasterIntClearEx(uiBaseAddr, 0x7fff);
- pI2cChannel->I2CCHAN_pucBuffer = API_VmmDmaAlloc(uiLen);
- if (pI2cChannel->I2CCHAN_pucBuffer) {
- pI2cChannel->I2CCHAN_uiBufferLen = uiLen;
- return (ERROR_NONE);
- } else {
- return (PX_ERROR);
- }
- } else {
- return (ERROR_NONE);
- }
+ return (iStat | I2C_TIMEOUT);
}
+
+
/*********************************************************************************************************
-** 函数名称: __am335xI2cDmaDone
-** 功能描述: i2c DMA 完成回调函数
-** 输 入 : uiChannel i2c DMA 通道号
-** pvArg 参数
-** 输 出 : NONE
+** 函数名称: __am335xI2cIsr
+** 功能描述: I2C 通道中断服务例程
+** 输 入 : pI2cChannel I2C 通道
+** ulVector 中断向量
+** 输 出 : 中断返回值
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-static VOID __am335xI2cDmaDone (UINT uiChannel, PVOID pvArg)
+static irqreturn_t __am335xI2cIsr (__PAM335X_I2C_CHANNEL pI2cChannel, ULONG ulVector)
{
- __PAM335X_I2C_CHANNEL pI2cChannel = pvArg;
-
- /* Disable the transmit event */
- I2CDMATxEventDisable(pI2cChannel->I2CCHAN_ulVirtAddrBase);
-
- /* Disable the transmit event */
- I2CDMARxEventDisable(pI2cChannel->I2CCHAN_ulVirtAddrBase);
-
- API_SemaphoreBPost(pI2cChannel->I2CCHAN_hSignal);
+ pI2cChannel->I2CCHAN_uiIntStat = I2CMasterIntStatus(pI2cChannel->I2CCHAN_ulVirtAddrBase);
+ /* 获取中断状态 */
+ I2CMasterIntDisableEx(pI2cChannel->I2CCHAN_ulVirtAddrBase,
+ I2C_IE_AL_IE | I2C_IE_NACK_IE |
+ I2C_IE_ARDY_IE | I2C_IE_RRDY_IE |
+ I2C_IE_XRDY_IE | I2C_IE_GC_IE); /* 禁止相应中断位 */
+ I2CMasterIntClearEx(pI2cChannel->I2CCHAN_ulVirtAddrBase, 0x7fff); /* 清除中断状态 */
+ API_SemaphoreBPost(pI2cChannel->I2CCHAN_hSignal); /* 释放同步信号 */
+
+ return (LW_IRQ_HANDLED);
}
/*********************************************************************************************************
** 函数名称: __am335xI2cTransferMsg
@@ -156,117 +197,87 @@ static INT __am335xI2cTransferMsg (__PAM335X_I2C_CHANNEL pI2cChannel,
BOOL bIsFirstMsg,
BOOL bIsLastMsg)
{
- LW_DMA_TRANSACTION dmaTransAction;
- INT iError;
+ INT i;
+ UINT uiError;
if (pI2cMsg->I2CMSG_usFlag & LW_I2C_M_RD) {
- __am335xI2cAllocBuffer(pI2cChannel, pI2cMsg->I2CMSG_usLen);
-
- lib_memset(&dmaTransAction, 0, sizeof(dmaTransAction));
-
- dmaTransAction.DMAT_pucSrcAddress = (UINT8 *)(pI2cChannel->I2CCHAN_ulPhyAddrBase + I2C_DATA);
- dmaTransAction.DMAT_iSrcAddrCtl = LW_DMA_ADDR_FIX;
-
- dmaTransAction.DMAT_pucDestAddress = pI2cChannel->I2CCHAN_pucBuffer;
- dmaTransAction.DMAT_iDestAddrCtl = LW_DMA_ADDR_INC;
-
- dmaTransAction.DMAT_iTransMode = EDMA3_MAKE_TARNS_MODE(EDMA3_TARNS_MODE_A_SYNC,
- EDMA3_TARNS_MODE_TRIG_MODE_EVENT,
- EDMA3_TARNS_MODE_TX_DUMMY_DISABLE,
- EDMA3_TARNS_MODE_LINK_INVALID,
- 0);
-
- dmaTransAction.DMAT_ulOption = EDMA3_MAKE_OPTION(1, pI2cMsg->I2CMSG_usLen);
-
- dmaTransAction.DMAT_stDataBytes = pI2cMsg->I2CMSG_usLen;
-
- dmaTransAction.DMAT_pfuncCallback = __am335xI2cDmaDone;
- dmaTransAction.DMAT_pvArg = (PVOID *)pI2cChannel;
-
- iError = API_DmaJobAdd(pI2cChannel->I2CCHAN_uiRxDmaChannel, &dmaTransAction);
- if (iError != ERROR_NONE) {
- return (iError);
- }
-
/* Data Count specifies the number of bytes to be received. */
I2CSetDataCount(pI2cChannel->I2CCHAN_ulVirtAddrBase, pI2cMsg->I2CMSG_usLen);
- /* Configure I2C controller in Master Receiver mode */
- I2CMasterControl(pI2cChannel->I2CCHAN_ulVirtAddrBase, I2C_CFG_MST_RX);
-
- API_SemaphoreBClear(pI2cChannel->I2CCHAN_hSignal);
+ /* Set I2C slave address. */
+ I2CMasterSlaveAddrSet(pI2cChannel->I2CCHAN_ulVirtAddrBase, pI2cMsg->I2CMSG_usAddr);
- /* I2C Receive Event is Enable */
- I2CDMARxEventEnable(pI2cChannel->I2CCHAN_ulVirtAddrBase);
+ /* Configure I2C controller in Master Receiver mode */
+ I2CMasterControl(pI2cChannel->I2CCHAN_ulVirtAddrBase, I2C_CFG_MST_RX );
- /* Generate Start Condition over I2C bus */
+ /*
+ * STT = 1, STP = 1, Conditions = Start-Stop (DCOUNT=n), Bus
+ * Activities = S-A-D..(n)..D-P.
+ */
I2CMasterStart(pI2cChannel->I2CCHAN_ulVirtAddrBase);
-
- if (ERROR_NONE != API_SemaphoreBPend(pI2cChannel->I2CCHAN_hSignal, 3 * LW_OPTION_WAIT_A_SECOND)) {
- printk(KERN_ERR "__am335xI2cTransferMsg(): TIMEOUT\n");
- return (PX_ERROR);
- }
-
I2CMasterStop(pI2cChannel->I2CCHAN_ulVirtAddrBase);
- while (I2CMasterBusBusy(pI2cChannel->I2CCHAN_ulVirtAddrBase)) {
+ for (i = 0; i < pI2cMsg->I2CMSG_usLen; i++) {
+ /*
+ * 检查NACK, RRDY中断
+ */
+ I2C_INTERRUPT_SET(I2C_IE_RRDY_IE);
+ I2C_INTERRUPT_WAIT_STAT();
+ CHECK_NACK(pI2cChannel->I2CCHAN_uiIntStat);
+ /*
+ * 检查到中断,等待保证数据寄存器更新最新
+ */
+ bspDelayUs(200);
+
+ if(pI2cChannel->I2CCHAN_uiIntStat & I2C_STAT_RRDY) {
+ pI2cMsg->I2CMSG_pucBuffer[i] =
+ I2CMasterDataGet(pI2cChannel->I2CCHAN_ulVirtAddrBase);
+ } else {
+ printk(KERN_ERR "NO CHECK I2C_STAT_RRDY state\n");
+ return (PX_ERROR);
+ }
}
-
- lib_memcpy(pI2cMsg->I2CMSG_pucBuffer, pI2cChannel->I2CCHAN_pucBuffer, pI2cMsg->I2CMSG_usLen);
+ __am335xI2cIrqPoll(pI2cChannel->I2CCHAN_ulVirtAddrBase, I2C_STAT_ARDY);
} else {
-
- __am335xI2cAllocBuffer(pI2cChannel, pI2cMsg->I2CMSG_usLen);
-
- lib_memcpy(pI2cChannel->I2CCHAN_pucBuffer, pI2cMsg->I2CMSG_pucBuffer, pI2cMsg->I2CMSG_usLen);
-
- lib_memset(&dmaTransAction, 0, sizeof(dmaTransAction));
-
- dmaTransAction.DMAT_pucSrcAddress = pI2cChannel->I2CCHAN_pucBuffer;
- dmaTransAction.DMAT_iSrcAddrCtl = LW_DMA_ADDR_INC;
-
- dmaTransAction.DMAT_pucDestAddress = (UINT8 *)(pI2cChannel->I2CCHAN_ulPhyAddrBase + I2C_DATA);
- dmaTransAction.DMAT_iDestAddrCtl = LW_DMA_ADDR_FIX;
-
- dmaTransAction.DMAT_iTransMode = EDMA3_MAKE_TARNS_MODE(EDMA3_TARNS_MODE_A_SYNC,
- EDMA3_TARNS_MODE_TRIG_MODE_EVENT,
- EDMA3_TARNS_MODE_TX_DUMMY_DISABLE,
- EDMA3_TARNS_MODE_LINK_INVALID,
- 0);
-
- dmaTransAction.DMAT_ulOption = EDMA3_MAKE_OPTION(1, pI2cMsg->I2CMSG_usLen);
-
- dmaTransAction.DMAT_stDataBytes = pI2cMsg->I2CMSG_usLen;
-
- dmaTransAction.DMAT_pfuncCallback = __am335xI2cDmaDone;
- dmaTransAction.DMAT_pvArg = (PVOID *)pI2cChannel;
-
- iError = API_DmaJobAdd(pI2cChannel->I2CCHAN_uiTxDmaChannel, &dmaTransAction);
- if (iError != ERROR_NONE) {
- return (iError);
- }
-
/* Data Count specifies the number of bytes to be received. */
I2CSetDataCount(pI2cChannel->I2CCHAN_ulVirtAddrBase, pI2cMsg->I2CMSG_usLen);
- /* Configure I2C controller in Master Transmitter mode */
- I2CMasterControl(pI2cChannel->I2CCHAN_ulVirtAddrBase, I2C_CFG_MST_TX);
-
- API_SemaphoreBClear(pI2cChannel->I2CCHAN_hSignal);
+ /* Set I2C slave address. */
+ I2CMasterSlaveAddrSet(pI2cChannel->I2CCHAN_ulVirtAddrBase, pI2cMsg->I2CMSG_usAddr);
- /* I2C Transmit Event is Enable */
- I2CDMATxEventEnable(pI2cChannel->I2CCHAN_ulVirtAddrBase);
+ /* Configure I2C controller in Master Receiver mode */
+ I2CMasterControl(pI2cChannel->I2CCHAN_ulVirtAddrBase, I2C_CFG_MST_TX );
- /* Generate Start Condition over I2C bus */
+ /*
+ * STT = 1, STP = 1, Conditions = Start-Stop (DCOUNT=n), Bus
+ * Activities = S-A-D..(n)..D-P.
+ */
I2CMasterStart(pI2cChannel->I2CCHAN_ulVirtAddrBase);
-
- if (ERROR_NONE != API_SemaphoreBPend(pI2cChannel->I2CCHAN_hSignal, 3 * LW_OPTION_WAIT_A_SECOND)) {
- printk(KERN_ERR "__am335xI2cTransferMsg(): TIMEOUT\n");
- return (PX_ERROR);
- }
-
I2CMasterStop(pI2cChannel->I2CCHAN_ulVirtAddrBase);
- while (I2CMasterBusBusy(pI2cChannel->I2CCHAN_ulVirtAddrBase)) {
+ for (i = 0; i < pI2cMsg->I2CMSG_usLen; i++) {
+ /*
+ * 检查NACK, XRDY中断
+ */
+ I2C_INTERRUPT_SET(I2C_IE_XRDY_IE);
+ I2C_INTERRUPT_WAIT_STAT();
+ CHECK_NACK(pI2cChannel->I2CCHAN_uiIntStat);
+
+ if(pI2cChannel->I2CCHAN_uiIntStat & I2C_STAT_XRDY) {
+ I2CMasterDataPut(pI2cChannel->I2CCHAN_ulVirtAddrBase,
+ pI2cMsg->I2CMSG_pucBuffer[i]);
+ } else {
+ printk(KERN_ERR "NO CHECK I2C_STAT_XRDY\n");
+ return (PX_ERROR);
+ }
+ /*
+ * 检查到中断,保证数据寄存器当前字节传输结束
+ */
+ bspDelayUs(200);
}
+
+ I2C_INTERRUPT_SET(I2C_IE_ARDY_IE);
+ I2C_INTERRUPT_WAIT_STAT();
+ CHECK_NACK(pI2cChannel->I2CCHAN_uiIntStat);
}
return (ERROR_NONE);
@@ -327,6 +338,10 @@ static INT __am335xI2cTryTransfer (__PAM335X_I2C_CHANNEL pI2cChannel,
}
}
+ I2CMasterDisable(pI2cChannel->I2CCHAN_ulVirtAddrBase);
+ I2CMasterStop(pI2cChannel->I2CCHAN_ulVirtAddrBase);
+ I2CMasterIntClearEx(pI2cChannel->I2CCHAN_ulVirtAddrBase, 0x7fff);
+
return (i);
}
/*********************************************************************************************************
@@ -433,9 +448,9 @@ static INT __am335xI2cMasterCtl (__PAM335X_I2C_CHANNEL pI2cChannel,
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-static INT __am335xI2c0MasterCtl(PLW_I2C_ADAPTER pI2cAdapter,
- INT iCmd,
- LONG lArg)
+static INT __am335xI2c0MasterCtl (PLW_I2C_ADAPTER pI2cAdapter,
+ INT iCmd,
+ LONG lArg)
{
return (__am335xI2cMasterCtl(&_G_am335xI2cChannels[0], pI2cAdapter, iCmd, lArg));
}
@@ -449,9 +464,9 @@ static INT __am335xI2c0MasterCtl(PLW_I2C_ADAPTER pI2cAdapter,
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-static INT __am335xI2c1MasterCtl(PLW_I2C_ADAPTER pI2cAdapter,
- INT iCmd,
- LONG lArg)
+static INT __am335xI2c1MasterCtl (PLW_I2C_ADAPTER pI2cAdapter,
+ INT iCmd,
+ LONG lArg)
{
return (__am335xI2cMasterCtl(&_G_am335xI2cChannels[1], pI2cAdapter, iCmd, lArg));
}
@@ -465,12 +480,13 @@ static INT __am335xI2c1MasterCtl(PLW_I2C_ADAPTER pI2cAdapter,
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-static INT __am335xI2c2MasterCtl(PLW_I2C_ADAPTER pI2cAdapter,
- INT iCmd,
- LONG lArg)
+static INT __am335xI2c2MasterCtl (PLW_I2C_ADAPTER pI2cAdapter,
+ INT iCmd,
+ LONG lArg)
{
return (__am335xI2cMasterCtl(&_G_am335xI2cChannels[2], pI2cAdapter, iCmd, lArg));
}
+
/*********************************************************************************************************
** 函数名称: __am335xI2cHwInit
** 功能描述: 初始化 i2c 硬件通道
@@ -479,7 +495,7 @@ static INT __am335xI2c2MasterCtl(PLW_I2C_ADAPTER pI2cAdapter,
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-static INT __am335xI2cHwInit(__PAM335X_I2C_CHANNEL pI2cChannel, PAM335X_PINMUX pPinMux)
+static INT __am335xI2cHwInit (__PAM335X_I2C_CHANNEL pI2cChannel, PAM335X_PINMUX pPinMux)
{
UINT uiChannel = pI2cChannel - &_G_am335xI2cChannels[0];
@@ -516,8 +532,14 @@ static INT __am335xI2cHwInit(__PAM335X_I2C_CHANNEL pI2cChannel, PAM335X_PINMUX
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-static INT __am335xI2cInit(__PAM335X_I2C_CHANNEL pI2cChannel, PAM335X_PINMUX pPinMux)
+static INT __am335xI2cInit (__PAM335X_I2C_CHANNEL pI2cChannel, PAM335X_PINMUX pPinMux)
{
+
+ CHAR cName[64];
+ UINT uiChannel;
+
+ uiChannel = pI2cChannel - _G_am335xI2cChannels;
+
if (!pI2cChannel->I2CCHAN_bIsInit) {
pI2cChannel->I2CCHAN_ulVirtAddrBase = (addr_t)API_VmmIoRemapNocache(
@@ -536,15 +558,21 @@ static INT __am335xI2cInit(__PAM335X_I2C_CHANNEL pI2cChannel, PAM335X_PINMUX
goto __error_handle;
}
- __am335xI2cAllocBuffer(pI2cChannel, 4096);
-
if (__am335xI2cHwInit(pI2cChannel, pPinMux) != ERROR_NONE) {
printk(KERN_ERR "__am335xI2cInit(): failed to init!\n");
goto __error_handle;
}
- API_DmaReset(pI2cChannel->I2CCHAN_uiTxDmaChannel);
- API_DmaReset(pI2cChannel->I2CCHAN_uiRxDmaChannel);
+ IntPrioritySet(pI2cChannel->I2CCHAN_ulVector,
+ pI2cChannel->I2CCHAN_uiIntPriority,
+ AINTC_HOSTINT_ROUTE_IRQ);
+ snprintf(cName, sizeof(cName), "i2c%d_par_isr", uiChannel);
+ API_InterVectorConnect(pI2cChannel->I2CCHAN_ulVector,
+ (PINT_SVR_ROUTINE)__am335xI2cIsr,
+ (PVOID)pI2cChannel,
+ cName); /* 安装操作系统中断向量表 */
+
+ API_InterVectorEnable(pI2cChannel->I2CCHAN_ulVector);
pI2cChannel->I2CCHAN_bIsInit = LW_TRUE;
}
diff --git a/SylixOS/driver/netif/am335x_cpsw.c b/SylixOS/driver/netif/am335x_cpsw.c
index 2d6f5a7..c722a59 100644
--- a/SylixOS/driver/netif/am335x_cpsw.c
+++ b/SylixOS/driver/netif/am335x_cpsw.c
@@ -17,75 +17,113 @@
** 文件创建日期: 2015 年 01 月 21 日
**
** 描 述: AM335X 处理器 CPSW 驱动
+Debug:
+2016.11.24 修改为最新与netif无关架构 by:胡瀚璋
*********************************************************************************************************/
#define __SYLIXOS_KERNEL
#include "config.h"
#include "SylixOS.h"
+#include <linux/compat.h>
+#include "netdev.h"
-#include "driver/am335x_common.h"
+#include "../am335x_common.h"
#include "cpswif.h"
#include "lwiplib.h"
#include "am335x_cpsw.h"
+#include "debug.h"
/*********************************************************************************************************
外部函数
*********************************************************************************************************/
-extern int netio_main(int argc, char **argv);
-extern ULONG API_VmmMap(PVOID pvVirtualAddr,
- PVOID pvPhysicalAddr,
- size_t stSize,
- ULONG ulFlag);
+extern int netio_main(int argc, char **argv);
+extern ULONG API_VmmMap(PVOID pvVirtualAddr,
+ PVOID pvPhysicalAddr,
+ size_t stSize,
+ ULONG ulFlag);
+extern err_t cpswif_output(struct netdev *pNetdev, struct pbuf *p);
+extern INT cpswif_init(netdev_t *netdev);
+/*********************************************************************************************************
+ 函数声明
+*********************************************************************************************************/
+static VOID __am335xCpswRx(struct netdev *pNetdev, int (*input)(struct netdev *, struct pbuf *));
+static INT __am335xCpswTx(struct netdev *pNetdev, struct pbuf *pbuf);
+/*********************************************************************************************************
+ 宏定义
+*********************************************************************************************************/
+#define CPSW_IF_NAME "cpsw0"
/*********************************************************************************************************
全局变量
*********************************************************************************************************/
__AM335X_CPSW_CONTROLER _G_am335xCpswControlers[MAX_CPSW_INST] = {
{
- SOC_CPSW_SS_REGS,
- LW_CFG_VMM_PAGE_SIZE,
+ .CPSWC_ulCpswSsPhyAddrBase = SOC_CPSW_SS_REGS,
+ .CPSWC_stCpswSsPhyAddrSize = LW_CFG_VMM_PAGE_SIZE,
- SOC_CPSW_MDIO_REGS,
- LW_CFG_VMM_PAGE_SIZE,
+ .CPSWC_ulCpswMidoPhyAddrBase = SOC_CPSW_MDIO_REGS,
+ .CPSWC_stCpswMidoPhyAddrSize = LW_CFG_VMM_PAGE_SIZE,
- SOC_CPSW_CPPI_RAM_REGS,
- 2 * LW_CFG_VMM_PAGE_SIZE,
+ .CPSWC_ulCpswCppiRamPhyAddrBase = SOC_CPSW_CPPI_RAM_REGS,
+ .CPSWC_stCpswCppiRamPhyAddrSize = 2 * LW_CFG_VMM_PAGE_SIZE,
- SYS_INT_3PGSWRXINT0,
- BSP_CFG_NETIF_RX_INT_PRIO,
+ .CPSWC_ulRxVector = SYS_INT_3PGSWRXINT0,
+ .CPSWC_uiRxIntPriority = BSP_CFG_NETIF_RX_INT_PRIO,
- SYS_INT_3PGSWTXINT0,
- BSP_CFG_NETIF_TX_INT_PRIO,
+ .CPSWC_ulTxVector = SYS_INT_3PGSWTXINT0,
+ .CPSWC_uiTxIntPriority = BSP_CFG_NETIF_TX_INT_PRIO,
- (ULONG)-1,
- BSP_CFG_NETIF_MISC_INT_PRIO,
+ .CPSWC_ulMiscVector = (ULONG)-1,
+ .CPSWC_uiMiscIntPriority = BSP_CFG_NETIF_MISC_INT_PRIO,
}
};
+
/*********************************************************************************************************
The lwIP network interface structure for CPSW ports.
*********************************************************************************************************/
#ifdef CPSW_DUAL_MAC_MODE
-static struct netif _G_am335xCpswNetIfs[MAX_CPSW_INST * MAX_SLAVEPORT_PER_INST];
static atomic_t _G_atomicAm335xCpswNetIfLinks[MAX_CPSW_INST * MAX_SLAVEPORT_PER_INST];
+struct netdev _G_am335xCpswNetDev[MAX_CPSW_INST * MAX_SLAVEPORT_PER_INST];
+struct netdev_funcs _G_am335xCpswNetDevFunc[MAX_CPSW_INST * MAX_SLAVEPORT_PER_INST] = {
+ {
+ .init = cpswif_init,
+ .transmit = __am335xCpswTx,
+ .receive = __am335xCpswRx,
+ },
+ {
+ .init = cpswif_init,
+ .transmit = __am335xCpswTx,
+ .receive = __am335xCpswRx,
+ },
+ };
#else
-static struct netif _G_am335xCpswNetIfs[MAX_CPSW_INST];
static atomic_t _G_atomicAm335xCpswNetIfLinks[MAX_CPSW_INST];
+struct netdev _G_am335xCpswNetDev[MAX_CPSW_INST];
+struct netdev_funcs _G_am335xCpswNetDevFunc[MAX_CPSW_INST] = {
+ {
+ .init = cpswif_init,
+ .transmit = __am335xCpswTx,
+ .receive = __am335xCpswRx,
+ },
+ };
#endif
/*********************************************************************************************************
Helper to identify ports
*********************************************************************************************************/
-typedef struct cpswportif __AM335X_CPSW_PORTIF, *__PAM335X_CPSW_PORTIF;
-static __AM335X_CPSW_PORTIF _G_am335xCpswPortIfs[MAX_CPSW_INST * MAX_SLAVEPORT_PER_INST];
+typedef struct cpswportif __AM335X_CPSW_PORTIF, *__PAM335X_CPSW_PORTIF;
+static __AM335X_CPSW_PORTIF _G_am335xCpswPortIfs[MAX_CPSW_INST * MAX_SLAVEPORT_PER_INST];
/*********************************************************************************************************
外部函数
*********************************************************************************************************/
-extern err_t cpswif_autoneg_config(struct netif *netif, u32_t inst_num, u32_t port_num);
+extern err_t cpswif_autoneg_config(u32_t inst_num,
+ u32_t port_num,
+ UINT32 *puiSpeed);
/*********************************************************************************************************
网络工作队列
*********************************************************************************************************/
-static LW_JOB_QUEUE _G_am335xTxNetJobQ;
-static LW_JOB_MSG _G_am335xTxNetJobMsgs[LW_CFG_LWIP_JOBQUEUE_SIZE];
+static LW_JOB_QUEUE _G_am335xTxNetJobQ;
+static LW_JOB_MSG _G_am335xTxNetJobMsgs[LW_CFG_LWIP_JOBQUEUE_SIZE];
/*********************************************************************************************************
INTERNAL FUNC
*********************************************************************************************************/
-static VOID __am335xTxNetJobThread(VOID); /* 作业处理程序 */
+static VOID __am335xTxNetJobThread(VOID); /* 作业处理程序 */
/*********************************************************************************************************
** 函数名称: __am335xTxNetJobqueueInit
** 功能描述: 初始化 Net jobqueue 处理 机制
@@ -104,15 +142,16 @@ static INT __am335xTxNetJobqueueInit (VOID)
return (PX_ERROR);
}
- API_ThreadAttrBuild(&threadattr, LW_CFG_LWIP_STK_SIZE,
+ API_ThreadAttrBuild(&threadattr,
+ LW_CFG_LWIP_STK_SIZE,
LW_PRIO_T_NETJOB,
- (LW_OPTION_THREAD_STK_CHK | LW_OPTION_THREAD_SAFE | LW_OPTION_OBJECT_GLOBAL),
+ (LW_OPTION_THREAD_STK_CHK | LW_OPTION_THREAD_SAFE | LW_OPTION_OBJECT_GLOBAL),
LW_NULL);
hNetJobThread = API_ThreadCreate("t_txnetjob",
(PTHREAD_START_ROUTINE)__am335xTxNetJobThread,
(PLW_CLASS_THREADATTR)&threadattr,
- LW_NULL); /* 建立 job 处理线程 */
+ LW_NULL); /* 建立 job 处理线程 */
if (!hNetJobThread) {
_jobQueueFinit(&_G_am335xTxNetJobQ);
return (PX_ERROR);
@@ -170,32 +209,46 @@ static VOID __am335xTxNetJobThread (VOID)
}
}
/*********************************************************************************************************
-** 函数名称: __am335xCpswRxJob
-** 功能描述: CPSW 接收工作
-** 输 入 : ulVector 中断向量
+** 函数名称: __am335xCpswTx
+** 功能描述: CPSW 发送
+** 输 入 : pNetdev netdev结构体
+** pbuf 协议栈数据
** 输 出 : NONE
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-static VOID __am335xCpswRxJob (ULONG ulVector)
+static INT __am335xCpswTx(struct netdev *pNetdev, struct pbuf *pbuf)
{
- cpswif_rx_inthandler(0, _G_am335xCpswNetIfs);
+ return cpswif_output(pNetdev, pbuf);
+}
+/*********************************************************************************************************
+** 函数名称: __am335xCpswRx
+** 功能描述: CPSW 接收
+** 输 入 : pNetdev netdev结构体
+** input 回报上层函数
+** 输 出 : NONE
+** 全局变量:
+** 调用模块:
+*********************************************************************************************************/
+static VOID __am335xCpswRx (struct netdev *pNetdev, int (*input) (struct netdev *, struct pbuf *))
+{
+ cpswif_rx_inthandler(0, pNetdev, input);
- API_InterVectorEnable(ulVector);
+ API_InterVectorEnable(_G_am335xCpswControlers[0].CPSWC_ulRxVector);
}
/*********************************************************************************************************
** 函数名称: __am335xCpswTxJob
** 功能描述: CPSW 发送工作
-** 输 入 : ulVector 中断向量
+** 输 入 : pNetdev netdev结构体
** 输 出 : NONE
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-static VOID __am335xCpswTxJob (ULONG ulVector)
+static VOID __am335xCpswTxJob (VOID)
{
- cpswif_tx_inthandler(0, _G_am335xCpswNetIfs);
+ cpswif_tx_inthandler(0, &_G_am335xCpswNetDev[0]);
- API_InterVectorEnable(ulVector);
+ API_InterVectorEnable(_G_am335xCpswControlers[0].CPSWC_ulTxVector);
}
/*********************************************************************************************************
** 函数名称: __am335xCpswRxIsr
@@ -210,7 +263,7 @@ static irqreturn_t __am335xCpswRxIsr (PVOID pvArg, ULONG ulVector)
{
API_InterVectorDisable(ulVector);
- API_NetJobAdd((VOIDFUNCPTR)__am335xCpswRxJob, (PVOID)ulVector, 0, 0, 0, 0, 0);
+ netdev_notify(&_G_am335xCpswNetDev[0], LINK_INPUT, 1);
return (LW_IRQ_HANDLED_DISV);
}
@@ -227,15 +280,15 @@ static irqreturn_t __am335xCpswTxIsr (PVOID pvArg, ULONG ulVector)
{
API_InterVectorDisable(ulVector);
- __am335xTxNetJobAdd((VOIDFUNCPTR)__am335xCpswTxJob, (PVOID)ulVector, 0, 0, 0, 0, 0);
+ __am335xTxNetJobAdd((VOIDFUNCPTR)__am335xCpswTxJob, 0, 0, 0, 0, 0, 0);
return (LW_IRQ_HANDLED_DISV);
}
/*********************************************************************************************************
** 函数名称: __am335xCpswMiscIsr
** 功能描述: CPSW MISC 中断服务例程
-** 输 入 : pvArg 参数
-** ulVector 中断向量
+** 输 入 : pvArg 参数
+** ulVector 中断向量
** 输 出 : 中断返回值
** 全局变量:
** 调用模块:
@@ -247,79 +300,72 @@ static irqreturn_t __am335xCpswMiscIsr (PVOID pvArg, ULONG ulVector)
/*********************************************************************************************************
** 函数名称: __am335xCpswLinkStatusCheck
** 功能描述: CPSW 连接状态检查
-** 输 入 : uiInstNum 实例号
-** uiSlavePortNum 从端口号
+** 输 入 : pNetdev netdev结构体
** 输 出 : NONE
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-static VOID __am335xCpswLinkStatusCheck (UINT uiInstNum, UINT uiSlavePortNum)
+static VOID __am335xCpswLinkStatusCheck (struct netdev *pNetdev)
{
+ UINT uiInstNum;
+ UINT uiSlavePortNum;
__PAM335X_CPSW_PORTIF pCpswPortIf;
- struct netif *pNetIf;
UINT uiNetIfNum;
atomic_t *pAtomicNetIfLink;
+ UINT32 uiSpeed;
+
+ pCpswPortIf = (__PAM335X_CPSW_PORTIF)pNetdev->priv;
+ uiInstNum = pCpswPortIf->inst_num;
+ uiSlavePortNum = pCpswPortIf->port_num;
#ifdef CPSW_DUAL_MAC_MODE
uiNetIfNum = (uiInstNum * MAX_SLAVEPORT_PER_INST) + uiSlavePortNum - 1;
#else
uiNetIfNum = uiInstNum;
#endif
-
- pCpswPortIf = &_G_am335xCpswPortIfs[(uiInstNum * MAX_SLAVEPORT_PER_INST) + uiSlavePortNum - 1];
- pNetIf = &_G_am335xCpswNetIfs[uiNetIfNum];
pAtomicNetIfLink = &_G_atomicAm335xCpswNetIfLinks[uiNetIfNum];
if (cpswif_link_status(uiInstNum, uiSlavePortNum)) {
-
API_TimeMSleep(100);
-
if (!cpswif_link_status(uiInstNum, uiSlavePortNum)) {
return;
}
if (!(pCpswPortIf->flags & NETIF_FLAG_LINK_UP)) {
-
- if (ERR_OK == cpswif_autoneg_config(pNetIf, uiInstNum, uiSlavePortNum)) {
-
+ if (ERR_OK == cpswif_autoneg_config(uiInstNum, uiSlavePortNum, &uiSpeed)) {
pCpswPortIf->flags |= NETIF_FLAG_LINK_UP;
-
#ifdef CPSW_SWITCH_CONFIG
printk(KERN_ALERT "netif %c%c%d port %d link up\n",
- pNetIf->name[0], pNetIf->name[1], pNetIf->num, uiSlavePortNum);
+ pNetdev->if_name[0], pNetdev->if_name[1], pCpswPortIf->inst_num + 1, uiSlavePortNum);
#endif
-
if (API_AtomicInc(pAtomicNetIfLink) == 1) {
-
- netif_set_link_up(pNetIf);
-
+ if (uiSpeed != 0) {
+ netdev_set_linkup(pNetdev, 1, uiSpeed);
printk(KERN_ALERT "netif %c%c%d link up\n",
- pNetIf->name[0], pNetIf->name[1], pNetIf->num);
+ pNetdev->if_name[0], pNetdev->if_name[1], uiInstNum + 1);
+ }
}
}
}
} else {
API_TimeMSleep(100);
-
if (cpswif_link_status(uiInstNum, uiSlavePortNum)) {
return;
}
-
if (pCpswPortIf->flags & NETIF_FLAG_LINK_UP) {
pCpswPortIf->flags &= ~NETIF_FLAG_LINK_UP;
#ifdef CPSW_SWITCH_CONFIG
printk(KERN_ALERT "netif %c%c%d port %d link down\n",
- pNetIf->name[0], pNetIf->name[1], pNetIf->num, uiSlavePortNum);
+ pNetdev->if_name[0], pNetdev->if_name[1], pCpswPortIf->inst_num + 1, uiSlavePortNum);
#endif
if (API_AtomicDec(pAtomicNetIfLink) == 0) {
- netif_set_link_down(pNetIf);
-
+ netdev_set_linkup(pNetdev, 0, 0);
printk(KERN_ALERT "netif %c%c%d link down\n",
- pNetIf->name[0], pNetIf->name[1], pNetIf->num);
+ pNetdev->if_name[0], pNetdev->if_name[1], uiInstNum + 1);
}
}
}
@@ -332,12 +378,10 @@ static VOID __am335xCpswLinkStatusCheck (UINT uiInstNum, UINT uiSlavePortNum)
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-static PVOID __am335xCpswLinkStatusCheckThread (PVOID pvArg)
+static PVOID __am335xCpswLinkStatusCheckThread (struct netdev *pNetdev)
{
- UINT uiSlavePortNum = (UINT)pvArg;
-
while (1) {
- __am335xCpswLinkStatusCheck(0, uiSlavePortNum);
+ __am335xCpswLinkStatusCheck(pNetdev);
API_TimeMSleep(250);
}
@@ -355,15 +399,15 @@ static PVOID __am335xCpswLinkStatusCheckThread (PVOID pvArg)
*********************************************************************************************************/
INT arm335xCpswNetIfAdd (AM335X_NETIF_CFG *pNetIfCfg, PAM335X_PINMUX pPinMux)
{
- __PAM335X_CPSW_PORTIF pCpswPortIf;
- struct netif *pNetIf;
+ __PAM335X_CPSW_PORTIF pCpswPortIf;
UINT uiNetIfNum;
- INT i;
UINT32 uiValue;
LW_OBJECT_HANDLE hThread;
LW_CLASS_THREADATTR threadAttr;
-
- (VOID)hThread;
+ struct netdev *pNetdev;
+ INT i;
+ CHAR cDevName[10] = CPSW_IF_NAME;
+ INT if_flags = 0;
if (!pNetIfCfg ||
pNetIfCfg->NETIFCFG_uiInstNum >= MAX_CPSW_INST ||
@@ -397,48 +441,66 @@ INT arm335xCpswNetIfAdd (AM335X_NETIF_CFG *pNetIfCfg, PAM335X_PINMUX pPinMux)
#endif
pCpswPortIf = &_G_am335xCpswPortIfs[(pNetIfCfg->NETIFCFG_uiInstNum * MAX_SLAVEPORT_PER_INST) +
- pNetIfCfg->NETIFCFG_uiSlavePortNum - 1];
- pNetIf = &_G_am335xCpswNetIfs[uiNetIfNum];
+ pNetIfCfg->NETIFCFG_uiSlavePortNum - 1];
+
+ pNetdev = &_G_am335xCpswNetDev[uiNetIfNum];
+
+ pNetdev->priv = (PVOID)pCpswPortIf;
+ pNetdev->magic_no = NETDEV_MAGIC;
+
+ cDevName[4] += uiNetIfNum;
+
+ sprintf(pNetdev->dev_name, "%s", cDevName);
+ lib_strcpy(pNetdev->if_name, "en");
+
+ pNetdev->if_hostname = "am335x";
+ pNetdev->init_flags = NETDEV_INIT_LOAD_PARAM
+ | NETDEV_INIT_LOAD_DNS
+ | NETDEV_INIT_IPV6_AUTOCFG;
+
+ pNetdev->chksum_flags = NETDEV_CHKSUM_ENABLE_ALL;
+ pNetdev->net_type = NETDEV_TYPE_ETHERNET;
+ pNetdev->speed = 0;
+ pNetdev->mtu = 1500;
+ pNetdev->hwaddr_len = 6;
+
+ pNetdev->drv = &(_G_am335xCpswNetDevFunc[uiNetIfNum]);
pCpswPortIf->inst_num = pNetIfCfg->NETIFCFG_uiInstNum;
pCpswPortIf->port_num = pNetIfCfg->NETIFCFG_uiSlavePortNum;
for (i = 0; i < __CPSW_MAC_LEN; i++) {
pCpswPortIf->eth_addr[i] = pNetIfCfg->NETIFCFG_ucMacArray[i];
+ pNetdev->hwaddr[i] = pNetIfCfg->NETIFCFG_ucMacArray[i];
}
- if (netif_add(pNetIf,
- &pNetIfCfg->NETIFCFG_ipAddr,
- &pNetIfCfg->NETIFCFG_netMask,
- &pNetIfCfg->NETIFCFG_gwAddr,
- pCpswPortIf,
- cpswif_init, tcpip_input) == LW_NULL) {
- printk(KERN_ERR "arm335xCpswNetIfAdd(): failed to add network interface %d!\n", uiNetIfNum);
- return (PX_ERROR);
- }
-
- pNetIf->ip6_autoconfig_enabled = 1; /* 允许 IPv6 地址自动配置 */
+ if_flags = IFF_BROADCAST | IFF_MULTICAST;
- netif_create_ip6_linklocal_address(pNetIf, 1); /* 构造 ipv6 link address */
-
- if (pNetIfCfg->NETIFCFG_bIsDefault) {
- netif_set_default(pNetIf);
+ if (pNetIfCfg->NETIFCFG_bIsEnable) {
+ if_flags |= IFF_UP | IFF_RUNNING;
}
- if (pNetIfCfg->NETIFCFG_bIsEnable) {
- netif_set_up(pNetIf);
+ uiValue = netdev_add(pNetdev,
+ pNetIfCfg->NETIFCFG_ipAddr,
+ pNetIfCfg->NETIFCFG_netMask,
+ pNetIfCfg->NETIFCFG_gwAddr,
+ if_flags);
+
+ if (uiValue != 0) {
+ printk("add cnds ethcard error.\n");
+ return (PX_ERROR);
}
threadAttr = API_ThreadAttrGetDefault();
threadAttr.THREADATTR_ulOption |= LW_OPTION_OBJECT_GLOBAL;
- threadAttr.THREADATTR_pvArg = (PVOID)pNetIfCfg->NETIFCFG_uiSlavePortNum;
+ threadAttr.THREADATTR_pvArg = (PVOID)pNetdev;
threadAttr.THREADATTR_ucPriority = LW_PRIO_LOW;
hThread = API_ThreadCreate("t_cpsw",
- __am335xCpswLinkStatusCheckThread,
+ (PTHREAD_START_ROUTINE)__am335xCpswLinkStatusCheckThread,
&threadAttr,
- LW_NULL);
+ LW_NULL);
if (hThread == LW_OBJECT_HANDLE_INVALID) {
printk(KERN_ERR "arm335xCpswNetIfAdd(): failed to create t_cpsw%d thread!\n",
pNetIfCfg->NETIFCFG_uiSlavePortNum);
@@ -460,11 +522,12 @@ INT arm335xCpswNetIfAdd (AM335X_NETIF_CFG *pNetIfCfg, PAM335X_PINMUX pPinMux)
INT arm335xCpswSwitchIfAdd (AM335X_NETIF_CFG *pNetIfCfg, PAM335X_PINMUX pPinMux)
{
UINT32 uiValue;
+ struct netdev *pNetdev;
+ UINT uiNetIfNum;
+ __PAM335X_CPSW_PORTIF pCpswPortIf;
LW_OBJECT_HANDLE hThread;
LW_CLASS_THREADATTR threadAttr;
- (VOID)hThread;
-
if (!pNetIfCfg ||
pNetIfCfg->NETIFCFG_uiInstNum >= MAX_CPSW_INST ||
(pNetIfCfg->NETIFCFG_uiSlavePortNum - 1) >= MAX_SLAVEPORT_PER_INST) {
@@ -489,16 +552,31 @@ INT arm335xCpswSwitchIfAdd (AM335X_NETIF_CFG *pNetIfCfg, PAM335X_PINMUX pPinM
write32(uiValue, SOC_CONTROL_REGS + CONTROL_GMII_SEL);
+ uiNetIfNum =(pNetIfCfg->NETIFCFG_uiInstNum * MAX_SLAVEPORT_PER_INST) +
+ pNetIfCfg->NETIFCFG_uiSlavePortNum - 1;
+
+ pCpswPortIf = &_G_am335xCpswPortIfs[uiNetIfNum];
+
+ pNetdev = &_G_am335xCpswNetDev[uiNetIfNum];
+
+ pNetdev->priv = (PVOID)pCpswPortIf;
+ pNetdev->magic_no = NETDEV_MAGIC;
+
+ lib_strcpy(pNetdev->if_name, "en");
+
+ pCpswPortIf->inst_num = pNetIfCfg->NETIFCFG_uiInstNum;
+ pCpswPortIf->port_num = pNetIfCfg->NETIFCFG_uiSlavePortNum;
+
threadAttr = API_ThreadAttrGetDefault();
threadAttr.THREADATTR_ulOption |= LW_OPTION_OBJECT_GLOBAL;
- threadAttr.THREADATTR_pvArg = (PVOID)pNetIfCfg->NETIFCFG_uiSlavePortNum;
+ threadAttr.THREADATTR_pvArg = (PVOID)pNetdev;
threadAttr.THREADATTR_ucPriority = LW_PRIO_LOW;
hThread = API_ThreadCreate("t_cpsw",
- __am335xCpswLinkStatusCheckThread,
+ (PTHREAD_START_ROUTINE)__am335xCpswLinkStatusCheckThread,
&threadAttr,
- LW_NULL);
+ LW_NULL);
if (hThread == LW_OBJECT_HANDLE_INVALID) {
printk(KERN_ERR "arm335xCpswNetIfAdd(): failed to create t_cpsw%d thread!\n",
pNetIfCfg->NETIFCFG_uiSlavePortNum);
@@ -517,10 +595,10 @@ INT arm335xCpswSwitchIfAdd (AM335X_NETIF_CFG *pNetIfCfg, PAM335X_PINMUX pPinM
** 全局变量:
** 调用模块:
*********************************************************************************************************/
-INT arm335xCpswMacAddrGet (UINT uiMacId, UCHAR *pucMacAddr)
+INT arm335xCpswMacAddrGet (UINT uiMacId, UCHAR *pucMacAddr)
{
- UINT32 uiMacIdLo;
- UINT32 uiMacIdHi;
+ UINT32 uiMacIdLo;
+ UINT32 uiMacIdHi;
if (uiMacId > MAX_CPSW_INST * MAX_SLAVEPORT_PER_INST) {
return (PX_ERROR);
@@ -529,12 +607,12 @@ INT arm335xCpswMacAddrGet (UINT uiMacId, UCHAR *pucMacAddr)
uiMacIdLo = read32(SOC_CONTROL_REGS + CONTROL_MAC_ID_LO(uiMacId));
uiMacIdHi = read32(SOC_CONTROL_REGS + CONTROL_MAC_ID_HI(uiMacId));
- pucMacAddr[5] = (uiMacIdLo >> 8) & 0xFF;
- pucMacAddr[4] = (uiMacIdLo) & 0xFF;
+ pucMacAddr[5] = (uiMacIdLo >> 8 ) & 0xFF;
+ pucMacAddr[4] = (uiMacIdLo ) & 0xFF;
pucMacAddr[3] = (uiMacIdHi >> 24) & 0xFF;
pucMacAddr[2] = (uiMacIdHi >> 16) & 0xFF;
- pucMacAddr[1] = (uiMacIdHi >> 8) & 0xFF;
- pucMacAddr[0] = (uiMacIdHi) & 0xFF;
+ pucMacAddr[1] = (uiMacIdHi >> 8 ) & 0xFF;
+ pucMacAddr[0] = (uiMacIdHi ) & 0xFF;
return (ERROR_NONE);
}
@@ -556,7 +634,6 @@ INT arm335xCpswInit (VOID)
am335xEnableModule(am335xModuleIdGet("CPGMAC0"));
-
pCpswControler->CPSWC_ulCpswSsVirtAddrBase = (addr_t)API_VmmIoRemapNocache(
(PVOID)pCpswControler->CPSWC_ulCpswSsPhyAddrBase,
pCpswControler->CPSWC_stCpswSsPhyAddrSize);
@@ -627,12 +704,13 @@ INT arm335xCpswInit (VOID)
pCpswControler->CPSWC_ulCpswSsVirtAddrBase +
(SOC_CPSW_SLIVER_2_REGS - SOC_CPSW_SS_REGS);
+
/*
* Register the Receive ISR for Core 0
*/
API_InterVectorConnect(pCpswControler->CPSWC_ulRxVector,
(PINT_SVR_ROUTINE)__am335xCpswRxIsr,
- LW_NULL,
+ (PVOID)LW_NULL,
"cpsw_rx_isr");
/*
@@ -640,7 +718,7 @@ INT arm335xCpswInit (VOID)
*/
API_InterVectorConnect(pCpswControler->CPSWC_ulTxVector,
(PINT_SVR_ROUTINE)__am335xCpswTxIsr,
- LW_NULL,
+ (PVOID)LW_NULL,
"cpsw_tx_isr");
/*
@@ -649,7 +727,7 @@ INT arm335xCpswInit (VOID)
if (pCpswControler->CPSWC_ulMiscVector != (ULONG)-1) {
API_InterVectorConnect(pCpswControler->CPSWC_ulMiscVector,
(PINT_SVR_ROUTINE)__am335xCpswMiscIsr,
- LW_NULL,
+ (PVOID)LW_NULL,
"cpsw_misc_isr");
}
diff --git a/SylixOS/driver/netif/am335x_cpsw.h b/SylixOS/driver/netif/am335x_cpsw.h
index 0415bd8..9928f7d 100644
--- a/SylixOS/driver/netif/am335x_cpsw.h
+++ b/SylixOS/driver/netif/am335x_cpsw.h
@@ -33,12 +33,11 @@
typedef struct {
UINT NETIFCFG_uiInstNum; /* Instance Number */
UINT NETIFCFG_uiSlavePortNum; /* CPSW Slave Port Number */
- ip_addr_t NETIFCFG_ipAddr; /* IP Address */
- ip_addr_t NETIFCFG_netMask; /* Net Mask */
- ip_addr_t NETIFCFG_gwAddr; /* Gate Way Address */
+ CHAR NETIFCFG_ipAddr[20]; /* IP Address */
+ CHAR NETIFCFG_netMask[20]; /* Net Mask */
+ CHAR NETIFCFG_gwAddr[20]; /* Gate Way Address */
#define __CPSW_MAC_LEN (6)
UINT8 NETIFCFG_ucMacArray[__CPSW_MAC_LEN]; /* MAC Address to be used */
- BOOL NETIFCFG_bIsDefault;
BOOL NETIFCFG_bIsEnable;
BOOL NETIFCFG_bInternalDelay;
UINT NETIFCFG_uiInterfaceMode;
diff --git a/SylixOS/driver/netif/cpswif.c b/SylixOS/driver/netif/cpswif.c
index 76555b5..099d8cb 100644
--- a/SylixOS/driver/netif/cpswif.c
+++ b/SylixOS/driver/netif/cpswif.c
@@ -59,20 +59,20 @@
#define __SYLIXOS_KERNEL
#include "config.h"
#include "SylixOS.h"
-#include "lwip/opt.h"
-#include "lwip/def.h"
-#include "lwip/mem.h"
-#include "lwip/pbuf.h"
-#include "lwip/sys.h"
-#include "lwip/stats.h"
-#include "lwip/snmp.h"
-#include "netif/etharp.h"
-#include "lwip/err.h"
+#include "netdev.h"
+#include "network/lwip/opt.h"
+#include "network/lwip/def.h"
+#include "network/lwip/mem.h"
+#include "network/lwip/pbuf.h"
+#include "network/lwip/sys.h"
+#include "network/lwip/stats.h"
+#include "network/lwip/snmp.h"
+#include "network/lwip/err.h"
#include "cpswif.h"
#include "lwiplib.h"
-#include "lwip/ethip6.h"
+#include "network/lwip/ethip6.h"
#include "pthread.h"
-
+#include "debug.h"
#define SIZEOF_STRUCT_PBUF LWIP_MEM_ALIGN_SIZE(sizeof(struct pbuf))
/*
@@ -420,6 +420,7 @@ cpswif_inst_config(struct cpswportif *cpswif) {
#endif
#endif
}
+
}
/**
@@ -1543,7 +1544,7 @@ static err_t
cpswif_autoneg_config(u32_t inst_num, u32_t port_num) {
#else
err_t
-cpswif_autoneg_config(struct netif *netif, u32_t inst_num, u32_t port_num) {
+cpswif_autoneg_config(u32_t inst_num, u32_t port_num, UINT32 *puiSpeed) {
#endif
struct cpswinst *cpswinst = &cpsw_inst_data[inst_num];
err_t linkstat = ERR_CONN;
@@ -1606,32 +1607,32 @@ cpswif_autoneg_config(struct netif *netif, u32_t inst_num, u32_t port_num) {
if(gbps_partnr_ablty & PHY_LINK_PARTNER_1000BT_FD) {
LWIP_PRINTF("PHY %d Transfer Mode : 1000 Mbps.", port_num);
transfer_mode = CPSW_SLIVER_GIG_FULL_DUPLEX;
- netif->link_speed = 1000 * 1000 * 1000;
+ *puiSpeed = 1000 * 1000 * 1000;
} else {
if ((adv_val & partnr_ablty) & PHY_100BTX_FD) {
LWIP_PRINTF("PHY %d Transfer Mode : 100 Mbps Full Duplex.", port_num);
transfer_mode = CPSW_SLIVER_NON_GIG_FULL_DUPLEX;
- netif->link_speed = 100 * 1000 * 1000;
+ *puiSpeed = 100 * 1000 * 1000;
} else if ((adv_val & partnr_ablty) & PHY_100BTX) {
LWIP_PRINTF("PHY %d Transfer Mode : 100 Mbps Half Duplex.", port_num);
transfer_mode = CPSW_SLIVER_NON_GIG_HALF_DUPLEX;
- netif->link_speed = 100 * 1000 * 1000;
+ *puiSpeed = 100 * 1000 * 1000;
} else if ((adv_val & partnr_ablty) & PHY_10BT_FD) {
LWIP_PRINTF("PHY %d Transfer Mode : 10 Mbps Full Duplex.", port_num);
transfer_mode = CPSW_SLIVER_INBAND | CPSW_SLIVER_NON_GIG_FULL_DUPLEX;
- netif->link_speed = 10 * 1000 * 1000;
+ *puiSpeed = 10 * 1000 * 1000;
} else if ((adv_val & partnr_ablty) & PHY_10BT) {
LWIP_PRINTF("PHY %d Transfer Mode : 10 Mbps Half Duplex.", port_num);
transfer_mode = CPSW_SLIVER_INBAND | CPSW_SLIVER_NON_GIG_HALF_DUPLEX;
- netif->link_speed = 10 * 1000 * 1000;
+ *puiSpeed = 10 * 1000 * 1000;
} else {
LWIP_PRINTF("PHY %d No Valid Transfer Mode is detected.", port_num);
- netif->link_speed = 0;
+ *puiSpeed = 0;
}
}
} else {
LWIP_PRINTF("PHY %d Auto-Negotiation Not Successful.", port_num);
- netif->link_speed = 0;
+ *puiSpeed = 0;
linkstat = ERR_CONN;
}
@@ -1681,16 +1682,6 @@ cpswif_phy_forced(struct cpswinst *cpswinst, u32_t port_num, u32_t speed,
return (ERR_OK);
}
-err_t cpswif_autoneg_config(struct netif *netif, u32_t inst_num, u32_t port_num)
-{
- struct cpswinst *cpswinst = &cpsw_inst_data[inst_num];
-
- netif->link_speed = 100 * 1000 * 1000;
-
- cpswif_phy_forced(cpswinst, port_num, SELECT_SPEED_100, TRUE);
-
- return (ERR_OK);
-}
static err_t
cpswif_phylink_config(struct cpswportif * cpswif, u32_t slv_port_num)
@@ -1719,7 +1710,7 @@ cpswif_link_status(u32_t inst_num, u32_t slv_port_num)
/**
* This function allocates the rx buffer descriptors ring. The function
- * internally calls pbuf_alloc() and allocates the pbufs to the rx buffer
+ * internally calls netdev_pbuf_alloc() and allocates the pbufs to the rx buffer
* descriptors.
*
* @param cpswinst The CPSW instance structure pointer
@@ -1745,23 +1736,14 @@ cpswif_rxbd_alloc(struct cpswinst *cpswinst) {
* Try to get a pbuf of max. length. This shall be cache line aligned if
* cache is enabled.
*/
- p = pbuf_alloc(PBUF_RAW, PBUF_LEN_MAX, PBUF_POOL);
+ p = netdev_pbuf_alloc(PBUF_LEN_MAX);
/**
* Allocate bd's if p is not NULL. This allocation doesnt support
* pbuf chaining.
*/
if(p != NULL) {
-#ifdef SYLIXOS
-
-#if ETHARP_SUPPORT_VLAN
- pbuf_header(p, -SIZEOF_VLAN_HDR); /* pre-save 4 bytes space for ip_forward() vlan header */
-#endif
-#if ETH_PAD_SIZE
- pbuf_header(p, -ETH_PAD_SIZE);
-#endif
-#endif
#ifdef LWIP_CACHE_ENABLED
/**
* Clean the pbuf structure info. This is needed to prevent losing
@@ -1822,17 +1804,16 @@ cpswif_rxbd_alloc(struct cpswinst *cpswinst) {
* contained in the pbuf that is passed to the function. This pbuf might be
* chained. That is, one pbuf can span more than one tx buffer descriptors
*
- * @param netif the network interface state for this ethernetif
* @param pbuf the pbuf which is to be sent over EMAC
* @return status ERR_OK, if transmit was successful
* ERR_MEM, if no memory available
*/
static err_t
-cpswif_transmit(struct netif *netif, struct pbuf *pbuf) {
+cpswif_transmit(struct netdev *pnetdev, struct pbuf *pbuf) {
struct pbuf *q;
struct txch *txch;
volatile struct cpdma_tx_bd *curr_bd, *bd_to_send, *bd_end;
- struct cpswportif *cpswif = netif->state;
+ struct cpswportif *cpswif = (struct cpswportif*)pnetdev->priv;
u32_t inst_num = cpswif->inst_num;
struct cpswinst *cpswinst = &cpsw_inst_data[inst_num];
@@ -1931,15 +1912,14 @@ cpswif_transmit(struct netif *netif, struct pbuf *pbuf) {
* This function will send a packet through the emac if the channel is
* available. Otherwise, the packet will be queued in a pbuf queue.
*
- * @param netif The lwip network interface structure for this ethernetif
* @param p The MAC packet to send (e.g. IP packet including
* MAC addresses and type)
* @return ERR_OK if the packet could be sent
* an err_t value if the packet couldn't be sent
*
*/
-static err_t
-cpswif_output(struct netif *netif, struct pbuf *p) {
+err_t
+cpswif_output(struct netdev *pnetdev, struct pbuf *p) {
err_t stat;
#ifdef SYLIXOS
u16_t len;
@@ -1957,28 +1937,22 @@ cpswif_output(struct netif *netif, struct pbuf *p) {
#endif
#ifdef SYLIXOS
-#if ETH_PAD_SIZE
- pbuf_header(p, -ETH_PAD_SIZE);
-#endif
len = (p->tot_len < MIN_PKT_LEN) ? MIN_PKT_LEN : p->tot_len;
#if defined(SYLIXOS) && (BSP_CFG_CPSW_TX_DMA_PBUF > 0)
- struct cpswportif *cpswif = netif->state;
+ struct cpswportif *cpswif = (struct cpswportif *)pnetdev->priv;
u32_t inst_num = cpswif->inst_num;
struct cpswinst *cpswinst = &cpsw_inst_data[inst_num];
q = dma_pbuf_alloc(cpswinst, PBUF_RAW, len, PBUF_POOL);
#else
- q = pbuf_alloc(PBUF_RAW, len, PBUF_POOL);
+ q = netdev_pbuf_alloc(len);
#endif
if (!q) {
return ERR_MEM;
}
pbuf_copy(q, p);
-#if ETH_PAD_SIZE
- pbuf_header(p, ETH_PAD_SIZE);
-#endif
p = q;
#else
/**
@@ -2004,14 +1978,14 @@ cpswif_output(struct netif *netif, struct pbuf *p) {
#endif
/* call the actual transmit function */
- stat = cpswif_transmit(netif, p);
+ stat = cpswif_transmit(pnetdev, p);
#ifdef SYLIXOS
if (stat != ERR_OK) {
#if BSP_CFG_CPSW_TX_DMA_PBUF > 0
dma_pbuf_free(cpswinst, p);
#else
- pbuf_free(p);
+ netdev_pbuf_free(p);
#endif
}
#endif
@@ -2222,42 +2196,33 @@ cpswif_phylink_config(struct cpswportif * cpswif, u32_t slv_port_num) {
/**
* Initializes the CPSW port
- * @param netif The cpsw interface
+ * @param netdev The cpsw interface
*
* @return ERR_OK if port initialization is successful
* an error status if failed
*/
static err_t
-cpswif_port_init(struct netif *netif) {
- struct cpswportif *cpswif = (struct cpswportif*)(netif->state);
- u32_t temp;
+cpswif_port_init(netdev_t *netdev) {
+ struct cpswportif *cpswif = (struct cpswportif*)(netdev->priv);
err_t err;
#ifdef CPSW_DUAL_MAC_MODE
struct cpswinst *cpswinst = &cpsw_inst_data[cpswif->inst_num];
u32_t curr_port = cpswif->port_num;
+ netif_debug("[NETIF]curr_port = %d\r\n", curr_port);
#endif
- /* set MAC hardware address length */
- netif->hwaddr_len = ETHARP_HWADDR_LEN;
-
- /* set MAC hardware address */
- for(temp = 0; temp < ETHARP_HWADDR_LEN; temp++) {
- netif->hwaddr[temp] = cpswif->eth_addr[temp];
- }
-
- /* maximum transfer unit */
- netif->mtu = MAX_TRANSFER_UNIT;
-
- /* device capabilities */
- /* don't set NETIF_FLAG_ETHARP if this device is not an ethernet one */
- netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_LINK_UP;
-
#ifdef CPSW_DUAL_MAC_MODE
/* Set the ethernet address for the port */
CPSWPortSrcAddrSet(cpswinst->port[curr_port - 1].port_base,
(u8_t *)(&(cpswif->eth_addr)));
+ INT i;
+ netif_debug("MAC:");
+ for (i = 0; i < 6; i++) {
+ netif_debug("%02x ", cpswif->eth_addr[i]);
+ }
+ netif_debug("\r\n");
/**
* For Dual Mac mode, configure port0 and port1 for one VLAN ID;
* port0 and port2 for a different VLAN ID. Here we choose the
@@ -2445,54 +2410,17 @@ cpswif_inst_init(struct cpswportif *cpswif){
* network interface. It calls the functions cpswif_inst_init() and
* cpswif_port_init() to do low level initializations
*
- * @param netif The lwip network interface structure for this ethernetif
+ * @param netdev The lwip network interface structure for this ethernetif
* @return ERR_OK If the interface is initialized
* any other err_t on error
*/
-err_t
-cpswif_init(struct netif *netif)
+INT cpswif_init(netdev_t *netdev)
{
- struct cpswportif *cpswif = (struct cpswportif*)(netif->state);
+
+ struct cpswportif *cpswif = (struct cpswportif*)(netdev->priv);
static u32_t inst_init_flag = 0;
u32_t inst_num = cpswif->inst_num;
-#if LWIP_NETIF_HOSTNAME
- /* Initialize interface hostname */
- netif->hostname = "lwip";
-#endif /* LWIP_NETIF_HOSTNAME */
-
-#ifdef SYLIXOS
- netif->name[0] = IFNAME0;
- netif->name[1] = IFNAME1;
-#endif
-
- /**
- * Initialize the snmp variables and counters inside the struct netif.
- * The last argument should be replaced with your link speed, in units
- * of bits per second.
- */
- NETIF_INIT_SNMP(netif, snmp_ifType_ethernet_csmacd, 10000000);
-
- /* let us use the interface number to identify netif */
-#ifdef CPSW_DUAL_MAC_MODE
- netif->num = (u8_t)(((cpswif->inst_num * MAX_SLAVEPORT_PER_INST)
- + cpswif->port_num - 1) & 0xFF);
-#else
- netif->num = (u8_t)(cpswif->inst_num);
-#endif
-
- /**
- * We directly use etharp_output() here to save a function call.
- * You can instead declare your own function an call etharp_output()
- * from it if you have to do some checks before sending (e.g. if link
- * is available...)
- */
- netif->output = etharp_output;
- netif->linkoutput = cpswif_output;
-#ifdef SYLIXOS
- netif->output_ip6 = ethip6_output;
-#endif
-
/**
* Initialize an instance only once. Port initialization will be
* done separately.
@@ -2503,39 +2431,35 @@ cpswif_init(struct netif *netif)
inst_init_flag |= (1 << inst_num);
}
- if(cpswif_port_init(netif) != ERR_OK) {
+ if(cpswif_port_init(netdev) != ERR_OK) {
#ifndef SYLIXOS
return ERR_CONN;
#else
- netif->flags &= ~NETIF_FLAG_LINK_UP;
+ netdev_set_linkup(netdev, 0, 0);
#endif
}
return ERR_OK;
}
-#ifdef SYLIXOS
-static err_t cpswif_input(struct pbuf *p, struct netif *netif)
-{
- return netif->input(p, netif);
-}
-#endif
-
/**
* Handler for Receive interrupt. Packet processing is done in this
* interrupt handler itself.
*
* @param inst_num the instance for which interrupt was generated
- * @param netif_arr the address of the array of netifs
+ * @param pnetdev the address of the array of netifs
* @return none
*/
void
-cpswif_rx_inthandler(u32_t inst_num, struct netif * netif_arr) {
+cpswif_rx_inthandler(u32_t inst_num, struct netdev *pnetdev, int (*input)(struct netdev *, struct pbuf *))
+{
struct cpswinst *cpswinst = &cpsw_inst_data[inst_num];
struct rxch *rxch;
volatile struct cpdma_rx_bd *curr_bd;
volatile struct pbuf *pbuf;
- u32_t tot_len, if_num;
+ u32_t tot_len;
+ u32_t if_num;
+ INT i = 0;
#ifdef CPSW_DUAL_MAC_MODE
u32_t from_port;
@@ -2581,41 +2505,42 @@ cpswif_rx_inthandler(u32_t inst_num, struct netif * netif_arr) {
pbuf->len = (u16_t)(tot_len);
pbuf->tot_len = (u16_t)(tot_len);
-#ifdef SYLIXOS
-#if ETH_PAD_SIZE
- pbuf_header((struct pbuf *)pbuf, ETH_PAD_SIZE);
-#endif
-#endif
+
+
+ netif_debug("\r\n");
+ for (i = 0; i < tot_len;) {
+ netif_debug("%02x ", ((unsigned char*)pbuf->payload)[i]);
+ i++;
+ if (!(i % 8)) {
+ if (!(i % 16)) {
+ netif_debug("\r\n");
+ } else {
+ netif_debug(" ");
+ }
+ }
+ }
+ netif_debug("\r\n");
curr_bd->flags_pktlen = CPDMA_BUF_DESC_OWNER;
/* Adjust the link statistics */
- LINK_STATS_INC(link.recv);
+ netdev_linkinfo_recv_inc(pnetdev + if_num);
#ifdef CPSW_DUAL_MAC_MODE
if_num = (inst_num * MAX_SLAVEPORT_PER_INST) + from_port - 1;
#else
if_num = inst_num;
#endif
#ifdef SYLIXOS
- snmp_add_ifinoctets(netif_arr + if_num, tot_len);
- snmp_inc_ifinucastpkts(netif_arr + if_num);
+ netdev_statinfo_total_add(pnetdev + if_num, LINK_INPUT, tot_len);
+ netdev_statinfo_ucasts_inc(pnetdev + if_num, LINK_INPUT);
#endif
-#ifndef SYLIXOS
/* Process the packet */
- if(ethernet_input((struct pbuf *)pbuf, netif_arr + if_num) != ERR_OK) {
+ if(input(pnetdev + if_num, (struct pbuf *)pbuf) != ERR_OK) {
/* Adjust the link statistics */
- LINK_STATS_INC(link.memerr);
- LINK_STATS_INC(link.drop);
+ netdev_linkinfo_memerr_inc(pnetdev + if_num);
+ netdev_linkinfo_drop_inc(pnetdev + if_num);
}
-#else
- /* Process the packet */
- if(cpswif_input((struct pbuf *)pbuf, netif_arr + if_num) != ERR_OK) {
- /* Adjust the link statistics */
- LINK_STATS_INC(link.memerr);
- LINK_STATS_INC(link.drop);
- }
-#endif
/* Acknowledge that this packet is processed */
CPSWCPDMARxCPWrite(cpswinst->cpdma_base, 0, (unsigned int)curr_bd);
@@ -2652,7 +2577,7 @@ cpswif_rx_inthandler(u32_t inst_num, struct netif * netif_arr) {
/**
* Handler for CPSW Transmit interrupt
*
- * @param netif the lwip network interface structure for this ethernetif
+ * @param pnetdev the lwip network interface structure for this ethernetif
* @return none
*/
#ifndef SYLIXOS
@@ -2660,7 +2585,7 @@ void
cpswif_tx_inthandler(u32_t inst_num) {
#else
void
-cpswif_tx_inthandler(u32_t inst_num, struct netif * netif_arr) {
+cpswif_tx_inthandler(u32_t inst_num, struct netdev *pnetdev) {
#endif
struct txch *txch;
struct cpswinst *cpswinst = &cpsw_inst_data[inst_num];
@@ -2760,17 +2685,17 @@ cpswif_tx_inthandler(u32_t inst_num, struct netif * netif_arr) {
#else
if_num = inst_num;
#endif
- snmp_add_ifoutoctets(netif_arr + if_num, curr_bd->pbuf->tot_len);
- snmp_inc_ifoutucastpkts(netif_arr + if_num);
+ netdev_statinfo_total_add(pnetdev + if_num, LINK_OUTPUT, curr_bd->pbuf->tot_len);
+ netdev_statinfo_ucasts_inc(pnetdev + if_num, LINK_OUTPUT);
#endif
#if defined(SYLIXOS) && (BSP_CFG_CPSW_TX_DMA_PBUF > 0)
dma_pbuf_free(cpswinst, (struct pbuf *)curr_bd->pbuf);
#else
- pbuf_free((struct pbuf *)curr_bd->pbuf);
+ netdev_pbuf_free((struct pbuf *)curr_bd->pbuf);
#endif
- LINK_STATS_INC(link.xmit);
+ netdev_linkinfo_xmit_inc(pnetdev);
send_head = txch->send_head;
curr_bd = send_head;
}
@@ -2784,17 +2709,7 @@ cpswif_tx_inthandler(u32_t inst_num, struct netif * netif_arr) {
API_SemaphoreBPost(cpswinst->txlock);
#endif
}
-
-/**
- * Gets the netif status
- *
- * @param netif The netif whoes status to be checked
- * @return The netif status
- */
-u32_t
-cpswif_netif_status(struct netif *netif) {
- return ((u32_t)(netif_is_up(netif)));
-}
+
#if CPSW_PHY_MDIO_EN > 0
/**
diff --git a/SylixOS/driver/netif/cpswif.h b/SylixOS/driver/netif/cpswif.h
index 0a272dc..e1bf353 100644
--- a/SylixOS/driver/netif/cpswif.h
+++ b/SylixOS/driver/netif/cpswif.h
@@ -44,7 +44,6 @@
#include "src/include/lwip/netif.h"
#else
#include "config.h"
-#include "lwip/netif.h"
#endif
#ifndef __CPSWIF_H__
@@ -75,30 +74,30 @@
网络接口控制器类型定义
*********************************************************************************************************/
typedef struct {
- addr_t CPSWC_ulCpswSsPhyAddrBase; /* CPSW_SS 物理地址基地址 */
- size_t CPSWC_stCpswSsPhyAddrSize; /* CPSW_SS 物理地址空间大小 */
- addr_t CPSWC_ulCpswMidoPhyAddrBase; /* CPSW_MIDO 物理地址基地址 */
- size_t CPSWC_stCpswMidoPhyAddrSize; /* CPSW_MIDO 物理地址空间大小 */
- addr_t CPSWC_ulCpswCppiRamPhyAddrBase; /* CPPI_RAM 物理地址基地址 */
- size_t CPSWC_stCpswCppiRamPhyAddrSize; /* CPPI_RAM 物理地址空间大小 */
- ULONG CPSWC_ulRxVector; /* 接收中断向量 */
- UINT CPSWC_uiRxIntPriority; /* 接收中断优先级 */
- ULONG CPSWC_ulTxVector; /* 发送中断向量 */
- UINT CPSWC_uiTxIntPriority; /* 发送中断优先级 */
- ULONG CPSWC_ulMiscVector; /* MISC 中断向量 */
- UINT CPSWC_uiMiscIntPriority; /* MISC 中断优先级 */
-
- addr_t CPSWC_ulCpswSsVirtAddrBase; /* CPSW_SS 虚拟地址基地址 */
- addr_t CPSWC_ulCpswMidoVirtAddrBase; /* CPSW_MIDO 虚拟地址基地址 */
- addr_t CPSWC_ulCpswCppiRamVirtAddrBase; /* CPSW_CPPI_RAM 虚拟地址基地址*/
- addr_t CPSWC_ulCpswWrVirtAddrBase; /* CPSW_WR 虚拟地址基地址 */
- addr_t CPSWC_ulCpswCpdmaVirtAddrBase; /* CPSW_CPDMA 虚拟地址基地址 */
- addr_t CPSWC_ulCpswAleVirtAddrBase; /* CPSW_ALE 虚拟地址基地址 */
- addr_t CPSWC_ulCpswPort0VirtAddrBase; /* CPSW_PORT_0 虚拟地址基地址 */
- addr_t CPSWC_ulCpswPort1VirtAddrBase; /* CPSW_PORT_1 虚拟地址基地址 */
- addr_t CPSWC_ulCpswSliver1VirtAddrBase; /* CPSW_SLIVER_1 虚拟地址基地址*/
- addr_t CPSWC_ulCpswPort2VirtAddrBase; /* CPSW_PORT_2 虚拟地址基地址 */
- addr_t CPSWC_ulCpswSliver2VirtAddrBase; /* CPSW_SLIVER_2 虚拟地址基地址*/
+ addr_t CPSWC_ulCpswSsPhyAddrBase; /* CPSW_SS 物理地址基地址 */
+ size_t CPSWC_stCpswSsPhyAddrSize; /* CPSW_SS 物理地址空间大小 */
+ addr_t CPSWC_ulCpswMidoPhyAddrBase; /* CPSW_MIDO 物理地址基地址 */
+ size_t CPSWC_stCpswMidoPhyAddrSize; /* CPSW_MIDO 物理地址空间大小 */
+ addr_t CPSWC_ulCpswCppiRamPhyAddrBase; /* CPPI_RAM 物理地址基地址 */
+ size_t CPSWC_stCpswCppiRamPhyAddrSize; /* CPPI_RAM 物理地址空间大小 */
+ ULONG CPSWC_ulRxVector; /* 接收中断向量 */
+ UINT CPSWC_uiRxIntPriority; /* 接收中断优先级 */
+ ULONG CPSWC_ulTxVector; /* 发送中断向量 */
+ UINT CPSWC_uiTxIntPriority; /* 发送中断优先级 */
+ ULONG CPSWC_ulMiscVector; /* MISC 中断向量 */
+ UINT CPSWC_uiMiscIntPriority; /* MISC 中断优先级 */
+
+ addr_t CPSWC_ulCpswSsVirtAddrBase; /* CPSW_SS 虚拟地址基地址 */
+ addr_t CPSWC_ulCpswMidoVirtAddrBase; /* CPSW_MIDO 虚拟地址基地址 */
+ addr_t CPSWC_ulCpswCppiRamVirtAddrBase; /* CPSW_CPPI_RAM 虚拟地址基地址*/
+ addr_t CPSWC_ulCpswWrVirtAddrBase; /* CPSW_WR 虚拟地址基地址 */
+ addr_t CPSWC_ulCpswCpdmaVirtAddrBase; /* CPSW_CPDMA 虚拟地址基地址 */
+ addr_t CPSWC_ulCpswAleVirtAddrBase; /* CPSW_ALE 虚拟地址基地址 */
+ addr_t CPSWC_ulCpswPort0VirtAddrBase; /* CPSW_PORT_0 虚拟地址基地址 */
+ addr_t CPSWC_ulCpswPort1VirtAddrBase; /* CPSW_PORT_1 虚拟地址基地址 */
+ addr_t CPSWC_ulCpswSliver1VirtAddrBase; /* CPSW_SLIVER_1 虚拟地址基地址*/
+ addr_t CPSWC_ulCpswPort2VirtAddrBase; /* CPSW_PORT_2 虚拟地址基地址 */
+ addr_t CPSWC_ulCpswSliver2VirtAddrBase; /* CPSW_SLIVER_2 虚拟地址基地址*/
BOOL CPSWC_bIsInit;
} __AM335X_CPSW_CONTROLER, *__PAM335X_CPSW_CONTROLER;
@@ -165,13 +164,14 @@ struct cpswportif {
#endif
}cpswportif;
-extern u32_t cpswif_netif_status(struct netif *netif);
extern u32_t cpswif_link_status(u32_t inst_num, u32_t slv_port_num);
-extern err_t cpswif_init(struct netif *netif);
-extern void cpswif_rx_inthandler(u32_t inst_num, struct netif * netif_arr);
+extern INT cpswif_init(netdev_t *netdev);
+extern void cpswif_rx_inthandler(u32_t inst_num,
+ struct netdev *pnetdev,
+ int (*input)(struct netdev *, struct pbuf *));
#ifndef SYLIXOS
extern void cpswif_tx_inthandler(u32_t inst_num);
#else
-extern void cpswif_tx_inthandler(u32_t inst_num, struct netif * netif_arr);
+extern void cpswif_tx_inthandler(u32_t inst_num, struct netdev *pnetdev);
#endif
#endif /* _CPSWIF_H__ */
diff --git a/SylixOS/driver/netif/debug.h b/SylixOS/driver/netif/debug.h
new file mode 100644
index 0000000..e567f1a
--- /dev/null
+++ b/SylixOS/driver/netif/debug.h
@@ -0,0 +1,39 @@
+/*********************************************************************************************************
+**
+** 中国软件开源组织
+**
+** 嵌入式实时操作系统
+**
+** SylixOS(TM)
+**
+** Copyright All Rights Reserved
+**
+**--------------文件信息--------------------------------------------------------------------------------
+**
+** 文 件 名: debug.h
+**
+** 创 建 人: Hu.Hanzhang (胡瀚璋)
+**
+** 文件创建日期: 2016 年 11 月 21 日
+**
+** 描 述: AM335X 处理器 CPSW 驱动调试信息开关
+*********************************************************************************************************/
+
+#ifndef DEBUG_H_
+#define DEBUG_H_
+
+/*********************************************************************************************************
+ DEBUG开关
+*********************************************************************************************************/
+#define __NETIF_DEBUG 0
+
+#if __NETIF_DEBUG > 0
+#define netif_debug(fmt, arg...) _DebugFormat(__PRINTMESSAGE_LEVEL, fmt, ##arg)
+#else
+#define netif_debug(fmt, arg...)
+#endif
+
+#endif /* DEBUG_H_ */
+/*********************************************************************************************************
+ END
+*********************************************************************************************************/ \ No newline at end of file
diff --git a/SylixOS/driver/netif/lwiplib.h b/SylixOS/driver/netif/lwiplib.h
index b78ce3e..13ceadd 100644
--- a/SylixOS/driver/netif/lwiplib.h
+++ b/SylixOS/driver/netif/lwiplib.h
@@ -45,7 +45,7 @@
#include "src/include/lwip/opt.h"
#else
#include "config.h"
-#include "lwip/opt.h"
+#include "network/lwip/opt.h"
#endif
/* Ensure that AUTOIP COOP option is configured correctly.*/
@@ -62,14 +62,14 @@
#include "src/include/lwip/mem.h"
#include "src/include/lwip/stats.h"
#else
-#include "lwip/api.h"
-#include "lwip/netifapi.h"
-#include "lwip/tcp.h"
-#include "lwip/udp.h"
-#include "lwip/tcpip.h"
-#include "lwip/sockets.h"
-#include "lwip/mem.h"
-#include "lwip/stats.h"
+#include "network/lwip/api.h"
+#include "network/lwip/netifapi.h"
+#include "network/lwip/tcp.h"
+#include "network/lwip/udp.h"
+#include "network/lwip/tcpip.h"
+#include "network/lwip/sockets.h"
+#include "network/lwip/mem.h"
+#include "network/lwip/stats.h"
#endif
/******************************************************************************
diff --git a/SylixOS/driver/pwm/am335x_pwm.c b/SylixOS/driver/pwm/am335x_pwm.c
index ea726e8..047c630 100644
--- a/SylixOS/driver/pwm/am335x_pwm.c
+++ b/SylixOS/driver/pwm/am335x_pwm.c
@@ -292,7 +292,7 @@ static LONG __am335xPwmOpen (PLW_DEV_HDR pDev,
}
if (pFdNode) {
- API_IosFdNodeDec(&pPwmChannel->PWMCHAN_fdNodeHeader, pFdNode);
+ API_IosFdNodeDec(&pPwmChannel->PWMCHAN_fdNodeHeader, pFdNode, LW_NULL);
pFdNode = LW_NULL;
}
@@ -315,7 +315,7 @@ static INT __am335xPwmClose (PLW_FD_ENTRY pFdEntry)
PLW_FD_NODE pFdNode = (PLW_FD_NODE)pFdEntry->FDENTRY_pfdnode;
if (pFdEntry && pFdNode) {
- API_IosFdNodeDec(&pPwmChannel->PWMCHAN_fdNodeHeader, pFdNode);
+ API_IosFdNodeDec(&pPwmChannel->PWMCHAN_fdNodeHeader, pFdNode, LW_NULL);
if (LW_DEV_DEC_USE_COUNT(&pPwmChannel->PWMCHAN_devHdr) == 0) {
diff --git a/SylixOS/driver/touch/am335x_adc_touch.c b/SylixOS/driver/touch/am335x_adc_touch.c
index d76b9e0..59702a7 100644
--- a/SylixOS/driver/touch/am335x_adc_touch.c
+++ b/SylixOS/driver/touch/am335x_adc_touch.c
@@ -688,7 +688,7 @@ static LONG __am335xAdcTouchOpen (PLW_DEV_HDR pDev,
}
if (pFdNode) {
- API_IosFdNodeDec(&pAdcTouchDev->ADCTOUCH_fdNodeHeader, pFdNode);
+ API_IosFdNodeDec(&pAdcTouchDev->ADCTOUCH_fdNodeHeader, pFdNode, LW_NULL);
pFdNode = LW_NULL;
}
@@ -711,7 +711,7 @@ static INT __am335xAdcTouchClose (PLW_FD_ENTRY pFdEntry)
PLW_FD_NODE pFdNode = (PLW_FD_NODE)pFdEntry->FDENTRY_pfdnode;
if (pFdEntry && pFdNode) {
- API_IosFdNodeDec(&pAdcTouchDev->ADCTOUCH_fdNodeHeader, pFdNode);
+ API_IosFdNodeDec(&pAdcTouchDev->ADCTOUCH_fdNodeHeader, pFdNode, LW_NULL);
/* Disable the system interrupt in AINTC. */
API_InterVectorDisable(pAdcTouchDev->ADCTOUCH_ulVector);
diff --git a/SylixOS/driver/tps65217/tps65217.c b/SylixOS/driver/tps65217/tps65217.c
index 11273f3..b59ba39 100644
--- a/SylixOS/driver/tps65217/tps65217.c
+++ b/SylixOS/driver/tps65217/tps65217.c
@@ -252,7 +252,7 @@ static LONG __tps65217Open (PLW_DEV_HDR pDev,
__error_handle:
if (pFdNode) {
- API_IosFdNodeDec(&pTps65217->TPS65217_fdNodeHeader, pFdNode);
+ API_IosFdNodeDec(&pTps65217->TPS65217_fdNodeHeader, pFdNode, LW_NULL);
pFdNode = LW_NULL;
}
@@ -274,7 +274,7 @@ static INT __tps65217Close (PLW_FD_ENTRY pFdEntry)
PLW_FD_NODE pFdNode = (PLW_FD_NODE)pFdEntry->FDENTRY_pfdnode;
if (pFdEntry && pFdNode) {
- API_IosFdNodeDec(&pTps65217->TPS65217_fdNodeHeader, pFdNode);
+ API_IosFdNodeDec(&pTps65217->TPS65217_fdNodeHeader, pFdNode, LW_NULL);
if (LW_DEV_DEC_USE_COUNT(&pTps65217->TPS65217_devHdr) == 0) {
diff --git a/SylixOS/driver/tps65217/tps65217.h b/SylixOS/driver/tps65217/tps65217.h
index 83b6f4b..03f6ec4 100644
--- a/SylixOS/driver/tps65217/tps65217.h
+++ b/SylixOS/driver/tps65217/tps65217.h
@@ -21,6 +21,8 @@
#ifndef __PMIC_TPS65217_H_
#define __PMIC_TPS65217_H_
+#include "sys/ioccom.h"
+
/*********************************************************************************************************
ioctl 命令字定义
*********************************************************************************************************/
diff --git a/SylixOS/driver/watchdog/am335x_watchdog.c b/SylixOS/driver/watchdog/am335x_watchdog.c
index 03b7249..e6486bf 100644
--- a/SylixOS/driver/watchdog/am335x_watchdog.c
+++ b/SylixOS/driver/watchdog/am335x_watchdog.c
@@ -147,7 +147,7 @@ static LONG __am335xWatchDogOpen (PLW_DEV_HDR pDev,
}
if (pFdNode) {
- API_IosFdNodeDec(&pWatchDogControler->WDTC_fdNodeHeader, pFdNode);
+ API_IosFdNodeDec(&pWatchDogControler->WDTC_fdNodeHeader, pFdNode, LW_NULL);
pFdNode = LW_NULL;
}
@@ -170,7 +170,7 @@ static INT __am335xWatchDogClose (PLW_FD_ENTRY pFdEntry)
PLW_FD_NODE pFdNode = (PLW_FD_NODE)pFdEntry->FDENTRY_pfdnode;
if (pFdEntry && pFdNode) {
- API_IosFdNodeDec(&pWatchDogControler->WDTC_fdNodeHeader, pFdNode);
+ API_IosFdNodeDec(&pWatchDogControler->WDTC_fdNodeHeader, pFdNode, LW_NULL);
if (LW_DEV_DEC_USE_COUNT(&pWatchDogControler->WDTC_devHdr) == 0) {
diff --git a/bspok335xs.mk b/bspok335xs.mk
index a8539f5..4e00675 100644
--- a/bspok335xs.mk
+++ b/bspok335xs.mk
@@ -58,6 +58,7 @@ SylixOS/driver/clock/am335x_clock_data.c \
SylixOS/driver/dma/am335x_dma.c \
SylixOS/driver/dma/am335x_dma_test.c \
SylixOS/driver/ds1337/ds1337.c \
+SylixOS/driver/ds1337/rx8010.c \
SylixOS/driver/ds1337/ds1337_test.c \
SylixOS/driver/dvfs/dvfs.c \
SylixOS/driver/ecap/am335x_ecap.c \
diff --git a/config.lds b/config.lds
deleted file mode 100644
index 84862f5..0000000
--- a/config.lds
+++ /dev/null
@@ -1,6 +0,0 @@
-MEMORY
-{
- TEXT (rx) : ORIGIN = 0x80000000, LENGTH = (6 * 1024 * 1024)
- DATA (rw) : ORIGIN = 0x80000000 + ((6 * 1024 * 1024)), LENGTH = (40 * 1024 * 1024)
-}
-BOOT_STACK_SIZE = (128 * 1024);
diff --git a/config.mk b/config.mk
index b607902..aa7cc5d 100644
--- a/config.mk
+++ b/config.mk
@@ -22,12 +22,7 @@
#*********************************************************************************************************
# SylixOS Base Project path
#*********************************************************************************************************
-SYLIXOS_BASE_PATH := D:\RealEvo-Simulator\src\workspace\sylixos-base-a8
-
-#*********************************************************************************************************
-# Toolchain prefix
-#*********************************************************************************************************
-TOOLCHAIN_PREFIX := arm-sylixos-eabi-
+SYLIXOS_BASE_PATH := D:\SylixOSDev\workspace\sylixos-base-a9
#*********************************************************************************************************
# Debug options (debug or release)
@@ -38,7 +33,6 @@ DEBUG_LEVEL := debug
# NOTICE: libsylixos, BSP and other kernel modules projects CAN NOT use vfp!
#*********************************************************************************************************
FPU_TYPE := disable
-CPU_TYPE := cortex-a8
#*********************************************************************************************************
# End