Skip to content
Snippets Groups Projects
  1. Jul 03, 2022
  2. Jul 02, 2022
  3. Jun 30, 2022
    • Richard Henderson's avatar
      Merge tag 'pull-aspeed-20220630' of https://github.com/legoater/qemu into staging · d495e432
      Richard Henderson authored
      aspeed queue:
      
      * m25p80 improvements (Iris)
      * Code cleanup in preparation of multi SoC machine (Peter)
      * New MAX31785 model (Mahesh)
      * New Qualcomm machines (Jae and Graeme)
      * Core I2C slave mode (Klaus)
      * Aspeed I2C slave mode for old and new register interface (Peter and Klaus)
      * New Aspeed PECI model (Peter)
      * Various small fixes
      
      # -----BEGIN PGP SIGNATURE-----
      #
      # iQIzBAABCAAdFiEEoPZlSPBIlev+awtgUaNDx8/77KEFAmK9UfQACgkQUaNDx8/7
      # 7KFYWhAAtlx3aaEacrn/ONNHjk6G9Fxku56gAbaIiuiaIWNOj3/T2frPsnmbO8x8
      # EKrgUYB8i8PFve/fJYA5vZUzIddPTaHkULZ12JQoGVg0L9hDBbizslN5lJWRXoSv
      # 9r3DF9nahzLKRNvzoBfuKjHDQ2cwHoFgYmKmlYpDcgfmBcl16uzZy8jvxg/Tghur
      # umH4IJMjeDNz/kLfINoO/m+kuFPVXmbTJNwl8uK5MUVDTgVSqharywWlUizugBVH
      # StLE+GmBPylTuYXyiOzLTkoGJeeHp3sQ1DmyI4DD83odjnfxa0BGMGDVhD35exXi
      # 9tLY9FgQ4smATuyN0UGAKZTBmzpI+ov0HMzvH4lUMR8i8daBuEet3RVr/DqkOP4h
      # LEVTRWTaTJip24ohgw4K/b86pI9nTJWVPGV56eZGYmnqufnvf/upNU65/nCsF/xD
      # i1TdS+zJWxhjgGEepg9cTmxxUlA4jVNNbl6dvAgS5Jr6Igrd1BlCSXjmyhO3NRPZ
      # bgOuvCb3RyxAY4+/9wphx2/t5X2VIU6R8EAjnh+7nIgBhOQU5SZ6uefFVYZq8xx+
      # IYEDHj3saiRa4FHmyOgeRxRaQj/Vvs83PPti2rPmJuieqiClJmbE+XfTIamoxVIv
      # 5USlKmMRRVI69MjsjwFi/gOaV/N1EUgcFoYbnvwZ+Md3fg5+70M=
      # =oUKu
      # -----END PGP SIGNATURE-----
      # gpg: Signature made Thu 30 Jun 2022 01:04:12 PM +0530
      # gpg:                using RSA key A0F66548F04895EBFE6B0B6051A343C7CFFBECA1
      # gpg: Good signature from "Cédric Le Goater <clg@kaod.org>" [undefined]
      # gpg: WARNING: This key is not certified with a trusted signature!
      # gpg:          There is no indication that the signature belongs to the owner.
      # Primary key fingerprint: A0F6 6548 F048 95EB FE6B  0B60 51A3 43C7 CFFB ECA1
      
      * tag 'pull-aspeed-20220630' of https://github.com/legoater/qemu
      
      : (27 commits)
        hw/misc/aspeed: Add PECI controller
        hw/i2c/aspeed: Add new-registers DMA slave mode RX support
        hw/i2c/aspeed: add slave device in old register mode
        hw/i2c: add asynchronous send
        hw/i2c: support multiple masters
        hw/i2c/aspeed: Fix MASTER_EN missing error message
        hw/i2c/aspeed: Fix DMA len write-enable bit handling
        hw/i2c/aspeed: Fix R_I2CD_FUN_CTRL reference
        hw/arm/aspeed: firework: add I2C MUXes for VR channels
        hw/arm/aspeed: firework: Add Thermal Diodes
        hw/arm/aspeed: Add MAX31785 Fan controllers
        hw/sensor: add Maxim MAX31785 device
        hw/i2c: pmbus: Page #255 is valid page for read requests.
        hw/arm/aspeed: add Qualcomm Firework BMC machine
        hw/arm/aspeed: add support for the Qualcomm DC-SCM v1 board
        aspeed: Remove use of qemu_get_cpu
        aspeed: Map unimplemented devices in SoC memory
        aspeed: Remove usage of sysbus_mmio_map
        aspeed: Add memory property to Aspeed SoC
        aspeed: Set CPU memory property explicitly
        ...
      
      Signed-off-by: default avatarRichard Henderson <richard.henderson@linaro.org>
      d495e432
    • Peter Delevoryas's avatar
      hw/misc/aspeed: Add PECI controller · 55c57023
      Peter Delevoryas authored
      
      This introduces a really basic PECI controller that responses to
      commands by always setting the response code to success and then raising
      an interrupt to indicate the command is done. This helps avoid getting
      hit with constant errors if the driver continuously attempts to send a
      command and keeps timing out.
      
      The AST2400 and AST2500 only included registers up to 0x5C, not 0xFC.
      They supported PECI 1.1, 2.0, and 3.0. The AST2600 and AST1030 support
      PECI 4.0, which includes more read/write buffer registers from 0x80 to
      0xFC to support 64-byte mode.
      
      This patch doesn't attempt to handle that, or to create a different
      version of the controller for the different generations, since it's only
      implementing functionality that is common to all generations.
      
      The basic sequence of events is that the firmware will read and write to
      various registers and then trigger a command by setting the FIRE bit in
      the command register (similar to the I2C controller).
      
      Then the firmware waits for an interrupt from the PECI controller,
      expecting the interrupt status register to be filled in with info on
      what happened. If the command was transmitted and received successfully,
      then response codes from the host CPU will be found in the data buffer
      registers.
      
      Signed-off-by: default avatarPeter Delevoryas <pdel@fb.com>
      Reviewed-by: default avatarCédric Le Goater <clg@kaod.org>
      Message-Id: <20220630045133.32251-12-me@pjd.dev>
      [ clg: s/sysbus_mmio_map/aspeed_mmio_map/ ]
      Signed-off-by: default avatarCédric Le Goater <clg@kaod.org>
      55c57023
    • Peter Delevoryas's avatar
      hw/i2c/aspeed: Add new-registers DMA slave mode RX support · 1c5d909f
      Peter Delevoryas authored
      
      This commit adds support for DMA RX in slave mode while using the new
      register set in the AST2600 and AST1030. This patch also pretty much
      assumes packet mode is enabled, I'm not sure if this will work in DMA
      step mode.
      
      This is particularly useful for testing IPMB exchanges between Zephyr
      and external devices, which requires multi-master I2C support and DMA in
      the new register mode, because the Zephyr drivers from Aspeed use DMA in
      the new mode by default. The Zephyr drivers are also using packet mode.
      
      The typical sequence of events for receiving data in DMA slave + packet
      mode is that the Zephyr firmware will configure the slave address
      register with an address to receive on and configure the bus's function
      control register to enable master mode and slave mode simultaneously at
      startup, before any transfers are initiated.
      
      RX DMA is enabled in the slave mode command register, and the slave RX
      DMA buffer address and slave RX DMA buffer length are set. TX DMA is not
      covered in this patch.
      
      When the Aspeed I2C controller receives data from some other I2C master,
      it will reset the I2CS_DMA_LEN RX_LEN value to zero, then buffer
      incoming data in the RX DMA buffer while incrementing the I2CC_DMA_ADDR
      address counter and decrementing the I2CC_DMA_LEN counter. It will also
      update the I2CS_DMA_LEN RX_LEN value along the way.
      
      Once all the data has been received, the bus controller will raise an
      interrupt indicating a packet command was completed, the slave address
      matched, a normal stop condition was seen, and the transfer was an RX
      operation.
      
      If the master sent a NACK instead of a normal stop condition, or the
      transfer timed out, then a slightly different set of interrupt status
      values would be set. Those conditions are not handled in this commit.
      
      The Zephyr firmware then collects data from the RX DMA buffer and clears
      the status register by writing the PKT_MODE_EN bit to the status
      register. In packet mode, clearing the packet mode interrupt enable bit
      also clears most of the other interrupt bits automatically (except for a
      few bits above it).
      
      Note: if the master transmit or receive functions were in use
      simultaneously with the slave mode receive functionality, then the
      master mode functions may have raised the interrupt line for the bus
      before the DMA slave transfer is complete. It's important to have the
      slave's interrupt status register clear throughout the receive
      operation, and if the slave attempts to raise the interrupt before the
      master interrupt status is cleared, then it needs to re-raise the
      interrupt once the master interrupt status is cleared. (And vice-versa).
      That's why in this commit, when the master interrupt status is cleared
      and the interrupt line is lowered, we call the slave interrupt _raise_
      function, to see if the interrupt was pending. (And again, vice-versa).
      
      Signed-off-by: default avatarPeter Delevoryas <pdel@fb.com>
      Message-Id: <20220630045133.32251-8-me@pjd.dev>
      Signed-off-by: default avatarCédric Le Goater <clg@kaod.org>
      1c5d909f
    • Klaus Jensen's avatar
      hw/i2c/aspeed: add slave device in old register mode · a8d48f59
      Klaus Jensen authored
      
      Add slave mode functionality for the Aspeed I2C controller in old
      register mode. This is implemented by realizing an I2C slave device
      owned by the I2C controller and attached to its own bus.
      
      The I2C slave device only implements asynchronous sends on the bus, so
      slaves not supporting that will not be able to communicate with it.
      
      Signed-off-by: default avatarKlaus Jensen <k.jensen@samsung.com>
      [ clg: checkpatch fixes ]
      Message-Id: <20220601210831.67259-6-its@irrelevant.dk>
      Signed-off-by: default avatarCédric Le Goater <clg@kaod.org>
      Message-Id: <20220630045133.32251-7-me@pjd.dev>
      Signed-off-by: default avatarCédric Le Goater <clg@kaod.org>
      a8d48f59
    • Klaus Jensen's avatar
      hw/i2c: add asynchronous send · a78e9839
      Klaus Jensen authored
      
      Add an asynchronous version of i2c_send() that requires the slave to
      explicitly acknowledge on the bus with i2c_ack().
      
      The current master must use the new i2c_start_send_async() to indicate
      that it wants to do an asynchronous transfer. This allows the i2c core
      to check if the target slave supports this or not. This approach relies
      on adding a new enum i2c_event member, which is why a bunch of other
      devices needs changes in their event handling switches.
      
      Signed-off-by: default avatarKlaus Jensen <k.jensen@samsung.com>
      Message-Id: <20220601210831.67259-5-its@irrelevant.dk>
      Signed-off-by: default avatarCédric Le Goater <clg@kaod.org>
      Message-Id: <20220630045133.32251-6-me@pjd.dev>
      Signed-off-by: default avatarCédric Le Goater <clg@kaod.org>
      a78e9839
    • Klaus Jensen's avatar
      hw/i2c: support multiple masters · 37fa5ca4
      Klaus Jensen authored
      
      Allow slaves to master the bus by registering a bottom halve. If the bus
      is busy, the bottom half is queued up. When a slave has succesfully
      mastered the bus, the bottom half is scheduled.
      
      Signed-off-by: default avatarKlaus Jensen <k.jensen@samsung.com>
      [ clg : - fixed typos in commit log ]
      Message-Id: <20220601210831.67259-4-its@irrelevant.dk>
      Signed-off-by: default avatarCédric Le Goater <clg@kaod.org>
      Message-Id: <20220630045133.32251-5-me@pjd.dev>
      Signed-off-by: default avatarCédric Le Goater <clg@kaod.org>
      37fa5ca4
    • Peter Delevoryas's avatar
      hw/i2c/aspeed: Fix MASTER_EN missing error message · 0c0f1bee
      Peter Delevoryas authored
      
      aspeed_i2c_bus_is_master is checking if master mode is enabled in the I2C
      bus controller's function-control register, not that slave mode is enabled
      or something.  The error here is that the guest is trying to trigger an I2C
      master mode command while master mode is not enabled.
      
      Fixes: ba2cccd6 ("aspeed: i2c: Add new mode support")
      Signed-off-by: default avatarPeter Delevoryas <pdel@fb.com>
      Message-Id: <20220630045133.32251-4-me@pjd.dev>
      Reviewed-by: default avatarCédric Le Goater <clg@kaod.org>
      Signed-off-by: default avatarCédric Le Goater <clg@kaod.org>
      0c0f1bee
    • Peter Delevoryas's avatar
      hw/i2c/aspeed: Fix DMA len write-enable bit handling · b582b7a1
      Peter Delevoryas authored
      I noticed i2c rx transfers were getting shortened to "1" on Zephyr. It
      seems to be because the Zephyr i2c driver sets the RX DMA len with the
      RX field write-enable bit set (bit 31) to avoid a read-modify-write. [1]
      
      /* 0x1C : I2CM Master DMA Transfer Length Register   */
      
      I think we should be checking the write-enable bits on the incoming
      value, not checking the register array. I'm not sure we're even writing
      the write-enable bits to the register array, actually.
      
      [1] https://github.com/AspeedTech-BMC/zephyr/blob/db3dbcc9c52e67a47180890ac938ed380b33f91c/drivers/i2c/i2c_aspeed.c#L145-L148
      
      
      
      Fixes: ba2cccd6 ("aspeed: i2c: Add new mode support")
      Signed-off-by: default avatarPeter Delevoryas <pdel@fb.com>
      Message-Id: <20220630045133.32251-3-me@pjd.dev>
      Reviewed-by: default avatarCédric Le Goater <clg@kaod.org>
      Signed-off-by: default avatarCédric Le Goater <clg@kaod.org>
      b582b7a1
Loading