[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 34/40] hw/arm: Add I2C sensors and EEPROM for GSJ machine
From: |
Peter Maydell |
Subject: |
[PULL 34/40] hw/arm: Add I2C sensors and EEPROM for GSJ machine |
Date: |
Tue, 16 Feb 2021 16:16:52 +0000 |
From: Hao Wu <wuhaotsh@google.com>
Add AT24 EEPROM and temperature sensors for GSJ machine.
Reviewed-by: Doug Evans<dje@google.com>
Reviewed-by: Tyrong Ting<kfting@nuvoton.com>
Signed-off-by: Hao Wu <wuhaotsh@google.com>
Message-id: 20210210220426.3577804-4-wuhaotsh@google.com
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
hw/arm/npcm7xx_boards.c | 27 +++++++++++++++++++++++++++
hw/arm/Kconfig | 1 +
2 files changed, 28 insertions(+)
diff --git a/hw/arm/npcm7xx_boards.c b/hw/arm/npcm7xx_boards.c
index 47a215bd015..fbf6ce8e028 100644
--- a/hw/arm/npcm7xx_boards.c
+++ b/hw/arm/npcm7xx_boards.c
@@ -19,6 +19,7 @@
#include "exec/address-spaces.h"
#include "hw/arm/npcm7xx.h"
#include "hw/core/cpu.h"
+#include "hw/i2c/smbus_eeprom.h"
#include "hw/loader.h"
#include "hw/qdev-properties.h"
#include "qapi/error.h"
@@ -104,6 +105,17 @@ static I2CBus *npcm7xx_i2c_get_bus(NPCM7xxState *soc,
uint32_t num)
return I2C_BUS(qdev_get_child_bus(DEVICE(&soc->smbus[num]), "i2c-bus"));
}
+static void at24c_eeprom_init(NPCM7xxState *soc, int bus, uint8_t addr,
+ uint32_t rsize)
+{
+ I2CBus *i2c_bus = npcm7xx_i2c_get_bus(soc, bus);
+ I2CSlave *i2c_dev = i2c_slave_new("at24c-eeprom", addr);
+ DeviceState *dev = DEVICE(i2c_dev);
+
+ qdev_prop_set_uint32(dev, "rom-size", rsize);
+ i2c_slave_realize_and_unref(i2c_dev, i2c_bus, &error_abort);
+}
+
static void npcm750_evb_i2c_init(NPCM7xxState *soc)
{
/* lm75 temperature sensor on SVB, tmp105 is compatible */
@@ -116,6 +128,20 @@ static void npcm750_evb_i2c_init(NPCM7xxState *soc)
i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 6), "tmp105", 0x48);
}
+static void quanta_gsj_i2c_init(NPCM7xxState *soc)
+{
+ /* GSJ machine have 4 max31725 temperature sensors, tmp105 is compatible.
*/
+ i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 1), "tmp105", 0x5c);
+ i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 2), "tmp105", 0x5c);
+ i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 3), "tmp105", 0x5c);
+ i2c_slave_create_simple(npcm7xx_i2c_get_bus(soc, 4), "tmp105", 0x5c);
+
+ at24c_eeprom_init(soc, 9, 0x55, 8192);
+ at24c_eeprom_init(soc, 10, 0x55, 8192);
+
+ /* TODO: Add additional i2c devices. */
+}
+
static void npcm750_evb_init(MachineState *machine)
{
NPCM7xxState *soc;
@@ -141,6 +167,7 @@ static void quanta_gsj_init(MachineState *machine)
npcm7xx_load_bootrom(machine, soc);
npcm7xx_connect_flash(&soc->fiu[0], 0, "mx25l25635e",
drive_get(IF_MTD, 0, 0));
+ quanta_gsj_i2c_init(soc);
npcm7xx_load_kernel(machine, soc);
}
diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig
index be017b997ab..4e6f4ffe90c 100644
--- a/hw/arm/Kconfig
+++ b/hw/arm/Kconfig
@@ -370,6 +370,7 @@ config NPCM7XX
bool
select A9MPCORE
select ARM_GIC
+ select AT24C # EEPROM
select PL310 # cache controller
select SERIAL
select SSI
--
2.20.1
- [PULL 18/40] linux-user: Fix types in uaccess.c, (continued)
- [PULL 18/40] linux-user: Fix types in uaccess.c, Peter Maydell, 2021/02/16
- [PULL 19/40] linux-user: Handle tags in lock_user/unlock_user, Peter Maydell, 2021/02/16
- [PULL 20/40] linux-user/aarch64: Implement PR_TAGGED_ADDR_ENABLE, Peter Maydell, 2021/02/16
- [PULL 21/40] target/arm: Improve gen_top_byte_ignore, Peter Maydell, 2021/02/16
- [PULL 22/40] target/arm: Use the proper TBI settings for linux-user, Peter Maydell, 2021/02/16
- [PULL 24/40] linux-user/aarch64: Implement PROT_MTE, Peter Maydell, 2021/02/16
- [PULL 23/40] linux-user/aarch64: Implement PR_MTE_TCF and PR_MTE_TAG, Peter Maydell, 2021/02/16
- [PULL 26/40] linux-user/aarch64: Pass syndrome to EXC_*_ABORT, Peter Maydell, 2021/02/16
- [PULL 30/40] target/arm: Enable MTE for user-only, Peter Maydell, 2021/02/16
- [PULL 28/40] linux-user/aarch64: Signal SEGV_MTEAERR for async tag check error, Peter Maydell, 2021/02/16
- [PULL 34/40] hw/arm: Add I2C sensors and EEPROM for GSJ machine,
Peter Maydell <=
- [PULL 32/40] hw/i2c: Implement NPCM7XX SMBus Module Single Mode, Peter Maydell, 2021/02/16
- [PULL 29/40] target/arm: Add allocation tag storage for user mode, Peter Maydell, 2021/02/16
- [PULL 35/40] hw/i2c: Add a QTest for NPCM7XX SMBus Device, Peter Maydell, 2021/02/16
- [PULL 25/40] target/arm: Split out syndrome.h from internals.h, Peter Maydell, 2021/02/16
- [PULL 31/40] tests/tcg/aarch64: Add mte smoke tests, Peter Maydell, 2021/02/16
- [PULL 27/40] linux-user/aarch64: Signal SEGV_MTESERR for sync tag check fault, Peter Maydell, 2021/02/16
- [PULL 39/40] hw/arm: Add npcm7xx emc model, Peter Maydell, 2021/02/16
- [PULL 33/40] hw/arm: Add I2C sensors for NPCM750 eval board, Peter Maydell, 2021/02/16
- [PULL 36/40] hw/i2c: Implement NPCM7XX SMBus Module FIFO Mode, Peter Maydell, 2021/02/16
- [PULL 37/40] MAINTAINERS: add myself maintainer for the clock framework, Peter Maydell, 2021/02/16