blob: 6bd5c168ecd84c7003aec564c2755cb5b8858d4a [file] [log] [blame]
Dhaval Patel1ac91032016-09-26 19:25:39 -07001/* Copyright (c) 2012, 2017, 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 __SDE_IO_UTIL_H__
14#define __SDE_IO_UTIL_H__
15
16#include <linux/gpio.h>
17#include <linux/platform_device.h>
18#include <linux/regulator/consumer.h>
19#include <linux/i2c.h>
20#include <linux/types.h>
21
22#ifdef DEBUG
23#define DEV_DBG(fmt, args...) pr_err(fmt, ##args)
24#else
25#define DEV_DBG(fmt, args...) pr_debug(fmt, ##args)
26#endif
27#define DEV_INFO(fmt, args...) pr_info(fmt, ##args)
28#define DEV_WARN(fmt, args...) pr_warn(fmt, ##args)
29#define DEV_ERR(fmt, args...) pr_err(fmt, ##args)
30
31struct dss_io_data {
32 u32 len;
33 void __iomem *base;
34};
35
36void dss_reg_w(struct dss_io_data *io, u32 offset, u32 value, u32 debug);
37u32 dss_reg_r(struct dss_io_data *io, u32 offset, u32 debug);
38void dss_reg_dump(void __iomem *base, u32 len, const char *prefix, u32 debug);
39
40#define DSS_REG_W_ND(io, offset, val) dss_reg_w(io, offset, val, false)
41#define DSS_REG_W(io, offset, val) dss_reg_w(io, offset, val, true)
42#define DSS_REG_R_ND(io, offset) dss_reg_r(io, offset, false)
43#define DSS_REG_R(io, offset) dss_reg_r(io, offset, true)
44
45enum dss_vreg_type {
46 DSS_REG_LDO,
47 DSS_REG_VS,
48};
49
50struct dss_vreg {
51 struct regulator *vreg; /* vreg handle */
52 char vreg_name[32];
53 int min_voltage;
54 int max_voltage;
55 int enable_load;
56 int disable_load;
57 int pre_on_sleep;
58 int post_on_sleep;
59 int pre_off_sleep;
60 int post_off_sleep;
61};
62
63struct dss_gpio {
64 unsigned int gpio;
65 unsigned int value;
66 char gpio_name[32];
67};
68
69enum dss_clk_type {
70 DSS_CLK_AHB, /* no set rate. rate controlled through rpm */
71 DSS_CLK_PCLK,
72 DSS_CLK_OTHER,
73};
74
75struct dss_clk {
76 struct clk *clk; /* clk handle */
77 char clk_name[32];
78 enum dss_clk_type type;
79 unsigned long rate;
80 unsigned long max_rate;
81};
82
83struct dss_module_power {
84 unsigned int num_vreg;
85 struct dss_vreg *vreg_config;
86 unsigned int num_gpio;
87 struct dss_gpio *gpio_config;
88 unsigned int num_clk;
89 struct dss_clk *clk_config;
90};
91
92int msm_dss_ioremap_byname(struct platform_device *pdev,
93 struct dss_io_data *io_data, const char *name);
94void msm_dss_iounmap(struct dss_io_data *io_data);
95
96int msm_dss_enable_gpio(struct dss_gpio *in_gpio, int num_gpio, int enable);
97int msm_dss_gpio_enable(struct dss_gpio *in_gpio, int num_gpio, int enable);
98
99int msm_dss_config_vreg(struct device *dev, struct dss_vreg *in_vreg,
100 int num_vreg, int config);
101int msm_dss_enable_vreg(struct dss_vreg *in_vreg, int num_vreg, int enable);
102
103int msm_dss_get_clk(struct device *dev, struct dss_clk *clk_arry, int num_clk);
104void msm_dss_put_clk(struct dss_clk *clk_arry, int num_clk);
105int msm_dss_clk_set_rate(struct dss_clk *clk_arry, int num_clk);
106int msm_dss_enable_clk(struct dss_clk *clk_arry, int num_clk, int enable);
107
108int sde_i2c_byte_read(struct i2c_client *client, uint8_t slave_addr,
109 uint8_t reg_offset, uint8_t *read_buf);
110int sde_i2c_byte_write(struct i2c_client *client, uint8_t slave_addr,
111 uint8_t reg_offset, uint8_t *value);
112
113#endif /* __SDE_IO_UTIL_H__ */