s3c6410 linux gadget hid driver

Publisher:TapirLatest update time:2024-09-06 Source: cnblogsKeywords:s3c6410  linux  gadget Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The kernel I use is linux2.6.38. At the beginning, the development board can be used as a USB flash drive, but when using the HID function, the following problems occur:


g_hid gadget: hid_setup crtl_request : bRequestType:0x21 bRequest:0xa Value:0x0

g_hid gadget: Unknown request 0xa

s3c-hsotg s3c-hsotg: writen DxEPCTL=0x04228000 to 00000900 (DxEPCTL=0x00208000)

s3c-hsotg s3c-hsotg: s3c_hsotg_rx_data: FIFO 8 bytes on ep0 but no req (DxEPCTl=0x00028000)

s3c-hsotg s3c-hsotg: s3c_hsotg_rx_data: FIFO 8 bytes on ep0 but no req (DxEPCTl=0x00028000)

s3c-hsotg s3c-hsotg: s3c_hsotg_rx_data: FIFO 8 bytes on ep0 but no req (DxEPCTl=0x00028000)

s3c-hsotg s3c-hsotg: S3C_GINTSTS_USBSusp

This is the information printed out after I turned on the debug information. I thought the device clock was not set correctly. The device clock should be set to 48M, but it turned out that this was not the problem. No matter how I changed the clock, the effect was the same. So last week, I changed the registers one by one, and found that the problem was still the same. So I started to study this: Unknown request 0xa


The general process of hid is s3c_hsotg.c->composite.c->f_hid.c. There are many specific processes on the Internet, so I will not explain them here.


material:


http://blog.csdn.net/wuyuwei45/article/details/8930830


http://blog.csdn.net/fanqipin/article/details/8450694


After struggling for a week, I spent several hours to adjust the HID of 2416. In the end, I had no choice but to do it step by step.


When the host sends a request of 0xa for 6410, the above error will appear directly. However, when the host sends 0xa for 2416, a -95 error will also appear. However, the host will continue to send 0x06 and 0x09 requests. Please check the USB protocol. I will not go into details here.


The operations of 6410 and 2416 when receiving 0xa request are basically the same. The difference is that after receiving 0xa, 2416 will ignore this request and send an empty packet to the host, so that the host will continue to send other requests, while 6410 ignores it after receiving 0xa, but does not send any data to the host, so the subsequent operations cannot be performed.


So the current job is to send an empty packet to the host when the device receives 0xa, so that the enumeration can continue.

The main modification is in the s3c_hsotg_process_control function in s3c_hsotg.c. I won’t analyze the whole process here, I don’t really understand it, haha.



/* as a fallback, try delivering it to the driver to deal with */

if (ret == 0 && hsotg->driver) {

ret = hsotg->driver->setup(&hsotg->gadget, ctrl);

if (ret < 0)

dev_dbg(hsotg->dev, "driver->setup() ret %dn", ret);

}


Here, composite_setup in composite.c processes the request after receiving it. When 0xa is received, an error of -95 is returned. Let's continue reading:




/* the request is either unhandlable, or is not formatted correctly

* so respond with a STALL for the status stage to indicate failure.

*/


if (ret < 0) {

u32 reg;

u32 ctrl;


dev_dbg(hsotg->dev, "ep0 stall (dir=%d)n", ep0->dir_in);

reg = (ep0->dir_in) ? S3C_DIEPCTL0 : S3C_DOEPCTL0;


/* S3C_DxEPCTL_Stall will be cleared by EP once it has

* taken effect, so no need to clear later. */


ctrl = readl(hsotg->regs + reg);

ctrl |= S3C_DxEPCTL_Stall;

ctrl |= S3C_DxEPCTL_CNAK;

writel(ctrl, hsotg->regs + reg);


dev_dbg(hsotg->dev,

"writen DxEPCTL=0x%08x to %08x (DxEPCTL=0x%08x)n",

ctrl, reg, readl(hsotg->regs + reg));


/* don't belive we need to anything more to get the EP

* to reply with a STALL packet */

}

When -95 is returned, only DIEPCTL0 is operated. For specific settings, please refer to the 6410 datasheet.



So we need to add the process of sending an empty packet here. If you look at s3c_hsotg.c, you will find that there is such a function: s3c_hsotg_send_zlp


The function of this function is to send an empty packet to the host. Of course, I cannot copy all of it. Copying all of it will cause problems, so my modifications are as follows:



/* the request is either unhandlable, or is not formatted correctly

* so respond with a STALL for the status stage to indicate failure.

*/


