linux-kernel-4.4 移植 (3) 网卡移植
开发环境:win10 64位 + VMware12 + Ubuntu14.04 32位
工具链:linaro提供的gcc-linaro-6.1.1-2016.08-x86_64_arm-linux-gnueabi
要移植的kernel版本:linux-4.4
Tiny4412开发板硬件版本为:
底板: Tiny4412SDK 1312B
核心板:Tiny4412 - 1306
——————————————————————————————————————————————————————————
1,查看原理图
与整个DM9621相连的有三个口,DP1+和DM1-与USB4640连接传输数据。另有一个复位口,控制网卡使能,低电平有效。所以我们在配置设备树USB-HUB时, 需要将GPM2_4拉低。
2,Patch
diff --git a/include/linux/platform_data/usb4640.h b/include/linux/platform_data/usb4640.h
new file mode
index ..062a50c
--- /dev/null
+++ b/include/linux/platform_data/usb4640.h
@@ -, +, @@
+#ifndef __USB4640_H__
+#define __USB4640_H__
+
+#define USB4640_NAME "usb4640" +enum usb4640_mode {
+ USB4640_MODE_UNKNOWN = ,
+ USB4640_MODE_HUB,
+ USB4640_MODE_STANDBY,
+};
+
+struct usb4640_platform_data {
+ enum usb4640_mode initial_mode;
+#define USB4640_NAME "usb4640" +enum usb4640_mode {
+ USB4640_MODE_UNKNOWN = ,
+ USB4640_MODE_HUB,
+ USB4640_MODE_STANDBY,
+};
+
+struct usb4640_platform_data {
+ enum usb4640_mode initial_mode;
+ int gpio_reset;
+};
+
+#endif
diff --git a/include/dt-bindings/usb4640/usb4640.h b/include/dt-bindings/usb4640/usb4640.h
new file mode
index ..ef3e1e1
--- /dev/null
+++ b/include/dt-bindings/usb4640/usb4640.h
@@ -, +, @@
+#ifndef _DT_BINDINGS_USB4640
+#define _DT_BINDINGS_USB4640
+
+#define USB4640_MODE_UNKNOWN 1
+#define USB4640_MODE_HUB 2
+#define USB4640_MODE_STANDBY 3
+#endif
diff --git a/drivers/usb/misc/usb4640.c b/drivers/usb/misc/usb4640.c
new file mode
index ..b7bc085
--- /dev/null
+++ b/drivers/usb/misc/usb4640.c
@@ -, +, @@
+/*
+ * Driver for SMSC USB4640 USB 2.0 hub controller driver
+ *
+ */
+
+#include <linux/gpio.h>
+#include <linux/delay.h>
+#include <linux/slab.h>
+#include <linux/module.h>
+#include <linux/of_gpio.h>
+#include <linux/platform_device.h>
+#include <linux/platform_data/usb4640.h>
+
+struct usb4640 {
+ enum usb4640_mode mode;
+ struct device *dev;
+ int gpio_reset;
+};
+
+static int usb4640_reset(struct usb4640 *hub, int state)
+{
+ if (gpio_is_valid(hub->gpio_reset))
+ gpio_set_value_cansleep(hub->gpio_reset, state);
+
+ /* Wait 1ms for hub logic to stabilize */
+ if (state)
+ usleep_range(, );
+
+ return ;
+}
+
+static int usb4640_connect(struct usb4640 *hub)
+{
+ struct device *dev = hub->dev;
+
+ usb4640_reset(hub, );
+ hub->mode = USB4640_MODE_HUB;
+ dev_info(dev, "switched to HUB mode\n");
+
+ return ;
+}
+
+static int usb4640_switch_mode(struct usb4640 *hub, enum usb4640_mode mode)
+{
+ struct device *dev = hub->dev;
+ int err = ;
+
+ switch (mode) {
+ case USB4640_MODE_HUB:
+ err = usb4640_connect(hub);
+ break;
+
+ case USB4640_MODE_STANDBY:
+ usb4640_reset(hub, );
+ dev_info(dev, "switched to STANDBY mode\n");
+ break;
+
+ default:
+ dev_err(dev, "unknown mode is requested\n");
+ err = -EINVAL;
+ break;
+ }
+
+ return err;
+}
+
+
+static int usb4640_probe(struct usb4640 *hub)
+{
+ struct device *dev = hub->dev;
+ struct usb4640_platform_data *pdata = dev_get_platdata(dev);
+ struct device_node *np = dev->of_node;
+ int err;
+ u32 mode = USB4640_MODE_HUB;
+
+ if (pdata) {
+ hub->gpio_reset = pdata->gpio_reset;
+ hub->mode = pdata->initial_mode;
+ } else if (np) {
+ hub->gpio_reset = of_get_named_gpio(np, "reset-gpios", );
+ if (hub->gpio_reset == -EPROBE_DEFER)
+ return -EPROBE_DEFER;
+ of_property_read_u32(np, "initial-mode", &mode);
+ hub->mode = mode;
+ }
+
+ if (gpio_is_valid(hub->gpio_reset)) {
+ err = devm_gpio_request_one(dev, hub->gpio_reset,
+ GPIOF_OUT_INIT_LOW, "usb4640 reset");
+ if (err) {
+ dev_err(dev,
+ "unable to request GPIO %d as reset pin (%d)\n",
+ hub->gpio_reset, err);
+ return err;
+ }
+ } else
+ dev_err(dev, "reset gpio is invalid: %d\n", hub->gpio_reset);
+
+ usb4640_switch_mode(hub, hub->mode);
+
+ dev_info(dev, "%s: probed in %s mode\n", __func__,
+ (hub->mode == USB4640_MODE_HUB) ? "hub" : "standby");
+
+ return ;
+}
+
+static int usb4640_platform_probe(struct platform_device *pdev)
+{
+ struct usb4640 *hub;
+
+ hub = devm_kzalloc(&pdev->dev, sizeof(struct usb4640), GFP_KERNEL);
+ if (!hub)
+ return -ENOMEM;
+ hub->dev = &pdev->dev;
+
+ return usb4640_probe(hub);
+}
+
+#ifdef CONFIG_OF
+static const struct of_device_id usb4640_of_match[] = {
+ { .compatible = "smsc,usb4640", },
+ {},
+};
+MODULE_DEVICE_TABLE(of, usb4640_of_match);
+#endif
+
+static struct platform_driver usb4640_platform_driver = {
+ .driver = {
+ .name = USB4640_NAME,
+#ifdef CONFIG_OF
+ .of_match_table = of_match_ptr(usb4640_of_match),
+#endif
+ },
+ .probe = usb4640_platform_probe,
+};
+
+static int __init usb4640_init(void)
+{
+ int err;
+
+ err = platform_driver_register(&usb4640_platform_driver);
+ if (err != )
+ pr_err("usb4640: Failed to register platform driver: %d\n",
+ err);
+
+ return ;
+}
+module_init(usb4640_init);
+
+static void __exit usb4640_exit(void)
+{
+ platform_driver_unregister(&usb4640_platform_driver);
+}
+module_exit(usb4640_exit);
+
+MODULE_DESCRIPTION("USB4640 USB HUB driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/usb/misc/Makefile b/drivers/usb/misc/Makefile
index 45fd4ac..98f81ed
--- a/drivers/usb/misc/Makefile
+++ b/drivers/usb/misc/Makefile
@@ -, +, @@ obj-$(CONFIG_USB_USS720) += uss720.o
obj-$(CONFIG_USB_SEVSEG) += usbsevseg.o
obj-$(CONFIG_USB_YUREX) += yurex.o
obj-$(CONFIG_USB_HSIC_USB3503) += usb3503.o
+
+obj-$(CONFIG_USB_HSIC_USB4640) += usb4640.o
+
obj-$(CONFIG_USB_CHAOSKEY) += chaoskey.o obj-$(CONFIG_USB_SISUSBVGA) += sisusbvga/
diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig
index f7a7fc2..9692ca5
--- a/drivers/usb/misc/Kconfig
+++ b/drivers/usb/misc/Kconfig
@@ -, +, @@ config USB_HSIC_USB3503
help
This option enables support for SMSC USB3503 HSIC to USB 2.0 Driver. +config USB_HSIC_USB4640
+ tristate "USB4640 HSIC to USB20 Driver"
+ help
+ This option enables support for SMSC USB4640 HSIC to USB 2.0 Driver.
+
config USB_LINK_LAYER_TEST
tristate "USB Link Layer Test driver"
help
diff --git a/arch/arm/boot/dts/exynos4412-tiny4412.dts b/arch/arm/boot/dts/exynos
index 048ae67..948f2d9
--- a/arch/arm/boot/dts/exynos4412-tiny4412.dts
+++ b/arch/arm/boot/dts/exynos4412-tiny4412.dts
@@ -, +, @@
/dts-v1/;
#include "exynos4412.dtsi"
#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/usb4640/usb4640.h> / {
model = "FriendlyARM TINY4412 board based on Exynos4412";
@@ -, +, @@ chosen {
stdout-path = &serial_0;
- bootargs="root=/dev/ram0 rw rootfstype=ext4 console=ttySAC0,115200 init=
- };
+ bootargs="root=/dev/ram0 rw rootfstype=ext4 console=ttySAC0,115200 et hmac=1C:6F:65:34:51:7E init=/linuxrc ignore_loglevel earlyprink";
+
+ };
+ memory {
+ device_type = "memory";
reg = <0x40000000 0x40000000>;
};
-
+
leds {
compatible = "gpio-leds"; @@ -, +, @@
clock-frequency = <>;
};
};
+
+ usb-hub {
+ compatible = "smsc,usb4640";
+ reset-gpios = <&gpm2 GPIO_ACTIVE_LOW>;
+ initial-mode = <USB4640_MODE_HUB>;
+ status = "okay";
+ };
}; +
+
&rtc {
status = "okay";
};
@@ -, +, @@
&serial_3 {
status = "okay";
};
+
+&mshc_0 {
+ pinctrl- = <&sd4_clk &sd4_cmd &sd4_bus4 &sd4_bus8>;
+ pinctrl-names = "default";
+ status = "okay";
+
+ num-slots = <>;
+ broken-cd;
+ card-detect-delay = <>;
+ samsung,dw-mshc-ciu-div = <>;
+ samsung,dw-mshc-sdr-timing = < >;
+ samsung,dw-mshc-ddr-timing = < >;
+ bus-width = <>;
+ cap-mmc-highspeed;
+};
+
+
+&exynos_usbphy {
+ status = "okay";
+};
+
+&ehci {
+ status = "okay";
+ port@ {
+ status = "okay";
+ };
+ port@ {
+ status = "okay";
+ };
+ port@ {
+ status = "okay";
+ };
+};
+
+&ohci {
+ status = "okay";
+ port@ {
+ status = "okay";
+ };
+};
+
+&hsotg {
+ status = "okay";
+};
+
diff --git a/tiny4412_defconfig b/tiny4412_defconfig
index 91cba5b..178cea8
--- a/tiny4412_defconfig
+++ b/tiny4412_defconfig
@@ -, +, @@ CONFIG_USB_NET_CDCETHER=y
CONFIG_USB_NET_CDC_NCM=y
# CONFIG_USB_NET_HUAWEI_CDC_NCM is not set
# CONFIG_USB_NET_CDC_MBIM is not set
-# CONFIG_USB_NET_DM9601 is not set
+CONFIG_USB_NET_DM9601=y
# CONFIG_USB_NET_SR9700 is not set
# CONFIG_USB_NET_SR9800 is not set
CONFIG_USB_NET_SMSC75XX=y
@@ -, +, @@ CONFIG_USB_DWC2_DUAL_ROLE=y
# CONFIG_USB_ISIGHTFW is not set
# CONFIG_USB_YUREX is not set
# CONFIG_USB_EZUSB_FX2 is not set
-CONFIG_USB_HSIC_USB3503=y
+# CONFIG_USB_HSIC_USB3503 is not set
+CONFIG_USB_HSIC_USB4640=y
# CONFIG_USB_LINK_LAYER_TEST is not set
# CONFIG_USB_CHAOSKEY is not set
结果:
发现缺少IP地址
[root@tiny4412:/]#ifconfig eth0 192.168.1.130
完成。
linux-kernel-4.4 移植 (3) 网卡移植的更多相关文章
- 【转】 linux内核移植和网卡驱动(二)
原文网址:http://blog.chinaunix.net/uid-29589379-id-4708911.html 一,内核移植步骤: 1, 修改顶层目录下的Makefile ARCH ...
- 基于tiny4412的Linux内核移植 -- DM9621NP网卡驱动移植(四)
作者信息 作者: 彭东林 邮箱:pengdonglin137@163.com QQ:405728433 平台简介 开发板:tiny4412ADK + S700 + 4GB Flash 要移植的内核版本 ...
- 移植Linux Kernel SM750 驱动到VxWorks 7
一.SM750简介 SM750 是SiliconMotion 推出的一款适合嵌入式设备的显卡(Embedded GPU),采用PCIe接口与CPU连接,内部集成16MB DDR SDRAM显存,产品具 ...
- 27.Linux-DM9000C网卡移植(详解)
上一节 我们学习了: 网卡驱动介绍以及制作虚拟网卡驱动: http://www.cnblogs.com/lifexy/p/7763352.html 接下来本节,学习网卡芯片DM9000C,如何编写 ...
- 基于tiny4412的Linux内核移植 -- MMA7660驱动移植(九)
作者信息 作者: 彭东林 邮箱:pengdonglin137@163.com QQ:405728433 平台简介 开发板:tiny4412ADK + S700 + 4GB Flash 要移植的内核版本 ...
- 嵌入式Linux下MP4视频录制库MP4V2移植和简单介绍
**************************************************************************************************** ...
- Intel 80x86 Linux Kernel Interrupt(中断)、Interrupt Priority、Interrupt nesting、Prohibit Things Whthin CPU In The Interrupt Off State
目录 . 引言 . Linux 中断的概念 . 中断处理流程 . Linux 中断相关的源代码分析 . Linux 硬件中断 . Linux 软中断 . 中断优先级 . CPU在关中断状态下编程要注意 ...
- Linux Kernel - Debug Guide (Linux内核调试指南 )
http://blog.csdn.net/blizmax6/article/details/6747601 linux内核调试指南 一些前言 作者前言 知识从哪里来 为什么撰写本文档 为什么需要汇编级 ...
- Linux Kernel中断子系统来龙去脉浅析【转】
转自:http://blog.csdn.net/u011461299/article/details/9772215 版权声明:本文为博主原创文章,未经博主允许不得转载. 一般来说,在一个device ...
- andriod and linux kernel启动流程
虽然这里的Arm Linux kernel前面加上了Android,但实际上还是和普遍Arm linux kernel启动的过程一样的,这里只是结合一下Android的Makefile,讲一下boot ...
随机推荐
- factory di
services.AddScoped(typeof(Test)); //services.AddScoped<Test>() // .AddScoped<ITest, Test> ...
- 常见手机的设备分辨率、viewport和devicePixelRatio
常见手机的设备分辨率和viewport分辨率,及其1rem的大小(以vmin为单位) 常见的devicePixelRatio是1, 1.325, 1.5, 2, 2.4, 3. (具体见下面的表格, ...
- hanlp使用自定义词典抽取关键词
1.在data/dictionary/custom/路径下新建文件 myDict.txt.,添加新的单词,单词,词性,词频.并删除当前文件夹下的bin文件, 2.在hanlp配置文件中的CustomD ...
- windows 查看端口占用、关闭端口
cmd打卡命令窗口 1)netstat -an 查看所有活动连接 2)netstat -aon| findstr “xxxx” 找到指定端口的连接 3)taskkill /F /PID xxxx 终 ...
- java-索引
集合 集合之深入理解HashMap HashMap的实现原理,以及在JDK1.7和1.8的区别 Java集合---ConcurrentHashMap原理分析 ConcurrentHashMap原理分析 ...
- IntelliJ IDEA spring boot 远程Ddbug调试
一.idea配置 1.在idea中点击右上角的 "Edit Configurations" 2.点击+,选择Remote 3.在Name处为此次Dbug起个名字,在Host添加测试 ...
- Oracle所有分析函数<转>
Oracle分析函数——函数列表 SUM :该函数计算组中表达式的累积和 MIN :在一个组中的数据窗口中查找表达式的最小值 MAX :在一个组中的数据窗口中 ...
- Python paramiko模块基本使用(一)
使用paramiko模块登录远程主机,对日志进行统计分析. import paramiko def batch_count(days, hours, ips, user, passwd, source ...
- 接口--Comparable接口【哈夫曼树】
我们在字符串中见到过CompareTo方法,知道这个方法是用于比较字符串顺序的,根据字典顺序进行排序.Java中很多类也都有CompareTo方法,甚至于排序算法的底层组成也是依赖于比较的,而这个比较 ...
- 自定义编写js格式化数字的函数
在处理网页的时候,有时候会需要显示很长的数字,但是当数字的长度比较长的时候,就很难看一个数字到底是多大.这种情况下,一些网站在处理数字的时候,当数字的长度大于3个时,就用逗号把他们分开,这是一个比较常 ...