• Home
  • Raw
  • Download

Lines Matching refs:st

111 static int ad5791_spi_write(struct ad5791_state *st, u8 addr, u32 val)  in ad5791_spi_write()  argument
113 st->data[0].d32 = cpu_to_be32(AD5791_CMD_WRITE | in ad5791_spi_write()
117 return spi_write(st->spi, &st->data[0].d8[1], 3); in ad5791_spi_write()
120 static int ad5791_spi_read(struct ad5791_state *st, u8 addr, u32 *val) in ad5791_spi_read() argument
125 .tx_buf = &st->data[0].d8[1], in ad5791_spi_read()
130 .tx_buf = &st->data[1].d8[1], in ad5791_spi_read()
131 .rx_buf = &st->data[2].d8[1], in ad5791_spi_read()
137 st->data[0].d32 = cpu_to_be32(AD5791_CMD_READ | in ad5791_spi_read()
139 st->data[1].d32 = cpu_to_be32(AD5791_ADDR(AD5791_ADDR_NOOP)); in ad5791_spi_read()
141 ret = spi_sync_transfer(st->spi, xfers, ARRAY_SIZE(xfers)); in ad5791_spi_read()
143 *val = be32_to_cpu(st->data[2].d32); in ad5791_spi_read()
156 struct ad5791_state *st = iio_priv(indio_dev); in ad5791_get_powerdown_mode() local
158 return st->pwr_down_mode; in ad5791_get_powerdown_mode()
164 struct ad5791_state *st = iio_priv(indio_dev); in ad5791_set_powerdown_mode() local
166 st->pwr_down_mode = mode; in ad5791_set_powerdown_mode()
181 struct ad5791_state *st = iio_priv(indio_dev); in ad5791_read_dac_powerdown() local
183 return sprintf(buf, "%d\n", st->pwr_down); in ad5791_read_dac_powerdown()
192 struct ad5791_state *st = iio_priv(indio_dev); in ad5791_write_dac_powerdown() local
199 st->ctrl &= ~(AD5791_CTRL_OPGND | AD5791_CTRL_DACTRI); in ad5791_write_dac_powerdown()
201 if (st->pwr_down_mode == AD5791_DAC_PWRDN_6K) in ad5791_write_dac_powerdown()
202 st->ctrl |= AD5791_CTRL_OPGND; in ad5791_write_dac_powerdown()
203 else if (st->pwr_down_mode == AD5791_DAC_PWRDN_3STATE) in ad5791_write_dac_powerdown()
204 st->ctrl |= AD5791_CTRL_DACTRI; in ad5791_write_dac_powerdown()
206 st->pwr_down = pwr_down; in ad5791_write_dac_powerdown()
208 ret = ad5791_spi_write(st, AD5791_ADDR_CTRL, st->ctrl); in ad5791_write_dac_powerdown()
255 struct ad5791_state *st = iio_priv(indio_dev); in ad5791_read_raw() local
261 ret = ad5791_spi_read(st, chan->address, val); in ad5791_read_raw()
268 *val = st->vref_mv; in ad5791_read_raw()
272 val64 = (((u64)st->vref_neg_mv) << chan->scan_type.realbits); in ad5791_read_raw()
273 do_div(val64, st->vref_mv); in ad5791_read_raw()
326 struct ad5791_state *st = iio_priv(indio_dev); in ad5791_write_raw() local
333 return ad5791_spi_write(st, chan->address, val); in ad5791_write_raw()
350 struct ad5791_state *st; in ad5791_probe() local
353 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); in ad5791_probe()
356 st = iio_priv(indio_dev); in ad5791_probe()
357 st->reg_vdd = devm_regulator_get(&spi->dev, "vdd"); in ad5791_probe()
358 if (!IS_ERR(st->reg_vdd)) { in ad5791_probe()
359 ret = regulator_enable(st->reg_vdd); in ad5791_probe()
363 ret = regulator_get_voltage(st->reg_vdd); in ad5791_probe()
370 st->reg_vss = devm_regulator_get(&spi->dev, "vss"); in ad5791_probe()
371 if (!IS_ERR(st->reg_vss)) { in ad5791_probe()
372 ret = regulator_enable(st->reg_vss); in ad5791_probe()
376 ret = regulator_get_voltage(st->reg_vss); in ad5791_probe()
383 st->pwr_down = true; in ad5791_probe()
384 st->spi = spi; in ad5791_probe()
386 if (!IS_ERR(st->reg_vss) && !IS_ERR(st->reg_vdd)) { in ad5791_probe()
387 st->vref_mv = (pos_voltage_uv + neg_voltage_uv) / 1000; in ad5791_probe()
388 st->vref_neg_mv = neg_voltage_uv / 1000; in ad5791_probe()
390 st->vref_mv = pdata->vref_pos_mv + pdata->vref_neg_mv; in ad5791_probe()
391 st->vref_neg_mv = pdata->vref_neg_mv; in ad5791_probe()
396 ret = ad5791_spi_write(st, AD5791_ADDR_SW_CTRL, AD5791_SWCTRL_RESET); in ad5791_probe()
400 st->chip_info = &ad5791_chip_info_tbl[spi_get_device_id(spi) in ad5791_probe()
404 st->ctrl = AD5761_CTRL_LINCOMP(st->chip_info->get_lin_comp(st->vref_mv)) in ad5791_probe()
408 ret = ad5791_spi_write(st, AD5791_ADDR_CTRL, st->ctrl | in ad5791_probe()
420 indio_dev->name = spi_get_device_id(st->spi)->name; in ad5791_probe()
428 if (!IS_ERR(st->reg_vss)) in ad5791_probe()
429 regulator_disable(st->reg_vss); in ad5791_probe()
431 if (!IS_ERR(st->reg_vdd)) in ad5791_probe()
432 regulator_disable(st->reg_vdd); in ad5791_probe()
439 struct ad5791_state *st = iio_priv(indio_dev); in ad5791_remove() local
442 if (!IS_ERR(st->reg_vdd)) in ad5791_remove()
443 regulator_disable(st->reg_vdd); in ad5791_remove()
445 if (!IS_ERR(st->reg_vss)) in ad5791_remove()
446 regulator_disable(st->reg_vss); in ad5791_remove()