/******************************************************************************
* I.MX6 make menuconfig OTG to slave only mode
* 声明:
* 本文通过跟踪代码的方式来了解如何将I.MX6的OTG的Host模式去掉,仅仅剩下
* slave模式,主要是有些场合仅仅需要slave模式。
*
* 2015-9-5 晴 深圳 南山平山村 曾剑锋
*****************************************************************************/ <kernel path>/drivers/usb/otg/fsl_otg.c static int __init fsl_usb_otg_init(void) <----------------------------+
{ |
printk(KERN_INFO DRIVER_DESC " loaded, %s\n", DRIVER_VERSION); |
return platform_driver_register(&fsl_otg_driver); |
} | |
| |
static void __exit fsl_usb_otg_exit(void) +-------------+ |
{ | |
platform_driver_unregister(&fsl_otg_driver); | |
printk(KERN_INFO DRIVER_DESC " unloaded\n"); | |
} | |
| |
subsys_initcall(fsl_usb_otg_init); --------------------|---------------+
module_exit(fsl_usb_otg_exit); |
|
MODULE_DESCRIPTION(DRIVER_INFO); |
MODULE_AUTHOR(DRIVER_AUTHOR); |
MODULE_LICENSE("GPL"); |
|
|
struct platform_driver fsl_otg_driver = { <-------------+
.probe = fsl_otg_probe,
.remove = fsl_otg_remove,
.driver = {
.name = driver_name, --------+
.owner = THIS_MODULE, |
}, |
}; |
V
static const char driver_name[] = "fsl-usb2-otg"; -------------+
|
|
<kernel path>/arch/arm$ grep fsl-usb2-otg * -R |
Binary file boot/Image matches |
mach-mx5/devices.c: .name = "fsl-usb2-otg", |
...... |
Binary file plat-mxc/devices/built-in.o matches V
-+- plat-mxc/devices/platform-fsl-usb2-otg.c: const char *name = "fsl-usb2-otg";
| Binary file plat-mxc/built-in.o matches |
+--------------------------------------------+ |
V |
<kernel path>/arch/arm/plat-mxc/devices/platform-fsl-usb2-otg.c |
#define imx_fsl_usb2_otg_data_entry_single(soc) \ |
{ \ |
.iobase = soc ## _USB_OTG_BASE_ADDR, \ |
.irq = soc ## _INT_USB_OTG, \ |
} |
|
|
#ifdef CONFIG_SOC_IMX6Q |
const struct imx_fsl_usb2_otg_data imx6q_fsl_usb2_otg_data __initconst = |
imx_fsl_usb2_otg_data_entry_single(MX6Q); |
#endif /* ifdef CONFIG_SOC_IMX6Q */ |
|
struct platform_device *__init imx_add_fsl_usb2_otg( ----------+ |
const struct imx_fsl_usb2_otg_data *data, | |
const struct fsl_usb2_platform_data *pdata) | |
{ | |
struct resource res[] = { | |
{ | |
.start = data->iobase, | |
.end = data->iobase + SZ_512 - , | |
.flags = IORESOURCE_MEM, | |
}, { | |
.start = data->irq, | |
.end = data->irq, | |
.flags = IORESOURCE_IRQ, | |
}, | |
}; | |
| |
int ret = -ENOMEM; | |
const char *name = "fsl-usb2-otg"; <-------------------------|---+
int id = -; |
unsigned int num_resources = ARRAY_SIZE(res); |
size_t size_data = sizeof(*pdata); |
u64 dmamask = DMA_BIT_MASK(); |
struct platform_device *pdev; |
|
pdev = platform_device_alloc(name, id); |
if (!pdev) |
goto err; |
|
if (dmamask) { |
/* |
* This memory isn't freed when the device is put, |
* I don't have a nice idea for that though. Conceptually |
* dma_mask in struct device should not be a pointer. |
* See http://thread.gmane.org/gmane.linux.kernel.pci/9081 |
*/ |
pdev->dev.dma_mask = |
kmalloc(sizeof(*pdev->dev.dma_mask), GFP_KERNEL); |
if (!pdev->dev.dma_mask) |
/* ret is still -ENOMEM; */ |
goto err; |
|
*pdev->dev.dma_mask = dmamask; |
pdev->dev.coherent_dma_mask = dmamask; |
} |
|
ret = platform_device_add_resources(pdev, res, num_resources); |
if (ret) |
goto err; |
|
if (data) { |
ret = platform_device_add_data(pdev, pdata, size_data); |
if (ret) |
goto err; |
} |
|
return pdev; |
err: |
if (dmamask) |
kfree(pdev->dev.dma_mask); |
platform_device_put(pdev); |
return ERR_PTR(ret); |
} |
EXPORT_SYMBOL(imx_add_fsl_usb2_otg); |
|
<kernel path>/arch/arm$ grep imx_add_fsl_usb2_otg * -R <-------------+
Binary file boot/Image matches
-+- mach-mx6/devices-imx6q.h: imx_add_fsl_usb2_otg(&imx6q_fsl_usb2_otg_data, pdata) ----------+
| ...... |
| plat-mxc/devices/platform-fsl-usb2-otg.c:struct platform_device *__init imx_add_fsl_usb2_otg( |
| plat-mxc/devices/platform-fsl-usb2-otg.c:EXPORT_SYMBOL(imx_add_fsl_usb2_otg); |
| Binary file plat-mxc/built-in.o matches |
+----------------------------------+ |
V |
<kernel path>/arch/arm/mach-mx6/devices-imx6q.h |
extern const struct imx_fsl_usb2_otg_data imx6q_fsl_usb2_otg_data __initconst; |
#define imx6q_add_fsl_usb2_otg(pdata) \ -------------------+ |
imx_add_fsl_usb2_otg(&imx6q_fsl_usb2_otg_data, pdata) <------------------*------+
|
<kernel path>/arch/arm$ grep imx6q_add_fsl_usb2_otg * -R |
Binary file mach-mx6/.usb_dr.c.swp matches |
mach-mx6/devices-imx6q.h:#define imx6q_add_fsl_usb2_otg(pdata) \ |
mach-mx6/devices-imx6q.h:#define imx6q_add_fsl_usb2_otg_wakeup(pdata) \ |
mach-mx6/usb_dr.c: pdev[i] = imx6q_add_fsl_usb2_otg(&dr_utmi_config); |
mach-mx6/usb_dr.c: pdev_wakeup = imx6q_add_fsl_usb2_otg_wakeup(&dr_wakeup_config); |
|
<kernel path>/arch/arm/mach-mx6/usb_dr.c |
static int __init mx6_usb_dr_init(void) |
{ |
int i = ; |
void __iomem *anatop_base_addr = MX6_IO_ADDRESS(ANATOP_BASE_ADDR); |
struct imx_fsl_usb2_wakeup_data imx6q_fsl_otg_wakeup_data = |
imx_fsl_usb2_wakeup_data_entry_single(MX6Q, , OTG); |
struct imx_mxc_ehci_data __maybe_unused imx6q_mxc_ehci_otg_data = |
imx_mxc_ehci_data_entry_single(MX6Q, , OTG); |
struct imx_fsl_usb2_udc_data __maybe_unused imx6q_fsl_usb2_udc_data = |
imx_fsl_usb2_udc_data_entry_single(MX6Q); |
struct imx_fsl_usb2_otg_data __maybe_unused imx6q_fsl_usb2_otg_data = |
imx_fsl_usb2_otg_data_entry_single(MX6Q); |
|
/* Some phy and power's special controls for otg |
* 1. The external charger detector needs to be disabled |
* or the signal at DP will be poor |
* 2. The EN_USB_CLKS is always enabled. |
* The PLL's power is controlled by usb and others who |
* use pll3 too. |
*/ |
__raw_writel(BM_ANADIG_USB1_CHRG_DETECT_EN_B \ |
| BM_ANADIG_USB1_CHRG_DETECT_CHK_CHRG_B, \ |
anatop_base_addr + HW_ANADIG_USB1_CHRG_DETECT); |
__raw_writel(BM_ANADIG_USB1_PLL_480_CTRL_EN_USB_CLKS, |
anatop_base_addr + HW_ANADIG_USB1_PLL_480_CTRL_SET); |
mx6_get_otghost_vbus_func(&mx6_set_usb_otg_vbus); |
dr_utmi_config.platform_driver_vbus = mx6_set_usb_otg_vbus; |
|
#ifdef CONFIG_USB_OTG |
/* wake_up_enable is useless, just for usb_register_remote_wakeup execution*/ |
dr_utmi_config.wake_up_enable = _device_wakeup_enable; |
dr_utmi_config.operating_mode = FSL_USB2_DR_OTG; |
dr_utmi_config.wakeup_pdata = &dr_wakeup_config; |
pdev[i] = imx6q_add_fsl_usb2_otg(&dr_utmi_config); <------------------------+
dr_wakeup_config.usb_pdata[i] = pdev[i]->dev.platform_data;
i++;
#endif
#ifdef CONFIG_USB_EHCI_ARC_OTG -------------------------+
dr_utmi_config.operating_mode = DR_HOST_MODE; |
dr_utmi_config.wake_up_enable = _host_wakeup_enable; |
if (usb_icbug_swfix_need()) { |
dr_utmi_config.platform_rh_suspend = _host_platform_rh_suspend_swfix; |
dr_utmi_config.platform_rh_resume = _host_platform_rh_resume_swfix; |
} else { |
dr_utmi_config.platform_rh_suspend = _host_platform_rh_suspend; |
dr_utmi_config.platform_rh_resume = _host_platform_rh_resume; |
} |
dr_utmi_config.platform_set_disconnect_det = fsl_platform_otg_set_usb_phy_dis; |
dr_utmi_config.phy_lowpower_suspend = _host_phy_lowpower_suspend; |
dr_utmi_config.is_wakeup_event = _is_host_wakeup; |
dr_utmi_config.wakeup_pdata = &dr_wakeup_config; |
dr_utmi_config.wakeup_handler = host_wakeup_handler; |
dr_utmi_config.platform_phy_power_on = dr_platform_phy_power_on; |
pdev[i] = imx6q_add_fsl_ehci_otg(&dr_utmi_config); |
dr_wakeup_config.usb_pdata[i] = pdev[i]->dev.platform_data; |
i++; |
#endif |
#ifdef CONFIG_USB_GADGET_ARC |
dr_utmi_config.operating_mode = DR_UDC_MODE; |
dr_utmi_config.wake_up_enable = _device_wakeup_enable; |
dr_utmi_config.platform_rh_suspend = NULL; |
dr_utmi_config.platform_rh_resume = NULL; |
dr_utmi_config.platform_set_disconnect_det = NULL; |
dr_utmi_config.phy_lowpower_suspend = _device_phy_lowpower_suspend; |
dr_utmi_config.is_wakeup_event = _is_device_wakeup; |
dr_utmi_config.wakeup_pdata = &dr_wakeup_config; |
dr_utmi_config.wakeup_handler = device_wakeup_handler; |
dr_utmi_config.charger_base_addr = anatop_base_addr; |
dr_utmi_config.platform_phy_power_on = dr_platform_phy_power_on; |
pdev[i] = imx6q_add_fsl_usb2_udc(&dr_utmi_config); |
dr_wakeup_config.usb_pdata[i] = pdev[i]->dev.platform_data; |
i++; |
#endif |
devnum = i; |
/* register wakeup device */ |
pdev_wakeup = imx6q_add_fsl_usb2_otg_wakeup(&dr_wakeup_config); |
for (i = ; i < devnum; i++) { |
platform_device_add(pdev[i]); |
((struct fsl_usb2_platform_data *)(pdev[i]->dev.platform_data))->wakeup_pdata = |
(struct fsl_usb2_wakeup_platform_data *)(pdev_wakeup->dev.platform_data); |
} |
|
return ; |
} |
module_init(mx6_usb_dr_init); |
|
<kernel path>$ make menuconfig |
| Symbol: USB_EHCI_ARC_OTG [=n] <--------------------------------*--------------------+
│ Type : boolean |
│ Prompt: Support for DR host port on Freescale controller |
│ Defined at drivers/usb/host/Kconfig: |
│ Depends on: USB_SUPPORT [=y] && USB_EHCI_ARC [=y] |
│ Location: |
│ -> Device Drivers |
│ -> USB support (USB_SUPPORT [=y]) |
│ -> Support for Freescale controller (USB_EHCI_ARC [=y]) |

I.MX6 make menuconfig OTG to slave only mode的更多相关文章

  1. I.MX6 make menuconfig进入x86模式

    /************************************************************************ * I.MX6 make menuconfig进入x ...

  2. I.MX6 OTG set as slave device hacking

    /****************************************************************************** * IMX6 OTG set as sl ...

  3. imx6 usb otg config 配置

    imx6 usb的host和slave配置,配置之后,安装gadget模块,就能够在host和slave之间切换. 参考文档: i.MX 6Dual/6Quad Linux Reference Man ...

  4. USB OTG插入检测识别

    转载请标注原文地址:http://blog.csdn.net/uranus_wm/article/details/9838847 一 USB引脚一般四根线,定义如下: 为支持OTG功能,mini/mi ...

  5. imx6 otg host support

    本文记录添加imx6 otg host支持的过程. 参考链接 http://www.cnblogs.com/helloworldtoyou/p/6108560.html https://communi ...

  6. imx6 关闭 otg host

    参考文档: http://www.cnblogs.com/zengjfgit/p/4711336.html make menuconfig 去掉Support for DR host port on ...

  7. I.MX6 bq27441 driver porting

    /************************************************************************** * I.MX6 bq27441 driver p ...

  8. I.MX6 PMU MMPF0100 driver porting

    /************************************************************************** * I.MX6 MMPF0100 driver ...

  9. USB OTG

    OTG检测的原理是:USB OTG标准在完全兼容USB2.0标准的基础上,增添了电源管理(节省功耗)功能,它允许设备既可作为主机,也可作为外设操作(两用OTG).USB OTG技术可实现没有主机时设备 ...

随机推荐

  1. Could not find a package configuration file provided by 'ecl_threads' ,.................couldn't find required component 'ecl_threads'

    sudo apt-get install ros-kinetic-ecl-threads

  2. Springboot 学习笔记 之 Day 4 笔记部分

    spring-boot-starter 核心Spring Boot starter,包括自动配置支持,日志和YAMLspring-boot-starter-actuator 生产准备的特性,用于帮你监 ...

  3. Spring AOP之使用注解创建切面

    上节中我们已经定义了Performance接口,他是切面中的切点的一个目标对象.那么现在就让我们使用AspectJ注解来定义切面吧. 1.定义切面 下面我们就来定义一场舞台剧中观众的切面类Audien ...

  4. 编写 R Markdown 文档

    数据分析师的工作不仅是将数据放入模型并得出一些结论.通常需要完成从数据收集.数据清理.可视化.建模再到最后编写报告或制作演示文稿的完整工作流程.在前面几章中,我们从不同方面深入学习 R 编程语言,从各 ...

  5. Redis 安装到linux系统

    下载地址 : http://download.redis.io/releases/redis-3.0.3.tar.gz ). tar -zxvf redis-.tar.gz -C /usr/share ...

  6. Codeforces 483B - Friends and Presents(二分+容斥)

    483B - Friends and Presents 思路:这个博客写的不错:http://www.cnblogs.com/windysai/p/4058235.html 代码: #include& ...

  7. 动态规划-Largest Sum of Averages

    2018-07-12 23:21:53 问题描述: 问题求解: dp[i][j] : 以ai结尾的分j个部分得到的最大值 dp[i][j] = max{dp[k][j - 1] + (ak+1 + . ...

  8. 12月16日 增加一个购物车内product数量的功能, 自定义method,在helper中定义,计算代码Refactor到Model中。

    仿照Rails实战:购物网站 教材:5-6 step5:计算总价,做出在nav上显示购物车内product的数量. 遇到的❌: 1. <% sum = 0 %> <% current ...

  9. codeforces 700a//As Fast As Possible// Codeforces Round #364(Div. 1)

    题意:n个人要运动ll长,有个bus带其中几个人,问最短时间 最后所有人在同一时间到终点是用时最少的.由于搭bus相当于加速,每个人的加速时间应该一样.先计算bus走过的路程route.看第一个人被搭 ...

  10. Nodejs AES加密

    这几天被一个问题困扰着. Nodejs的AES加密和Java,C#加密出来的不一致.当然,这样就不能解密了. 纠结了许久:后来还是实在不行了,看了下源代码,要不然还得继续纠结下去. 网上说,通常的no ...