2 * Nuvoton NPCM7xx SMBus Module.
4 * Copyright 2020 Google LLC
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 #ifndef NPCM7XX_SMBUS_H
17 #define NPCM7XX_SMBUS_H
19 #include "exec/memory.h"
20 #include "hw/i2c/i2c.h"
22 #include "hw/sysbus.h"
25 * Number of addresses this module contains. Do not change this without
26 * incrementing the version_id in the vmstate.
28 #define NPCM7XX_SMBUS_NR_ADDRS 10
30 /* Size of the FIFO buffer. */
31 #define NPCM7XX_SMBUS_FIFO_SIZE 16
33 typedef enum NPCM7xxSMBusStatus
{
34 NPCM7XX_SMBUS_STATUS_IDLE
,
35 NPCM7XX_SMBUS_STATUS_SENDING
,
36 NPCM7XX_SMBUS_STATUS_RECEIVING
,
37 NPCM7XX_SMBUS_STATUS_NEGACK
,
38 NPCM7XX_SMBUS_STATUS_STOPPING_LAST_RECEIVE
,
39 NPCM7XX_SMBUS_STATUS_STOPPING_NEGACK
,
43 * struct NPCM7xxSMBusState - System Management Bus device state.
44 * @bus: The underlying I2C Bus.
45 * @irq: GIC interrupt line to fire on events (if enabled).
46 * @sda: The serial data register.
47 * @st: The status register.
48 * @cst: The control status register.
49 * @cst2: The control status register 2.
50 * @cst3: The control status register 3.
51 * @ctl1: The control register 1.
52 * @ctl2: The control register 2.
53 * @ctl3: The control register 3.
54 * @ctl4: The control register 4.
55 * @ctl5: The control register 5.
56 * @addr: The SMBus module's own addresses on the I2C bus.
57 * @scllt: The SCL low time register.
58 * @sclht: The SCL high time register.
59 * @fif_ctl: The FIFO control register.
60 * @fif_cts: The FIFO control status register.
61 * @fair_per: The fair period register.
62 * @txf_ctl: The transmit FIFO control register.
63 * @t_out: The SMBus timeout register.
64 * @txf_sts: The transmit FIFO status register.
65 * @rxf_sts: The receive FIFO status register.
66 * @rxf_ctl: The receive FIFO control register.
67 * @rx_fifo: The FIFO buffer for receiving in FIFO mode.
68 * @rx_cur: The current position of rx_fifo.
69 * @status: The current status of the SMBus.
71 struct NPCM7xxSMBusState
{
89 uint8_t addr
[NPCM7XX_SMBUS_NR_ADDRS
];
103 uint8_t rx_fifo
[NPCM7XX_SMBUS_FIFO_SIZE
];
106 NPCM7xxSMBusStatus status
;
109 #define TYPE_NPCM7XX_SMBUS "npcm7xx-smbus"
110 OBJECT_DECLARE_SIMPLE_TYPE(NPCM7xxSMBusState
, NPCM7XX_SMBUS
)
112 #endif /* NPCM7XX_SMBUS_H */