SMBus is a two-wire serial bus. Its first specification was commercially available in 1996. It is mostly based on I2C bus specifications. Like I2C, SMBus does not require additional pins. It is created to add new features, but only works at kHz and is dedicated to smart battery management applications. It works in Mast
"# include
In the kernel driver; one is published by the i2c-tools for use in user programs. Obviously, we need to use the second
A i2c-dev.h file.
Now, you need to determine which adapter to access. You Need To view/sys/class/i2c-dev/or run
"I2cdetect-L" OK. The adapter number is often dynamically allocated. You cannot preassume a value. Because they are
It wi
communication method in struct i2c_adapter, is defined as follows. The implementation of this member and its kernel method is the core task of developing the I2C bus driver. This struct is defined in include/linux/i2c. h.
1 struct i2c_algorithm {2/* points to a specific I2C transmission function pointer. The corresponding transmission is generally initiated by d
) #define Late_initcall (FN) __define_initcall ("7", fn,7) #define LATE_INITCALL_SYNC (FN) __define_initcall ("7s", FN,
7s) #define __initcall (FN) Device_initcall (FN) ... #define MODULE_INIT (x) __initcall (x);Here it can be found that in the actual drive, the initialization function has the following form: Module_init (Init_func)
Originally Module_init is a macro, you can find Module_init macro eventually expanded will be init_func function as a
The initcall6.init tag, and eventually this
indirectly increased:Static int i2cdev_attach_adapter (struct i2c_adapter * ADAP) As you can see, the device embedded in i2c_dev uses ADAP-> Dev as the parent node and adds a reference count of ADAP-> Dev in device_create.Now, the open () operation is complete.Usage: (refer to kernel-test/i2c-msm-test.c)1. Construct struct i2c_msg[Read] struct i2c_msg msgs [] ={2. Operate the device through IOCTL
Static int do_rdwr (int fd, struct i2c_msg * msgs, int
() and write () methods are only applicable when the adapter supports I2C algorithms, for example:
Static const struct i2c_algorithm s3c24xx_i2c_algorithm = {. Master_xfer = s3c24xx_i2c_xfer,. Functionality = s3c24xx_i2c_func,};
This method is not suitable when the adapter only supports the SMBus algorithm, for example:Static const struct i2c_algorithm smbus_algorithm = {. Smbus_xfer = i801_access,. Functi
SMBusDirectory
the difference between SMBus and I²c
SMBus is the abbreviation for System Management Bus, which was proposed by Intel in 1995 for low-rate communication in mobile PC and desktop PC systems. It mainly wants to control the device on the motherboard and collect the information by means of a cheap and powerful bus (consisting of two lines).
() methods are only applicable when the adapter supports I2C algorithms, for example:
Static const struct i2c_algorithm s3c24xx_i2c_algorithm = {. Master_xfer = s3c24xx_i2c_xfer,. Functionality = s3c24xx_i2c_func,};
This method is not suitable when the adapter only supports the SMBus algorithm, for example:Static const struct i2c_algorithm smbus_algorithm = {. Smbus_xfer = i801_access,. Functionality = i80
1. The following error occurred while compiling the kernelCHK Include/linux/version.hCHK include/generated/utsrelease.hMAKE[1]: ' Include/generated/mach-types.h ' is up to date.Call scripts/checksyscalls.shCC SCRIPTS/MOD/EMPTY.O/OPT/FRIENDLYARM/TOOLSCHAIN/4.5.1/LIB/GCC/ARM-NONE-LINUX-GNUEABI/4.5.1/. /.. /.. /.. /arm-none-linux-gnueabi/bin/as:error while loading shared libraries:libz.so.1:cannot open shared object file:no such F Ile or DirectoryMAKE[2]: * * * [SCRIPTS/MOD/EMPTY.O] Error 1MAKE[1]:
Error : error message on system boot: Piix4_smbus 0000:00:007.3:host SMBus Controller not enabledReason: The system is loaded into the I2C_PIIX4 module because the system cannot find the module, so the errorProcessing method:1. Find out the exact name of the loading module (lsmod | grep i2c_piix4), and the result of the output is the exact name of the module: i2c_piix42, the module is included in the non-loading list. Edit file vim/etc/modprobe.d/blac
(there are also two ways, the first is to use the i2c-dev.c provided by the kernel to build, the other is to write)
The first method is as follows:Use the i2c-dev.c provided by the system to implement a device file for an I2C adapter. Then, the I2C device is controlled by operating the
1. Overview
2. Data Structure
3. Adapter
4. I2c-core
5. Slave Device
1. Overview
1.1 Definition I2C inter-integrated circuit SMBUS System Management Bus, the I2C subset
1.2 Characteristics The amount of data exchanged is small. The required data transfer rate is low.
1.3 Speed Fast speed Kbps Full speed Kbps
1.4 Topol
}
D, write a hybrid device operation function
static struct Miscdevice At24c02_dev = {. minor = Misc_dynamic_minor,//automatic allocation of secondary device number. Name = "At24c02",//DEV/AT24C02. FoPs = at24c02_fops};
static struct File_operations At24c02_fops = {. Owner = This_module,. Unlocked_ioctl = At24c02_ioctl};
E, implement At24c02_ioctl function
The IOCTL function realizes the data transmission interface, uses the SMBus interface to throw t
settings to register Cdev:cdev_init (cdev,file_operations); Cdev_add ()(1) Read:{/* Check whether the I2c_adapter supports read-byte functionality/* I2c_check_functionality (I2c_func_smbus_read_byte_data) i2c_smbus_read_byte_data ()/ /from EEPROM read a byte of Data copy_to_user ()//Copy to user space}Not all I2C or SMBus adapters implement all the functionality on the
identify a physical I2C bus along with the access algorithms necessary to access it .*/Struct i2c_adapter {
Struct module * owner;
Unsigned int ID;
Unsigned int class;/* classes to allow probing */
Const struct i2c_algorithm * algo;/* the algorithm to access the bus */
Void * algo_data;
/* Data fields that are valid for all devices */
U8 level;/* nesting level for lockdep */
Struct mutex bus_lock;
Int timeout;/* In jiffies */
Int retries
data structure of each device on the bus. A static array can be used because one I2C bus can only have i2c_clent_max devices. (if the number of related data structures is unknown, the linked list is obviously a better choice ). Lock semaphores are used to achieve mutex access to the I2C bus: the current process must first obtain the semaphores during access to any device on the
After installing the Ubuntu16.10 in VMware, the ' SMBus Host Controller not enabled ' Error prompt is started and cannot be entered into the GUI.Search the Web, the solution is to enter the terminal window in the graphical interface, edit the blacklist.conf file, prohibit i2c_piix4 driver loading.But now the system has not been loaded, into the terminal window, how to deal with it?The workaround is as follows (pro-Test available):Systems running on a
"Piix4_smbus0000:00:07.3:host SMBus Controller not enabled!" appears after each boot completion of the virtual machine deployment Ubuntu10.04-server Prompt informationOnline search is the result of Ubuntu loading i2c_piix4 module, processing method:1. Find out the exact name of the loading module: lsmod | grep i²c# Lsmod | grep i2c_piix4I2C_PIIX4 12574 02, the module is included in the non-loading list. Edit file/etc/modprobe.d/blacklist.conf, add bla
Linux under the I2C-driven loading process, divided into I2C equipment layer, I2C adapter layer and I2C core layer
The I2C device driver layer is the drive we write for a particular I2C device, and the following is the
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.