Lines Matching refs:priv

75 static void rcar_gyroadc_hw_init(struct rcar_gyroadc *priv)
77 const unsigned long clk_mhz = clk_get_rate(priv->clk) / 1000000;
79 (priv->mode == RCAR_GYROADC_MODE_SELECT_1_MB88101A) ? 10 : 5;
91 writel(0, priv->regs + RCAR_GYROADC_START_STOP);
94 if (priv->model == RCAR_GYROADC_MODEL_R8A7792)
95 writel(0, priv->regs + RCAR_GYROADC_INTENR);
98 writel(priv->mode, priv->regs + RCAR_GYROADC_MODE_SELECT);
99 writel(clk_len, priv->regs + RCAR_GYROADC_CLOCK_LENGTH);
100 writel(clk_mhz * 1250, priv->regs + RCAR_GYROADC_1_25MS_LENGTH);
103 static void rcar_gyroadc_hw_start(struct rcar_gyroadc *priv)
107 priv->regs + RCAR_GYROADC_START_STOP);
118 static void rcar_gyroadc_hw_stop(struct rcar_gyroadc *priv)
121 writel(0, priv->regs + RCAR_GYROADC_START_STOP);
162 static int rcar_gyroadc_set_power(struct rcar_gyroadc *priv, bool on)
164 struct device *dev = priv->dev;
178 struct rcar_gyroadc *priv = iio_priv(indio_dev);
188 if (priv->mode == RCAR_GYROADC_MODE_SELECT_1_MB88101A)
189 consumer = priv->vref[0];
191 consumer = priv->vref[chan->channel];
206 ret = rcar_gyroadc_set_power(priv, true);
212 *val = readl(priv->regs + datareg);
213 *val &= BIT(priv->sample_width) - 1;
215 ret = rcar_gyroadc_set_power(priv, false);
228 *val2 = 1 << priv->sample_width;
244 struct rcar_gyroadc *priv = iio_priv(indio_dev);
254 if (priv->model == RCAR_GYROADC_MODEL_R8A7792)
260 *readval = readl(priv->regs + reg);
318 struct rcar_gyroadc *priv = iio_priv(indio_dev);
319 struct device *dev = priv->dev;
401 priv->vref[reg] = vref;
410 priv->num_channels = num_channels;
411 priv->mode = childmode;
412 priv->sample_width = sample_width;
437 struct rcar_gyroadc *priv = iio_priv(indio_dev);
440 for (i = 0; i < priv->num_channels; i++) {
441 if (!priv->vref[i])
444 regulator_disable(priv->vref[i]);
450 struct rcar_gyroadc *priv = iio_priv(indio_dev);
451 struct device *dev = priv->dev;
455 for (i = 0; i < priv->num_channels; i++) {
456 if (!priv->vref[i])
459 ret = regulator_enable(priv->vref[i]);
477 struct rcar_gyroadc *priv;
481 indio_dev = devm_iio_device_alloc(dev, sizeof(*priv));
485 priv = iio_priv(indio_dev);
486 priv->dev = dev;
488 priv->regs = devm_platform_ioremap_resource(pdev, 0);
489 if (IS_ERR(priv->regs))
490 return PTR_ERR(priv->regs);
492 priv->clk = devm_clk_get(dev, "fck");
493 if (IS_ERR(priv->clk))
494 return dev_err_probe(dev, PTR_ERR(priv->clk),
505 priv->model = (uintptr_t)of_device_get_match_data(&pdev->dev);
513 ret = clk_prepare_enable(priv->clk);
527 rcar_gyroadc_hw_init(priv);
528 rcar_gyroadc_hw_start(priv);
541 rcar_gyroadc_hw_stop(priv);
546 clk_disable_unprepare(priv->clk);
556 struct rcar_gyroadc *priv = iio_priv(indio_dev);
557 struct device *dev = priv->dev;
561 rcar_gyroadc_hw_stop(priv);
565 clk_disable_unprepare(priv->clk);
572 struct rcar_gyroadc *priv = iio_priv(indio_dev);
574 rcar_gyroadc_hw_stop(priv);
582 struct rcar_gyroadc *priv = iio_priv(indio_dev);
584 rcar_gyroadc_hw_start(priv);