forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/drivers/iio/dac/vf610_dac.c
....@@ -1,17 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * Freescale Vybrid vf610 DAC driver
34 *
45 * 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.
156 */
167
178 #include <linux/clk.h>
....@@ -45,6 +36,7 @@
4536 struct device *dev;
4637 enum vf610_conversion_mode_sel conv_mode;
4738 void __iomem *regs;
39
+ struct mutex lock;
4840 };
4941
5042 static void vf610_dac_init(struct vf610_dac *info)
....@@ -73,7 +65,7 @@
7365 struct vf610_dac *info = iio_priv(indio_dev);
7466 int val;
7567
76
- mutex_lock(&indio_dev->mlock);
68
+ mutex_lock(&info->lock);
7769 info->conv_mode = mode;
7870 val = readl(info->regs + VF610_DACx_STATCTRL);
7971 if (mode)
....@@ -81,7 +73,7 @@
8173 else
8274 val &= ~VF610_DAC_LPEN;
8375 writel(val, info->regs + VF610_DACx_STATCTRL);
84
- mutex_unlock(&indio_dev->mlock);
76
+ mutex_unlock(&info->lock);
8577
8678 return 0;
8779 }
....@@ -156,9 +148,9 @@
156148
157149 switch (mask) {
158150 case IIO_CHAN_INFO_RAW:
159
- mutex_lock(&indio_dev->mlock);
151
+ mutex_lock(&info->lock);
160152 writel(VF610_DAC_DAT0(val), info->regs);
161
- mutex_unlock(&indio_dev->mlock);
153
+ mutex_unlock(&info->lock);
162154 return 0;
163155
164156 default:
....@@ -181,7 +173,6 @@
181173 {
182174 struct iio_dev *indio_dev;
183175 struct vf610_dac *info;
184
- struct resource *mem;
185176 int ret;
186177
187178 indio_dev = devm_iio_device_alloc(&pdev->dev,
....@@ -194,8 +185,7 @@
194185 info = iio_priv(indio_dev);
195186 info->dev = &pdev->dev;
196187
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);
199189 if (IS_ERR(info->regs))
200190 return PTR_ERR(info->regs);
201191
....@@ -209,13 +199,13 @@
209199 platform_set_drvdata(pdev, indio_dev);
210200
211201 indio_dev->name = dev_name(&pdev->dev);
212
- indio_dev->dev.parent = &pdev->dev;
213
- indio_dev->dev.of_node = pdev->dev.of_node;
214202 indio_dev->info = &vf610_dac_iio_info;
215203 indio_dev->modes = INDIO_DIRECT_MODE;
216204 indio_dev->channels = vf610_dac_iio_channels;
217205 indio_dev->num_channels = ARRAY_SIZE(vf610_dac_iio_channels);
218206
207
+ mutex_init(&info->lock);
208
+
219209 ret = clk_prepare_enable(info->clk);
220210 if (ret) {
221211 dev_err(&pdev->dev,