USB Devices Disabled,广东求助网

usb 接口识别不出来 - i.MX产品 - 恩智浦技术社区
后使用快捷导航没有帐号?
查看: 5490|回复: 3
usb 接口识别不出来
该用户从未签到主题帖子积分
新手上路, 积分 5, 距离下一级还需 45 积分
新手上路, 积分 5, 距离下一级还需 45 积分
手上的是客户提供的imx6dq板子,板子是客户自己画的,一开始USB功能都没有问题。前一阵子手贱了下,不知道改了什么东西,现在只能在刷机模式识别usb接口,正常启动android系统后,Ubuntu识别不了板子上的usb设备。下面是串口log,还望帮帮忙,着急累了,谢谢了!!!!
kernel cmdline:
use boot.img command line:
console=ttymxc3,115200 init=/init video=mxcfb0:dev=lcd,CLAA-WVGA,if=RGB24,bpp=32 video=mxcfb1ff video=mxcfb2ff fbme
Starting kernel ...
0.000000] Initializing cgroup subsys cpu
0.000000] Linux version 3.0.35-0bd2 (inuyasha@inuyasha-Aspire-4741) (gcc version 4.6.x-google
(prerelea4
0.000000] CPU: ARMv7 Processor [412fc09a] revision 10 (ARMv7), cr=10c53c7d
0.000000] CPU: VIPT nonaliasing data cache, VIPT aliasing instruction cache
0.000000] Machine: Freescale i.MX 6Quad/DualLite/Solo Sabre-SD Board
0.000000] Memory policy: ECC disabled, Data cache writealloc
0.000000] CPU identified as i.MX6DL/SOLO, silicon rev 1.1
0.000000] PERCPU: Embedded 7 pages/cpu @c10c r u32768
0.000000] Built 1 zonelists in Zone order, mobility grouping on.
Total pages: 208384
0.000000] Kernel command line: console=ttymxc3,115200 init=/init video=mxcfb0:dev=lcd,CLAA-WVGA,if=RGB24,bpp=32 video=mxcfe
0.000000] PID hash table entries: 2048 (order: 1, 8192 bytes)
0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
0.000000] Memory: 379MB 203MB 240MB = 822MB total
0.000000] Memory: 3920k available, 224656k reserved, 442368K highmem
0.000000] Virtual kernel memory layout:
: 0xffff0000 - 0xffff1000
: 0xfff00000 - 0xfffe0000
: 0xfbe00000 - 0xffe00000
vmalloc : 0xd9800000 - 0xf2000000
: 0xc0000000 - 0xd9000000
: 0xbfe00000 - 0xc0000000
modules : 0xbf000000 - 0xbfe00000
.init : 0xc0008000 - 0xc003e000
.text : 0xc003e000 - 0xc06d9f38
.data : 0xc06da000 - 0xc0743e90
.bss : 0xc0743eb4 - 0xc08baf88
0.000000] Preemptible hierarchical RCU implementation.
0.000000] NR_IRQS:624
0.000000] MXC GPIO hardware
0.000000] sched_clock: 32 bits at 3000kHz, resolution 333ns, wraps every 1431655ms
0.000000] Set periph_clk's parent to pll2_pfd_400M!
0.000000] arm_max_freq=1GHz
0.000000] MXC_Early serial console at MMIO 0x21f0000 (options '115200')
0.000000] bootconsole [ttymxc3] enabled
0.226533] Calibrating delay loop... 1581.05 BogoMIPS (lpj=7905280)
0.319264] pid_max: default: 32768 minimum: 301
0.324132] Mount-cache hash table entries: 512
0.329416] Initializing cgroup subsys debug
0.333707] Initializing cgroup subsys cpuacct
0.338209] Initializing cgroup subsys freezer
0.342737] CPU: Testing write buffer coherency: ok
0.347937] hw perfevents: enabled with ARMv7 Cortex-A9 PMU driver, 7 counters available
0.468563] CPU1: Booted secondary processor
0.527930] Brought up 2 CPUs
0.535190] SMP: Total of 2 processors activated (3162.11 BogoMIPS).
0.567036] print_constraints: dummy:
0.571075] NET: Registered protocol family 16
0.580584] print_constraints: vddpu: 725&&1300 mV at 700 mV fast normal
0.588153] print_constraints: vddcore: 725&&1300 mV at 1150 mV fast normal
0.595997] print_constraints: vddsoc: 725&&1300 mV at 1200 mV fast normal
0.603735] print_constraints: vdd2p5:
mV at 2400 mV fast normal
0.611558] print_constraints: vdd1p1: 800&&1400 mV at 1100 mV fast normal
0.619309] print_constraints: vdd3p0:
mV at 3000 mV fast normal
0.636605] the rate in mxc_cs4344_init=
0.650066] hw-breakpoint: found 6 breakpoint and 1 watchpoint registers.
0.656880] hw-breakpoint: 1 breakpoint(s) reserved for watchpoint single-step.
0.664255] hw-breakpoint: maximum watchpoint size is 4 bytes.
0.670152] L310 cache controller enabled
0.674180] l2x0: 16 ways, CACHE_ID 0x, AUX_CTRL 0x, Cache size: 524288 B
0.707617] bio: create slab&&at 0
0.715215] mxs-dma mxs-dma-apbh: initialized
0.720021] print_constraints: vmmc: 3300 mV
0.726081] SCSI subsystem initialized
0.730525] usbcore: registered new interface driver usbfs
0.736179] usbcore: registered new interface driver hub
0.741772] usbcore: registered new device driver usb
0.746845] Freescale USB OTG Driver loaded, $Revision: 1.55 $
0.947909] mc_pfuze 1-0008: recv failed!:-5,0
0.952380] mc_pfuze: probe of 1-0008 failed with error -1
0.959787] mxc_mipi_csi2 mxc_mipi_csi2: i.MX MIPI CSI2 driver probed
0.966253] mxc_mipi_csi2 mxc_mipi_csi2: i.MX MIPI CSI2 dphy version is 0x3130302a
0.974001] MIPI CSI2 driver module loaded
0.978373] Advanced Linux Sound Architecture Driver Version 1.0.24.
0.985858] i2c-core: driver [max17135] using legacy suspend method
0.992161] i2c-core: driver [max17135] using legacy resume method
0.998391] Switching to clocksource mxc_timer1
1.013329] NET: Registered protocol family 2
1.017877] IP route cache hash table entries: 16384 (order: 4, 65536 bytes)
1.025411] TCP established hash table entries: 65536 (order: 7, 524288 bytes)
1.033729] TCP bind hash table entries: 65536 (order: 7, 786432 bytes)
1.041519] TCP: Hash tables configured (established 65536 bind 65536)
1.048085] TCP reno registered
1.051242] UDP hash table entries: 256 (order: 1, 8192 bytes)
1.057124] UDP-Lite hash table entries: 256 (order: 1, 8192 bytes)
1.063794] NET: Registered protocol family 1
1.068332] Unpacking initramfs...
1.084631] Freeing initrd memory: 176K
1.089376] PMU: registered new PMU device of type 0
1.094536] Static Power Management for Freescale i.MX6
1.099780] wait mode is enabled for i.MX6
1.104117] cpaddr = d9820000 suspend_iram_base=d98b8000
1.109536] PM driver module loaded
1.113332] IMX usb wakeup probe
1.117086] add wake up source irq 75
1.124477] IMX usb wakeup probe
1.128026] cpu regulator mode:ldo_enable
1.132273] i.MXC CPU frequency driver
1.146154] highmem bounce pool size: 64 pages
1.150904] ashmem: initialized
1.154641] NTFS driver 2.1.30 [Flags: R/O].
1.158988] fuse init (API version 7.16)
1.163193] msgmni has been set to 745
1.168033] NET: Registered protocol family 38
1.172674] cryptodev: driver loaded.
1.176392] io scheduler noop registered
1.180328] io scheduler deadline registered
1.184677] io scheduler cfq registered (default)
1.190813] mxc_mipi_dsi mxc_mipi_dsi: i.MX MIPI DSI driver probed
1.197166] MIPI DSI driver module loaded
1.201389] mxc_sdc_fb mxc_sdc_fb.0: register mxc display driver lcd
1.208535] mxc_sdc_fb mxc_sdc_fb.1: Can't get fb option for mxcfb1!
1.215717] imx-sdma imx-sdma: loaded firmware 1.1
1.225525] imx-sdma imx-sdma: initialized
1.366772] Serial: IMX driver
1.369953] imx-uart.0: ttymxc0 at MMIO 0x2020000 (irq = 58) is a IMX
1.376931] imx-uart.3: ttymxc3 at MMIO 0x21f0000 (irq = 61) is a IMX
1.383435] console [ttymxc3] enabled, bootconsole disabled
1.383435] console [ttymxc3] enabled, bootconsole disabled
1.401210] loop: module loaded
1.405460] PPP generic driver version 2.4.2
1.410213] PPP Deflate Compression module registered
1.415297] PPP BSD Compression module registered
1.420455] PPP MPPE Compression module registered
1.425274] NET: Registered protocol family 24
1.429746] PPTP driver version 0.8.5
1.433724] tun: Universal TUN/TAP device driver, 1.6
1.438784] tun: (C)
Max Krasnyansky
1.445509] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
1.452264] fsl-ehci fsl-ehci.0: Freescale On-Chip EHCI Host Controller
1.458929] fsl-ehci fsl-ehci.0: new USB bus registered, assigned bus number 1
1.493011] fsl-ehci fsl-ehci.0: irq 75, io base 0x
1.512990] fsl-ehci fsl-ehci.0: USB 2.0 started, EHCI 1.00
1.519281] hub 1-0:1.0: USB hub found
1.523069] hub 1-0:1.0: 1 port detected
1.527188] add wake up source irq 72
1.530893] fsl-ehci fsl-ehci.1: Freescale On-Chip EHCI Host Controller
1.537542] fsl-ehci fsl-ehci.1: new USB bus registered, assigned bus number 2
1.573005] fsl-ehci fsl-ehci.1: irq 72, io base 0x
1.592991] fsl-ehci fsl-ehci.1: USB 2.0 started, EHCI 1.00
1.599220] hub 2-0:1.0: USB hub found
1.603004] hub 2-0:1.0: 1 port detected
1.607337] usbcore: registered new interface driver cdc_acm
1.613018] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
1.621025] Initializing USB Mass Storage driver...
1.626109] usbcore: registered new interface driver usb-storage
1.632161] USB Mass Storage support registered.
1.637096] usbcore: registered new interface driver usbserial
1.642937] usbserial: USB Serial Driver core
1.647431] USB Serial support registered for GSM modem (1-port)
1.653654] usbcore: registered new interface driver option
1.659229] option: v0.7.2:USB Driver for GSM modems
1.664328] USB Serial support registered for Qualcomm USB modem
1.670482] usbcore: registered new interface driver qcserial
1.676247] ARC USBOTG Device Controller driver (1 August 2005)
1.685981] android_usb gadget: Mass Storage Function, version:
1.692867] android_usb gadget: Number of LUNs=1
lun0: LUN: removable file: (no medium)
1.703048] Gadget Android: controller 'fsl-usb2-udc' not recognized
1.709415] android_usb gadget: android_usb ready
1.714137] Suspend udc for OTG auto detect
1.718328] fsl-usb2-udc: bind to driver android_usb
1.723937] mousedev: PS/2 mouse device common for all mice
1.730014] input: gpio-keys as /devices/platform/gpio-keys/input/input0
1.738855] using rtc device, snvs_rtc, for alarms
1.743506] snvs_rtc snvs_rtc.0: rtc core: registered snvs_rtc as rtc0
1.750382] i2c /dev entries driver
1.754813] Linux video capture interface: v2.00
1.759932] imx2-wdt imx2-wdt.0: IMX2+ Watchdog Timer enabled. timeout=60s (nowayout=0)
1.768190] device-mapper: uevent: version 1.0.3
1.773173] device-mapper: ioctl: 4.20.0-ioctl () initialised: dm-
1.781977] sdhci: Secure Digital Host Controller Interface driver
1.788181] sdhci: Copyright(c) Pierre Ossman
1.792952] mmc0: SDHCI controller on platform [sdhci-esdhc-imx.2] using ADMA
1.800441] mxc_vdoa mxc_vdoa: i.MX Video Data Order Adapter(VDOA) driver probed
1.808652] VPU initialized
1.812087] mxc_asrc registered
1.835701] revserved_memory_account:viv_gpu registerd
1.846809] Thermal calibration data is 0x
1.851604] Thermal sensor with ratio = 185
1.873024] Anatop Thermal registered as thermal_zone0
1.880216] anatop_thermal_probe: default cooling device is cpufreq!
1.888376] usbcore: registered new interface driver usbhid
1.893972] usbhid: USB HID core driver
1.898469] logger: created 256K log 'log_main'
1.903293] logger: created 256K log 'log_events'
1.908227] logger: created 256K log 'log_radio'
1.913091] logger: created 256K log 'log_system'
1.918606] usbcore: registered new interface driver snd-usb-audio
1.925509] mxc_hdmi_soc mxc_hdmi_soc.0: MXC HDMI Audio
1.931373] here run in cs4344_probe in cs4344.c
1.936051] usb 2-1: new high speed USB device number 2 using fsl-ehci
1.949954] mmc0: new high speed DDR MMC card at address 0001
1.956382] mmcblk0: mmc0:0001 MMC04G 3.57 GiB
1.956498] imx-hdmi-soc-dai imx-hdmi-soc-dai.0: Failed: Load HDMI-video first.
1.958363] asoc: cs4344-hifi&&imx-ssi.1 mapping ok
1.959228] here run in imx_asoc_init in imx-cs4344.c
1.959678] Initialize HDMI-audio failed. Load HDMI-video first!
1.959685] ALSA device list:
#0: cs4344-audio
1.960075] oprofile: using arm/armv7-ca9
1.994500] Netfilter messages via NETLINK v0.30.
1.999287] mmcblk0boot0: mmc0:0001 MMC04G partition 1 2.00 MiB
1.999319] nf_conntrack version 0.5.0 (12876 buckets, 51504 max)
2.011528] mmcblk0boot1: mmc0:0001 MMC04G partition 2 2.00 MiB
2.011544] ctnetlink v0.93: registering with nfnetlink.
2.011590] NF_TPROXY: Transparent proxy support initialized, version 4.1.0
2.011597] NF_TPROXY: Copyright (c)
BalaBit IT Ltd.
2.036117] xt_time: kernel timezone is -0000
2.040521] IPv4 over IPv4 tunneling driver
mmcblk0: p1 p2 p3 & p5 p6 p7 p8 p9 & p4
2.043287] mmcblk0: p4 size 5308416 extends beyond EOD, truncated
2.056853] GRE over IPv4 demultiplexor driver
mmcblk0boot1: unknown partition table
2.066487] ip_tables: (C)
Netfilter Core Team
2.071957] arp_tables: (C) 2002 David S. Miller
2.076747] TCP cubic registered
mmcblk0boot0: unknown partition table
2.084983] NET: Registered protocol family 10
2.090228] ip6_tables: (C)
Netfilter Core Team
2.096293] IPv6 over IPv4 tunneling driver
2.101897] NET: Registered protocol family 17
2.106403] NET: Registered protocol family 15
2.110854] L2TP core driver, V2.0
2.114302] PPPoL2TP kernel driver, V2.0
2.118226] L2TP IP encapsulation support (L2TPv3)
2.123118] L2TP netlink interface
2.126546] L2TP ethernet pseudowire support (L2TPv3)
2.131599] lib80211: common routines for IEEE802.11 drivers
2.137307] VFP support v0.3: implementor 41 architecture 3 part 30 variant 9 rev 4
2.145437] Bus freq driver module loaded
2.149457] Bus freq driver Enabled
2.154964] mxc_dvfs_core_probe
2.158390] DVFS driver module loaded
2.163169]&&GTP driver install.
2.167724]&&GTP Driver Version:V1.0
2.173593]&&GTP Driver build@15:39:31,Jan 27 2014
2.293315] input: Goodix Capacitive TouchScreen as /devices/virtual/input/input1
2.301412]&&GTP works in interrupt mode.
2.502988]&&GTP chip version:f811_2010
2.508045]&&Applied memory size:2562.
2.513044]&&Create proc entry success!
2.518778] Freeing init memory: 216K
2.522442] kernel_init done
3.131507] init: cannot find '/system/etc/install-recovery.sh', disabling 'flash_recovery'
3.214108] android_usb: already disabled
3.219485] android_usb: already disabled
3.223912] mtp_bind_config
3.226758] adb_bind_config
3.246743] warning: `adbd' uses 32-bit capabilities (legacy support in use)
3.258771] adb_open
root@android:/ # [
3.865360] imx-ipuv3 imx-ipuv3.0: Warning: channel already initialized 9
3.865408] imx-ipuv3 imx-ipuv3.0: Warning: channel already enabled 9
8.932873] init: sys_prop: permission denied uid:1003
name:service.bootanim.exit
10.992478] request_suspend_state: wakeup (3-&0) at
( 00:00:01. UTC)
11.001878] cpufreq_interactive_input_connect: connect to Goodix Capacitive TouchScreen
11.376761] acc_open
11.378967] acc_release
该用户从未签到主题帖子积分
回复:usb 接口识别不出来
我已经将你的问题转给我们的i.MX工程师
该用户从未签到主题帖子积分
新手上路, 积分 28, 距离下一级还需 22 积分
新手上路, 积分 28, 距离下一级还需 22 积分
RE:usb 接口识别不出来
你插一个USB Mouse上去会有反应嗎?
该用户从未签到主题帖子积分
回复:usb 接口识别不出来
如果问题解决了,麻烦楼主在求助帖标题末添加“(已解决)”字样。
如果有新的问题,也欢迎继续在版块发求助帖提问。
感谢你对飞思卡尔产品的关注!
站长推荐 /4
NXP官方IDH的米尔电子隆重推出的NXP i.MX6ULL系列开发板,只要你的想法足够优秀,你的创意足够新鲜,就来免费申请你的开发板吧!将项目帖分享到论坛中,更有机会获得500京东券的创意奖!
φ(>ω<*) 金豆是NXP社区于日发布的新币种,用户可通过回答问题帖、发布原创帖获取,每10枚金豆可兑换10元京东券一份( o ?ωo? )?
闪迪120g固态硬盘、支付宝红包、机械键盘、双肩包、金士顿U盘……超多福利大放送。5月8日14:00,恩智浦技术日在线直播|智能驾驶专场等你来嗨!赶紧来报名占座吧~
Cortex-M 从零开始学!经典图书免费下载,总有一本适合你?(^?^*)?(^?^*)(*^▽^*)
Tel: 3-8069
版权所有@苏州灵动帧格网络科技有限公司
Powered by你好,我的电脑在进入bios里面想调整下U盘先启动。但是在高级选项里面找不到usb Storage Device_百度知道
你好,我的电脑在进入bios里面想调整下U盘先启动。但是在高级选项里面找不到usb Storage Device
插了U 盘重启按F12里面也找不到USB的选项。
我有更好的答案
找到usb Storage Device的方法:计算机-管理-设备管理器-下载并更新加载“USB mass storage device”驱动即可。具体步骤:一、在电脑桌面右单击“计算机”,点击“管理”。二、单击“设备管理器”--单击“通用串行总线控制器”会看到故障位置,有故障带黄色感叹号的地方会自动弹出来。三、下载“USB mass storage device”驱动。不要关闭此管理页面。四、下载驱动,并下载到固定文件夹位置、并解压,以便于之后加载寻找方便。五、再次回到”计算机管理“页面,单击“USB mass storage device”选择“更新驱动程序”。六、单击下一步。七、选择不要搜索,单击下一步。八、单击下一步。九、单击“浏览”加载驱动文件。十、加载刚刚下载的驱动程序,选择进入下载的文件夹,选择“mydtloem.inf&,单击打开。十一、单击确定。十二、等待加载。十三、加载成功之后,再次重复步骤1、2。就能找到usb Storage Device。
你好!机器出厂预装win8,想要用系统盘安装win7系统时,开机按F12,进入开机启动项选择时,发现不存在从CD/DVD启动 的选项,来教你如何解决这个问题:1. 开机按F2,进入BIOS2.在 BIOS 的Boot菜单下,将Secure Boot 改为 Disabled3. 将Boot List Option 改为 Legacy按F10保存,重新开机按F12,即可看到开机启动选项了。
本回答被提问者和网友采纳
你好:设置BIOS比较麻烦困难,根据你的电脑类型,在将制作好的U盘系统插入电脑后,然后使用电脑开启启动项热键快捷键直接启动一键U盘装系统,由于不同品牌主板与品牌笔记本设置方法有所不一样,以下是各品牌主板与笔记本热键进入开机启动项设置的方法,如下图:
在上边boot的那个选项里
其他1条回答
为您推荐:
其他类似问题
进入bios的相关知识
&#xe675;换一换
回答问题,赢新手礼包&#xe6b9;
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。本页链接:
第1个回答:
步骤&#47;方法首先下载压缩包并解压,得到 LibUSB **Plugin文件夹和RemoteJoySDL104c.exe程序。将**Plugin文件夹复制到记忆棒根目录(如果已有同名文件夹请将其删除),然后关闭PSP(电源键上推3秒),再按住R键+开机键进入恢复模式,选plugins,将两个文件后的disabled改为enabled,然后选back、再选EXIT,小p启动到待机界面。给PSP连上usb犀打开怪物猎人P2G,电脑会提示找到新硬件,如图:选择从列表或指**置安装,点下一步。选择对应驱动(驱动在LibUSB文件夹里) 如图:4驱动装好后 开启RemoteJoySDL104c.exe程序,点击程序上的开始按钮,就可以看到你的游戏画面了。
猜你感兴趣求救!!!电脑提示usb
devices disabled【macbook吧】_百度贴吧
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&签到排名:今日本吧第个签到,本吧因你更精彩,明天继续来努力!
本吧签到人数:0成为超级会员,使用一键签到本月漏签0次!成为超级会员,赠送8张补签卡连续签到:天&&累计签到:天超级会员单次开通12个月以上,赠送连续签到卡3张
关注:340,977贴子:
求救!!!电脑提示usb
devices disabled收藏
最近不知道怎么回事,每次开机MacBook air都会显示“ unplug the device using too much power to re-enable usb devices&, 而且耗电也特别快....但问题就是,我电脑更本就没有插什么USB设备,难道是接口坏了么!?醉了....
请拔出耗电太快的设备来重新启用usb接口设备
登录百度帐号usb驱动开发21之驱动生命线 - 京月飞鸿 - 博客园
从IT开始,走上一个宁静的生活
现在开始就沿着usb_generic_driver的生命线继续往下走。设备的生命线你可以为是从你的usb设备连接到hub的某个端口时开始,而驱动的生命线就必须得回溯到usb子系统的初始化函数usb_init了。
if (retval)
goto hub_init_
retval = usb_register_device_driver(&usb_generic_driver, THIS_MODULE);
if (!retval)
在usb子系统初始化的时候就调用driver.c里的usb_register_device_driver函数将usb_generic_driver注册给系统了,怀胎十月,嗷嗷一声之后,usb世界里的一个超级大美女诞生了。现在先看看带她来到这个世界上的usb_register_device_driver函数。
* usb_register_device_driver - register a USB device (not interface) driver
* @new_udriver: USB operations for the device driver
* @owner: module owner of this driver.
* Registers a USB device driver with the USB core. The list of
* unattached devices will be rescanned whenever a new driver is
* added, allowing the new driver to attach to any recognized devices.
* Returns a negative error code on failure and 0 on success.
int usb_register_device_driver(struct usb_device_driver *new_udriver,
struct module *owner)
int retval = 0;
if (usb_disabled())
return -ENODEV;
new_udriver-&drvwrap.for_devices = 1;
new_udriver-&drvwrap.driver.name = (char *) new_udriver-&
new_udriver-&drvwrap.driver.bus = &usb_bus_
new_udriver-&drvwrap.driver.probe = usb_probe_
new_udriver-&drvwrap.driver.remove = usb_unbind_
new_udriver-&drvwrap.driver.owner =
retval = driver_register(&new_udriver-&drvwrap.driver);
if (!retval) {
pr_info("%s: registered new device driver %s\n",
usbcore_name, new_udriver-&name);
usbfs_update_special();
printk(KERN_ERR "%s: error %d registering device "
" driver %s\n",
usbcore_name, retval, new_udriver-&name);
usb_disabled函数判断一下usb子系统是不是在你启动内核的时候就被禁止了,如果是的话,这个超级大美女的生命也就太短暂了。
看到没,for_devices就是在这儿被初始化为1的,有了它,match里的那个is_usb_device_driver把门儿的才有章可循有凭可依。
下面就是充实了下usb_generic_driver里嵌入的那个struct device_driver结构体,usb_generic_driver就是通过它和设备模型搭上关系的。name就是usb_generic_driver的名字,即usb,所属的总线类型同样被设置为usb_bus_type,然后是指定probe函数和remove函数。
然后调用设备模型的函数driver_register将usb_generic_driver添加到usb总线的那条驱动链表里。
usb_generic_driver和usb设备匹配成功后,就会调用指定的probe函数usb_probe_device(),现在看看driver.c里定义的这个函数。
/* called from driver core with dev locked */
static int usb_probe_device(struct device *dev)
struct usb_device_driver *udriver = to_usb_device_driver(dev-&driver);
struct usb_device *
int error = -ENODEV;
dev_dbg(dev, "%s\n", __FUNCTION__);
if (!is_usb_device(dev)) /* Sanity check */
udev = to_usb_device(dev);
/* TODO: Add real matching code */
/* The device should always appear to be in use
* unless the driver suports autosuspend.
udev-&pm_usage_cnt = !(udriver-&supports_autosuspend);
error = udriver-&probe(udev);
首先to_usb_device_driver是include/linux/usb.h里定义的一个宏,和前面遇到的那个to_usb_device有异曲同工之妙,
然后is_usb_device表示 usb_generic_driver是match成功了,但是还需要获得usb_device结构体,所以to_usb_device它这就来了。
pm_usage_cnt和supports_autosuspend两个变量,前面都提到过那么一下,现在将那两个片断给回顾一下。每个struct usb_interface或struct usb_device里都有一个pm_usage_cnt,每个struct usb_driver或struct usb_device_driver里都有一个supports_autosuspend。提到pm_usage_cnt时说只有它为0时才会允许接口autosuspend,提到supports_autosuspend时说如果它为0就不再允许绑定到这个驱动的接口autosuspend。接口乎?设备乎?有些时候需要那么难得糊涂一下。需要的时候,群众的眼睛是雪亮的,接口是接口设备是设备,不需要的时候,群众是不明真相的,接口设备一个样。这里就是不需要的时候,所以将上面的话里的接口换成设备套一下就是:pm_usage_cnt为0时才会允许设备autosuspend,supports_autosuspend为0就不再允许绑定到这个驱动的设备autosuspend。
所有的usb设备都是绑定到usb_generic_driver上面的,usb_generic_driver的supports_autosuspend字段又是为1的,所以这行就是将设备struct usb_device结构体的pm_usage_cnt置为了0,也就是说允许设备autosuspend。但是不是说这里将pm_usage_cnt轻轻松松置为0,设备就能够autosuspend了,什么事都是说起来简单,做起来就不是那么回事儿,驱动必须得实现一对儿suspend/resume函数供PM子系统那块驱使,usb_generic_driver里的这对函数就是generic_suspend/generic_resume,就不多说它们了。
最后调用usb_generic_driver自己私有的probe函数generic_probe()对你的设备进行进一步的审查。
static int generic_probe(struct usb_device *udev)
/* put device-specific files into sysfs */
usb_create_sysfs_dev_files(udev);
/* Choose and set the configuration. This registers the interfaces
* with the driver core and lets interface drivers bind to them.
c = choose_configuration(udev);
if (c &= 0) {
err = usb_set_configuration(udev, c);
if (err) {
dev_err(&udev-&dev, "can't set config #%d, error %d\n",
/* This need not be fatal. The user can try to
* set other configurations. */
/* USB device state == configured ... usable */
usb_notify_add_device(udev);
这函数用一句话去概括它的中心思想,就是从设备可能的众多配置中选择一个合适的,然后去配置设备,从而让设备进入期待已久的Configured状态。概括了中心思想,再去看看细节。先看看是怎么选择一个配置的,调用的是generic.c里的choose_configuration函数。注释很详细就不说了。看一下另一个设备配置usb_set_configuration函数。
* usb_set_configuration - Makes a particular device setting be current
* @dev: the device whose configuration is being updated
* @configuration: the configuration being chosen.
* Context: !in_interrupt(), caller owns the device lock
* This is used to enable non-default device modes. Not all devices
* use this kin many devices only have one
* configuration.
* @configuration is the value of the configuration to be installed.
* According to the USB spec (e.g. section 9.1.1.5), configuration values
* must be non- a value of zero indicates that the device in
* unconfigured. However some devices erroneously use 0 as one of their
* configuration values. To help manage such devices, this routine will
* accept @configuration = -1 as indicating the device should be put in
* an unconfigured state.
* USB device configurations may affect Linux interoperability,
* power consumption and the functionality available. For example,
* the default configuration is limited to using 100mA of bus power,
* so that when certain device functionality requires more power,
* and the device is bus powered, that functionality should be in some
* non-default device configuration. Other device modes may also be
* reflected as configuration options, such as whether two ISDN
* channels are ava and choosing between open
* standard device protocols (like CDC) or proprietary ones.
* Note that USB has an additional level of device configurability,
* associated with interfaces. That configurability is accessed using
* usb_set_interface().
* This call is synchronous. The calling context must be able to sleep,
* must own the device lock, and must not hold the driver model's USB
* usb device driver probe() methods cannot use this routine.
* Returns zero on success, or else the status code returned by the
* underlying call that failed. On successful completion, each interface
* in the original device configuration has been destroyed, and each one
* in the new configuration has been probed by all relevant usb device
* drivers currently known to the kernel.
int usb_set_configuration(struct usb_device *dev, int configuration)
struct usb_host_config *cp = NULL;
struct usb_interface **new_interfaces = NULL;
if (configuration == -1)
configuration = 0;
for (i = 0; i & dev-&descriptor.bNumC i++) {
if (dev-&config[i].desc.bConfigurationValue ==
configuration) {
cp = &dev-&config[i];
if ((!cp && configuration != 0))
return -EINVAL;
/* The USB spec says configuration 0 means unconfigured.
* But if a device includes a configuration numbered 0,
* we will accept it as a correctly configured state.
* Use -1 if you really want to unconfigure the device.
if (cp && configuration == 0)
dev_warn(&dev-&dev, "config 0 descriptor??\n");
/* Allocate memory for new interfaces before doing anything else,
* so that if we run out then nothing will have changed. */
n = nintf = 0;
nintf = cp-&desc.bNumI
new_interfaces = kmalloc(nintf * sizeof(*new_interfaces),
GFP_KERNEL);
if (!new_interfaces) {
dev_err(&dev-&dev, "Out of memory");
return -ENOMEM;
for (; n & ++n) {
new_interfaces[n] = kzalloc(
sizeof(struct usb_interface),
GFP_KERNEL);
if (!new_interfaces[n]) {
dev_err(&dev-&dev, "Out of memory");
ret = -ENOMEM;
free_interfaces:
while (--n &= 0)
kfree(new_interfaces[n]);
kfree(new_interfaces);
i = dev-&bus_mA - cp-&desc.bMaxPower * 2;
if (i & 0)
dev_warn(&dev-&dev, "new config #%d exceeds power "
"limit by %dmA\n",
configuration, -i);
/* Wake up the device so we can send it the Set-Config request */
ret = usb_autoresume_device(dev);
goto free_
/* if it's already configured, clear out old state first.
* getting rid of old interfaces means unbinding their drivers.
if (dev-&state != USB_STATE_ADDRESS)
usb_disable_device (dev, 1); // Skip ep0
if ((ret = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
USB_REQ_SET_CONFIGURATION, 0, configuration, 0,
NULL, 0, USB_CTRL_SET_TIMEOUT)) & 0) {
/* All the old state is gone, so what else can we do?
* The device is probably useless now anyway.
cp = NULL;
dev-&actconfig =
if (!cp) {
usb_set_device_state(dev, USB_STATE_ADDRESS);
usb_autosuspend_device(dev);
goto free_
usb_set_device_state(dev, USB_STATE_CONFIGURED);
/* Initialize the new interface structures and the
* hc/hcd/usbcore interface/endpoint state.
for (i = 0; i & ++i) {
struct usb_interface_cache *
struct usb_interface *
struct usb_host_interface *
cp-&interface[i] = intf = new_interfaces[i];
intfc = cp-&intf_cache[i];
intf-&altsetting = intfc-&
intf-&num_altsetting = intfc-&num_
kref_get(&intfc-&ref);
alt = usb_altnum_to_altsetting(intf, 0);
/* No altsetting 0? We'll assume the first altsetting.
* We could use a GetInterface call, but if a device is
* so non-compliant that it doesn't have altsetting 0
* then I wouldn't trust its reply anyway.
alt = &intf-&altsetting[0];
intf-&cur_altsetting =
usb_enable_interface(dev, intf);
intf-&dev.parent = &dev-&
intf-&dev.driver = NULL;
intf-&dev.bus = &usb_bus_
intf-&dev.type = &usb_if_device_
intf-&dev.dma_mask = dev-&dev.dma_
device_initialize (&intf-&dev);
mark_quiesced(intf);
sprintf (&intf-&dev.bus_id[0], "%d-%s:%d.%d",
dev-&bus-&busnum, dev-&devpath,
configuration, alt-&desc.bInterfaceNumber);
kfree(new_interfaces);
if (cp-&string == NULL)
cp-&string = usb_cache_string(dev, cp-&desc.iConfiguration);
/* Now that all the interfaces are set up, register them
* to trigger binding of drivers to interfaces. probe()
* routines may install different altsettings and may
* claim() any interfaces not yet bound. Many class drivers
* need that: CDC, audio, video, etc.
for (i = 0; i & ++i) {
struct usb_interface *intf = cp-&interface[i];
dev_dbg (&dev-&dev,
"adding %s (config #%d, interface %d)\n",
intf-&dev.bus_id, configuration,
intf-&cur_altsetting-&desc.bInterfaceNumber);
ret = device_add (&intf-&dev);
if (ret != 0) {
dev_err(&dev-&dev, "device_add(%s) --& %d\n",
intf-&dev.bus_id, ret);
usb_create_sysfs_intf_files (intf);
usb_autosuspend_device(dev);
遇到很长的代码,我们总是想说点函数背后的理论,或者聊聊函数背后的人生哲学。走到这里,设备已经和usb_generic_driver这个大美女配对成功了,这并不意味着你可以高枕无忧了,要想保持和她的这种亲密关系,你得想办法让她得到满足,你就要准备着让她去配置,准备着她想让你什么样你就什么样。你要明白,吸引住男人的办法就是让他一直得不到,吸引住女人的办法正好相反,就是让她一直满足。从这个角度看,这个函数就可以泾渭分明的分成三个部分三个阶段。一是准备阶段,做做常规检查啊,申请申请内存啊,搞点前戏什么的。二是设备从Address发展到了Configured,可算是高潮阶段,别看它短,这是事物发展的规律,也是每个男人女人的规律,充实充实设备的每个接口并提交给设备模型,为它们寻找命中注定的接口驱动。最后温存温存,过了这个后戏阶段,usb_generic_driver也就彻底从你设备那儿得到满足了,generic_probe的历史使命也就完成了。事物的发展大体上就脱离不了这三个阶段,再比如股票,买、卖、回味。
先看第一阶段,configuration(函数参数之一)是前边儿choose_configuration()那里返回回来的,找到合意的配置的话,就返回那个配置的bConfigurationValue值,没有找到称心的配置的话,就返回-1,所以这里的configuration值就可能有两种情况,或者为-1,或者为配置的bConfigurationValue值。当configuration为-1时这里为啥又要把它改为0捏?要知道configuration这个值是要在后面的高潮阶段里发送SET_CONFIGURATION请求时用的,关于SET_CONFIGURATION请求,spec里说,这个值必须为0或者与配置描述符的bConfigurationValue一致,如果为0,则设备收到SET_CONFIGURATION请求后,仍然会待在Address状态。这里当configuration为-1也就是没有发现满意的配置时,设备不能进入Configured,所以要把configuration的值改为0,以便满足SET_CONFIGURATION请求的要求。那接下来的问题就出来了,在没有找到合适配置的时候直接给configuration这个参数传个0,也就是让choose_configuration()返回个0不就得了,干吗还这么麻烦先返回个-1再把它改成0,不是脱裤子放屁多此一举么?这归根结底还是那句话,有些设备就是有拿0当配置bConfigurationValue值的毛病,你又不能不让它用,这里妥协一下就是了,想让设备回到Address状态时,usb_set_configuration()就别传递0了,传递个-1,里边儿去处理一下。如果configuration值为0或大于0的值,就从设备struct usb_device结构体的config数组里将相应配置的描述信息,也就是struct usb_host_config结构体给取出来。如果没有拿到配置的内容,configuration值就必须为0了,让设备待在Address那儿别动。这也很好理解,配置的内容都找不到了,还配置个什么劲儿。当然,如果拿到了配置的内容,但同时configuration为0,这就是对应了上面说的那种有毛病的设备的情况,就提出一下警告,告诉你不正常现象出现了。接下来的if判断如果配置是实实在在存在的,就为它使用的那些接口都准备一个struct usb_interface结构体。new_interfaces是开头儿就定义好的一个struct usb_interface结构体指针数组,数组的每一项都指向了一个struct usb_interface结构体,所以这里申请内存也要分两步走,先申请指针数组的,再申请每一项的。
下面的高潮部分,还是抽两支烟的功夫后再看吧。

我要回帖

更多关于 百度求助 的文章

 

随机推荐