.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * Freescale Vybrid vf610 DAC driver |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright 2016 Toradex AG |
---|
5 | | - * |
---|
6 | | - * This program is free software; you can redistribute it and/or modify |
---|
7 | | - * it under the terms of the GNU General Public License as published by |
---|
8 | | - * the Free Software Foundation; either version 2 of the License, or |
---|
9 | | - * (at your option) any later version. |
---|
10 | | - * |
---|
11 | | - * This program is distributed in the hope that it will be useful, |
---|
12 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | | - * GNU General Public License for more details. |
---|
15 | 6 | */ |
---|
16 | 7 | |
---|
17 | 8 | #include <linux/clk.h> |
---|
.. | .. |
---|
45 | 36 | struct device *dev; |
---|
46 | 37 | enum vf610_conversion_mode_sel conv_mode; |
---|
47 | 38 | void __iomem *regs; |
---|
| 39 | + struct mutex lock; |
---|
48 | 40 | }; |
---|
49 | 41 | |
---|
50 | 42 | static void vf610_dac_init(struct vf610_dac *info) |
---|
.. | .. |
---|
73 | 65 | struct vf610_dac *info = iio_priv(indio_dev); |
---|
74 | 66 | int val; |
---|
75 | 67 | |
---|
76 | | - mutex_lock(&indio_dev->mlock); |
---|
| 68 | + mutex_lock(&info->lock); |
---|
77 | 69 | info->conv_mode = mode; |
---|
78 | 70 | val = readl(info->regs + VF610_DACx_STATCTRL); |
---|
79 | 71 | if (mode) |
---|
.. | .. |
---|
81 | 73 | else |
---|
82 | 74 | val &= ~VF610_DAC_LPEN; |
---|
83 | 75 | writel(val, info->regs + VF610_DACx_STATCTRL); |
---|
84 | | - mutex_unlock(&indio_dev->mlock); |
---|
| 76 | + mutex_unlock(&info->lock); |
---|
85 | 77 | |
---|
86 | 78 | return 0; |
---|
87 | 79 | } |
---|
.. | .. |
---|
156 | 148 | |
---|
157 | 149 | switch (mask) { |
---|
158 | 150 | case IIO_CHAN_INFO_RAW: |
---|
159 | | - mutex_lock(&indio_dev->mlock); |
---|
| 151 | + mutex_lock(&info->lock); |
---|
160 | 152 | writel(VF610_DAC_DAT0(val), info->regs); |
---|
161 | | - mutex_unlock(&indio_dev->mlock); |
---|
| 153 | + mutex_unlock(&info->lock); |
---|
162 | 154 | return 0; |
---|
163 | 155 | |
---|
164 | 156 | default: |
---|
.. | .. |
---|
181 | 173 | { |
---|
182 | 174 | struct iio_dev *indio_dev; |
---|
183 | 175 | struct vf610_dac *info; |
---|
184 | | - struct resource *mem; |
---|
185 | 176 | int ret; |
---|
186 | 177 | |
---|
187 | 178 | indio_dev = devm_iio_device_alloc(&pdev->dev, |
---|
.. | .. |
---|
194 | 185 | info = iio_priv(indio_dev); |
---|
195 | 186 | info->dev = &pdev->dev; |
---|
196 | 187 | |
---|
197 | | - mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
---|
198 | | - info->regs = devm_ioremap_resource(&pdev->dev, mem); |
---|
| 188 | + info->regs = devm_platform_ioremap_resource(pdev, 0); |
---|
199 | 189 | if (IS_ERR(info->regs)) |
---|
200 | 190 | return PTR_ERR(info->regs); |
---|
201 | 191 | |
---|
.. | .. |
---|
209 | 199 | platform_set_drvdata(pdev, indio_dev); |
---|
210 | 200 | |
---|
211 | 201 | indio_dev->name = dev_name(&pdev->dev); |
---|
212 | | - indio_dev->dev.parent = &pdev->dev; |
---|
213 | | - indio_dev->dev.of_node = pdev->dev.of_node; |
---|
214 | 202 | indio_dev->info = &vf610_dac_iio_info; |
---|
215 | 203 | indio_dev->modes = INDIO_DIRECT_MODE; |
---|
216 | 204 | indio_dev->channels = vf610_dac_iio_channels; |
---|
217 | 205 | indio_dev->num_channels = ARRAY_SIZE(vf610_dac_iio_channels); |
---|
218 | 206 | |
---|
| 207 | + mutex_init(&info->lock); |
---|
| 208 | + |
---|
219 | 209 | ret = clk_prepare_enable(info->clk); |
---|
220 | 210 | if (ret) { |
---|
221 | 211 | dev_err(&pdev->dev, |
---|