⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 linux-2_6_14下usb驱动移植心得 - luofuchong - it博客网.htm

📁 2.6内核下usb移植的资料
💻 HTM
📖 第 1 页 / 共 4 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0064)http://www.cnitblog.com/luofuchong/archive/2007/06/17/22265.html -->
<HTML xmlns:o = "urn:schemas-microsoft-com:office:office" xmlns:st1 = 
"urn:schemas-microsoft-com:office:smarttags"><HEAD id=Head><TITLE>linux-2.6.14下USB驱动移植心得 - luofuchong - IT博客网</TITLE>
<META http-equiv=Content-Type content="text/html; charset=utf-8">
<META id=metaKeywords content=linux-2.6.14下USB驱动移植心得 name=keywords><LINK 
id=MainCss href="linux-2_6_14下USB驱动移植心得 - luofuchong - IT博客网.files/style.css" 
type=text/css rel=stylesheet><LINK id=RSSLink title=RSS 
href="http://www.cnitblog.com/luofuchong/rss.aspx" type=application/rss+xml 
rel=alternate>
<META content="MSHTML 6.00.2900.2963" name=GENERATOR></HEAD>
<BODY>
<FORM id=Form1 name=Form1 onsubmit="javascript:return WebForm_OnSubmit();" 
action=22265.html method=post>
<DIV><INPUT id=__EVENTTARGET type=hidden name=__EVENTTARGET> <INPUT 
id=__EVENTARGUMENT type=hidden name=__EVENTARGUMENT> <INPUT 
id="&#13;&#10;__VIEWSTATE" type=hidden name=__VIEWSTATE> </DIV>
<SCRIPT type=text/javascript>
<!--
var theForm = document.forms['Form1'];
if (!theForm) {
    theForm = document.Form1;
}
function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
}
// -->
</SCRIPT>

<SCRIPT src="linux-2_6_14下USB驱动移植心得 - luofuchong - IT博客网.files/WebResource.axd" 
type=text/javascript></SCRIPT>

<SCRIPT language=JavaScript>
									function ctlent(evt,id)
											{
												if(evt.ctrlKey && evt.keyCode == 13)
												{	
													try
													{
														TempSave(id);
													}
													catch(ex)
													{
													}
													finally
													{
													    __doPostBack('AjaxHolder$PostComment$btnSubmit','')
													}
												}
		
												}</SCRIPT>

<SCRIPT language=JavaScript>function SetReplyAuhor(author){document.getElementById('AjaxHolder_PostComment_tbComment').value+="@"+author+"\n";document.getElementById('AjaxHolder_PostComment_tbComment').focus();return false}</SCRIPT>

<SCRIPT 
src="F:\下载\usbhost\linux-2_6_14下USB驱动移植心得 - luofuchong - IT博客网.files\WebResource(1).axd" 
type=text/javascript></SCRIPT>

<SCRIPT 
src="linux-2_6_14下USB驱动移植心得 - luofuchong - IT博客网.files/ScriptResource.axd" 
type=text/javascript></SCRIPT>

<SCRIPT 
src="F:\下载\usbhost\linux-2_6_14下USB驱动移植心得 - luofuchong - IT博客网.files\ScriptResource(1).axd" 
type=text/javascript></SCRIPT>

