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) Kernel driver max6875
^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) Supported chips:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)   * Maxim MAX6874, MAX6875
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)     Prefix: 'max6875'
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)     Addresses scanned: None (see below)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13)     Datasheet: http://pdfserv.maxim-ic.com/en/ds/MAX6874-MAX6875.pdf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) Author: Ben Gardner <bgardner@wabtec.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) Description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) -----------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) The Maxim MAX6875 is an EEPROM-programmable power-supply sequencer/supervisor.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) It provides timed outputs that can be used as a watchdog, if properly wired.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) It also provides 512 bytes of user EEPROM.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) At reset, the MAX6875 reads the configuration EEPROM into its configuration
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) registers.  The chip then begins to operate according to the values in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) registers.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) The Maxim MAX6874 is a similar, mostly compatible device, with more inputs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) and outputs:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) ===========  ===     ===    ====
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) -            vin     gpi    vout
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) ===========  ===     ===    ====
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) MAX6874        6       4       8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) MAX6875        4       3       5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) ===========  ===     ===    ====
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) See the datasheet for more information.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) Sysfs entries
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) -------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) eeprom        - 512 bytes of user-defined EEPROM space.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) General Remarks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) ---------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) Valid addresses for the MAX6875 are 0x50 and 0x52.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) Valid addresses for the MAX6874 are 0x50, 0x52, 0x54 and 0x56.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) The driver does not probe any address, so you explicitly instantiate the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) devices.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) Example::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60)   $ modprobe max6875
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61)   $ echo max6875 0x50 > /sys/bus/i2c/devices/i2c-0/new_device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) The MAX6874/MAX6875 ignores address bit 0, so this driver attaches to multiple
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) addresses.  For example, for address 0x50, it also reserves 0x51.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) The even-address instance is called 'max6875', the odd one is 'dummy'.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) Programming the chip using i2c-dev
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) ----------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) Use the i2c-dev interface to access and program the chips.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) Reads and writes are performed differently depending on the address range.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) The configuration registers are at addresses 0x00 - 0x45.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) Use i2c_smbus_write_byte_data() to write a register and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) i2c_smbus_read_byte_data() to read a register.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) The command is the register number.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) Examples:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) To write a 1 to register 0x45::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86)   i2c_smbus_write_byte_data(fd, 0x45, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) To read register 0x45::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90)   value = i2c_smbus_read_byte_data(fd, 0x45);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) The configuration EEPROM is at addresses 0x8000 - 0x8045.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) The user EEPROM is at addresses 0x8100 - 0x82ff.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) Use i2c_smbus_write_word_data() to write a byte to EEPROM.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) The command is the upper byte of the address: 0x80, 0x81, or 0x82.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) The data word is the lower part of the address or'd with data << 8::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)   cmd = address >> 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)   val = (address & 0xff) | (data << 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) Example:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) To write 0x5a to address 0x8003::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)   i2c_smbus_write_word_data(fd, 0x80, 0x5a03);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) Reading data from the EEPROM is a little more complicated.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) Use i2c_smbus_write_byte_data() to set the read address and then
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) i2c_smbus_read_byte() or i2c_smbus_read_i2c_block_data() to read the data.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) Example:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) To read data starting at offset 0x8100, first set the address::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)   i2c_smbus_write_byte_data(fd, 0x81, 0x00);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) And then read the data::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)   value = i2c_smbus_read_byte(fd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) or::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)   count = i2c_smbus_read_i2c_block_data(fd, 0x84, 16, buffer);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) The block read should read 16 bytes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 0x84 is the block read command.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) See the datasheet for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)