blob: 5ae401a409fd901c749238c7ac01a417f9fbc266 [file] [log] [blame]
Dhaval Patel83e27fc2013-12-19 14:52:24 -08001/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#ifndef __MDSS_PLL_H
14#define __MDSS_PLL_H
15
16#include <linux/mdss_io_util.h>
17#include <linux/io.h>
18
19#define MDSS_PLL_REG_W(base, offset, data) \
20 writel_relaxed((data), (base) + (offset))
21#define MDSS_PLL_REG_R(base, offset) readl_relaxed((base) + (offset))
22
23enum {
24 MDSS_DSI_PLL,
25 MDSS_EDP_PLL,
26 MDSS_HDMI_PLL,
27 MDSS_UNKNOWN_PLL,
28};
29
30struct mdss_pll_resources {
31
32 /* Pll specific resources like GPIO, power supply, clocks, etc*/
33 struct dss_module_power mp;
34
35 /* dsi/edp/hmdi plls' base register and phy register mapping */
36 void __iomem *pll_base;
37 void __iomem *phy_base;
38
39 /*
40 * Certain pll's needs to update the same vco rate after resume in
41 * suspend/resume scenario. Cached the vco rate for such plls.
42 */
43 unsigned long vco_cached_rate;
44
45 /* dsi/edp/hmdi pll interface type */
46 u32 pll_interface_type;
47
48 /*
49 * Keep track to resource status to avoid updating same status for the
50 * pll from different paths
51 */
52 bool resource_enable;
53
54 /*
55 * Certain plls' do not allow vco rate update if it is on. Keep track of
56 * status for them to turn on/off after set rate success.
57 */
58 bool pll_on;
59
60 /*
61 * handoff_status is true of pll is already enabled by bootloader with
62 * continuous splash enable case. Clock API will call the handoff API
63 * to enable the status. It is disabled if continuous splash
64 * feature is disabled.
65 */
66 bool handoff_resources;
67
68 /*
69 * Keep reference count of pll resource client to avoid releasing them
70 * before all clients are finished with their tasks
71 */
72 unsigned int resource_refcount;
73
74 /* Lock status to provide updated resource status to all clients */
75 struct mutex resource_lock;
76};
77
78int mdss_pll_resource_enable(struct mdss_pll_resources *pll_res, bool enable);
79int mdss_pll_util_resource_init(struct platform_device *pdev,
80 struct mdss_pll_resources *pll_res);
81void mdss_pll_util_resource_deinit(struct platform_device *pdev,
82 struct mdss_pll_resources *pll_res);
83void mdss_pll_util_resource_release(struct platform_device *pdev,
84 struct mdss_pll_resources *pll_res);
85int mdss_pll_util_resource_enable(struct mdss_pll_resources *pll_res,
86 bool enable);
87int mdss_pll_util_resource_parse(struct platform_device *pdev,
88 struct mdss_pll_resources *pll_res);
89#endif