Lines Matching +full:page +full:- +full:offset

1 // SPDX-License-Identifier: GPL-2.0-or-later
37 * Calculate the closest absolute offset between commanded vout value
44 int offset; in stpddc60_get_offset() local
47 v = 250 + (vout - 1) * 5; /* Convert VID to mv */ in stpddc60_get_offset()
53 offset = DIV_ROUND_CLOSEST(abs(l - v), 50); in stpddc60_get_offset()
55 if (offset > 0) in stpddc60_get_offset()
56 offset--; in stpddc60_get_offset()
58 return clamp_val(offset, 0, 7); in stpddc60_get_offset()
70 d = e - fixed; in stpddc60_adjust_linear()
75 m >>= -d; in stpddc60_adjust_linear()
85 static int stpddc60_read_byte_data(struct i2c_client *client, int page, int reg) in stpddc60_read_byte_data() argument
89 if (page > 0) in stpddc60_read_byte_data()
90 return -ENXIO; in stpddc60_read_byte_data()
97 ret = -ENODATA; in stpddc60_read_byte_data()
109 static int stpddc60_read_word_data(struct i2c_client *client, int page, in stpddc60_read_word_data() argument
114 if (page > 0) in stpddc60_read_word_data()
115 return -ENXIO; in stpddc60_read_word_data()
119 ret = pmbus_read_word_data(client, page, phase, in stpddc60_read_word_data()
127 ret = pmbus_read_word_data(client, page, phase, reg); in stpddc60_read_word_data()
133 ret = -ENODATA; in stpddc60_read_word_data()
141 * The vout under- and over-voltage limits are set as an offset relative to
145 static int stpddc60_write_word_data(struct i2c_client *client, int page, in stpddc60_write_word_data() argument
149 u8 offset; in stpddc60_write_word_data() local
151 if (page > 0) in stpddc60_write_word_data()
152 return -ENXIO; in stpddc60_write_word_data()
156 ret = pmbus_read_word_data(client, page, 0xff, in stpddc60_write_word_data()
160 offset = stpddc60_get_offset(ret, word, true); in stpddc60_write_word_data()
161 ret = pmbus_write_byte_data(client, page, in stpddc60_write_word_data()
163 offset); in stpddc60_write_word_data()
166 ret = pmbus_read_word_data(client, page, 0xff, in stpddc60_write_word_data()
170 offset = stpddc60_get_offset(ret, word, false); in stpddc60_write_word_data()
171 ret = pmbus_write_byte_data(client, page, in stpddc60_write_word_data()
173 offset); in stpddc60_write_word_data()
182 ret = pmbus_read_word_data(client, page, 0xff, reg); in stpddc60_write_word_data()
186 ret = pmbus_write_word_data(client, page, reg, word); in stpddc60_write_word_data()
189 ret = -ENODATA; in stpddc60_write_word_data()
203 if (!i2c_check_functionality(client->adapter, in stpddc60_probe()
206 return -ENODEV; in stpddc60_probe()
210 dev_err(&client->dev, "Failed to read Manufacturer Model\n"); in stpddc60_probe()
213 for (mid = stpddc60_id; mid->name[0]; mid++) { in stpddc60_probe()
214 if (!strncasecmp(mid->name, device_id, strlen(mid->name))) in stpddc60_probe()
217 if (!mid->name[0]) { in stpddc60_probe()
218 dev_err(&client->dev, "Unsupported device\n"); in stpddc60_probe()
219 return -ENODEV; in stpddc60_probe()
222 info->read_byte_data = stpddc60_read_byte_data; in stpddc60_probe()
223 info->read_word_data = stpddc60_read_word_data; in stpddc60_probe()
224 info->write_word_data = stpddc60_write_word_data; in stpddc60_probe()