]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - arch/arm/plat-samsung/setup-mipiphy.c
Merge remote-tracking branch 'spi/topic/mxs' into spi-next
[mirror_ubuntu-bionic-kernel.git] / arch / arm / plat-samsung / setup-mipiphy.c
CommitLineData
1d45ac49
SN
1/*
2 * Copyright (C) 2011 Samsung Electronics Co., Ltd.
3 *
4 * S5P - Helper functions for MIPI-CSIS and MIPI-DSIM D-PHY control
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 version 2 as
8 * published by the Free Software Foundation.
9 */
10
30da66ea 11#include <linux/export.h>
1d45ac49
SN
12#include <linux/kernel.h>
13#include <linux/platform_device.h>
14#include <linux/io.h>
15#include <linux/spinlock.h>
16#include <mach/regs-clock.h>
17
69a3d4f7 18static int __s5p_mipi_phy_control(int id, bool on, u32 reset)
1d45ac49
SN
19{
20 static DEFINE_SPINLOCK(lock);
21 void __iomem *addr;
22 unsigned long flags;
1d45ac49
SN
23 u32 cfg;
24
69a3d4f7
SN
25 id = max(0, id);
26 if (id > 1)
1d45ac49
SN
27 return -EINVAL;
28
69a3d4f7 29 addr = S5P_MIPI_DPHY_CONTROL(id);
1d45ac49
SN
30
31 spin_lock_irqsave(&lock, flags);
32
33 cfg = __raw_readl(addr);
34 cfg = on ? (cfg | reset) : (cfg & ~reset);
35 __raw_writel(cfg, addr);
36
37 if (on) {
38 cfg |= S5P_MIPI_DPHY_ENABLE;
39 } else if (!(cfg & (S5P_MIPI_DPHY_SRESETN |
40 S5P_MIPI_DPHY_MRESETN) & ~reset)) {
41 cfg &= ~S5P_MIPI_DPHY_ENABLE;
42 }
43
44 __raw_writel(cfg, addr);
45 spin_unlock_irqrestore(&lock, flags);
46
47 return 0;
48}
49
69a3d4f7 50int s5p_csis_phy_enable(int id, bool on)
1d45ac49 51{
69a3d4f7 52 return __s5p_mipi_phy_control(id, on, S5P_MIPI_DPHY_SRESETN);
1d45ac49 53}
30da66ea 54EXPORT_SYMBOL(s5p_csis_phy_enable);
1d45ac49
SN
55
56int s5p_dsim_phy_enable(struct platform_device *pdev, bool on)
57{
69a3d4f7 58 return __s5p_mipi_phy_control(pdev->id, on, S5P_MIPI_DPHY_MRESETN);
1d45ac49 59}
30da66ea 60EXPORT_SYMBOL(s5p_dsim_phy_enable);