hw/arm: Extract at24c_eeprom_init helper from Aspeed and Nuvoton boards

This helper is useful in board initialization because lets users initialize and
realize an EEPROM on an I2C bus with a single function call.

Signed-off-by: Peter Delevoryas <peter@pjd.dev>
Reviewed-by: Cédric Le Goater <clg@kaod.org>
Reviewed-by: Joel Stanley <joel@jms.id.au>
Reviewed-by: Corey Minyard <cminyard@mvista.com>
Link: https://lore.kernel.org/r/20230128060543.95582-2-peter@pjd.dev
Signed-off-by: Cédric Le Goater <clg@kaod.org>
This commit is contained in:
Peter Delevoryas 2023-02-07 09:02:04 +01:00 committed by Cédric Le Goater
parent ddbf7bd73c
commit 9618ebae45
4 changed files with 41 additions and 24 deletions

View file

@ -0,0 +1,23 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* SPDX-License-Identifier: GPL-2.0-only
*/
#ifndef EEPROM_AT24C_H
#define EEPROM_AT24C_H
#include "hw/i2c/i2c.h"
/*
* Create and realize an AT24C EEPROM device on the heap.
* @bus: I2C bus to put it on
* @address: I2C address of the EEPROM slave when put on a bus
* @rom_size: size of the EEPROM
*
* Create the device state structure, initialize it, put it on the specified
* @bus, and drop the reference to it (the device is realized).
*/
I2CSlave *at24c_eeprom_init(I2CBus *bus, uint8_t address, uint32_t rom_size);
#endif