blob: c63cc651c04f959049493d0cb43c8b89140f0a5f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
/* Copyright 2021 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
/**
* @file
*
* @brief Backend API for BB retimer emulator
*/
#ifndef __EMUL_BB_RETIMER_H
#define __EMUL_BB_RETIMER_H
#include <emul.h>
#include <drivers/i2c.h>
#include <drivers/i2c_emul.h>
/**
* @brief BB retimer emulator backend API
* @defgroup bb_emul BB retimer emulator
* @{
*
* BB retimer emulator supports access to all its registers using I2C messages.
* It supports not four bytes writes by padding zeros (the same as real
* device), but show warning in that case.
* Application may alter emulator state:
*
* - define a Device Tree overlay file to set default vendor ID and which
* inadvisable driver behaviour should be treated as errors
* - call @ref bb_emul_set_reg and @ref bb_emul_get_reg to set and get value
* of BB retimers registers
* - call bb_emul_set_err_* to change emulator behaviour on inadvisable driver
* behaviour
* - call functions from emul_common_i2c.h to setup custom handlers for I2C
* messages
*/
/**
* @brief Get pointer to BB retimer emulator using device tree order number.
*
* @param ord Device tree order number obtained from DT_DEP_ORD macro
*
* @return Pointer to BB retimer emulator
*/
struct i2c_emul *bb_emul_get(int ord);
/**
* @brief Set value of given register of BB retimer
*
* @param emul Pointer to BB retimer emulator
* @param reg Register address which value will be changed
* @param val New value of the register
*/
void bb_emul_set_reg(struct i2c_emul *emul, int reg, uint32_t val);
/**
* @brief Get value of given register of BB retimer
*
* @param emul Pointer to BB retimer emulator
* @param reg Register address
*
* @return Value of the register
*/
uint32_t bb_emul_get_reg(struct i2c_emul *emul, int reg);
/**
* @brief Set if error should be generated when read only register is being
* written
*
* @param emul Pointer to BB retimer emulator
* @param set Check for this error
*/
void bb_emul_set_err_on_ro_write(struct i2c_emul *emul, bool set);
/**
* @brief Set if error should be generated when reserved bits of register are
* not set to 0 on write I2C message
*
* @param emul Pointer to BB retimer emulator
* @param set Check for this error
*/
void bb_emul_set_err_on_rsvd_write(struct i2c_emul *emul, bool set);
/**
* @}
*/
#endif /* __EMUL_BB_RETIMER */
|