?? linux-2_6_14下usb驅動移植心得 - luofuchong - it博客網.htm
字號:
?<!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=" __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> <A class=menu
id=MyLinks1_MyHomeLink
href="http://www.cnitblog.com/luofuchong/">首頁</A> <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>
<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>
<A class=menu id=MyLinks1_Admin
href="http://www.cnitblog.com/luofuchong/admin/EditPosts.aspx">管理</A> </DIV>
<DIV id=mystats><!--done-->隨筆-5 評論-20 文章-2 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 <asm/arch/regs-clock.h><BR></SPAN>#<SPAN
lang=EN-US>include <asm/arch/usb-control.h><BR></SPAN>#<SPAN
lang=EN-US>include <linux/device.h><BR></SPAN>#<SPAN lang=EN-US>include
<linux/delay.h><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> .port[0] =
{<BR> .flags =
S<st1:chmetcnv tcsc="0" numbertype="1" negative="False" hasspace="False"
sourcevalue="3" unitname="C" w:st="on">3C</st1:chmetcnv>_HCDFLG_USED<BR>
}<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<<12)|(0x02<<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 =
&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(&smdk2410_board);<BR>/*************************add
by lfc****************************/<BR>
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=&Board=embedded&Number=556915&page=0&view=collapsed&sb=5&o=0&fpart="
target=_blank><SPAN
style="COLOR: #333333; TEXT-DECORATION: none; text-underline: none">http://www.linuxforum.net/forum/showflat.php?Cat=&Board=embedded&Number=556915&page=0&view=collapsed&sb=5&o=0&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>
General setup
---> <BR> </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 + -