Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) ========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) i2c-stub
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3) ========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) Description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) ===========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) This module is a very simple fake I2C/SMBus driver.  It implements six
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) types of SMBus commands: write quick, (r/w) byte, (r/w) byte data, (r/w)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) word data, (r/w) I2C block data, and (r/w) SMBus block data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) You need to provide chip addresses as a module parameter when loading this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) driver, which will then only react to SMBus commands to these addresses.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) No hardware is needed nor associated with this module.  It will accept write
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) quick commands to the specified addresses; it will respond to the other
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) commands (also to the specified addresses) by reading from or writing to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) arrays in memory.  It will also spam the kernel logs for every command it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) handles.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) A pointer register with auto-increment is implemented for all byte
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) operations.  This allows for continuous byte reads like those supported by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) EEPROMs, among others.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) SMBus block command support is disabled by default, and must be enabled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) explicitly by setting the respective bits (0x03000000) in the functionality
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) module parameter.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) SMBus block commands must be written to configure an SMBus command for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) SMBus block operations. Writes can be partial. Block read commands always
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) return the number of bytes selected with the largest write so far.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) The typical use-case is like this:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 	1. load this module
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 	2. use i2cset (from the i2c-tools project) to pre-load some data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 	3. load the target chip driver module
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 	4. observe its behavior in the kernel log
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) There's a script named i2c-stub-from-dump in the i2c-tools package which
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) can load register values automatically from a chip dump.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) Parameters
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) ==========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) int chip_addr[10]:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 	The SMBus addresses to emulate chips at.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) unsigned long functionality:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 	Functionality override, to disable some commands. See I2C_FUNC_*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 	constants in <linux/i2c.h> for the suitable values. For example,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 	value 0x1f0000 would only enable the quick, byte and byte data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 	commands.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) u8 bank_reg[10], u8 bank_mask[10], u8 bank_start[10], u8 bank_end[10]:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 	Optional bank settings. They tell which bits in which register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 	select the active bank, as well as the range of banked registers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) Caveats
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) =======
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) If your target driver polls some byte or word waiting for it to change, the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) stub could lock it up.  Use i2cset to unlock it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) If you spam it hard enough, printk can be lossy.  This module really wants
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) something like relayfs.