Rob Clark | c8afe68 | 2013-06-26 12:44:06 -0400 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2013 Red Hat |
| 3 | * Author: Rob Clark <robdclark@gmail.com> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of the GNU General Public License version 2 as published by |
| 7 | * the Free Software Foundation. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 12 | * more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License along with |
| 15 | * this program. If not, see <http://www.gnu.org/licenses/>. |
| 16 | */ |
| 17 | |
| 18 | #ifndef __HDMI_CONNECTOR_H__ |
| 19 | #define __HDMI_CONNECTOR_H__ |
| 20 | |
| 21 | #include <linux/i2c.h> |
| 22 | #include <linux/clk.h> |
| 23 | #include <linux/platform_device.h> |
| 24 | #include <linux/regulator/consumer.h> |
| 25 | |
| 26 | #include "msm_drv.h" |
| 27 | #include "hdmi.xml.h" |
| 28 | |
| 29 | |
| 30 | struct hdmi_phy; |
| 31 | |
| 32 | struct hdmi { |
| 33 | struct drm_device *dev; |
| 34 | struct platform_device *pdev; |
| 35 | |
| 36 | void __iomem *mmio; |
| 37 | |
| 38 | struct regulator *mvs; /* HDMI_5V */ |
| 39 | struct regulator *mpp0; /* External 5V */ |
| 40 | |
| 41 | struct clk *clk; |
| 42 | struct clk *m_pclk; |
| 43 | struct clk *s_pclk; |
| 44 | |
| 45 | struct hdmi_phy *phy; |
| 46 | struct i2c_adapter *i2c; |
| 47 | struct drm_connector *connector; |
| 48 | |
| 49 | bool hdmi_mode; /* are we in hdmi mode? */ |
| 50 | |
| 51 | int irq; |
| 52 | }; |
| 53 | |
| 54 | /* platform config data (ie. from DT, or pdata) */ |
| 55 | struct hdmi_platform_config { |
| 56 | struct hdmi_phy *(*phy_init)(struct hdmi *hdmi); |
| 57 | int ddc_clk_gpio, ddc_data_gpio, hpd_gpio, pmic_gpio; |
| 58 | }; |
| 59 | |
| 60 | void hdmi_set_mode(struct hdmi *hdmi, bool power_on); |
| 61 | void hdmi_destroy(struct hdmi *hdmi); |
| 62 | int hdmi_init(struct hdmi *hdmi, struct drm_device *dev, |
| 63 | struct drm_connector *connector); |
| 64 | |
| 65 | static inline void hdmi_write(struct hdmi *hdmi, u32 reg, u32 data) |
| 66 | { |
| 67 | msm_writel(data, hdmi->mmio + reg); |
| 68 | } |
| 69 | |
| 70 | static inline u32 hdmi_read(struct hdmi *hdmi, u32 reg) |
| 71 | { |
| 72 | return msm_readl(hdmi->mmio + reg); |
| 73 | } |
| 74 | |
| 75 | /* |
| 76 | * The phy appears to be different, for example between 8960 and 8x60, |
| 77 | * so split the phy related functions out and load the correct one at |
| 78 | * runtime: |
| 79 | */ |
| 80 | |
| 81 | struct hdmi_phy_funcs { |
| 82 | void (*destroy)(struct hdmi_phy *phy); |
| 83 | void (*reset)(struct hdmi_phy *phy); |
| 84 | void (*powerup)(struct hdmi_phy *phy, unsigned long int pixclock); |
| 85 | void (*powerdown)(struct hdmi_phy *phy); |
| 86 | }; |
| 87 | |
| 88 | struct hdmi_phy { |
| 89 | const struct hdmi_phy_funcs *funcs; |
| 90 | }; |
| 91 | |
| 92 | /* |
| 93 | * phy can be different on different generations: |
| 94 | */ |
| 95 | struct hdmi_phy *hdmi_phy_8960_init(struct hdmi *hdmi); |
| 96 | struct hdmi_phy *hdmi_phy_8x60_init(struct hdmi *hdmi); |
| 97 | |
| 98 | /* |
| 99 | * hdmi connector: |
| 100 | */ |
| 101 | |
| 102 | void hdmi_connector_irq(struct drm_connector *connector); |
| 103 | |
| 104 | /* |
| 105 | * i2c adapter for ddc: |
| 106 | */ |
| 107 | |
| 108 | void hdmi_i2c_irq(struct i2c_adapter *i2c); |
| 109 | void hdmi_i2c_destroy(struct i2c_adapter *i2c); |
| 110 | struct i2c_adapter *hdmi_i2c_init(struct hdmi *hdmi); |
| 111 | |
| 112 | #endif /* __HDMI_CONNECTOR_H__ */ |