Lines Matching +full:chip +full:- +full:id

4  * SPDX-License-Identifier: Apache-2.0
25 struct ak8975_data *drv_data = dev->data; in ak8975_sample_fetch()
26 const struct ak8975_config *drv_config = dev->config; in ak8975_sample_fetch()
31 if (i2c_reg_write_byte_dt(&drv_config->i2c, AK8975_REG_CNTL, AK8975_MODE_MEASURE) < 0) { in ak8975_sample_fetch()
33 return -EIO; in ak8975_sample_fetch()
38 if (i2c_burst_read_dt(&drv_config->i2c, AK8975_REG_DATA_START, buf, 6) < 0) { in ak8975_sample_fetch()
40 return -EIO; in ak8975_sample_fetch()
43 drv_data->x_sample = sys_le16_to_cpu(buf[0] | (buf[1] << 8)); in ak8975_sample_fetch()
44 drv_data->y_sample = sys_le16_to_cpu(buf[2] | (buf[3] << 8)); in ak8975_sample_fetch()
45 drv_data->z_sample = sys_le16_to_cpu(buf[4] | (buf[5] << 8)); in ak8975_sample_fetch()
57 val->val1 = conv_val / 1000000; in ak8975_convert()
58 val->val2 = conv_val % 1000000; in ak8975_convert()
65 struct ak8975_data *drv_data = dev->data; in ak8975_channel_get()
73 ak8975_convert(val, drv_data->x_sample, drv_data->x_adj); in ak8975_channel_get()
74 ak8975_convert(val + 1, drv_data->y_sample, drv_data->y_adj); in ak8975_channel_get()
75 ak8975_convert(val + 2, drv_data->z_sample, drv_data->z_adj); in ak8975_channel_get()
77 ak8975_convert(val, drv_data->x_sample, drv_data->x_adj); in ak8975_channel_get()
79 ak8975_convert(val, drv_data->y_sample, drv_data->y_adj); in ak8975_channel_get()
81 ak8975_convert(val, drv_data->z_sample, drv_data->z_adj); in ak8975_channel_get()
83 return -ENOTSUP; in ak8975_channel_get()
96 struct ak8975_data *drv_data = dev->data; in ak8975_read_adjustment_data()
97 const struct ak8975_config *drv_config = dev->config; in ak8975_read_adjustment_data()
100 if (i2c_reg_write_byte_dt(&drv_config->i2c, AK8975_REG_CNTL, AK8975_MODE_FUSE_ACCESS) < 0) { in ak8975_read_adjustment_data()
101 LOG_ERR("Failed to set chip in fuse access mode."); in ak8975_read_adjustment_data()
102 return -EIO; in ak8975_read_adjustment_data()
105 if (i2c_burst_read_dt(&drv_config->i2c, AK8975_REG_ADJ_DATA_START, buf, 3) < 0) { in ak8975_read_adjustment_data()
107 return -EIO; in ak8975_read_adjustment_data()
110 drv_data->x_adj = buf[0]; in ak8975_read_adjustment_data()
111 drv_data->y_adj = buf[1]; in ak8975_read_adjustment_data()
112 drv_data->z_adj = buf[2]; in ak8975_read_adjustment_data()
119 const struct ak8975_config *drv_config = dev->config; in ak8975_init()
120 uint8_t id; in ak8975_init() local
122 if (!device_is_ready(drv_config->i2c.bus)) { in ak8975_init()
124 return -ENODEV; in ak8975_init()
127 /* check chip ID */ in ak8975_init()
128 if (i2c_reg_read_byte_dt(&drv_config->i2c, AK8975_REG_CHIP_ID, &id) < 0) { in ak8975_init()
129 LOG_ERR("Failed to read chip ID."); in ak8975_init()
130 return -EIO; in ak8975_init()
133 if (id != AK8975_CHIP_ID) { in ak8975_init()
134 LOG_ERR("Invalid chip ID."); in ak8975_init()
135 return -EINVAL; in ak8975_init()
139 return -EIO; in ak8975_init()