mdss_io_util.h 3.3 KB

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