Linux 2.6.21 read core notes at91_i2c-Linux general technology-Linux programming and kernel information. The following is a detailed description. In the use of linux 2.6.21 in at91rm9200 (Atmel), it seems that i2c is not very good and sometimes unreliable!
Errors may occur after thousands of reads and writes. However, note the following:
A. at91rm9200 datasheet Page396 requirements are as follows:
• Program the PIO controller:
? Dedicate TWD and TWCK as peripheral lines.
? Define TWD and TWCK as open-drain.
In linux 2.6.21, how does one implement kernel?
2.6.21 is different from 2.4.18 in many systems, such as initializing this part 2.4.18 in kernel_source_root/drivers/i2c/, while 2.6.21 in kernel_source_root/Arch/arm/Mach-at91/At91rm9200_devices.c.
The at91_add_device_i2c () function completes the initialization of at91 i2c. Let's give the definition of the two functions.
/*
* Mux the pin to the "A" internal peripheral role.
*/
Int _ init_or_module at91_set_A_periph (unsigned pin, int use_pullup)
{
Void _ iomem * pio = pin_to_controller (pin );
Unsigned mask = pin_to_mask (pin );
If (! Pio)
Return-EINVAL;
_ Raw_writel (mask, pio + PIO_IDR );
_ Raw_writel (mask, pio + (use_pullup? PIO_PUER: PIO_PUDR ));
_ Raw_writel (mask, pio + PIO_ASR );
_ Raw_writel (mask, pio + PIO_PDR );
Return 0;
}
Obviously: at91_set_A_periph assigns the pin the PeriphA function and marks it by use_pullup.
Int _ init_or_module at91_set_multi_drive (unsigned pin, int is_on)
{
Void _ iomem * pio = pin_to_controller (pin );
Unsigned mask = pin_to_mask (pin );
If (! Pio)
Return-EINVAL;
_ Raw_writel (mask, pio + (is_on? PIO_MDER: PIO_MDDR ));
Return 0;
}
While at91_set_multi_drive (unsigned pin, int is_on) sets whether the pin can be used in multiple functions.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.