<SCRIPT type=text/javascript>
<!--
function WebForm_OnSubmit() {
if (typeof(ValidatorOnSubmit) == "function" && ValidatorOnSubmit() == false) return false;
return true;
}
// -->
</SCRIPT>
<!--done-->
<DIV id=header><!--done-->
<DIV class=header>
<DIV class=headerText><A class=headermaintitle id=Header1_HeaderTitle 
href="http://www.cnitblog.com/luofuchong/">luofuchong</A><BR></DIV></DIV></DIV>
<DIV id=mytopmenu>
<DIV id=mylinks><!--done--><A class=menu id=MyLinks1_HomeLink 
href="http://www.cnitblog.com/">IT博客网</A>&nbsp;&nbsp; <A class=menu 
id=MyLinks1_MyHomeLink 
href="http://www.cnitblog.com/luofuchong/">首页</A>&nbsp;&nbsp; <A class=menu 
id=MyLinks1_NewPostLink 
href="http://www.cnitblog.com/luofuchong/admin/EditPosts.aspx?opt=1">新随笔</A> <A 
class=menu id=MyLinks1_ContactLink 
href="http://www.cnitblog.com/luofuchong/contact.aspx?id=1">联系</A>&nbsp;&nbsp; 
<A class=menu id=MyLinks1_Syndication 
href="http://www.cnitblog.com/luofuchong/Rss.aspx">聚合</A><A id=MyLinks1_XMLLink 
href="http://www.cnitblog.com/luofuchong/Rss.aspx"><IMG 
style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" 
src="linux-2_6_14下USB驱动移植心得 - luofuchong - IT博客网.files/xml.gif"></A>&nbsp;&nbsp; 
<A class=menu id=MyLinks1_Admin 
href="http://www.cnitblog.com/luofuchong/admin/EditPosts.aspx">管理</A> </DIV>
<DIV id=mystats><!--done-->随笔-5&nbsp; 评论-20&nbsp; 文章-2&nbsp; trackbacks-0 
</DIV></DIV>
<DIV id=centercontent><!--done-->
<DIV class=post>
<DIV class=postTitle><A class=postTitle2 id=viewpost1_TitleUrl 
href="http://www.cnitblog.com/luofuchong/archive/2007/01/24/22265.html">linux-2.6.14下USB驱动移植心得</A> 
</DIV>
<P class=MsoNormal 
style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 171pt; TEXT-ALIGN: left; mso-pagination: widow-orphan; mso-char-indent-count: 19.0" 
align=left><SPAN lang=EN-US 
style="FONT-SIZE: 9pt; COLOR: #555555; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">USB</SPAN> 
<SPAN 
style="FONT-SIZE: 9pt; COLOR: #555555; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">驱动移植心得<SPAN 
lang=EN-US><BR></SPAN>一、代码修改<SPAN lang=EN-US><BR></SPAN>主要是按照这个贴来做:<SPAN 
lang=EN-US><BR><A 
href="http://www.hfrk.net/S3C2410/kaifa/063152202483252_37.htm" 
target=_blank><SPAN 
style="COLOR: #333333; TEXT-DECORATION: none; mso-bidi-font-size: 12.0pt; text-underline: none">http://www.hfrk.net/S3C2410/kaifa/063152202483252_37.htm</SPAN></A><BR></SPAN>我也看过其它不同版本的内核关于<SPAN 
lang=EN-US>usb</SPAN>驱动的移植,移植方法几乎一样,只是修改的文件不同而已。上面的贴子有不少头文件没有例出来,以下是我按照以上贴子添加的代码(好像在很多论坛上包括头文件部分都显示不出来,在这里把<SPAN 
lang=EN-US>include</SPAN>前面的<SPAN lang=EN-US>#</SPAN>给删了,希望有帮助):<SPAN 
lang=EN-US><o:p></o:p></SPAN></SPAN> </P>
<P class=MsoNormal 
style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-pagination: widow-orphan; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" 
align=left><SPAN lang=EN-US 
style="FONT-SIZE: 9pt; COLOR: #555555; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">/*add 
by lfc*/<BR></SPAN><SPAN 
style="FONT-SIZE: 9pt; COLOR: #555555; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">#<SPAN 
lang=EN-US>include &lt;asm/arch/regs-clock.h&gt;<BR></SPAN>#<SPAN 
lang=EN-US>include &lt;asm/arch/usb-control.h&gt;<BR></SPAN>#<SPAN 
lang=EN-US>include &lt;linux/device.h&gt;<BR></SPAN>#<SPAN lang=EN-US>include 
&lt;linux/delay.h&gt;<BR>/*end add*/ <o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal 
style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-pagination: widow-orphan; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" 
align=left><SPAN lang=EN-US 
style="FONT-SIZE: 9pt; COLOR: #555555; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">/**********************add 
by lfc*************************************/<BR>static struct s<st1:chmetcnv 
tcsc="0" numbertype="1" negative="False" hasspace="False" sourcevalue="3" 
unitname="C" w:st="on">3c</st1:chmetcnv>2410_hcd_info usb_sbc2410_info = 
{<BR>&nbsp; &nbsp; &nbsp; &nbsp;.port[0] &nbsp; &nbsp; &nbsp; &nbsp;= 
{<BR>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;.flags &nbsp;= 
S<st1:chmetcnv tcsc="0" numbertype="1" negative="False" hasspace="False" 
sourcevalue="3" unitname="C" w:st="on">3C</st1:chmetcnv>_HCDFLG_USED<BR>&nbsp; 
&nbsp; &nbsp; &nbsp;}<BR>}; <o:p></o:p></SPAN></P>
<P class=MsoNormal 
style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-pagination: widow-orphan; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" 
align=left><SPAN lang=EN-US 
style="FONT-SIZE: 9pt; COLOR: #555555; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">int 
usb_sbc2410_init(void)<BR>{<BR>unsigned long upllvalue = 
(0x78&lt;&lt;12)|(0x02&lt;&lt;4)|(0x03);<BR>printk("USB Control, (c) 2006 
sbc2410\n");<BR>s<st1:chmetcnv tcsc="0" numbertype="1" negative="False" 
hasspace="False" sourcevalue="3" unitname="C" 
w:st="on">3c</st1:chmetcnv>_device_usb.dev.platform_data = 
&amp;usb_sbc2410_info;<BR>while(upllvalue!=__raw_readl(S<st1:chmetcnv tcsc="0" 
numbertype="1" negative="False" hasspace="False" sourcevalue="3" unitname="C" 
w:st="on">3C</st1:chmetcnv>2410_UPLLCON))<BR>{<BR>__raw_writel(upllvalue,S<st1:chmetcnv 
tcsc="0" numbertype="1" negative="False" hasspace="False" sourcevalue="3" 
unitname="C" 
w:st="on">3C</st1:chmetcnv>2410_UPLLCON);<BR>mdelay(1);<BR>}<BR>return 0;<BR>} 
<o:p></o:p></SPAN></P>
<P class=MsoNormal 
style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-pagination: widow-orphan; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" 
align=left><SPAN lang=EN-US 
style="FONT-SIZE: 9pt; COLOR: #555555; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">/***************************end 
add**********************/ <o:p></o:p></SPAN></P>
<P class=MsoNormal 
style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-pagination: widow-orphan; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" 
align=left><SPAN lang=EN-US 
style="FONT-SIZE: 9pt; COLOR: #555555; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">static 
void __init smdk2410_map_io(void)<BR>{<BR>s<st1:chmetcnv tcsc="0" numbertype="1" 
negative="False" hasspace="False" sourcevalue="3" unitname="C" 
w:st="on">3c</st1:chmetcnv>24xx_init_io(smdk2410_iodesc, 
ARRAY_SIZE(smdk2410_iodesc));<BR>s<st1:chmetcnv tcsc="0" numbertype="1" 
negative="False" hasspace="False" sourcevalue="3" unitname="C" 
w:st="on">3c</st1:chmetcnv>24xx_init_clocks(0);<BR>s<st1:chmetcnv tcsc="0" 
numbertype="1" negative="False" hasspace="False" sourcevalue="3" unitname="C" 
w:st="on">3c</st1:chmetcnv>24xx_init_uarts(smdk2410_uartcfgs, 
ARRAY_SIZE(smdk2410_uartcfgs));<BR>s<st1:chmetcnv tcsc="0" numbertype="1" 
negative="False" hasspace="False" sourcevalue="3" unitname="C" 
w:st="on">3c</st1:chmetcnv>24xx_set_board(&amp;smdk2410_board);<BR>/*************************add 
by lfc****************************/<BR>&nbsp; &nbsp; &nbsp; 
&nbsp;usb_sbc2410_init();<BR>/*************************end 
add*******************************/<BR>} <o:p></o:p></SPAN></P>
<P class=MsoNormal 
style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-pagination: widow-orphan; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" 
align=left><SPAN 
style="FONT-SIZE: 9pt; COLOR: #555555; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">上面的修改其实也参考了这个牛贴一下,里面有大虾们对<SPAN 
lang=EN-US>USB</SPAN>驱动移植的讨论,还不错:<SPAN lang=EN-US><BR><A 
href="http://www.linuxforum.net/forum/showflat.php?Cat=&amp;Board=embedded&amp;Number=556915&amp;page=0&amp;view=collapsed&amp;sb=5&amp;o=0&amp;fpart=" 
target=_blank><SPAN 
style="COLOR: #333333; TEXT-DECORATION: none; text-underline: none">http://www.linuxforum.net/forum/showflat.php?Cat=&amp;Board=embedded&amp;Number=556915&amp;page=0&amp;view=collapsed&amp;sb=5&amp;o=0&amp;fpart=</SPAN></A><o:p></o:p></SPAN></SPAN> 
</P>
<P class=MsoNormal 
style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-pagination: widow-orphan; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" 
align=left><SPAN 
style="FONT-SIZE: 9pt; COLOR: #555555; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">其实到了这里,要修改的代码已经修改完了,比添加<SPAN 
lang=EN-US>Nand flash</SPAN>的支持修改的地方还要少<SPAN 
lang=EN-US>^_^</SPAN>,不过我一直以为还没修改好,最后发现原来是没配置好<SPAN lang=EN-US>~_~ 
<o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal 
style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-pagination: widow-orphan; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" 
align=left><SPAN 
style="FONT-SIZE: 9pt; COLOR: #555555; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">二、内核配置<SPAN 
lang=EN-US><BR></SPAN>下面说一下郁闷了我好一阵子的内核配置(支持<SPAN 
lang=EN-US>USB</SPAN>)问题,这个就比<SPAN lang=EN-US>Nand flash</SPAN>的配置要复杂多了。<SPAN 
lang=EN-US><BR></SPAN>1、让内核支持热插拔<SPAN lang=EN-US><BR></SPAN>│<SPAN lang=EN-US> 
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;General setup 
&nbsp;---&gt; &nbsp;<BR>&nbsp;</SPAN>│ │<SPAN lang=EN-US>[*] Support for 
hot-pluggable devices <o:p></o:p></SPAN></SPAN></P>
<P class=MsoNormal 
style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: left; mso-pagination: widow-orphan; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto" 
align=left><SPAN 
style="FONT-SIZE: 9pt; COLOR: #555555; FONT-FAMILY: 宋体; mso-font-kerning: 0pt; mso-bidi-font-family: 宋体">2、<SPAN 
lang=EN-US>USB</SPAN>驱动设置,可能有些不选也行,不过没时间去试,至于为什么要选这些选项的话可以看一下这个贴(<SPAN 
lang=EN-US>Linux</SPAN>下的硬件驱动——<SPAN lang=EN-US>USB</SPAN>设备):<SPAN 
lang=EN-US><BR><A 
href="http://www-128.ibm.com/developerworks/cn/linux/l-usb/index1.html" 
target=_blank><SPAN 
style="COLOR: #333333; TEXT-DECORATION: none; text-underline: none">http://www-128.ibm.com/developerworks/cn/linux/l-usb/index1.html</SPAN></A><o:p></o:p></SPAN></SPAN> 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -