开发环境: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) 网卡移植的更多相关文章

  1. 【转】 linux内核移植和网卡驱动(二)

    原文网址:http://blog.chinaunix.net/uid-29589379-id-4708911.html 一,内核移植步骤: 1, 修改顶层目录下的Makefile ARCH       ...

  2. 基于tiny4412的Linux内核移植 -- DM9621NP网卡驱动移植(四)

    作者信息 作者: 彭东林 邮箱:pengdonglin137@163.com QQ:405728433 平台简介 开发板:tiny4412ADK + S700 + 4GB Flash 要移植的内核版本 ...

  3. 移植Linux Kernel SM750 驱动到VxWorks 7

    一.SM750简介 SM750 是SiliconMotion 推出的一款适合嵌入式设备的显卡(Embedded GPU),采用PCIe接口与CPU连接,内部集成16MB DDR SDRAM显存,产品具 ...

  4. 27.Linux-DM9000C网卡移植(详解)

    上一节 我们学习了:   网卡驱动介绍以及制作虚拟网卡驱动: http://www.cnblogs.com/lifexy/p/7763352.html 接下来本节,学习网卡芯片DM9000C,如何编写 ...

  5. 基于tiny4412的Linux内核移植 -- MMA7660驱动移植(九)

    作者信息 作者: 彭东林 邮箱:pengdonglin137@163.com QQ:405728433 平台简介 开发板:tiny4412ADK + S700 + 4GB Flash 要移植的内核版本 ...

  6. 嵌入式Linux下MP4视频录制库MP4V2移植和简单介绍

    **************************************************************************************************** ...

  7. Intel 80x86 Linux Kernel Interrupt(中断)、Interrupt Priority、Interrupt nesting、Prohibit Things Whthin CPU In The Interrupt Off State

    目录 . 引言 . Linux 中断的概念 . 中断处理流程 . Linux 中断相关的源代码分析 . Linux 硬件中断 . Linux 软中断 . 中断优先级 . CPU在关中断状态下编程要注意 ...

  8. Linux Kernel - Debug Guide (Linux内核调试指南 )

    http://blog.csdn.net/blizmax6/article/details/6747601 linux内核调试指南 一些前言 作者前言 知识从哪里来 为什么撰写本文档 为什么需要汇编级 ...

  9. Linux Kernel中断子系统来龙去脉浅析【转】

    转自:http://blog.csdn.net/u011461299/article/details/9772215 版权声明:本文为博主原创文章,未经博主允许不得转载. 一般来说,在一个device ...

  10. andriod and linux kernel启动流程

    虽然这里的Arm Linux kernel前面加上了Android,但实际上还是和普遍Arm linux kernel启动的过程一样的,这里只是结合一下Android的Makefile,讲一下boot ...

随机推荐

  1. css选择器区别

    空格选择器 ul li 选择ul 下面的所有li 元素 大于号选择器  ul>li 选择ul 下面的直接子元素 只能是儿子辈的 不能是孙子辈的

  2. gentoo 画框架图,流程图

    需要话框架图,流程图的时候,只需要安装 dia 软件就可以了.

  3. spring boot 监听器实例

    在日常项目中订单创建成功后,会有类似各式各样的通知.有站内通知.短信通知.微信,app通知. 伪代码: 这里,只用伪代码示例.各式各样的通知 肯定不只一行代码.只是简化.如果后续还要增加各种各样的通知 ...

  4. uva-108-贪心

    题意: 求二维数组中子数组中的最大和. 使用二维数组,第i行表示前i行的和.那么a[i-j]表示从j行到i行的和.注意第三层循环,每次都保存当前最大的sum,如果sum小于0,直接置0. #inclu ...

  5. matlab-逻辑回归二分类(Logistic Regression)

    逻辑回归二分类 今天尝试写了一下逻辑回归分类,把代码分享给大家,至于原理的的话请戳这里 https://blog.csdn.net/laobai1015/article/details/7811321 ...

  6. Exce 快捷键 tips

    1. 填充快捷键 ctrl+R  向下填充 CTRL+D 向右填充 2. 筛选快捷键 CTRL+SHIFT+L 3. 移动到当前区域的边缘: Ctrl + shift + 方向箭头 4. 字符连接:& ...

  7. PHP入门——基本巩固

    ----------一.变量 ----------二.运算 ----------三.控制结构 ----------四.函数 ----------六.字符串 ----------七.数组 ------- ...

  8. win10如何查看文件扩展名

    就可以修改扩展名,修改文件类型.

  9. 超简单(两步)-微信怎么实现打开外部浏览器,下载app,打开网页URL

    现在微信渠道可以说是拉新最快的渠道,因为微信具备强裂变性.但是目前微信对第三方下载链接的拦截是越来越严格了,那么想要在微信内肆无忌惮地推广链接就需要用到微信跳转浏览器的接口,那如何获取该接口呢?   ...

  10. 深入理解Java虚拟机之JVM垃圾回收随笔

    1.对象已经死亡? 1.1引用计数法:给对象中添加一个引用计数器,每当有一个地方引用他时,计数器值就加1:当引用失效时,计数器值就减1:任何时刻计数器都为0的对象就是不可能再被使用 的.但是它很难解决 ...