xref: /openbmc/qemu/include/hw/nvram/eeprom_at24c.h (revision 2f95279a)
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * SPDX-License-Identifier: GPL-2.0-only
5  */
6 
7 #ifndef EEPROM_AT24C_H
8 #define EEPROM_AT24C_H
9 
10 #include "hw/i2c/i2c.h"
11 
12 /*
13  * Create and realize an AT24C EEPROM device on the heap.
14  * @bus: I2C bus to put it on
15  * @address: I2C address of the EEPROM slave when put on a bus
16  * @rom_size: size of the EEPROM
17  *
18  * Create the device state structure, initialize it, put it on the specified
19  * @bus, and drop the reference to it (the device is realized).
20  */
21 I2CSlave *at24c_eeprom_init(I2CBus *bus, uint8_t address, uint32_t rom_size);
22 
23 
24 /*
25  * Create and realize an AT24C EEPROM device on the heap with initial data.
26  * @bus: I2C bus to put it on
27  * @address: I2C address of the EEPROM slave when put on a bus
28  * @rom_size: size of the EEPROM
29  * @init_rom: Array of bytes to initialize EEPROM memory with
30  * @init_rom_size: Size of @init_rom, must be less than or equal to @rom_size
31  *
32  * Create the device state structure, initialize it, put it on the specified
33  * @bus, and drop the reference to it (the device is realized). Copies the data
34  * from @init_rom to the beginning of the EEPROM memory buffer.
35  */
36 I2CSlave *at24c_eeprom_init_rom(I2CBus *bus, uint8_t address, uint32_t rom_size,
37                                 const uint8_t *init_rom, uint32_t init_rom_size);
38 
39 #endif
40