Lines Matching +full:tegra114 +full:- +full:mipi
131 struct tegra_mipi *mipi; member
136 static inline u32 tegra_mipi_readl(struct tegra_mipi *mipi, in tegra_mipi_readl() argument
139 return readl(mipi->regs + (offset << 2)); in tegra_mipi_readl()
142 static inline void tegra_mipi_writel(struct tegra_mipi *mipi, u32 value, in tegra_mipi_writel() argument
145 writel(value, mipi->regs + (offset << 2)); in tegra_mipi_writel()
148 static int tegra_mipi_power_up(struct tegra_mipi *mipi) in tegra_mipi_power_up() argument
153 err = clk_enable(mipi->clk); in tegra_mipi_power_up()
157 value = tegra_mipi_readl(mipi, MIPI_CAL_BIAS_PAD_CFG0); in tegra_mipi_power_up()
160 if (mipi->soc->needs_vclamp_ref) in tegra_mipi_power_up()
163 tegra_mipi_writel(mipi, value, MIPI_CAL_BIAS_PAD_CFG0); in tegra_mipi_power_up()
165 value = tegra_mipi_readl(mipi, MIPI_CAL_BIAS_PAD_CFG2); in tegra_mipi_power_up()
167 tegra_mipi_writel(mipi, value, MIPI_CAL_BIAS_PAD_CFG2); in tegra_mipi_power_up()
169 clk_disable(mipi->clk); in tegra_mipi_power_up()
174 static int tegra_mipi_power_down(struct tegra_mipi *mipi) in tegra_mipi_power_down() argument
179 err = clk_enable(mipi->clk); in tegra_mipi_power_down()
188 value = tegra_mipi_readl(mipi, MIPI_CAL_BIAS_PAD_CFG2); in tegra_mipi_power_down()
190 tegra_mipi_writel(mipi, value, MIPI_CAL_BIAS_PAD_CFG2); in tegra_mipi_power_down()
194 * control a regulator that supplies current to the pre-driver logic. in tegra_mipi_power_down()
198 value = tegra_mipi_readl(mipi, MIPI_CAL_BIAS_PAD_CFG0); in tegra_mipi_power_down()
200 if (mipi->soc->needs_vclamp_ref) in tegra_mipi_power_down()
204 tegra_mipi_writel(mipi, value, MIPI_CAL_BIAS_PAD_CFG0); in tegra_mipi_power_down()
216 err = of_parse_phandle_with_args(np, "nvidia,mipi-calibrate", in tegra_mipi_request()
217 "#nvidia,mipi-calibrate-cells", 0, in tegra_mipi_request()
224 err = -ENOMEM; in tegra_mipi_request()
228 dev->pdev = of_find_device_by_node(args.np); in tegra_mipi_request()
229 if (!dev->pdev) { in tegra_mipi_request()
230 err = -ENODEV; in tegra_mipi_request()
234 dev->mipi = platform_get_drvdata(dev->pdev); in tegra_mipi_request()
235 if (!dev->mipi) { in tegra_mipi_request()
236 err = -EPROBE_DEFER; in tegra_mipi_request()
242 dev->pads = args.args[0]; in tegra_mipi_request()
243 dev->device = device; in tegra_mipi_request()
248 platform_device_put(dev->pdev); in tegra_mipi_request()
259 platform_device_put(device->pdev); in tegra_mipi_free()
268 mutex_lock(&dev->mipi->lock); in tegra_mipi_enable()
270 if (dev->mipi->usage_count++ == 0) in tegra_mipi_enable()
271 err = tegra_mipi_power_up(dev->mipi); in tegra_mipi_enable()
273 mutex_unlock(&dev->mipi->lock); in tegra_mipi_enable()
284 mutex_lock(&dev->mipi->lock); in tegra_mipi_disable()
286 if (--dev->mipi->usage_count == 0) in tegra_mipi_disable()
287 err = tegra_mipi_power_down(dev->mipi); in tegra_mipi_disable()
289 mutex_unlock(&dev->mipi->lock); in tegra_mipi_disable()
298 struct tegra_mipi *mipi = device->mipi; in tegra_mipi_finish_calibration() local
299 void __iomem *status_reg = mipi->regs + (MIPI_CAL_STATUS << 2); in tegra_mipi_finish_calibration()
307 mutex_unlock(&device->mipi->lock); in tegra_mipi_finish_calibration()
308 clk_disable(device->mipi->clk); in tegra_mipi_finish_calibration()
316 const struct tegra_mipi_soc *soc = device->mipi->soc; in tegra_mipi_start_calibration()
321 err = clk_enable(device->mipi->clk); in tegra_mipi_start_calibration()
325 mutex_lock(&device->mipi->lock); in tegra_mipi_start_calibration()
327 value = MIPI_CAL_BIAS_PAD_DRV_DN_REF(soc->pad_drive_down_ref) | in tegra_mipi_start_calibration()
328 MIPI_CAL_BIAS_PAD_DRV_UP_REF(soc->pad_drive_up_ref); in tegra_mipi_start_calibration()
329 tegra_mipi_writel(device->mipi, value, MIPI_CAL_BIAS_PAD_CFG1); in tegra_mipi_start_calibration()
331 value = tegra_mipi_readl(device->mipi, MIPI_CAL_BIAS_PAD_CFG2); in tegra_mipi_start_calibration()
334 value |= MIPI_CAL_BIAS_PAD_VCLAMP(soc->pad_vclamp_level); in tegra_mipi_start_calibration()
335 value |= MIPI_CAL_BIAS_PAD_VAUXP(soc->pad_vauxp_level); in tegra_mipi_start_calibration()
336 tegra_mipi_writel(device->mipi, value, MIPI_CAL_BIAS_PAD_CFG2); in tegra_mipi_start_calibration()
338 for (i = 0; i < soc->num_pads; i++) { in tegra_mipi_start_calibration()
341 if (device->pads & BIT(i)) { in tegra_mipi_start_calibration()
343 MIPI_CAL_CONFIG_HSPDOS(soc->hspdos) | in tegra_mipi_start_calibration()
344 MIPI_CAL_CONFIG_HSPUOS(soc->hspuos) | in tegra_mipi_start_calibration()
345 MIPI_CAL_CONFIG_TERMOS(soc->termos); in tegra_mipi_start_calibration()
347 MIPI_CAL_CONFIG_HSCLKPDOSD(soc->hsclkpdos) | in tegra_mipi_start_calibration()
348 MIPI_CAL_CONFIG_HSCLKPUOSD(soc->hsclkpuos); in tegra_mipi_start_calibration()
351 tegra_mipi_writel(device->mipi, data, soc->pads[i].data); in tegra_mipi_start_calibration()
353 if (soc->has_clk_lane && soc->pads[i].clk != 0) in tegra_mipi_start_calibration()
354 tegra_mipi_writel(device->mipi, clk, soc->pads[i].clk); in tegra_mipi_start_calibration()
357 value = tegra_mipi_readl(device->mipi, MIPI_CAL_CTRL); in tegra_mipi_start_calibration()
363 if (!soc->clock_enable_override) in tegra_mipi_start_calibration()
368 tegra_mipi_writel(device->mipi, value, MIPI_CAL_CTRL); in tegra_mipi_start_calibration()
371 value = tegra_mipi_readl(device->mipi, MIPI_CAL_STATUS); in tegra_mipi_start_calibration()
372 tegra_mipi_writel(device->mipi, value, MIPI_CAL_STATUS); in tegra_mipi_start_calibration()
374 value = tegra_mipi_readl(device->mipi, MIPI_CAL_CTRL); in tegra_mipi_start_calibration()
376 tegra_mipi_writel(device->mipi, value, MIPI_CAL_CTRL); in tegra_mipi_start_calibration()
493 { .compatible = "nvidia,tegra114-mipi", .data = &tegra114_mipi_soc },
494 { .compatible = "nvidia,tegra124-mipi", .data = &tegra124_mipi_soc },
495 { .compatible = "nvidia,tegra132-mipi", .data = &tegra132_mipi_soc },
496 { .compatible = "nvidia,tegra210-mipi", .data = &tegra210_mipi_soc },
503 struct tegra_mipi *mipi; in tegra_mipi_probe() local
505 match = of_match_node(tegra_mipi_of_match, pdev->dev.of_node); in tegra_mipi_probe()
507 return -ENODEV; in tegra_mipi_probe()
509 mipi = devm_kzalloc(&pdev->dev, sizeof(*mipi), GFP_KERNEL); in tegra_mipi_probe()
510 if (!mipi) in tegra_mipi_probe()
511 return -ENOMEM; in tegra_mipi_probe()
513 mipi->soc = match->data; in tegra_mipi_probe()
514 mipi->dev = &pdev->dev; in tegra_mipi_probe()
516 mipi->regs = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); in tegra_mipi_probe()
517 if (IS_ERR(mipi->regs)) in tegra_mipi_probe()
518 return PTR_ERR(mipi->regs); in tegra_mipi_probe()
520 mutex_init(&mipi->lock); in tegra_mipi_probe()
522 mipi->clk = devm_clk_get_prepared(&pdev->dev, NULL); in tegra_mipi_probe()
523 if (IS_ERR(mipi->clk)) { in tegra_mipi_probe()
524 dev_err(&pdev->dev, "failed to get clock\n"); in tegra_mipi_probe()
525 return PTR_ERR(mipi->clk); in tegra_mipi_probe()
528 platform_set_drvdata(pdev, mipi); in tegra_mipi_probe()
535 .name = "tegra-mipi",