if (ret < 0) {

u32 reg;

u32 ctrl;


dev_dbg(hsotg->dev, "ep0 stall (dir=%d)n", ep0->dir_in);

reg = (ep0->dir_in) ? S3C_DIEPCTL0 : S3C_DOEPCTL0;


/* S3C_DxEPCTL_Stall will be cleared by EP once it has

* taken effect, so no need to clear later. */

if(ret != -95) {

ctrl = readl(hsotg->regs + reg);

ctrl |= S3C_DxEPCTL_Stall;

ctrl |= S3C_DxEPCTL_CNAK;

writel(ctrl, hsotg->regs + reg);

}

else {

/* issue a zero-sized packet to terminate this */

writel(S3C_DxEPTSIZ_MC(1) | S3C_DxEPTSIZ_PktCnt(1) |

S3C_DxEPTSIZ_XferSize(0), hsotg->regs + S3C_DIEPTSIZ(0));


ctrl = readl(hsotg->regs + reg);

ctrl |= S3C_DxEPCTL_CNAK;  /* clear NAK set by core */

ctrl |= S3C_DxEPCTL_EPEna; /* ensure ep enabled */

ctrl |= S3C_DxEPCTL_USBActEp;

writel(ctrl, hsotg->regs + reg);

}


dev_dbg(hsotg->dev,

"writen DxEPCTL=0x%08x to %08x (DxEPCTL=0x%08x)n",

ctrl, reg, readl(hsotg->regs + reg));


/* don't belive we need to anything more to get the EP

* to reply with a STALL packet */

}

When if (ret < 0) is changed to the following, and the original settings are retained to avoid problems later, after this modification, when the host sends 0xa to the device, the device will return an empty packet to the host so that the host will continue with the subsequent operations. In this way, you can see your HID device in your computer hardware management.



My level is limited, please point out if there are any errors.


Keywords:s3c6410  linux  gadget Reference address:s3c6410 linux gadget hid driver

Previous article:Develop ARM programs using only serial ports and network bare metal (OK6410 development board)
Next article:Analysis on the implementation of opengl on s3c6410

Recommended ReadingLatest update time:2024-11-16 08:52

Power management of linux driver: linux sleep and wake-up (2)
In Linux, hibernation is divided into three main steps: (1) Freeze user-mode processes and kernel-mode tasks; (2) Call the suspend callback function of registered devices; (3) Hibernate core devices and enable the CPU according to the registration order. Enter dormant state.        Freezing a process means that the
[Microcontroller]
Running Xen on the ARM platform can manage Linux and VxWorks at the same time
The Xen project hypervisor has been under development at Cambridge University since the 1990s, and was open sourced in 2002. Today, it is one of the most popular open source hypervisors that can be used on cloud computing. Xilinx and DornerWorks have applied this virtualization platform to the Zynq UltraScale+ MPSoC,
[Microcontroller]
Running Xen on the ARM platform can manage Linux and VxWorks at the same time
[linux kernel] Kernel graphical cropping configuration
System version: Ubuntu18.04-64 Compiler version: gcc version 7.4.0 (Ubuntu/Linaro 7.4.0-1ubuntu1~18.04.1) uboot version: 2018.07-linux4sam_6.0 Board model: at91sama5d3x-xplained MCU model: sama5d36 The kernel cross-toolchain relies on the Makefile file for cascade compilation and the Kconfig file for configu
[Microcontroller]
[linux kernel] Kernel graphical cropping configuration
Design of camera driver based on Video4Linux
0 Introduction With the rapid development of multimedia technology, network technology and the advent of the post-PC era, it has become possible to use embedded systems to realize applications such as remote video monitoring, videophone and video conferencing. In order to realize these applications, real-time vi
[Embedded]
Design of camera driver based on Video4Linux
OK6410A Development Board (VIII) 94 linux-5.11 OK6410A Analysis of memory management from the perspective of memory consumers
The memory management unit is consumer-oriented and does the following things 1. Application of physical memory 2. Application of virtual memory 3. Mapping of physical memory and virtual memory The memory management unit provides the following interfaces to consumers 1. Memory application 2. Memory release
[Microcontroller]
Use of Linux 2.4.18 kernel timer
My kernel is 2.4.18 . The Linux kernel defines a timer structure: #include linux/timer.h struct timer_list { struct list_head list; unsigned long expires; // Timer expiration time unsigned long data; // passed as a paramete
[Microcontroller]
Implementation of expansion board hardware circuit design based on Linux and EMBEST S3C4510B development board
USB devices have entered every aspect of our work and life, and they have brought us many conveniences. Therefore, having USB functionality has become a basic requirement for many systems now. The S3C4510B developed by Samsung for ARM7 is a chip that is very frequently used in the industry. Its powerful functions make
[Microcontroller]
Implementation of expansion board hardware circuit design based on Linux and EMBEST S3C4510B development board
VeriSilicon Dai Weimin: RISC-V should learn from the Linux Patent Alliance to protect the interests of relevant companies
Recently, during the third Dishui Lake China RISC-V Industry Forum, Dai Weimin, chairman of the China RISC-V Industry Alliance and founder, chairman and president of VeriSilicon, said that there are currently no patent litigation issues related to RISC-V. But that doesn’t mean patents don’t have risks. If the RISC-V
[Semiconductor design/manufacturing]
VeriSilicon Dai Weimin: RISC-V should learn from the Linux Patent Alliance to protect the interests of relevant companies
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号