亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? ohci-s3c2410.c

?? USB HOST DEVICE驅動程序
?? C
字號:
?
/* 
* OHCI HCD (Host Controller Driver) for USB
該程序主要完成s3c2410 USB 主機控制器的初始化工作,包括電源,時鐘等
*/
//需要用到的頭文件
#include <asm/hardware.h> 
#include <asm/mach-types.h> 
#include <asm/hardware/clock.h> 
#include <asm/arch/usb-control.h> 
//定義主機控制器的有效端口數
#define valid_port(idx) ((idx) == 1 || (idx) == 2) 

/* 主機控制器的時鐘,在clock.h中有它的定義 */

static struct clk *clk; 

/* 預定義,s3c2410_hcd_oc   主機端口的過流保護函數*/

static void s3c2410_hcd_oc(struct s3c2410_hcd_info *info, int port_oc); 

/* 該函數返回總線上的當前的平臺信息
    該函數的返回結構: (具體的定義在usb_control.h中)
    struct s3c2410_hcd_info{
            struct usb_hcd  *hcd;
            struct s3c2410_hcd_port port[2];
            void  (*power_control)(int port,int to);
            void  (*enable_oc)(struct s3c2410_hcd_info *,int on);
            void  (*report_oc)(struct s3c2410_hcd_info *,int ports);
    };


 */

struct s3c2410_hcd_info *to_s3c2410_info(struct usb_hcd *hcd) 
{ 
return hcd->self.controller->platform_data; 
} 
 /* s3c2410_start_hc  該函數啟動主機控制器,主要是啟動時鐘,對打開對端口的過流保護
 */
static void s3c2410_start_hc(struct platform_device *dev, struct usb_hcd *hcd) 
{ 
struct s3c2410_hcd_info *info = dev->dev.platform_data; 

dev_dbg(&dev->dev, "s3c2410_start_hc:\n"); 
clk_enable(clk); 

if (info != NULL) { 
info->hcd = hcd; 
info->report_oc = s3c2410_hcd_oc; 

if (info->enable_oc != NULL) { 
(info->enable_oc)(info, 1); 
} 
} 
} 
 /* s3c2410_stop_hc  該函數停止主機控制器,關閉時鐘
 */
static void s3c2410_stop_hc(struct platform_device *dev) 
{ 
struct s3c2410_hcd_info *info = dev->dev.platform_data; 

dev_dbg(&dev->dev, "s3c2410_stop_hc:\n"); 

if (info != NULL) { 
info->report_oc = NULL; 
info->hcd = NULL; 

if (info->enable_oc != NULL) { 
(info->enable_oc)(info, 0); 
} 
} 

clk_disable(clk); 
} 

/* ohci_s3c2410_hub_status_data  該函數是集線器的狀態函數,
掃描集線器的兩個下行端口,檢測是否連接USB設備,若有返回1,無,返回0

*/ 

static int 
ohci_s3c2410_hub_status_data (struct usb_hcd *hcd, char *buf) 
{ 
struct s3c2410_hcd_info *info = to_s3c2410_info(hcd); 
struct s3c2410_hcd_port *port; 
int orig; 
int portno; 

orig = ohci_hub_status_data (hcd, buf); 

if (info == NULL) 
return orig; 

port = &info->port[0]; 

/*掃描兩個端口*/

for (portno = 0; portno < 2; port++, portno++) { 
if (port->oc_changed == 1 && 
port->flags & S3C_HCDFLG_USED) { 
dev_dbg(hcd->self.controller, 
"oc change on port %d\n", portno); 

if (orig < 1) 
orig = 1; 

buf[0] |= 1<<(portno+1); 
} 
} 

return orig; 
} 

/* s3c2410_usb_set_power 該函數實現對端口的電源配置

*/ 

static void s3c2410_usb_set_power(struct s3c2410_hcd_info *info, 
int port, int to) 
{ 
if (info == NULL) 
return; 

if (info->power_control != NULL) { 
info->port[port-1].power = to; 
(info->power_control)(port, to); 
} 
} 

/* ohci_s3c2410_hub_control  該函數是集線器的控制函數
 處理一些對 集線器的控制請求
 具體參數:
typeReq 控制請求類別
 wValue 請求值
*/ 

