MCPcopy Create free account
hub / github.com/coreboot/coreboot / rcd_readd

Function rcd_readd

src/device/dram/rcd.c:98–127  ·  view source on GitHub ↗

Reads a register storing its value in the host's byte order. Returns non-zero on success. */

Source from the content-addressed store, hash-verified

96
97/* Reads a register storing its value in the host's byte order. Returns non-zero on success. */
98static int rcd_readd(unsigned int bus, uint8_t slave, uint8_t reg, uint32_t *data)
99{
100 struct i2c_msg seg[2];
101 struct rcd_i2c_cmd cmd = {
102 .cmd = RCD_CMD_BLOCK | RCD_CMD_RD_DWORD,
103 .bytes = RCD_CMD_BYTES,
104 .reg_l = reg
105 };
106 struct rcd_i2c_rsp rsp = { 0xaa, 0x55 };
107
108 seg[0].flags = 0;
109 seg[0].slave = slave;
110 seg[0].buf = (uint8_t *)&cmd;
111 seg[0].len = cmd.bytes + 2; /* + .cmd and .bytes fields */
112
113 i2c_transfer(bus, seg, 1);
114
115 seg[0].len = 1; /* Send just the command again */
116 seg[1].flags = I2C_M_RD;
117 seg[1].slave = slave;
118 seg[1].buf = (uint8_t *)&rsp;
119 seg[1].len = RCD_RSP_BYTES + 1; /* + .bytes field */
120
121 i2c_transfer(bus, seg, ARRAY_SIZE(seg));
122
123 /* Data is sent MSB to LSB, i.e. higher registers to lower. */
124 *data = be32toh(rsp.ddata);
125
126 return rsp.status == RCD_STS_SUCCESS;
127}
128
129static int rcd_writed(unsigned int bus, uint8_t slave, uint8_t reg, uint32_t data)
130{

Callers 1

dump_rcdFunction · 0.85

Calls 1

i2c_transferFunction · 0.85

Tested by

no test coverage detected