Lines Matching +full:address +full:- +full:address +full:- +full:data

1 // SPDX-License-Identifier: GPL-2.0+
6 #include <linux/fsi-occ.h>
18 /* OCB (on-chip control bridge - interface to OCC) registers */
23 /* OCC SRAM address space */
36 static int p8_i2c_occ_getscom(struct i2c_client *client, u32 address, u8 *data) in p8_i2c_occ_getscom() argument
43 address <<= 1; in p8_i2c_occ_getscom()
45 msgs[0].addr = client->addr; in p8_i2c_occ_getscom()
46 msgs[0].flags = client->flags & I2C_M_TEN; in p8_i2c_occ_getscom()
48 /* address is a scom address; bus-endian */ in p8_i2c_occ_getscom()
49 msgs[0].buf = (char *)&address; in p8_i2c_occ_getscom()
51 /* data from OCC is big-endian */ in p8_i2c_occ_getscom()
52 msgs[1].addr = client->addr; in p8_i2c_occ_getscom()
53 msgs[1].flags = (client->flags & I2C_M_TEN) | I2C_M_RD; in p8_i2c_occ_getscom()
57 rc = i2c_transfer(client->adapter, msgs, 2); in p8_i2c_occ_getscom()
61 *(u64 *)data = be64_to_cpu(buf); in p8_i2c_occ_getscom()
66 static int p8_i2c_occ_putscom(struct i2c_client *client, u32 address, u8 *data) in p8_i2c_occ_putscom() argument
72 address <<= 1; in p8_i2c_occ_putscom()
74 /* address is bus-endian; data passed through from user as-is */ in p8_i2c_occ_putscom()
75 buf[0] = address; in p8_i2c_occ_putscom()
76 memcpy(&buf[1], &data[4], sizeof(u32)); in p8_i2c_occ_putscom()
77 memcpy(&buf[2], data, sizeof(u32)); in p8_i2c_occ_putscom()
83 return -EIO; in p8_i2c_occ_putscom()
88 static int p8_i2c_occ_putscom_u32(struct i2c_client *client, u32 address, in p8_i2c_occ_putscom_u32() argument
96 return p8_i2c_occ_putscom(client, address, buf); in p8_i2c_occ_putscom_u32()
99 static int p8_i2c_occ_putscom_be(struct i2c_client *client, u32 address, in p8_i2c_occ_putscom_be() argument
100 u8 *data, size_t len) in p8_i2c_occ_putscom_be() argument
104 memcpy(&data0, data, min_t(size_t, len, 4)); in p8_i2c_occ_putscom_be()
106 len -= 4; in p8_i2c_occ_putscom_be()
107 memcpy(&data1, data + 4, min_t(size_t, len, 4)); in p8_i2c_occ_putscom_be()
110 return p8_i2c_occ_putscom_u32(client, address, be32_to_cpu(data0), in p8_i2c_occ_putscom_be()
123 struct i2c_client *client = ctx->client; in p8_i2c_occ_send_cmd()
128 /* set sram address for command */ in p8_i2c_occ_send_cmd()
133 /* write command (expected to already be BE), we need bus-endian... */ in p8_i2c_occ_send_cmd()
144 /* set sram address for response */ in p8_i2c_occ_send_cmd()
155 if (or->return_status == OCC_RESP_CMD_IN_PRG) { in p8_i2c_occ_send_cmd()
156 rc = -EALREADY; in p8_i2c_occ_send_cmd()
167 switch (or->return_status) { in p8_i2c_occ_send_cmd()
169 rc = -ETIMEDOUT; in p8_i2c_occ_send_cmd()
178 rc = -EINVAL; in p8_i2c_occ_send_cmd()
187 rc = -EREMOTEIO; in p8_i2c_occ_send_cmd()
190 rc = -EPROTO; in p8_i2c_occ_send_cmd()
196 data_length = get_unaligned_be16(&or->data_length); in p8_i2c_occ_send_cmd()
198 return -EMSGSIZE; in p8_i2c_occ_send_cmd()
200 /* fetch the rest of the response data */ in p8_i2c_occ_send_cmd()
213 struct p8_i2c_occ *ctx = devm_kzalloc(&client->dev, sizeof(*ctx), in p8_i2c_occ_probe()
216 return -ENOMEM; in p8_i2c_occ_probe()
218 ctx->client = client; in p8_i2c_occ_probe()
219 occ = &ctx->occ; in p8_i2c_occ_probe()
220 occ->bus_dev = &client->dev; in p8_i2c_occ_probe()
221 dev_set_drvdata(&client->dev, occ); in p8_i2c_occ_probe()
223 occ->powr_sample_time_us = 250; in p8_i2c_occ_probe()
224 occ->poll_cmd_data = 0x10; /* P8 OCC poll data */ in p8_i2c_occ_probe()
225 occ->send_cmd = p8_i2c_occ_send_cmd; in p8_i2c_occ_probe()
232 struct occ *occ = dev_get_drvdata(&client->dev); in p8_i2c_occ_remove()
238 { .compatible = "ibm,p8-occ-hwmon" },
245 .name = "occ-hwmon",