Lines Matching +full:mcp4131 +full:- +full:502
1 // SPDX-License-Identifier: GPL-2.0-only
11 * mcp4131 1 129 5, 10, 50, 100
170 int address = chan->channel; in mcp4131_read_raw()
174 mutex_lock(&data->lock); in mcp4131_read_raw()
176 data->buf[0] = (address << MCP4131_WIPER_SHIFT) | MCP4131_READ; in mcp4131_read_raw()
177 data->buf[1] = 0; in mcp4131_read_raw()
179 err = mcp4131_read(data->spi, data->buf, 2); in mcp4131_read_raw()
181 mutex_unlock(&data->lock); in mcp4131_read_raw()
186 if (!MCP4131_CMDERR(data->buf)) { in mcp4131_read_raw()
187 mutex_unlock(&data->lock); in mcp4131_read_raw()
188 return -EIO; in mcp4131_read_raw()
191 *val = MCP4131_RAW(data->buf); in mcp4131_read_raw()
192 mutex_unlock(&data->lock); in mcp4131_read_raw()
197 *val = 1000 * data->cfg->kohms; in mcp4131_read_raw()
198 *val2 = data->cfg->max_pos; in mcp4131_read_raw()
202 return -EINVAL; in mcp4131_read_raw()
211 int address = chan->channel << MCP4131_WIPER_SHIFT; in mcp4131_write_raw()
215 if (val > data->cfg->max_pos || val < 0) in mcp4131_write_raw()
216 return -EINVAL; in mcp4131_write_raw()
220 return -EINVAL; in mcp4131_write_raw()
223 mutex_lock(&data->lock); in mcp4131_write_raw()
225 data->buf[0] = address << MCP4131_WIPER_SHIFT; in mcp4131_write_raw()
226 data->buf[0] |= MCP4131_WRITE | (val >> 8); in mcp4131_write_raw()
227 data->buf[1] = val & 0xFF; /* 8 bits here */ in mcp4131_write_raw()
229 err = spi_write(data->spi, data->buf, 2); in mcp4131_write_raw()
230 mutex_unlock(&data->lock); in mcp4131_write_raw()
243 struct device *dev = &spi->dev; in mcp4131_probe()
250 return -ENOMEM; in mcp4131_probe()
254 data->spi = spi; in mcp4131_probe()
255 data->cfg = device_get_match_data(&spi->dev); in mcp4131_probe()
256 if (!data->cfg) { in mcp4131_probe()
257 devid = spi_get_device_id(spi)->driver_data; in mcp4131_probe()
258 data->cfg = &mcp4131_cfg[devid]; in mcp4131_probe()
261 mutex_init(&data->lock); in mcp4131_probe()
263 indio_dev->info = &mcp4131_info; in mcp4131_probe()
264 indio_dev->channels = mcp4131_channels; in mcp4131_probe()
265 indio_dev->num_channels = data->cfg->wipers; in mcp4131_probe()
266 indio_dev->name = spi_get_device_id(spi)->name; in mcp4131_probe()
270 dev_info(&spi->dev, "Unable to register %s\n", indio_dev->name); in mcp4131_probe()
278 { .compatible = "microchip,mcp4131-502",
280 { .compatible = "microchip,mcp4131-103",
282 { .compatible = "microchip,mcp4131-503",
284 { .compatible = "microchip,mcp4131-104",
286 { .compatible = "microchip,mcp4132-502",
288 { .compatible = "microchip,mcp4132-103",
290 { .compatible = "microchip,mcp4132-503",
292 { .compatible = "microchip,mcp4132-104",
294 { .compatible = "microchip,mcp4141-502",
296 { .compatible = "microchip,mcp4141-103",
298 { .compatible = "microchip,mcp4141-503",
300 { .compatible = "microchip,mcp4141-104",
302 { .compatible = "microchip,mcp4142-502",
304 { .compatible = "microchip,mcp4142-103",
306 { .compatible = "microchip,mcp4142-503",
308 { .compatible = "microchip,mcp4142-104",
310 { .compatible = "microchip,mcp4151-502",
312 { .compatible = "microchip,mcp4151-103",
314 { .compatible = "microchip,mcp4151-503",
316 { .compatible = "microchip,mcp4151-104",
318 { .compatible = "microchip,mcp4152-502",
320 { .compatible = "microchip,mcp4152-103",
322 { .compatible = "microchip,mcp4152-503",
324 { .compatible = "microchip,mcp4152-104",
326 { .compatible = "microchip,mcp4161-502",
328 { .compatible = "microchip,mcp4161-103",
330 { .compatible = "microchip,mcp4161-503",
332 { .compatible = "microchip,mcp4161-104",
334 { .compatible = "microchip,mcp4162-502",
336 { .compatible = "microchip,mcp4162-103",
338 { .compatible = "microchip,mcp4162-503",
340 { .compatible = "microchip,mcp4162-104",
342 { .compatible = "microchip,mcp4231-502",
344 { .compatible = "microchip,mcp4231-103",
346 { .compatible = "microchip,mcp4231-503",
348 { .compatible = "microchip,mcp4231-104",
350 { .compatible = "microchip,mcp4232-502",
352 { .compatible = "microchip,mcp4232-103",
354 { .compatible = "microchip,mcp4232-503",
356 { .compatible = "microchip,mcp4232-104",
358 { .compatible = "microchip,mcp4241-502",
360 { .compatible = "microchip,mcp4241-103",
362 { .compatible = "microchip,mcp4241-503",
364 { .compatible = "microchip,mcp4241-104",
366 { .compatible = "microchip,mcp4242-502",
368 { .compatible = "microchip,mcp4242-103",
370 { .compatible = "microchip,mcp4242-503",
372 { .compatible = "microchip,mcp4242-104",
374 { .compatible = "microchip,mcp4251-502",
376 { .compatible = "microchip,mcp4251-103",
378 { .compatible = "microchip,mcp4251-503",
380 { .compatible = "microchip,mcp4251-104",
382 { .compatible = "microchip,mcp4252-502",
384 { .compatible = "microchip,mcp4252-103",
386 { .compatible = "microchip,mcp4252-503",
388 { .compatible = "microchip,mcp4252-104",
390 { .compatible = "microchip,mcp4261-502",
392 { .compatible = "microchip,mcp4261-103",
394 { .compatible = "microchip,mcp4261-503",
396 { .compatible = "microchip,mcp4261-104",
398 { .compatible = "microchip,mcp4262-502",
400 { .compatible = "microchip,mcp4262-103",
402 { .compatible = "microchip,mcp4262-503",
404 { .compatible = "microchip,mcp4262-104",
411 { "mcp4131-502", MCP413x_502 },
412 { "mcp4131-103", MCP413x_103 },
413 { "mcp4131-503", MCP413x_503 },
414 { "mcp4131-104", MCP413x_104 },
415 { "mcp4132-502", MCP413x_502 },
416 { "mcp4132-103", MCP413x_103 },
417 { "mcp4132-503", MCP413x_503 },
418 { "mcp4132-104", MCP413x_104 },
419 { "mcp4141-502", MCP414x_502 },
420 { "mcp4141-103", MCP414x_103 },
421 { "mcp4141-503", MCP414x_503 },
422 { "mcp4141-104", MCP414x_104 },
423 { "mcp4142-502", MCP414x_502 },
424 { "mcp4142-103", MCP414x_103 },
425 { "mcp4142-503", MCP414x_503 },
426 { "mcp4142-104", MCP414x_104 },
427 { "mcp4151-502", MCP415x_502 },
428 { "mcp4151-103", MCP415x_103 },
429 { "mcp4151-503", MCP415x_503 },
430 { "mcp4151-104", MCP415x_104 },
431 { "mcp4152-502", MCP415x_502 },
432 { "mcp4152-103", MCP415x_103 },
433 { "mcp4152-503", MCP415x_503 },
434 { "mcp4152-104", MCP415x_104 },
435 { "mcp4161-502", MCP416x_502 },
436 { "mcp4161-103", MCP416x_103 },
437 { "mcp4161-503", MCP416x_503 },
438 { "mcp4161-104", MCP416x_104 },
439 { "mcp4162-502", MCP416x_502 },
440 { "mcp4162-103", MCP416x_103 },
441 { "mcp4162-503", MCP416x_503 },
442 { "mcp4162-104", MCP416x_104 },
443 { "mcp4231-502", MCP423x_502 },
444 { "mcp4231-103", MCP423x_103 },
445 { "mcp4231-503", MCP423x_503 },
446 { "mcp4231-104", MCP423x_104 },
447 { "mcp4232-502", MCP423x_502 },
448 { "mcp4232-103", MCP423x_103 },
449 { "mcp4232-503", MCP423x_503 },
450 { "mcp4232-104", MCP423x_104 },
451 { "mcp4241-502", MCP424x_502 },
452 { "mcp4241-103", MCP424x_103 },
453 { "mcp4241-503", MCP424x_503 },
454 { "mcp4241-104", MCP424x_104 },
455 { "mcp4242-502", MCP424x_502 },
456 { "mcp4242-103", MCP424x_103 },
457 { "mcp4242-503", MCP424x_503 },
458 { "mcp4242-104", MCP424x_104 },
459 { "mcp4251-502", MCP425x_502 },
460 { "mcp4251-103", MCP425x_103 },
461 { "mcp4251-503", MCP425x_503 },
462 { "mcp4251-104", MCP425x_104 },
463 { "mcp4252-502", MCP425x_502 },
464 { "mcp4252-103", MCP425x_103 },
465 { "mcp4252-503", MCP425x_503 },
466 { "mcp4252-104", MCP425x_104 },
467 { "mcp4261-502", MCP426x_502 },
468 { "mcp4261-103", MCP426x_103 },
469 { "mcp4261-503", MCP426x_503 },
470 { "mcp4261-104", MCP426x_104 },
471 { "mcp4262-502", MCP426x_502 },
472 { "mcp4262-103", MCP426x_103 },
473 { "mcp4262-503", MCP426x_503 },
474 { "mcp4262-104", MCP426x_104 },
481 .name = "mcp4131",
491 MODULE_DESCRIPTION("MCP4131 digital potentiometer");