Allows users to specify binary data to initialize an EEPROM, allowing users to emulate data programmed at manufacturing time. - Added init_rom and init_rom_size attributes to TYPE_AT24C_EE - Added at24c_eeprom_init_rom helper function to initialize attributes - If -drive property is provided, it overrides init_rom data Signed-off-by: Peter Delevoryas <peter@pjd.dev> Reviewed-by: Joel Stanley <joel@jms.id.au> Reviewed-by: Corey Minyard <cminyard@mvista.com> Reviewed-by: Cédric Le Goater <clg@kaod.org> Tested-by: Ninad Palsule <ninadpalsule@us.ibm.com> Link: https://lore.kernel.org/r/20230128060543.95582-4-peter@pjd.dev Signed-off-by: Cédric Le Goater <clg@kaod.org>
		
			
				
	
	
		
			40 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			40 lines
		
	
	
		
			1.3 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
/*
 | 
						|
 * 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);
 | 
						|
 | 
						|
 | 
						|
/*
 | 
						|
 * Create and realize an AT24C EEPROM device on the heap with initial data.
 | 
						|
 * @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
 | 
						|
 * @init_rom: Array of bytes to initialize EEPROM memory with
 | 
						|
 * @init_rom_size: Size of @init_rom, must be less than or equal to @rom_size
 | 
						|
 *
 | 
						|
 * Create the device state structure, initialize it, put it on the specified
 | 
						|
 * @bus, and drop the reference to it (the device is realized). Copies the data
 | 
						|
 * from @init_rom to the beginning of the EEPROM memory buffer.
 | 
						|
 */
 | 
						|
I2CSlave *at24c_eeprom_init_rom(I2CBus *bus, uint8_t address, uint32_t rom_size,
 | 
						|
                                const uint8_t *init_rom, uint32_t init_rom_size);
 | 
						|
 | 
						|
#endif
 |