开发环境: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. [STM32F103]串口UART配置

    l 串口时钟使能,GPIO时钟使能: RCC_APB2PeriphClockCmd(); l 串口复位: USART_DeInit(); 这一步不是必须的 l GPIO端口模式设置: GPIO_Ini ...

  2. redis哨兵架构的基础知识及部署和管理

    一.前言 1.哨兵的介绍 sentinal,中文名是哨兵 哨兵是redis集群架构中非常重要的一个组件,主要功能如下 ()集群监控,负责监控redis master和slave进程是否正常工作 ()消 ...

  3. React Native仿京东客户端实现(首页 分类 发现 购物车 我的)五个Tab导航页面

    1.首先创建  这几个文件 myths-Mac:JdApp myth$ yarn add react-native-tab-navigator 2.各个文件完整代码 1)CartPage.js imp ...

  4. Windows环境下在sublime text3配置C编译环境

    1. 检查本机有没有安装GCC,没有的话先进行安装 2. 选择 sublime 的Tools->Build System->New Build System,建立配置文件,文件命名为C.s ...

  5. windows 查看端口占用、关闭端口

    cmd打卡命令窗口 1)netstat -an 查看所有活动连接 2)netstat -aon| findstr “xxxx” 找到指定端口的连接 3)taskkill  /F /PID xxxx 终 ...

  6. Angular6 Observable.fromEvent error: “Invalid event target”

    今天在angular6项目中写了个拖拽功能,但是控制台报错,如图 后来在控制台打出发现,原来是 ngOnInit( ) 这个生命周期里,页面的dom节点还未产生,还只是null. 改为用 ngAfte ...

  7. 【Python】爬虫

    参考:http://www.cnblogs.com/fnng/p/3576154.html import urllib,re page = urllib.urlopen('http://trend.b ...

  8. matlab-霍夫变换详解(判断正方形长方形)

    霍夫变换 霍夫变换是1972年提出来的,最开始就是用来在图像中过检测直线,后来扩展能检测圆.曲线等. 直线的霍夫变换就是 把xy空间的直线 换成成 另一空间的点.就是直线和点的互换. 我们在初中数学中 ...

  9. Jenkins+Git+Maven构建并部署war包到tomcat

    主要思路:1.jenkins从git中拉取项目源码:jenkins使用maven构建并将生成的war部署到tomcat容器下. 环境:Centos7.Maven3.5.3.git(单机) 安装Git ...

  10. python深拷贝,浅拷贝

    1.浅拷贝, 首先要引用copy包 from copy import copy class A: def __init__(self): self.A=1 self.B=2 a = A() copy( ...