static int ohci_s3c2410_hub_control (
struct usb_hcd *hcd, 
u16 typeReq, 
u16 wValue, 
u16 wIndex, 
char *buf, 
u16 wLength) 
{ 
struct s3c2410_hcd_info *info = to_s3c2410_info(hcd); 
struct usb_hub_descriptor *desc; 
int ret = -EINVAL; 
u32 *data = (u32 *)buf; 

dev_dbg(hcd->self.controller, 
"s3c2410_hub_control(%p,0x%04x,0x%04x,0x%04x,%p,%04x)\n", 
hcd, typeReq, wValue, wIndex, buf, wLength); 


if (info == NULL) { 
ret = ohci_hub_control(hcd, typeReq, wValue, 
wIndex, buf, wLength); 
goto out; 
} 

/* 檢測HUB的請求類別,并且處理相關請求
*/

switch (typeReq) { 
/*集線器啟用端口的請求  */
case SetPortFeature: 
if (wValue == USB_PORT_FEAT_POWER) { 
dev_dbg(hcd->self.controller, "SetPortFeat: POWER\n"); 
s3c2410_usb_set_power(info, wIndex, 1); 
goto out; 
} 
break; 
/* 消除端口的請求*/
case ClearPortFeature: 
/*具體的請求值*/
switch (wValue) { 
case USB_PORT_FEAT_C_OVER_CURRENT: 
dev_dbg(hcd->self.controller, 
"ClearPortFeature: C_OVER_CURRENT\n"); 

if (valid_port(wIndex)) { 
info->port[wIndex-1].oc_changed = 0; 
info->port[wIndex-1].oc_status = 0; 
} 

goto out; 

case USB_PORT_FEAT_OVER_CURRENT: 
dev_dbg(hcd->self.controller, 
"ClearPortFeature: OVER_CURRENT\n"); 

if (valid_port(wIndex)) { 
info->port[wIndex-1].oc_status = 0; 
} 

goto out; 

case USB_PORT_FEAT_POWER: 
dev_dbg(hcd->self.controller, 
"ClearPortFeature: POWER\n"); 

if (valid_port(wIndex)) { 
s3c2410_usb_set_power(info, wIndex, 0); 
return 0; 
} 
} 
break; 
} 

ret = ohci_hub_control(hcd, typeReq, wValue, wIndex, buf, wLength); 
if (ret) 
goto out; 

switch (typeReq) { 
/*獲取集線器特定的描述符*/
case GetHubDescriptor: 

/* 更新集線器的描述符*/

desc = (struct usb_hub_descriptor *)buf; 

if (info->power_control == NULL) 
return ret; 

dev_dbg(hcd->self.controller, "wHubCharacteristics 0x%04x\n", 
desc->wHubCharacteristics); 

/* 更新集線器的配置,包括HUB電源和過流保護的配置
*/ 

desc->wHubCharacteristics &= ~cpu_to_le16(HUB_CHAR_LPSM); 
desc->wHubCharacteristics |= cpu_to_le16(0x0001); 

if (info->enable_oc) { 
desc->wHubCharacteristics &= ~cpu_to_le16(HUB_CHAR_OCPM); 
desc->wHubCharacteristics |= cpu_to_le16(0x0008|0x0001); 
} 

dev_dbg(hcd->self.controller, "wHubCharacteristics after 0x%04x\n", 
desc->wHubCharacteristics); 

return ret; 
/* 獲取端口的狀態 */
case GetPortStatus: 

dev_dbg(hcd->self.controller, "GetPortStatus(%d)\n", wIndex); 

if (valid_port(wIndex)) { 
if (info->port[wIndex-1].oc_changed) { 
*data |= cpu_to_le32(RH_PS_OCIC); 
} 

if (info->port[wIndex-1].oc_status) { 
*data |= cpu_to_le32(RH_PS_POCI); 
} 
} 
} 

out: 
return ret; 
} 

/* s3c2410_hcd_oc  該函數是主機控制器對端口的過流保護

*/ 

static void s3c2410_hcd_oc(struct s3c2410_hcd_info *info, int port_oc) 
{ 
struct s3c2410_hcd_port *port; 
struct usb_hcd *hcd; 
unsigned long flags; 
int portno; 

if (info == NULL) 
return; 

port = &info->port[0]; 
hcd = info->hcd; 

local_irq_save(flags); 

for (portno = 0; portno < 2; port++, portno++) { 
if (port_oc & (1<<portno) && 
port->flags & S3C_HCDFLG_USED) { 
port->oc_status = 1; 
port->oc_changed = 1; 

/* 停止該端口的供電 */
s3c2410_usb_set_power(info, portno+1, 0); 
} 
} 

local_irq_restore(flags); 
} 

