USB hot-swap driver problem for s3c2440

Publisher:温柔心情Latest update time:2024-08-05 Source: cnblogsKeywords:s3c2440 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The USB driver of s3c2440 has better support in the newer LINUX kernel, and the code modification is less, but there are still some problems. The modification records are as follows:


1. Pay attention to selecting the following items in the compilation options, and the others can be selected according to actual conditions:


[*]USB support-à


<*> support for Host-side USB


[*] USB device filesystem


[*] USB device class-devices(DEPRECATED)


<*>OHCI HCD support


<*>USB Mass storage support


2. Modify drivers/usb/host/ohci-s3c2410.c (to solve error -62 when inserting USB device)


#include

#include

unsigned long upllvalue = (0x78<<12)|(0x02<<4)|(0x03); //add static void s3c2410_start_hc function

while (upllvalue !=__raw_readl(S3C2410_UPLLCON))

{

__raw_writel(upllvalue, S3C2410_UPLLCON);

mdelay(1);


}


Write S3C2410_UPLLCON register to set USB clock UPLL to 48MHz


If you still have problems, refer to the article by tpu boss:


Today, tpu took out a 2440 board for debugging and found that despite various measures, USBHOST would occasionally not work. UCLK was brought out through CLKOUT0 and checked with an oscilloscope. It was found that when it did not work, UCLK was not stable at all. So after careful consideration, there are several places that affect USB:


1. External crystal oscillator 16.9344Mhz

2. UPLL LOCKTIME of LOCKTIME register

3.UPLLCON

4. UPLL switch of CLKSLOW register


Next, exclude them one by one:

1. The crystal oscillator is shared by MPLL and UPLL. I have never heard of MPLL being unstable.

2. I suspect that LOCKTIME is too large (0xffff), but reducing it has no effect.

3. When UCLK is unstable, it is useless to repeatedly set UPLLCON.

4. When UCLK is unstable, switching UPLL is effective! When UCLK is stable, switching UPLL will also cause instability.


That is to say, UPLL may fail to synchronize when it starts. But why? UPLL and MPLL should have the same structure, and MPLL never has problems. UPLL just has a lower frequency than MPLL. Then let's look for it from the frequency.


Now set a relatively low frequency (such as 7Mhz) for UPLLCON. At this time, no matter how UPLL is turned on and off, UCLK is still not stable. Well, dawn has appeared! Then set a super high frequency (112Mhz). Haha, no matter how UPLL is turned on and off, or powered on, UCLK is very stable.


The problem can then be described as follows: UPLL cannot start reliably at low frequencies.

Solution to the problem: First give UPLL a higher frequency, and then set the required frequency after it works stably.

Note: If you want to turn on or off the UPLL switch in CLKSLOW, you must also follow this setting procedure.


After this modification, the TPU switched on and off for more than 100 times, and UCLK was always very stable. This is only the case for 2440, but it should also be applicable to 2410. You can actually test and verify it.


Change the s3c2410_start_hc function as follows:


static void s3c2410_start_hc(struct platform_device *dev, struct usb_hcd *hcd)

{

struct s3c2410_hcd_info *info = dev->dev.platform_data;

//--------------------------------

unsigned long upllvalue = (0x69<<12)|(0x01<<4)|(0x02); //Set the higher frequency first

while (upllvalue != __raw_readl(S3C2410_UPLLCON))

{

__raw_writel(upllvalue, S3C2410_UPLLCON);

mdelay(1);

}


clk_enable(usb_clk);

mdelay(11);

clk_enable(clk);

mdelay(2);

clk_disable(usb_clk);

mdelay(11);


upllvalue = (0x78<<12)|(0x02<<4)|(0x03); //Change to 48MHz

while (upllvalue != __raw_readl(S3C2410_UPLLCON))

{

__raw_writel(upllvalue, S3C2410_UPLLCON);

mdelay(1);

}

//--------------------------------

dev_dbg(&dev->dev, "s3c2410_start_hc:/n");


clk_enable(usb_clk);

mdelay(2); /* let the bus clock stabilize */


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);

}

}

}


The problem is solved. I would like to express my highest respect to tpu boss here. The pursuit of knowledge will never end!

3. An error occurred when mounting the USB drive, saying that the device could not be found, but the ls /dev command showed that there was sda1


This is usually because the USB flash drive's file system is not supported, so support for VFAT and NTFS should be added when the kernel is compiled.

Keywords:s3c2440 Reference address:USB hot-swap driver problem for s3c2440

Previous article:Solution to USB driver failure under DNW
Next article:S3C2440 implements DM9000 network card driver transplantation

Latest Microcontroller Articles
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号