hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/drivers/gpu/host1x/mipi.c
....@@ -21,9 +21,9 @@
2121 */
2222
2323 #include <linux/clk.h>
24
-#include <linux/delay.h>
2524 #include <linux/host1x.h>
2625 #include <linux/io.h>
26
+#include <linux/iopoll.h>
2727 #include <linux/of_platform.h>
2828 #include <linux/platform_device.h>
2929 #include <linux/slab.h>
....@@ -206,9 +206,9 @@
206206 return 0;
207207 }
208208
209
-struct tegra_mipi_device *tegra_mipi_request(struct device *device)
209
+struct tegra_mipi_device *tegra_mipi_request(struct device *device,
210
+ struct device_node *np)
210211 {
211
- struct device_node *np = device->of_node;
212212 struct tegra_mipi_device *dev;
213213 struct of_phandle_args args;
214214 int err;
....@@ -293,24 +293,25 @@
293293 }
294294 EXPORT_SYMBOL(tegra_mipi_disable);
295295
296
-static int tegra_mipi_wait(struct tegra_mipi *mipi)
296
+int tegra_mipi_finish_calibration(struct tegra_mipi_device *device)
297297 {
298
- unsigned long timeout = jiffies + msecs_to_jiffies(250);
298
+ struct tegra_mipi *mipi = device->mipi;
299
+ void __iomem *status_reg = mipi->regs + (MIPI_CAL_STATUS << 2);
299300 u32 value;
301
+ int err;
300302
301
- while (time_before(jiffies, timeout)) {
302
- value = tegra_mipi_readl(mipi, MIPI_CAL_STATUS);
303
- if ((value & MIPI_CAL_STATUS_ACTIVE) == 0 &&
304
- (value & MIPI_CAL_STATUS_DONE) != 0)
305
- return 0;
303
+ err = readl_relaxed_poll_timeout(status_reg, value,
304
+ !(value & MIPI_CAL_STATUS_ACTIVE) &&
305
+ (value & MIPI_CAL_STATUS_DONE), 50,
306
+ 250000);
307
+ mutex_unlock(&device->mipi->lock);
308
+ clk_disable(device->mipi->clk);
306309
307
- usleep_range(10, 50);
308
- }
309
-
310
- return -ETIMEDOUT;
310
+ return err;
311311 }
312
+EXPORT_SYMBOL(tegra_mipi_finish_calibration);
312313
313
-int tegra_mipi_calibrate(struct tegra_mipi_device *device)
314
+int tegra_mipi_start_calibration(struct tegra_mipi_device *device)
314315 {
315316 const struct tegra_mipi_soc *soc = device->mipi->soc;
316317 unsigned int i;
....@@ -374,14 +375,16 @@
374375 value |= MIPI_CAL_CTRL_START;
375376 tegra_mipi_writel(device->mipi, value, MIPI_CAL_CTRL);
376377
377
- err = tegra_mipi_wait(device->mipi);
378
+ /*
379
+ * Wait for min 72uS to let calibration logic finish calibration
380
+ * sequence codes before waiting for pads idle state to apply the
381
+ * results.
382
+ */
383
+ usleep_range(75, 80);
378384
379
- mutex_unlock(&device->mipi->lock);
380
- clk_disable(device->mipi->clk);
381
-
382
- return err;
385
+ return 0;
383386 }
384
-EXPORT_SYMBOL(tegra_mipi_calibrate);
387
+EXPORT_SYMBOL(tegra_mipi_start_calibration);
385388
386389 static const struct tegra_mipi_pad tegra114_mipi_pads[] = {
387390 { .data = MIPI_CAL_CONFIG_CSIA },