/*  usb_hcd_s3c2410_remove  主機控制器的卸載
停止主機控制器,釋放內存資源

* 
*/ 

void usb_hcd_s3c2410_remove (struct usb_hcd *hcd, struct platform_device *dev) 
{ 
usb_remove_hcd(hcd); 
s3c2410_stop_hc(dev); 
iounmap(hcd->regs);  //解除與內存映射的關系函數
release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 
usb_put_hcd(hcd); 
} 

/**  usb_hcd_s3c2410_probe    USB 主機控制器的探測函數.
  主要實現對主機控制器進行分配資源,并啟動主機控制器等
*/ 
int usb_hcd_s3c2410_probe (const struct hc_driver *driver, 
struct platform_device *dev) 
{ 
struct usb_hcd *hcd = NULL; 
int retval; 
/** 給端口進行供電*/
s3c2410_usb_set_power(dev->dev.platform_data, 0, 1); 
s3c2410_usb_set_power(dev->dev.platform_data, 1, 1); 
/** usb_create_hcd() 函數初始化主機控制器*/
hcd = usb_create_hcd(driver, &dev->dev, "s3c24xx"); 
if (hcd == NULL) 
return -ENOMEM; //系統錯誤,沒有相應的內存空間
 /*主機控制器的資源節點*/
hcd->rsrc_start = dev->resource[0].start; 
hcd->rsrc_len = dev->resource[0].end - dev->resource[0].start + 1; 
 /*請求分配內存資源*/
if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { 
dev_err(&dev->dev, "request_mem_region failed"); 
retval = -EBUSY;   //系統錯誤,表示要分配的內存資源已經被占用
goto err0; 
} 

clk = clk_get(NULL, "usb-host"); 
if (IS_ERR(clk)) { 
dev_err(&dev->dev, "cannot get usb-host clock\n"); 
retval = -ENOENT; 
goto err1; 
} 
/*啟動始終,并啟動主機控制器*/
clk_use(clk); 
s3c2410_start_hc(dev, hcd); 
/*ioremap()作用是將物理地址映射成相應的虛擬地址*/
hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); 
if (!hcd->regs) { 
dev_err(&dev->dev, "ioremap failed\n"); 
retval = -ENOMEM; 
goto err2; 
} 

ohci_hcd_init(hcd_to_ohci(hcd)); 

retval = usb_add_hcd(hcd, dev->resource[1].start, SA_INTERRUPT); 
if (retval != 0) 
goto err2; 

return 0; 

err2: 
s3c2410_stop_hc(dev); 
iounmap(hcd->regs); 
clk_unuse(clk); 
clk_put(clk); 

err1: 
release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 

err0: 
usb_put_hcd(hcd); 
return retval; 
} 
/* ohci_s3c2410_start 開放式主機控制器接口的啟動函數
  調用上層的 ohci_run()函數來實現該功能
*/

static int 
ohci_s3c2410_start (struct usb_hcd *hcd) 
{ 
struct ohci_hcd *ohci = hcd_to_ohci (hcd); 
int ret; 

if ((ret = ohci_init(ohci)) < 0) 
return ret; 

if ((ret = ohci_run (ohci)) < 0) { 
err ("can't start %s", hcd->self.bus_name); 
ohci_stop (hcd); 
return ret; 
} 

return 0; 
} 
/*節點操作函數的實例
定義了2410 USB主機控制器的具體操作函數實例
*/

static const struct hc_driver ohci_s3c2410_hc_driver = { 
.description = hcd_name, 
.product_desc = "S3C24XX OHCI", 
.hcd_priv_size = sizeof(struct ohci_hcd), 


.irq = ohci_irq, 
.flags = HCD_USB11 | HCD_MEMORY, 

.start = ohci_s3c2410_start, 
.stop = ohci_stop, 

/* 
* 管理I/O請求&相關的設備資源
*/ 
.urb_enqueue = ohci_urb_enqueue, //提交URB的具體處理函數
.urb_dequeue = ohci_urb_dequeue, 
.endpoint_disable = ohci_endpoint_disable, 

/* 
*調度支持,獲取當前總線幀號
*/ 
.get_frame_number = ohci_get_frame, 

/* 
* 根集線器的控制實例
*/ 
.hub_status_data = ohci_s3c2410_hub_status_data, 
.hub_control = ohci_s3c2410_hub_control, 

#if defined(CONFIG_USB_SUSPEND) && 0 
.hub_suspend = ohci_hub_suspend, 
.hub_resume = ohci_hub_resume, 
#endif 
}; 

