qemu/include/hw/ppc/pnv_i2c.h
Cédric Le Goater 263b81ee15 ppc/pnv: Add an I2C controller model
The more recent IBM power processors have an embedded I2C
controller that is accessible by software via the XSCOM
address space.

Each instance of the I2C controller is capable of controlling
multiple I2C buses (one at a time).  Prior to beginning a
transaction on an I2C bus, the bus must be selected by writing
the port number associated with the bus into the PORT_NUM
field of the MODE register.  Once an I2C bus is selected,
the status of the bus can be determined by reading the
Status and Extended Status registers.

I2C bus transactions can be started by writing a command to
the Command register and reading/writing data from/to the
FIFO register.

Not supported :

 . 10 bit I2C addresses
 . Multimaster
 . Slave

Signed-off-by: Cédric Le Goater <clg@kaod.org>
[milesg: Split wiring to powernv9 into its own commit]
[milesg: Added more detail to commit message]
[milesg: Added SPDX Licensed Identifier to new files]
[milesg: updated copyright dates]
[milesg: Added use of g_autofree]
[milesg: Added NULL check after pnv_i2c_get_bus]
Signed-off-by: Glenn Miles <milesg@linux.vnet.ibm.com>
Acked-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Message-ID: <20231016222013.3739530-2-milesg@linux.vnet.ibm.com>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
2023-11-07 15:49:41 -03:00

39 lines
672 B
C

/*
* QEMU PowerPC PowerNV Processor I2C model
*
* Copyright (c) 2019-2023, IBM Corporation.
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef PPC_PNV_I2C_H
#define PPC_PNV_I2C_H
#include "hw/ppc/pnv.h"
#include "hw/i2c/i2c.h"
#include "qemu/fifo8.h"
#define TYPE_PNV_I2C "pnv-i2c"
#define PNV_I2C(obj) OBJECT_CHECK(PnvI2C, (obj), TYPE_PNV_I2C)
#define PNV_I2C_REGS 0x20
typedef struct PnvI2C {
DeviceState parent;
struct PnvChip *chip;
qemu_irq psi_irq;
uint64_t regs[PNV_I2C_REGS];
uint32_t engine;
uint32_t num_busses;
I2CBus **busses;
MemoryRegion xscom_regs;
Fifo8 fifo;
} PnvI2C;
#endif /* PPC_PNV_I2C_H */