OpenBIC
OpenSource Bridge-IC
eeprom.h
Go to the documentation of this file.
1/*
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef EEPROM_H
18#define EEPROM_H
19
20#include <stdbool.h>
21#include <stdint.h>
22#include "plat_def.h"
23
24#ifndef EEPROM_WRITE_SIZE
25#define EEPROM_WRITE_SIZE 0x20
26#endif
27
28// define offset, size and order for EEPROM write/read
29#define FRU_START 0x0000 // start at 0x000
30#define FRU_SIZE 0x0400 // size 1KB
31
32#define SEL_START 0x0400
33#define SEL_SIZE 0x0400
34
35#define GUID_START 0x0800
36#define GUID_SIZE 0x0100
37
38#define BIC_CONFIG_START 0x0900
39#define BIC_CONFIG_SIZE 0x0100
40// next start should be 0x0A00
41
42typedef struct _EEPROM_CFG_ {
43 uint8_t dev_type;
44 uint8_t dev_id;
45 uint8_t port;
46 uint8_t target_addr;
47 uint8_t access;
48 uint16_t start_offset;
49 uint16_t max_size;
51 uint8_t mux_addr;
52 uint8_t mux_channel;
53 struct k_mutex *bus_mutex;
55
56typedef struct _EEPROM_ENTRY_ {
58 uint16_t offset;
59 uint16_t data_len;
62
63bool eeprom_write(EEPROM_ENTRY *entry);
64bool eeprom_read(EEPROM_ENTRY *entry);
65
66#endif
#define EEPROM_WRITE_SIZE
Definition: eeprom.h:25
struct _EEPROM_CFG_ EEPROM_CFG
bool eeprom_write(EEPROM_ENTRY *entry)
Definition: eeprom.c:58
struct _EEPROM_ENTRY_ EEPROM_ENTRY
bool eeprom_read(EEPROM_ENTRY *entry)
Definition: eeprom.c:108
Definition: eeprom.h:42
uint8_t dev_id
Definition: eeprom.h:44
uint8_t access
Definition: eeprom.h:47
struct k_mutex * bus_mutex
Definition: eeprom.h:53
uint16_t max_size
Definition: eeprom.h:49
uint16_t start_offset
Definition: eeprom.h:48
uint8_t dev_type
Definition: eeprom.h:43
bool mux_present
Definition: eeprom.h:50
uint8_t port
Definition: eeprom.h:45
uint8_t mux_addr
Definition: eeprom.h:51
uint8_t mux_channel
Definition: eeprom.h:52
uint8_t target_addr
Definition: eeprom.h:46
Definition: eeprom.h:56
uint16_t data_len
Definition: eeprom.h:59
EEPROM_CFG config
Definition: eeprom.h:57
uint8_t data[EEPROM_WRITE_SIZE]
Definition: eeprom.h:60
uint16_t offset
Definition: eeprom.h:58