/*ohci_hcd_s3c2410_drv_probe  主機控制器驅動的探測函數   */

static int ohci_hcd_s3c2410_drv_probe(struct device *dev) 
{ 
struct platform_device *pdev = to_platform_device(dev); 
return usb_hcd_s3c2410_probe(&ohci_s3c2410_hc_driver, pdev); 
} 
/*ohci_hcd_s3c2410_drv_remove  主機控制器驅動的卸載函數   */
static int ohci_hcd_s3c2410_drv_remove(struct device *dev) 
{ 
struct platform_device *pdev = to_platform_device(dev); 
struct usb_hcd *hcd = dev_get_drvdata(dev); 

usb_hcd_s3c2410_remove(hcd, pdev); 
return 0; 
} 
/*
*s3c2410 主機控制驅動的結構實例
***/
static struct device_driver ohci_hcd_s3c2410_driver = { 
.name = "s3c2410-ohci",   //驅動名稱
.bus = &platform_bus_type,  //總線類型
.probe = ohci_hcd_s3c2410_drv_probe,  //驅動的探測
.remove = ohci_hcd_s3c2410_drv_remove,  //驅動的卸載

}; 
/*s3c2410主機控制器的初始,系統調用,注冊主機設備  */
static int __init ohci_hcd_s3c2410_init (void) 
{ 
return driver_register(&ohci_hcd_s3c2410_driver); 
} 
 /* s3c2410主機控制器的注銷,從Linux內核中注銷驅動程序 */
static void __exit ohci_hcd_s3c2410_cleanup (void) 
{ 
driver_unregister(&ohci_hcd_s3c2410_driver); 
} 
/*  初始&卸載 s3c2410主機控制模塊   */
module_init (ohci_hcd_s3c2410_init); 
module_exit (ohci_hcd_s3c2410_cleanup); 

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩欧美在线影院| 日韩电影一区二区三区四区| 亚洲永久精品大片| 狠狠色丁香婷婷综合| 色婷婷亚洲一区二区三区| 日韩美女天天操| 香港成人在线视频| 91色视频在线| 亚洲国产精品国自产拍av| 精品一区二区三区在线播放| 欧美日韩一区二区在线观看视频| 国产欧美视频在线观看| 麻豆成人av在线| 欧美日韩不卡一区| 亚洲一区视频在线| 99re热视频这里只精品| 中文字幕免费在线观看视频一区| 九九久久精品视频| 日韩欧美一二三四区| 日本一不卡视频| 欧美老女人第四色| 视频在线观看一区| 欧美日韩国产不卡| 亚洲va欧美va人人爽午夜| 色婷婷亚洲综合| 一区二区三区四区国产精品| 91色视频在线| 亚洲狠狠丁香婷婷综合久久久| 成人精品一区二区三区四区| 国产人妖乱国产精品人妖| 国产精品亚洲专一区二区三区 | 欧美电影免费提供在线观看| 亚洲h在线观看| 91超碰这里只有精品国产| 亚洲成av人影院| 91精品黄色片免费大全| 美女mm1313爽爽久久久蜜臀| 日韩精品综合一本久道在线视频| 免费精品99久久国产综合精品| 欧美一三区三区四区免费在线看| 欧美a一区二区| 久久免费视频色| 懂色av噜噜一区二区三区av| 中文字幕av在线一区二区三区| 风间由美性色一区二区三区| 中文字幕五月欧美| 色菇凉天天综合网| 天天色 色综合| 久久青草国产手机看片福利盒子| 成人av电影在线| 亚洲一区二区综合| 日韩一级片网址| 国产一区二区三区在线观看免费视频| 久久理论电影网| 99国产精品久| 亚洲va韩国va欧美va| 精品久久久网站| 成人动漫视频在线| 性做久久久久久免费观看欧美| 精品久久人人做人人爱| gogo大胆日本视频一区| 天天操天天综合网| 国产欧美日韩在线| 欧美日韩aaa| 风间由美中文字幕在线看视频国产欧美| 国产精品美女久久久久av爽李琼 | 菠萝蜜视频在线观看一区| 一二三区精品视频| 精品福利二区三区| 色婷婷综合久久久久中文| 蜜臀久久99精品久久久久宅男| 国产欧美精品一区aⅴ影院| 欧美日韩国产在线观看| 国产真实乱偷精品视频免| 亚洲欧美日韩一区二区三区在线观看| 日韩一级视频免费观看在线| 91日韩在线专区| 国内久久精品视频| 三级欧美在线一区| 中文字幕国产一区| 精品少妇一区二区三区在线播放 | 国产成人亚洲精品青草天美| 亚洲一区二区三区四区在线观看| 久久久久久麻豆| 欧美高清视频不卡网| 99久久伊人网影院| 久久69国产一区二区蜜臀| 亚洲一区二区五区| 国产精品美女www爽爽爽| 精品日韩成人av| 911精品国产一区二区在线| 97精品超碰一区二区三区| 国产自产v一区二区三区c| 五月天激情综合| 一区二区三区四区不卡视频| 国产精品女主播在线观看| 久久天天做天天爱综合色| 911精品国产一区二区在线| 色综合天天综合色综合av| 国产成人精品影视| 国产一区二区在线视频| 麻豆视频观看网址久久| 天天色 色综合| 午夜精品爽啪视频| 亚洲一区成人在线| 一区二区三区不卡视频| 国产精品毛片无遮挡高清| 久久人人97超碰com| 精品国产制服丝袜高跟| 欧美一区2区视频在线观看| 欧美高清视频一二三区| 欧美久久一二三四区| 欧美日韩国产经典色站一区二区三区| 色狠狠一区二区三区香蕉| 一本一道久久a久久精品综合蜜臀 一本一道综合狠狠老 | 国产色91在线| 国产亚洲成年网址在线观看| 国产喷白浆一区二区三区| 久久久久久久久久久99999| 精品国产免费久久| 26uuu久久综合| 国产日韩欧美高清| 中文在线一区二区| 中文字幕免费不卡| 日韩毛片在线免费观看| 一二三四区精品视频| 午夜国产不卡在线观看视频| 日韩vs国产vs欧美| 久久成人羞羞网站| 国产精品伊人色| 99久久精品一区| 欧美网站大全在线观看| 欧美日韩在线播放一区| 日韩欧美中文字幕精品| 久久精品欧美一区二区三区不卡 | 一区二区在线观看免费| 一二三区精品视频| 麻豆久久久久久| 成人黄色777网| 欧美日韩五月天| 亚洲精品一区二区三区香蕉| 国产精品视频线看| 亚洲一二三四在线观看| 日韩成人午夜精品| 福利一区福利二区| 一本一本大道香蕉久在线精品| 欧美色综合天天久久综合精品| 精品欧美黑人一区二区三区| 中文字幕成人网| 日韩精品视频网站| 国产99久久久久| 欧美日韩成人综合天天影院| 久久网站热最新地址| 亚洲一区在线电影| 国产乱一区二区| 色又黄又爽网站www久久| 日韩丝袜美女视频| 亚洲色图一区二区三区| 蜜桃av一区二区| 在线亚洲免费视频| 国产亚洲人成网站| 日本中文一区二区三区| www.色综合.com| 日韩网站在线看片你懂的| 亚洲欧美电影院| 国产精一品亚洲二区在线视频| 欧美色图天堂网| 中文字幕一区二区三区蜜月| 美女网站在线免费欧美精品| 色婷婷国产精品综合在线观看| 欧美精品一二三| 有码一区二区三区| 成人黄色在线看| 久久久久久影视| 久久99国产精品免费网站| 欧美日韩国产精品成人| 亚洲另类春色国产| 成人爱爱电影网址| 亚洲国产精华液网站w| 久久se这里有精品| 欧美精品在线观看一区二区| 亚洲精品伦理在线| 成人国产亚洲欧美成人综合网| 精品国产不卡一区二区三区| 免费久久99精品国产| 欧美午夜在线一二页| 亚洲免费观看视频| av在线不卡观看免费观看| 精品成人免费观看| 麻豆freexxxx性91精品| 欧美一区二区在线不卡| 亚洲国产精品影院| 欧美日韩久久不卡| 亚洲福利电影网| 精品视频1区2区3区| 亚洲成人免费影院| 欧美乱妇23p| 秋霞av亚洲一区二区三| 日韩一区二区三区精品视频| 久久精品国产一区二区|